Netdev List
 help / color / mirror / Atom feed
From: David Yang <mmyangfl@gmail.com>
To: netdev@vger.kernel.org
Cc: David Yang <mmyangfl@gmail.com>, Andrew Lunn <andrew@lunn.ch>,
	Vladimir Oltean <olteanv@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>
Subject: [PATCH net-next v5 6/7] net: dsa: destroy the bridge port before the leave on join rollback
Date: Sun,  6 Dec 2026 10:20:37 +0800	[thread overview]
Message-ID: <20261206022040.4020726-7-mmyangfl@gmail.com> (raw)
In-Reply-To: <20261206022040.4020726-1-mmyangfl@gmail.com>

The join rollback broadcasts DSA_NOTIFIER_BRIDGE_LEAVE before the bridge
port is destroyed, so drivers' port_bridge_leave() see the port still
bridged, while anywhere else (join / leave) promise the effective
configuration is applied before that method is called.

Mirror the normal leave path and destroy first.

Signed-off-by: David Yang <mmyangfl@gmail.com>
---
 net/dsa/port.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/net/dsa/port.c b/net/dsa/port.c
index 54c970984095..66dba29fade8 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -509,8 +509,10 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br,
 
 	info.bridge = *dp->bridge;
 	err = dsa_broadcast(DSA_NOTIFIER_BRIDGE_JOIN, &info);
-	if (err)
-		goto out_rollback;
+	if (err) {
+		dsa_port_bridge_destroy(dp, br);
+		return err;
+	}
 
 	/* Drivers which support bridge TX forwarding should set this */
 	dp->bridge->tx_fwd_offload = info.tx_fwd_offload;
@@ -534,9 +536,11 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br,
 					&dsa_user_switchdev_blocking_notifier);
 	dsa_flush_workqueue();
 out_rollback_unbridge:
-	dsa_broadcast(DSA_NOTIFIER_BRIDGE_LEAVE, &info);
-out_rollback:
+	/* Align with dsa_port_bridge_leave(), so that drivers' implementations
+	 * always see the port unbridged.
+	 */
 	dsa_port_bridge_destroy(dp, br);
+	dsa_broadcast(DSA_NOTIFIER_BRIDGE_LEAVE, &info);
 	return err;
 }
 
-- 
2.53.0


  parent reply	other threads:[~2026-12-06  2:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-06  2:20 [PATCH net-next v5 0/7] net: dsa: motorcomm: Reject isolated redirect targets David Yang
2026-12-06  2:20 ` [PATCH net-next v5 1/7] net: dsa: motorcomm: Remove local cpu_ports_mask David Yang
2026-12-06  2:20 ` [PATCH net-next v5 2/7] net: dsa: motorcomm: Do not block hairpins on standalone ports David Yang
2026-12-06  2:20 ` [PATCH net-next v5 3/7] net: dsa: motorcomm: Derive port isolation masks on the fly David Yang
2026-12-06  2:20 ` [PATCH net-next v5 4/7] net: dsa: motorcomm: Reject isolated redirect targets David Yang
2026-12-06  2:20 ` [PATCH net-next v5 5/7] net: dsa: motorcomm: Reject bridge changes that break redirect rules David Yang
2026-12-06  2:20 ` David Yang [this message]
2026-12-06  2:20 ` [PATCH net-next v5 7/7] net: dsa: motorcomm: Recompute redirect rules on bridge changes David Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261206022040.4020726-7-mmyangfl@gmail.com \
    --to=mmyangfl@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox