Skip to content

Commit

Permalink
Discard pre-handshake packets after the handshake
Browse files Browse the repository at this point in the history
Attempting to parse frames from these non-frame-bearing packets was
responsible for some spurious connection failures in interop testing
under high packet loss.
  • Loading branch information
Ralith committed Jul 24, 2024
1 parent 061a74f commit 649f81a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion quinn-proto/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2301,7 +2301,10 @@ impl Connection {
State::Established => {
match packet.header.space() {
SpaceId::Data => self.process_payload(now, remote, number.unwrap(), packet)?,
_ => self.process_early_payload(now, packet)?,
_ if packet.header.has_frames() => self.process_early_payload(now, packet)?,
_ => {
trace!("discarding unexpected pre-handshake packet");
}
}
return Ok(());
}
Expand Down
12 changes: 12 additions & 0 deletions quinn-proto/src/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,18 @@ impl Header {
VersionNegotiate { ref dst_cid, .. } => dst_cid,
}
}

/// Whether the payload of this packet contains QUIC frames
pub(crate) fn has_frames(&self) -> bool {
use Header::*;
match *self {
Initial(_) => true,
Long { .. } => true,
Retry { .. } => false,
Short { .. } => true,
VersionNegotiate { .. } => false,
}
}
}

pub(crate) struct PartialEncode {
Expand Down

0 comments on commit 649f81a

Please sign in to comment.