interface-ip: fix route selection for host dependencies
authorFelix Fietkau <nbd@nbd.name>
Tue, 13 Mar 2018 12:05:28 +0000 (13:05 +0100)
committerFelix Fietkau <nbd@nbd.name>
Tue, 13 Mar 2018 12:06:38 +0000 (13:06 +0100)
In order to find the best match, allow overriding the last found entry
if route->mask for the new entry is bigger than the one from the previous
entry.

Patch submitted by 'Mikael' in FS#1358

Signed-off-by: Felix Fietkau <nbd@nbd.name>
interface-ip.c

index 6ccc03ee762029c36db15af0e7a0ad090f080561..4a3e2c059845980356c803fc2f3da1d1ec5470b1 100644 (file)
@@ -204,7 +204,7 @@ __find_ip_route_target(struct interface_ip_settings *ip, union if_addr *a,
                if (route->flags & DEVROUTE_TABLE)
                        continue;
 
-               if (!*res || route->mask < (*res)->mask)
+               if (!*res || route->mask > (*res)->mask)
                        *res = route;
        }
 }