99 lines
3.3 KiB
Diff
99 lines
3.3 KiB
Diff
From b95a9f0a7253f1d6d772bf0489bb0d55897411f9 Mon Sep 17 00:00:00 2001
|
|
From: Thomas Haller <thaller@redhat.com>
|
|
Date: Thu, 13 Feb 2014 21:31:37 +0100
|
|
Subject: [PATCH 1/2] route: rtnl_route_build_msg() should not overwrite the
|
|
route scope
|
|
|
|
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>
|
|
(cherry picked from commit 85ec9c7ad80c60f4f619472f2bb9d9595da93b26)
|
|
---
|
|
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.9.0
|
|
|
|
|
|
From 06633875c6ebbfae598edbc20a305f6c8fb55fc6 Mon Sep 17 00:00:00 2001
|
|
From: Thomas Haller <thaller@redhat.com>
|
|
Date: Thu, 13 Mar 2014 13:16:51 +0100
|
|
Subject: [PATCH 2/2] utils: indicate capability
|
|
NL_CAPABILITY_ROUTE_BUILD_MSG_SET_SCOPE
|
|
|
|
This capability indicates that libnl does no longer overwrites
|
|
the route scope in rtnl_route_build_msg(), as fixed by commit
|
|
85ec9c7ad80c60f4f619472f2bb9d9595da93b26.
|
|
|
|
Acked-by: Thomas Graf <tgraf@suug.ch>
|
|
Signed-off-by: Thomas Haller <thaller@redhat.com>
|
|
(cherry picked from commit 015c4ee59b786fec35118c2a963532b3e05ba5a2)
|
|
|
|
Conflicts:
|
|
include/netlink/utils.h
|
|
lib/utils.c
|
|
---
|
|
include/netlink/utils.h | 8 ++++++++
|
|
lib/utils.c | 2 +-
|
|
2 files changed, 9 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/include/netlink/utils.h b/include/netlink/utils.h
|
|
index e929cfd..5b0d275 100644
|
|
--- a/include/netlink/utils.h
|
|
+++ b/include/netlink/utils.h
|
|
@@ -83,6 +83,14 @@ enum {
|
|
NL_CAPABILITY_NONE,
|
|
|
|
/**
|
|
+ * rtnl_route_build_msg() no longer guesses the route scope
|
|
+ * if explicitly set to RT_SCOPE_NOWHERE.
|
|
+ * @ingroup utils
|
|
+ */
|
|
+ NL_CAPABILITY_ROUTE_BUILD_MSG_SET_SCOPE = 1,
|
|
+#define NL_CAPABILITY_ROUTE_BUILD_MSG_SET_SCOPE NL_CAPABILITY_ROUTE_BUILD_MSG_SET_SCOPE
|
|
+
|
|
+ /**
|
|
* Indicate that the local port is unspecified until the user accesses
|
|
* it (via nl_socket_get_local_port()) or until nl_connect(). More importantly,
|
|
* if the port is left unspecified, nl_connect() will retry generating another
|
|
diff --git a/lib/utils.c b/lib/utils.c
|
|
index 267368e..77d1ff0 100644
|
|
--- a/lib/utils.c
|
|
+++ b/lib/utils.c
|
|
@@ -1144,7 +1144,7 @@ int nl_has_capability (int capability)
|
|
_NL_SETV((i), 2, (v2)) | _NL_SETV((i), 6, (v6)) | \
|
|
_NL_SETV((i), 3, (v3)) | _NL_SETV((i), 7, (v7)) )
|
|
_NL_SET(0,
|
|
- 0,
|
|
+ NL_CAPABILITY_ROUTE_BUILD_MSG_SET_SCOPE,
|
|
0,
|
|
0,
|
|
NL_CAPABILITY_NL_CONNECT_RETRY_GENERATE_PORT_ON_ADDRINUSE,
|
|
--
|
|
1.9.0
|
|
|