aboutgitcodebugslistschat
path: root/netlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'netlink.c')
-rw-r--r--netlink.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/netlink.c b/netlink.c
index 8b16ebc..37c55cc 100644
--- a/netlink.c
+++ b/netlink.c
@@ -362,7 +362,7 @@ unsigned int nl_get_ext_if(int s, sa_family_t af)
}
/**
- * nl_route_get_def_multipath() - Get lowest-weight route from nexthop list
+ * nl_route_get_def_multipath() - Get first highest-weight route from nexthop list
* @rta: Routing netlink attribute with type RTA_MULTIPATH
* @gw: Default gateway to fill
*
@@ -380,11 +380,9 @@ static bool nl_route_get_def_multipath(struct rtattr *rta, void *gw)
size_t len = rtnh->rtnh_len - sizeof(*rtnh);
struct rtattr *rta_inner;
- if (rtnh->rtnh_hops < hops)
+ if (rtnh->rtnh_hops <= hops)
continue;
- hops = rtnh->rtnh_hops;
-
for (rta_inner = RTNH_DATA(rtnh); RTA_OK(rta_inner, len);
rta_inner = RTA_NEXT(rta_inner, len)) {
@@ -392,6 +390,7 @@ static bool nl_route_get_def_multipath(struct rtattr *rta, void *gw)
continue;
memcpy(gw, RTA_DATA(rta_inner), RTA_PAYLOAD(rta_inner));
+ hops = rtnh->rtnh_hops;
found = true;
}
}