Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · 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 fix covers only part of the bug its commit message
describes.
--
net: dsa: microchip: ksz9477: do not keep the learned port in FDB entries
This patch changes ksz9477_fdb_add() so that a static FDB entry no longer
inherits the port map of a learned ALU entry for the same address. If the
ALU entry found for the address is not already static, its port map is
cleared before the requested port is set.
quoted hunk ↗ jump to hunk
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 972703fe7454f..98211d9835734 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -800,6 +800,13 @@ int ksz9477_fdb_add(struct dsa_switch *ds, int port,
/* read ALU entry */
ksz9477_read_table(dev, alu_table);
+ /* The ALU table holds learned and static entries. If the entry is
+ * not static (learned, or none found), clear its port map, so that
+ * the static entry lists only this port.
+ */
+ if (!(alu_table[0] & ALU_V_STATIC_VALID))
+ alu_table[1] &= ~ALU_V_PORT_MAP;
+
/* update ALU entry */
alu_table[0] = ALU_V_STATIC_VALID;
alu_table[1] |= BIT(port);
[Severity: High]
Can the stale static entry from the commit message still be created when
the existing ALU entry is already static?
When ALU_V_STATIC_VALID is set, the port map is kept, and the
alu_table[1] |= BIT(port) adds the new port to the old one.
For a user replace, the bridge does not tell the driver about the old
port. fdb_add_entry()->fdb_update_dst() in net/bridge/br_fdb.c only
rewrites the destination:
net/bridge/br_fdb.c:fdb_update_dst() {
...
br_fdb_dst_write(fdb, dst);
return true;
}
Only RTM_NEWNEIGH is then sent for the new port. That differs from learned
migration in br_fdb_update(), which first sends a delete for the old
port:
if (source != old_port) {
br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH);
br_fdb_dst_write(fdb, dst);
So in the replace case, port_fdb_add is the only notice the driver gets
that the address moved. Take this sequence:
bridge fdb add H dev lan1 master static -> ALU static {lan1}
bridge fdb replace H dev lan2 master static -> ALU static {lan1, lan2}
bridge fdb del H dev lan2 master static
After the replace, the bridge has H only on lan2. ksz9477_fdb_del() then
clears only the deleted port:
/* clear forwarding port */
alu_table[1] &= ~BIT(port);
That leaves a static {lan1} entry. The bridge no longer tracks it, and it
never ages out. This is the same result the commit message describes:
"The entry stays static and still points to lan1. Static entries never
age out. So the switch keeps sending frames for H to lan1, even after H
has moved."
Would it be better to always set the unicast port map to exactly BIT(port),
by clearing ALU_V_PORT_MAP unconditionally instead of only for non-static
entries? mv88e6xxx_port_db_load_purge() already does this for unicast
static entries:
if (state == MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC)
entry.portvec = BIT(port);
Multicast uses the separate static table in ksz9477_mdb_add(), so it does
not seem to go through this path.
The note below the --- line already mentions this gap:
"If bridge fdb replace moves an existing static entry to another port,
the entry still keeps the old port. This patch does not change that."
That text does not end up in git history, though. The commit carries a
Fixes: tag, so the commit log does not show that the bug is only partly
fixed. The following ksz9477 change sets ds->assisted_learning_on_cpu_port,
which creates more static entries on the CPU port that this OR-merge can
act on.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126-ksz-stp-link-local-v1-0-39aed15f6271%40pengutronix.de