From 790966d69aea9aea304caed22486834ba55eb5c7 Mon Sep 17 00:00:00 2001 From: Michael Altizer Date: Sun, 9 Oct 2011 17:02:36 -0400 Subject: [PATCH] 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 --- lib/route/route_obj.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/route/route_obj.c b/lib/route/route_obj.c index 834cb91..d322633 100644 --- a/lib/route/route_obj.c +++ b/lib/route/route_obj.c @@ -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;