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 v3 5/5] net: dsa: motorcomm: Recompute redirect rules on bridge changes
Date: Thu, 03 Dec 2026 11:15:43 +0000 [thread overview]
Message-ID: <179629654388.3146.17104538294961493197@kernel.org> (raw)
In-Reply-To: <20261201081459.2104904-6-mmyangfl@gmail.com>
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
prev parent reply other threads:[~2026-12-03 11:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 8:14 [PATCH net-next v3 0/5] net: dsa: motorcomm: Reject isolated redirect targets David Yang
2026-12-01 8:14 ` [PATCH net-next v3 1/5] net: dsa: motorcomm: Remove local cpu_ports_mask David Yang
2026-12-01 8:14 ` [PATCH net-next v3 2/5] net: dsa: motorcomm: Cache port isolation masks David Yang
2026-12-03 11:15 ` netdev-bot+sashiko
2026-12-01 8:14 ` [PATCH net-next v3 3/5] net: dsa: motorcomm: Reject isolated redirect targets David Yang
2026-12-03 11:15 ` netdev-bot+sashiko
2026-12-01 8:14 ` [PATCH net-next v3 4/5] net: dsa: motorcomm: Reject bridge flags that break redirect rules David Yang
2026-12-03 11:15 ` netdev-bot+sashiko
2026-12-01 8:14 ` [PATCH net-next v3 5/5] net: dsa: motorcomm: Recompute redirect rules on bridge changes David Yang
2026-12-03 11:15 ` 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=179629654388.3146.17104538294961493197@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