Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'mpls-multipath-route-cleanups'

David Ahern says:

====================
net: mpls: multipath route cleanups

When a device associated with a nexthop is deleted, the nexthop in
the route is effectively removed, so remove it from the route dump.

Further, when all nexhops have been deleted the route is effectively
done, so remove the route.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+13 -4
+13 -4
net/mpls/af_mpls.c
··· 1299 1299 struct mpls_route __rcu **platform_label; 1300 1300 struct net *net = dev_net(dev); 1301 1301 unsigned int nh_flags = RTNH_F_DEAD | RTNH_F_LINKDOWN; 1302 - unsigned int alive; 1302 + unsigned int alive, deleted; 1303 1303 unsigned index; 1304 1304 1305 1305 platform_label = rtnl_dereference(net->mpls.platform_label); ··· 1310 1310 continue; 1311 1311 1312 1312 alive = 0; 1313 + deleted = 0; 1313 1314 change_nexthops(rt) { 1314 1315 if (rtnl_dereference(nh->nh_dev) != dev) 1315 1316 goto next; ··· 1329 1328 next: 1330 1329 if (!(nh->nh_flags & nh_flags)) 1331 1330 alive++; 1331 + if (!rtnl_dereference(nh->nh_dev)) 1332 + deleted++; 1332 1333 } endfor_nexthops(rt); 1333 1334 1334 1335 WRITE_ONCE(rt->rt_nhn_alive, alive); 1336 + 1337 + /* if there are no more nexthops, delete the route */ 1338 + if (event == NETDEV_UNREGISTER && deleted == rt->rt_nhn) 1339 + mpls_route_update(net, index, NULL, NULL); 1335 1340 } 1336 1341 } 1337 1342 ··· 1776 1769 goto nla_put_failure; 1777 1770 1778 1771 for_nexthops(rt) { 1772 + dev = rtnl_dereference(nh->nh_dev); 1773 + if (!dev) 1774 + continue; 1775 + 1779 1776 rtnh = nla_reserve_nohdr(skb, sizeof(*rtnh)); 1780 1777 if (!rtnh) 1781 1778 goto nla_put_failure; 1782 1779 1783 - dev = rtnl_dereference(nh->nh_dev); 1784 - if (dev) 1785 - rtnh->rtnh_ifindex = dev->ifindex; 1780 + rtnh->rtnh_ifindex = dev->ifindex; 1786 1781 if (nh->nh_flags & RTNH_F_LINKDOWN) { 1787 1782 rtnh->rtnh_flags |= RTNH_F_LINKDOWN; 1788 1783 linkdown++;