Skip to content

Commit

Permalink
fixup! undo next_pkt_num change
Browse files Browse the repository at this point in the history
We will probably want to do this later anyway, but let's leave it out of
the refactoring for now.
  • Loading branch information
ghedo committed May 2, 2024
1 parent 40fd23a commit 40e2433
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
25 changes: 10 additions & 15 deletions quiche/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,9 +1355,6 @@ pub struct Connection {
/// Packet number spaces.
pkt_num_spaces: [packet::PktNumSpace; packet::Epoch::count()],

/// Next packet number
next_pkt_num: u64,

/// Peer's transport parameters.
peer_transport_params: TransportParams,

Expand Down Expand Up @@ -1871,8 +1868,6 @@ impl Connection {
packet::PktNumSpace::new(),
],

next_pkt_num: 0,

peer_transport_params: TransportParams::default(),

local_transport_params: config.local_transport_params.clone(),
Expand Down Expand Up @@ -3604,7 +3599,7 @@ impl Connection {
b.cap()
};

let pn = self.next_pkt_num;
let pn = pkt_space.next_pkt_num;
let pn_len = packet::pkt_num_len(pn)?;

// The AEAD overhead at the current encryption level.
Expand Down Expand Up @@ -4594,7 +4589,7 @@ impl Connection {
path.recovery.delivery_rate_update_app_limited(true);
}

self.next_pkt_num += 1;
pkt_space.next_pkt_num += 1;

let handshake_status = recovery::HandshakeStatus {
has_handshake_keys: self.pkt_num_spaces[packet::Epoch::Handshake]
Expand Down Expand Up @@ -8692,7 +8687,7 @@ pub mod testing {

space.key_update = Some(packet::KeyUpdate {
crypto_open: open_prev.unwrap(),
pn_on_update: self.client.next_pkt_num,
pn_on_update: space.next_pkt_num,
update_acked: true,
timer: time::Instant::now(),
});
Expand Down Expand Up @@ -8794,7 +8789,7 @@ pub mod testing {

let space = &mut conn.pkt_num_spaces[epoch];

let pn = conn.next_pkt_num;
let pn = space.next_pkt_num;
let pn_len = 4;

let send_path = conn.paths.get_active()?;
Expand Down Expand Up @@ -8857,7 +8852,7 @@ pub mod testing {
aead,
)?;

conn.next_pkt_num += 1;
space.next_pkt_num += 1;

Ok(written)
}
Expand Down Expand Up @@ -11118,7 +11113,7 @@ mod tests {

// Client acks RESET_STREAM frame.
let mut ranges = ranges::RangeSet::default();
ranges.insert(pipe.server.next_pkt_num - 5..pipe.server.next_pkt_num);
ranges.insert(0..6);

let frames = [frame::Frame::ACK {
ack_delay: 15,
Expand Down Expand Up @@ -13309,15 +13304,15 @@ mod tests {
for _ in 0..512 {
let recv_count = pipe.server.recv_count;

last_packet_sent = pipe.client.next_pkt_num;
last_packet_sent = pipe.client.pkt_num_spaces[epoch].next_pkt_num;

pipe.send_pkt_to_server(pkt_type, &frames, &mut buf)
.unwrap();

assert_eq!(pipe.server.recv_count, recv_count + 1);

// Skip packet number.
pipe.client.next_pkt_num += 1;
pipe.client.pkt_num_spaces[epoch].next_pkt_num += 1;
}

assert_eq!(
Expand Down Expand Up @@ -16992,7 +16987,7 @@ mod tests {
let mut b = octets::OctetsMut::with_slice(&mut pkt_buf);
let epoch = packet::Type::Short.to_epoch().unwrap();
let space = &mut pipe.client.pkt_num_spaces[epoch];
let pn = pipe.client.next_pkt_num;
let pn = space.next_pkt_num;
let pn_len = 4;

let hdr = Header {
Expand Down Expand Up @@ -17028,7 +17023,7 @@ mod tests {
aead,
)
.expect("packet encrypt");
pipe.client.next_pkt_num += 1;
space.next_pkt_num += 1;

pipe.server
.recv(&mut pkt_buf[..written], RecvInfo {
Expand Down
4 changes: 4 additions & 0 deletions quiche/src/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,8 @@ pub struct PktNumSpace {

pub largest_rx_non_probing_pkt_num: u64,

pub next_pkt_num: u64,

pub recv_pkt_need_ack: ranges::RangeSet,

pub recv_pkt_num: PktNumWindow,
Expand All @@ -885,6 +887,8 @@ impl PktNumSpace {

largest_rx_non_probing_pkt_num: 0,

next_pkt_num: 0,

recv_pkt_need_ack: ranges::RangeSet::new(crate::MAX_ACK_RANGES),

recv_pkt_num: PktNumWindow::default(),
Expand Down

0 comments on commit 40e2433

Please sign in to comment.