* [PATCH iproute2] lwtunnel: fix argument parsing
@ 2015-12-15 11:18 Paolo Abeni
2015-12-18 1:16 ` Stephen Hemminger
0 siblings, 1 reply; 2+ messages in thread
From: Paolo Abeni @ 2015-12-15 11:18 UTC (permalink / raw)
To: shemming; +Cc: netdev, Roopa Prabhu
Currently parse_encap_ip() does not update correctly argv/argc;
if multiple lwtunnel arguments are provided, the parsing fails after
the first one, i.e.
ip route add 172.16.101.0/24 dev vxlan1 encap ip id 42 dst 192.168.255.1
fails with:
Error: either "to" is duplicate, or "dst" is a garbage.
This commit addresses the issue, stepping to next argument at each iteration
of the parsing loop.
Fixes: 1e5293056a02 ("lwtunnel: Add encapsulation support to ip route")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
ip/iproute_lwtunnel.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
index 63322a1..c825b82 100644
--- a/ip/iproute_lwtunnel.c
+++ b/ip/iproute_lwtunnel.c
@@ -178,10 +178,14 @@ static int parse_encap_ip(struct rtattr *rta, size_t len, int *argcp, char ***ar
} else {
break;
}
+ argc--; argv++;
}
- *argcp = argc;
- *argvp = argv;
+ /* argv is currently the first unparsed argument,
+ * but the lwt_parse_encap() caller will move to the next,
+ * so step back */
+ *argcp = argc + 1;
+ *argvp = argv - 1;
return 0;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH iproute2] lwtunnel: fix argument parsing
2015-12-15 11:18 [PATCH iproute2] lwtunnel: fix argument parsing Paolo Abeni
@ 2015-12-18 1:16 ` Stephen Hemminger
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2015-12-18 1:16 UTC (permalink / raw)
To: Paolo Abeni; +Cc: netdev, Roopa Prabhu
On Tue, 15 Dec 2015 12:18:04 +0100
Paolo Abeni <pabeni@redhat.com> wrote:
> Currently parse_encap_ip() does not update correctly argv/argc;
> if multiple lwtunnel arguments are provided, the parsing fails after
> the first one, i.e.
>
> ip route add 172.16.101.0/24 dev vxlan1 encap ip id 42 dst 192.168.255.1
>
> fails with:
>
> Error: either "to" is duplicate, or "dst" is a garbage.
>
> This commit addresses the issue, stepping to next argument at each iteration
> of the parsing loop.
>
> Fixes: 1e5293056a02 ("lwtunnel: Add encapsulation support to ip route")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Applied, thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-18 1:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-15 11:18 [PATCH iproute2] lwtunnel: fix argument parsing Paolo Abeni
2015-12-18 1:16 ` Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).