Commit 4ea8efad authored by David Ahern's avatar David Ahern Committed by David S. Miller

net: mpls: Delete route when all nexthops have been deleted

When all devices for all nexthops in a route have been deleted, the
route is effectively dead, so remove it.
Signed-off-by: default avatarDavid Ahern <dsa@cumulusnetworks.com>
Acked-by: default avatarRoopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c00e51dd
...@@ -1299,7 +1299,7 @@ static void mpls_ifdown(struct net_device *dev, int event) ...@@ -1299,7 +1299,7 @@ static void mpls_ifdown(struct net_device *dev, int event)
struct mpls_route __rcu **platform_label; struct mpls_route __rcu **platform_label;
struct net *net = dev_net(dev); struct net *net = dev_net(dev);
unsigned int nh_flags = RTNH_F_DEAD | RTNH_F_LINKDOWN; unsigned int nh_flags = RTNH_F_DEAD | RTNH_F_LINKDOWN;
unsigned int alive; unsigned int alive, deleted;
unsigned index; unsigned index;
platform_label = rtnl_dereference(net->mpls.platform_label); platform_label = rtnl_dereference(net->mpls.platform_label);
...@@ -1310,6 +1310,7 @@ static void mpls_ifdown(struct net_device *dev, int event) ...@@ -1310,6 +1310,7 @@ static void mpls_ifdown(struct net_device *dev, int event)
continue; continue;
alive = 0; alive = 0;
deleted = 0;
change_nexthops(rt) { change_nexthops(rt) {
if (rtnl_dereference(nh->nh_dev) != dev) if (rtnl_dereference(nh->nh_dev) != dev)
goto next; goto next;
...@@ -1328,9 +1329,15 @@ static void mpls_ifdown(struct net_device *dev, int event) ...@@ -1328,9 +1329,15 @@ static void mpls_ifdown(struct net_device *dev, int event)
next: next:
if (!(nh->nh_flags & nh_flags)) if (!(nh->nh_flags & nh_flags))
alive++; alive++;
if (!rtnl_dereference(nh->nh_dev))
deleted++;
} endfor_nexthops(rt); } endfor_nexthops(rt);
WRITE_ONCE(rt->rt_nhn_alive, alive); WRITE_ONCE(rt->rt_nhn_alive, alive);
/* if there are no more nexthops, delete the route */
if (event == NETDEV_UNREGISTER && deleted == rt->rt_nhn)
mpls_route_update(net, index, NULL, NULL);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment