Patchwork Latest iproute2 breaks "ip route get" command

login
register
mail settings
Submitter Andreas Henriksson
Date Aug. 8, 2010, 7:33 p.m.
Message ID <20100808193304.GA15380@amd64.fatal.se>
Download mbox | patch
Permalink /patch/61228/
State Superseded
Delegated to: stephen hemminger
Headers show

Comments

Fabio Comolli - Aug. 8, 2010, 7:31 p.m.
Yup, that seems to fix it.
You can add my Tested-By in case you need it.

Regards,
Fabio




On Sun, Aug 8, 2010 at 9:33 PM, Andreas Henriksson <andreas@fatal.se> wrote:
>> 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:
>
>
> diff --git a/ip/iproute.c b/ip/iproute.c
> index 711576e..86c7ab7 100644
> --- a/ip/iproute.c
> +++ b/ip/iproute.c
> @@ -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
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andreas Henriksson - Aug. 8, 2010, 7:33 p.m.
> 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:





(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 - Aug. 8, 2010, 7:52 p.m.
On sön, 2010-08-08 at 21:31 +0200, Fabio Comolli wrote:
> 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

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ulrich Weber - Aug. 12, 2010, 9:02 a.m.
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

On 08/08/2010 09:52 PM, Andreas Henriksson wrote:
> On sön, 2010-08-08 at 21:31 +0200, Fabio Comolli wrote:
>> 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
>
Fabio Comolli - Aug. 12, 2010, 9:12 a.m.
Hi.
Is this patch supposed to be applied on top of plain iproute2 v2.6.35
or on top of the previous Andreas' patch?



On Thu, Aug 12, 2010 at 11:05 AM, Ulrich Weber <uweber@astaro.com> 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.
>
> Signed-off-by: Ulrich Weber <uweber@astaro.com>
> ---
>  ip/iproute.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/ip/iproute.c b/ip/iproute.c
> index 711576e..b43933c 100644
> --- a/ip/iproute.c
> +++ b/ip/iproute.c
> @@ -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
>
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ulrich Weber - Aug. 12, 2010, 9:20 a.m.
The patch should be applied on top of iproute2 v2.6.35.

Cheers
 Ulrich

On 08/12/2010 11:12 AM, Fabio Comolli wrote:
> Hi.
> Is this patch supposed to be applied on top of plain iproute2 v2.6.35
> or on top of the previous Andreas' patch?
> 
> 
> 
> On Thu, Aug 12, 2010 at 11:05 AM, Ulrich Weber <uweber@astaro.com> 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.
>>
>> Signed-off-by: Ulrich Weber <uweber@astaro.com>
>> ---
>>  ip/iproute.c |    1 +
>>  1 files changed, 1 insertions(+), 0 deletions(-)
>>
>> diff --git a/ip/iproute.c b/ip/iproute.c
>> index 711576e..b43933c 100644
>> --- a/ip/iproute.c
>> +++ b/ip/iproute.c
>> @@ -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
>>
>>
Fabio Comolli - Aug. 12, 2010, 6:58 p.m.
Works for me (for ipv4, I cannot test ipv6).
You can add my Tested-By in case you need it.

Regards,
Fabio



On Thu, Aug 12, 2010 at 11:20 AM, Ulrich Weber <uweber@astaro.com> wrote:
> The patch should be applied on top of iproute2 v2.6.35.
>
> Cheers
>  Ulrich
>
> On 08/12/2010 11:12 AM, Fabio Comolli wrote:
>> Hi.
>> Is this patch supposed to be applied on top of plain iproute2 v2.6.35
>> or on top of the previous Andreas' patch?
>>
>>
>>
>> On Thu, Aug 12, 2010 at 11:05 AM, Ulrich Weber <uweber@astaro.com> 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.
>>>
>>> Signed-off-by: Ulrich Weber <uweber@astaro.com>
>>> ---
>>>  ip/iproute.c |    1 +
>>>  1 files changed, 1 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/ip/iproute.c b/ip/iproute.c
>>> index 711576e..b43933c 100644
>>> --- a/ip/iproute.c
>>> +++ b/ip/iproute.c
>>> @@ -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
>>>
>>>
>
>
> --
> Ulrich Weber | uweber@astaro.com | Software Engineer
> Astaro GmbH & Co. KG | www.astaro.com | Phone +49-721-25516-0 | Fax –200
> An der RaumFabrik 33a | 76227 Karlsruhe | Germany
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/ip/iproute.c b/ip/iproute.c
index 711576e..86c7ab7 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -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) {