From fa9dae705d955d0dd6acd263fb7dabb720e21f7a Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Fri, 28 Feb 2025 16:11:18 +0100 Subject: [PATCH] Issue path CIDs at connection start --- quinn-proto/src/connection/mod.rs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/quinn-proto/src/connection/mod.rs b/quinn-proto/src/connection/mod.rs index dc4c7811b..95f2f7d77 100644 --- a/quinn-proto/src/connection/mod.rs +++ b/quinn-proto/src/connection/mod.rs @@ -2694,6 +2694,12 @@ impl Connection { self.events.push_back(Event::Connected); self.state = State::Established; trace!("established"); + + // Multipath can only be enabled after the state has reached Established. + // So this can not happen any earlier. + if self.is_multipath_enabled() { + self.issue_first_path_cids(now); + } Ok(()) } Header::Initial(InitialHeader { @@ -3305,11 +3311,7 @@ impl Connection { } /// Issue an initial set of connection IDs to the peer upon connection - // Is called before the handshake is completed. But I think they are only sent on - // 1-RTT packets? fn issue_first_cids(&mut self, now: Instant) { - // TODO(flub): This needs to issue CIDs for several paths! - // Do this. if self .local_cid_state .get(&PathId(0)) @@ -3326,6 +3328,21 @@ impl Connection { .push_back(EndpointEventInner::NeedIdentifiers(PathId(0), now, n)); } + /// Issues an initial set of CIDs to the peer for PathId > 0 + fn issue_first_path_cids(&mut self, now: Instant) { + debug_assert!(self.is_multipath_enabled()); + if let Some(max_path_id) = self.config.initial_max_path_id { + for n in 1..(max_path_id + 1) { + self.endpoint_events + .push_back(EndpointEventInner::NeedIdentifiers( + PathId(n), + now, + self.peer_params.issue_cids_limit(), + )); + } + } + } + fn populate_packet( &mut self, now: Instant,