net: dsa: tag_brcm: legacy: fix untagged rx on unbridged ports for bcm63xx

[ Upstream commit 3d18a84edd ]

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 ed409f3bba ("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: 964dbf186e ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Jonas Gorski
2025-10-27 20:46:21 +01:00
committed by Greg Kroah-Hartman
parent fc4bb4ed43
commit 02c492301a

View File

@@ -218,12 +218,14 @@ static struct sk_buff *brcm_leg_tag_rcv(struct sk_buff *skb,
{ {
int len = BRCM_LEG_TAG_LEN; int len = BRCM_LEG_TAG_LEN;
int source_port; int source_port;
__be16 *proto;
u8 *brcm_tag; u8 *brcm_tag;
if (unlikely(!pskb_may_pull(skb, BRCM_LEG_TAG_LEN + VLAN_HLEN))) if (unlikely(!pskb_may_pull(skb, BRCM_LEG_TAG_LEN + VLAN_HLEN)))
return NULL; return NULL;
brcm_tag = dsa_etype_header_pos_rx(skb); brcm_tag = dsa_etype_header_pos_rx(skb);
proto = (__be16 *)(brcm_tag + BRCM_LEG_TAG_LEN);
source_port = brcm_tag[5] & BRCM_LEG_PORT_ID; source_port = brcm_tag[5] & BRCM_LEG_PORT_ID;
@@ -231,8 +233,12 @@ static struct sk_buff *brcm_leg_tag_rcv(struct sk_buff *skb,
if (!skb->dev) if (!skb->dev)
return NULL; return NULL;
/* VLAN tag is added by BCM63xx internal switch */ /* The internal switch in BCM63XX SoCs always tags on egress on the CPU
if (netdev_uses_dsa(skb->dev)) * port. We use VID 0 internally for untagged traffic, so strip the tag
* if the TCI field is all 0, and keep it otherwise to also retain
* e.g. 802.1p tagged packets.
*/
if (proto[0] == htons(ETH_P_8021Q) && proto[1] == 0)
len += VLAN_HLEN; len += VLAN_HLEN;
/* Remove Broadcom tag and update checksum */ /* Remove Broadcom tag and update checksum */