🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27536

Re: [PATCH net v3 3/3] net: dsa: forward a marked frame only while its port is in a bridge

#27536
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 22:44
117 lines
12765 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] In an mv88e6xxx tree that mixes chips with and without a
  cross-chip Port VLAN Table (PVT), a bridge can still be granted TX…

--

net: dsa: forward a marked frame only while its port is in a bridge

This commit changes the tag_dsa, tag_sja1105 and tag_vsc73xx_8021q
taggers to read dp->bridge only once. A new helper,
dsa_xmit_fwd_offload(), lets them build a forward-in-bridge tag only when
the frame is marked and the port is in a bridge with a non-zero number.
This fixes a NULL dereference in br_vlan_enabled() and FORWARD tags for
bridge 0 when a marked frame reaches a port that has left its bridge or
was redirected by tc.

Link: https://lore.kernel.org/all/20261121185821.1471559-1-julius@bairaktaris.de/ [1]

> diff --git a/net/dsa/tag.h b/net/dsa/tag.h
> index 0e1be1da4537e..fd543eb705c2c 100644
> --- a/net/dsa/tag.h
> +++ b/net/dsa/tag.h
> @@ -241,6 +241,20 @@ static inline void dsa_default_offload_fwd_mark(struct sk_buff *skb)
>  	skb->offload_fwd_mark = !!READ_ONCE(dp->bridge);
>  }
>  
> +/* Whether the switch is to forward @skb on behalf of @bridge, the bridge of
> + * the user port as the tagger read it, once. The bridge marks a frame for TX
> + * forwarding offload only on a port whose bridge has a number. A frame can
> + * also carry a mark set before its port left the bridge, or one set on
> + * reception and kept by a redirect; it is then forwarded in a bridge only if
> + * the port is in one that has a number, and otherwise sent to the port the
> + * stack chose.
> + */
> +static inline bool dsa_xmit_fwd_offload(const struct sk_buff *skb,
> +					const struct dsa_bridge *bridge)
> +{
> +	return skb->offload_fwd_mark && bridge && bridge->num;
> +}

[Severity: Medium]

Does mv88e6xxx actually follow the rule in this comment: "The bridge marks
a frame for TX forwarding offload only on a port whose bridge has a
number"?

On any chip with a PVT, mv88e6xxx_port_bridge_join() grants TX forwarding
offload without checking bridge.num:

drivers/net/dsa/mv88e6xxx/chip.c:mv88e6xxx_port_bridge_join() {
    ...
	if (mv88e6xxx_has_pvt(chip)) {
		err = mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge.num);
		if (err)
			goto unlock;

		*tx_fwd_offload = true;
	}
    ...
}

A bridge first joined from a chip without a PVT gets number 0.
mv88e6xxx_setup() never sets ds->max_num_bridges for that chip, so
dsa_bridge_num_get() returns 0. Switches that join later reuse that
dsa_bridge through dsa_tree_bridge_find().

A tree with only PVT chips can hit the same case when last_switch is 31.
max_num_bridges is then MV88E6XXX_MAX_PVT_SWITCHES - last_switch - 1, which
is 0.

When a port on a PVT chip joins such a bridge, dsa_port_bridge_join()
passes tx_fwd_offload = true to switchdev_bridge_port_offload(), and the
bridge sets BR_TX_FWD_OFFLOAD_BIT on the port.

On a flood, nbp_switchdev_frame_mark_tx_fwd_to_hwdom() sets the tree's
hwdom bit in fwd_hwdoms. nbp_switchdev_allowed_egress() then skips every
other port in the same DSA tree. The bridge sends one marked copy and
expects the switch to flood it.

With this patch, dsa_xmit_fwd_offload() returns false for bridge->num == 0,
so dsa_xmit_ll() takes the FROM_CPU branch for that one copy:

	cmd = DSA_CMD_FROM_CPU;
	tag_dev = dp->ds->index;
	tag_port = dp->index;

If so, only this one port receives broadcast, multicast and unknown
unicast traffic from the host or from other bridge ports, such as ARP
requests and IPv6 ND. Would the bridge's other ports in the tree stop
getting these floods altogether?

The commit message says such frames "now go to the one port the bridge
chose", but it does not say that the other ports stop getting floods.

The old behaviour was also wrong. A FORWARD tag with tag_dev = last_switch
is treated by mv88e6xxx_port_vlan() as the physical switch last_switch.

Could this be fixed in mv88e6xxx_port_bridge_join() instead? It could skip
setting *tx_fwd_offload, and skip mapping the virtual bridge into the PVT,
when bridge.num is 0. The bridge would then send one unmarked copy per
port, and the FROM_CPU path in dsa_xmit_ll() would be correct.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204222045.214014-1-julius%40bairaktaris.de
Technical Details
Message-ID: <179651067106.3148.13104164913848720920@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.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-378165-linux-kernel-netdev=dewy.ru
References: <20261204222045.214014-4-julius@bairaktaris.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.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-378165-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v3 3/3] net: dsa: forward a marked frame only while
 its port is in a bridge
Date: Sat, 05 Dec 2026 22:44:31 +0000
Organization: Usenet Network
Message-ID: <179651067106.3148.13104164913848720920@kernel.org>
References: <20261204222045.214014-4-julius@bairaktaris.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3136296"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:OV2O75o/C+NmjLNX0A+X7IYdwEo= sha256:I/nHQiMt77Q4LtIR6wo7bfH5tnIHjWRd1izba9bYqj4=
	sha1:UNiXPYrUpSQXybEey1Dfv3abgRg= sha256:CGto8jiiqp3bE7m9Xtwn9a6mFBc5X/9NVY7qEHQyf8o=
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 0D95F117EDD; Sun,  6 Dec 2026 01:44:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.539
X-Spam-Status: No, score=-3.539 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.14, 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 NQeQ5KIwibv1;
	Sun,  6 Dec 2026 01:44:45 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-378165-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 37719117EC1; Sun,  6 Dec 2026 01:44:35 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id D84832F9D0; Sat,  5 Dec 2026 22:44:33 +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=1796510673;
	b=Qsibf2TYfPdSILXMg5RjxuKJvAZrP2AvC7Kpi1lnFyNExedr31RFG4hyMnq9IoA/sfuo
	 noRRnfRt+DtaMzk291X7BKwpSgM8iVzu/dfazINcW3a/QUV+XWlrZ9V48IdjFoud5QVWB
	 MNRjQ1wiBHl0Gqnj7xM7UHpKYOdbt/0r8jMvtgd5PVzUmz8wPCugaizUFPCO1K8t8CtKf
	 OxfwjPjE+ARQppe7qpUzIAv54ULfXdPArrGyesnW7HW0vAxmQxE/3QHqRwQF0DPBmXD8r
	 FCwyrabVu0C0w5ZJ4sbETP3alqTo5qg9mmXVoSFEyTYvrGkjeY2LfrcYaR++6rMdXgw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796510673;
	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=2XRM77uyGCO5P8f4r4mekmrIaEjTzn9soa3gAPii93k=;
	b=odF+YVHIE1sJI7DGpVNPNGuDxuBx4ZJE7xDUpHORNM201gX61SyQwzVI22Qeewu3Jf+V
	 G5bKLvuFMwIAvb1z0dvfHxLMpPH4+4jxWwdFEdXs6NjIvgg2BorpeG5rG8m112QevExj+
	 IUQGhFX7LvQiFjiU7tlaX1QNuiENA4ne4MQxmCYkuDF8d1BQ9BXfrWqXxlMYqQtJ2tq/5
	 gs+HblCZsLLF+mR5wfKqAsUUZ8XA4Kh+Kx06mqUcuMRm2vxhQbbOVavHNscZt3VojwZO1
	 9N/5Mh3W8Y/JHkNj+fdGcBXWUzg+T0vNvkX5FTgpo8dihbGC37rOnuhJZBvZY6Egyiw==
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=oVE+H96d;
	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 B15FD606A335;
	Sat,  5 Dec 2026 22:44:33 +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=oVE+H96d
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=1796510672;
	b=mUF7Ubjy1t+Fdb1TpNidogomIbQ4BYGigZrdlRl+Z1Y4JMuum9SE2NhjtNFhoi/WOBG4
	 OS6iz9GLHIcboQVm1S5xVUnSReRgj+ecGJPyWDOzvYyNQrazrJMAO8ws6/zc6e6si36qc
	 nak09UVLwhaLK7gR6c2piOIIMfS/no4GzCFYHRm8kWeBNVJTRPYabTpGZuVkrLtMTykCb
	 wGqSIBslA7jBZ+s9n19jpO3BIMp4LJeYELdpJHShlFaXQzjyw2tBFnoK7dMmf6e4C7CBt
	 zsWSluQ5AuMOLFqirA9SxNOyLhBPpQfW+I8JfFHEi4rKH9wVjPAJMLXzsRf2uRp0YrQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796510672;
	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=2XRM77uyGCO5P8f4r4mekmrIaEjTzn9soa3gAPii93k=;
	b=QZfvZmBcXdvawqfUC4UshgxF5X6BNfuZ3yunjBI4WWWMnSuoNwwEUb+qGhtQYc9ZRbVV
	 g8yBvZfN4rfapvXzffur8fN0iWhe623rxqaqALifGPIr6CgQ0Iz4vBpGeHL+KWUSO0Iem
	 hTiLT6O/zJiuL6eIZfKgJYHGDgWAfAwIu1YhXNeizsAZP2xQ08BFVxrO2GLsC/Qm5jiZT
	 KjqujHONl2SZRLK/KV2CiFJ1OXTCQFlJuECXlpiP2FmSSXdagPkBCNq77KS9Ymv7wHmE7
	 Dr21V+Nd3jEFPk1rj6G48b7/z0MuOM6kKIcUifgx3Yse4hqqNepkj0xSPCxuLGGX8Bw==
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=oVE+H96d;
	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 D02DB606A31F;
	Sat,  5 Dec 2026 22:44:32 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 808061F00936;
	Sat,  5 Dec 2026 22:44:31 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796510672;
	bh=2XRM77uyGCO5P8f4r4mekmrIaEjTzn9soa3gAPii93k=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=oVE+H96djF3UmVRaWUw1R+KGeX/rQf5se5fIxqUfPRMJ4BrrHKWa6FGgUWD4wbmKd
	 oDPkgf5bpTG7G4ME44zGis1b1Bjct8SJUIlJrxjIhUdyghq/DQ4WyYJaRtF9koTV7y
	 zO6ocMU0lSDqYSWgVE2Z++mD9CGMq757me+euCytU2eMFFgiTarpfYZyXXYNuBoq0S
	 u+zTFcCbAiYXLv2m7TEPZp28/rPg/29GvFaUZE4JUw5uuk2IcOGJuXPDH706LPwVy4
	 iEC/yKIOmgUmIpZNcCjYf+h5YF9sfUpLtvpnSHxnP+92GmYwt4X1ifSLnAhfdrqYVp
	 zkx117UBTvNQQ==
X-Cc: andrew@lunn.ch, olteanv@gmail.com, netdev@vger.kernel.org,
 bridge@lists.linux.dev, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org,
 razor@blackwall.org, idosch@nvidia.com, alvin.sipraga@analog.com,
 f.fainelli@gmail.com, tobias@waldekranz.com, linusw@kernel.org,
 paweldembicki@gmail.com
X-In-Reply-To: <20261204222045.214014-4-julius@bairaktaris.de>
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