From: David Ahern Date: Thu, 25 Jan 2018 03:45:29 +0000 (-0800) Subject: net/ipv6: Do not allow route add with a device that is down X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=955ec4cb3b54c7c389a9f830be7d3ae2056b9212;p=linux.git 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. Signed-off-by: David Ahern Reviewed-by: Ido Schimmel Reviewed-by: Roopa Prabhu Signed-off-by: David S. Miller --- diff --git a/net/ipv6/route.c b/net/ipv6/route.c index f85da2f1e7291..aa4411c81e7e3 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -2734,6 +2734,12 @@ 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"); + err = -ENETDOWN; + 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");