mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robert Hodaszi <robert.hodaszi@digi.com>
To: netdev@vger.kernel.org, vladimir.oltean@nxp.com,
	claudiu.manoil@nxp.com, alexandre.belloni@bootlin.com,
	UNGLinuxDriver@microchip.com, andrew@lunn.ch,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org,
	linux-kernel@vger.kernel.org
Cc: Robert Hodaszi <robert.hodaszi@digi.com>
Subject: [PATCH RFC net 1/2] net: dsa: provide a way to exclude switch ports from VLAN untagging
Date: Sun, 15 Dec 2024 17:33:33 +0100	[thread overview]
Message-ID: <20241215163334.615427-2-robert.hodaszi@digi.com> (raw)
In-Reply-To: <20241215163334.615427-1-robert.hodaszi@digi.com>

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@digi.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


  reply	other threads:[~2024-12-15 16:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-15 16:33 [PATCH RFC net 0/2] net: dsa: felix: fix VLAN-unaware reception Robert Hodaszi
2024-12-15 16:33 ` Robert Hodaszi [this message]
2024-12-15 16:33 ` [PATCH RFC net 2/2] net: dsa: felix: fix reception from VLAN-unaware ports Robert Hodaszi
2024-12-15 17:09 ` [PATCH RFC net 0/2] net: dsa: felix: fix VLAN-unaware reception Vladimir Oltean
2024-12-16 10:10   ` Robert Hodaszi
2024-12-16 13:51     ` Vladimir Oltean
2024-12-16 14:39       ` Robert Hodaszi
2024-12-16 14:48         ` Vladimir Oltean
2024-12-17 10:15           ` Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241215163334.615427-2-robert.hodaszi@digi.com \
    --to=robert.hodaszi@digi.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vladimir.oltean@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®