Thread View: linux.kernel.netdev
4 messages
4 total messages
Started by Oleksij Rempel
Sun, 15 Nov 2026 10:59
[PATCH net-next v2 3/3] net: dsa: forget the port ageing time when the port leaves the bridge
Author: Oleksij Rempel
Date: Sun, 15 Nov 2026 10:59
Date: Sun, 15 Nov 2026 10:59
51 lines
12321 bytes
12321 bytes
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@pengutronix.de>
---
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
Re: [PATCH net-next v2 3/3] net: dsa: forget the port ageing time when the port leaves the bridge
Author: Andrew Lunn
Date: Sun, 15 Nov 2026 15:40
Date: Sun, 15 Nov 2026 15:40
26 lines
9981 bytes
9981 bytes
On Sun, Nov 15, 2026 at 11:59:53AM +0100, Oleksij Rempel wrote:
> 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@pengutronix.de>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
Re: [PATCH net-next v2 3/3] net: dsa: forget the port ageing time when the port leaves the bridge
Author: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 11:00
Date: Mon, 16 Nov 2026 11:00
112 lines
12259 bytes
12259 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] In net/dsa/port.c, dsa_port_switchdev_unsync_attrs() now
clears the cached dp->ageing_time, but nothing on the bridge-leave…
--
net: dsa: forget the port ageing time when the port leaves the bridge
This patch clears the cached dp->ageing_time in
dsa_port_switchdev_unsync_attrs() when a port leaves a bridge. After that,
dsa_switch_fastest_ageing_time() no longer counts the departed port's
value. The switch can then return to the bridge's long ageing time when
another port of the same bridge gets a restore.
> diff --git a/net/dsa/port.c b/net/dsa/port.c
> index 15e7da20b0e2f..54c9709840952 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;
[Severity: Medium]
This clears the cache, but the leave path never writes the switch's ageing
register again. Can the chip still stay at the departed port's short
ageing time?
The hardware is only programmed in dsa_switch_ageing_time(), which runs
on DSA_NOTIFIER_AGEING_TIME:
net/dsa/switch.c:dsa_switch_ageing_time() {
...
ageing_time = dsa_switch_fastest_ageing_time(ds, info);
if (ds->ops->set_ageing_time)
return ds->ops->set_ageing_time(ds, ageing_time);
...
}
That notifier is only sent by dsa_port_ageing_time(). It is reached from
dsa_port_switchdev_sync_attrs() when a port joins, and from
dsa_user_port_attr_set(), which is gated on the port still offloading the
bridge:
net/dsa/user.c:dsa_user_port_attr_set() {
...
case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME:
if (!dsa_port_offloads_bridge_dev(dp, attr->orig_dev))
return -EOPNOTSUPP;
ret = dsa_port_ageing_time(dp, attr->u.ageing_time);
...
}
Take one switch with br0 holding lan1 and lan2 at 300 s, and br1 holding
only lan3 at 10 s (or 2 x forward_delay during an STP topology change on
br1). The chip runs at 10 s.
When lan3 leaves br1, the call chain is:
dsa_port_bridge_leave()
dsa_port_switchdev_unsync_attrs()
dp->ageing_time = 0;
br1 has no ports left in this tree to send a restore, and br0 has no
reason to send one. The chip stays at 10 s. br0's FDB entries then age
out early, which causes extra unknown-unicast flooding. This lasts until
br0's ageing time changes, a port joins a bridge, or br0 has its own
topology change.
At that point dsa_switch_fastest_ageing_time() would return the minimum
of the remaining cached values (300 s), but the hardware is never set to
it.
The comment kept just above the new code says there is "no good reason
(or value)" to change the ageing time here. In this case there is a
usable value: the minimum over the remaining bridged ports.
Could the leave path recompute the fastest ageing time over the switch's
remaining bridged ports after clearing the cache, and program it? The
register could be left alone when no bridged ports remain.
The commit message notes that "The switch gets the restored value only
if another port of the same bridge is still in this DSA tree", and the
v2 changelog moves the last-port case to the cover letter. The
multi-bridge case above would still leave the switch at the short value
this patch is meant to fix.
> }
>
> static int dsa_port_bridge_create(struct dsa_port *dp,
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261115-ksz-stp-ageing-v2-0-7af27320033e%40pengutronix.de
Re: [PATCH net-next v2 3/3] net: dsa: forget the port ageing time when the port leaves the bridge
Author: Oleksij Rempel
Date: Tue, 17 Nov 2026 12:02
Date: Tue, 17 Nov 2026 12:02
11 lines
10697 bytes
10697 bytes
On Mon, Nov 16, 2026 at 11:00:36AM +0000, netdev-bot+sashiko@kernel.org wrote: > Could the leave path recompute the fastest ageing time over the > switch's remaining bridged ports after clearing the cache, and program > it? Yes, I reproduced this on a KSZ9893 with two bridges. v3 adds a patch that programs the fastest ageing time of the remaining bridged ports when a port leaves its bridge. pw-bot: cr
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads