Fix feth max MTU sysctl.

This commit is contained in:
Adam Ierymenko 2021-07-30 18:44:23 -04:00
parent 5623a0b420
commit 63a44c9268
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3

View file

@ -59,10 +59,13 @@
static const ZeroTier::MulticastGroup _blindWildcardMulticastGroup(ZeroTier::MAC(0xff),0);
#define MACOS_FETH_MAX_MTU_SYSCTL "net.link.fake.max_mtu"
namespace ZeroTier {
static Mutex globalTapCreateLock;
static bool globalTapInitialized = false;
static bool fethMaxMtuAdjusted = false;
MacEthernetTap::MacEthernetTap(
const char *homePath,
@ -102,6 +105,14 @@ MacEthernetTap::MacEthernetTap(
Mutex::Lock _gl(globalTapCreateLock); // only make one at a time
if (!fethMaxMtuAdjusted) {
fethMaxMtuAdjusted = true;
int old_mtu = 0;
size_t old_mtu_len = sizeof(old_mtu);
int mtu = 10000;
sysctlbyname(MACOS_FETH_MAX_MTU_SYSCTL, &old_mtu, &old_mtu_len, &mtu, sizeof(mtu));
}
// Destroy all feth devices on first tap start in case ZeroTier did not exit cleanly last time.
// We leave interfaces less than feth100 alone in case something else is messing with feth devices.
if (!globalTapInitialized) {