All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/4] mlxsw: Various fixes
@ 2018-12-06 17:44 Ido Schimmel
  2018-12-06 17:44 ` [PATCH net 1/4] mlxsw: spectrum_nve: Remove easily triggerable warnings Ido Schimmel
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Ido Schimmel @ 2018-12-06 17:44 UTC (permalink / raw)
  To: netdev; +Cc: davem, Jiri Pirko, Nir Dotan, Petr Machata, Ido Schimmel

Patches #1 and #2 fix two VxLAN related issues. The first patch removes
warnings that can currently be triggered from user space. Second patch
avoids leaking a FID in an error path.

Patch #3 fixes a too strict check that causes certain host routes not to
be promoted to perform GRE decapsulation in hardware.

Last patch avoids a use-after-free when deleting a VLAN device via an
ioctl when it is enslaved to a bridge. I have a patchset for net-next
that reworks this code and makes the driver more robust.

Ido Schimmel (3):
  mlxsw: spectrum_nve: Remove easily triggerable warnings
  mlxsw: spectrum_switchdev: Avoid leaking FID's reference count
  mlxsw: spectrum_switchdev: Fix VLAN device deletion via ioctl

Nir Dotan (1):
  mlxsw: spectrum_router: Relax GRE decap matching check

 .../net/ethernet/mellanox/mlxsw/spectrum_nve.c  |  4 ++--
 .../ethernet/mellanox/mlxsw/spectrum_router.c   |  5 +----
 .../mellanox/mlxsw/spectrum_switchdev.c         | 17 +++++++++++++----
 3 files changed, 16 insertions(+), 10 deletions(-)

-- 
2.19.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net 1/4] mlxsw: spectrum_nve: Remove easily triggerable warnings
  2018-12-06 17:44 [PATCH net 0/4] mlxsw: Various fixes Ido Schimmel
@ 2018-12-06 17:44 ` Ido Schimmel
  2018-12-06 17:44 ` [PATCH net 2/4] mlxsw: spectrum_switchdev: Avoid leaking FID's reference count Ido Schimmel
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Ido Schimmel @ 2018-12-06 17:44 UTC (permalink / raw)
  To: netdev; +Cc: davem, Jiri Pirko, Nir Dotan, Petr Machata, Ido Schimmel

It is possible to trigger a warning in mlxsw in case a flood entry which
mlxsw is not aware of is deleted from the VxLAN device. This is because
mlxsw expects to find a singly linked list where the flood entry is
present in.

Fix by removing these warnings for now.

Will re-add them in the next release after we teach mlxsw to ask for a
dump of FDB entries from the VxLAN device, once it is enslaved to a
bridge mlxsw cares about.

Fixes: 6e6030bd5412 ("mlxsw: spectrum_nve: Implement common NVE core")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Petr Machata <petrm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c
index ad06d9969bc1..5c13674439f1 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c
@@ -560,7 +560,7 @@ static void mlxsw_sp_nve_mc_list_ip_del(struct mlxsw_sp *mlxsw_sp,
 
 	mc_record = mlxsw_sp_nve_mc_record_find(mc_list, proto, addr,
 						&mc_entry);
-	if (WARN_ON(!mc_record))
+	if (!mc_record)
 		return;
 
 	mlxsw_sp_nve_mc_record_entry_del(mc_record, mc_entry);
@@ -647,7 +647,7 @@ void mlxsw_sp_nve_flood_ip_del(struct mlxsw_sp *mlxsw_sp,
 
 	key.fid_index = mlxsw_sp_fid_index(fid);
 	mc_list = mlxsw_sp_nve_mc_list_find(mlxsw_sp, &key);
-	if (WARN_ON(!mc_list))
+	if (!mc_list)
 		return;
 
 	mlxsw_sp_nve_fid_flood_index_clear(fid, mc_list);
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net 2/4] mlxsw: spectrum_switchdev: Avoid leaking FID's reference count
  2018-12-06 17:44 [PATCH net 0/4] mlxsw: Various fixes Ido Schimmel
  2018-12-06 17:44 ` [PATCH net 1/4] mlxsw: spectrum_nve: Remove easily triggerable warnings Ido Schimmel
@ 2018-12-06 17:44 ` Ido Schimmel
  2018-12-06 17:44 ` [PATCH net 3/4] mlxsw: spectrum_router: Relax GRE decap matching check Ido Schimmel
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Ido Schimmel @ 2018-12-06 17:44 UTC (permalink / raw)
  To: netdev; +Cc: davem, Jiri Pirko, Nir Dotan, Petr Machata, Ido Schimmel

It should never be possible for a user to set a VNI on a FID in case one
is already set. The driver therefore returns an error, but fails to drop
the reference count taken earlier when calling
mlxsw_sp_fid_8021d_lookup().

Drop the reference when this unlikely error is hit.

Fixes: 1c30d1836aeb ("mlxsw: spectrum: Enable VxLAN enslavement to bridges")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index 739a51f0a366..7f2091c2648e 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -2134,8 +2134,10 @@ mlxsw_sp_bridge_8021d_vxlan_join(struct mlxsw_sp_bridge_device *bridge_device,
 	if (!fid)
 		return -EINVAL;
 
-	if (mlxsw_sp_fid_vni_is_set(fid))
-		return -EINVAL;
+	if (mlxsw_sp_fid_vni_is_set(fid)) {
+		err = -EINVAL;
+		goto err_vni_exists;
+	}
 
 	err = mlxsw_sp_nve_fid_enable(mlxsw_sp, fid, &params, extack);
 	if (err)
@@ -2149,6 +2151,7 @@ mlxsw_sp_bridge_8021d_vxlan_join(struct mlxsw_sp_bridge_device *bridge_device,
 	return 0;
 
 err_nve_fid_enable:
+err_vni_exists:
 	mlxsw_sp_fid_put(fid);
 	return err;
 }
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net 3/4] mlxsw: spectrum_router: Relax GRE decap matching check
  2018-12-06 17:44 [PATCH net 0/4] mlxsw: Various fixes Ido Schimmel
  2018-12-06 17:44 ` [PATCH net 1/4] mlxsw: spectrum_nve: Remove easily triggerable warnings Ido Schimmel
  2018-12-06 17:44 ` [PATCH net 2/4] mlxsw: spectrum_switchdev: Avoid leaking FID's reference count Ido Schimmel
@ 2018-12-06 17:44 ` Ido Schimmel
  2018-12-06 17:44 ` [PATCH net 4/4] mlxsw: spectrum_switchdev: Fix VLAN device deletion via ioctl Ido Schimmel
  2018-12-06 21:31 ` [PATCH net 0/4] mlxsw: Various fixes David Miller
  4 siblings, 0 replies; 7+ messages in thread
From: Ido Schimmel @ 2018-12-06 17:44 UTC (permalink / raw)
  To: netdev; +Cc: davem, Jiri Pirko, Nir Dotan, Petr Machata, Ido Schimmel

From: Nir Dotan <nird@mellanox.com>

GRE decap offload is configured when local routes prefix correspond to the
local address of one of the offloaded GRE tunnels. The matching check was
found to be too strict, such that for a flat GRE configuration, in which
the overlay and underlay traffic share the same non-default VRF, decap flow
was not offloaded.

Relax the check for decap flow offloading. A match occurs if the local
address of the tunnel matches the local route address while both share the
same VRF table.

Fixes: 4607f6d26950 ("mlxsw: spectrum_router: Support IPv4 underlay decap")
Signed-off-by: Nir Dotan <nird@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 9e9bb57134f2..6ebf99cc3154 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -1275,15 +1275,12 @@ mlxsw_sp_ipip_entry_matches_decap(struct mlxsw_sp *mlxsw_sp,
 {
 	u32 ul_tb_id = l3mdev_fib_table(ul_dev) ? : RT_TABLE_MAIN;
 	enum mlxsw_sp_ipip_type ipipt = ipip_entry->ipipt;
-	struct net_device *ipip_ul_dev;
 
 	if (mlxsw_sp->router->ipip_ops_arr[ipipt]->ul_proto != ul_proto)
 		return false;
 
-	ipip_ul_dev = __mlxsw_sp_ipip_netdev_ul_dev_get(ipip_entry->ol_dev);
 	return mlxsw_sp_ipip_entry_saddr_matches(mlxsw_sp, ul_proto, ul_dip,
-						 ul_tb_id, ipip_entry) &&
-	       (!ipip_ul_dev || ipip_ul_dev == ul_dev);
+						 ul_tb_id, ipip_entry);
 }
 
 /* Given decap parameters, find the corresponding IPIP entry. */
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net 4/4] mlxsw: spectrum_switchdev: Fix VLAN device deletion via ioctl
  2018-12-06 17:44 [PATCH net 0/4] mlxsw: Various fixes Ido Schimmel
                   ` (2 preceding siblings ...)
  2018-12-06 17:44 ` [PATCH net 3/4] mlxsw: spectrum_router: Relax GRE decap matching check Ido Schimmel
@ 2018-12-06 17:44 ` Ido Schimmel
  2018-12-06 21:31 ` [PATCH net 0/4] mlxsw: Various fixes David Miller
  4 siblings, 0 replies; 7+ messages in thread
From: Ido Schimmel @ 2018-12-06 17:44 UTC (permalink / raw)
  To: netdev; +Cc: davem, Jiri Pirko, Nir Dotan, Petr Machata, Ido Schimmel

When deleting a VLAN device using an ioctl the netdev is unregistered
before the VLAN filter is updated via ndo_vlan_rx_kill_vid(). It can
lead to a use-after-free in mlxsw in case the VLAN device is deleted
while being enslaved to a bridge.

The reason for the above is that when mlxsw receives the CHANGEUPPER
event, it wrongly assumes that the VLAN device is no longer its upper
and thus destroys the internal representation of the bridge port despite
the reference count being non-zero.

Fix this by checking if the VLAN device is our upper using its real
device. In net-next I'm going to remove this trick and instead make
mlxsw completely agnostic to the order of the events.

Fixes: c57529e1d5d8 ("mlxsw: spectrum: Replace vPorts with Port-VLAN")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Petr Machata <petrm@mellanox.com>
---
 .../net/ethernet/mellanox/mlxsw/spectrum_switchdev.c   | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index 7f2091c2648e..50080c60a279 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -296,7 +296,13 @@ static bool
 mlxsw_sp_bridge_port_should_destroy(const struct mlxsw_sp_bridge_port *
 				    bridge_port)
 {
-	struct mlxsw_sp *mlxsw_sp = mlxsw_sp_lower_get(bridge_port->dev);
+	struct net_device *dev = bridge_port->dev;
+	struct mlxsw_sp *mlxsw_sp;
+
+	if (is_vlan_dev(dev))
+		mlxsw_sp = mlxsw_sp_lower_get(vlan_dev_real_dev(dev));
+	else
+		mlxsw_sp = mlxsw_sp_lower_get(dev);
 
 	/* In case ports were pulled from out of a bridged LAG, then
 	 * it's possible the reference count isn't zero, yet the bridge
@@ -2109,7 +2115,7 @@ mlxsw_sp_bridge_8021d_port_leave(struct mlxsw_sp_bridge_device *bridge_device,
 
 	vid = is_vlan_dev(dev) ? vlan_dev_vlan_id(dev) : 1;
 	mlxsw_sp_port_vlan = mlxsw_sp_port_vlan_find_by_vid(mlxsw_sp_port, vid);
-	if (WARN_ON(!mlxsw_sp_port_vlan))
+	if (!mlxsw_sp_port_vlan)
 		return;
 
 	mlxsw_sp_port_vlan_bridge_leave(mlxsw_sp_port_vlan);
-- 
2.19.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net 0/4] mlxsw: Various fixes
  2018-12-06 17:44 [PATCH net 0/4] mlxsw: Various fixes Ido Schimmel
                   ` (3 preceding siblings ...)
  2018-12-06 17:44 ` [PATCH net 4/4] mlxsw: spectrum_switchdev: Fix VLAN device deletion via ioctl Ido Schimmel
@ 2018-12-06 21:31 ` David Miller
  4 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2018-12-06 21:31 UTC (permalink / raw)
  To: idosch; +Cc: netdev, jiri, nird, petrm

From: Ido Schimmel <idosch@mellanox.com>
Date: Thu, 6 Dec 2018 17:44:48 +0000

> Patches #1 and #2 fix two VxLAN related issues. The first patch removes
> warnings that can currently be triggered from user space. Second patch
> avoids leaking a FID in an error path.
> 
> Patch #3 fixes a too strict check that causes certain host routes not to
> be promoted to perform GRE decapsulation in hardware.
> 
> Last patch avoids a use-after-free when deleting a VLAN device via an
> ioctl when it is enslaved to a bridge. I have a patchset for net-next
> that reworks this code and makes the driver more robust.

Series applied.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net 0/4] mlxsw: Various fixes
@ 2020-01-12 16:06 Ido Schimmel
  0 siblings, 0 replies; 7+ messages in thread
From: Ido Schimmel @ 2020-01-12 16:06 UTC (permalink / raw)
  To: netdev; +Cc: davem, jiri, mlxsw, Ido Schimmel

From: Ido Schimmel <idosch@mellanox.com>

This patch set contains various fixes for mlxsw.

Patch #1 splits the init() callback between Spectrum-2 and Spectrum-3 in
order to avoid enforcing the same firmware version for both ASICs, as
this can't possibly work. Without this patch the driver cannot boot with
the Spectrum-3 ASIC.

Patches #2-#3 from Shalom fix a long standing race condition that was
recently exposed while testing the driver on an emulator, which is very
slow compared to the actual hardware. The problem is explained in detail
in the commit message.

Patch #4 from Petr fixes a selftest.

Ido Schimmel (1):
  mlxsw: spectrum: Do not enforce same firmware version for multiple
    ASICs

Petr Machata (1):
  selftests: mlxsw: qos_mc_aware: Fix mausezahn invocation

Shalom Toledo (2):
  mlxsw: switchx2: Do not modify cloned SKBs during xmit
  mlxsw: spectrum: Do not modify cloned SKBs during xmit

 .../net/ethernet/mellanox/mlxsw/spectrum.c    | 27 ++++++++++++++++++-
 .../net/ethernet/mellanox/mlxsw/switchx2.c    |  4 +++
 .../drivers/net/mlxsw/qos_mc_aware.sh         |  8 ++++--
 3 files changed, 36 insertions(+), 3 deletions(-)

-- 
2.24.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-01-12 16:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-06 17:44 [PATCH net 0/4] mlxsw: Various fixes Ido Schimmel
2018-12-06 17:44 ` [PATCH net 1/4] mlxsw: spectrum_nve: Remove easily triggerable warnings Ido Schimmel
2018-12-06 17:44 ` [PATCH net 2/4] mlxsw: spectrum_switchdev: Avoid leaking FID's reference count Ido Schimmel
2018-12-06 17:44 ` [PATCH net 3/4] mlxsw: spectrum_router: Relax GRE decap matching check Ido Schimmel
2018-12-06 17:44 ` [PATCH net 4/4] mlxsw: spectrum_switchdev: Fix VLAN device deletion via ioctl Ido Schimmel
2018-12-06 21:31 ` [PATCH net 0/4] mlxsw: Various fixes David Miller
2020-01-12 16:06 Ido Schimmel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.