diff options
| author | Joakim Hulthe <joakim@hulthe.net> | 2025-08-15 14:28:13 +0200 |
|---|---|---|
| committer | Markus Pettersson <markus.pettersson@mullvad.net> | 2025-08-18 15:26:50 +0200 |
| commit | 1aab3e607a3a6bb72dfa76038b40c4145d1630bd (patch) | |
| tree | 44ee51a9d299e05054f30afb0817c54ab5b72557 | |
| parent | 6ca9372052e472083ef4eccfa080d4b0215c50bb (diff) | |
| download | mullvadvpn-1aab3e607a3a6bb72dfa76038b40c4145d1630bd.tar.xz mullvadvpn-1aab3e607a3a6bb72dfa76038b40c4145d1630bd.zip | |
Respect quinn::EndpointConfig minimum max udp payload size
| -rw-r--r-- | mullvad-masque-proxy/src/lib.rs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/mullvad-masque-proxy/src/lib.rs b/mullvad-masque-proxy/src/lib.rs index e6533b5368..7a3b60dc1b 100644 --- a/mullvad-masque-proxy/src/lib.rs +++ b/mullvad-masque-proxy/src/lib.rs @@ -27,21 +27,34 @@ const UDP_HEADER_SIZE: u16 = 8; /// QUIC header size. This is conservative, real overhead varies const QUIC_HEADER_SIZE: u16 = 41; +/// The minimum allowed `max_udp_payload_size`-value allowed by [quinn::EndpointConfig]. +const MIN_MAX_UDP_PAYLOAD_SIZE: u16 = 1200; + /// This is the size of the payload that stores QUIC packets /// MTU - IP header - UDP header +/// +/// Note that [quinn::EndpointConfig] accepts a minimum value of 1200. const fn compute_udp_payload_size(mtu: u16, target_addr: SocketAddr) -> u16 { let ip_overhead = if target_addr.is_ipv4() { 20 } else { 40 }; - mtu - ip_overhead - UDP_HEADER_SIZE + let desired_max = mtu - ip_overhead - UDP_HEADER_SIZE; + + if desired_max < MIN_MAX_UDP_PAYLOAD_SIZE { + MIN_MAX_UDP_PAYLOAD_SIZE + } else { + desired_max + } } -/// Minimum allowed MTU (IPv6) is the overhead of all headers, plus 1 byte for actual data. +/// Minimum allowed MTU (IPv4) +/// /// QUIC defines that clients must support UDP payloads of at least 1200 bytes. /// <https://datatracker.ietf.org/doc/html/rfc9000#section-8.1> // 20 = IPv4 header (without optional fields) pub const MIN_IPV4_MTU: u16 = 20 + UDP_HEADER_SIZE + 1200; -/// Minimum allowed MTU (IPv6) is the overhead of all headers, plus 1 byte for actual data. +/// Minimum allowed MTU (IPv6) +/// /// QUIC defines that clients must support UDP payloads of at least 1200 bytes. /// <https://datatracker.ietf.org/doc/html/rfc9000#section-8.1> -// 40 = IPv6 header (without optional fields) +// 40 = IPv6 header pub const MIN_IPV6_MTU: u16 = 40 + UDP_HEADER_SIZE + 1200; |
