All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/3] net: Fail route add with unsupported nexthop attribute
@ 2019-02-26 17:00 David Ahern
  2019-02-26 17:00 ` [PATCH net 1/3] ipv4: Return error for RTA_VIA attribute David Ahern
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: David Ahern @ 2019-02-26 17:00 UTC (permalink / raw)
  To: davem; +Cc: netdev, David Ahern

From: David Ahern <dsahern@gmail.com>

RTA_VIA was added for MPLS as a way of specifying a gateway from a
different address family. IPv4 and IPv6 do not currently support RTA_VIA
so using it leads to routes that are not what the user intended. Catch
and fail - returning a proper error message.

MPLS on the other hand does not support RTA_GATEWAY since it does not
make sense to have a nexthop from the MPLS address family. Similarly,
catch and fail - returning a proper error message.

David Ahern (3):
  ipv4: Return error for RTA_VIA attribute
  ipv6: Return error for RTA_VIA attribute
  mpls: Return error for RTA_GATEWAY attribute

 net/ipv4/fib_frontend.c | 4 ++++
 net/ipv6/route.c        | 4 ++++
 net/mpls/af_mpls.c      | 3 +++
 3 files changed, 11 insertions(+)

-- 
2.11.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net 1/3] ipv4: Return error for RTA_VIA attribute
  2019-02-26 17:00 [PATCH net 0/3] net: Fail route add with unsupported nexthop attribute David Ahern
@ 2019-02-26 17:00 ` David Ahern
  2019-02-26 17:00 ` [PATCH net 2/3] ipv6: " David Ahern
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: David Ahern @ 2019-02-26 17:00 UTC (permalink / raw)
  To: davem; +Cc: netdev, David Ahern

From: David Ahern <dsahern@gmail.com>

IPv4 currently does not support nexthops outside of the AF_INET family.
Specifically, it does not handle RTA_VIA attribute. If it is passed
in a route add request, the actual route added only uses the device
which is clearly not what the user intended:

  $ ip ro add 172.16.1.0/24 via inet6 2001:db8:1::1 dev eth0
  $ ip ro ls
  ...
  172.16.1.0/24 dev eth0

Catch this and fail the route add:
  $ ip ro add 172.16.1.0/24 via inet6 2001:db8:1::1 dev eth0
  Error: IPv4 does not support RTA_VIA attribute.

Fixes: 03c0566542f4c ("mpls: Netlink commands to add, remove, and dump routes")
Signed-off-by: David Ahern <dsahern@gmail.com>
---
 net/ipv4/fib_frontend.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index fe4f6a624238..ed14ec245584 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -710,6 +710,10 @@ static int rtm_to_fib_config(struct net *net, struct sk_buff *skb,
 		case RTA_GATEWAY:
 			cfg->fc_gw = nla_get_be32(attr);
 			break;
+		case RTA_VIA:
+			NL_SET_ERR_MSG(extack, "IPv4 does not support RTA_VIA attribute");
+			err = -EINVAL;
+			goto errout;
 		case RTA_PRIORITY:
 			cfg->fc_priority = nla_get_u32(attr);
 			break;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net 2/3] ipv6: Return error for RTA_VIA attribute
  2019-02-26 17:00 [PATCH net 0/3] net: Fail route add with unsupported nexthop attribute David Ahern
  2019-02-26 17:00 ` [PATCH net 1/3] ipv4: Return error for RTA_VIA attribute David Ahern
@ 2019-02-26 17:00 ` David Ahern
  2019-02-26 17:00 ` [PATCH net 3/3] mpls: Return error for RTA_GATEWAY attribute David Ahern
  2019-02-26 22:27 ` [PATCH net 0/3] net: Fail route add with unsupported nexthop attribute David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Ahern @ 2019-02-26 17:00 UTC (permalink / raw)
  To: davem; +Cc: netdev, David Ahern

From: David Ahern <dsahern@gmail.com>

IPv6 currently does not support nexthops outside of the AF_INET6 family.
Specifically, it does not handle RTA_VIA attribute. If it is passed
in a route add request, the actual route added only uses the device
which is clearly not what the user intended:

  $ ip -6 ro add 2001:db8:2::/64 via inet 172.16.1.1 dev eth0
  $ ip ro ls
  ...
  2001:db8:2::/64 dev eth0 metric 1024 pref medium

Catch this and fail the route add:
  $ ip -6 ro add 2001:db8:2::/64 via inet 172.16.1.1 dev eth0
  Error: IPv6 does not support RTA_VIA attribute.

Fixes: 03c0566542f4c ("mpls: Netlink commands to add, remove, and dump routes")
Signed-off-by: David Ahern <dsahern@gmail.com>
---
 net/ipv6/route.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index ce15dc4ccbfa..b7a620023a52 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -4182,6 +4182,10 @@ static int rtm_to_fib6_config(struct sk_buff *skb, struct nlmsghdr *nlh,
 		cfg->fc_gateway = nla_get_in6_addr(tb[RTA_GATEWAY]);
 		cfg->fc_flags |= RTF_GATEWAY;
 	}
+	if (tb[RTA_VIA]) {
+		NL_SET_ERR_MSG(extack, "IPv6 does not support RTA_VIA attribute");
+		goto errout;
+	}
 
 	if (tb[RTA_DST]) {
 		int plen = (rtm->rtm_dst_len + 7) >> 3;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net 3/3] mpls: Return error for RTA_GATEWAY attribute
  2019-02-26 17:00 [PATCH net 0/3] net: Fail route add with unsupported nexthop attribute David Ahern
  2019-02-26 17:00 ` [PATCH net 1/3] ipv4: Return error for RTA_VIA attribute David Ahern
  2019-02-26 17:00 ` [PATCH net 2/3] ipv6: " David Ahern
@ 2019-02-26 17:00 ` David Ahern
  2019-02-26 22:27 ` [PATCH net 0/3] net: Fail route add with unsupported nexthop attribute David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Ahern @ 2019-02-26 17:00 UTC (permalink / raw)
  To: davem; +Cc: netdev, David Ahern

From: David Ahern <dsahern@gmail.com>

MPLS does not support nexthops with an MPLS address family.
Specifically, it does not handle RTA_GATEWAY attribute. Make it
clear by returning an error.

Fixes: 03c0566542f4c ("mpls: Netlink commands to add, remove, and dump routes")
Signed-off-by: David Ahern <dsahern@gmail.com>
---
 net/mpls/af_mpls.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index 7d55d4c04088..fa763e2e50ec 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -1838,6 +1838,9 @@ static int rtm_to_route_config(struct sk_buff *skb,
 				goto errout;
 			break;
 		}
+		case RTA_GATEWAY:
+			NL_SET_ERR_MSG(extack, "MPLS does not support RTA_GATEWAY attribute");
+			goto errout;
 		case RTA_VIA:
 		{
 			if (nla_get_via(nla, &cfg->rc_via_alen,
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net 0/3] net: Fail route add with unsupported nexthop attribute
  2019-02-26 17:00 [PATCH net 0/3] net: Fail route add with unsupported nexthop attribute David Ahern
                   ` (2 preceding siblings ...)
  2019-02-26 17:00 ` [PATCH net 3/3] mpls: Return error for RTA_GATEWAY attribute David Ahern
@ 2019-02-26 22:27 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2019-02-26 22:27 UTC (permalink / raw)
  To: dsahern; +Cc: netdev, dsahern

From: David Ahern <dsahern@kernel.org>
Date: Tue, 26 Feb 2019 09:00:01 -0800

> From: David Ahern <dsahern@gmail.com>
> 
> RTA_VIA was added for MPLS as a way of specifying a gateway from a
> different address family. IPv4 and IPv6 do not currently support RTA_VIA
> so using it leads to routes that are not what the user intended. Catch
> and fail - returning a proper error message.
> 
> MPLS on the other hand does not support RTA_GATEWAY since it does not
> make sense to have a nexthop from the MPLS address family. Similarly,
> catch and fail - returning a proper error message.

Series applied and queued up for -stable.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-02-26 22:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-26 17:00 [PATCH net 0/3] net: Fail route add with unsupported nexthop attribute David Ahern
2019-02-26 17:00 ` [PATCH net 1/3] ipv4: Return error for RTA_VIA attribute David Ahern
2019-02-26 17:00 ` [PATCH net 2/3] ipv6: " David Ahern
2019-02-26 17:00 ` [PATCH net 3/3] mpls: Return error for RTA_GATEWAY attribute David Ahern
2019-02-26 22:27 ` [PATCH net 0/3] net: Fail route add with unsupported nexthop attribute David Miller

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.