]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
lwtunnel: fix argument parsing
authorPaolo Abeni <pabeni@redhat.com>
Tue, 15 Dec 2015 11:18:04 +0000 (12:18 +0100)
committerStephen Hemminger <shemming@brocade.com>
Fri, 18 Dec 2015 01:16:02 +0000 (17:16 -0800)
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

index b2764a6caf73b3ac4a4ca556571cf03d3040b54a..1243977cc0e8fe93869e4eb39fa8a5f6ddf361aa 100644 (file)
@@ -201,10 +201,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;
 }