Skip to content

Commit

Permalink
Fix incorrect initial DCID indexing on retried connections
Browse files Browse the repository at this point in the history
This could also cause other packets received before the server accepts
the connection to be lost.
  • Loading branch information
Ralith committed Jul 31, 2024
1 parent cf445be commit 169f0c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion quinn-proto/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ impl Endpoint {

let incoming_idx = self.incoming_buffers.insert(IncomingBuffer::default());
self.index
.insert_initial_incoming(orig_dst_cid, incoming_idx);
.insert_initial_incoming(header.dst_cid, incoming_idx);

Some(DatagramEvent::NewConnection(Incoming {
addresses,
Expand Down
12 changes: 11 additions & 1 deletion quinn-proto/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,17 @@ fn stateless_retry() {
let _guard = subscribe();
let mut pair = Pair::default();
pair.server.incoming_connection_behavior = IncomingConnectionBehavior::Validate;
pair.connect();
let (client_ch, _server_ch) = pair.connect();
pair.client
.connections
.get_mut(&client_ch)
.unwrap()
.close(pair.time, VarInt(42), Bytes::new());
pair.drive();
assert_eq!(pair.client.known_connections(), 0);
assert_eq!(pair.client.known_cids(), 0);
assert_eq!(pair.server.known_connections(), 0);
assert_eq!(pair.server.known_cids(), 0);
}

#[test]
Expand Down

0 comments on commit 169f0c2

Please sign in to comment.