]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ip route: error out on multiple via without nexthop keyword
authorDavid Ahern <dsa@cumulusnetworks.com>
Thu, 19 Jan 2017 17:08:21 +0000 (09:08 -0800)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 20 Jan 2017 17:38:20 +0000 (09:38 -0800)
To specify multiple nexthops in a route the user is expected to use the
"nexthop" keyword which ip route uses to create the RTA_MULTIPATH.
However, ip route always accepts multiple 'via' keywords where only the
last one is used in the route leading to confusion. For example, ip
accepts this syntax:
    $ ip ro add vrf red  1.1.1.0/24 via 10.100.1.18 via 10.100.2.18

but the route entered inserted by the kernel is just the last gateway:
    1.1.1.0/24 via 10.100.2.18 dev eth2

which is not the full request from the user. Detect the presense of
multiple 'via' and give the user a hint to add nexthop:

    $ ip ro add vrf red  1.1.1.0/24 via 10.100.1.18 via 10.100.2.18
    Error: argument "via" is wrong: use nexthop syntax to specify multiple via

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/iproute.c

index e433de8be189e1a100289c1148f4f4ac1d0292c0..52dbdc7dea36b572cc4c74f766b0fa1e7e8ba712 100644 (file)
@@ -881,6 +881,10 @@ static int iproute_modify(int cmd, unsigned int flags, int argc, char **argv)
                        inet_prefix addr;
                        int family;
 
+                       if (gw_ok) {
+                               invarg("use nexthop syntax to specify multiple via\n",
+                                      *argv);
+                       }
                        gw_ok = 1;
                        NEXT_ARG();
                        family = read_family(*argv);