Only use the MULTIPATH attribute when adding routes with more than one next hop.
Only use the MULTIPATH attribute when adding routes with more than one next hop. This solves issues with two scenarios: 1. Adding an IPv4 route to a kernel configured without CONFIG_IP_ROUTE_MULTIPATH=y. 2. Adding an IPv6 route in general, since the MULTIPATH attribute is not supported there. Signed-off-by: Michael Altizer <xiche@verizon.net>
This commit is contained in:
parent
6c70cf7d72
commit
790966d69a
1 changed files with 11 additions and 1 deletions
|
@ -1078,7 +1078,17 @@ int rtnl_route_build_msg(struct nl_msg *msg, struct rtnl_route *route)
|
|||
nla_nest_end(msg, metrics);
|
||||
}
|
||||
|
||||
if (rtnl_route_get_nnexthops(route) > 0) {
|
||||
if (rtnl_route_get_nnexthops(route) == 1) {
|
||||
struct rtnl_nexthop *nh;
|
||||
|
||||
nh = rtnl_route_nexthop_n(route, 0);
|
||||
if (nh->rtnh_gateway)
|
||||
NLA_PUT_ADDR(msg, RTA_GATEWAY, nh->rtnh_gateway);
|
||||
if (nh->rtnh_ifindex)
|
||||
NLA_PUT_U32(msg, RTA_OIF, nh->rtnh_ifindex);
|
||||
if (nh->rtnh_realms)
|
||||
NLA_PUT_U32(msg, RTA_FLOW, nh->rtnh_realms);
|
||||
} else if (rtnl_route_get_nnexthops(route) > 1) {
|
||||
struct nlattr *multipath;
|
||||
struct rtnl_nexthop *nh;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue