net: Fail route add with unsupported nexthop attribute
Subsystems (3)
David Ahern
maintainercover net: Fail route add with unsupported nexthop attribute
From: David Ahern <[email protected]>
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(+)
Signature · 1 line
2.11.0
David Ahern
maintainerPATCH 1/3 ipv4: Return error for RTA_VIA attribute
From: David Ahern <[email protected]>
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.
--- net/ipv4/fib_frontend.c | 4 ++++ 1 file changed, 4 insertions(+)
net/ipv4/fib_frontend.c +4 -0
@@ -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 ;
Signature · 1 line
2.11.0
David Ahern
maintainerPATCH 2/3 ipv6: Return error for RTA_VIA attribute
In reply to David AhernFrom: David Ahern <[email protected]>
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.
--- net/ipv6/route.c | 4 ++++ 1 file changed, 4 insertions(+)
net/ipv6/route.c +4 -0
@@ -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 ;
Signature · 1 line
2.11.0
David Ahern
maintainerPATCH 3/3 mpls: Return error for RTA_GATEWAY attribute
In reply to David AhernFrom: David Ahern <[email protected]>
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.
--- net/mpls/af_mpls.c | 3 +++ 1 file changed, 3 insertions(+)
net/mpls/af_mpls.c +3 -0
@@ -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,
Signature · 1 line
2.11.0
David Miller
maintainerFrom: David Ahern <[email protected]>
Date: Tue, 26 Feb 2019 09:00:01 -0800
Quoted 10 lines
From: David Ahern <[email protected]>
RTA_VIAwas added for MPLS as a way of specifying a gateway from a different address family. IPv4 and IPv6 do not currently supportRTA_VIAso 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_GATEWAYsince 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.