summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Altizer <xiche@verizon.net>2011-10-09 17:02:36 -0400
committerThomas Graf <tgraf@redhat.com>2011-10-10 11:44:10 +0200
commit790966d69aea9aea304caed22486834ba55eb5c7 (patch)
treef0926bcea766551444f7a1204d09da1a17ca35db
parent6c70cf7d72db62b65de6d5ee810f0c606313fbce (diff)
downloadlibnl-790966d69aea9aea304caed22486834ba55eb5c7.tar.gz
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>
-rw-r--r--lib/route/route_obj.c12
1 files changed, 11 insertions, 1 deletions
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;