Skip to contentSkip to conversation

Latest iproute2 breaks "ip route get" command

PATCH Applied Andreas Henriksson 4 participants 9 messages Aug 8, 2010 – Aug 23, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw
Quoted 3 lines

The following logs should explain the problem. In short, the "ip route get" command with iproute2 v. 2.6.35 does not output anything (and exits with a 0). This breaks (for example) vpnc.

Seems to be caused by:

http://git.kernel.org/?p=linux/kernel/git/shemminger/iproute2.git;a=commitdiff;h=447928279c88b6581ae4cdc1b5ac0a9e755aff64

Have no idea if this is the correct fix, but it seemed like a likely typo based on the changes in the above commit and that this brings the output back:

ip/iproute.c +1 -1
index 711576e..86c7ab7 100644
@@ -160,7 +160,7 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 	if (r->rtm_family == AF_INET6 && table != RT_TABLE_MAIN)
 		ip6_multiple_tables = 1;
 
-	if (filter.cloned == !(r->rtm_flags&RTM_F_CLONED))
+	if (filter.cloned && !(r->rtm_flags&RTM_F_CLONED))
 		return 0;
 
 	if (r->rtm_family == AF_INET6 && !ip6_multiple_tables) {

(PS. Sorry for not properly replying in thread, but todays mailing list archives seems to be extremely afraid of exposing any real mail headers making it hard to reply properly without having received the original mail.)

Signature · 1 line
Andreas Henriksson
#1 lore raw

Yup, that seems to fix it.
You can add my Tested-By in case you need it.

Regards,
Fabio

Quoted 35 lines · Andreas Henriksson
Quoted 3 lines

The following logs should explain the problem. In short, the "ip route get" command with iproute2 v. 2.6.35 does not output anything (and exits with a 0). This breaks (for example) vpnc.

Seems to be caused by:

http://git.kernel.org/?p=linux/kernel/git/shemminger/iproute2.git;a=commitdiff;h=447928279c88b6581ae4cdc1b5ac0a9e755aff64

Have no idea if this is the correct fix, but it seemed like a likely typo based on the changes in the above commit and that this brings the output back:

ip/iproute.c +1 -1
index 711576e..86c7ab7 100644
@@ -160,7 +160,7 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
        if (r->rtm_family == AF_INET6 && table != RT_TABLE_MAIN)
                ip6_multiple_tables = 1;
 
-       if (filter.cloned == !(r->rtm_flags&RTM_F_CLONED))
+       if (filter.cloned && !(r->rtm_flags&RTM_F_CLONED))
                return 0;
 
        if (r->rtm_family == AF_INET6 && !ip6_multiple_tables) {

(PS. Sorry for not properly replying in thread, but todays mailing list archives seems to be extremely afraid of exposing any real mail headers making it hard to reply properly without having received the original mail.)

--
Andreas Henriksson

#2 lore raw
Quoted 2 lines · Fabio Comolli

Yup, that seems to fix it.
You can add my Tested-By in case you need it.

I'll let Ulrich Weber confirm it's the right fix and forward to Stephen Hemminger. Just received an "out of office" notice saying he'll be back 11 august (wednesday), so I guess we'll have to wait a couple of days for that.

//Andreas

#3 lore raw

Hi Andreas,

your fix will work for IPv4 but will display the IPv6 cached routes again with "ip -6 route show" what I was trying to fix with 447928279c88b6581ae4cdc1b5ac0a9e755aff64

Will send another patch which makes the filter.cloned check not matching for iproute_get routes.

Best regards
Ulrich

Quoted 11 lines · Andreas Henriksson
Quoted 2 lines · Fabio Comolli

Yup, that seems to fix it.
You can add my Tested-By in case you need it.

I'll let Ulrich Weber confirm it's the right fix and forward to Stephen Hemminger. Just received an "out of office" notice saying he'll be back 11 august (wednesday), so I guess we'll have to wait a couple of days for that.

//Andreas

Signature · 3 lines
Ulrich Weber | [email protected] | Software Engineer
Astaro GmbH & Co. KG | www.astaro.com | Phone +49-721-25516-0 | Fax –200
An der RaumFabrik 33a | 76227 Karlsruhe | Germany
#4 lore raw

PATCH 1/1 iproute2: dont filter cached routes on iproute_get

In reply to Andreas Henriksson

iproute_get will return cloned routes for IPv4 and cloned as well non-cloned routes for IPv6.

Therefore RTM_F_CLONED flag should not be checked for iproute_get routes. Check in print_route will always fail because valid values are 0 and 1.

---
 ip/iproute.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
ip/iproute.c +1 -0
index 711576e..b43933c 100644
@@ -1286,6 +1286,7 @@ int iproute_get(int argc, char **argv)
 	memset(&req, 0, sizeof(req));
 
 	iproute_reset_filter();
+	filter.cloned = 2;
 
 	req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
 	req.n.nlmsg_flags = NLM_F_REQUEST;
Signature · 1 line
1.7.0.4
#5 lore raw

Re: [PATCH] iproute2: dont filter cached routes on iproute_get

Hi.
Is this patch supposed to be applied on top of plain iproute2 v2.6.35 or on top of the previous Andreas' patch?

Quoted 28 lines · Ulrich Weber

iproute_get will return cloned routes for IPv4 and cloned as well non-cloned routes for IPv6.

Therefore RTM_F_CLONED flag should not be checked for iproute_get routes. Check in print_route will always fail because valid values are 0 and 1.

---
 ip/iproute.c |    1 +

 1 files changed, 1 insertions(+), 0 deletions(-)
ip/iproute.c +1 -1
index 711576e..b43933c 100644
@@ -1286,6 +1286,7 @@ int iproute_get(int argc, char **argv)
        memset(&req, 0, sizeof(req));
 
        iproute_reset_filter();
+       filter.cloned = 2;
 
        req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
        req.n.nlmsg_flags = NLM_F_REQUEST;
--

1.7.0.4

#6 lore raw

Re: [PATCH] iproute2: dont filter cached routes on iproute_get

The patch should be applied on top of iproute2 v2.6.35.

Cheers
Ulrich

Quoted 35 lines · Fabio Comolli

Hi.
Is this patch supposed to be applied on top of plain iproute2 v2.6.35 or on top of the previous Andreas' patch?

Quoted 28 lines · Ulrich Weber

iproute_get will return cloned routes for IPv4 and cloned as well non-cloned routes for IPv6.

Therefore RTM_F_CLONED flag should not be checked for iproute_get routes. Check in print_route will always fail because valid values are 0 and 1.

---
 ip/iproute.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
ip/iproute.c +1 -1
index 711576e..b43933c 100644
@@ -1286,6 +1286,7 @@ int iproute_get(int argc, char **argv)
       memset(&req, 0, sizeof(req));
 
       iproute_reset_filter();
+       filter.cloned = 2;
 
       req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
       req.n.nlmsg_flags = NLM_F_REQUEST;
--

1.7.0.4

Signature · 3 lines
Ulrich Weber | [email protected] | Software Engineer
Astaro GmbH & Co. KG | www.astaro.com | Phone +49-721-25516-0 | Fax –200
An der RaumFabrik 33a | 76227 Karlsruhe | Germany
#7 lore raw

Re: [PATCH] iproute2: dont filter cached routes on iproute_get

Works for me (for ipv4, I cannot test ipv6).
You can add my Tested-By in case you need it.

Regards,
Fabio

Quoted 48 lines · Ulrich Weber

The patch should be applied on top of iproute2 v2.6.35.

Cheers
 Ulrich

Quoted 29 lines · Fabio Comolli

Hi.
Is this patch supposed to be applied on top of plain iproute2 v2.6.35 or on top of the previous Andreas' patch?

Quoted 22 lines · Ulrich Weber

iproute_get will return cloned routes for IPv4 and cloned as well non-cloned routes for IPv6.

Therefore RTM_F_CLONED flag should not be checked for iproute_get routes. Check in print_route will always fail because valid values are 0 and 1.

---
 ip/iproute.c |    1 +

 1 files changed, 1 insertions(+), 0 deletions(-)
ip/iproute.c +1 -0
index 711576e..b43933c 100644
@@ -1286,6 +1286,7 @@ int iproute_get(int argc, char **argv)
        memset(&req, 0, sizeof(req));
 
        iproute_reset_filter();
+       filter.cloned = 2;
 
Quoted 6 lines
Quoted 6 lines
ip/iproute.c +0 -1
        req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
        req.n.nlmsg_flags = NLM_F_REQUEST;
--

1.7.0.4

--
Ulrich Weber | [email protected] | Software Engineer
Astaro GmbH & Co. KG | www.astaro.com | Phone +49-721-25516-0 | Fax –200 An der RaumFabrik 33a | 76227 Karlsruhe | Germany

#8 lore raw

Re: [PATCH] iproute2: dont filter cached routes on iproute_get

In reply to Ulrich Weber
Quoted 17 lines · On Thu, 12 Aug 2010 11:05:19 +0200 Ulrich Weber <[email protected]> wrote:

iproute_get will return cloned routes for IPv4 and cloned as well non-cloned routes for IPv6.

Therefore RTM_F_CLONED flag should not be checked for iproute_get routes. Check in print_route will always fail because valid values are 0 and 1.

---
 ip/iproute.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
ip/iproute.c +0 -0
index 711576e..b43933c 100644

ip/iproute.c int iproute_get(int argc, char **argv) · line 1292

Quoted 7 lines
ip/iproute.c +1 -0
@@ -1286,6 +1286,7 @@ int iproute_get(int argc, char **argv)
 	memset(&req, 0, sizeof(req));
 
 	iproute_reset_filter();
+	filter.cloned = 2;
 
 	req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
 	req.n.nlmsg_flags = NLM_F_REQUEST;

Applied