[PATCH net-next v2 3/3] net: dsa: forget the port ageing time when the port leaves the bridge

From: Oleksij Rempel

Date: Sun Nov 15 2026 - 06:00:29 EST


Clear the cached dp->ageing_time when the port leaves the bridge.
Otherwise dsa_switch_fastest_ageing_time() still uses the ageing time
of the port that left. If the port leaves with a shorter ageing time,
for example during an STP topology change, the switch stays at the
short value until that port joins a bridge again. With this change the
switch goes back to the long value when the bridge restores it at the
end of the topology change. The switch gets the restored value only if
another port of the same bridge is still in this DSA tree.

Found by code inspection. Tested on a KSZ9893 with lan1 and lan2 in a
bridge, ageing time 300 s:
- kernel STP, forward delay 4 s, lan2 removed during a topology change:
without this patch the switch stayed at 8 s (2 x 4 s). With it, the
switch went back to 300 s at the end of the topology change.
- no STP: I set the ageing time to 10 s, removed lan2, then set 300 s.
The switch stayed at 10 s without this patch and went to 300 s with
it.

Fixes: 34a79f63bbe4 ("net: dsa: support switchdev ageing time attr")
Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
---
Changes in v2:
- Say how long the short ageing time stays, with an STP test (Andrew)
- Rephrase the commit message and the comment
- Move the case of the last bridge port leaving to the cover letter
- Add a Fixes tag
---
net/dsa/port.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/net/dsa/port.c b/net/dsa/port.c
index 15e7da20b0e2f470a0ce5b763fa73b9b66b4c6f2..54c9709840952210ecd1abdfde31f751d07ef2b6 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -415,6 +415,12 @@ static void dsa_port_switchdev_unsync_attrs(struct dsa_port *dp,
/* Ageing time may be global to the switch chip, so don't change it
* here because we have no good reason (or value) to change it to.
*/
+
+ /* Forget the ageing time cached for this port.
+ * dsa_switch_fastest_ageing_time() skips 0, so this port no longer
+ * counts towards the minimum.
+ */
+ dp->ageing_time = 0;
}

static int dsa_port_bridge_create(struct dsa_port *dp,

--
2.47.3