Article View: linux.kernel.netdev
Article #24606Re: [PATCH net-next v2 5/5] net: dsa: motorcomm: Reject bridge flags that break redirect rules
From: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 12:25
Date: Mon, 30 Nov 2026 12:25
155 lines
13270 bytes
13270 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · 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).
- [High] The patch adds a check in yt921x_dsa_port_pre_bridge_flags()
(drivers/net/dsa/motorcomm/chip.c) to reject bridge flag changes that…
--
net: dsa: motorcomm: Reject bridge flag changes that break redirect rules
This patch adds per-destination counters, acl_dst_cnts[], for hardware-only
(non sw_assisted) redirect ACL rules. yt921x_dsa_port_pre_bridge_flags()
now uses them to reject turning hairpin mode off, or isolating a port, when
the change would block an installed redirect rule.
> diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
> index 7282bc0693ebb..40d0334f3d74c 100644
> --- a/drivers/net/dsa/motorcomm/chip.c
> +++ b/drivers/net/dsa/motorcomm/chip.c
> @@ -1465,9 +1465,44 @@ yt921x_dsa_port_pre_bridge_flags(struct dsa_switch *ds, int port,
> struct switchdev_brport_flags flags,
> struct netlink_ext_ack *extack)
> {
> + struct yt921x_priv *priv = dsa_to_yt921x_priv(ds);
> + struct yt921x_port *pp = &priv->ports[port];
> +
> if (flags.mask & ~(BR_HAIRPIN_MODE | BR_LEARNING | BR_FLOOD |
> BR_MCAST_FLOOD | BR_ISOLATED))
> return -EINVAL;
> +
> + if ((flags.mask & BR_HAIRPIN_MODE) && !(flags.val & BR_HAIRPIN_MODE) &&
> + pp->acl_dst_cnts[port]) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Cannot disable hairpin mode while there are hairpin redirect rules installed");
> + return -EINVAL;
> + }
> +
> + if ((flags.mask & BR_ISOLATED) && (flags.val & BR_ISOLATED)) {
> + struct dsa_port *dp = dsa_to_port(ds, port);
> + unsigned long ports_mask;
> + struct net_device *bdev;
> + unsigned int i;
> +
> + bdev = dsa_port_bridge_dev_get(dp);
> + if (!bdev)
> + return 0;
> +
> + ports_mask = dsa_bridge_ports(ds, bdev);
> + for_each_set_bit(i, &ports_mask, YT921X_PORT_NUM) {
> + if (i == port || !priv->ports[i].isolated)
> + continue;
[Severity: High]
Can this check be bypassed, because the state it reads hasn't been
committed yet?
pp->isolated, pp->hairpin and pp->isolation_mask are only updated in
yt921x_bridge_flags():
drivers/net/dsa/motorcomm/chip.c:yt921x_bridge_flags() {
...
if (flags.mask & BR_HAIRPIN_MODE) {
pp->hairpin = flags.val & BR_HAIRPIN_MODE;
...
if (flags.mask & BR_ISOLATED) {
pp->isolated = flags.val & BR_ISOLATED;
...
res = yt921x_bridge(priv, ports_mask);
...
}
br_switchdev_set_port_flag() sends PRE_BRIDGE_FLAGS synchronously. It then
queues BRIDGE_FLAGS as deferred:
net/bridge/br_switchdev.c:br_switchdev_set_port_flag() {
...
attr.id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS;
attr.flags = SWITCHDEV_F_DEFER;
err = switchdev_port_attr_set(p->dev, &attr, extack);
...
}
switchdev_deferred_process_work() takes rtnl_lock() again later, from a
workqueue. So other RTM_SETLINK or tc requests can run between this check
and the commit, and they still see the old driver state.
With A and B in the same bridge and a skip_sw redirect A->B installed
(ports[A].acl_dst_cnts[B] == 1):
bridge link set dev A isolated on
-> pre_bridge_flags(A) passes, B is not isolated yet
-> BRIDGE_FLAGS(A) queued
bridge link set dev B isolated on (e.g. next message in the same batch)
-> pre_bridge_flags(B) passes, ports[A].isolated is still false,
so the !priv->ports[i].isolated test skips A
deferred work runs both commits
-> yt921x_bridge() puts B into A's isolation_mask
The tc side has the same window. If B is already isolated,
pre_bridge_flags(A, isolated on) passes while no rules exist. A skip_sw
"mirred egress redirect dev B" on A is then checked in
yt921x_acl_rule_ext_parse_flow_action() against the old mask:
if (pp->isolation_mask & BIT(to_dp->index)) {
if (cls->common.skip_sw) {
So the rule is accepted as hardware-only, and the deferred commit then
isolates A.
The same thing can happen with hairpin. Turning hairpin off on A passes
while acl_dst_cnts[A] is 0. A skip_sw A->A redirect is then accepted
because pp->hairpin is still set, and the deferred commit clears it.
In all three cases nothing repairs the rule afterwards, because
yt921x_acl_recompute() skips non sw_assisted rules:
if (!aclrule || !aclrule->sw_assisted)
continue;
So the hardware redirect is silently blocked, which is the case the commit
message says this patch prevents.
Would it work to make the pre-check and the tc parse check use the same
committed or pending state? One option is to read the bridge port flags,
which br_setport() stores right after the pre-check succeeds. Another is to
record the pending isolated/hairpin state in the driver during
pre_bridge_flags.
> +
> + if (pp->acl_dst_cnts[i] ||
> + priv->ports[i].acl_dst_cnts[port]) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Cannot isolate port while there are redirect rules installed");
> + return -EINVAL;
> + }
> + }
> + }
> +
> return 0;
> }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129115556.1669188-1-mmyangfl%40gmail.com
Technical Details
Message-ID:
<179604155795.3146.3013639565028372543@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374168-linux-kernel-netdev=dewy.ruReferences:
<20261129115556.1669188-6-mmyangfl@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374168-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v2 5/5] net: dsa: motorcomm: Reject bridge flags that break redirect rules Date: Mon, 30 Nov 2026 12:25:57 +0000 Organization: Usenet Network Message-ID: <179604155795.3146.3013639565028372543@kernel.org> References: <20261129115556.1669188-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="1423132"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:kg86gWguEv0f+OLE4xshvPf4t7c= sha256:d4JIOniZJEu6eDvqVInts/FSWOc/DQGB64/qvb3Oa0g= sha1:xRh5qk0h9b8YOatPRfd4OEK1+0U= sha256:37ze7PV6Ww/2+OHXFB1QeBsmO22t2Q4b4CB3VeRQiyg= 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 8D23D125FDE; Mon, 30 Nov 2026 15:26:18 +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 OH3fXtd6KLjW; Mon, 30 Nov 2026 15:26:15 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374168-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 CD97F125FE4; Mon, 30 Nov 2026 15:26:06 +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 66DFD2CD78; Mon, 30 Nov 2026 12:26:00 +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=1796041560; b=bfuyhdEtkC9svzMZ4iPhd0jy2Kg1pe0yxzEs458W4fhWjs91Q9JGYKT2jxoVMp1i1s5H bUrN0Z7VeI62l/1up5r6IgUH6JsEEJqh0SWNOZ7+g9hqlx7M8jeF8WW2/Y27C397Niwyd MhpXiZr/hvYrTxOGx74sXKPThdy44aFLsnwwv1cR/yH7RWPwL/AuPcmQRAV1AMqNrcGup Kb1rraVcGbNAFXlyd/xL2RWKyjGavTVyH1j9bd/WFWmXRU+4OdgOBBceHTi9q9B0RFwY+ ZHIQ6YPX+HcJzEHI8Esfvkj42kKcebvBPaAbBpMZ6fxz8CbRJpNHqGDb8bJQh+BzoKA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796041560; 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=o2DHGk0qm9JNKS3oHWCq87oBLcYkTpmFygufeFcVz+U=; b=fqmFZ/yJFYfTZpGAoGMdeMCSbLGg2/6t3epqSsNlNBUAwx+vyS0UAye7jKd609U6XKEN XuRCrgRsWxkwAdCLc029aOoS7ffrqGf33NTiH8K3i0Yzs973A7Dr2ZRB56SVrNnTGTMCW eVhHLR/VHVt8FandR5uHTYgw8dbBdRDClbxKXzntsB96vfH+ooLJKh7p+oVtxC9bOkb5I OPMz2RCJkfFgOxJ3Q8stvlEEJsd0J1NWEeH7DJccPhXxohXn+pLJNQdaDj385oxms9yUM I066PpCRK8khcHNIt/gtn7wVDs/24qAsBDN3Y2fgLnZM/KF8t1jlMLgsGrCRCI1GvCA== 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=Ra1bJZzP; 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 3EA95606A325; Mon, 30 Nov 2026 12:26:00 +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=Ra1bJZzP 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=1796041559; b=cFSKljmtjggd1j2GMgI2UxBjnV6e2kFoH5/rqjsTZNkDtjhqgsw4a0Xp9TBIzanqVrwb znC86ZKhOBdsKMA9DeUcfw6Y9yB145yZu5gwuyv6Ll5sRrLz+Z0tuKWTN42E/JapHKz6j vmXvHvZgYrvDS22F8wKc/fjrJMSbn/UOwNYSeLxOQkkXn+ATzgUGwvLKQ5G4iBR3mUGOw 7+XWter5yLeSw+jDrHMWvMuozJTRuSWI0Y2yAz/b8L2mhF2I0FgObcidSxmFvf9N/WakS FuRSS+kxc9RmwLWf3dizSDd1ztIFBdU75VOaY8t8vIDZBiGX0yYRFcLKYmQOQvSe2QQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796041559; 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=o2DHGk0qm9JNKS3oHWCq87oBLcYkTpmFygufeFcVz+U=; b=y/gxwbogekV1F5Puj2IroYO7+YqGC68fjMhxHc7+dEL0ALROCcp3U48GIcUmbaMQ4yg5 URhaq9Q+bX3L1kxjqNmIloGma0PRbKhmd8xK4vokGxUjhyUFlG/q6yfeRPmLvEXjqfIqu pGSxUsSL9eavoBX020qt1+sYoia8Pze0ERpA03/mtNRODPWjadNglYRG+8NnQbYx11JEP mOejWo0R8sPpRbjfsiyoaPBMcc0uKtYzabUOnNyja8SJ4GHI5DDfCUSwtEwA39JybcVfl GEgNBzGJsF8vsZ1GRJyrU499CfqrwKPaH5pZsFrAFBsRFbto94UR70MchfvV0/UMzEw== 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=Ra1bJZzP; 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 5D415606A32F for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 12:25:59 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61FE71F000C1; Mon, 30 Nov 2026 12:25:58 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796041558; bh=o2DHGk0qm9JNKS3oHWCq87oBLcYkTpmFygufeFcVz+U=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Ra1bJZzPoTY4zgxYujdsdpmwlLE7HFCPh6yWcI30+CwoNH6pajLJ76hc6VgH5lwhD weW+li1ZGUpoa5WWJq6R9qOhk69SMI770w11Oi6WgaotgW8fLJv3yR5dXc/eqXmAFT ryZh7P+/AKxFwV2HQuKoGeELg84dbcbsSjaxUuUYoq+VuckkARzdTQiKOq+Fpkvhis wIPyfN8y8MAvgkEHLRdqo9jpLPcHshWEeobOl7ntXYj6TeOfyK5SBL0yBp6uwHzDkW 5webME0rD+8RNvASqC+mEcL6ntPbI4FiP3TVyFL4r1fYHwN8yzFdvX+6iVGxQetyjc tf6qgShftTgHw== 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-6-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