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

mlxsw: spectrum_router: Don't reflect LINKDOWN nexthops

The kernel resolves the nexthops for a given route using
FIB_LOOKUP_IGNORE_LINKSTATE which means a notification can be sent for a
route with one of its nexthops being LINKDOWN.

In case IGNORE_ROUTES_WITH_LINKDOWN is set for the nexthop netdev, then
we shouldn't reflect the nexthop to the device's table.

Once the nexthop netdev's carrier goes up we'll be notified using NH_ADD
and reflect it to the device.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Ido Schimmel and committed by
David S. Miller
df6dd79b d9e1661d

+10 -1
+10 -1
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
··· 40 40 #include <linux/bitops.h> 41 41 #include <linux/in6.h> 42 42 #include <linux/notifier.h> 43 + #include <linux/inetdevice.h> 43 44 #include <net/netevent.h> 44 45 #include <net/neighbour.h> 45 46 #include <net/arp.h> ··· 1549 1548 struct fib_nh *fib_nh) 1550 1549 { 1551 1550 struct net_device *dev = fib_nh->nh_dev; 1551 + struct in_device *in_dev; 1552 1552 struct mlxsw_sp_rif *r; 1553 1553 int err; 1554 1554 ··· 1558 1556 err = mlxsw_sp_nexthop_insert(mlxsw_sp, nh); 1559 1557 if (err) 1560 1558 return err; 1559 + 1560 + in_dev = __in_dev_get_rtnl(dev); 1561 + if (in_dev && IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN(in_dev) && 1562 + fib_nh->nh_flags & RTNH_F_LINKDOWN) 1563 + return 0; 1561 1564 1562 1565 r = mlxsw_sp_rif_find_by_dev(mlxsw_sp, dev); 1563 1566 if (!r) ··· 1667 1660 1668 1661 err_nexthop_group_insert: 1669 1662 err_nexthop_init: 1670 - for (i--; i >= 0; i--) 1663 + for (i--; i >= 0; i--) { 1664 + nh = &nh_grp->nexthops[i]; 1671 1665 mlxsw_sp_nexthop_fini(mlxsw_sp, nh); 1666 + } 1672 1667 kfree(nh_grp); 1673 1668 return ERR_PTR(err); 1674 1669 }