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
Subject: Re: [PATCH net-next v4 6/6] net: dsa: motorcomm: Recompute redirect rules on bridge changes
Date: Sat, 05 Dec 2026 11:00:46 +0000 [thread overview]
Message-ID: <179646844684.3146.4587711461431918229@kernel.org> (raw)
In-Reply-To: <20261204101300.3680838-7-mmyangfl@gmail.com>
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
prev parent reply other threads:[~2026-12-05 11:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 10:12 [PATCH net-next v4 0/6] net: dsa: motorcomm: Reject isolated redirect targets David Yang
2026-12-04 10:12 ` [PATCH net-next v4 1/6] net: dsa: motorcomm: Remove local cpu_ports_mask David Yang
2026-12-04 10:12 ` [PATCH net-next v4 2/6] net: dsa: motorcomm: Do not block hairpins on standalone ports David Yang
2026-12-05 11:00 ` netdev-bot+sashiko
2026-12-04 10:12 ` [PATCH net-next v4 3/6] net: dsa: motorcomm: Derive port isolation masks on the fly David Yang
2026-12-04 10:12 ` [PATCH net-next v4 4/6] net: dsa: motorcomm: Reject isolated redirect targets David Yang
2026-12-04 10:12 ` [PATCH net-next v4 5/6] net: dsa: motorcomm: Reject bridge flags that break redirect rules David Yang
2026-12-05 11:00 ` netdev-bot+sashiko
2026-12-04 10:12 ` [PATCH net-next v4 6/6] net: dsa: motorcomm: Recompute redirect rules on bridge changes David Yang
2026-12-05 11:00 ` netdev-bot+sashiko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179646844684.3146.4587711461431918229@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=mmyangfl@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox