]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: dsa: sja1105: fix checks for VLAN state in redirect action
authorVladimir Oltean <vladimir.oltean@nxp.com>
Tue, 16 Jun 2020 23:58:42 +0000 (02:58 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 19 Jun 2020 03:20:46 +0000 (20:20 -0700)
This action requires the VLAN awareness state of the switch to be of the
same type as the key that's being added:

- If the switch is unaware of VLAN, then the tc filter key must only
  contain the destination MAC address.
- If the switch is VLAN-aware, the key must also contain the VLAN ID and
  PCP.

But this check doesn't work unless we verify the VLAN awareness state on
both the "if" and the "else" branches.

Fixes: b350775e6575 ("net: dsa: sja1105: support flow-based redirection via virtual links")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/sja1105/sja1105_vl.c

index 32eca3e660e1e5896932a60063a3a00ae0db352b..a176f39a052b070ba0a8ed51dada9089e5dbf8fd 100644 (file)
@@ -342,7 +342,9 @@ int sja1105_vl_redirect(struct sja1105_private *priv, int port,
                NL_SET_ERR_MSG_MOD(extack,
                                   "Can only redirect based on DMAC");
                return -EOPNOTSUPP;
-       } else if (key->type != SJA1105_KEY_VLAN_AWARE_VL) {
+       } else if ((priv->vlan_state == SJA1105_VLAN_BEST_EFFORT ||
+                   priv->vlan_state == SJA1105_VLAN_FILTERING_FULL) &&
+                  key->type != SJA1105_KEY_VLAN_AWARE_VL) {
                NL_SET_ERR_MSG_MOD(extack,
                                   "Can only redirect based on {DMAC, VID, PCP}");
                return -EOPNOTSUPP;