* [PATCH iproute2] ip route: error out on multiple via without nexthop keyword
@ 2017-01-19 17:08 David Ahern
2017-01-20 17:38 ` Stephen Hemminger
0 siblings, 1 reply; 2+ messages in thread
From: David Ahern @ 2017-01-19 17:08 UTC (permalink / raw)
To: netdev, stephen; +Cc: David Ahern
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>
---
ip/iproute.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/ip/iproute.c b/ip/iproute.c
index e433de8be189..52dbdc7dea36 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -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);
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH iproute2] ip route: error out on multiple via without nexthop keyword
2017-01-19 17:08 [PATCH iproute2] ip route: error out on multiple via without nexthop keyword David Ahern
@ 2017-01-20 17:38 ` Stephen Hemminger
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2017-01-20 17:38 UTC (permalink / raw)
To: David Ahern; +Cc: netdev
On Thu, 19 Jan 2017 09:08:21 -0800
David Ahern <dsa@cumulusnetworks.com> wrote:
> 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>
Applied thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-20 17:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-19 17:08 [PATCH iproute2] ip route: error out on multiple via without nexthop keyword David Ahern
2017-01-20 17:38 ` Stephen Hemminger
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.