Set MTU on IPv6 interface for wireguard-nt only if IPv6 is enabled
This commit is contained in:
parent
22fc75dc52
commit
b0ba6488ea
@ -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!(
|
||||
"{}",
|
||||
|
@ -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
|
||||
|
@ -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!(
|
||||
"{}",
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user