From: Luiz Angelo Daros de Luca <luizl...@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 <luizl...@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 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel