diff options
| author | David Lönnhager <david.l@mullvad.net> | 2025-03-17 17:15:47 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2025-03-19 09:56:46 +0100 |
| commit | b0ba6488ea4a034afbd0b6850d96d3e18fb05389 (patch) | |
| tree | 155eb78c0129ea62af2327c21b86f0f2a7c1e2c2 | |
| parent | 22fc75dc527d1510874f7253b728a068426f6beb (diff) | |
| download | mullvadvpn-b0ba6488ea4a034afbd0b6850d96d3e18fb05389.tar.xz mullvadvpn-b0ba6488ea4a034afbd0b6850d96d3e18fb05389.zip | |
Set MTU on IPv6 interface for wireguard-nt only if IPv6 is enabled
| -rw-r--r-- | talpid-openvpn/src/wintun.rs | 2 | ||||
| -rw-r--r-- | talpid-tunnel/src/windows.rs | 13 | ||||
| -rw-r--r-- | talpid-wireguard/src/wireguard_go/mod.rs | 3 | ||||
| -rw-r--r-- | talpid-wireguard/src/wireguard_nt/mod.rs | 8 |
4 files changed, 19 insertions, 7 deletions
diff --git a/talpid-openvpn/src/wintun.rs b/talpid-openvpn/src/wintun.rs index f8592ef94c..a77ce81e02 100644 --- a/talpid-openvpn/src/wintun.rs +++ b/talpid-openvpn/src/wintun.rs @@ -98,7 +98,7 @@ impl WintunAdapter { pub fn prepare_interface(&self) { if let Err(error) = - talpid_tunnel::network_interface::initialize_interfaces(self.luid(), None) + talpid_tunnel::network_interface::initialize_interfaces(self.luid(), None, None) { log::error!( "{}", diff --git a/talpid-tunnel/src/windows.rs b/talpid-tunnel/src/windows.rs index bc5fffb3f0..109e6a9ae1 100644 --- a/talpid-tunnel/src/windows.rs +++ b/talpid-tunnel/src/windows.rs @@ -7,8 +7,15 @@ use windows_sys::Win32::{ /// Sets MTU, metric, and disables unnecessary features for the IP interfaces /// on the specified network interface (identified by `luid`). -pub fn initialize_interfaces(luid: NET_LUID_LH, mtu: Option<u32>) -> io::Result<()> { - for family in &[AddressFamily::Ipv4, AddressFamily::Ipv6] { +pub fn initialize_interfaces( + luid: NET_LUID_LH, + ipv4_mtu: Option<u32>, + ipv6_mtu: Option<u32>, +) -> io::Result<()> { + for (family, mtu) in &[ + (AddressFamily::Ipv4, ipv4_mtu), + (AddressFamily::Ipv6, ipv6_mtu), + ] { let mut row = match get_ip_interface_entry(*family, &luid) { Ok(row) => row, Err(error) if error.raw_os_error() == Some(ERROR_NOT_FOUND as i32) => continue, @@ -16,7 +23,7 @@ pub fn initialize_interfaces(luid: NET_LUID_LH, mtu: Option<u32>) -> io::Result< }; if let Some(mtu) = mtu { - row.NlMtu = mtu; + row.NlMtu = *mtu; } // Disable DAD, DHCP, and router discovery diff --git a/talpid-wireguard/src/wireguard_go/mod.rs b/talpid-wireguard/src/wireguard_go/mod.rs index 0289831172..2f315c82cb 100644 --- a/talpid-wireguard/src/wireguard_go/mod.rs +++ b/talpid-wireguard/src/wireguard_go/mod.rs @@ -311,7 +311,8 @@ impl WgGoTunnel { .map_err(|e| BoxedError::new(TunnelError::SetupIpInterfaces(e)))?; log::debug!("Waiting for tunnel IP interfaces: Done"); - if let Err(error) = talpid_tunnel::network_interface::initialize_interfaces(luid, None) + if let Err(error) = + talpid_tunnel::network_interface::initialize_interfaces(luid, None, None) { log::error!( "{}", diff --git a/talpid-wireguard/src/wireguard_nt/mod.rs b/talpid-wireguard/src/wireguard_nt/mod.rs index ff5b082490..baac2ddd69 100644 --- a/talpid-wireguard/src/wireguard_nt/mod.rs +++ b/talpid-wireguard/src/wireguard_nt/mod.rs @@ -543,8 +543,12 @@ async fn setup_ip_listener(device: Arc<WgNtAdapter>, mtu: u32, has_ipv6: bool) - .map_err(Error::IpInterfaces)?; log::debug!("Waiting for tunnel IP interfaces: Done"); - talpid_tunnel::network_interface::initialize_interfaces(luid, Some(mtu)) - .map_err(Error::SetTunnelMtu)?; + talpid_tunnel::network_interface::initialize_interfaces( + luid, + Some(mtu), + has_ipv6.then_some(mtu), + ) + .map_err(Error::SetTunnelMtu)?; device .set_state(WgAdapterState::Up) |
