aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2017-06-07 14:26:23 -0400
committerDavid S. Miller <davem@davemloft.net>2017-06-08 11:12:39 -0400
commit8397ed36b7c585f8d3e06c431f4137309124f78f (patch)
tree8a25809f8242f918ca61d97b4c509d0d569e057a
parent0eed9cf58446b28b233388b7f224cbca268b6986 (diff)
net: ipv6: Release route when device is unregistering
Roopa reported attempts to delete a bond device that is referenced in a multipath route is hanging: $ ifdown bond2 # ifupdown2 command that deletes virtual devices unregister_netdevice: waiting for bond2 to become free. Usage count = 2 Steps to reproduce: echo 1 > /proc/sys/net/ipv6/conf/all/ignore_routes_with_linkdown ip link add dev bond12 type bond ip link add dev bond13 type bond ip addr add 2001:db8:2::0/64 dev bond12 ip addr add 2001:db8:3::0/64 dev bond13 ip route add 2001:db8:33::0/64 nexthop via 2001:db8:2::2 nexthop via 2001:db8:3::2 ip link del dev bond12 ip link del dev bond13 The root cause is the recent change to keep routes on a linkdown. Update the check to detect when the device is unregistering and release the route for that case. Fixes: a1a22c12060e4 ("net: ipv6: Keep nexthop of multipath route on admin down") Reported-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: David Ahern <dsahern@gmail.com> Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/netdevice.h5
-rw-r--r--net/ipv6/route.c1
2 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index ab7ca3fdc495..846193dfb0ac 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -4262,6 +4262,11 @@ static inline const char *netdev_name(const struct net_device *dev)
4262 return dev->name; 4262 return dev->name;
4263} 4263}
4264 4264
4265static inline bool netdev_unregistering(const struct net_device *dev)
4266{
4267 return dev->reg_state == NETREG_UNREGISTERING;
4268}
4269
4265static inline const char *netdev_reg_state(const struct net_device *dev) 4270static inline const char *netdev_reg_state(const struct net_device *dev)
4266{ 4271{
4267 switch (dev->reg_state) { 4272 switch (dev->reg_state) {
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index dc61b0b5e64e..7cebd954d5bb 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2804,6 +2804,7 @@ static int fib6_ifdown(struct rt6_info *rt, void *arg)
2804 if ((rt->dst.dev == dev || !dev) && 2804 if ((rt->dst.dev == dev || !dev) &&
2805 rt != adn->net->ipv6.ip6_null_entry && 2805 rt != adn->net->ipv6.ip6_null_entry &&
2806 (rt->rt6i_nsiblings == 0 || 2806 (rt->rt6i_nsiblings == 0 ||
2807 (dev && netdev_unregistering(dev)) ||
2807 !rt->rt6i_idev->cnf.ignore_routes_with_linkdown)) 2808 !rt->rt6i_idev->cnf.ignore_routes_with_linkdown))
2808 return -1; 2809 return -1;
2809 2810