From b8cb59beb227faeef95462c20269e94dc5732cf3 Mon Sep 17 00:00:00 2001 From: Jamil Date: Thu, 17 Aug 2023 22:14:04 -0700 Subject: [PATCH] Use tunnelOverheadBytes to properly set tunnel interface MTU (#1924) Apple provides a mechanism to calculate a smarter MTU for the tunnel interface that is created. This will be automatically adjusted depending on the MTU of the underlying physical device. --- swift/apple/FirezoneNetworkExtension/NetworkSettings.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/swift/apple/FirezoneNetworkExtension/NetworkSettings.swift b/swift/apple/FirezoneNetworkExtension/NetworkSettings.swift index 2cb2a9ab8..1ffea3647 100644 --- a/swift/apple/FirezoneNetworkExtension/NetworkSettings.swift +++ b/swift/apple/FirezoneNetworkExtension/NetworkSettings.swift @@ -31,9 +31,8 @@ class NetworkSettings { let tunnelAddressIPv6: String let dnsAddress: String - // In theory we could update the MTU dynamically based on the network environment, - // but 1280 is guaranteed to work everywhere. - let tunnelMTU = NSNumber(1280) + // WireGuard has an 80-byte overhead. + let tunnelOverheadBytes = NSNumber(80) // Modifiable values private(set) var dnsFallbackStrategy: DNSFallbackStrategy @@ -153,7 +152,7 @@ class NetworkSettings { dnsSettings.matchDomains = [""] } tunnelNetworkSettings.dnsSettings = dnsSettings - tunnelNetworkSettings.mtu = tunnelMTU + tunnelNetworkSettings.tunnelOverheadBytes = tunnelOverheadBytes self.hasUnappliedChanges = false logger.debug("Attempting to set network settings")