Thomas Bogendoerfer 5b79d7
From: Petr Machata <petrm@mellanox.com>
Thomas Bogendoerfer 5b79d7
Date: Mon, 18 Nov 2019 09:18:42 +0200
Thomas Bogendoerfer 5b79d7
Subject: mlxsw: spectrum_router: Fix determining underlay for a GRE tunnel
Thomas Bogendoerfer 5b79d7
Patch-mainline: v5.4
Thomas Bogendoerfer 5b79d7
Git-commit: 1fc1657775dc1b19e9ac1d46b4054ed8ae5d99ab
Thomas Bogendoerfer 5b79d7
References: bsc#1112374
Thomas Bogendoerfer 5b79d7
Thomas Bogendoerfer 5b79d7
The helper mlxsw_sp_ipip_dev_ul_tb_id() determines the underlay VRF of a
Thomas Bogendoerfer 5b79d7
GRE tunnel. For a tunnel without a bound device, it uses the same VRF that
Thomas Bogendoerfer 5b79d7
the tunnel is in. However in Linux, a GRE tunnel without a bound device
Thomas Bogendoerfer 5b79d7
uses the main VRF as the underlay. Fix the function accordingly.
Thomas Bogendoerfer 5b79d7
Thomas Bogendoerfer 5b79d7
mlxsw further assumed that moving a tunnel to a different VRF could cause
Thomas Bogendoerfer 5b79d7
conflict in local tunnel endpoint address, which cannot be offloaded.
Thomas Bogendoerfer 5b79d7
However, the only way that an underlay could be changed by moving the
Thomas Bogendoerfer 5b79d7
tunnel device itself is if the tunnel device does not have a bound device.
Thomas Bogendoerfer 5b79d7
But in that case the underlay is always the main VRF, so there is no
Thomas Bogendoerfer 5b79d7
opportunity to introduce a conflict by moving such device. Thus this check
Thomas Bogendoerfer 5b79d7
constitutes a dead code, and can be removed, which do.
Thomas Bogendoerfer 5b79d7
Thomas Bogendoerfer 5b79d7
Fixes: 6ddb7426a7d4 ("mlxsw: spectrum_router: Introduce loopback RIFs")
Thomas Bogendoerfer 5b79d7
Signed-off-by: Petr Machata <petrm@mellanox.com>
Thomas Bogendoerfer 5b79d7
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Thomas Bogendoerfer 5b79d7
Signed-off-by: David S. Miller <davem@davemloft.net>
Thomas Bogendoerfer 5b79d7
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
Thomas Bogendoerfer 5b79d7
---
Thomas Bogendoerfer 5b79d7
 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c |   19 ------------------
Thomas Bogendoerfer 5b79d7
 1 file changed, 1 insertion(+), 18 deletions(-)
Thomas Bogendoerfer 5b79d7
Thomas Bogendoerfer 5b79d7
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
Thomas Bogendoerfer 5b79d7
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
Thomas Bogendoerfer 5b79d7
@@ -984,7 +984,7 @@ u32 mlxsw_sp_ipip_dev_ul_tb_id(const str
Thomas Bogendoerfer 5b79d7
 	if (d)
Thomas Bogendoerfer 5b79d7
 		return l3mdev_fib_table(d) ? : RT_TABLE_MAIN;
Thomas Bogendoerfer 5b79d7
 	else
Thomas Bogendoerfer 5b79d7
-		return l3mdev_fib_table(ol_dev) ? : RT_TABLE_MAIN;
Thomas Bogendoerfer 5b79d7
+		return RT_TABLE_MAIN;
Thomas Bogendoerfer 5b79d7
 }
Thomas Bogendoerfer 5b79d7
 
Thomas Bogendoerfer 5b79d7
 static struct mlxsw_sp_rif *
Thomas Bogendoerfer 5b79d7
@@ -1589,27 +1589,10 @@ static int mlxsw_sp_netdevice_ipip_ol_vr
Thomas Bogendoerfer 5b79d7
 {
Thomas Bogendoerfer 5b79d7
 	struct mlxsw_sp_ipip_entry *ipip_entry =
Thomas Bogendoerfer 5b79d7
 		mlxsw_sp_ipip_entry_find_by_ol_dev(mlxsw_sp, ol_dev);
Thomas Bogendoerfer 5b79d7
-	enum mlxsw_sp_l3proto ul_proto;
Thomas Bogendoerfer 5b79d7
-	union mlxsw_sp_l3addr saddr;
Thomas Bogendoerfer 5b79d7
-	u32 ul_tb_id;
Thomas Bogendoerfer 5b79d7
 
Thomas Bogendoerfer 5b79d7
 	if (!ipip_entry)
Thomas Bogendoerfer 5b79d7
 		return 0;
Thomas Bogendoerfer 5b79d7
 
Thomas Bogendoerfer 5b79d7
-	/* For flat configuration cases, moving overlay to a different VRF might
Thomas Bogendoerfer 5b79d7
-	 * cause local address conflict, and the conflicting tunnels need to be
Thomas Bogendoerfer 5b79d7
-	 * demoted.
Thomas Bogendoerfer 5b79d7
-	 */
Thomas Bogendoerfer 5b79d7
-	ul_tb_id = mlxsw_sp_ipip_dev_ul_tb_id(ol_dev);
Thomas Bogendoerfer 5b79d7
-	ul_proto = mlxsw_sp->router->ipip_ops_arr[ipip_entry->ipipt]->ul_proto;
Thomas Bogendoerfer 5b79d7
-	saddr = mlxsw_sp_ipip_netdev_saddr(ul_proto, ol_dev);
Thomas Bogendoerfer 5b79d7
-	if (mlxsw_sp_ipip_demote_tunnel_by_saddr(mlxsw_sp, ul_proto,
Thomas Bogendoerfer 5b79d7
-						 saddr, ul_tb_id,
Thomas Bogendoerfer 5b79d7
-						 ipip_entry)) {
Thomas Bogendoerfer 5b79d7
-		mlxsw_sp_ipip_entry_demote_tunnel(mlxsw_sp, ipip_entry);
Thomas Bogendoerfer 5b79d7
-		return 0;
Thomas Bogendoerfer 5b79d7
-	}
Thomas Bogendoerfer 5b79d7
-
Thomas Bogendoerfer 5b79d7
 	return __mlxsw_sp_ipip_entry_update_tunnel(mlxsw_sp, ipip_entry,
Thomas Bogendoerfer 5b79d7
 						   true, false, false, extack);
Thomas Bogendoerfer 5b79d7
 }