diff --git a/controller/EmbeddedNetworkController.cpp b/controller/EmbeddedNetworkController.cpp index 203dcdd56..8b3f1517f 100644 --- a/controller/EmbeddedNetworkController.cpp +++ b/controller/EmbeddedNetworkController.cpp @@ -1523,8 +1523,11 @@ void EmbeddedNetworkController::_request( int routedNetmaskBits = -1; for(unsigned int rk=0;rkrouteCount;++rk) { - if (reinterpret_cast(&(nc->routes[rk].target))->containsAddress(ip)) - routedNetmaskBits = reinterpret_cast(&(nc->routes[rk].target))->netmaskBits(); + if (reinterpret_cast(&(nc->routes[rk].target))->containsAddress(ip)) { + const int nb = (int)(reinterpret_cast(&(nc->routes[rk].target))->netmaskBits()); + if (nb > routedNetmaskBits) + routedNetmaskBits = nb; + } } if (routedNetmaskBits >= 0) {