diff --git a/quinn-proto/src/connection/mod.rs b/quinn-proto/src/connection/mod.rs index c957a4d7d..e695550e9 100644 --- a/quinn-proto/src/connection/mod.rs +++ b/quinn-proto/src/connection/mod.rs @@ -228,8 +228,10 @@ pub struct Connection { /// exist. So if multipath is supported the number of paths here will be higher than /// the actual number of paths in use. rem_cids: BTreeMap, - // Attributes of CIDs generated by local peer - local_cid_state: CidState, + /// Attributes of CIDs generated by local endpoint + local_cid_state: BTreeMap, + /// A map from issued CIDs to PathId, for fast lookup. + path_cids: BTreeMap, /// State of the unreliable datagram extension datagrams: DatagramState, /// Connection level statistics @@ -242,11 +244,6 @@ pub struct Connection { // /// [`PathId`] associated with this connection if any. path_id: Option, - - /// A temporary map between CID and PathID. - // TODO(flub): This will probably be stored somewhere more cohesive with other path - // data. But is useful now because it allows us to make the logic changes. - path_cids: BTreeMap, } impl Connection { @@ -289,18 +286,22 @@ impl Connection { expected_token: Bytes::new(), client_hello: None, }); + let local_cid_state = BTreeMap::from([( + PathId(0), + CidState::new( + cid_gen.cid_len(), + cid_gen.cid_lifetime(), + now, + if pref_addr_cid.is_some() { 2 } else { 1 }, + ), + )]); let mut this = Self { endpoint_config, crypto, handshake_cid: loc_cid, rem_handshake_cid: rem_cid, - local_cid_state: CidState::new( - cid_gen.cid_len(), - cid_gen.cid_lifetime(), - now, - if pref_addr_cid.is_some() { 2 } else { 1 }, - ), + local_cid_state, path: PathData::new(remote, allow_mtud, None, now, path_validated, &config), allow_mtud, local_ip,