๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26629

Re: [PATCH net v2 1/2] net: bridge: switchdev: count an offload only after its hwdom is set

#26629
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 00:27
112 lines
12026 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 0 ยท Medium: 1 ยท 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).

- [Medium] On rocker, this patch adds a WARN that userspace can trigger,
  and no patch in the series fixes it.

--

net: bridge: switchdev: count an offload only after its hwdom is set

This patch moves the setting of p->offload_count in nbp_switchdev_add()
so it happens after nbp_switchdev_hwdom_set() succeeds. Before, a port
whose offload failed with -EBUSY kept a count for an offload that never
happened.

> diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
> index 10f3aea6a1f82..8de12d56452dc 100644
> --- a/net/bridge/br_switchdev.c
> +++ b/net/bridge/br_switchdev.c
> @@ -280,12 +280,13 @@ static int nbp_switchdev_add(struct net_bridge_port *p,
>  	}
>  
>  	p->ppid = ppid;
> -	p->offload_count = 1;
>  
>  	err = nbp_switchdev_hwdom_set(p);
>  	if (err)
>  		return err;
>  
> +	p->offload_count = 1;
> +

[Severity: Medium]
Can this make userspace able to trigger the WARN_ON() in
nbp_switchdev_del() on rocker ports? The changelog says so itself:

  "With this patch, that unoffload hits the WARN_ON() in
  nbp_switchdev_del()."

Neither this patch nor the next one in the series seems to address it.

rocker_netdevice_event() only logs the offload failure and returns
NOTIFY_DONE:

drivers/net/ethernet/rocker/rocker_main.c:rocker_netdevice_event() {
    ...
			if (err)
				netdev_warn(dev, "failed to reflect master linked (err %d)\n",
					    err);
    ...
}

So br_add_if() never sees the error and keeps the port in the bridge.

Also, ofdpa_port_bridge_join() sets ofdpa_port->bridge_dev = bridge
before it calls switchdev_bridge_port_offload(). It does not clear it
when the offload fails, so ofdpa_port_is_bridged() is still true when
the port is unlinked later.

When the port leaves the bridge, the call chain is:

del_nbp()
  netdev_upper_dev_unlink()
    rocker_netdevice_event()
      ofdpa_port_master_unlinked()
        ofdpa_port_bridge_leave()
          switchdev_bridge_port_unoffload(dev, NULL, NULL, NULL)
            br_switchdev_blocking_event()
              br_switchdev_port_unoffload()
                nbp_switchdev_del()
                  if (WARN_ON(!p->offload_count))

Before this patch, the failed offload left offload_count at 1, so this
unoffload was balanced. It now runs with offload_count == 0 and fires
the WARN, which panics with panic_on_warn.

The -EBUSY case can be reached on the current tree. A CAP_NET_ADMIN
user fills hwdoms 1..BR_HWDOM_MAX-1 with ports from other switches,
then adds a rocker port from a new switch. While br_add_if() runs, that
port is not yet in br->port_list, so nbp_switchdev_hwdom_set() returns
-EBUSY.

The follow-up patch "net: bridge: switchdev: clear the hwdom of a port
that stops the offload" leaves both rocker and the WARN_ON() in
nbp_switchdev_del() as they are. The WARN is therefore still reachable
at the end of the series.

DSA does not have this problem. dsa_port_bridge_join() calls
dsa_port_bridge_destroy() when the offload fails, and
dsa_port_pre_bridge_leave() returns early when there is no brport_dev.

Should rocker be fixed in the same series? One option is to return
the error with notifier_from_errno() so br_add_if() unwinds. Another
is to record whether the offload succeeded, and skip
switchdev_bridge_port_unoffload() in ofdpa_port_bridge_leave() when it
did not.

>  	if (tx_fwd_offload) {
>  		set_bit(BR_TX_FWD_OFFLOAD_BIT, &p->flags);
>  		static_branch_inc(&br_switchdev_tx_fwd_offload);

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203002451.517879-1-koralilgun%40gmail.com
Technical Details
Message-ID: <179634406142.3146.16588048091797797302@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376934-linux-kernel-netdev=dewy.ru
References: <20261203002451.517879-2-koralilgun@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376934-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 1/2] net: bridge: switchdev: count an offload only
 after its hwdom is set
Date: Fri, 04 Dec 2026 00:27:41 +0000
Organization: Usenet Network
Message-ID: <179634406142.3146.16588048091797797302@kernel.org>
References: <20261203002451.517879-2-koralilgun@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2639010"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:P1t1+Y4dREhkND4apYNqMZlth5U= sha256:RgBDdQqSCsMxLPr8YfutRUjHGGvCfzFSYUCf9JLRV8Q=
	sha1:wfOruxEEFxMH8UwnFfJYylTF+mY= sha256:6gBbN94ZNBhfthmVdJyUssP2S1qmLOGSss6kizQSwGY=
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 959C3117A87; Fri,  4 Dec 2026 03:28:02 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.639
X-Spam-Status: No, score=-3.639 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, 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 ffMn3LviCZSI;
	Fri,  4 Dec 2026 03:27:59 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-376934-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 4826B117A7F; Fri,  4 Dec 2026 03:27:50 +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 CDC5920C52; Fri,  4 Dec 2026 00:27:44 +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=1796344064;
	b=YgI+KaT3NmwTYQMYtwHD8+BIMZHU8pgHWML3Z7vOkO9l0AjECV9KmLa9Wvj9V8vHxVUP
	 rWGZg4RLn9GHKkTIw2ZWqgoRKVAnBGrHoxoUxuuA8LV0m+46mm2ywBOeix0MH9B2d7qXj
	 4Gms7WWhtJbU6eWSbNWBr2YLgPbQ41s7ayFmAiA+Rm4Ojr9lZyfB1IyT+05sq5GYVcMgq
	 mnBBkhGmPddjYMeV2fXk2eqVn/0KbQ5en6j+r+dzi785scjcnXjDz0eBylCfEoePxe5Ej
	 kRGv5v9wJzNr+Fmk7hwfqHKYwgQr0Pv6iywNHUVmzP0TsiFRUjtEdZgEdQb/N283vLg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796344064;
	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=l25MkAs36+LDUtjo3aTSduVWvfR2CAQiaTz2bEZ2Mok=;
	b=lXIe9kEnkb3QLMuMgUw0kaTJaQw/o9yDSnaE4Dq/qHVESmY4pPlqSJOGkQnxoHAHAsFp
	 z6u+GY4QqjRVL1XOGAeRFUydrLJsrwFJEl6RuQqoAanNJ2w+84SB9/9dNMzmL6mT8B4rV
	 OJ0ziKurbZDeVCXhO7bM//Gj5Kecp9AyB9857NYEmqTQE3tm7xziGACLbu/uf1V1+E22u
	 SPc+4tFwpB+dfrQWHZnunvss6ZA3kCeVXNZDMoZhUUIo+/AtHYYNrZB9vjX6RqRRZmKZM
	 9SQRKbVh6InqbG+vheciCTzzpFd8gf+Xl32IZc/HucUcg+oNNKF54JEnfQCM+dSBRwQ==
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=G1hj1jfQ;
	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 0807B606A336;
	Fri,  4 Dec 2026 00:27:44 +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=G1hj1jfQ
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=1796344063;
	b=xvpe7TcZfg1jDEsF0TLs2pWGQwrR9zAy2V1C5YBblWHuok46uIIU/6qgQlfqlxve4IrM
	 qjbjNvkUNQeAUBKdKOm0ZBhODz0F2QO65FsZZTGBuH62yfpZs8xRqbxx25ENlMycHs7Ma
	 T6vzCXPda8TbFGHaZt41PJpb+wjWdztHyCgu2s3xHZQNrE4PqGey1AIeByoShjfMsBRTk
	 4FRYQgmgAL2BlT0i4YP7ehizT9fP5vj1VKdHfEa8dWJnXXk5G1Tio5ehjpsTig3Yc3rNQ
	 LnLj0YLsWmsMwV8Rl6JvucG7RUFFpFQEByk10vgh6pd0um324UacULo/srlrooW/ulw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796344063;
	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=l25MkAs36+LDUtjo3aTSduVWvfR2CAQiaTz2bEZ2Mok=;
	b=z81+N7dlWUmwzDsd+dkG44H/czDR/odzytF4VgDDA/zxRuClVUA8MyacACbGVdliEh+F
	 56JwwgxQlBs7ktTDcVtvcJfyLMtepIsQkHX0cG2ZKzgr9XctIaI7UOiF9rDpRKkzctrdJ
	 Q+NAXl/dONJeVPgqO8exzL3O+S6uYmMvtFKK7WtnQ7SFS7XlRAgyA4OWunERC6HcluZMU
	 5heQ5XY0hdbEbeApvApZsrkskVJ0QdWfeeBpoUx1xvRkvQnCSt6CkfYn01xd28tF9lN6J
	 HMFmsl3kvAVpBXaAuwIGzQ6sZq6NqF2E/BZ31jWHdNlXg4JcQSL7HZCdyFCOHxcwKIw==
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=G1hj1jfQ;
	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 23E44606A322;
	Fri,  4 Dec 2026 00:27:42 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id D55BA1F00897;
	Fri,  4 Dec 2026 00:27:41 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796344062;
	bh=l25MkAs36+LDUtjo3aTSduVWvfR2CAQiaTz2bEZ2Mok=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=G1hj1jfQbHCYROVEJ2HJt4FEcs4z+edbqvi2tWliiVIc87oB/gdSwdB/rbCqHQ7YK
	 9o4rU8e57Q4UveXsrvUdoNn1ed0inoy08dghEV8j2lZZ54HBojauoBjzDZYccwmgnS
	 JtsUZBL6fwUg0FLPQxzyk/HFSC9yYnZLL7yWWL9NOzsckutYyHSOMgELiu3fKbUku4
	 l8xUzWll/2wKN9z78Kh5/Y3BEuZtJc1Hteg4RuIa2EzGgL9KaA/bbIthhkc26I0QVU
	 TqGmKP7oNdv4kiAqfmxSzk+irvB7ChKaSWkYbVU6KSxtnpXxtanwUms6Zm57SIE7Mg
	 kmh1lGTH7yg9A==
X-Cc: razor@blackwall.org, idosch@nvidia.com, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com,
 horms@kernel.org, vladimir.oltean@nxp.com, ioana.ciornei@nxp.com,
 andrew@lunn.ch, jiri@resnulli.us, daniel.machon@microchip.com,
 bridge@lists.linux.dev, netdev@vger.kernel.org, koral.ilgun@adtran.com
X-In-Reply-To: <20261203002451.517879-2-koralilgun@gmail.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