* [PATCH net v3 0/3] net: dsa: motorcomm: FDB fixup
@ 2026-11-19 22:10 David Yang
2026-11-19 22:10 ` [PATCH net v3 1/3] net: dsa: motorcomm: Ignore multicast addresses in FDB ops David Yang
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: David Yang @ 2026-11-19 22:10 UTC (permalink / raw)
To: netdev
Cc: David Yang, Andrew Lunn, Vladimir Oltean, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Various FDB defects. Assisted and verified on the hardware by LLM.
There are more gotchas about multi-bridge setup, but I'd leave that for
net-next since multi-bridge has always been tricky among DSA drivers.
v3:
- ignore multicast addresses in FDB ops
- exclude CPU port from leave mask
- withdraw the following patches
v2: https://lore.kernel.org/r/20261116160107.1351198-1-mmyangfl@gmail.com
- include the CPU port when rewriting FDB entry
- read the port PVID instead of bridge's
- fix PVID when port joining/leaving bridge
v1: https://lore.kernel.org/r/20261111234110.1449602-1-mmyangfl@gmail.com
David Yang (3):
net: dsa: motorcomm: Ignore multicast addresses in FDB ops
net: dsa: motorcomm: Do not inherit ports from dynamic FDB entries
net: dsa: motorcomm: Rewrite FDB entry on port migration
drivers/net/dsa/motorcomm/chip.c | 100 +++++++++++++++++--------------
1 file changed, 56 insertions(+), 44 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH net v3 1/3] net: dsa: motorcomm: Ignore multicast addresses in FDB ops 2026-11-19 22:10 [PATCH net v3 0/3] net: dsa: motorcomm: FDB fixup David Yang @ 2026-11-19 22:10 ` David Yang 2026-11-23 22:11 ` netdev-bot+sashiko 2026-11-19 22:10 ` [PATCH net v3 2/3] net: dsa: motorcomm: Do not inherit ports from dynamic FDB entries David Yang 2026-11-19 22:10 ` [PATCH net v3 3/3] net: dsa: motorcomm: Rewrite FDB entry on port migration David Yang 2 siblings, 1 reply; 7+ messages in thread From: David Yang @ 2026-11-19 22:10 UTC (permalink / raw) To: netdev Cc: David Yang, Andrew Lunn, Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni The software bridge never forwards according to an FDB entry with a multicast MAC. A multicast entry created by "bridge fdb add" is therefore inert in the software data path, but its switchdev notification still reaches .port_fdb_add(). Ignore multicast addresses in .port_fdb_add() and .port_fdb_del() so multicast entries are not touched from FDB side. Fixes: 186623f4aa72 ("net: dsa: yt921x: Add support for Motorcomm YT921x") Signed-off-by: David Yang <mmyangfl@gmail.com> --- drivers/net/dsa/motorcomm/chip.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c index b12bf32f8896..eddec2f26586 100644 --- a/drivers/net/dsa/motorcomm/chip.c +++ b/drivers/net/dsa/motorcomm/chip.c @@ -862,6 +862,9 @@ yt921x_dsa_port_fdb_del(struct dsa_switch *ds, int port, struct yt921x_priv *priv = dsa_to_yt921x_priv(ds); int res; + if (is_multicast_ether_addr(addr)) + return 0; + mutex_lock(&priv->reg_lock); res = yt921x_fdb_leave(priv, addr, vid, BIT(port)); mutex_unlock(&priv->reg_lock); @@ -876,6 +879,12 @@ yt921x_dsa_port_fdb_add(struct dsa_switch *ds, int port, struct yt921x_priv *priv = dsa_to_yt921x_priv(ds); int res; + /* The software bridge never forwards according to an FDB entry with a + * multicast MAC, do not touch it from the FDB path + */ + if (is_multicast_ether_addr(addr)) + return 0; + mutex_lock(&priv->reg_lock); res = yt921x_fdb_join(priv, addr, vid, BIT(port)); mutex_unlock(&priv->reg_lock); -- 2.53.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net v3 1/3] net: dsa: motorcomm: Ignore multicast addresses in FDB ops 2026-11-19 22:10 ` [PATCH net v3 1/3] net: dsa: motorcomm: Ignore multicast addresses in FDB ops David Yang @ 2026-11-23 22:11 ` netdev-bot+sashiko 0 siblings, 0 replies; 7+ messages in thread From: netdev-bot+sashiko @ 2026-11-23 22:11 UTC (permalink / raw) To: mmyangfl; +Cc: netdev, andrew, olteanv, davem, edumazet, kuba, pabeni Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin. Low priority / nit picks for your consideration: - [Low] The commit message does not say what actually breaks in hardware, even though the patch carries a Fixes: tag. - [Low] For multicast MACs, yt921x_dsa_port_fdb_add() now returns 0 without writing anything to the switch. -- net: dsa: motorcomm: Ignore multicast addresses in FDB ops This patch makes yt921x_dsa_port_fdb_add() and yt921x_dsa_port_fdb_del() return early for multicast MAC addresses. Multicast entries are then no longer touched from the FDB path, because the software bridge never forwards according to a multicast FDB entry. > The software bridge never forwards according to an FDB entry with a > multicast MAC. A multicast entry created by "bridge fdb add" is > therefore inert in the software data path, but its switchdev > notification still reaches .port_fdb_add(). > > Ignore multicast addresses in .port_fdb_add() and .port_fdb_del() so > multicast entries are not touched from FDB side. [Severity: Low] This isn't a bug, but could the commit message say what goes wrong in hardware without this change? The patch carries a Fixes: tag, and the description does not mention the user-visible impact. In this driver the FDB and MDB ops share one hardware table. They use the same (addr, vid) key and the same helpers: drivers/net/dsa/motorcomm/chip.c:yt921x_dsa_port_mdb_add() { ... res = yt921x_fdb_join(priv, addr, vid, BIT(port)); ... } yt921x_dsa_port_mdb_del() calls yt921x_fdb_leave(), which is also what the FDB ops called before this patch. Before this patch, "bridge fdb add <mcast> dev swpN master static" wrote a static hardware entry. The switch then forwarded that group by the FDB port mask, while the software bridge forwarded it by MDB or by flooding. Also, a later "bridge fdb del" of an address that MDB had also programmed ran yt921x_fdb_leave(). That cleared the port bit from the MDB-owned entry, or deleted the entry once no ports were left: drivers/net/dsa/motorcomm/chip.c:yt921x_fdb_leave() { ... if (!(ctrl2 & YT921X_FDB_IO2_EGR_PORTS_M)) { ctrl = YT921X_FDB_OP_OP_DEL | YT921X_FDB_OP_START; ... } After that, hardware multicast forwarding no longer matches the software MDB, which still believes the group is offloaded. Could these two effects be described in the commit message? > diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c > index c753c746490a1..9a9e8ed76e01f 100644 > --- a/drivers/net/dsa/motorcomm/chip.c > +++ b/drivers/net/dsa/motorcomm/chip.c [ ... ] > @@ -876,6 +879,12 @@ yt921x_dsa_port_fdb_add(struct dsa_switch *ds, int port, > struct yt921x_priv *priv = dsa_to_yt921x_priv(ds); > int res; > > + /* The software bridge never forwards according to an FDB entry with a > + * multicast MAC, do not touch it from the FDB path > + */ > + if (is_multicast_ether_addr(addr)) > + return 0; [Severity: Low] Will returning 0 here make the bridge report the multicast entry as offloaded, even though nothing was written to the switch? dsa_user_switchdev_event_work() in net/dsa/user.c treats any 0 return as a successful offload: dsa_user_switchdev_event_work() dsa_port_fdb_add() yt921x_dsa_port_fdb_add() <- returns 0 for multicast dsa_fdb_offload_notify() info.offloaded = true; call_switchdev_notifiers(SWITCHDEV_FDB_OFFLOADED, ...) The bridge handles this in br_fdb_offloaded_set(), which sets BR_FDB_OFFLOADED. br_fdb_fill_info() then reports NTF_OFFLOADED. As a result, "bridge fdb show" would list the multicast entry as "offload", but the hardware table has no such entry. The driver's fdb dump path also filters out multicast, so the hardware side shows nothing. Before this patch the entry was actually programmed. For comparison, rtl83xx_port_fdb_add() and rtl83xx_port_fdb_del() in drivers/net/dsa/realtek/rtl83xx.c return -EOPNOTSUPP for the same check. If 0 was chosen on purpose, for example to avoid the dev_err() that the deferred work prints on failure, could the commit message or the code comment say so? This also seems to remain after the later patch in this series, "net: dsa: motorcomm: Rewrite FDB entry on port migration". That patch keeps the multicast early return of 0 in both fdb_add and fdb_del. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119221110.1123578-1-mmyangfl%40gmail.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net v3 2/3] net: dsa: motorcomm: Do not inherit ports from dynamic FDB entries 2026-11-19 22:10 [PATCH net v3 0/3] net: dsa: motorcomm: FDB fixup David Yang 2026-11-19 22:10 ` [PATCH net v3 1/3] net: dsa: motorcomm: Ignore multicast addresses in FDB ops David Yang @ 2026-11-19 22:10 ` David Yang 2026-11-23 22:11 ` netdev-bot+sashiko 2026-11-19 22:10 ` [PATCH net v3 3/3] net: dsa: motorcomm: Rewrite FDB entry on port migration David Yang 2 siblings, 1 reply; 7+ messages in thread From: David Yang @ 2026-11-19 22:10 UTC (permalink / raw) To: netdev Cc: David Yang, Andrew Lunn, Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni When adding an fdb/mdb entry whose (address, VID) key already exists in hardware, the existing egress ports were silently merged into the new static entry. Ports learned by hardware are untracked by DSA and can never be deleted. Replace the port mask instead of merging when the existing entry is not static. Fixes: 186623f4aa72 ("net: dsa: yt921x: Add support for Motorcomm YT921x") Signed-off-by: David Yang <mmyangfl@gmail.com> --- drivers/net/dsa/motorcomm/chip.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c index eddec2f26586..5bfdac18c012 100644 --- a/drivers/net/dsa/motorcomm/chip.c +++ b/drivers/net/dsa/motorcomm/chip.c @@ -799,7 +799,10 @@ yt921x_fdb_join(struct yt921x_priv *priv, const unsigned char *addr, u16 vid, ctrl1 = val1 & ~YT921X_FDB_IO1_STATUS_M; ctrl1 |= YT921X_FDB_IO1_STATUS_STATIC; - ctrl2 = val2 | YT921X_FDB_IO2_EGR_PORTS(ports_mask); + ctrl2 = val2; + if (ctrl1 != val1) + ctrl2 &= ~YT921X_FDB_IO2_EGR_PORTS_M; + ctrl2 |= YT921X_FDB_IO2_EGR_PORTS(ports_mask); if (ctrl1 == val1 && ctrl2 == val2) return 0; -- 2.53.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net v3 2/3] net: dsa: motorcomm: Do not inherit ports from dynamic FDB entries 2026-11-19 22:10 ` [PATCH net v3 2/3] net: dsa: motorcomm: Do not inherit ports from dynamic FDB entries David Yang @ 2026-11-23 22:11 ` netdev-bot+sashiko 0 siblings, 0 replies; 7+ messages in thread From: netdev-bot+sashiko @ 2026-11-23 22:11 UTC (permalink / raw) To: mmyangfl; +Cc: netdev, andrew, olteanv, davem, edumazet, kuba, pabeni 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] When yt921x_fdb_join() (drivers/net/dsa/motorcomm/chip.c) finds an existing non-static (hardware-learned) entry for the (addr,… -- net: dsa: motorcomm: Do not inherit ports from dynamic FDB entries This patch changes yt921x_fdb_join() so that an existing non-static (hardware-learned) entry for the same (address, VID) key has its egress port mask replaced, not merged, when it is converted into a static fdb/mdb entry. > diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c > index 9a9e8ed76e01f..ea305159cd5e7 100644 > --- a/drivers/net/dsa/motorcomm/chip.c > +++ b/drivers/net/dsa/motorcomm/chip.c > @@ -799,7 +799,10 @@ yt921x_fdb_join(struct yt921x_priv *priv, const unsigned char *addr, u16 vid, > > ctrl1 = val1 & ~YT921X_FDB_IO1_STATUS_M; > ctrl1 |= YT921X_FDB_IO1_STATUS_STATIC; > - ctrl2 = val2 | YT921X_FDB_IO2_EGR_PORTS(ports_mask); > + ctrl2 = val2; > + if (ctrl1 != val1) > + ctrl2 &= ~YT921X_FDB_IO2_EGR_PORTS_M; > + ctrl2 |= YT921X_FDB_IO2_EGR_PORTS(ports_mask); [Severity: Medium] When a learned entry is turned into a static one here, only YT921X_FDB_IO2_EGR_PORTS_M is cleared. Should the other attributes of the learned entry be cleared as well? The remaining OUT2 bits are written back through yt921x_fdb_add_index_in12(): YT921X_FDB_IO2_MOVE_AGING_STATUS_M GENMASK(31, 30) YT921X_FDB_IO2_IGR_DROP BIT(29) YT921X_FDB_IO2_EGR_DROP BIT(17) YT921X_FDB_IO2_COPY_TO_CPU BIT(16) YT921X_FDB_IO2_IGR_PRIO_EN BIT(15) YT921X_FDB_IO2_PRIO_M GENMASK(14, 12) YT921X_FDB_IO2_NEW_VID_M GENMASK(11, 0) YT921X_FDB_IO1_EGR_PRIO_EN in ctrl1 is kept as well, because only YT921X_FDB_IO1_STATUS_M is replaced. The other path that creates a static entry, yt921x_fdb_add(), writes only the port mask to IN2: ctrl = YT921X_FDB_IO2_EGR_PORTS(ports_mask); res = yt921x_reg_write(priv, YT921X_FDB_IN2, ctrl); The driver never sets any of the other IO1/IO2 attribute bits. That means the contents of a static entry added through port_fdb_add or port_mdb_add now depend on whether the switch learned the address first. If the hardware fills in MOVE_AGING_STATUS or any of the drop, copy or priority bits on a learned entry, the static entry inherits them. yt921x_fdb_leave() also writes OUT1/OUT2 back with only the egress ports changed, so nothing later clears that state. This looks like the same kind of problem the commit message describes, untracked hardware state carried into a DSA-installed static entry, but handled only for the port mask. The later patch in this series, "net: dsa: motorcomm: Rewrite FDB entry on port migration", moves this logic into yt921x_fdb_update() and keeps the same partial mask: if (join_ports_mask) { ctrl1 &= ~YT921X_FDB_IO1_STATUS_M; ctrl1 |= YT921X_FDB_IO1_STATUS_STATIC; if (ctrl1 != val1) ctrl2 &= ~YT921X_FDB_IO2_EGR_PORTS_M; } So the issue is still present at the end of the series. For the non-static case, could ctrl1/ctrl2 be rebuilt the way yt921x_fdb_add() builds them (STATUS_STATIC plus FID and address in IN1, only EGR_PORTS in IN2), instead of masking out a single field? > if (ctrl1 == val1 && ctrl2 == val2) > return 0; > -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119221110.1123578-1-mmyangfl%40gmail.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net v3 3/3] net: dsa: motorcomm: Rewrite FDB entry on port migration 2026-11-19 22:10 [PATCH net v3 0/3] net: dsa: motorcomm: FDB fixup David Yang 2026-11-19 22:10 ` [PATCH net v3 1/3] net: dsa: motorcomm: Ignore multicast addresses in FDB ops David Yang 2026-11-19 22:10 ` [PATCH net v3 2/3] net: dsa: motorcomm: Do not inherit ports from dynamic FDB entries David Yang @ 2026-11-19 22:10 ` David Yang 2026-11-23 22:11 ` netdev-bot+sashiko 2 siblings, 1 reply; 7+ messages in thread From: David Yang @ 2026-11-19 22:10 UTC (permalink / raw) To: netdev Cc: David Yang, Andrew Lunn, Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni When unicast addresses move between ports, DSA calls .port_fdb_add() without a prior .port_fdb_del() call, making the new port directly OR into the existing entries. The old port mask then loses track in DSA and can never be deleted. Fuse FDB join/leave into one change function, and rewrite the whole entry on add with the bridge port mask as the leave mask, so that ports left behind by the migration are dropped from the entry. Note the commit only covers single bridge usage correctly. Host subscriptions should be mutually exclusive with multiple bridges, which may be addressed in a separate commit later. Fixes: 186623f4aa72 ("net: dsa: yt921x: Add support for Motorcomm YT921x") Signed-off-by: David Yang <mmyangfl@gmail.com> --- drivers/net/dsa/motorcomm/chip.c | 94 ++++++++++++++++---------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c index 5bfdac18c012..e9f01aeb9d3e 100644 --- a/drivers/net/dsa/motorcomm/chip.c +++ b/drivers/net/dsa/motorcomm/chip.c @@ -729,13 +729,14 @@ yt921x_fdb_add(struct yt921x_priv *priv, const unsigned char *addr, u16 vid, } static int -yt921x_fdb_leave(struct yt921x_priv *priv, const unsigned char *addr, - u16 vid, u16 ports_mask) +yt921x_fdb_update(struct yt921x_priv *priv, const unsigned char *addr, + u16 vid, u16 leave_ports_mask, u16 join_ports_mask) { u16 index; u32 ctrl1; u32 ctrl2; u32 ctrl; + u32 val1; u32 val2; u32 val; int res; @@ -744,69 +745,63 @@ yt921x_fdb_leave(struct yt921x_priv *priv, const unsigned char *addr, res = yt921x_fdb_has(priv, addr, vid, &index); if (res) return res; - if (index >= YT921X_FDB_NUM) - return 0; + if (index >= YT921X_FDB_NUM) { + if (!join_ports_mask) + return 0; + + return yt921x_fdb_add(priv, addr, vid, join_ports_mask); + } /* Check if action required */ res = yt921x_reg_read(priv, YT921X_FDB_OUT2, &val2); if (res) return res; - ctrl2 = val2 & ~YT921X_FDB_IO2_EGR_PORTS(ports_mask); - if (ctrl2 == val2) - return 0; - if (!(ctrl2 & YT921X_FDB_IO2_EGR_PORTS_M)) { - ctrl = YT921X_FDB_OP_OP_DEL | YT921X_FDB_OP_START; - res = yt921x_reg_write(priv, YT921X_FDB_OP, ctrl); - if (res) - return res; + ctrl2 = val2 & ~YT921X_FDB_IO2_EGR_PORTS(leave_ports_mask); + if (!join_ports_mask) { + if (ctrl2 == val2) + return 0; + + if (!(ctrl2 & YT921X_FDB_IO2_EGR_PORTS_M)) { + ctrl = YT921X_FDB_OP_OP_DEL | YT921X_FDB_OP_START; + res = yt921x_reg_write(priv, YT921X_FDB_OP, ctrl); + if (res) + return res; - return yt921x_fdb_wait(priv, &val); + return yt921x_fdb_wait(priv, &val); + } } - res = yt921x_reg_read(priv, YT921X_FDB_OUT1, &ctrl1); + res = yt921x_reg_read(priv, YT921X_FDB_OUT1, &val1); if (res) return res; + ctrl1 = val1; + if (join_ports_mask) { + ctrl1 &= ~YT921X_FDB_IO1_STATUS_M; + ctrl1 |= YT921X_FDB_IO1_STATUS_STATIC; + if (ctrl1 != val1) + ctrl2 &= ~YT921X_FDB_IO2_EGR_PORTS_M; + } + ctrl2 |= YT921X_FDB_IO2_EGR_PORTS(join_ports_mask); + if (ctrl1 == val1 && ctrl2 == val2) + return 0; + return yt921x_fdb_add_index_in12(priv, index, ctrl1, ctrl2); } +static int +yt921x_fdb_leave(struct yt921x_priv *priv, const unsigned char *addr, + u16 vid, u16 ports_mask) +{ + return yt921x_fdb_update(priv, addr, vid, ports_mask, 0); +} + static int yt921x_fdb_join(struct yt921x_priv *priv, const unsigned char *addr, u16 vid, u16 ports_mask) { - u16 index; - u32 ctrl1; - u32 ctrl2; - u32 val1; - u32 val2; - int res; - - /* Check for presence */ - res = yt921x_fdb_has(priv, addr, vid, &index); - if (res) - return res; - if (index >= YT921X_FDB_NUM) - return yt921x_fdb_add(priv, addr, vid, ports_mask); - - /* Check if action required */ - res = yt921x_reg_read(priv, YT921X_FDB_OUT1, &val1); - if (res) - return res; - res = yt921x_reg_read(priv, YT921X_FDB_OUT2, &val2); - if (res) - return res; - - ctrl1 = val1 & ~YT921X_FDB_IO1_STATUS_M; - ctrl1 |= YT921X_FDB_IO1_STATUS_STATIC; - ctrl2 = val2; - if (ctrl1 != val1) - ctrl2 &= ~YT921X_FDB_IO2_EGR_PORTS_M; - ctrl2 |= YT921X_FDB_IO2_EGR_PORTS(ports_mask); - if (ctrl1 == val1 && ctrl2 == val2) - return 0; - - return yt921x_fdb_add_index_in12(priv, index, ctrl1, ctrl2); + return yt921x_fdb_update(priv, addr, vid, 0, ports_mask); } static int @@ -880,6 +875,7 @@ yt921x_dsa_port_fdb_add(struct dsa_switch *ds, int port, const unsigned char *addr, u16 vid, struct dsa_db db) { struct yt921x_priv *priv = dsa_to_yt921x_priv(ds); + u32 leave_ports_mask = 0; int res; /* The software bridge never forwards according to an FDB entry with a @@ -888,8 +884,12 @@ yt921x_dsa_port_fdb_add(struct dsa_switch *ds, int port, if (is_multicast_ether_addr(addr)) return 0; + if (db.type == DSA_DB_BRIDGE) + leave_ports_mask = dsa_bridge_ports(ds, db.bridge.dev); + mutex_lock(&priv->reg_lock); - res = yt921x_fdb_join(priv, addr, vid, BIT(port)); + res = yt921x_fdb_update(priv, addr, vid, leave_ports_mask, + BIT(port)); mutex_unlock(&priv->reg_lock); return res; -- 2.53.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net v3 3/3] net: dsa: motorcomm: Rewrite FDB entry on port migration 2026-11-19 22:10 ` [PATCH net v3 3/3] net: dsa: motorcomm: Rewrite FDB entry on port migration David Yang @ 2026-11-23 22:11 ` netdev-bot+sashiko 0 siblings, 0 replies; 7+ messages in thread From: netdev-bot+sashiko @ 2026-11-23 22:11 UTC (permalink / raw) To: mmyangfl; +Cc: netdev, andrew, olteanv, davem, edumazet, kuba, pabeni Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider. Critical: 0 · High: 1 · 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). - [High] The migration fix is incomplete when an address moves between the host (CPU port) and a user port, even in the single-bridge setup… - [Medium] The new dsa_bridge_ports(ds, db.bridge.dev) call in yt921x_dsa_port_fdb_add() (chip.c:888) walks every user port of the… -- net: dsa: motorcomm: Rewrite FDB entry on port migration This commit merges yt921x_fdb_join() and yt921x_fdb_leave() into a new yt921x_fdb_update() helper. On .port_fdb_add() it uses the bridge port mask as the leave mask, so that ports left behind by a migration are dropped from the hardware entry. > diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c > index ea305159cd5e7..79e4326d5a703 100644 > --- a/drivers/net/dsa/motorcomm/chip.c > +++ b/drivers/net/dsa/motorcomm/chip.c [ ... ] > @@ -888,8 +884,12 @@ yt921x_dsa_port_fdb_add(struct dsa_switch *ds, int port, > if (is_multicast_ether_addr(addr)) > return 0; > > + if (db.type == DSA_DB_BRIDGE) > + leave_ports_mask = dsa_bridge_ports(ds, db.bridge.dev); > + [Severity: High] Does this leave mask handle an address that moves between the host (CPU port) and a user port? dsa_bridge_ports() walks dsa_switch_for_each_bridge_member(), which is built on dsa_switch_for_each_user_port(). That means the CPU port bit is never in leave_ports_mask. The driver sets assisted_learning_on_cpu_port, so a host address A (on br0, or on a foreign bridged interface) is installed through dsa_port_do_fdb_add(cpu_dp). The hardware entry becomes static with only the CPU port in its egress mask. If the address is then moved with: bridge fdb replace A dev swp2 master static fdb_add_entry() in net/bridge/br_fdb.c only sends RTM_NEWNEIGH, so the driver gets yt921x_dsa_port_fdb_add(swp2) with no delete first. In yt921x_fdb_update(): ctrl2 = val2 & ~YT921X_FDB_IO2_EGR_PORTS(leave_ports_mask); ... ctrl1 = val1; if (join_ports_mask) { ctrl1 &= ~YT921X_FDB_IO1_STATUS_M; ctrl1 |= YT921X_FDB_IO1_STATUS_STATIC; if (ctrl1 != val1) ctrl2 &= ~YT921X_FDB_IO2_EGR_PORTS_M; } ctrl2 |= YT921X_FDB_IO2_EGR_PORTS(join_ports_mask); The entry is already static, so ctrl1 == val1 and the clear-all branch is skipped. Wouldn't the entry be written back as {CPU, swp2}, leaving the CPU port behind? The reverse direction looks broken too, and the driver can't see it. Moving A back to the host goes through dsa_port_do_fdb_add(cpu_dp). There the old record, whose refcount was never released, is found again: net/dsa/switch.c:dsa_port_do_fdb_add() { ... a = dsa_mac_addr_find(&dp->fdbs, addr, vid, db); if (a) { refcount_inc(&a->refcount); ... } So .port_fdb_add() is not called for the CPU port and swp2 stays in the entry. A later fdb del on the host side only drops the refcount. yt921x_dsa_port_fdb_del() also only clears BIT(port). Can this leave a static hardware entry that never ages out and keeps forwarding unicast for A to the CPU port and/or swp2 after the software bridge has moved it? The commit message says single-bridge usage is covered, and this is a single-bridge setup. The CPU port side depends on DSA's refcounting. Can a driver-side leave mask fix that part at all? [Severity: Medium] Is it safe to walk every port's dp->bridge from .port_fdb_add()? This handler can run from the deferred switchdev worker without rtnl: dsa_user_switchdev_event_work() dsa_port_bridge_host_fdb_add() dsa_port_do_fdb_add(cpu_dp) ds->ops->port_fdb_add() yt921x_dsa_port_fdb_add() dsa_bridge_ports() The comment in dsa_port_bridge_host_fdb_add() says rtnl can't be guaranteed there. Only cpu_dp->addr_lists_lock is held. dsa_bridge_ports() reads each user port's bridge through dsa_port_bridge_dev_get(): return dp->bridge ? dp->bridge->dev : NULL; At the same time, another port Q can leave its bridge under rtnl. When Q is the last member, dsa_port_bridge_destroy() does this with no RCU grace period: dp->bridge = NULL; if (!refcount_dec_and_test(&bridge->refcount)) return; ... kfree(bridge); The dsa_flush_workqueue() in dsa_port_pre_bridge_leave() only drains work queued before that point. Host FDB work for a port that stays bridged can still be queued from softirq learning. With multiple bridges on the switch, can the worker load dp->bridge for Q and then read ->dev after that dsa_bridge has been freed? Even without a use-after-free, the membership snapshot is not taken under any lock that serializes bridge join/leave. Could leave_ports_mask be stale by the time the entry is written? Before this patch, this path only used the db that DSA passed in for the calling port. The other dsa_bridge_ports() callers in this driver (port_bridge_flags and bridge join) run under rtnl. DSA core already reads dp->bridge in this worker without rtnl (for example in dsa_foreign_dev_check()), but this patch adds a new cross-port walk. > mutex_lock(&priv->reg_lock); > - res = yt921x_fdb_join(priv, addr, vid, BIT(port)); > + res = yt921x_fdb_update(priv, addr, vid, leave_ports_mask, > + BIT(port)); > mutex_unlock(&priv->reg_lock); > > return res; -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119221110.1123578-1-mmyangfl%40gmail.com ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-23 22:11 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-19 22:10 [PATCH net v3 0/3] net: dsa: motorcomm: FDB fixup David Yang 2026-11-19 22:10 ` [PATCH net v3 1/3] net: dsa: motorcomm: Ignore multicast addresses in FDB ops David Yang 2026-11-23 22:11 ` netdev-bot+sashiko 2026-11-19 22:10 ` [PATCH net v3 2/3] net: dsa: motorcomm: Do not inherit ports from dynamic FDB entries David Yang 2026-11-23 22:11 ` netdev-bot+sashiko 2026-11-19 22:10 ` [PATCH net v3 3/3] net: dsa: motorcomm: Rewrite FDB entry on port migration David Yang 2026-11-23 22:11 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox