Article View: linux.kernel.netdev
Article #24604Re: [PATCH net-next v2 4/5] net: dsa: motorcomm: Recompute redirect rules on bridge changes
From: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 12:25
Date: Mon, 30 Nov 2026 12:25
124 lines
12738 bytes
12738 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 ยท High: 1 ยท Medium: 0 ยท Low: 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).
- [High] yt921x_acl_recompute() in drivers/net/dsa/motorcomm/tc.c gets
the rule's source port wrong.
- [Low] net: dsa: motorcomm: redundant ACL commits in
yt921x_acl_recompute()
--
net: dsa: motorcomm: Recompute redirect rules on bridge changes
This adds yt921x_acl_recompute(), which re-evaluates non-skip_sw redirect
rules after bridge join, leave and flag changes rewrite the port isolation
masks. It is called from yt921x_bridge_flags(),
yt921x_dsa_port_bridge_join() and yt921x_dsa_port_bridge_leave().
> diff --git a/drivers/net/dsa/motorcomm/tc.c b/drivers/net/dsa/motorcomm/tc.c
> index 20edfd53b230d..146db2a37c268 100644
> --- a/drivers/net/dsa/motorcomm/tc.c
> +++ b/drivers/net/dsa/motorcomm/tc.c
> @@ -1394,6 +1394,56 @@ yt921x_acl_commit(struct yt921x_priv *priv, unsigned int entid, u8 entsmask)
[ ... ]
> +int yt921x_acl_recompute(struct yt921x_priv *priv, int port)
> +{
[ ... ]
> + src = ffs(aclrule->entries[0].key[1] &
> + YT921X_ACL_KEYb_SPORTS_M) - 1;
> + dsts = FIELD_GET(YT921X_ACL_ACTc_FWD_REDIR_DPORTS_M,
> + action[2]);
> + if (src != port && !(dsts & BIT(port)))
> + continue;
> +
> + aclrule->sw_assisting =
> + !!(dsts & priv->ports[src].isolation_mask);
^^^^^^^^^^^^^^^^^
[Severity: High]
Can this read past the end of priv->ports[]? The source port field is not
shifted down before ffs(), and tc.h has:
#define YT921X_ACL_KEYb_SPORTS_M GENMASK(20, 10)
#define YT921X_ACL_KEYb_SPORTn(port) BIT((port) + 10)
So a rule on port p gives src = p + 10. For p >= 1 that is 11..20, but
ports[] only has YT921X_PORT_NUM (11) entries. For p == 0 it reads the
isolation_mask of port 10 instead.
The other decoders of this field, yt921x_acl_find(), yt921x_acl_add() and
yt921x_acl_del(), all use FIELD_GET(YT921X_ACL_KEYb_SPORTS_M, ...). Should
this be something like:
src = ffs(FIELD_GET(YT921X_ACL_KEYb_SPORTS_M,
aclrule->entries[0].key[1])) - 1;
The same offset also breaks the filter above. Because src != port is
almost always true, rules sourced on the port whose bridge state changed
are skipped unless they also redirect to that port.
As an example, take a non-skip_sw flower rule on port 1 that redirects to
port 2. A bridge join or leave on port 2, or a BR_ISOLATED or
BR_HAIRPIN_MODE change there, calls yt921x_acl_recompute(priv, 2). The
rule passes the dsts & BIT(2) check, and priv->ports[11] is read. That
value then decides whether yt921x_acl_commit() writes a REDIR or a TRAP
action to YT921X_ACLn_ACT.
The later patch in this series, "net: dsa: motorcomm: Reject bridge flags
that break redirect rules", does not touch yt921x_acl_recompute(), so the
problem is still there at the end of the series.
> + entid = YT921X_ACL_ENT_PER_BLK * blkid + i;
> + res = yt921x_acl_commit(priv, entid, aclrule->mask);
> + if (res)
> + return res;
> + }
> + }
> +
> + return 0;
> +}
[Severity: Low]
This calls yt921x_acl_commit() for every rule that passes the filter,
whether or not the newly computed sw_assisting value differs from the
one already programmed. Each commit rewrites the 96-bit action, the key
and mask of every entry in the rule, and the block KEEP, ENTRY and CMD
registers. All of that goes over MDIO while reg_lock is held in the
bridge join, leave and flags paths.
FLOW_ACTION_DROP rules also get past the action check here.
yt921x_acl_rule_ext_parse_flow_action() encodes them as
YT921X_ACL_ACTc_FWD_EN | YT921X_ACL_ACTc_FWD_REDIR with an empty DPORTS
field. For those rules dsts is 0, so sw_assisting always comes out false
and the commit just writes back the action that is already there. Once
src is decoded correctly, every non-skip_sw drop rule sourced on the
port would be reprogrammed on each bridge change. The same applies to
redirect rules whose destinations are not affected by the isolation
change.
Nothing breaks functionally, but would it make sense to skip rules with
dsts == 0? yt921x_acl_commit() could also be called only when
sw_assisting actually flips, for example by computing the new value into
a local, comparing it with aclrule->sw_assisting and continuing if they
match.
Or is the unconditional rewrite intended to resync the hardware after
an earlier failed commit? sw_assisting is updated before
yt921x_acl_commit() runs, so after a failure the software state and the
hardware can disagree.
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129115556.1669188-1-mmyangfl%40gmail.com
Technical Details
Message-ID:
<179604155661.3146.6089853869175513173@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374167-linux-kernel-netdev=dewy.ruReferences:
<20261129115556.1669188-5-mmyangfl@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374167-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v2 4/5] net: dsa: motorcomm: Recompute redirect rules on bridge changes Date: Mon, 30 Nov 2026 12:25:56 +0000 Organization: Usenet Network Message-ID: <179604155661.3146.6089853869175513173@kernel.org> References: <20261129115556.1669188-5-mmyangfl@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1423023"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:65VAYIhuMOktWp4+H/tVh6KxXCA= sha256:Uz8vZ49NdF8N6Z8pe5KXvB/yUpp7uR8pw9kwKkujVBY= sha1:sOEbAENiVKLfNmKSdk7N7zcmRsQ= sha256:MQHc8DcOJABAEgs1TixhpHvT2j1rTKaLORRwUT95xtI= 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 772B7125FDE; Mon, 30 Nov 2026 15:26:13 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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 Rk8DlOX2x7hS; Mon, 30 Nov 2026 15:26:09 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-374167-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 70A33125FE1; Mon, 30 Nov 2026 15:26:00 +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 2C219259E0; Mon, 30 Nov 2026 12:25:59 +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=1796041558; b=GJlB3JNfJNLX0V+5kXmdMlf6PkV/TzCyA8ZOGB7Fmnx5sNPj0gWsuf9PuQPh9kaw9nzK qDabk1d3NG4pbVdJtpIAZMnSoLpjTSgpi+V2oNjLZHgHm2UHZk4YVpLHgCj83+gyiLNbn Y5rH/ZCY5i6VzHNthLLpo6CuduYidE4SoztT/XZxqjgMrYg/CaQaTRwqB+uSKLkc4M7jr z4WglCbZATisqkCoohnCGpHG03KkKK8Zd3BCBAvKbKqI2ZQsrvj4ISWk7ih86MajAtuvW GWjVNVrabiSV6aGcFtPccVr0IHqTQTgY9RVJt1cpafgZ/4Afn1CyNH+UM8KckrLqqLg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796041558; 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=lyncOSeYB5OV68nVCZT1DFdFt/lpUnWWqVx1WQcVv1Q=; b=SGLO/yD2eEZtIwKWwm2H2ssvfZVUf/DNhnxZytSEsIdTE30yA4hXDj4UYw0FlLuoEgRt 6L2kdS0Pg6RTdu+3eXTXdlftrp+1wR5E80me0fNP2K7xnElaMzT1pr5t+c9bmgvBYlFdM BDwKWCDHduCM/qCSvYRQhmo0m/v3gcdfe02aD4nbUDgMGA7SqeQbPoK5R/7f+3b6BIEJ4 tIeIIU49QaTXu9DpRv5aDbTPHc868/vhMUEry9WDvsAlaSDR665F4i6WW6BZmEJSQDzqR ilYV3TZSFuSYc5Tp0t8ZwClL1D+5nof22VScAxE7uGGvwGt54pLWbY8SB+dtbL6ayCg== 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=j+4ooDVD; 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 D6071606A32A; Mon, 30 Nov 2026 12:25:58 +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=j+4ooDVD 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=1796041558; b=4yNU0zCAvaAnel6nmSXhIQLPXGozmXuUxeYJoFmevK2YCvo5XA93N33aNcCBOfkSAh9i pDPLrOOrUQfJ3pJhBQX3qkmJuRdgzbk2uT0vU6kqfdi571NnXWykEuo1Mrht0khjV+EAZ gu4LDoFliTqKofkesd0bnHgHJCma0WP+FoRCDXlPvffwvyxlxpMn87sH5Q7u/7zavO4Ql xn9aukSJP0O51rCVSLpc6UdwjVQUPYKvtzvhTV480DA9lh304qf8gLQdfXMPAqJvpApxA Lk/33FIJ93cITZ6aO7eRBh0nxkLqbNiY1ZkXzeMXuG7goSJW4hjfhbjhiMAZP9sdW3g== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796041558; 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=lyncOSeYB5OV68nVCZT1DFdFt/lpUnWWqVx1WQcVv1Q=; b=GFwLKkXJrdxXf/ilSfHQ2al49UwFjiAXmxbxj0ZGvMrqkdDrYmTCU+eIQYHfZfqR7/x/ T+OGlGqxfeDfHetdKOzRHna4fJK7RLgbm2MSMnUAJuDxIOD/jNl5lelEn5oBlF5i7Wno4 aA80atlblQh/vjgU1zc9gc3k9+EOd/V1QaW5zcOam4DUvc4+KwSrHcYErjh8mJf+RYtv4 5g/NcAPpI1am4GWQ4QosvaH9bk4x9ffVyAzN3+DHLQqF0nOEzBFr5U8tpMa/9nDVdQOJU 99VJqr3wLuHmx4IWprFEwSNY+/CLwerogN/EqzeBDTCVPOE9v6PZr7BDJxz/SbRnZhw== 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=j+4ooDVD; 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 03567606A329 for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 12:25:57 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09CA51F00896; Mon, 30 Nov 2026 12:25:56 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796041557; bh=lyncOSeYB5OV68nVCZT1DFdFt/lpUnWWqVx1WQcVv1Q=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=j+4ooDVD1T7iHkRKXpvllY7nmp4mHEMctaB+NuUukDVSjvDdrzofhKmuMTaLvuLl0 1nhKnsblUuxCgeSzLVrot/sBYYI8HS6VNEPNYl13Ne5d4yN7mIuSQF8JtnWGcr+aFk OWUh3BcwlaKTHmBuKIVk6NO4H32Y1dJxebiUQQhV68MyofSnvH/5B9hvA90ML1GY0X Sm6bBObT4B9v0wvkiXpHQHJpNs2UXLIvQWTbdcIU80aDPxlzmkaov1Ci204Ci3096i KNaUEzHR+J9PmGXnJKuMyOWQZIyEAaFOKKXyikqJJKa5afc7S4D7XlWoFBsQuYlp+S j6uhtogRcJJFw== 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: <20261129115556.1669188-5-mmyangfl@gmail.com> X-sashiko-severity: High 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