Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: o.rempel@pengutronix.de
Cc: woojung.huh@microchip.com, UNGLinuxDriver@microchip.com,
	andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org, f.fainelli@gmail.com, razor@blackwall.org,
	idosch@nvidia.com, netdev@vger.kernel.org,
	bridge@lists.linux.dev, kernel@pengutronix.de
Subject: Re: [PATCH net-next 2/5] net: dsa: microchip: ksz9477: do not keep the learned port in FDB entries
Date: Fri, 27 Nov 2026 08:24:32 +0000	[thread overview]
Message-ID: <179576787253.3135.17885676621555467617@kernel.org> (raw)
In-Reply-To: <20261126-ksz-stp-link-local-v1-2-39aed15f6271@pengutronix.de>

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.

> 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

  reply	other threads:[~2026-11-27  8:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  8:07 [PATCH net-next 0/5] net: dsa: microchip: let the bridge decide about link-local frames Oleksij Rempel
2026-11-26  8:07 ` [PATCH net-next 1/5] net: dsa: tag_ksz: do not mark trapped link-local frames as forwarded Oleksij Rempel
2026-11-26 14:47   ` Andrew Lunn
2026-11-26  8:07 ` [PATCH net-next 2/5] net: dsa: microchip: ksz9477: do not keep the learned port in FDB entries Oleksij Rempel
2026-11-27  8:24   ` netdev-bot+sashiko [this message]
2026-11-26  8:07 ` [PATCH net-next 3/5] net: dsa: microchip: ksz9477: do not learn addresses on the CPU port Oleksij Rempel
2026-11-27  8:24   ` netdev-bot+sashiko
2026-11-26  8:07 ` [PATCH net-next 4/5] net: dsa: microchip: ksz9477: refuse FDB/MDB entries for trapped groups Oleksij Rempel
2026-11-27  8:24   ` netdev-bot+sashiko
2026-11-26  8:07 ` [PATCH net-next 5/5] net: dsa: microchip: ksz9477: report the trapped link-local groups Oleksij Rempel
2026-11-27  8:24   ` netdev-bot+sashiko
2026-11-26 10:23 ` [PATCH net-next 0/5] net: dsa: microchip: let the bridge decide about link-local frames Vladimir Oltean
2026-11-27  5:53   ` Oleksij Rempel

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=179576787253.3135.17885676621555467617@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=bridge@lists.linux.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.org \
    --cc=woojung.huh@microchip.com \
    /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