mlxsw: spectrum: Clear VLAN filters during port initialization
authorIdo Schimmel <idosch@mellanox.com>
Thu, 26 Sep 2019 11:43:38 +0000 (14:43 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 27 Sep 2019 18:33:19 +0000 (20:33 +0200)
When a port is created, its VLAN filters are not cleared by the
firmware. This causes tagged packets to be later dropped by the ingress
STP filters, which default to DISCARD state.

The above did not matter much until commit b5ce611fd96e ("mlxsw:
spectrum: Add devlink-trap support") where we exposed the drop reason to
users.

Without this patch, the drop reason users will see is not consistent. If
a port is enslaved to a VLAN-aware bridge and a packet with an invalid
VLAN tries to ingress the bridge, it will be dropped due to ingress STP
filter. If the VLAN is later enabled and then disabled, the packet will
be dropped by the ingress VLAN filter despite the above being a
seemingly NOP operation.

Fix this by clearing all the VLAN filters during port initialization.
Adjust the test accordingly.

Fixes: b5ce611fd96e ("mlxsw: spectrum: Add devlink-trap support")
Reported-by: Alex Kushnarov <alexanderk@mellanox.com>
Tested-by: Alex Kushnarov <alexanderk@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l2_drops.sh

index dd234cf7b39df18c52694bdd5a5d098a90c1b750..dcf9562bce8a9773d7d9d155f5371032275756f9 100644 (file)
@@ -3771,6 +3771,14 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
                goto err_port_qdiscs_init;
        }
 
+       err = mlxsw_sp_port_vlan_set(mlxsw_sp_port, 0, VLAN_N_VID - 1, false,
+                                    false);
+       if (err) {
+               dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to clear VLAN filter\n",
+                       mlxsw_sp_port->local_port);
+               goto err_port_vlan_clear;
+       }
+
        err = mlxsw_sp_port_nve_init(mlxsw_sp_port);
        if (err) {
                dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to initialize NVE\n",
@@ -3818,6 +3826,7 @@ err_port_vlan_create:
 err_port_pvid_set:
        mlxsw_sp_port_nve_fini(mlxsw_sp_port);
 err_port_nve_init:
+err_port_vlan_clear:
        mlxsw_sp_tc_qdisc_fini(mlxsw_sp_port);
 err_port_qdiscs_init:
        mlxsw_sp_port_fids_fini(mlxsw_sp_port);
index 5dcdfa20fc6c5f62320977d312fc1b84d1e839a0..126caf28b529b6ef6331831b77e8e4152dd97ca4 100755 (executable)
@@ -224,13 +224,6 @@ ingress_vlan_filter_test()
        local vid=10
 
        bridge vlan add vid $vid dev $swp2 master
-       # During initialization the firmware enables all the VLAN filters and
-       # the driver does not turn them off since the traffic will be discarded
-       # by the STP filter whose default is DISCARD state. Add the VID on the
-       # ingress bridge port and then remove it to make sure it is not member
-       # in the VLAN.
-       bridge vlan add vid $vid dev $swp1 master
-       bridge vlan del vid $vid dev $swp1 master
 
        RET=0