🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27340

Re: [PATCH net-next v4 5/6] net: dsa: motorcomm: Reject bridge flags that break redirect rules

#27340
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 11:00
132 lines
12153 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] yt921x_dsa_port_pre_bridge_flags()
  (drivers/net/dsa/motorcomm/chip.c) does not veto BR_ISOLATED when the…

--

net: dsa: motorcomm: Reject bridge flags that break redirect rules

This commit adds per-port acl_dst_cnts bookkeeping in yt921x_acl_add() and
yt921x_acl_del() for redirect rules that are not sw_assisted. It then uses
those counters in yt921x_dsa_port_pre_bridge_flags() to reject turning off
hairpin mode, or turning on BR_ISOLATED, when the change would block such a
rule.

> diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
> index a71a8dd5dc63c..323c1705f613c 100644
> --- a/drivers/net/dsa/motorcomm/chip.c
> +++ b/drivers/net/dsa/motorcomm/chip.c
> @@ -1525,9 +1525,52 @@ yt921x_dsa_port_pre_bridge_flags(struct dsa_switch *ds, int port,

[ ... ]

> +	if ((flags.mask & BR_ISOLATED) && (flags.val & BR_ISOLATED)) {
> +		struct dsa_port *other_dp;
> +
> +		dsa_switch_for_each_user_port(other_dp, ds) {
> +			struct net_device *other_brport;
> +			int i = other_dp->index;
> +
> +			if (i == port || !(ports_mask & BIT(i)))
> +				continue;
> +			if (!pp->acl_dst_cnts[i] &&
> +			    !priv->ports[i].acl_dst_cnts[port])
> +				continue;
> +
> +			other_brport = dsa_port_to_bridge_port(other_dp);
> +			if (!br_port_flag_is_set(other_brport, BR_ISOLATED))
> +				continue;

[Severity: Medium]
Can this check be bypassed when both ends of a skip_sw redirect rule are
members of the same offloaded LAG?

The port being changed gets its new isolation state from flags.val. The
peer's state is read back from the bridge. For LAG members,
dsa_port_to_bridge_port() returns the shared LAG netdev:

include/net/dsa.h:dsa_port_to_bridge_port() {
    ...
	if (dp->lag)
		return dp->lag->dev;
    ...
}

The bridge sends PRE_BRIDGE_FLAGS before it writes the new value into
p->flags. This happens on both the netlink path and the sysfs path:

net/bridge/br_netlink.c:br_setport() {
    ...
	err = br_switchdev_set_port_flag(p, flags, changed_mask, extack);
    ...
	} while (!try_cmpxchg(&p->flags, &old_flags, flags));
    ...
}

net/bridge/br_sysfs_if.c:store_flag() {
    ...
	err = br_switchdev_set_port_flag(p, flags, BIT(bitnr), &extack);
    ...
	assign_bit(bitnr, &p->flags, v);
    ...
}

So when the LAG bridge port itself is being isolated, each member sees its
LAG peer as not yet isolated and hits the continue above.

Here is an example. Ports P and Q are in one offloaded LAG, bond0, and bond0
is a bridge port:

  skip_sw flower redirect rule from P to Q
    -> P's acl_dst_cnts[Q] is incremented

  bridge link set dev bond0 isolated on
    -> pre_bridge_flags(P) and pre_bridge_flags(Q) both return 0
    -> .port_bridge_flags
       -> yt921x_isolation_refresh()
          -> yt921x_isolation_calc_bridge()

When yt921x_isolation_calc_bridge() runs, bond0 now reads as isolated:

	if (br_port_flag_is_set(brport, BR_ISOLATED))
		isolated_mask |= BIT(port);

That gives isolated_mask = BIT(P) | BIT(Q). Q's bit then lands in P's
isolation mask, and the hardware drops the P->Q redirect even though the
rule was accepted as skip_sw.

Isn't this the case the commit message says should be rejected?

The later patch in the series ("net: dsa: motorcomm: Recompute redirect
rules on bridge changes") does not change yt921x_dsa_port_pre_bridge_flags(),
so this still seems to apply at the end of the series.

The new warning that patch adds in yt921x_bridge_flags() would not reach
the user here either, because the deferred switchdev attr path passes a
NULL extack.

> +
> +			NL_SET_ERR_MSG_MOD(extack,
> +					   "Cannot isolate port while there are redirect rules");
> +			return -EINVAL;
> +		}
> +	}
> +
>  	return 0;
>  }

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204101300.3680838-1-mmyangfl%40gmail.com
Technical Details
Message-ID: <179646844578.3146.6159172839639383786@kernel.org>
Path: mbox-mo1.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-377942-linux-kernel-netdev=dewy.ru
References: <20261204101300.3680838-6-mmyangfl@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.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-377942-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v4 5/6] net: dsa: motorcomm: Reject bridge flags
 that break redirect rules
Date: Sat, 05 Dec 2026 11:00:45 +0000
Organization: Usenet Network
Message-ID: <179646844578.3146.6159172839639383786@kernel.org>
References: <20261204101300.3680838-6-mmyangfl@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3011806"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:vzX7XLXAe6m2isM8NAmTMIN3waA= sha256:tEgd1/FiXEhHKqK4naEfupBYRetce7SJ/EO/8PKIDwk=
	sha1:I+n0Figeqmguv1uf7mAT5hQ4Zi0= sha256:Jhj2wIkAKPzWJ+tTPuDXYA3QiPm58HhJIfviFRC82lQ=
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 69670117BCE; Sat,  5 Dec 2026 14:01:04 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.641
X-Spam-Status: No, score=-3.641 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.142, 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 eRsBwqI0p5v0;
	Sat,  5 Dec 2026 14:01:01 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-377942-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id EC10B117DEF; Sat,  5 Dec 2026 14:00:52 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 412FC2A192; Sat,  5 Dec 2026 11:00:50 +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=1796468448;
	b=5r19VX3vV4s/dBaPOX+usMcV91Ic9QasPFJvsJ9Si6DquPsz4MmvwGGfWQonDsyQx2Sr
	 sBIF2EQ6sQuXYH9QWHQcYEXLrRdIt6RMUd2g/nJbzPwT+gdq+6kheGvsQ69vysMdJdXpo
	 WZdKMJP8r/NDCOAlM//dXtGbRHNgD77BaHDpV4jMid6fL7A85nn/s8cPED4GJJemYbfHH
	 NQEac4NuTZwPjEyB/vPO+1XOAA48tlGvfVQFu1LTviHbrf+DSbGX6xMFoLya3mBNNGwWI
	 rK72rn/dTdZMTZogQqg2/WpeKB5DARDrFQIkyCBqZwNNjYvTDd7MY+cZF0+KHDNti2g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796468448;
	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=RkbPkhVynH3qFUsNBq10Ts0AY26RpK2gbe9Mb5cPm70=;
	b=WrYxaUkOakDTEj0TlbXnOReDKTOEHxMTdOkdZKXoHwSnSAKSE6h02Lvlgf+mHmD3jZvw
	 mzZZ79wmxpiTOSf75/w7u4lCvqwh+IABQiCAIOsQMl4wSRAt6dHhwDo58yK6eOQ1GlyOI
	 pg//C4veoFNkYVgqdSF2ptJYyWH81PndpPq3I7gbSldwNZspJ+Kkqv0cvnZlGc+Lk5DaL
	 RzNHf0xmJALaSj0oMxvZyExdhE5qS/5bb1XmL62chR5HwHd6cqFweRFf9XGpzJcE3kEBu
	 6oAfFC2ZyY+3ENK5SeKC/SEifUFnSGXSszP9016JMyMlNyokqDwsI2SWA8OUNa5w1ng==
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=AohjUOmI;
	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 DEE1B606A680;
	Sat,  5 Dec 2026 11:00:47 +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=AohjUOmI
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=1796468447;
	b=Dfe9zQJblPMdatrGWVUsXnt/7u3Eb5l6RBdE3/eFsIOjrO5nDgBQ4y1qpzOm3pvkfXJ1
	 8C5LbGVGaprdxUuBfotHqZVvaFwpk9tz1kdcBEz+uFh3PgMfKyBwkDzXc7RnYCgbl3clK
	 g8fIi5f6vL2B5QJUKC2tX0cP4vDk/kkdMMM+/Zn+sbf8FSQGKCf9ufDShcDrCY9cBmQyF
	 ZL14e/xZtZhWqTOAqBNjL9h07nhiLq7h2/yy1ZvpJFqTONAwcEiV31EkJVUNYJhV70bTE
	 LmhUJo+XiXzLyKZcNK6oQkPyBpQs54TbyHjk3wmpct1DglWBXedr5BWZlX+JnP6tOZQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796468447;
	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=RkbPkhVynH3qFUsNBq10Ts0AY26RpK2gbe9Mb5cPm70=;
	b=aX+UWS3CHqy5DdIQHXHO003gCdweY+AIngZ+J7ZCujaHh2KC6iKGpFG0LYvoEnx24GqN
	 SwrkcyrKnSrzEqDzgTpO8WKOV3qgGvIWOT6odYhR+nc1RUwx1iZjQyCtxcrzPy+leHH9g
	 W/jE5bN3kwS2kviujToq3KxZJG/ZcvjJZj3r1FMzZAsRr3m6E84DhttBNZ+j1AZAWMdKd
	 GzZfL4nYPf2f3ty35w0M/NxiTXDdl7Dn2eWgs0AHoPd29TZ2aLG/wGrXwV7XcVWVkep7M
	 +0PhkETUc8/KT3PBHXNe1Yo8lTPCysoq3PmHPb9h9niBF+rh5IWtcCVBZ9AIzV5A3nA==
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=AohjUOmI;
	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 09B1D606A338
	for <netdev@vger.kernel.org>; Sat,  5 Dec 2026 11:00:46 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C6911F0092B;
	Sat,  5 Dec 2026 11:00:46 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796468446;
	bh=RkbPkhVynH3qFUsNBq10Ts0AY26RpK2gbe9Mb5cPm70=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=AohjUOmICY1cj+yBJnGLKPxTulq2NP9jcTOFWO6OwgVMtrz7jfs4h1kkzegymKOo6
	 M4gWRytzHd88gKV8hWSJ1wKqbPy7tj8IrO/5vz5UeumuUM6KEb/+no7bXBMdxbbRPW
	 JcRzJ2GYcBbttOeqY2nMGlOkLnJNQqd0uLH7rMyrpWovUqryg2mKb+KoQ9K11oAAKY
	 8pr+In4vpT+3q68plZEoD00hhQmb2qxispTDN+wtgtdvyuqnMUSFpbUN+ztbxML6ts
	 Id/dRokQfqRlFlv1pALLCounhUPetzpvE2UODVpAjPct+ogs7WN29A4gICmOa8rh3t
	 3od45sowGpdgQ==
X-Cc: netdev@vger.kernel.org, andrew@lunn.ch, olteanv@gmail.com,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com
X-In-Reply-To: <20261204101300.3680838-6-mmyangfl@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