From 6bb1598fa386982720d7d6cdc6fbbd3f57cb7a7e Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 15 Sep 2021 11:50:54 -0400 Subject: [PATCH] Another fix for routing and interface issues on MacOS --- osdep/ManagedRoute.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/osdep/ManagedRoute.cpp b/osdep/ManagedRoute.cpp index abe768930..fd06f9cfe 100644 --- a/osdep/ManagedRoute.cpp +++ b/osdep/ManagedRoute.cpp @@ -437,6 +437,24 @@ bool ManagedRoute::sync() #ifdef __BSD__ // ------------------------------------------------------------ + if (_device[0]) { + bool haveDevice = false; + struct ifaddrs *ifa = (struct ifaddrs *)0; + if (!getifaddrs(&ifa)) { + struct ifaddrs *p = ifa; + while (p) { + if ((p->ifa_name)&&(!strcmp(_device, p->ifa_name))) { + haveDevice = true; + break; + } + p = p->ifa_next; + } + freeifaddrs(ifa); + } + if (!haveDevice) + return false; + } + // Find lowest metric system route that this route should override (if any) InetAddress newSystemVia; char newSystemDevice[128];