Skip to content

Commit

Permalink
Merge pull request #1 from mozilla/fix-remove-windows-min
Browse files Browse the repository at this point in the history
fix: Don't limit the Windows MTU
  • Loading branch information
larseggert authored Sep 2, 2024
2 parents b5b593c + 0605112 commit c732bd2
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ fn get_interface_mtu_linux_macos(socket: &UdpSocket) -> Result<usize, Error> {

#[cfg(target_os = "windows")]
fn get_interface_mtu_windows(socket: &UdpSocket) -> Result<usize, Error> {
use std::{cmp::min, ffi::c_void, slice};
use std::{ffi::c_void, slice};

use windows::Win32::{
Foundation::NO_ERROR,
Expand Down Expand Up @@ -214,8 +214,7 @@ fn get_interface_mtu_windows(socket: &UdpSocket) -> Result<usize, Error> {
// For the matching address, find local interface and its MTU.
for iface in ifaces {
if iface.InterfaceIndex == addr.InterfaceIndex {
// On loopback, the MTU is 4294967295...
res = min(iface.NlMtu, 65536).try_into().or(res);
res = iface.NlMtu.try_into().or(res);
break 'addr_loop;
}
}
Expand Down Expand Up @@ -263,16 +262,20 @@ mod test {
fn loopback_interface_mtu_v4() {
#[cfg(target_os = "macos")]
check_mtu("localhost:443", true, 16384);
#[cfg(not(target_os = "macos"))]
check_mtu("localhost:443", true, 65536);
#[cfg(target_os = "linux")]
check_mtu("localhost:443", false, 65_536);
#[cfg(target_os = "windows")]
check_mtu("localhost:443", false, 4_294_967_295);
}

#[test]
fn loopback_interface_mtu_v6() {
#[cfg(target_os = "macos")]
check_mtu("localhost:443", false, 16384);
#[cfg(not(target_os = "macos"))]
check_mtu("localhost:443", false, 65536);
#[cfg(target_os = "linux")]
check_mtu("localhost:443", false, 65_536);
#[cfg(target_os = "windows")]
check_mtu("localhost:443", false, 4_294_967_295);
}

#[test]
Expand Down

0 comments on commit c732bd2

Please sign in to comment.