[PATCH 2/2] interface-ip: use metric when looking for a route
luizluca at gmail.com
luizluca at gmail.com
Tue Oct 26 14:59:53 PDT 2021
From: Luiz Angelo Daros de Luca <luizluca at gmail.com>
When there were multiple routes with the same target but different
metrics, __find_ip_route_target was returning the first one,
independently of the metric.
Signed-off-by: Luiz Angelo Daros de Luca <luizluca at gmail.com>
---
interface-ip.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/interface-ip.c b/interface-ip.c
index 7c60fec..cecfb6d 100644
--- a/interface-ip.c
+++ b/interface-ip.c
@@ -234,7 +234,9 @@ __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 ||
+ ((route->mask == (*res)->mask) && (route->flags & DEVROUTE_METRIC)
+ && (route->metric < (*res)->metric)))
*res = route;
}
}
--
2.33.1
More information about the openwrt-devel
mailing list