From 1bf1c38b30a12472d9cb2f36718ba69c9d43abe0 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 16 Jun 2016 18:23:33 -0700 Subject: Default route population works on Mac! --- service/OneService.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'service/OneService.cpp') diff --git a/service/OneService.cpp b/service/OneService.cpp index 29916896..45f4234e 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -1327,6 +1327,18 @@ public: const InetAddress *const via = reinterpret_cast(&(nwc->routes[i].via)); bool haveRoute = false; + + // We don't need to bother applying local routes to local managed IPs since these are implied by setting the IP + for(std::vector::iterator ip(n.managedIps.begin());ip!=n.managedIps.end();++ip) { + if ((target->netmaskBits() == ip->netmaskBits())&&(target->containsAddress(*ip))) { + haveRoute = true; + break; + } + } + + if (haveRoute) + continue; + for(std::list::iterator mr(n.managedRoutes.begin());mr!=n.managedRoutes.end();++mr) { if (mr->target() == *target) { if ((via->ss_family == target->ss_family)&&(mr->via() == *via)) { @@ -1338,11 +1350,11 @@ public: } } } + if (haveRoute) continue; n.managedRoutes.push_back(ManagedRoute()); - if ((target->isDefaultRoute())&&(n.allowDefault)) { if (!n.managedRoutes.back().set(*target,*via,tapdev.c_str())) n.managedRoutes.pop_back(); -- cgit v1.2.3