From ea23a9308082b5a785305f6e2ef592fe48d6914e Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Thu, 27 Feb 2025 15:27:36 +0100 Subject: [PATCH] Add cid len check to enable multipath --- quinn-proto/src/connection/mod.rs | 4 ++-- quinn-proto/src/shared.rs | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/quinn-proto/src/connection/mod.rs b/quinn-proto/src/connection/mod.rs index 05e8d3bcb..3f7564b77 100644 --- a/quinn-proto/src/connection/mod.rs +++ b/quinn-proto/src/connection/mod.rs @@ -1437,9 +1437,9 @@ impl Connection { /// Multipath is only enabled after the handshake is completed and if it was negotiated /// by both peers. pub fn is_multipath_enabled(&self) -> bool { - // TODO(flub): Multipath can only be enabled if both sides use non-zero length CIDs. - // Also check that. !self.is_handshaking() + && self.handshake_cid.len() > 0 + && self.rem_handshake_cid.len() > 0 && self.config.initial_max_path_id.is_some() && self.peer_params.initial_max_path_id.is_some() } diff --git a/quinn-proto/src/shared.rs b/quinn-proto/src/shared.rs index aefa1a00e..97d0f797f 100644 --- a/quinn-proto/src/shared.rs +++ b/quinn-proto/src/shared.rs @@ -98,6 +98,10 @@ impl ConnectionId { res } + pub(crate) fn len(&self) -> usize { + self.len as usize + } + /// Decode from long header format pub(crate) fn decode_long(buf: &mut impl Buf) -> Option { let len = buf.get::().ok()? as usize;