From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D653606A337 for ; Fri, 4 Dec 2026 15:14:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=NYBwKwAc; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gESz7nKD DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:Message-ID:Date :Cc:To:From:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=nIffP/L4CE0Ole8Jehs07SQIOA5vwUmH88+TO6xhucU=; b=NYBwKwAcU920qjcqAR3FhYcI3w GBpcsu+8xRclYs3b51GjFzO8Tkv5LJ9dfdfbyLRJLOh6yq4ONliHP9YmcGS1NNwmGQYoN1bVbPQcg 3/Tj3YMtT3Uq+nnvY8/6KP0YGW+lHlPGzRVfPOF7OHgbHe6IJUb7lMyjUxZnjmmikYbLUPXjQHmfl 5pxn1aG6xs5trjEhzY+Qv169U/7bpOCpe5mePHM40d6/AWTnaXa2CL/R5vZGr4UTtalOBvJsh4dLr uSJyWRM2SxcK9HtI5zCLZmgxRjk6yQzNr7UDgAJFJOf5gX4KGSVSXeehG0FgPw1eXbgUnGxdGWmSn N6ODw2nQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZUzT-00000000j0F-3eIz; Fri, 04 Dec 2026 15:14:27 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZUz1-00000000iwv-0TZr for linux-arm-kernel@lists.infradead.org; Fri, 04 Dec 2026 15:14:22 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 938E845FF1; Fri, 4 Dec 2026 15:13:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3A401F000C2; Fri, 4 Dec 2026 15:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796397238; bh=nIffP/L4CE0Ole8Jehs07SQIOA5vwUmH88+TO6xhucU=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=gESz7nKDg1H7lHEAjqZ2njR0wfE/Xyu+awlBwXcNA+UIKZLBbgVCtEKqc9UZdDkUA NMP9StgCkWa/lRMS4zRVrTQoj251UNWjeIU3lCiU+OEaw9vbypAkJh7b2TPQxfCvLS SYQrggu0WZ6rQ50smFcp4O3dQn7f9rAJB59RLI3PdP+c0pX8qjffYjTukpptWcxUPi HBicA9oQW9xqd+ZB0I2rQ4vymwtLbKUfV6ppWUrOyEcF5dfIGEVoC8YOldiSvxmVj6 RkoMiIcTQaMgLMmHNj/ciH6cSLOnxQAS9iFiINq/YmbMTsC8Cht1SqGHcE1P/Pwgxf qJjrj0t+tb6kA== Subject: Re: [PATCH net v3] net: sparx5/lan969x: remove MDB entries on last bridge leave From: netdev-bot+sashiko@kernel.org To: daniel.machon@microchip.com 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 Date: Fri, 04 Dec 2026 15:13:57 +0000 Message-ID: <179639723737.3146.2801107171885145585@kernel.org> In-Reply-To: <20261203-sparx5-mdb-bridge-leave-v3-1-835c752ef628@microchip.com> References: <20261203-sparx5-mdb-bridge-leave-v3-1-835c752ef628@microchip.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Archived-By: MIME-Version: 1.0 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-11.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 (1) · Medium: 1 · Low: 0 (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 flushes all MDB entries, host groups included, on the last bridge leave (sparx5_port_bridge_leave(),… Pre-existing issues: - [High] This problem wasn't introduced by this patch, but sparx5_register_notifier_blocks() registers the atomic switchdev… - [Low] The new ctx filter in sparx5_handle_port_obj_add() (`if (info->info.ctx && info->info.ctx != netdev_priv(dev)) return 0;`,… -- net: sparx5/lan969x: remove MDB entries on last bridge leave This patch flushes all MDB entries when the last sparx5 port leaves the bridge, before hw_bridge_dev is cleared. It also ignores MDB add/del while no bridge is offloaded. To restore host groups, it has the bridge replay its MDB on join and filters out replayed objects that belong to other ports. > diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c > index dac4dd833127a..5bd5d3474e54a 100644 > --- a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c > +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c [ ... ] > @@ -227,8 +256,10 @@ static void sparx5_port_bridge_leave(struct sparx5_port *port, > switchdev_bridge_port_unoffload(port->ndev, NULL, NULL, NULL); > > clear_bit(port->portno, sparx5->bridge_mask); > - if (bitmap_empty(sparx5->bridge_mask, SPX5_PORTS)) > + if (bitmap_empty(sparx5->bridge_mask, SPX5_PORTS)) { > + sparx5_mdb_flush(sparx5); > sparx5->hw_bridge_dev = NULL; > + } [Severity: Medium] This flush also removes the host groups. The commit message relies on the MDB replay at the next join to bring them back. Is the replay guaranteed to happen? br_switchdev_mdb_replay() returns early when multicast snooping is off: net/bridge/br_switchdev.c:br_switchdev_mdb_replay() { ... if (!br_opt_get(br, BROPT_MULTICAST_ENABLED)) return 0; ... } Turning snooping back on in br_multicast_toggle() only calls br_multicast_open() and br_multicast_enable_all_ports(). Nothing replays the MDB to switchdev. For example: bridge mdb add dev br0 port br0 grp 239.1.1.1 permanent ip link set br0 type bridge mcast_snooping 0 ip link set nomaster -> sparx5_mdb_flush() ip link set master br0 -> replay skipped ip link set br0 type bridge mcast_snooping 1 After this, the bridge MDB still has the host group, but the switch has no PGID/MAC entry and no CPU copy for it. sparx5_port_bridge_join() unsyncs the standalone mc list. Would the host then stop receiving this group's traffic from the sparx5 ports? Before this patch, the host group's hardware entry was not touched on leave, so this sequence kept working. > > /* Clear bridge vlan settings before updating the port settings */ > port->vlan_aware = 0; [ ... ] > @@ -647,6 +677,9 @@ static int sparx5_handle_port_obj_add(struct net_device *dev, > const struct switchdev_obj *obj = info->obj; > int err; > > + if (info->info.ctx && info->info.ctx != netdev_priv(dev)) > + return 0; > + [Severity: Low] This is a pre-existing issue rather than one introduced by this patch, but this ctx check also drops replayed objects whose dev is the bridge master. br_switchdev_vlan_replay() replays the bridge's own VLAN group with dev set to the bridge and ctx set to the port: err = br_switchdev_vlan_replay_group(nb, br_dev, br_vlan_group(br), ctx, action, extack); netdev_priv() of the bridge is a struct net_bridge, which never matches ctx. As a result, replay can never reach this branch in sparx5_handle_port_vlan_add(): if (netif_is_bridge_master(dev)) { ... sparx5_mact_learn(sparx5, sparx5_get_pgid(sparx5, PGID_BCAST), dev->broadcast, v->vid); return 0; } Normal notifications have a NULL ctx, so they still pass the check. Before this patch there was no replay at all, so the broadcast entries for bridge VLANs that existed before the blocking notifier was registered were already missing. Could bridge master objects be let through here, for example by checking netif_is_bridge_master(dev) before the ctx comparison? > switch (obj->id) { > case SWITCHDEV_OBJ_ID_PORT_VLAN: > err = sparx5_handle_port_vlan_add(dev, nb, > @@ -748,6 +781,7 @@ int sparx5_register_notifier_blocks(struct sparx5 *s5) > int err; > > s5->netdevice_nb.notifier_call = sparx5_netdevice_event; > + s5->switchdev_blocking_nb.notifier_call = sparx5_switchdev_blocking_event; > err = register_netdevice_notifier(&s5->netdevice_nb); > if (err) > return err; > @@ -757,7 +791,6 @@ int sparx5_register_notifier_blocks(struct sparx5 *s5) > if (err) > goto err_switchdev_nb; > > - s5->switchdev_blocking_nb.notifier_call = sparx5_switchdev_blocking_event; > err = register_switchdev_blocking_notifier(&s5->switchdev_blocking_nb); > if (err) > goto err_switchdev_blocking_nb; [Severity: High] This bug isn't introduced by this patch, but it sits in the ordering this hunk touches. sparx5_register_notifier_blocks() registers switchdev_nb before it allocates sparx5_owq. In the other direction, sparx5_unregister_notifier_blocks() destroys sparx5_owq before it unregisters switchdev_nb: void sparx5_unregister_notifier_blocks(struct sparx5 *s5) { destroy_workqueue(sparx5_owq); unregister_switchdev_blocking_notifier(&s5->switchdev_blocking_nb); unregister_switchdev_notifier(&s5->switchdev_nb); ... } sparx5_switchdev_event() does not check that the device belongs to sparx5. For SWITCHDEV_FDB_ADD_TO_DEVICE and SWITCHDEV_FDB_DEL_TO_DEVICE it allocates a work item, takes dev_hold(), and calls: static void sparx5_schedule_work(struct work_struct *work) { queue_work(sparx5_owq, work); } br_switchdev_fdb_notify() sends these events for FDB learning and ageing on any bridge in the system, including software-only bridges. During probe, can an FDB event between register_switchdev_notifier() and alloc_ordered_workqueue() call queue_work() with a NULL sparx5_owq? The window includes register_switchdev_blocking_notifier(), which can sleep. mchp_sparx5_probe() has already registered the netdevs by then, so ports can be in use. During remove, can an FDB event between destroy_workqueue() and unregister_switchdev_notifier() queue work on the freed workqueue? That would also leak the work item and the device reference. There is a related gap. The blocking notifier is still registered after the netdevice notifier. If a port joins a bridge inside that window, could objects that are not replayed be missed, such as the PVID VLAN added by nbp_vlan_init()? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203-sparx5-mdb-bridge-leave-v3-1-835c752ef628%40microchip.com