Skip to content

Commit

Permalink
implement path MTU discovery support
Browse files Browse the repository at this point in the history
  • Loading branch information
divyabhat1 authored Mar 1, 2024
1 parent 45b59aa commit 5387d47
Show file tree
Hide file tree
Showing 14 changed files with 695 additions and 36 deletions.
3 changes: 3 additions & 0 deletions apps/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ pub struct ServerArgs {
pub key: String,
pub disable_gso: bool,
pub disable_pacing: bool,
pub enable_pmtud: bool,
}

impl Args for ServerArgs {
Expand All @@ -491,6 +492,7 @@ impl Args for ServerArgs {
let key = args.get_str("--key").to_string();
let disable_gso = args.get_bool("--disable-gso");
let disable_pacing = args.get_bool("--disable-pacing");
let enable_pmtud = args.get_bool("--enable-pmtud");

ServerArgs {
listen,
Expand All @@ -501,6 +503,7 @@ impl Args for ServerArgs {
key,
disable_gso,
disable_pacing,
enable_pmtud,
}
}
}
1 change: 1 addition & 0 deletions apps/src/bin/quiche-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ fn main() {

config.set_application_protos(&conn_args.alpns).unwrap();

config.discover_pmtu(args.enable_pmtud);
config.set_max_idle_timeout(conn_args.idle_timeout);
config.set_max_recv_udp_payload_size(max_datagram_size);
config.set_max_send_udp_payload_size(max_datagram_size);
Expand Down
3 changes: 3 additions & 0 deletions quiche/include/quiche.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ void quiche_config_verify_peer(quiche_config *config, bool v);
// Configures whether to send GREASE.
void quiche_config_grease(quiche_config *config, bool v);

// Configures whether to do path MTU discovery.
void quiche_config_discover_pmtu(quiche_config *config, bool v);

// Enables logging of secrets.
void quiche_config_log_keys(quiche_config *config);

Expand Down
5 changes: 5 additions & 0 deletions quiche/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ pub extern fn quiche_config_grease(config: &mut Config, v: bool) {
config.grease(v);
}

#[no_mangle]
pub extern fn quiche_config_discover_pmtu(config: &mut Config, v: bool) {
config.discover_pmtu(v);
}

#[no_mangle]
pub extern fn quiche_config_log_keys(config: &mut Config) {
config.log_keys();
Expand Down
21 changes: 14 additions & 7 deletions quiche/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ pub enum Frame {
len: usize,
},

Ping,
Ping {
// Attach metadata to the Ping frame. This doesn't appear on the wire,
// but does tell us if this frame was part of a PMTUD probe and how
// large the probe was. This will only show up on sent frames and be
// None otherwise. This is the total size of the QUIC packet in the
// probe.
mtu_probe: Option<usize>,
},

ACK {
ack_delay: u64,
Expand Down Expand Up @@ -198,7 +205,7 @@ impl Frame {
Frame::Padding { len }
},

0x01 => Frame::Ping,
0x01 => Frame::Ping { mtu_probe: None },

0x02..=0x03 => parse_ack_frame(frame_type, b)?,

Expand Down Expand Up @@ -376,7 +383,7 @@ impl Frame {
}
},

Frame::Ping => {
Frame::Ping { .. } => {
b.put_varint(0x01)?;
},

Expand Down Expand Up @@ -595,7 +602,7 @@ impl Frame {
match self {
Frame::Padding { len } => *len,

Frame::Ping => 1,
Frame::Ping { .. } => 1,

Frame::ACK {
ack_delay,
Expand Down Expand Up @@ -1024,8 +1031,8 @@ impl std::fmt::Debug for Frame {
write!(f, "PADDING len={len}")?;
},

Frame::Ping => {
write!(f, "PING")?;
Frame::Ping { mtu_probe } => {
write!(f, "PING mtu_probe={mtu_probe:?}")?;
},

Frame::ACK {
Expand Down Expand Up @@ -1375,7 +1382,7 @@ mod tests {
fn ping() {
let mut d = [42; 128];

let frame = Frame::Ping;
let frame = Frame::Ping { mtu_probe: None };

let wire_len = {
let mut b = octets::OctetsMut::with_slice(&mut d);
Expand Down
Loading

0 comments on commit 5387d47

Please sign in to comment.