netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] mlxsw: Set port STP state on bridge enslavement
@ 2023-08-08 13:18 Petr Machata
  2023-08-08 13:18 ` [PATCH net-next 1/2] " Petr Machata
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Petr Machata @ 2023-08-08 13:18 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev
  Cc: Ido Schimmel, Petr Machata, Danielle Ratson, mlxsw

When the first port joins a LAG that already has a bridge upper, an
instance of struct mlxsw_sp_bridge_port is created for the LAG to keep
track of it as a bridge port. The bridge_port's STP state is initialized to
BR_STATE_DISABLED. This made sense previously, because mlxsw would only
ever allow a port to join a LAG if the LAG had no uppers. Thus if a
bridge_port was instantiated, it must have been because the LAG as such is
joining a bridge, and the STP state is correspondingly disabled.

However as of commit 2c5ffe8d7226 ("mlxsw: spectrum: Permit enslavement to
netdevices with uppers"), mlxsw allows a port to join a LAG that is already
a member of a bridge. The STP state may be different than disabled in that
case. Initialize it properly by querying the actual state.

This bug may cause an issue as traffic on ports attached to a bridged LAG
gets dropped on ingress with discard_ingress_general counter bumped.

The above fix in patch #1. Patch #2 contains a selftest that would
sporadically reproduce the issue.

Petr Machata (2):
  mlxsw: Set port STP state on bridge enslavement
  selftests: mlxsw: router_bridge_lag: Add a new selftest

 .../mellanox/mlxsw/spectrum_switchdev.c       |  2 +-
 .../drivers/net/mlxsw/router_bridge_lag.sh    | 50 +++++++++++++++++++
 2 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100755 tools/testing/selftests/drivers/net/mlxsw/router_bridge_lag.sh

-- 
2.41.0


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

* [PATCH net-next 1/2] mlxsw: Set port STP state on bridge enslavement
  2023-08-08 13:18 [PATCH net-next 0/2] mlxsw: Set port STP state on bridge enslavement Petr Machata
@ 2023-08-08 13:18 ` Petr Machata
  2023-08-08 13:18 ` [PATCH net-next 2/2] selftests: mlxsw: router_bridge_lag: Add a new selftest Petr Machata
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Petr Machata @ 2023-08-08 13:18 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev
  Cc: Ido Schimmel, Petr Machata, Danielle Ratson, mlxsw

When the first port joins a LAG that already has a bridge upper, an
instance of struct mlxsw_sp_bridge_port is created for the LAG to keep
track of it as a bridge port. The bridge_port's STP state is initialized to
BR_STATE_DISABLED. This made sense previously, because mlxsw would only
ever allow a port to join a LAG if the LAG had no uppers. Thus if a
bridge_port was instantiated, it must have been because the LAG as such is
joining a bridge, and the STP state is correspondingly disabled.

However as of commit 2c5ffe8d7226 ("mlxsw: spectrum: Permit enslavement to
netdevices with uppers"), mlxsw allows a port to join a LAG that is already
a member of a bridge. The STP state may be different than disabled in that
case. Initialize it properly by querying the actual state.

This bug may cause an issue as traffic on ports attached to a bridged LAG
gets dropped on ingress with discard_ingress_general counter bumped.

Fixes: c6514f3627a0 ("Merge branch 'mlxsw-enslavement'")
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index 5376d4af5f91..ad90f7f5eeb7 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -490,7 +490,7 @@ mlxsw_sp_bridge_port_create(struct mlxsw_sp_bridge_device *bridge_device,
 		bridge_port->system_port = mlxsw_sp_port->local_port;
 	bridge_port->dev = brport_dev;
 	bridge_port->bridge_device = bridge_device;
-	bridge_port->stp_state = BR_STATE_DISABLED;
+	bridge_port->stp_state = br_port_get_stp_state(brport_dev);
 	bridge_port->flags = BR_LEARNING | BR_FLOOD | BR_LEARNING_SYNC |
 			     BR_MCAST_FLOOD;
 	INIT_LIST_HEAD(&bridge_port->vlans_list);
-- 
2.41.0


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

* [PATCH net-next 2/2] selftests: mlxsw: router_bridge_lag: Add a new selftest
  2023-08-08 13:18 [PATCH net-next 0/2] mlxsw: Set port STP state on bridge enslavement Petr Machata
  2023-08-08 13:18 ` [PATCH net-next 1/2] " Petr Machata
@ 2023-08-08 13:18 ` Petr Machata
  2023-08-09 14:50 ` [PATCH net-next 0/2] mlxsw: Set port STP state on bridge enslavement Simon Horman
  2023-08-09 22:40 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Petr Machata @ 2023-08-08 13:18 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev
  Cc: Ido Schimmel, Petr Machata, Danielle Ratson, mlxsw

Add a selftest to verify enslavement to a LAG with upper after fresh
devlink reload.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Danielle Ratson <danieller@nvidia.com>
---
 .../drivers/net/mlxsw/router_bridge_lag.sh    | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100755 tools/testing/selftests/drivers/net/mlxsw/router_bridge_lag.sh

diff --git a/tools/testing/selftests/drivers/net/mlxsw/router_bridge_lag.sh b/tools/testing/selftests/drivers/net/mlxsw/router_bridge_lag.sh
new file mode 100755
index 000000000000..6ce317cfaf9b
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/mlxsw/router_bridge_lag.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+# Test enslavement to LAG with a clean slate.
+# See $lib_dir/router_bridge_lag.sh for further details.
+
+ALL_TESTS="
+	config_devlink_reload
+	config_enslave_h1
+	config_enslave_h2
+	config_enslave_h3
+	config_enslave_h4
+	config_enslave_swp1
+	config_enslave_swp2
+	config_enslave_swp3
+	config_enslave_swp4
+	config_wait
+	ping_ipv4
+	ping_ipv6
+"
+
+config_devlink_reload()
+{
+	log_info "Devlink reload"
+	devlink_reload
+}
+
+config_enslave_h1()
+{
+	config_enslave $h1 lag1
+}
+
+config_enslave_h2()
+{
+	config_enslave $h2 lag4
+}
+
+config_enslave_h3()
+{
+	config_enslave $h3 lag4
+}
+
+config_enslave_h4()
+{
+	config_enslave $h4 lag1
+}
+
+lib_dir=$(dirname $0)/../../../net/forwarding
+EXTRA_SOURCE="source $lib_dir/devlink_lib.sh"
+source $lib_dir/router_bridge_lag.sh
-- 
2.41.0


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

* Re: [PATCH net-next 0/2] mlxsw: Set port STP state on bridge enslavement
  2023-08-08 13:18 [PATCH net-next 0/2] mlxsw: Set port STP state on bridge enslavement Petr Machata
  2023-08-08 13:18 ` [PATCH net-next 1/2] " Petr Machata
  2023-08-08 13:18 ` [PATCH net-next 2/2] selftests: mlxsw: router_bridge_lag: Add a new selftest Petr Machata
@ 2023-08-09 14:50 ` Simon Horman
  2023-08-09 22:40 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2023-08-09 14:50 UTC (permalink / raw)
  To: Petr Machata
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev, Ido Schimmel, Danielle Ratson, mlxsw

On Tue, Aug 08, 2023 at 03:18:14PM +0200, Petr Machata wrote:
> When the first port joins a LAG that already has a bridge upper, an
> instance of struct mlxsw_sp_bridge_port is created for the LAG to keep
> track of it as a bridge port. The bridge_port's STP state is initialized to
> BR_STATE_DISABLED. This made sense previously, because mlxsw would only
> ever allow a port to join a LAG if the LAG had no uppers. Thus if a
> bridge_port was instantiated, it must have been because the LAG as such is
> joining a bridge, and the STP state is correspondingly disabled.
> 
> However as of commit 2c5ffe8d7226 ("mlxsw: spectrum: Permit enslavement to
> netdevices with uppers"), mlxsw allows a port to join a LAG that is already
> a member of a bridge. The STP state may be different than disabled in that
> case. Initialize it properly by querying the actual state.
> 
> This bug may cause an issue as traffic on ports attached to a bridged LAG
> gets dropped on ingress with discard_ingress_general counter bumped.
> 
> The above fix in patch #1. Patch #2 contains a selftest that would
> sporadically reproduce the issue.
> 
> Petr Machata (2):
>   mlxsw: Set port STP state on bridge enslavement
>   selftests: mlxsw: router_bridge_lag: Add a new selftest

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH net-next 0/2] mlxsw: Set port STP state on bridge enslavement
  2023-08-08 13:18 [PATCH net-next 0/2] mlxsw: Set port STP state on bridge enslavement Petr Machata
                   ` (2 preceding siblings ...)
  2023-08-09 14:50 ` [PATCH net-next 0/2] mlxsw: Set port STP state on bridge enslavement Simon Horman
@ 2023-08-09 22:40 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-08-09 22:40 UTC (permalink / raw)
  To: Petr Machata
  Cc: davem, edumazet, kuba, pabeni, netdev, idosch, danieller, mlxsw

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 8 Aug 2023 15:18:14 +0200 you wrote:
> When the first port joins a LAG that already has a bridge upper, an
> instance of struct mlxsw_sp_bridge_port is created for the LAG to keep
> track of it as a bridge port. The bridge_port's STP state is initialized to
> BR_STATE_DISABLED. This made sense previously, because mlxsw would only
> ever allow a port to join a LAG if the LAG had no uppers. Thus if a
> bridge_port was instantiated, it must have been because the LAG as such is
> joining a bridge, and the STP state is correspondingly disabled.
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] mlxsw: Set port STP state on bridge enslavement
    https://git.kernel.org/netdev/net-next/c/a76ca8afd45a
  - [net-next,2/2] selftests: mlxsw: router_bridge_lag: Add a new selftest
    https://git.kernel.org/netdev/net-next/c/aae5bb8d18d8

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-08-09 22:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-08 13:18 [PATCH net-next 0/2] mlxsw: Set port STP state on bridge enslavement Petr Machata
2023-08-08 13:18 ` [PATCH net-next 1/2] " Petr Machata
2023-08-08 13:18 ` [PATCH net-next 2/2] selftests: mlxsw: router_bridge_lag: Add a new selftest Petr Machata
2023-08-09 14:50 ` [PATCH net-next 0/2] mlxsw: Set port STP state on bridge enslavement Simon Horman
2023-08-09 22:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).