Netlink: Ignore dead routes
With net.ipv4.conf.XXX.ignore_routes_with_linkdown sysctl, a user can ensure the kernel does not use a route whose target interface is down. Such route is marked with a 'dead' / RTNH_F_DEAD flag. Ignore these routes or multipath nexthops during scan. Thanks to Vincent Bernat for the original patch.
This commit is contained in:
parent
a40ddf5c61
commit
df83f62697
1 changed files with 7 additions and 1 deletions
|
@ -697,6 +697,9 @@ nl_parse_multipath(struct nl_parse_state *s, struct krt_proto *p, struct rtattr
|
||||||
if ((len < sizeof(*nh)) || (len < nh->rtnh_len))
|
if ((len < sizeof(*nh)) || (len < nh->rtnh_len))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (nh->rtnh_flags & RTNH_F_DEAD)
|
||||||
|
goto next;
|
||||||
|
|
||||||
*last = rv = lp_allocz(s->pool, NEXTHOP_MAX_SIZE);
|
*last = rv = lp_allocz(s->pool, NEXTHOP_MAX_SIZE);
|
||||||
last = &(rv->next);
|
last = &(rv->next);
|
||||||
|
|
||||||
|
@ -772,7 +775,7 @@ nl_parse_multipath(struct nl_parse_state *s, struct krt_proto *p, struct rtattr
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
next:
|
||||||
len -= NLMSG_ALIGN(nh->rtnh_len);
|
len -= NLMSG_ALIGN(nh->rtnh_len);
|
||||||
nh = RTNH_NEXT(nh);
|
nh = RTNH_NEXT(nh);
|
||||||
}
|
}
|
||||||
|
@ -1683,6 +1686,9 @@ nl_parse_route(struct nl_parse_state *s, struct nlmsghdr *h)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i->rtm_flags & RTNH_F_DEAD)
|
||||||
|
return;
|
||||||
|
|
||||||
ra->nh.iface = if_find_by_index(oif);
|
ra->nh.iface = if_find_by_index(oif);
|
||||||
if (!ra->nh.iface)
|
if (!ra->nh.iface)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue