Skip to content

Commit

Permalink
Limit volume of CIDs retired at peer's request
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith committed Feb 11, 2022
1 parent f4acc99 commit 6c0e380
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions quinn-proto/src/cid_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,14 @@ impl CidQueue {
self.cursor = (self.cursor + i) % Self::LEN;
let orig_offset = self.offset;
self.offset = cid.retire_prior_to + i as u64;
// We don't immediately retire CIDs in the range (orig_offset +
// Self::LEN)..self.offset. These are CIDs that we haven't yet received from a
// NEW_CONNECTION_ID frame, since having previously received them would violate the
// connection ID limit we specified based on Self::LEN. If we do receive a such a frame
// in the future, e.g. due to reordering, we'll retire it then. This ensures we can't be
// made to buffer an arbitrarily large number of RETIRE_CONNECTION_ID frames.
Ok(Some((
orig_offset..self.offset,
orig_offset..self.offset.min(orig_offset + Self::LEN as u64),
token.expect("non-initial CID missing reset token"),
)))
}
Expand Down Expand Up @@ -240,7 +246,7 @@ mod tests {
q.insert(cid(2, 0)).unwrap();
assert_eq!(
q.insert(cid(1_000_000, 1_000_000)).unwrap().unwrap().0,
0..1_000_000,
0..CidQueue::LEN as u64,
);
assert_eq!(q.active_seq(), 1_000_000);
}
Expand Down

0 comments on commit 6c0e380

Please sign in to comment.