From f0603a467b8c3719b6575d781b43aa0567180603 Mon Sep 17 00:00:00 2001 From: Daniel Walter Date: Tue, 22 Mar 2011 10:45:41 +0100 Subject: [PATCH] add missing checks for ROUTE_ATTR_MULTIPATH attached patch adds missing checks for ROUTE_ATTR_MULTIPATH when dealing with multipath routing. Affected functions rtnl_route_remove_nexthop rtnl_route_get_nexthops rtnl_route_get_nnexthops --- lib/route/route_obj.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/route/route_obj.c b/lib/route/route_obj.c index 2cbe2ae..d3b09ab 100644 --- a/lib/route/route_obj.c +++ b/lib/route/route_obj.c @@ -687,18 +687,26 @@ void rtnl_route_add_nexthop(struct rtnl_route *route, struct rtnl_nexthop *nh) void rtnl_route_remove_nexthop(struct rtnl_route *route, struct rtnl_nexthop *nh) { - route->rt_nr_nh--; - nl_list_del(&nh->rtnh_list); + if (route->ce_mask & ROUTE_ATTR_MULTIPATH) { + route->rt_nr_nh--; + nl_list_del(&nh->rtnh_list); + } } struct nl_list_head *rtnl_route_get_nexthops(struct rtnl_route *route) { - return &route->rt_nexthops; + if (route->ce_mask & ROUTE_ATTR_MULTIPATH) + return &route->rt_nexthops; + + return NULL; } int rtnl_route_get_nnexthops(struct rtnl_route *route) { - return route->rt_nr_nh; + if (route->ce_mask & ROUTE_ATTR_MULTIPATH) + return route->rt_nr_nh; + + return 0; } void rtnl_route_foreach_nexthop(struct rtnl_route *r,