🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21880

Re: [PATCH net] net: sparx5/lan969x: remove MDB entries on last bridge leave

#21880
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 14:56
147 lines
13457 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 (1) · Low: 1

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] The patch makes host-joined MDB groups disappear from hardware
  when the last sparx5 port leaves a bridge that stays up, and nothing…
- [Low] sparx5_mdb_flush() ignores the return value of
  sparx5_mact_forget(), which can be -ETIMEDOUT from…

Pre-existing issues:
- [Medium] MDB entries leak when the driver is unbound while ports are
  bridged.

--

net: sparx5/lan969x: remove MDB entries on last bridge leave

This patch fixes a NULL pointer dereference in sparx5_handle_port_mdb_del()
that happens when a bridge with a permanent MDB entry on one of its ports is
deleted. When the last port leaves the bridge, all MDB entries are now
flushed before hw_bridge_dev is cleared. MDB adds and deletes are ignored
while no bridge is offloaded.

> diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
> index dac4dd833127a..65ce225baa023 100644
> --- a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
> +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
> @@ -172,6 +172,30 @@ static int sparx5_port_attr_set(struct net_device *dev, const void *ctx,

[ ... ]

> +static void sparx5_mdb_flush(struct sparx5 *sparx5)
> +{
> +	struct sparx5_mdb_entry *entry, *tmp;
> +
> +	mutex_lock(&sparx5->mdb_lock);
> +	list_for_each_entry_safe(entry, tmp, &sparx5->mdb_entries, list) {
> +		if (entry->cpu_copy)
> +			sparx5_cpu_copy_ena(sparx5, entry->pgid_idx, false);

[Severity: Medium]
Can flushing the host-only entries here leave the hardware out of sync
with the bridge? This would happen when the bridge stays up and a port
rejoins it later.

After the last port leaves, the bridge still holds the host group (an
entry with cpu_copy set and an empty port_mask).
br_multicast_del_port() only deletes the leaving port's groups from
port->mglist, so mp->host_joined stays true. br_multicast_host_join()
only notifies when host_joined goes from false to true.

When a port rejoins, sparx5_port_bridge_join() passes no notifier blocks:

	err = switchdev_bridge_port_offload(ndev, ndev, NULL, NULL, NULL,
					    false, extack);

so br_switchdev_mdb_replay() returns early:

	if (!nb)
		return 0;

Nothing adds the MAC/PGID entry with CPU copy back. This sequence looks
like enough to hit it:

  ip link add br0 type bridge
  ip link set p1 master br0
  ip link set br0 up
  bridge mdb add dev br0 port br0 grp 239.1.1.1 permanent
  ip link set p1 nomaster
  ip link set p1 master br0

Afterwards the bridge still lists 239.1.1.1 as host-joined, but the
switch no longer copies the group to the CPU. Dynamic host joins look
the same, because later host reports only refresh the timer.

Before this patch, sparx5_port_bridge_leave() did not touch the MDB list
or the hardware entries, so this leave/rejoin case kept working. The
commit message says:

  "Host groups added before the first port joins the bridge are not
  offloaded either, so this matches the existing behaviour."

Does that hold for the leave/rejoin case as well?

Could the flush keep the host-only entries? Another option is to pass
notifier blocks to switchdev_bridge_port_offload() so the bridge replays
its MDB. lan966x_port_bridge_join() does this with &lan966x_switchdev_nb
and &lan966x_switchdev_blocking_nb.

> +		sparx5_pgid_clear(sparx5, entry->pgid_idx);
> +		sparx5_mact_forget(sparx5, entry->addr, entry->vid);
> +		list_del(&entry->list);
> +		sparx5_pgid_free(sparx5, entry->pgid_idx);

[Severity: Low]
sparx5_mact_forget() can return -ETIMEDOUT from
sparx5_mact_wait_for_completion(). Is it safe to ignore that and still
return the PGID to the pool?

If the UNLEARN did not complete, the MAC table could still have an entry
pointing at this PGID. sparx5_pgid_alloc_mcast() hands out the lowest
free index first, so the next group would probably get this PGID.

This needs a MAC table engine timeout. sparx5_handle_port_mdb_del()
already frees the PGID unconditionally after sparx5_mact_forget() in the
same way.

> +		kfree(entry);
> +	}
> +	mutex_unlock(&sparx5->mdb_lock);
> +}

[Severity: Medium]
This is a pre-existing issue, not one introduced by this patch, but are
the MDB entries still leaked when the driver is unbound while ports are
bridged?

mchp_sparx5_remove() unregisters the notifiers before the netdevs:

	sparx5_unregister_notifier_blocks(sparx5);
	sparx5_unregister_netdevs(sparx5);

The CHANGEUPPER sent when the bridge ports are removed therefore never
reaches sparx5_port_bridge_leave(), and sparx5_mdb_flush() never runs.
The deferred switchdev MDB deletes are not delivered either.

sparx5_mact_deinit() does not walk sparx5->mdb_entries:

	cancel_delayed_work_sync(&sparx5->mact_work);
	destroy_workqueue(sparx5->mact_queue);
	mutex_destroy(&sparx5->mact_lock);

So the sparx5_mdb_entry allocations are never freed, and mdb_lock is
never destroyed.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123-sparx5-mdb-bridge-leave-v1-1-40b50d7b7a1c%40microchip.com
Technical Details
Message-ID: <179553221699.3135.13151285770716836389@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-370486-linux-kernel-netdev=dewy.ru
References: <20261123-sparx5-mdb-bridge-leave-v1-1-40b50d7b7a1c@microchip.com>

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-370486-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] net: sparx5/lan969x: remove MDB entries on last bridge leave
Date: Tue, 24 Nov 2026 14:56:56 +0000
Organization: Usenet Network
Message-ID: <179553221699.3135.13151285770716836389@kernel.org>
References: <20261123-sparx5-mdb-bridge-leave-v1-1-40b50d7b7a1c@microchip.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="4162959"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:3KMdm2ZcQIrqoVfdfxaaj5i1eXo= sha256:65/rNnf6GgH7AL8sZ4sPsukJOGtQiV7F7M2lOwkVqh8=
	sha1:EdPy8kRYRhIMH1kT9St2sr74M6k= sha256:7KQKOXiXUbGHJuVu4DVFJOU6tIEKKrXIId+sXhI/nUU=
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 27FC8125E1C; Tue, 24 Nov 2026 17:57:21 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.5
X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31
	tests=[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,
	URIBL_BLOCKED=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 UquIMId2C_GH;
	Tue, 24 Nov 2026 17:57:16 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-370486-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 5BA00125E1B; Tue, 24 Nov 2026 17:57:05 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id C40516049A7; Tue, 24 Nov 2026 14:57:04 +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=1795532219;
	b=Qco5FfpQfeuSSdl5d/rwuocaWWuEjUrd7NJw5QWXE6lFAPAAp3s5fcK/EfPgEhY/z6mj
	 IVhjzSkDxlWc62Z7fRVz6nLrhgQmL1PZb7igboMozgo8LiHC0+SYdB1x7Hfgv5I7f0A4y
	 8rABVvwGew8W2EwsU5vByKgGJ/r/vUAQHxAdt1MPMFStgA8lXpCCVsjMBI0Kq2FLTBPLD
	 ccvvVWkLWpIsBn2n9r1ao6ORHIMERmV+csN34IxB0MLQD6gZTutmyaLkAlC4XzXVZA9wI
	 OWOkX40jSckiHVyW43zYrsI+XqGVdJxH0/aIGLk2izIIiAMOLo2j1/ONOCtwo+DCBHw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795532219;
	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=mh/yVqw5w3cdbkpA2iej9q/2ol5jZwPriRpNWVPGSqw=;
	b=lcqUxFxxDZoH+bof31wO6H/8DmM8EMiQq9H3uNdBYrJU70jQU/xkcVhOJDFHSLfdnzJu
	 U5azw+m8gs6yItLLba0UwnZw6ii+jd7Alt0YBvAoHVvgdKdb9jLe/6tGjz/yT34jMP/Yz
	 /I0daNRoRwk/VcUqyO7qkPgIMpXjxSSWoBiE6hbuLD4yIdyMUOs5+HqQGeXd6kJoa7XiG
	 hAfTVEBrP9jmObQQMfYfNF0Kxm0ID24ZZZnavR9OgjfnMFLxPbMdpWi+y6TK9pubV/A/L
	 FYCQo6x/jAWsX+oHC1Rblze93KjxFLAa3hVj0ayCHOanfZfef8O5KkfFUqc74erKFOA==
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=KUtJxRBa;
	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 432EC606A6AA;
	Tue, 24 Nov 2026 14:56:59 +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=KUtJxRBa
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=1795532218;
	b=DDvGCd4dw7ataMXKCU1IUJI60j7hRGn4tDReZ0DHQY97LtXWPIy6Q6rE6c7IhcftuYis
	 33pTLtMIietoPAWDaKAA2B7VNJUPDxYIzJBayjtxDTEbn6Iv8t0hJPZwO4qlhidxXUy1n
	 geZGclRPlJXV1fbvZsSgRatsvqOAE78ieP8rfa6hqEi+Ds+NmzRwhk/7oQABsGDFaFQpX
	 NgMO5R5PSAknZfBe6Ta1u9gB/32hmX6zWU2/oh35B/d0Z8klZ7wadwiiKNKXxHJHPC4wn
	 lclmZNLTVHqKcc5V/H6wZtUdE65bIn75/SsANJx7KGwKqxPU3GTkQhp+xOqDIxjTFpg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795532218;
	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=mh/yVqw5w3cdbkpA2iej9q/2ol5jZwPriRpNWVPGSqw=;
	b=ICzylDF5NPxNEObt1TcYt+7Wamb4LBCz4qzHYTbUmCVgIckdtoIVuMmWOrNnUW5P6X4C
	 HYqDJ67zB8MF9y0U4WyYUVdBOMbea5hUfNbjXSBPXG4suvNO+NLhKcJlgOUhK3Ob0Sye8
	 4i4l5MkoRz6qc+gRvaoqgI4FnpViYTeayvR+iR/PSArnE1sx21l6TSs7wVVFarww1CxxW
	 wuAZ24k0ZPwxzIDqwR/9XtAZnUHfj5gGQkNfM2e43QCCZoHCN/JVI77k0ywOQ+v8ZC8A9
	 AKKm/+G97XR6glk27Ce5jueEGDHGVPKUO1sSzcZKDwDCjeLi/jNNYydxtmlhf1WzWCg==
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=KUtJxRBa;
	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 64F63606A32E
	for <netdev@vger.kernel.org>; Tue, 24 Nov 2026 14:56:58 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 693A71F01573;
	Tue, 24 Nov 2026 14:56:57 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795532218;
	bh=mh/yVqw5w3cdbkpA2iej9q/2ol5jZwPriRpNWVPGSqw=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=KUtJxRBap81WBZxh0syX5xcKWiubLKw4vGS/0Cjp7Fjk+8dRAd/FrmEw5zj7sok5A
	 Npdls3qRh2JKVUyF5hdk0RQdcOJ0DDuLtDHSkNvUrhn9ApcbkteSyfSEbzWi43lvfI
	 ud8OHWevznazs6zobdmOKqaaOyK0Bb/br7TEGH0qx9BBpX7Y1JCbgYCjRRwg8DJU9X
	 YJ40L6/x1slVzjZOgz3gWeisqLh6jn0KMrNw9IVgqvcEKS8m4dgtLiZ7qf41czfuZ3
	 tyJKD6YIee70O0Cca6Nahod6UcwkoAm4yqFahya+VKiWUbJAFsQaBMlk0qCLtAfcXD
	 zL7i/C0l50RBw==
X-Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, Steen.Hegelund@microchip.com,
 UNGLinuxDriver@microchip.com, casper.casan@gmail.com, netdev@vger.kernel.org,
 linux-arm-kernel@lists.infradead.org, haoxiang_li2024@163.com
X-In-Reply-To: <20261123-sparx5-mdb-bridge-leave-v1-1-40b50d7b7a1c@microchip.com>
X-sashiko-severity: Medium
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