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=1796296545; b=DVlCrm1u4G2UrQKKvTkHQFQeMn0CZwgmBFUhkjHZoIECDzFKZBB1f0yDDg0Dk+pci420 s1BYHmbL2qL4CCDPV6hekmzZuW71fcbpPLc8yVD5Ri54SRV/mNzdmbZaKPquWX7ny3zwO KzzUO0WjcXi8wvFaGRhF+QDboh/sehTWp87PSDAOLcE/M/YlK2HNlvEZQEZJ3yM+itObV H4wskTouVpITx0CN4OIEscSMkYbNXw9KRJWB2lFKfgJSQkEX6Y+xCVrOgp3pHeUuSPB8s rSwDpmDJtCFjZAgQg3dD4O5Ty0dunIMcbC90/9STPFwIctOziA59hPK3rBNYZ/iM4Yw== 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== 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 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 ; Thu, 3 Dec 2026 11:15:44 +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=MvFrMqip Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54EC51F008A0; Thu, 3 Dec 2026 11:15:44 +0000 (UTC) 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== Subject: Re: [PATCH net-next v3 5/5] net: dsa: motorcomm: Recompute redirect rules on bridge changes 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: Thu, 03 Dec 2026 11:15:43 +0000 Message-ID: <179629654388.3146.17104538294961493197@kernel.org> In-Reply-To: <20261201081459.2104904-6-mmyangfl@gmail.com> References: <20261201081459.2104904-6-mmyangfl@gmail.com> X-sashiko-severity: Medium 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 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