aboutgitcodebugslistschat
path: root/netlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'netlink.c')
-rw-r--r--netlink.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/netlink.c b/netlink.c
index e91507d..e1b5f75 100644
--- a/netlink.c
+++ b/netlink.c
@@ -375,11 +375,13 @@ unsigned int nl_get_ext_if(int s, sa_family_t af)
/**
* nl_route_get_def_multipath() - Get first highest-weight route from nexthop list
* @rta: Routing netlink attribute with type RTA_MULTIPATH
+ * @ifi: Interface index
* @gw: Default gateway to fill
*
* Return: true if a gateway was found, false otherwise
*/
-static bool nl_route_get_def_multipath(struct rtattr *rta, void *gw)
+static bool nl_route_get_def_multipath(struct rtattr *rta, unsigned int ifi,
+ void *gw)
{
int nh_len = RTA_PAYLOAD(rta);
struct rtnexthop *rtnh;
@@ -391,6 +393,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_ifindex != (int)ifi)
+ continue;
+
if (rtnh->rtnh_hops <= hops)
continue;
@@ -453,7 +458,8 @@ int nl_route_get_def(int s, unsigned int ifi, sa_family_t af, void *gw)
for (rta = RTM_RTA(rtm), na = RTM_PAYLOAD(nh); RTA_OK(rta, na);
rta = RTA_NEXT(rta, na)) {
if (rta->rta_type == RTA_MULTIPATH)
- found = nl_route_get_def_multipath(rta, gw);
+ found = nl_route_get_def_multipath(rta, ifi,
+ gw);
if (rta->rta_type != RTA_GATEWAY)
continue;