]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
Avoid dynamic MTU calculations for now
authorJason A. Donenfeld <Jason@zx2c4.com>
Thu, 3 Jan 2019 18:24:30 +0000 (19:24 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 8 Jan 2019 00:23:39 +0000 (19:23 -0500)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift

index 7c908aa0bf94e56378d70e37c7e130ac283bb852..b011c2a0827aa17f13507e0f9ba5ea157e17abd8 100644 (file)
@@ -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()