]> granicus.if.org Git - libnl/commitdiff
route: rtnl_route_build_msg() should not overwrite the route scope
authorThomas Haller <thaller@redhat.com>
Thu, 13 Feb 2014 20:31:37 +0000 (21:31 +0100)
committerThomas Haller <thaller@redhat.com>
Thu, 20 Feb 2014 15:49:46 +0000 (16:49 +0100)
rtnl_route_build_msg() should allow the user to set the route scope
explicitly to RT_SCOPE_NOWHERE.

This is useful for IPv4 routes, because when deleting a route,
the kernel requires the scope to match, unless the scope is set to
RT_SCOPE_NOWHERE. Thus by setting the scope to RT_SCOPE_NOWHERE,
the user can delete a route, even without knowing its scope.

rtnl_route_build_msg() should only try to guess the scope, if it was
not explicitly specified.

Signed-off-by: Thomas Haller <thaller@redhat.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
lib/route/route_obj.c

index f2de523e37be5613ca3d8634ef7e22e6871a46d1..dd4bf49e6455aba95cc560f16ae71eb46544ed69 100644 (file)
@@ -1198,7 +1198,7 @@ int rtnl_route_build_msg(struct nl_msg *msg, struct rtnl_route *route)
        if (route->rt_src)
                rtmsg.rtm_src_len = nl_addr_get_prefixlen(route->rt_src);
 
-       if (rtmsg.rtm_scope == RT_SCOPE_NOWHERE)
+       if (!(route->ce_mask & ROUTE_ATTR_SCOPE))
                rtmsg.rtm_scope = rtnl_route_guess_scope(route);
 
        if (rtnl_route_get_nnexthops(route) == 1) {