From: Jason A. Donenfeld Date: Thu, 3 Jan 2019 18:24:30 +0000 (+0100) Subject: Avoid dynamic MTU calculations for now X-Git-Tag: 0.0.20190107-1~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=150cd119c7144b7701a15286781bc1d62bdd82b3;p=thirdparty%2Fwireguard-apple.git Avoid dynamic MTU calculations for now Signed-off-by: Jason A. Donenfeld --- diff --git a/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift b/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift index 7c908aa..b011c2a 100644 --- a/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift +++ b/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift @@ -72,14 +72,20 @@ class PacketTunnelSettingsGenerator { dnsSettings.matchDomains = [""] // All DNS queries must first go through the tunnel's DNS networkSettings.dnsSettings = dnsSettings - let mtu = tunnelConfiguration.interface.mtu ?? 0 + var mtu = tunnelConfiguration.interface.mtu ?? 0 + + /* 0 means automatic MTU. In theory, we should just do + * `networkSettings.tunnelOverheadBytes = 80` but in + * practice there are too many broken networks out there. + * Instead set it to 1280. Boohoo. Maybe someday we'll + * add a nob, maybe, or iOS will do probing for us. + */ if mtu == 0 { - // 0 imples automatic MTU, where we set overhead as 80 bytes, which is the worst case for WireGuard - networkSettings.tunnelOverheadBytes = 80 - } else { - networkSettings.mtu = NSNumber(value: mtu) + mtu = 1280 } + networkSettings.mtu = NSNumber(value: mtu) + let (ipv4Routes, ipv6Routes) = routes() let (ipv4IncludedRoutes, ipv6IncludedRoutes) = includedRoutes()