[iproute PATCH] ip-route: Fix for listing routes with RTAX_LOCK attribute

Subsystems: the rest

STALE3260d

2 messages, 2 authors, 2017-09-29 · open the first message on its own page

[iproute PATCH] ip-route: Fix for listing routes with RTAX_LOCK attribute

From: Phil Sutter <phil@nwl.cc>
Date: 2017-09-28 17:34:10

This fixes a corner-case for routes with a certain metric locked to
zero:

| ip route add 192.168.7.0/24 dev eth0 window 0
| ip route add 192.168.7.0/24 dev eth0 window lock 0

Since the kernel doesn't dump the attribute if it is zero, both routes
added above would appear as if they were equal although they are not.

Fix this by taking mxlock value for the given metric into account before
skipping it if it is not present.

Reported-by: Thomas Haller <redacted>
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 ip/iproute.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ip/iproute.c b/ip/iproute.c
index a8733f45bf881..e81bc05ec16cb 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -574,10 +574,10 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 		for (i = 2; i <= RTAX_MAX; i++) {
 			__u32 val = 0U;
 
-			if (mxrta[i] == NULL)
+			if (mxrta[i] == NULL && !(mxlock & (1 << i)))
 				continue;
 
-			if (i != RTAX_CC_ALGO)
+			if (mxrta[i] != NULL && i != RTAX_CC_ALGO)
 				val = rta_getattr_u32(mxrta[i]);
 
 			if (i == RTAX_HOPLIMIT && (int)val == -1)
-- 
2.13.1

Re: [iproute PATCH] ip-route: Fix for listing routes with RTAX_LOCK attribute

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2017-09-29 19:03:04

On Thu, 28 Sep 2017 19:33:56 +0200
Phil Sutter [off-list ref] wrote:
This fixes a corner-case for routes with a certain metric locked to
zero:

| ip route add 192.168.7.0/24 dev eth0 window 0
| ip route add 192.168.7.0/24 dev eth0 window lock 0

Since the kernel doesn't dump the attribute if it is zero, both routes
added above would appear as if they were equal although they are not.

Fix this by taking mxlock value for the given metric into account before
skipping it if it is not present.

Reported-by: Thomas Haller <redacted>
Signed-off-by: Phil Sutter <phil@nwl.cc>
Looks good, Applied. Thanks Phil
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help