[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241215163334.615427-2-robert.hodaszi@digi.com>
Date: Sun, 15 Dec 2024 17:33:33 +0100
From: Robert Hodaszi <robert.hodaszi@...i.com>
To: netdev@...r.kernel.org,
vladimir.oltean@....com,
claudiu.manoil@....com,
alexandre.belloni@...tlin.com,
UNGLinuxDriver@...rochip.com,
andrew@...n.ch,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
horms@...nel.org,
linux-kernel@...r.kernel.org
Cc: Robert Hodaszi <robert.hodaszi@...i.com>
Subject: [PATCH RFC net 1/2] net: dsa: provide a way to exclude switch ports from VLAN untagging
Even if a switch driver sets 'untag_vlan_aware_bridge_pvid' or
'untag_bridge_pvid', it may not enable tagging on one or more ports
(VLAN-unaware port). Without a way to exclude these ports,
dsa_software_vlan_untag() untags packets it shouldn't, and so it
corrupts the packet.
That happens currently with the felix driver. The driver always sets
'untag_vlan_aware_bridge_pvid', but enables inner tags
(push_inner_tag=1) only when VLAN-filtering is enabled.
To exclude a port from untagging, set dp->not_tagged=1. The inverse
logic is to keep backward compatibility, and avoid the need to
potentially change currently working users.
Fixes: f1288fd7293b ("net: dsa: felix: fix VLAN tag loss on CPU reception with ocelot-8021q")
Signed-off-by: Robert Hodaszi <robert.hodaszi@...i.com>
---
include/net/dsa.h | 7 +++++++
net/dsa/tag.h | 4 ++++
2 files changed, 11 insertions(+)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 72ae65e7246a..99b1267f0c46 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -289,6 +289,13 @@ struct dsa_port {
u8 setup:1;
+ /* Use this to mark a switch port as "untagged", to avoid
+ * dsa_software_vlan_untag() do a VLAN untagging on it if
+ * ds->untag_bridge_pvid or ds->untag_vlan_aware_bridge_pvid is set to
+ * true
+ */
+ u8 not_tagged:1;
+
struct device_node *dn;
unsigned int ageing_time;
diff --git a/net/dsa/tag.h b/net/dsa/tag.h
index d5707870906b..c3d76a49b1c6 100644
--- a/net/dsa/tag.h
+++ b/net/dsa/tag.h
@@ -155,6 +155,10 @@ static inline struct sk_buff *dsa_software_vlan_untag(struct sk_buff *skb)
if (!br)
return skb;
+ /* This switch port is not tagged, no need for untagging */
+ if (dp->not_tagged)
+ return skb;
+
/* Move VLAN tag from data to hwaccel */
if (!skb_vlan_tag_present(skb)) {
skb = skb_vlan_untag(skb);
--
2.43.0
Powered by blists - more mailing lists