]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mlxsw: spectrum_router: Only provide MAC address for valid nexthops
authorIdo Schimmel <idosch@nvidia.com>
Mon, 22 Mar 2021 15:58:44 +0000 (17:58 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 22 Mar 2021 20:45:46 +0000 (13:45 -0700)
The helper returns the MAC address associated with the nexthop. It is
only valid when the nexthop forwards packets and when it is an Ethernet
nexthop. Reflect this in the checks the helper is performing.

This is not an issue because the sole caller of the function only
invokes it for such nexthops.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

index 593a40aa9af888665a2fffb213c996f0d13ad555..b7358cf611c17e1094664d4eedb08d81d766bac3 100644 (file)
@@ -2986,7 +2986,8 @@ bool mlxsw_sp_nexthop_is_forward(const struct mlxsw_sp_nexthop *nh)
 
 unsigned char *mlxsw_sp_nexthop_ha(struct mlxsw_sp_nexthop *nh)
 {
-       if (!nh->offloaded)
+       if (nh->type != MLXSW_SP_NEXTHOP_TYPE_ETH ||
+           !mlxsw_sp_nexthop_is_forward(nh))
                return NULL;
        return nh->neigh_entry->ha;
 }