]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mlxsw: spectrum_router: Fix IPv4 nexthop gateway indication
authorIdo Schimmel <idosch@nvidia.com>
Tue, 19 Jul 2022 12:26:26 +0000 (15:26 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 20 Jul 2022 10:00:46 +0000 (11:00 +0100)
mlxsw needs to distinguish nexthops with a gateway from connected
nexthops in order to write the former to the adjacency table of the
device. The check used to rely on the fact that nexthops with a gateway
have a 'link' scope whereas connected nexthops have a 'host' scope. This
is no longer correct after commit 4be009aa4a33 ("ip: fix dflt addr
selection for connected nexthop").

Fix that by instead checking the address family of the gateway IP. This
is a more direct way and also consistent with the IPv6 counterpart in
mlxsw_sp_rt6_is_gateway().

Cc: stable@vger.kernel.org
Fixes: 4be009aa4a33 ("ip: fix dflt addr selection for connected nexthop")
Fixes: 4b16068d4069 ("nexthop: Add support for IPv4 nexthops")
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

index 85aa1c468cd4ae87caeaaa224ea57e1754664010..ce33dbde124d9dc4baedd125581da2d9d05bbcc6 100644 (file)
@@ -5384,7 +5384,7 @@ static bool mlxsw_sp_fi_is_gateway(const struct mlxsw_sp *mlxsw_sp,
 {
        const struct fib_nh *nh = fib_info_nh(fi, 0);
 
-       return nh->fib_nh_scope == RT_SCOPE_LINK ||
+       return nh->fib_nh_gw_family ||
               mlxsw_sp_nexthop4_ipip_type(mlxsw_sp, nh, NULL);
 }