From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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 ; Mon, 30 Nov 2026 12:25:59 +0000 (UTC) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61FE71F000C1; Mon, 30 Nov 2026 12:25:58 +0000 (UTC) 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== Subject: Re: [PATCH net-next v2 5/5] net: dsa: motorcomm: Reject bridge flags that break redirect rules From: netdev-bot+sashiko@kernel.org To: mmyangfl@gmail.com Cc: netdev@vger.kernel.org, andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com Date: Mon, 30 Nov 2026 12:25:57 +0000 Message-ID: <179604155795.3146.3013639565028372543@kernel.org> In-Reply-To: <20261129115556.1669188-6-mmyangfl@gmail.com> References: <20261129115556.1669188-6-mmyangfl@gmail.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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