Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In the LAG-leave window and the dsa_port_change_conduit() window,
this patch makes a bridge port that the switch still forwards for act…
--
net: bridge: switchdev: clear the hwdom of a port that stops the offload
When the last offload of a bridge port stops, nbp_switchdev_del() now
clears the port's hwdom. Before, the hwdom leaked when the port stayed in
the bridge. nbp_switchdev_hwdom_set() now skips ports without a hwdom, and
the forwarding path helpers read the hwdom once with READ_ONCE().
> diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
> index 8de12d56452dc..52b51b8753f43 100644
> --- a/net/bridge/br_switchdev.c
> +++ b/net/bridge/br_switchdev.c
[ ... ]
> @@ -305,8 +330,10 @@ static void nbp_switchdev_del(struct net_bridge_port *p)
> if (p->offload_count)
> return;
>
> - if (p->hwdom)
> + if (p->hwdom) {
> nbp_switchdev_hwdom_put(p);
> + WRITE_ONCE(p->hwdom, 0);
> + }
>
> if (test_bit(BR_TX_FWD_OFFLOAD_BIT, &p->flags)) {
> clear_bit(BR_TX_FWD_OFFLOAD_BIT, &p->flags);
[Severity: Low]
During a LAG leave, can clearing the hwdom here drop frames toward bridge
ports that are software only?
The last DSA port can leave a LAG that stays a bridge port. In that case
this code runs at NETDEV_PRECHANGEUPPER:
dsa_user_prechangeupper()
dsa_port_pre_lag_leave()
dsa_port_pre_bridge_leave()
switchdev_bridge_port_unoffload()
nbp_switchdev_del()
WRITE_ONCE(p->hwdom, 0)
The hardware bridge and the trunk are torn down later, at
NETDEV_CHANGEUPPER, by dsa_port_lag_leave()->dsa_port_bridge_leave().
Until then, tag_dsa still marks every trunk frame:
net/dsa/tag_dsa.c:dsa_rcv_ll() {
...
if (trunk)
skb->offload_fwd_mark = true;
...
}
nbp_switchdev_frame_mark() then leaves src_hwdom at 0 for the LAG port.
Take a software-only egress port such as a veth or tap, which has hwdom 0.
For that port, nbp_switchdev_allowed_egress() checks:
return !test_bit(hwdom, &cb->fwd_hwdoms) &&
(!skb->offload_fwd_mark || cb->src_hwdom != hwdom);
Here offload_fwd_mark is set and cb->src_hwdom == hwdom == 0. The port is
refused, but the hardware never delivered the frame to it.
The other switch ports have hwdom X and pass the check, because 0 != X.
They get a software copy of a frame that the hardware already flooded.
In the other direction, a marked frame from another switch port passes the
check for the LAG, which now has hwdom 0. It then goes out through the
trunk a second time.
Documentation/networking/switchdev.rst says the bridge stops a frame from
being forwarded "through any bridge port with the same mark". Here hwdom 0
means that the port has no hardware domain, not that it shares a mark.
dsa_port_change_conduit() opens the same window between
dsa_port_pre_bridge_leave() and dsa_port_bridge_leave().
The commit message describes this window, and it lasts one RTNL operation.
Before this patch, though, the LAG kept its hwdom during the window and
these checks gave the right result.
Could the drops toward software-only ports be avoided by not counting
src_hwdom 0 as a match in nbp_switchdev_allowed_egress()? For example, the
check could require cb->src_hwdom != 0 before it refuses the port.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40gmail.com