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=1796468448; b=KNr9pHEKpi9E+uz4lOizyoDXdwfW+DFIpf3xgfAqBvISD3KjgnThHBObzXplJyKpzZJ4 CM6Bv5dXk+PrO8chLt1KU9+F3pVBNqc1LTrTGhYDWBk+TvG0NB1jZDJnEGXv/Wa9wCnZC /yL+cNwF391juqaq0AelUMkM3oU64t4cYykektUrZQZLtOnTN7Y216uHxXBJHAM8gJs4u nqC0YIMOG7mncMfWnMUuUpO2Gmqw1XhlSL4/cEs1GStIn58oGCLpvd7WiRyYZu0mi47uS xrYDYwWVWiFLSuTHGk6bWsWn8BbzWnIJ47dktvRCwsPEQSZL5C+mknn16b4UoipzE8g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796468448; 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=E61tjw5TdQ6QZCBwUZ+9sgoL1FEr6Ju0P2xVV5f5iig=; b=TJumhqlf8Ju6wFpnqy+LMYvcjBH1P531/LIDYKNYYBjRA59iEv31P+7GpcjEG+fT2r0q h6PX698Xynup62G4g15oVZ1cW2dgUAVCTDGyswme6vXnESCuxhvp3OfvbkM3qdgO32irY Qk8rF/csPxszlX7iLp0pRiqyFqNnhGyEtHM/IfiYmF4jhNlNuf+JbyA9uj/BbxnGHCNNc o6RyYgUwo2fHmOvE2KrvP0Bq+4SuI1vpoR6zOZnYESwa/VYZV9RXjjIQdq924KxfINd0F u3HJ5J7F+N4B+QGNfGYltQ6I/uFL9DQQ+tJF2B9nqASTrfhNFhR4w8KJ6GegcpfZyRg== 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=lAxtSbM+; 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 E5AE8606A681 for ; Sat, 5 Dec 2026 11:00:47 +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=lAxtSbM+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 406311F0092B; Sat, 5 Dec 2026 11:00:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796468447; bh=E61tjw5TdQ6QZCBwUZ+9sgoL1FEr6Ju0P2xVV5f5iig=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=lAxtSbM+CbeG1/HIsXOifKY+1cQztj52hkfpwBPKMB+eyWxsRhUPEhqG/JYoINJUs WGnrczofKmBAKl5QoXefN4CRbx42qg76hAAPq6zNH3R0w0orfDYtfrI93Db55EmIol Hwl0/tPOnJWLmloMkXPq9Fw7ten6TQ1V9MFuE3qA3IGSPP043nfOhNdANBmgXif9st V8xO4su6YDrZs83i2rxh8hlDZeV6vJWBl1gAAkbC/D+X8HW8IVRAj32J4uYmc1i7M3 m94apHVzFFOeXaDYdnj3/CNulP30oaAZ1DDBH3ErDF2VVz4BiV83VOQZfoT7xapj5v bnrhGk31H0p6A== Subject: Re: [PATCH net-next v4 6/6] 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: Sat, 05 Dec 2026 11:00:46 +0000 Message-ID: <179646844684.3146.4587711461431918229@kernel.org> In-Reply-To: <20261204101300.3680838-7-mmyangfl@gmail.com> References: <20261204101300.3680838-7-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 6 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 2 · Low: 4 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] yt921x_acl_refresh() in drivers/net/dsa/motorcomm/tc.c sets `inability = true` for every skip_sw rule (`!aclrule->sw_assisted`)… - [Medium] net: dsa: motorcomm: bridge join breaks skip_sw hairpin redirect rules - [Low] The order of the ACL refresh relative to the isolation register update is fixed per call site. - [Low] Both strings built by the new yt921x_acl_refresh_extack() helper end with '\n': "Failed to refresh ACL rules: %i\n"… - [Low] In yt921x_bridge_flags(), the result of yt921x_acl_refresh() is reported only through extack via yt921x_acl_refresh_extack(res,… - [Low] yt921x_acl_refresh() updates the driver's record (`aclrule->sw_assisting = assisting;`) before calling… -- net: dsa: motorcomm: Recompute redirect rules on bridge changes On bridge join, bridge leave, and hairpin/isolated flag changes, this commit re-evaluates the non-skip_sw redirect ACL rules. Each one is trapped or untrapped to match the new isolation masks. skip_sw rules are left as they are, and a warning is meant to be emitted if any of them are invalidated. > diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c > index 323c1705f613c..dc64ec1e310dd 100644 > --- a/drivers/net/dsa/motorcomm/chip.c > +++ b/drivers/net/dsa/motorcomm/chip.c [ ... ] > @@ -1488,12 +1488,25 @@ yt921x_bridge_join(struct yt921x_priv *priv, int port) > return 0; > } > > +static void yt921x_acl_refresh_extack(int res, struct netlink_ext_ack *extack) > +{ > + if (res < 0) > + NL_SET_ERR_MSG_FMT_MOD(extack, > + "Failed to refresh ACL rules: %i\n", > + res); > + else if (res > 0) > + NL_SET_ERR_MSG_MOD(extack, > + "Could not reload some redirect rules due to skip_sw, they no longer work as expected\n"); > +} [Severity: Low] This isn't a bug, but both extack strings in yt921x_acl_refresh_extack() end with a trailing \n. The other extack messages in the driver don't have one. > + > static int > yt921x_bridge_flags(struct yt921x_priv *priv, int port, > - struct switchdev_brport_flags flags) > + struct switchdev_brport_flags flags, > + struct netlink_ext_ack *extack) > { [ ... ] > @@ -1512,9 +1525,17 @@ yt921x_bridge_flags(struct yt921x_priv *priv, int port, > /* BR_BCAST_FLOOD: we can filter bcast, but cannot trap them */ > > if ((flags.mask & BR_HAIRPIN_MODE) || (flags.mask & BR_ISOLATED)) { > - res = yt921x_isolation_refresh(priv, BIT(port), true); > - if (res) > - return res; > + /* Trap the rules first, so no frame is dropped in between */ > + res = yt921x_acl_refresh(priv, port); > + /* Refresh failure is not considered fatal, though the hardware > + * is likely desynced > + */ > + > + ret = yt921x_isolation_refresh(priv, BIT(port), true); > + if (ret) > + return ret; [Severity: Low] Does this ordering still hold when isolation is being relaxed? In a single pass, yt921x_acl_refresh() computes the post-change masks and commits both trap and untrap transitions. Clearing BR_ISOLATED or enabling BR_HAIRPIN_MODE turns trapped rules back into plain REDIR. That happens while the old, stricter PORTn_ISOLATION is still programmed. The existing comment in yt921x_acl_rule_ext_parse_flow_action() says: /* Port isolation takes after REDIR judgment, but * software delivers such frames. */ So until yt921x_isolation_refresh() runs, would matching frames be dropped in hardware? That would contradict "no frame is dropped in between". yt921x_dsa_port_bridge_leave() uses the same order. For example, a sw_assisted P->P rule on a non-hairpin bridged port is untrapped before yt921x_bridge_leave() relaxes isolation. yt921x_dsa_port_bridge_join() uses the opposite order: res = yt921x_bridge_join(priv, port); if (res) goto end; res = yt921x_acl_refresh(priv, port); There, a sw_assisted P->P rule that was a live REDIR while the port was standalone gets blocked by the new non-hairpin isolation before it is trapped. If yt921x_isolation_refresh() fails here, the ACL also stays programmed for an isolation state that was never applied. Would trap first, then isolation update, then untrap avoid the window in all three paths? > + > + yt921x_acl_refresh_extack(res, extack); > } > > return 0; [Severity: Medium] Should yt921x_dsa_port_bridge_join() refuse the join here instead of downgrading the result to a warning? A standalone port has isolation_masks[port] = ~(BIT(port) | cpu), so yt921x_acl_rule_ext_parse_flow_action() lets a skip_sw P->P redirect be offloaded on it. yt921x_acl_add() then bumps priv->ports[port].acl_dst_cnts[port]. When that port is enslaved, new_nbp() creates the bridge port without BR_HAIRPIN_MODE, so yt921x_bridge_join() programs self-isolation for the port. The skip_sw rule stays a plain REDIR. Port isolation is applied after the REDIR decision, so matching frames are dropped in hardware. tc still reports the rule as offloaded, and because it is skip_sw, software will not deliver those frames either. yt921x_acl_refresh() returns 1 in this case. The join path only passes that to yt921x_acl_refresh_extack() and then clears res, so the join succeeds and the rule is silently broken. yt921x_dsa_port_pre_bridge_flags() already refuses to clear BR_HAIRPIN_MODE while pp->acl_dst_cnts[port] is non-zero, precisely so that skip_sw hairpin rules are not broken behind tc's back. port_bridge_join() can return an error, unlike port_bridge_leave(). Could the same check be done here, before yt921x_bridge_join() touches the hardware, so that the join fails with an error and an extack message? [Severity: Low] Can extack be non-NULL when this branch runs? br_switchdev_set_port_flag() sends SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS with SWITCHDEV_F_DEFER, and the deferred path does: net/switchdev/switchdev.c:switchdev_port_attr_set_deferred() { ... err = switchdev_port_attr_set_now(dev, attr, NULL); ... } dsa_port_inherit_brport_flags() and dsa_port_clear_brport_flags() call in directly, but they only use BR_LEARNING, BR_FLOOD, BR_MCAST_FLOOD, BR_BCAST_FLOOD and BR_PORT_LOCKED. They never reach the hairpin/isolated branch. So if yt921x_acl_commit() fails during a hairpin or isolated change, the error seems to go unreported, and yt921x_bridge_flags() returns 0. yt921x_dsa_port_bridge_leave() reports the same result with dev_err() and dev_warn(). Should this path do that too? [ ... ] > diff --git a/drivers/net/dsa/motorcomm/tc.c b/drivers/net/dsa/motorcomm/tc.c > index 7691da95d76f3..00c632447b3c5 100644 > --- a/drivers/net/dsa/motorcomm/tc.c > +++ b/drivers/net/dsa/motorcomm/tc.c > @@ -1393,6 +1393,80 @@ yt921x_acl_commit(struct yt921x_priv *priv, unsigned int entid, u8 entsmask) > return 0; > } > > +/* Only non-skip_sw rules are refreshes; skip_sw rules cannot be degraded, > + * port_bridge_leave() cannot be rejected (return value is void), nor can tc be > + * told which rule got invalidated. > + * > + * Return 1 if any skip_sw rules are now invalidated. > + */ > +int yt921x_acl_refresh(struct yt921x_priv *priv, int port) > +{ [ ... ] > + if (!(aclrule->action[2] & YT921X_ACL_ACTc_FWD_EN) || > + (aclrule->action[2] & YT921X_ACL_ACTc_FWD_M) != > + YT921X_ACL_ACTc_FWD_REDIR) > + continue; > + > + srcs = FIELD_GET(YT921X_ACL_KEYb_SPORTS_M, > + aclrule->entries[0].key[1]); > + dsts = FIELD_GET(YT921X_ACL_ACTc_FWD_REDIR_DPORTS_M, > + aclrule->action[2]); > + if (!((srcs | dsts) & BIT(port))) > + continue; > + > + assisting = false; > + for_each_set_bit(o, &srcs, YT921X_PORT_NUM) > + if (dsts & isolation_masks[o]) { > + assisting = true; > + break; > + } > + > + if (!aclrule->sw_assisted) { > + inability = true; > + continue; > + } [Severity: Medium] Should this check assisting before setting inability? As written, any skip_sw redirect rule that touches the port makes yt921x_acl_refresh() return 1. It does not matter whether the new isolation masks block the rule or not. The function comment says "Return 1 if any skip_sw rules are now invalidated", and the commit message says "Warn if any skip_sw rules are invalidated". For skip_sw rules, though, the assisting value computed just above is never used. Drop rules are caught as well. yt921x_acl_rule_ext_parse_flow_action() encodes a drop as: case FLOW_ACTION_DROP: action[2] |= YT921X_ACL_ACTc_FWD_EN | YT921X_ACL_ACTc_FWD_REDIR; The DPORTS field is left empty, so the rule passes the REDIR filter above and srcs & BIT(port) is true. With dsts == 0, isolation can't affect the rule. Even so, any port with a skip_sw drop rule would get "they no longer work as expected" on every bridge leave (dev_warn() in yt921x_dsa_port_bridge_leave()) and on every bridge join (extack in yt921x_dsa_port_bridge_join()). A skip_sw P->P rule on a hairpin-enabled bridged port is another example. It stays valid after the port leaves, because the standalone mask ~(BIT(P) | cpu) allows self-redirect, but it would still be reported. On the bridge_flags path, yt921x_dsa_port_pre_bridge_flags() already rejects changes that would invalidate skip_sw hairpin redirects: if ((flags.mask & BR_HAIRPIN_MODE) && !(flags.val & BR_HAIRPIN_MODE) && pp->acl_dst_cnts[port]) { So any skip_sw warning from that path looks spurious. The warning is right in one case. On join, a skip_sw P->P rule from a standalone port really is invalidated, because the port joins as non-hairpin. Would something like this match the intent? if (!aclrule->sw_assisted) { if (assisting) inability = true; continue; } > + > + entid = YT921X_ACL_ENT_PER_BLK * blkid + i; > + if (aclrule->sw_assisting != assisting) { > + aclrule->sw_assisting = assisting; > + res = yt921x_acl_commit(priv, entid, > + aclrule->mask); > + if (res && !ret) > + ret = res; > + } [Severity: Low] What happens to aclrule->sw_assisting if yt921x_acl_commit() fails? It is updated before the commit and never restored. The hardware can keep the old action, or a half-written block, while the driver records the new state. Later refreshes compare aclrule->sw_assisting != assisting, find the two equal, and never rewrite the entry. The mismatch would last until the rule is deleted. yt921x_bridge_flags() also ignores the refresh error and still writes the new isolation masks. A failed REDIR->TRAP transition would then leave the hardware redirecting into a port that is now isolated, so those frames would be dropped. Should sw_assisting be updated only after the commit succeeds, or be restored when it fails? [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204101300.3680838-1-mmyangfl%40gmail.com