Skip to contentSkip to conversation

net/ipv6: Do not allow route add with a device that is down

PATCH Superseded David Ahern 3 participants 3 messages Jan 24, 2018

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

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
index f85da2f1e729..689670713744 100644
@@ -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
#1 lore raw
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.

---
 net/ipv6/route.c | 5 +++++
 1 file changed, 5 insertions(+)
net/ipv6/route.c +0 -0
index f85da2f1e729..689670713744 100644

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

#2 lore raw
In reply to David Ahern
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.

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