Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 0 · 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). - [High] The patch adds a check in yt921x_dsa_port_pre_bridge_flags() (drivers/net/dsa/motorcomm/chip.c) to reject bridge flag changes that… -- net: dsa: motorcomm: Reject bridge flag changes that break redirect rules This patch adds per-destination counters, acl_dst_cnts[], for hardware-only (non sw_assisted) redirect ACL rules. yt921x_dsa_port_pre_bridge_flags() now uses them to reject turning hairpin mode off, or isolating a port, when the change would block an installed redirect rule.
> diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c > index 7282bc0693ebb..40d0334f3d74c 100644 > --- a/drivers/net/dsa/motorcomm/chip.c > +++ b/drivers/net/dsa/motorcomm/chip.c > @@ -1465,9 +1465,44 @@ yt921x_dsa_port_pre_bridge_flags(struct dsa_switch *ds, int port, > struct switchdev_brport_flags flags, > struct netlink_ext_ack *extack) > { > + struct yt921x_priv *priv = dsa_to_yt921x_priv(ds); > + struct yt921x_port *pp = &priv->ports[port]; > + > if (flags.mask & ~(BR_HAIRPIN_MODE | BR_LEARNING | BR_FLOOD | > 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)) { > + struct dsa_port *dp = dsa_to_port(ds, port); > + unsigned long ports_mask; > + struct net_device *bdev; > + unsigned int i; > + > + bdev = dsa_port_bridge_dev_get(dp); > + if (!bdev) > + return 0; > + > + 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;
[Severity: High] Can this check be bypassed, because the state it reads hasn't been committed yet? pp->isolated, pp->hairpin and pp->isolation_mask are only updated in yt921x_bridge_flags(): drivers/net/dsa/motorcomm/chip.c:yt921x_bridge_flags() { ... if (flags.mask & BR_HAIRPIN_MODE) { pp->hairpin = flags.val & BR_HAIRPIN_MODE; ... if (flags.mask & BR_ISOLATED) { pp->isolated = flags.val & BR_ISOLATED; ... res = yt921x_bridge(priv, ports_mask); ... } br_switchdev_set_port_flag() sends PRE_BRIDGE_FLAGS synchronously. It then queues BRIDGE_FLAGS as deferred: net/bridge/br_switchdev.c:br_switchdev_set_port_flag() { ... attr.id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS; attr.flags = SWITCHDEV_F_DEFER; err = switchdev_port_attr_set(p->dev, &attr, extack); ... } switchdev_deferred_process_work() takes rtnl_lock() again later, from a workqueue. So other RTM_SETLINK or tc requests can run between this check and the commit, and they still see the old driver state. With A and B in the same bridge and a skip_sw redirect A->B installed (ports[A].acl_dst_cnts[B] == 1): bridge link set dev A isolated on -> pre_bridge_flags(A) passes, B is not isolated yet -> BRIDGE_FLAGS(A) queued bridge link set dev B isolated on (e.g. next message in the same batch) -> pre_bridge_flags(B) passes, ports[A].isolated is still false, so the !priv->ports[i].isolated test skips A deferred work runs both commits -> yt921x_bridge() puts B into A's isolation_mask The tc side has the same window. If B is already isolated, pre_bridge_flags(A, isolated on) passes while no rules exist. A skip_sw "mirred egress redirect dev B" on A is then checked in yt921x_acl_rule_ext_parse_flow_action() against the old mask: if (pp->isolation_mask & BIT(to_dp->index)) { if (cls->common.skip_sw) { So the rule is accepted as hardware-only, and the deferred commit then isolates A. The same thing can happen with hairpin. Turning hairpin off on A passes while acl_dst_cnts[A] is 0. A skip_sw A->A redirect is then accepted because pp->hairpin is still set, and the deferred commit clears it. In all three cases nothing repairs the rule afterwards, because yt921x_acl_recompute() skips non sw_assisted rules: if (!aclrule || !aclrule->sw_assisted) continue; So the hardware redirect is silently blocked, which is the case the commit message says this patch prevents. Would it work to make the pre-check and the tc parse check use the same committed or pending state? One option is to read the bridge port flags, which br_setport() stores right after the pre-check succeeds. Another is to record the pending isolated/hairpin state in the driver during pre_bridge_flags.
> + > + 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; > + } > + } > + } > + > return 0; > }
[ ... ]
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40gmail.com