When switchdev_bridge_port_offload() or dsa_port_switchdev_sync_attrs() fails after the BRIDGE_JOIN broadcast, dsa_port_bridge_join() sends BRIDGE_LEAVE while dp->bridge is still set, and clears it afterwards. dsa_port_bridge_leave() does it the other way round, and drivers that recompute membership from dp->bridge in their leave callback rely on that: mv88e6xxx_port_bridge_leave() rebuilds the port VLAN maps through mv88e6xxx_port_vlan(), which still counts the failed port as a member of the bridge, so the port and the other members of the bridge keep forwarding to each other in the switch although the port is now standalone. The rollback also sends the copy of the bridge taken before the join, without the tx_fwd_offload the joining switch set, so mv88e6xxx skips the remap of the bridge's virtual device in the PVT. And unlike a leave, the rollback does not undo what dsa_port_switchdev_sync_attrs() set before it failed, so the now standalone port keeps the bridge port flags (learning), STP state and VLAN filtering of the bridge. Undo the join as a leave does: take the bridge as it is now, clear dp->bridge, send BRIDGE_LEAVE, then reset the port attributes with dsa_port_switchdev_unsync_attrs(). When switchdev_bridge_port_offload() failed and nothing was synced, the reset leaves the port as dsa_port_bridge_leave() leaves any port: standalone flooding without learning, the forwarding state, and VLAN filtering changed only if the bridge's setting differs from what the switch needs standalone. Fixes: 5961d6a12c13 ("net: dsa: inherit the actual bridge port flags at join time") Signed-off-by: Julius Bairaktaris --- v2: new, found while reviewing 5/7; also resets the port attributes that dsa_port_switchdev_sync_attrs() set before it failed. net/dsa/port.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/dsa/port.c b/net/dsa/port.c index 7ebdc9ce6b92..f07064384f34 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -548,7 +548,14 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br, &dsa_user_switchdev_blocking_notifier); dsa_flush_workqueue(); out_rollback_unbridge: + /* Undo the join as dsa_port_bridge_leave() does: drivers see the port + * out of the bridge, and the bridge as it is now + */ + info.bridge = *dp->bridge; + dsa_port_bridge_destroy(dp, br); dsa_broadcast(DSA_NOTIFIER_BRIDGE_LEAVE, &info); + dsa_port_switchdev_unsync_attrs(dp, info.bridge); + return err; out_rollback: dsa_port_bridge_destroy(dp, br); return err; -- 2.53.0