* [PATCH net] net: dsa: lantiq_gswip: enable assisted learning on CPU port
@ 2026-11-28 19:04 Daniel Golle
2026-12-04 13:53 ` Paolo Abeni
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Golle @ 2026-11-28 19:04 UTC (permalink / raw)
To: Hauke Mehrtens, Andrew Lunn, Vladimir Oltean, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Florian Fainelli,
netdev
Cc: petzah, stable, petzah
From: Peter Zahradnik <petzah@znik.co.uk>
The switch learns no source addresses from frames sent by the CPU, so a
station behind a foreign bridge port such as a Wi-Fi interface stays
unknown to it. When that station was last seen behind a user port, for
example the uplink to another access point, the learned entry keeps
pointing there, and frames for the station arriving on that same port
are dropped until the entry ages out. A client roaming onto a local
Wi-Fi interface loses its DHCP replies this way.
Set ds->assisted_learning_on_cpu_port so that DSA installs the addresses
the bridge learns on foreign ports as static entries on the CPU port,
which replace a learned entry for the same address and FID. This relies
on commit e29bbd73ad71 ("net: dsa: lantiq_gswip: support bridge FDB
entries on the CPU port").
Fixes: 8206e0ce96b3 ("net: dsa: lantiq: Add VLAN unaware bridge offloading")
Cc: <stable@vger.kernel.org> # 6.12.x: e29bbd73ad71: net: dsa: lantiq_gswip: support bridge FDB entries on the CPU port
Link: https://github.com/openwrt/openwrt/issues/11650
Link: https://github.com/openwrt/openwrt/pull/26988
Signed-off-by: Peter Zahradnik <petzah@znik.co.uk>
[Daniel: rewrote the commit message, dropped the code comment]
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
Tested by Peter on a BT Home Hub 5A (xRX200, GSWIP 2.1) used as a wired
access point with a VLAN-aware bridge, on OpenWrt kernels 6.18.64 and
6.12.112 with commit e29bbd73ad71 backported. Without the change a
client roaming onto the access point gets no downlink traffic and roams
away again; with it the stale uplink entry is replaced at association,
and in 4 hours per kernel 25 roams left every DHCP request answered. On
net the change is not built or tested.
Use of generated content, as Documentation/process/generated-content.rst
asks: Peter wrote the change with an LLM coding assistant, as disclosed
in the OpenWrt pull request. The analysis of the bridge and DSA FDB
paths behind it and this commit message were written with an LLM coding
assistant (Claude Code), asked whether the OpenWrt issue is still
present upstream and how to fix it without regressing other cases.
---
drivers/net/dsa/lantiq/lantiq_gswip_common.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/dsa/lantiq/lantiq_gswip_common.c b/drivers/net/dsa/lantiq/lantiq_gswip_common.c
index 861d9df4ff80b..d605b2e1c3153 100644
--- a/drivers/net/dsa/lantiq/lantiq_gswip_common.c
+++ b/drivers/net/dsa/lantiq/lantiq_gswip_common.c
@@ -745,6 +745,7 @@ static int gswip_setup(struct dsa_switch *ds)
}
ds->mtu_enforcement_ingress = true;
+ ds->assisted_learning_on_cpu_port = true;
return 0;
}
base-commit: 28a371228d4eb4857cc31eeb1a0d7d01e9c3ea2f
--
2.56.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net: dsa: lantiq_gswip: enable assisted learning on CPU port
2026-11-28 19:04 [PATCH net] net: dsa: lantiq_gswip: enable assisted learning on CPU port Daniel Golle
@ 2026-12-04 13:53 ` Paolo Abeni
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Abeni @ 2026-12-04 13:53 UTC (permalink / raw)
To: daniel
Cc: hauke, andrew, olteanv, davem, edumazet, kuba, pabeni, f.fainelli,
netdev, petzah, stable
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
Full review at: https://netdev-ai.bots.linux.dev/sashiko/
---
--- Patch [1]: [PATCH net] net: dsa: lantiq_gswip: enable assisted learning on CPU port ---
commit b1076c543459c8d9d8dab1fbe56ed6d899ebf737
Author: Peter Zahradnik <petzah@znik.co.uk>
net: dsa: lantiq_gswip: enable assisted learning on CPU port
This commit sets ds->assisted_learning_on_cpu_port in gswip_setup(). With
it, DSA installs the addresses the software bridge learns on foreign ports,
such as Wi-Fi interfaces, as static FDB entries on the CPU port. These
entries are meant to replace stale learned entries that point at a user
port and drop downlink traffic for roaming clients.
Link: https://github.com/openwrt/openwrt/issues/11650
Link: https://github.com/openwrt/openwrt/pull/26988
> diff --git a/drivers/net/dsa/lantiq/lantiq_gswip_common.c b/drivers/net/dsa/lantiq/lantiq_gswip_common.c
> index 861d9df4ff80b..d605b2e1c3153 100644
> --- a/drivers/net/dsa/lantiq/lantiq_gswip_common.c
> +++ b/drivers/net/dsa/lantiq/lantiq_gswip_common.c
> @@ -745,6 +745,7 @@ static int gswip_setup(struct dsa_switch *ds)
> }
>
> ds->mtu_enforcement_ingress = true;
> + ds->assisted_learning_on_cpu_port = true;
[Severity: Medium]
[Finding: main-1-0]
[Sources: opus-5-5]
With this flag set, each (MAC, VID) pair that the bridge learns on a
foreign port becomes a separate refcounted host FDB entry on the CPU port.
dsa_mac_addr_find() matches on addr, vid and db. Does gswip_port_fdb() keep
those VIDs apart in hardware?
The vid argument appears unused, and the FID depends only on the bridge:
drivers/net/dsa/lantiq/lantiq_gswip_common.c:gswip_port_fdb() {
...
for (i = max_ports; i < ARRAY_SIZE(priv->vlans); i++) {
if (priv->vlans[i].bridge == bridge) {
fid = priv->vlans[i].fid;
break;
}
}
...
mac_bridge.key[3] = FIELD_PREP(GSWIP_TABLE_MAC_BRIDGE_KEY3_FID, fid);
...
mac_bridge.valid = add;
...
}
gswip_vlan_add() also gives every VLAN of a VLAN-aware bridge the same FID.
Suppose a station MAC M is learned on a foreign port in VIDs A and B of a
VLAN-aware bridge. Both adds write the same (M, FID) slot. Then, when
(M, A) ages out of the bridge:
dsa_port_do_fdb_del()
refcount_dec_and_test(&a->refcount) -> true
ds->ops->port_fdb_del()
gswip_port_fdb(add=false)
key-mode write of (M, FID) with valid = false
Wouldn't this remove the hardware entry that (M, B) still needs? DSA would
still have (M, B) in the CPU port's dp->fdbs list and would never
reinstall it.
The FID is shared, so a static CPU-port entry installed for VLAN B would
also send M's traffic to the CPU in every other VLAN of the bridge. Would
it also suppress hardware learning of M in those VLANs, even where M is
behind a user port?
Documentation/networking/dsa/dsa.rst says for DSA_DB_BRIDGE:
Separation between the VLAN-unaware database and the per-VID
databases of this bridge is expected to be done by the driver.
Before this patch, gswip_port_fdb() already ignored the VID for local
CPU-port addresses. This patch now sends every address learned on a
foreign port through that path, and the fix depends on it.
[Severity: Medium]
[Finding: main-2-3]
[Sources: opus-5-5]
gswip_port_fdb_add() and gswip_port_fdb_del() pick the hardware FID from
db.bridge.dev, but the driver never sets ds->fdb_isolation. Can enabling
assisted learning without fdb_isolation leave CPU-port entries missing or
stale when more than one bridge is offloaded?
Without fdb_isolation, the host FDB helpers treat all bridges as one
database for refcounting:
net/dsa/port.c:dsa_port_bridge_host_fdb_add() {
...
if (!dp->ds->fdb_isolation)
db.bridge.num = 0;
...
}
dsa_port_bridge_host_fdb_del() does the same. db.bridge.dev is not
changed. The driver therefore gets the dev of whichever bridge made the
first add and of whichever bridge made the last delete.
Take two VLAN-unaware bridges, br-lan and br-guest, each with a Wi-Fi
port. A client MAC M is learned on both at VID 0:
br-lan add -> gswip_port_fdb() writes (M, FID_lan)
br-guest add -> refcount bump only, (M, FID_guest) never written
br-lan del -> refcount drop only, (M, FID_lan) stays
br-guest del -> gswip_port_fdb() clears the never-written (M, FID_guest)
Would this leave (M, FID_lan) behind as a static CPU-port entry with no
DSA record, so nothing ever removes it? Would br-guest also never get the
entry this patch relies on?
Documentation/networking/dsa/dsa.rst says:
The drivers which act upon the dsa_db argument in port_fdb_add,
port_mdb_add etc should declare ds->fdb_isolation as true.
For comparison, mxl862xx, felix and rtl8365mb set both
assisted_learning_on_cpu_port and fdb_isolation. Commit e29bbd73ad71 first
broke this contract for local addresses. This patch extends it to every
address learned on a foreign port.
[Severity: Low]
[Finding: main-1-1]
[Sources: opus-5-5]
gswip_setup() is in lantiq_gswip_common.c. Both lantiq_gswip.c and
mxl-gsw1xx.c reach it through gswip_probe_common(). This line therefore
turns on assisted learning for every GSWIP revision and for the MaxLinear
GSW1xx family. Should the commit message say so, instead of only "the
switch"?
The testing note covers one GSWIP 2.1 (xRX200) device and says the change
was not built or tested on net. On GSWIP 2.2_ETC and newer,
gswip_port_fdb() encodes VAL1 differently:
if (GSWIP_VERSION_GE(priv, GSWIP_VERSION_2_2_ETC))
mac_bridge.val[1] = add ? (GSWIP_TABLE_MAC_BRIDGE_VAL1_STATIC |
GSWIP_TABLE_MAC_BRIDGE_VAL1_VALID) : 0;
else
mac_bridge.val[1] = GSWIP_TABLE_MAC_BRIDGE_VAL1_STATIC;
The commit message says the static entries "replace a learned entry for
the same address and FID", but that has only been tested with the 2.1
encoding. Has it been checked on 2.2+ or GSW1xx hardware?
[Severity: Low]
[Finding: main-6-9]
[Sources: opus-5-5]
With this flag set, dynamically learned foreign-port entries now pass this
check in dsa_user_fdb_event():
if (!ds->assisted_learning_on_cpu_port)
return 0;
As a result, every source MAC the bridge learns on a foreign port becomes
a non-aging STATIC entry in the MAC bridging table. There is no capacity
accounting. Going by the loop in gswip_port_fast_age(), the table has 2048
entries.
Could an untrusted party on an open or guest Wi-Fi network, or on another
bridged non-DSA port, fill this hardware table by using many source MACs?
The bridge's fdb_max_learned limit defaults to 0, which means unlimited.
If learning on the wired ports then runs out of space, wired-to-wired
unicast would fall back to the unknown-unicast map (GSWIP_PCE_PMAP3 =
cpu_ports) and go through the CPU.
This effect is not confirmed, because the driver does not document what
the table does when a hash bucket is full. Other drivers that enable
assisted learning, such as mt7530, felix, sja1105 and rtl8365mb, make the
same trade-off.
>
> return 0;
> }
--
This is an AI-generated review.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-04 13:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 19:04 [PATCH net] net: dsa: lantiq_gswip: enable assisted learning on CPU port Daniel Golle
2026-12-04 13:53 ` Paolo Abeni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox