Skip to content

Commit 79099aa

Browse files
David Aherndavem330
authored andcommitted
mpls: Do not decrement alive counter for unregister events
Multipath routes can be rendered usesless when a device in one of the paths is deleted. For example: $ ip -f mpls ro ls 100 nexthop as to 200 via inet 172.16.2.2 dev virt12 nexthop as to 300 via inet 172.16.3.2 dev br0 101 nexthop as to 201 via inet6 2000:2::2 dev virt12 nexthop as to 301 via inet6 2000:3::2 dev br0 $ ip li del br0 When br0 is deleted the other hop is not considered in mpls_select_multipath because of the alive check -- rt_nhn_alive is 0. rt_nhn_alive is decremented once in mpls_ifdown when the device is taken down (NETDEV_DOWN) and again when it is deleted (NETDEV_UNREGISTER). For a 2 hop route, deleting one device drops the alive count to 0. Since devices are taken down before unregistering, the decrement on NETDEV_UNREGISTER is redundant. Fixes: c89359a ("mpls: support for dead routes") Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b17075d commit 79099aa

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/mpls/af_mpls.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,8 @@ static void mpls_ifdown(struct net_device *dev, int event)
12881288
/* fall through */
12891289
case NETDEV_CHANGE:
12901290
nh->nh_flags |= RTNH_F_LINKDOWN;
1291-
ACCESS_ONCE(rt->rt_nhn_alive) = rt->rt_nhn_alive - 1;
1291+
if (event != NETDEV_UNREGISTER)
1292+
ACCESS_ONCE(rt->rt_nhn_alive) = rt->rt_nhn_alive - 1;
12921293
break;
12931294
}
12941295
if (event == NETDEV_UNREGISTER)

0 commit comments

Comments
 (0)