Re: [PATCH net 2/6] net: dsa: tag_sja1105, tag_vsc73xx_8021q: read the bridge once in xmit
From: willemb
Date: Sat Dec 05 2026 - 22:54:57 EST
Julius Bairaktaris wrote:
A frame received on a port that offloads a bridge carries
offload_fwd_mark (dsa_default_offload_fwd_mark()). A tc mirred redirect
or mirror, or an nft netdev fwd or dup, from that port to a standalone
port of the same switch keeps the mark, and vsc73xx_xmit() and
sja1105_imprecise_xmit() then look up the bridge of the standalone port:
dsa_port_bridge_dev_get() returns NULL and br_vlan_enabled() dereferences
it, in softirq, for every such frame. The same happens when a port leaves
its bridge while a frame that the bridge marked is still queued for it.
Both taggers also read dp->bridge twice, once for the device and once
for the number.
Read dp->bridge once. When the port is not in a bridge, it is a
standalone port, so send the frame in its standalone VLAN, to the port
alone, with the PCP of its TX queue, as for a frame without
offload_fwd_mark.
Both drivers are fixed in one commit because they share the mechanism.
Found by an LLM review (Claude), and reproduced in QEMU with dsa_loop.
Fixes: b6ad86e6ad6c ("net: dsa: sja1105: add bridge TX data plane offload based on tag_8021q")
Fixes: 6c87e1a47928 ("net: dsa: vsc73xx: introduce tag 8021q for vsc73xx")
Signed-off-by: Julius Bairaktaris <julius@xxxxxxxxxxxxxx>
- net/dsa/tag_sja1105.c:221-224 (sja1105_imprecise_xmit):
When skb->offload_fwd_mark is set and !bridge, the new fallback inside
sja1105_imprecise_xmit() immediately sends the frame through dsa_8021q_xmit()
in the port's standalone tag_8021q VLAN, bypassing sja1105_is_link_local(skb)
in both sja1105_xmit() (lines 289-295, SPI management routes via
sja1105_defer_xmit()) and sja1110_xmit() (lines 320-351, in-band control
extension header/trailer). SJA1105/SJA1110 hardware matches 01:80:C2:xx:xx:xx
and PTP 01:1B:19:xx:xx:xx (include/linux/dsa/sja1105.h:22-26) in its
management filters, so link-local or PTP frames carrying offload_fwd_mark
(e.g., redirected from another switch's bridged port or bridge-forwarded with
group_fwd_mask / PTP multicast right before port leave) must take the control
path, not dsa_8021q_xmit(). Fix cleanly by checking READ_ONCE(dp->bridge) in
sja1105_xmit() and sja1110_xmit() and only calling sja1105_imprecise_xmit(skb,
netdev, bridge) when bridge != NULL, letting !bridge fall through to the normal
standalone path (which also removes the extra pcp parameter).
- tag_vsc73xx_8021q) net/dsa/tag_sja1105.c:282,313, net/dsa/tag_vsc73xx_8021q.c:19:
Same root architectural gap as Patch 3/6: tc mirred and nft netdev fwd/dup do
not clear RX skb->offload_fwd_mark on egress redirect, so redirecting from a
bridged ingress port to a *bridged* sja1105/vsc73xx port (e.g. in another
bridge) still enters imprecise bridge-wide TX forwarding (or returns an
untagged/wrong-VLAN frame