🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26294

Re: [PATCH net-next v3 5/5] net: dsa: motorcomm: Recompute redirect rules on bridge changes

#26294
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 11:15
193 lines
14463 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 2

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 yt921x_acl_recompute_rule()
  (drivers/net/dsa/motorcomm/tc.c), the cached flag…
- [Low] When the isolation step fails part-way,
  yt921x_dsa_port_bridge_leave(), yt921x_dsa_port_bridge_join() and…
- [Low] When isolation is tightened, the new PORTn_ISOLATION registers
  are written first and the affected non-skip_sw redirect rules are…

--

net: dsa: motorcomm: Recompute redirect rules on bridge changes

This commit makes bridge join, bridge leave and BR_ISOLATED or
BR_HAIRPIN_MODE flag changes in the yt921x driver recompute the non-skip_sw
tc redirect rules. Each rule is switched between REDIR and TRAP depending
on whether the new isolation masks still allow the redirect. skip_sw rules
are not changed.

> diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
> index 0bc5da2b80d7a..a5e673a693555 100644
> --- a/drivers/net/dsa/motorcomm/chip.c
> +++ b/drivers/net/dsa/motorcomm/chip.c

[ ... ]

> @@ -1431,6 +1432,14 @@ yt921x_bridge_flags(struct yt921x_priv *priv, int port,
>  			if (res)
>  				return res;
>  		}
> +
> +		res = yt921x_acl_recompute(priv, port);
> +		if (res) {
> +			dev_err(dev,
> +				"Failed to refresh ACL rules for port %d: %i\n",
> +				port, res);
> +			res = 0;
> +		}
>  	}

[Severity: Low]
Is the order of these two steps right when isolation is being tightened?

When BR_ISOLATED is set or BR_HAIRPIN_MODE is cleared,
yt921x_isolation_commit() writes the tighter PORTn_ISOLATION registers for
every bridge port first. Only then does yt921x_acl_recompute() switch the
affected redirect rules from REDIR to TRAP.

The comment at the FLOW_ACTION_REDIRECT case in tc.c says port isolation
is applied after the REDIR decision. So while these SMI/MDIO writes are in
progress, would frames matching a non-skip_sw redirect rule be redirected
into a port that isolation now blocks, and be dropped instead of trapped to
the CPU?

yt921x_dsa_port_bridge_leave() has the same ordering. It writes the
isolation registers in yt921x_userport_standalone() and in
yt921x_isolation_commit(priv, ~0), and recomputes the ACLs afterwards.

The join path looks fine, because it loosens isolation first and un-traps
afterwards.

On the tightening paths, could the rules be trapped first, using the
software isolation_mask values that are already computed, and the
isolation registers committed after that?

[ ... ]

> @@ -1531,7 +1540,19 @@ yt921x_dsa_port_bridge_leave(struct dsa_switch *ds, int port,
>  		return;
>  
>  	mutex_lock(&priv->reg_lock);
> +
>  	res = yt921x_bridge_leave(priv, port);
> +	if (res)
> +		goto end;

[Severity: Low]
If yt921x_bridge_leave() fails part-way, the ACL refresh is skipped. But
yt921x_userport_standalone() may already have tightened isolation in both
software and hardware before a later write fails:

drivers/net/dsa/motorcomm/chip.c:yt921x_userport_standalone() {
    ...
	ctrl = ~dsa_cpu_ports(ds);
	pp->isolation_mask = ctrl;
	res = yt921x_reg_write(priv, YT921X_PORTn_ISOLATION(port), ctrl);
    ...
	res = yt921x_reg_set_bits(priv, YT921X_PORTn_LEARN(port), mask);
	if (res)
		return res;
    ...
}

port_bridge_leave() returns void, so DSA and the bridge treat the port as
gone either way.

Take a non-skip_sw rule whose source is the leaving port and whose
destination is a former bridge peer. Would that rule keep sw_assisting ==
false and keep redirecting into a port that isolation now blocks?

yt921x_bridge_flags() has the same pattern. pre_bridge_flags has already
recalculated isolation_mask, but a failure in yt921x_isolation_commit()
returns before yt921x_acl_recompute() runs.

yt921x_dsa_port_bridge_join() is similar. It does goto end after
yt921x_isolation_calc_bridge() has already changed the software masks.

yt921x_acl_recompute() only reads the software isolation_mask. Could it
still be called on these failure paths, so the rules match the intended
isolation state?

> +
> +	res = yt921x_acl_recompute(priv, port);
> +	if (res) {
> +		dev_err(dev, "Failed to refresh ACL rules for port %d: %i\n",
> +			port, res);
> +		res = 0;
> +	}
> +
> +end:
>  	mutex_unlock(&priv->reg_lock);

[ ... ]

> diff --git a/drivers/net/dsa/motorcomm/tc.c b/drivers/net/dsa/motorcomm/tc.c
> index 9a19ee7d4358a..210f7af3a206a 100644
> --- a/drivers/net/dsa/motorcomm/tc.c
> +++ b/drivers/net/dsa/motorcomm/tc.c

[ ... ]

> +static int
> +yt921x_acl_recompute_rule(struct yt921x_priv *priv, int port,
> +			  unsigned int entid)
> +{

[ ... ]

> +	assisting = false;
> +	for_each_set_bit(o, &srcs, YT921X_PORT_NUM)
> +		if (dsts & priv->ports[o].isolation_mask) {
> +			assisting = true;
> +			break;
> +		}
> +
> +	if (aclrule->sw_assisting != assisting) {
> +		aclrule->sw_assisting = assisting;
> +		res = yt921x_acl_commit(priv, entid, aclrule->mask);
> +		if (res)
> +			return res;
> +	}

[Severity: Medium]
What happens if yt921x_acl_commit() fails here? sw_assisting has already
been updated, but the hardware ACT entry has not.

Wouldn't every later recompute then see sw_assisting == assisting and skip
the commit? The hardware would stay out of sync until the rule is deleted
or the isolation state flips twice.

In the REDIR to TRAP direction, the rule would keep redirecting into a port
that is now isolated, so its frames are dropped.

Two other things make this harder to recover from. The walk in
yt921x_acl_recompute() stops at the first failing rule:

> +			res = yt921x_acl_recompute_rule(priv, port, entid);
> +			if (res)
> +				return res;

so the remaining redirect rules for this port are never refreshed. Also,
yt921x_bridge_flags(), yt921x_dsa_port_bridge_leave() and
yt921x_dsa_port_bridge_join() all log the error, set res = 0 and carry on,
so nothing retries.

Could sw_assisting be set only after the commit succeeds, or be restored on
failure? And could yt921x_acl_recompute() keep going through the remaining
rules and return the first error at the end?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201081459.2104904-1-mmyangfl%40gmail.com
Technical Details
Message-ID: <179629654388.3146.17104538294961493197@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376512-linux-kernel-netdev=dewy.ru
References: <20261201081459.2104904-6-mmyangfl@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376512-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v3 5/5] net: dsa: motorcomm: Recompute redirect
 rules on bridge changes
Date: Thu, 03 Dec 2026 11:15:43 +0000
Organization: Usenet Network
Message-ID: <179629654388.3146.17104538294961493197@kernel.org>
References: <20261201081459.2104904-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="2469981"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:FLKYAfuLKZybzIA//iWTl6xUhMk= sha256:x76z0+VOt7MXBJlNoAnQQS963+SQEjX/TewWgCN5RwE=
	sha1:u8AZm9N69N6okQjTNZHBcVIMzMU= sha256:z5hD9a5BbPn2g9UcLUyZ+GS1yXcQ12iFnR37HwsEfgo=
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 A41101178EC; Thu,  3 Dec 2026 14:16:02 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.74
X-Spam-Status: No, score=-3.74 tagged_above=-9999 required=6.31
	tests=[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]
	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 vVMnXAx4GYpQ;
	Thu,  3 Dec 2026 14:15:59 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-376512-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 6A51C1178E4; Thu,  3 Dec 2026 14:15:51 +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 A115F602F4B; Thu,  3 Dec 2026 11:15: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=1796296546;
	b=CV4oZsFk7KmdOETiQO/k6szZXfXJ7YP42yM2enlt5ZqHeh0CKuS/J2diGmBDCPk54Jgh
	 mFRwO8b9KkVreJhYeti+rVVRwunnruIiul5IBNzCTcKTulASFhyIRhGcP+QGVqCWF2gdO
	 c1fUeDoGC4Km2b4YlUeSHHhb47IkyZkY0cmHT4nsCCzSmO+taXnBMWd8xEUueaFtMdCkM
	 RfoRXFY4tyZyjlM+MrRYJ72n9VzuFsMyVFcEDtn+iSGGkpOu1CkCjHY18Bd8V1OTn0H++
	 CnZFJjaJo4dcGVkjhs9Dydmln6/lQhH71mz1ufb+oCuDcd1dkzA6E1SSVdMtt6ypwSg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796296546;
	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=3eL7Ie/b+RIu9OJVxa/tN18p5tNMzq+F+UVQxxkCkIk=;
	b=NckdhsrLhRJ/9XBLPTlOf1g37F5LVVBoKGGXzRdEqvJdM0AAM4Zs09f9qQcGWv+DAKOu
	 10OPiQ+m4B5JOp2cmeXO3XihYkbBI3EzUeNiqyH1rBC3NRaL7DhgsVjUTxmMSRv2QHB9O
	 tXqo+eU61bT9GRsh3zqpCn2YRIUzqAfKamJfxvM006nbaT11HMKsyOKzniLdpjolZLCtI
	 vAqW7E3ZcNx56Mu4X9ME2sn8mfzt6/otFPN2qgkWgN0rlVPL5qlpqcKfUGvC6a2CoyACq
	 Y4IteQi+v4HzrBJ2zXr+sZ6n76grsiK5FCfLeuhKfdenngwez2Fa6Njmz5vcfift8/Q==
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=MvFrMqip;
	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 11886606A339;
	Thu,  3 Dec 2026 11:15:46 +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=MvFrMqip
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=1796296545;
	b=DVlCrm1u4G2UrQKKvTkHQFQeMn0CZwgmBFUhkjHZoIECDzFKZBB1f0yDDg0Dk+pci420
	 s1BYHmbL2qL4CCDPV6hekmzZuW71fcbpPLc8yVD5Ri54SRV/mNzdmbZaKPquWX7ny3zwO
	 KzzUO0WjcXi8wvFaGRhF+QDboh/sehTWp87PSDAOLcE/M/YlK2HNlvEZQEZJ3yM+itObV
	 H4wskTouVpITx0CN4OIEscSMkYbNXw9KRJWB2lFKfgJSQkEX6Y+xCVrOgp3pHeUuSPB8s
	 rSwDpmDJtCFjZAgQg3dD4O5Ty0dunIMcbC90/9STPFwIctOziA59hPK3rBNYZ/iM4Yw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796296545;
	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=3eL7Ie/b+RIu9OJVxa/tN18p5tNMzq+F+UVQxxkCkIk=;
	b=tmassQetTqbSQlFy3oEJGpEf6Q869A7oPjUn5dV2KjHjT6D/OM+pFE1IbWPd/lep46c1
	 wPGjE2oNzpWXNOY0uvhFIdzXW2YfSw8VTVORZ7Bjj56mFqXF/LvAAA9QFYRuC+Wz52niU
	 ujjHVchb0rzuC4t+dn+xU0afEl6iMLdzvoSXHC6dM9BtlNF4cod0Wd6B2fq7rg9C7J3us
	 Y3WI/RZALMMilscXendY6pDVe+6iL2IZsUcloHB7od+lx18mwXACzrtCEzVkRQopQ9Aui
	 pABsRtLBWli8YAyy1vDZ+Rzu1Pt9p8Vtm/e4RzNU0m7n6wUKDBvVIIdsKSs/DNaQlVw==
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=MvFrMqip;
	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 330C8606A333
	for <netdev@vger.kernel.org>; Thu,  3 Dec 2026 11:15:44 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54EC51F008A0;
	Thu,  3 Dec 2026 11:15:44 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796296544;
	bh=3eL7Ie/b+RIu9OJVxa/tN18p5tNMzq+F+UVQxxkCkIk=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=MvFrMqipSnc1QusbAqgzvYMWXpXAzV0M01ecg7NRJ+vIvcTqOW+gShrjcehwLlu+G
	 zud5IS1CUdh5duhBDQGGeknIo5dT3bnAC1XHpafHKDpEkOpNwj8Uw9Jb3i2x3NXFy9
	 cQaBeaxEFqLooRB5Md/RJPetPfB2vkI71Mbz+EkfqFda5tOWWo6mLGUm2Aet6G2dVB
	 k9mNa8Q1FX3eE1MbeM18MFKwKnlCUhwFuaukJrBfGIMPJNXDeBjrqtiuIiQtlooQIZ
	 oJG1TxeUjD97F36gvm+hAos52OcNvbERVhUX+XpDdm+47km87uzJfiPa7QpNRvPcbz
	 ZsniDLapMBz6g==
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: <20261201081459.2104904-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