Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · 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).
- [Medium] yt921x_dsa_port_pre_bridge_flags()
(drivers/net/dsa/motorcomm/chip.c) does not veto BR_ISOLATED when the…
--
net: dsa: motorcomm: Reject bridge flags that break redirect rules
This commit adds per-port acl_dst_cnts bookkeeping in yt921x_acl_add() and
yt921x_acl_del() for redirect rules that are not sw_assisted. It then uses
those counters in yt921x_dsa_port_pre_bridge_flags() to reject turning off
hairpin mode, or turning on BR_ISOLATED, when the change would block such a
rule.
> diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
> index a71a8dd5dc63c..323c1705f613c 100644
> --- a/drivers/net/dsa/motorcomm/chip.c
> +++ b/drivers/net/dsa/motorcomm/chip.c
> @@ -1525,9 +1525,52 @@ yt921x_dsa_port_pre_bridge_flags(struct dsa_switch *ds, int port,
[ ... ]
> + if ((flags.mask & BR_ISOLATED) && (flags.val & BR_ISOLATED)) {
> + struct dsa_port *other_dp;
> +
> + dsa_switch_for_each_user_port(other_dp, ds) {
> + struct net_device *other_brport;
> + int i = other_dp->index;
> +
> + if (i == port || !(ports_mask & BIT(i)))
> + continue;
> + if (!pp->acl_dst_cnts[i] &&
> + !priv->ports[i].acl_dst_cnts[port])
> + continue;
> +
> + other_brport = dsa_port_to_bridge_port(other_dp);
> + if (!br_port_flag_is_set(other_brport, BR_ISOLATED))
> + continue;
[Severity: Medium]
Can this check be bypassed when both ends of a skip_sw redirect rule are
members of the same offloaded LAG?
The port being changed gets its new isolation state from flags.val. The
peer's state is read back from the bridge. For LAG members,
dsa_port_to_bridge_port() returns the shared LAG netdev:
include/net/dsa.h:dsa_port_to_bridge_port() {
...
if (dp->lag)
return dp->lag->dev;
...
}
The bridge sends PRE_BRIDGE_FLAGS before it writes the new value into
p->flags. This happens on both the netlink path and the sysfs path:
net/bridge/br_netlink.c:br_setport() {
...
err = br_switchdev_set_port_flag(p, flags, changed_mask, extack);
...
} while (!try_cmpxchg(&p->flags, &old_flags, flags));
...
}
net/bridge/br_sysfs_if.c:store_flag() {
...
err = br_switchdev_set_port_flag(p, flags, BIT(bitnr), &extack);
...
assign_bit(bitnr, &p->flags, v);
...
}
So when the LAG bridge port itself is being isolated, each member sees its
LAG peer as not yet isolated and hits the continue above.
Here is an example. Ports P and Q are in one offloaded LAG, bond0, and bond0
is a bridge port:
skip_sw flower redirect rule from P to Q
-> P's acl_dst_cnts[Q] is incremented
bridge link set dev bond0 isolated on
-> pre_bridge_flags(P) and pre_bridge_flags(Q) both return 0
-> .port_bridge_flags
-> yt921x_isolation_refresh()
-> yt921x_isolation_calc_bridge()
When yt921x_isolation_calc_bridge() runs, bond0 now reads as isolated:
if (br_port_flag_is_set(brport, BR_ISOLATED))
isolated_mask |= BIT(port);
That gives isolated_mask = BIT(P) | BIT(Q). Q's bit then lands in P's
isolation mask, and the hardware drops the P->Q redirect even though the
rule was accepted as skip_sw.
Isn't this the case the commit message says should be rejected?
The later patch in the series ("net: dsa: motorcomm: Recompute redirect
rules on bridge changes") does not change yt921x_dsa_port_pre_bridge_flags(),
so this still seems to apply at the end of the series.
The new warning that patch adds in yt921x_bridge_flags() would not reach
the user here either, because the deferred switchdev attr path passes a
NULL extack.
> +
> + NL_SET_ERR_MSG_MOD(extack,
> + "Cannot isolate port while there are redirect rules");
> + return -EINVAL;
> + }
> + }
> +
> return 0;
> }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40gmail.com