From: Paolo Abeni <pabeni@redhat.com>
To: daniel@makrotopia.org
Cc: hauke@hauke-m.de, andrew@lunn.ch, olteanv@gmail.com,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, f.fainelli@gmail.com, netdev@vger.kernel.org,
petzah@znik.co.uk, stable@vger.kernel.org
Subject: Re: [PATCH net] net: dsa: lantiq_gswip: enable assisted learning on CPU port
Date: Fri, 4 Dec 2026 14:53:26 +0100 [thread overview]
Message-ID: <20261204135326.80725-1-pabeni@redhat.com> (raw)
In-Reply-To: <10fd8e9784811ecfde8b31f59b8f1c6a94184342.1795890781.git.daniel@makrotopia.org>
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.
prev parent reply other threads:[~2026-12-04 13:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261204135326.80725-1-pabeni@redhat.com \
--to=pabeni@redhat.com \
--cc=andrew@lunn.ch \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=f.fainelli@gmail.com \
--cc=hauke@hauke-m.de \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=petzah@znik.co.uk \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox