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] In yt921x_dsa_port_pre_bridge_flags()
(drivers/net/dsa/motorcomm/chip.c), the new per-port vetoes run before…
--
net: dsa: motorcomm: Reject bridge flags that break redirect rules
This commit adds a per-port acl_dst_cnts[] counter. yt921x_acl_add() and
yt921x_acl_del() update it for redirect rules that are not sw_assisted.
yt921x_dsa_port_pre_bridge_flags() then uses the counters to reject turning
off hairpin mode or turning on isolation when such rules would be blocked.
> diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
> index 6c6a87207bd5c..0bc5da2b80d7a 100644
> --- a/drivers/net/dsa/motorcomm/chip.c
> +++ b/drivers/net/dsa/motorcomm/chip.c
> @@ -1448,6 +1448,37 @@ yt921x_dsa_port_pre_bridge_flags(struct dsa_switch *ds, int port,
> BR_MCAST_FLOOD | BR_ISOLATED))
> return -EINVAL;
>
> + if ((flags.mask & BR_HAIRPIN_MODE) && !(flags.val & BR_HAIRPIN_MODE) &&
> + pp->acl_dst_cnts[port]) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Cannot disable hairpin mode while there are hairpin redirect rules installed");
> + return -EINVAL;
> + }
> +
> + if ((flags.mask & BR_ISOLATED) && (flags.val & BR_ISOLATED)) {
[ ... ]
> + ports_mask = dsa_bridge_ports(ds, bdev);
> + for_each_set_bit(i, &ports_mask, YT921X_PORT_NUM) {
> + if (i == port || !priv->ports[i].isolated)
> + continue;
> +
> + if (pp->acl_dst_cnts[i] ||
> + priv->ports[i].acl_dst_cnts[port]) {
> + NL_SET_ERR_MSG_MOD(extack,
> + "Cannot isolate port while there are redirect rules installed");
> + return -EINVAL;
> + }
> + }
> + }
> +
> if ((flags.mask & BR_HAIRPIN_MODE) || (flags.mask & BR_ISOLATED)) {
> struct dsa_port *dp = dsa_to_port(ds, port);
> struct net_device *bdev;
[Severity: Medium]
Can these new per-port checks leave driver state half updated when the
bridge port is an offloaded LAG?
Right after these checks, the prepare phase already changes driver state:
if (flags.mask & BR_HAIRPIN_MODE)
pp->hairpin = flags.val & BR_HAIRPIN_MODE;
if (flags.mask & BR_ISOLATED)
pp->isolated = flags.val & BR_ISOLATED;
...
yt921x_isolation_calc_bridge(priv, ports_mask);
Take bond0 with lowers swpA and swpB on this switch. The bridge sends one
PRE_BRIDGE_FLAGS notification, and switchdev calls the driver once per
lower:
br_setport()
br_switchdev_set_port_flag()
__switchdev_handle_port_attr_set() /* loops over lowers */
dsa_user_port_attr_set()
dsa_port_pre_bridge_flags()
yt921x_dsa_port_pre_bridge_flags()
__switchdev_handle_port_attr_set() returns on the first hard error. It does
not undo the lowers that already succeeded.
Suppose swpA has no conflicting rules. Its call passes, sets pp->hairpin or
pp->isolated, and rewrites isolation_mask for every bridge member through
yt921x_isolation_calc_bridge().
Then suppose swpB fails one of the new acl_dst_cnts[] checks. br_setport()
returns the error, the bridge keeps its old flags, and the deferred
PORT_BRIDGE_FLAGS is never sent.
Nothing appears to roll back swpA's hairpin/isolated state or the cached
isolation_mask values. The next yt921x_isolation_commit() would write those
stale masks to hardware. That happens on a later successful hairpin or
isolated change, or on a bridge_join. Frames would then be dropped even
though the bridge configuration allows them.
The stale masks are also used by the tc parse path and by
yt921x_acl_recompute_rule(). The isolation check above also reads the stale
priv->ports[i].isolated, so isolation changes on other ports could be
rejected wrongly.
Retrying the same flag change would not fix it. The bridge sees no change in
its flags, so it never calls the driver.
Before this patch, the only failure in this function was the unsupported-flag
mask check. That check gives the same result for every lower, so it failed
on the first lower before any state changed.
The later patch in this series, "net: dsa: motorcomm: Recompute redirect
rules on bridge changes", does not touch pre_bridge_flags. Does this problem
still exist at the end of the series?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40gmail.com