[PATCH 1/1] route: rtnl_route_build_msg() should not overwrite the route scope

Thomas Haller thaller at redhat.com
Fri Feb 14 04:13:27 EST 2014


rtnl_route_build_msg() should allow the user to set the route scope
explicitly to RT_SCOPE_NOWHERE and it should only try to guess the
scope, if it was not explicitly specified.

This is useful for IPv4 addresses, 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.

Signed-off-by: Thomas Haller <thaller at redhat.com>
---
 lib/route/route_obj.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/route/route_obj.c b/lib/route/route_obj.c
index f2de523..dd4bf49 100644
--- a/lib/route/route_obj.c
+++ b/lib/route/route_obj.c
@@ -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) {
-- 
1.8.5.3




More information about the libnl mailing list