Skip to content

Commit 3d18a84

Browse files
KanjiMonsterkuba-moo
authored andcommitted
net: dsa: tag_brcm: legacy: fix untagged rx on unbridged ports for bcm63xx
The internal switch on BCM63XX SoCs will unconditionally add 802.1Q VLAN tags on egress to CPU when 802.1Q mode is enabled. We do this unconditionally since commit ed409f3 ("net: dsa: b53: Configure VLANs while not filtering"). This is fine for VLAN aware bridges, but for standalone ports and vlan unaware bridges this means all packets are tagged with the default VID, which is 0. While the kernel will treat that like untagged, this can break userspace applications processing raw packets, expecting untagged traffic, like STP daemons. This also breaks several bridge tests, where the tcpdump output then does not match the expected output anymore. Since 0 isn't a valid VID, just strip out the VLAN tag if we encounter it, unless the priority field is set, since that would be a valid tag again. Fixes: 964dbf1 ("net: dsa: tag_brcm: add support for legacy tags") Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com> Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Link: https://patch.msgid.link/20251027194621.133301-1-jonas.gorski@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 5a89b27 commit 3d18a84

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

net/dsa/tag_brcm.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,21 +224,27 @@ static struct sk_buff *brcm_leg_tag_rcv(struct sk_buff *skb,
224224
{
225225
int len = BRCM_LEG_TAG_LEN;
226226
int source_port;
227+
__be16 *proto;
227228
u8 *brcm_tag;
228229

229230
if (unlikely(!pskb_may_pull(skb, BRCM_LEG_TAG_LEN + VLAN_HLEN)))
230231
return NULL;
231232

232233
brcm_tag = dsa_etype_header_pos_rx(skb);
234+
proto = (__be16 *)(brcm_tag + BRCM_LEG_TAG_LEN);
233235

234236
source_port = brcm_tag[5] & BRCM_LEG_PORT_ID;
235237

236238
skb->dev = dsa_conduit_find_user(dev, 0, source_port);
237239
if (!skb->dev)
238240
return NULL;
239241

240-
/* VLAN tag is added by BCM63xx internal switch */
241-
if (netdev_uses_dsa(skb->dev))
242+
/* The internal switch in BCM63XX SoCs always tags on egress on the CPU
243+
* port. We use VID 0 internally for untagged traffic, so strip the tag
244+
* if the TCI field is all 0, and keep it otherwise to also retain
245+
* e.g. 802.1p tagged packets.
246+
*/
247+
if (proto[0] == htons(ETH_P_8021Q) && proto[1] == 0)
242248
len += VLAN_HLEN;
243249

244250
/* Remove Broadcom tag and update checksum */

0 commit comments

Comments
 (0)