diff --git a/neqo-transport/src/connection/tests/ecn.rs b/neqo-transport/src/connection/tests/ecn.rs index 7bcd608c79..c6b7e22926 100644 --- a/neqo-transport/src/connection/tests/ecn.rs +++ b/neqo-transport/src/connection/tests/ecn.rs @@ -158,6 +158,16 @@ fn request_response_delay_after_handshake_with_ecn_blackhole() { #[test] fn migration_delay_to_ecn_blackhole() { + migration_to_ecn_blackhole(false); +} + +/// Also when ECN validation on the new path ends before its last ECN-marked attempt times out. +#[test] +fn forced_migration_to_ecn_blackhole() { + migration_to_ecn_blackhole(true); +} + +fn migration_to_ecn_blackhole(force: bool) { let mut now = now(); let mut client = default_client(); let mut server = default_server(); @@ -167,8 +177,9 @@ fn migration_delay_to_ecn_blackhole() { // Migrate the client. client - .migrate(Some(DEFAULT_ADDR_V4), Some(DEFAULT_ADDR_V4), false, now) + .migrate(Some(DEFAULT_ADDR_V4), Some(DEFAULT_ADDR_V4), force, now) .unwrap(); + let stream = client.stream_create(StreamType::UniDi).unwrap(); // The client should send Path::MAX_PROBES path challenges with ECN enabled, and then another // Path::MAX_PROBES without ECN. @@ -180,7 +191,7 @@ fn migration_delay_to_ecn_blackhole() { } Output::Datagram(d) => { // The new path is IPv4. - if d.source().is_ipv4() { + if d.source().is_ipv4() && client.stats().frame_tx.path_challenge > probes { // This should be a PATH_CHALLENGE. probes += 1; assert_eq!(client.stats().frame_tx.path_challenge, probes); @@ -192,6 +203,13 @@ fn migration_delay_to_ecn_blackhole() { // The next probes should be sent without ECN. assert_ecn_disabled(d.tos()); } + if probes == Path::MAX_PROBES { + // Ends ECN validation before this attempt times out. + for _ in 0..ecn::TEST_COUNT { + client.stream_send(stream, &[0]).unwrap(); + drop(client.process_output(now)); + } + } } } Output::None => panic!("unexpected output"), diff --git a/neqo-transport/src/path.rs b/neqo-transport/src/path.rs index 7e09c29ba7..66847d57f4 100644 --- a/neqo-transport/src/path.rs +++ b/neqo-transport/src/path.rs @@ -595,6 +595,8 @@ pub struct Path { probe_blocked_since: Option, /// The ECN-related state for this path (see RFC9000, Section 13.4 and Appendix A.4) ecn_info: ecn::Info, + /// Whether every `PATH_CHALLENGE` sent since ECN validation started was ECN-marked. + challenges_ecn_marked: bool, /// SCONE info for this path. scone: Option, /// For logging of events. @@ -649,6 +651,7 @@ impl Path { sent_bytes: 0, probe_blocked_since: None, ecn_info: ecn::Info::default(), + challenges_ecn_marked: false, scone: None, qlog, } @@ -867,7 +870,7 @@ impl Path { _ => 0, }; self.state = if probe_count >= Self::MAX_PROBES { - if self.ecn_info.is_marking() { + if self.challenges_ecn_marked { // The path validation failure may be due to ECN blackholing, try again without ECN. info!("[{self}] Possible ECN blackhole, disabling ECN and re-probing path"); self.ecn_info @@ -945,6 +948,7 @@ impl Path { // As above, no recovery token. stats.path_challenge += 1; + self.challenges_ecn_marked &= self.ecn_info.is_marking(); self.state = ProbeState::Probing { probe_count, @@ -982,6 +986,7 @@ impl Path { pub fn start_ecn(&mut self, stats: &mut Stats) { self.ecn_info.start(stats); + self.challenges_ecn_marked = true; } pub const fn acked_ack_frequency(&mut self, acked: AckRate) {