Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions neqo-transport/src/connection/tests/ecn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@

#[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();
Expand All @@ -167,8 +177,9 @@

// 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.
Expand All @@ -180,7 +191,7 @@
}
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);
Expand All @@ -192,6 +203,13 @@
// 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"),
Expand Down
7 changes: 6 additions & 1 deletion neqo-transport/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,8 @@ pub struct Path {
probe_blocked_since: Option<Instant>,
/// 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<Scone>,
/// For logging of events.
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
Loading