fix set ipv6 mtu may cause tun init error (#1300)

This commit is contained in:
Sijie.Sun
2025-08-27 09:57:32 +08:00
committed by GitHub
parent 0ceb58586b
commit a3806e0190

View File

@@ -701,8 +701,12 @@ impl InterfaceLuid {
// SAFETY: Both NET_LUID_LH unions should be the same. We're just copying out
// the u64 value and re-wrapping it, since wintun doesn't refer to the windows
// crate's version of NET_LUID_LH.
self.try_set_mtu(AF_INET as ADDRESS_FAMILY, mtu)?;
self.try_set_mtu(AF_INET6 as ADDRESS_FAMILY, mtu)?;
if let Err(e) = self.try_set_mtu(AF_INET as ADDRESS_FAMILY, mtu) {
tracing::warn!("Failed to set IPv4 MTU: {:?}", e);
}
if let Err(e) = self.try_set_mtu(AF_INET6 as ADDRESS_FAMILY, mtu) {
tracing::warn!("Failed to set IPv6 MTU: {:?}", e);
}
Ok(())
}