[PATCH net-next v2 2/3] net: dsa: ignore the old ageing time of the port being changed

From: Oleksij Rempel

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


Pass the port to the ageing time notifier. When
dsa_switch_fastest_ageing_time() takes the minimum, skip the cached
dp->ageing_time of that port and use the requested value instead. DSA
updates the cache only after the notifier.

Without this, the minimum includes the port's old ageing time. During
an STP topology change, the bridge lowers the ageing time to
2 x forward_delay (8 s with forward_delay 4 s). When it restores the
configured value, DSA programs the cached 8 s again, and the switch
keeps ageing at 8 s.

An automated review of the lan9645x bridge series pointed this out [1].
I reproduced it on a KSZ9893 and tested the fix there.

Fixes: 77b61365ecef ("net: dsa: remove the transactional logic from ageing time notifiers")
Link: https://lore.kernel.org/netdev/179180428624.434549.14425623884223795761@xxxxxxxxxx/ [1]
Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
---
Changes in v2:
- Pass the port to the notifier and skip its old value, instead of
updating the cache first (Andrew)
- Rephrase the subject and the commit message, and move the sja1105
note to the cover letter
- Add a Fixes tag
---
net/dsa/port.c | 7 ++++---
net/dsa/switch.c | 17 +++++++++++++----
net/dsa/switch.h | 1 +
3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/net/dsa/port.c b/net/dsa/port.c
index 1f5536c0dffc2311db24015697e0c8f5c014ac74..15e7da20b0e2f470a0ce5b763fa73b9b66b4c6f2 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -876,11 +876,12 @@ int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock)
{
unsigned long ageing_jiffies = clock_t_to_jiffies(ageing_clock);
unsigned int ageing_time = jiffies_to_msecs(ageing_jiffies);
- struct dsa_notifier_ageing_time_info info;
+ struct dsa_notifier_ageing_time_info info = {
+ .dp = dp,
+ .ageing_time = ageing_time,
+ };
int err;

- info.ageing_time = ageing_time;
-
err = dsa_port_notify(dp, DSA_NOTIFIER_AGEING_TIME, &info);
if (err)
return err;
diff --git a/net/dsa/switch.c b/net/dsa/switch.c
index a670a04edb7237a2606bc1959f6f2bb324c832ab..e9bef66fea3173c54fcde88da319cb8fd91195fc 100644
--- a/net/dsa/switch.c
+++ b/net/dsa/switch.c
@@ -20,14 +20,23 @@
#include "trace.h"
#include "user.h"

-static unsigned int dsa_switch_fastest_ageing_time(struct dsa_switch *ds,
- unsigned int ageing_time)
+static unsigned int
+dsa_switch_fastest_ageing_time(struct dsa_switch *ds,
+ const struct dsa_notifier_ageing_time_info *info)
{
+ unsigned int ageing_time = info->ageing_time;
struct dsa_port *dp;

- dsa_switch_for_each_port(dp, ds)
+ dsa_switch_for_each_port(dp, ds) {
+ /* info->dp is the port being changed. Its cached value is
+ * stale until the notifier returns. Skip it.
+ */
+ if (dp == info->dp)
+ continue;
+
if (dp->ageing_time && dp->ageing_time < ageing_time)
ageing_time = dp->ageing_time;
+ }

return ageing_time;
}
@@ -44,7 +53,7 @@ static int dsa_switch_ageing_time(struct dsa_switch *ds,
return -ERANGE;

/* Program the fastest ageing time in case of multiple bridges */
- ageing_time = dsa_switch_fastest_ageing_time(ds, 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);
diff --git a/net/dsa/switch.h b/net/dsa/switch.h
index be0a2749cd9791e19b8f03c6f6ceafb2d0432b14..5362ee9bfb68cfb52759c108d0626c55e19bb3a3 100644
--- a/net/dsa/switch.h
+++ b/net/dsa/switch.h
@@ -39,6 +39,7 @@ enum {

/* DSA_NOTIFIER_AGEING_TIME */
struct dsa_notifier_ageing_time_info {
+ const struct dsa_port *dp;
unsigned int ageing_time;
};


--
2.47.3