[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID:
<MR1P264MB3681CCB3C20AD95E1B20C878F84F2@MR1P264MB3681.FRAP264.PROD.OUTLOOK.COM>
Date: Fri, 25 Oct 2024 13:46:48 +0000
From: Hervé Gourmelon <herve.gourmelon@...nops.com>
To: Andrew Lunn <andrew@...n.ch>, Florian Fainelli <f.fainelli@...il.com>,
Vivien Didelot <vivien.didelot@...il.com>
CC: "netdev@...r.kernel.org" <netdev@...r.kernel.org>, Vladimir Oltean
<vladimir.oltean@....com>, Tobias Waldekranz <tobias@...dekranz.com>
Subject: [PATCH 1/1] net: dsa: fix tag_dsa.c for untagged VLANs
Hello,
Trying to set up an untagged VLAN bridge on a DSA architecture of
mv88e6xxx switches, I realized that whenever I tried to emit a
'From_CPU' or 'Forward' DSA packet, it would always egress with an
unwanted 802.1Q header on the bridge port.
Taking a closer look at the code, I saw that the Src_Tagged bit of the
DSA header (1st octet, bit 5) was always set to '1' due to the
following line:
dsa_header[0] = (cmd << 6) | 0x20 | tag_dev;
which is wrong: Src_Tagged should be reset if we need the frame to
egress untagged from the bridge port.
So I added a few lines to check whether the port is a member of a VLAN
bridge, and whether the VLAN is set to egress untagged from the port,
before setting or resetting the Src_Tagged bit as needed.
Signed-off-by: Hervé Gourmelon <herve.gourmelon@...nops.com>
---
net/dsa/tag_dsa.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/net/dsa/tag_dsa.c b/net/dsa/tag_dsa.c
index 2a2c4fb61a65..14b4d8c3dc8a 100644
--- a/net/dsa/tag_dsa.c
+++ b/net/dsa/tag_dsa.c
@@ -163,6 +163,21 @@ static struct sk_buff *dsa_xmit_ll(struct sk_buff *skb, struct net_device *dev,
*/
if (skb->protocol == htons(ETH_P_8021Q) &&
(!br_dev || br_vlan_enabled(br_dev))) {
+ struct bridge_vlan_info br_info;
+ u16 vid = 0;
+ u16 src_tagged = 1;
+ u8 *vid_ptr;
+ int err = 0;
+
+ /* Read VID from VLAN 802.1Q tag */
+ vid_ptr = dsa_etype_header_pos_tx(skb);
+ vid = ((vid_ptr[2] & 0x0F) << 8 | vid_ptr[3]);
+ /* Get VLAN info for vid on net_device *dev (dsa slave) */
+ err = br_vlan_get_info_rcu(dev, vid, &br_info);
+ if (err == 0 && (br_info.flags & BRIDGE_VLAN_INFO_UNTAGGED)) {
+ src_tagged = 0;
+ }
+
if (extra) {
skb_push(skb, extra);
dsa_alloc_etype_header(skb, extra);
@@ -170,11 +185,11 @@ static struct sk_buff *dsa_xmit_ll(struct sk_buff *skb, struct net_device *dev,
/* Construct tagged DSA tag from 802.1Q tag. */
dsa_header = dsa_etype_header_pos_tx(skb) + extra;
- dsa_header[0] = (cmd << 6) | 0x20 | tag_dev;
+ dsa_header[0] = (cmd << 6) | (src_tagged << 5) | tag_dev;
dsa_header[1] = tag_port << 3;
/* Move CFI field from byte 2 to byte 1. */
- if (dsa_header[2] & 0x10) {
+ if (src_tagged == 1 && dsa_header[2] & 0x10) {
dsa_header[1] |= 0x01;
dsa_header[2] &= ~0x10;
}
--
2.34.1
Powered by blists - more mailing lists