๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #23405

Re: [PATCH net-next 2/5] net: dsa: microchip: ksz9477: do not keep the learned port in FDB entries

#23405
From: netdev-bot+sashiko
Date: Fri, 27 Nov 2026 08:24
112 lines
12226 bytes
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
Technical Details
Message-ID: <179576787253.3135.17885676621555467617@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372535-linux-kernel-netdev=dewy.ru
References: <20261126-ksz-stp-link-local-v1-2-39aed15f6271@pengutronix.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372535-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179576787253.3135.17885676621555467617@kernel.org>
References: <20261126-ksz-stp-link-local-v1-2-39aed15f6271@pengutronix.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="682362"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:PCPcjsXVfXooBDGPyJ+CWpD0AXU= sha256:RGW9KwNmGauscLaNMY9tcc9OWjP6DMj1qI136vTUKtM=
	sha1:UWygS6JHuvKjTvCEf++oND1P+pQ= sha256:KzbKoluxixu61OCUDVVBbPiTIUZoqo95FZjbw7vZsOs=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 753A1125F27; Fri, 27 Nov 2026 11:24:57 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id GrjcgASo4QJM;
	Fri, 27 Nov 2026 11:24:53 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-372535-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 07759125F20; Fri, 27 Nov 2026 11:24:43 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 5925C20831; Fri, 27 Nov 2026 08:24:39 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795767875;
	b=zt0QiQOBxJ876acAuUHwKl8i5RmYfxuW4N9AO1dPHGrE9aRyQ0ERKgSBGRa4/a12Mdr1
	 9QqNDIzlH8qI+oQ5UZYvZgJ5W2nPLv9qBhGmlU1yBL7MSGtRj9XAJOvl5aFG7KRcqHCBJ
	 Zh3lgfobUoFgmFFX1qvABaM3D1KscCuvuvMKbml/jBjzXViNyBfx2v26DtQZu1QFzwy0N
	 VIhqdv8KXi8JS+uixp9V3j8eKd0vGa7ttn4KQTgSvvQ8oDWUUqdxONzNDMSsURYXfywrT
	 mK6GWvHKgrIxgUHDCEgBnPuju+qDehVJA5P+U9a6Ov8IKqMkfWk+7J5oi0MmwK9rULQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795767875;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=clCUkJmrvj16kl83LPMA6kvCuKRRhj6JejeF30H3Ws4=;
	b=HlezRdFziY4Dehtwfk75v5F7en7nSkO4wKdD+/+4A6kEwMkmc1I3LSajYYkmN0TWrlYk
	 5KljGKlaWDdPICMt+fpPMmVZKkrhG2Fa4wYk+6SWybm6s/QnoQnbIUlZ+3JA3pl1YFbr8
	 HwopiQyydQN/gKhDpbEZ+f1sOI7AD8r8WYMACSJe0NSHmhFH5t58rgK3sHX4H4JVTOpva
	 GXL6WcqOHRugARa9y6I4GPFL0QKIuQ+9UvcmWKQv2ZWgam+mNolLVsK9HzbcPubNK6zkK
	 2BOY2rbo20Wnf6mFDmZfy0LNbpgbfDiGV2JZrXUZhhmz14b6jJEAXI+u8mjzPBIP8iw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FPk8Fzhq;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B406606A33C;
	Fri, 27 Nov 2026 08:24:35 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FPk8Fzhq
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795767874;
	b=Y2Qy2pnf0ViuP52DYZhrmch365cmNtFO4hPVUbWMMAeub6PCEmZTjSyBCurCDRVWiFah
	 nGh22wOp8ziFEN/guhaCwjuTYAFGJ469DVeJFIKDlQzX7DeQIxd0Z9+P23W8hpbETuwDo
	 NCrPBVw5qweHuNHYNGFbICRP9xgMmVeg7qlyL8odlwnFmzyYcbktJs+EcW5lugSVBmctT
	 oQB67YBcwCbIY7nBn9AXrzoG18Zd6N9dw31fupPPpmsQPvHLnasEVFGoWIQjBQ+o4mzhF
	 ksWyPdHJ3rZwXq4eH34zBRUk6kt3c+vRjVFURrG2BzFN4A6PHgaq6HmKeiwx1gwr3tw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795767874;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=clCUkJmrvj16kl83LPMA6kvCuKRRhj6JejeF30H3Ws4=;
	b=Eo9ZlZZWYtRUqsI5mm9k4QbxzrqUqAYM9DvzG89JMwTOvo0qWoMpxz9U26041Pngod+0
	 +Qi9DVaNf0YHlircKxmGY64H9ekyWkOWuerQWaC30ZhuRunNUwN7ypCZZrsTQ/X7WyOZo
	 rB0ofkP4x/jK480lpH8bKwfB2UJzT86/ZPDUVqDhQ6mmZq5doV5ZwRQ00KiESteQDXJ/4
	 0Ki8Tu3XftoigLZhMDbZuljxPoF32BSaXYHnzhR2oJ7VzhO3vLXYXgNp3bODyMS+60aaY
	 4Yy7AmVWLnUkN1FfBHkkLVVsJOUjXVlWDv5UV5GQZvjgUKpwtCZN5uEfReroZwamEag==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FPk8Fzhq;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 438CF606A323;
	Fri, 27 Nov 2026 08:24:34 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0251A1F00897;
	Fri, 27 Nov 2026 08:24:32 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795767873;
	bh=clCUkJmrvj16kl83LPMA6kvCuKRRhj6JejeF30H3Ws4=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=FPk8Fzhqmz3lsVmKocfY/zbgpLEKVAQOrHmdMFxLCKTS8+7/G9XflNl0RadA4MZg8
	 ufxqpi3z1DFUSwT3+Vu+yv+iSk0dzo04W4D39RfqBYuIg94jNmUiz/LUsUwP+2vj+3
	 b+jZUMTAzBhmslZwrLUrsa5mpuxOKNPvVH3ROtw2yC8pfCvz/9mVVxoZOFIZfX4gUU
	 8xtXE6cPq5+TsbphFZhp+WhfewnPzSF5M3jXxTvMg+MNlTFldJUQvtN3M41N4GMKLM
	 HI4L70BxHHLw4/nrPOI4ukUcPdwxO6TrlE1V1ONuv2x/tBdskujF1QSJDcAWoVvK7i
	 500W+x5t/DGIg==
X-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
X-In-Reply-To: <20261126-ksz-stp-link-local-v1-2-39aed15f6271@pengutronix.de>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list