diff mbox series

[RFC,4/6] net: dsa: tag_8021q: skip disabled ports

Message ID 20200504124325.26758-5-olteanv@gmail.com
State New
Headers show
Series None | expand

Commit Message

Vladimir Oltean May 4, 2020, 12:43 p.m. UTC
From: Vladimir Oltean <vladimir.oltean@nxp.com>

Not only is it not needed to program dsa_8021q VLANs into ports that are
not used, but it also makes validation impossible, given the fact that
port == dsa_upstream_port(ds, port) for a port that is disabled. So when
a user port wants to install its rx_vid into us (we the disabled port),
think that we are in fact the CPU port, so we want the flags to be
egress-tagged (which they aren't). So instead of trying to make
dsa_upstream_port return something more sensible for disabled ports,
skip this nonsense altogether.

Because we didn't have VID validation until now, there's no reason to
treat this patch as a bugfix.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 net/dsa/tag_8021q.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/net/dsa/tag_8021q.c b/net/dsa/tag_8021q.c
index 158584153e15..3958f426d60e 100644
--- a/net/dsa/tag_8021q.c
+++ b/net/dsa/tag_8021q.c
@@ -239,7 +239,7 @@  int dsa_port_setup_8021q_tagging(struct dsa_switch *ds, int port, bool enabled)
 	for (i = 0; i < ds->num_ports; i++) {
 		u16 flags;
 
-		if (i == upstream)
+		if (!dsa_is_user_port(ds, i))
 			continue;
 		else if (i == port)
 			/* The RX VID is pvid on this port */
@@ -302,6 +302,8 @@  int dsa_8021q_vid_validate(struct dsa_switch *ds, int port, u16 vid, u16 flags)
 		return -EPERM;
 
 	for (other_port = 0; other_port < ds->num_ports; other_port++) {
+		if (!dsa_is_user_port(ds, other_port))
+			continue;
 		if (vid == dsa_8021q_rx_vid(ds, other_port)) {
 			rx_vid_of = other_port;
 			break;