From aac1068fb350edb70bc2cac4d97b2ce947bcffe9 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 7 Aug 2020 12:06:32 -0700 Subject: [PATCH] wgengine/router: set MTU on Windows to min(configured,possible) Fixes tailscale/corp#542 Signed-off-by: Brad Fitzpatrick (cherry picked from commit c64a43a734f52a6dd4eb01e9bc72d4b49ae3c776) --- wgengine/router/ifconfig_windows.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wgengine/router/ifconfig_windows.go b/wgengine/router/ifconfig_windows.go index 410e4facb..a127d724c 100644 --- a/wgengine/router/ifconfig_windows.go +++ b/wgengine/router/ifconfig_windows.go @@ -116,6 +116,13 @@ func monitorDefaultRoutes(device *device.Device, autoMTU bool, tun *tun.NativeTu return err } iface.NlMtu = mtu - 80 + // If the TUN device was created with a smaller MTU, + // though, such as 1280, we don't want to go bigger than + // configured. (See the comment on minimalMTU in the + // wgengine package.) + if min, err := tun.MTU(); err == nil && min < int(iface.NlMtu) { + iface.NlMtu = uint32(min) + } if iface.NlMtu < 576 { iface.NlMtu = 576 }