Skip to content

Commit 032a954

Browse files
Noltarikuba-moo
authored andcommitted
net: dsa: tag_brcm: legacy: fix daisy-chained switches
When BCM63xx internal switches are connected to switches with a 4-byte Broadcom tag, it does not identify the packet as VLAN tagged, so it adds one based on its PVID (which is likely 0). Right now, the packet is received by the BCM63xx internal switch and the 6-byte tag is properly processed. The next step would to decode the corresponding 4-byte tag. However, the internal switch adds an invalid VLAN tag after the 6-byte tag and the 4-byte tag handling fails. In order to fix this we need to remove the invalid VLAN tag after the 6-byte tag before passing it to the 4-byte tag decoding. Fixes: 964dbf1 ("net: dsa: tag_brcm: add support for legacy tags") Signed-off-by: Álvaro Fernández Rojas <[email protected]> Reviewed-by: Michal Swiatkowski <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f038f39 commit 032a954

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
@@ -7,6 +7,7 @@
77

88
#include <linux/dsa/brcm.h>
99
#include <linux/etherdevice.h>
10+
#include <linux/if_vlan.h>
1011
#include <linux/list.h>
1112
#include <linux/slab.h>
1213

@@ -252,6 +253,7 @@ static struct sk_buff *brcm_leg_tag_xmit(struct sk_buff *skb,
252253
static struct sk_buff *brcm_leg_tag_rcv(struct sk_buff *skb,
253254
struct net_device *dev)
254255
{
256+
int len = BRCM_LEG_TAG_LEN;
255257
int source_port;
256258
u8 *brcm_tag;
257259

@@ -266,12 +268,16 @@ static struct sk_buff *brcm_leg_tag_rcv(struct sk_buff *skb,
266268
if (!skb->dev)
267269
return NULL;
268270

271+
/* VLAN tag is added by BCM63xx internal switch */
272+
if (netdev_uses_dsa(skb->dev))
273+
len += VLAN_HLEN;
274+
269275
/* Remove Broadcom tag and update checksum */
270-
skb_pull_rcsum(skb, BRCM_LEG_TAG_LEN);
276+
skb_pull_rcsum(skb, len);
271277

272278
dsa_default_offload_fwd_mark(skb);
273279

274-
dsa_strip_etype_header(skb, BRCM_LEG_TAG_LEN);
280+
dsa_strip_etype_header(skb, len);
275281

276282
return skb;
277283
}

0 commit comments

Comments
 (0)