diff --git a/Cargo.lock b/Cargo.lock index e75a89befa..e59d7a7bcd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -455,7 +455,7 @@ dependencies = [ [[package]] name = "fuzz" -version = "0.12.1" +version = "0.12.2" dependencies = [ "libfuzzer-sys", "neqo-common", @@ -811,7 +811,7 @@ dependencies = [ [[package]] name = "neqo-bin" -version = "0.12.1" +version = "0.12.2" dependencies = [ "clap", "clap-verbosity-flag", @@ -834,7 +834,7 @@ dependencies = [ [[package]] name = "neqo-common" -version = "0.12.1" +version = "0.12.2" dependencies = [ "criterion", "enum-map", @@ -850,7 +850,7 @@ dependencies = [ [[package]] name = "neqo-crypto" -version = "0.12.1" +version = "0.12.2" dependencies = [ "bindgen", "log", @@ -865,7 +865,7 @@ dependencies = [ [[package]] name = "neqo-http3" -version = "0.12.1" +version = "0.12.2" dependencies = [ "enumset", "log", @@ -882,7 +882,7 @@ dependencies = [ [[package]] name = "neqo-qpack" -version = "0.12.1" +version = "0.12.2" dependencies = [ "log", "neqo-common", @@ -894,7 +894,7 @@ dependencies = [ [[package]] name = "neqo-transport" -version = "0.12.1" +version = "0.12.2" dependencies = [ "criterion", "enum-map", @@ -912,7 +912,7 @@ dependencies = [ [[package]] name = "neqo-udp" -version = "0.12.1" +version = "0.12.2" dependencies = [ "cfg_aliases", "log", @@ -1227,7 +1227,7 @@ dependencies = [ [[package]] name = "test-fixture" -version = "0.12.1" +version = "0.12.2" dependencies = [ "log", "neqo-common", diff --git a/Cargo.toml b/Cargo.toml index 3bd4d6c00d..d002ab4369 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ description = "Neqo, the Mozilla implementation of QUIC in Rust." keywords = ["quic", "http3", "neqo", "mozilla", "ietf", "firefox"] categories = ["network-programming", "web-programming"] readme = "README.md" -version = "0.12.1" +version = "0.12.2" # Keep in sync with `.rustfmt.toml` `edition`. edition = "2021" license = "MIT OR Apache-2.0" diff --git a/neqo-transport/src/ecn.rs b/neqo-transport/src/ecn.rs index 83878005f5..f23cb4e9dd 100644 --- a/neqo-transport/src/ecn.rs +++ b/neqo-transport/src/ecn.rs @@ -16,7 +16,7 @@ use crate::{ }; /// The number of packets to use for testing a path for ECN capability. -pub const TEST_COUNT: usize = 10; +pub(crate) const TEST_COUNT: usize = 10; /// The number of packets to use for testing a path for ECN capability when exchanging /// Initials during the handshake. This is a lower number than [`TEST_COUNT`] to avoid @@ -97,12 +97,14 @@ impl DerefMut for Count { } impl Count { + #[must_use] pub const fn new(not_ect: u64, ect0: u64, ect1: u64, ce: u64) -> Self { // Yes, the enum array order is different from the argument order. Self(EnumMap::from_array([not_ect, ect1, ect0, ce])) } /// Whether any of the ECN counts are non-zero. + #[must_use] pub fn is_some(&self) -> bool { self[IpTosEcn::Ect0] > 0 || self[IpTosEcn::Ect1] > 0 || self[IpTosEcn::Ce] > 0 } @@ -158,7 +160,7 @@ pub enum ValidationOutcome { } #[derive(Debug, Default)] -pub struct Info { +pub(crate) struct Info { /// The current state of ECN validation on this path. state: ValidationState, @@ -171,12 +173,12 @@ pub struct Info { impl Info { /// Set the baseline (= the ECN counts from the last ACK Frame). - pub fn set_baseline(&mut self, baseline: Count) { + pub(crate) fn set_baseline(&mut self, baseline: Count) { self.baseline = baseline; } /// Expose the current baseline. - pub const fn baseline(&self) -> Count { + pub(crate) const fn baseline(&self) -> Count { self.baseline } @@ -184,7 +186,7 @@ impl Info { /// Exit ECN validation if the number of packets sent exceeds `TEST_COUNT`. /// We do not implement the part of the RFC that says to exit ECN validation if the time since /// the start of ECN validation exceeds 3 * PTO, since this seems to happen much too quickly. - pub fn on_packet_sent(&mut self, stats: &mut Stats) { + pub(crate) fn on_packet_sent(&mut self, stats: &mut Stats) { if let ValidationState::Testing { probes_sent, .. } = &mut self.state { *probes_sent += 1; qdebug!("ECN probing: sent {probes_sent} probes"); @@ -196,14 +198,14 @@ impl Info { } /// Disable ECN. - pub fn disable_ecn(&mut self, stats: &mut Stats, reason: ValidationError) { + pub(crate) fn disable_ecn(&mut self, stats: &mut Stats, reason: ValidationError) { self.state.set(ValidationState::Failed(reason), stats); } /// Process ECN counts from an ACK frame. /// /// Returns whether ECN counts contain new valid ECN CE marks. - pub fn on_packets_acked( + pub(crate) fn on_packets_acked( &mut self, acked_packets: &[SentPacket], ack_ecn: Option, @@ -217,7 +219,7 @@ impl Info { && (self.baseline - prev_baseline)[IpTosEcn::Ce] > 0 } - pub fn on_packets_lost(&mut self, lost_packets: &[SentPacket], stats: &mut Stats) { + pub(crate) fn on_packets_lost(&mut self, lost_packets: &[SentPacket], stats: &mut Stats) { if let ValidationState::Testing { probes_sent, initial_probes_lost: probes_lost, @@ -239,7 +241,7 @@ impl Info { } /// After the ECN validation test has ended, check if the path is ECN capable. - pub fn validate_ack_ecn_and_update( + pub(crate) fn validate_ack_ecn_and_update( &mut self, acked_packets: &[SentPacket], ack_ecn: Option, @@ -316,7 +318,7 @@ impl Info { } /// The ECN mark to use for packets sent on this path. - pub const fn ecn_mark(&self) -> IpTosEcn { + pub(crate) const fn ecn_mark(&self) -> IpTosEcn { match self.state { ValidationState::Testing { .. } | ValidationState::Capable => IpTosEcn::Ect0, ValidationState::Failed(_) | ValidationState::Unknown => IpTosEcn::NotEct, diff --git a/neqo-transport/src/lib.rs b/neqo-transport/src/lib.rs index 49dd3470f1..d157f04300 100644 --- a/neqo-transport/src/lib.rs +++ b/neqo-transport/src/lib.rs @@ -13,7 +13,7 @@ mod cc; mod cid; mod connection; mod crypto; -mod ecn; +pub mod ecn; mod events; mod fc; #[cfg(fuzzing)] diff --git a/neqo-transport/tests/stats.rs b/neqo-transport/tests/stats.rs new file mode 100644 index 0000000000..c8e6e657f2 --- /dev/null +++ b/neqo-transport/tests/stats.rs @@ -0,0 +1,16 @@ +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use neqo_transport::ecn; + +#[test] +fn crate_exports_ecn_types() { + let stats = neqo_transport::Stats::default(); + + let _ = stats.ecn_path_validation[ecn::ValidationOutcome::Capable]; + let _ = stats.ecn_path_validation + [ecn::ValidationOutcome::NotCapable(ecn::ValidationError::BlackHole)]; +}