summaryrefslogtreecommitdiff
path: root/controller
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2019-02-01 14:05:29 -0800
committerGrant Limberg <grant.limberg@zerotier.com>2019-02-01 14:06:34 -0800
commita3b2aeb00115ed6f4c962640db89e15abb8aa174 (patch)
treeb8a40b79c1a24deeda1d2e087ddba5948bbe8bed /controller
parentd0f78f1e03f89e276a95507d66adffcc7f2235a9 (diff)
downloadinfinitytier-a3b2aeb00115ed6f4c962640db89e15abb8aa174.tar.gz
infinitytier-a3b2aeb00115ed6f4c962640db89e15abb8aa174.zip
Take netmask bits from most specific route.
Diffstat (limited to 'controller')
-rw-r--r--controller/EmbeddedNetworkController.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/controller/EmbeddedNetworkController.cpp b/controller/EmbeddedNetworkController.cpp
index 203dcdd5..8b3f1517 100644
--- a/controller/EmbeddedNetworkController.cpp
+++ b/controller/EmbeddedNetworkController.cpp
@@ -1523,8 +1523,11 @@ void EmbeddedNetworkController::_request(
int routedNetmaskBits = -1;
for(unsigned int rk=0;rk<nc->routeCount;++rk) {
- if (reinterpret_cast<const InetAddress *>(&(nc->routes[rk].target))->containsAddress(ip))
- routedNetmaskBits = reinterpret_cast<const InetAddress *>(&(nc->routes[rk].target))->netmaskBits();
+ if (reinterpret_cast<const InetAddress *>(&(nc->routes[rk].target))->containsAddress(ip)) {
+ const int nb = (int)(reinterpret_cast<const InetAddress *>(&(nc->routes[rk].target))->netmaskBits());
+ if (nb > routedNetmaskBits)
+ routedNetmaskBits = nb;
+ }
}
if (routedNetmaskBits >= 0) {