mlxsw: spectrum_switchdev: Add support for locked FDB notifications
authorIdo Schimmel <idosch@nvidia.com>
Tue, 8 Nov 2022 10:47:15 +0000 (11:47 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 10 Nov 2022 03:06:15 +0000 (19:06 -0800)
In Spectrum, learning happens in parallel to the security checks.
Therefore, regardless of the result of the security checks, a learning
notification will be generated by the device and polled later on by the
driver.

Currently, the driver reacts to learning notifications by programming
corresponding FDB entries to the device. When a port is locked (i.e.,
has security checks enabled), this can no longer happen, as otherwise
any host will blindly gain authorization.

Instead, notify the learned entry as a locked entry to the bridge driver
that will in turn notify it to user space, in case MAB is enabled. User
space can then decide to authorize the host by clearing the "locked"
flag, which will cause the entry to be programmed to the device.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c

index 0fbefa43f9b11a9b0d0565c63488d3ce1eb7b64b..f336be77019fb425fcd02d7e25d1d861f7b769b7 100644 (file)
@@ -2942,6 +2942,12 @@ static void mlxsw_sp_fdb_notify_mac_process(struct mlxsw_sp *mlxsw_sp,
        vid = bridge_device->vlan_enabled ? mlxsw_sp_port_vlan->vid : 0;
        evid = mlxsw_sp_port_vlan->vid;
 
+       if (adding && mlxsw_sp_port->security) {
+               mlxsw_sp_fdb_call_notifiers(SWITCHDEV_FDB_ADD_TO_BRIDGE, mac,
+                                           vid, bridge_port->dev, false, true);
+               return;
+       }
+
 do_fdb_op:
        err = mlxsw_sp_port_fdb_uc_op(mlxsw_sp, local_port, mac, fid, evid,
                                      adding, true);
@@ -3006,6 +3012,12 @@ static void mlxsw_sp_fdb_notify_mac_lag_process(struct mlxsw_sp *mlxsw_sp,
        vid = bridge_device->vlan_enabled ? mlxsw_sp_port_vlan->vid : 0;
        lag_vid = mlxsw_sp_port_vlan->vid;
 
+       if (adding && mlxsw_sp_port->security) {
+               mlxsw_sp_fdb_call_notifiers(SWITCHDEV_FDB_ADD_TO_BRIDGE, mac,
+                                           vid, bridge_port->dev, false, true);
+               return;
+       }
+
 do_fdb_op:
        err = mlxsw_sp_port_fdb_uc_lag_op(mlxsw_sp, lag_id, mac, fid, lag_vid,
                                          adding, true);