Skip to content

Commit 5dac9ea

Browse files
committed
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 <[email protected]>
2 parents 88275ed + 4ea8efa commit 5dac9ea

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

net/mpls/af_mpls.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ static void mpls_ifdown(struct net_device *dev, int event)
12991299
struct mpls_route __rcu **platform_label;
13001300
struct net *net = dev_net(dev);
13011301
unsigned int nh_flags = RTNH_F_DEAD | RTNH_F_LINKDOWN;
1302-
unsigned int alive;
1302+
unsigned int alive, deleted;
13031303
unsigned index;
13041304

13051305
platform_label = rtnl_dereference(net->mpls.platform_label);
@@ -1310,6 +1310,7 @@ static void mpls_ifdown(struct net_device *dev, int event)
13101310
continue;
13111311

13121312
alive = 0;
1313+
deleted = 0;
13131314
change_nexthops(rt) {
13141315
if (rtnl_dereference(nh->nh_dev) != dev)
13151316
goto next;
@@ -1328,9 +1329,15 @@ static void mpls_ifdown(struct net_device *dev, int event)
13281329
next:
13291330
if (!(nh->nh_flags & nh_flags))
13301331
alive++;
1332+
if (!rtnl_dereference(nh->nh_dev))
1333+
deleted++;
13311334
} endfor_nexthops(rt);
13321335

13331336
WRITE_ONCE(rt->rt_nhn_alive, alive);
1337+
1338+
/* if there are no more nexthops, delete the route */
1339+
if (event == NETDEV_UNREGISTER && deleted == rt->rt_nhn)
1340+
mpls_route_update(net, index, NULL, NULL);
13341341
}
13351342
}
13361343

@@ -1769,13 +1776,15 @@ static int mpls_dump_route(struct sk_buff *skb, u32 portid, u32 seq, int event,
17691776
goto nla_put_failure;
17701777

17711778
for_nexthops(rt) {
1779+
dev = rtnl_dereference(nh->nh_dev);
1780+
if (!dev)
1781+
continue;
1782+
17721783
rtnh = nla_reserve_nohdr(skb, sizeof(*rtnh));
17731784
if (!rtnh)
17741785
goto nla_put_failure;
17751786

1776-
dev = rtnl_dereference(nh->nh_dev);
1777-
if (dev)
1778-
rtnh->rtnh_ifindex = dev->ifindex;
1787+
rtnh->rtnh_ifindex = dev->ifindex;
17791788
if (nh->nh_flags & RTNH_F_LINKDOWN) {
17801789
rtnh->rtnh_flags |= RTNH_F_LINKDOWN;
17811790
linkdown++;

0 commit comments

Comments
 (0)