net/ipv6: Do not allow route add with a device that is down
Subsystems (3)
PATCH 1/1 net/ipv6: Do not allow route add with a device that is down
IPv6 allows routes to be installed when the device is not up (admin up). Worse, it does not mark it as LINKDOWN. IPv4 does not allow it and really there is no reason for IPv6 to allow it, so check the flags and deny if device is admin down.
--- net/ipv6/route.c | 5 +++++ 1 file changed, 5 insertions(+)
net/ipv6/route.c +5 -0
@@ -2734,6 +2734,11 @@ static struct rt6_info *ip6_route_info_create(struct fib6_config *cfg,if (!dev) goto out; +if (!(dev->flags &IFF_UP )) { +NL_SET_ERR_MSG (extack,"Nexthop device is not up" ); + goto out; + } +if (!ipv6_addr_any (&cfg->fc_prefsrc)) {if (!ipv6_chk_addr (net, &cfg->fc_prefsrc, dev,0 )) {NL_SET_ERR_MSG (extack,"Invalid source address" );
Signature · 1 line
2.11.0
Quoted 15 lines · David Ahern
IPv6 allows routes to be installed when the device is not up (admin up). Worse, it does not mark it as LINKDOWN. IPv4 does not allow it and really there is no reason for IPv6 to allow it, so check the flags and deny if device is admin down.
Signed-off-by David Ahern <[email protected]>--- net/ipv6/route.c | 5 +++++ 1 file changed, 5 insertions(+)net/ipv6/route.c +0
-0
net/ipv6/route.c static struct rt6_info *ip6_route_info_create(struct fib6_config *cfg, · line 2740
Quoted 7 lines
net/ipv6/route.c +4
-0@@ -2734,6 +2734,11 @@ static struct rt6_info *ip6_route_info_create(struct fib6_config *cfg,if (!dev) goto out; +if (!(dev->flags &IFF_UP )) { +NL_SET_ERR_MSG (extack,"Nexthop device is not up" ); + goto out; + }
looks like it will need a -ENETDOWN too ?
Quoted 7 lines
net/ipv6/route.c +1
-1+if (!ipv6_addr_any (&cfg->fc_prefsrc)) {if (!ipv6_chk_addr (net, &cfg->fc_prefsrc, dev,0 )) {NL_SET_ERR_MSG (extack,"Invalid source address" ); --2.11.0
Quoted 6 lines · David Ahern
IPv6 allows routes to be installed when the device is not up (admin up). Worse, it does not mark it as LINKDOWN. IPv4 does not allow it and really there is no reason for IPv6 to allow it, so check the flags and deny if device is admin down.
Signed-off-by David Ahern <[email protected]>
I figured people might complain if I change that, but I obviously prefer to have it like IPv4. Agree with Roopa about the error code.
Thanks