net/mlx5e: Allow MAC invalidation while spoofchk is ON [Linux 5.0]

net/mlx5e: Allow MAC invalidation while spoofchk is ON [Linux 5.0]

This Linux kernel change "net/mlx5e: Allow MAC invalidation while spoofchk is ON" is included in the Linux 5.0 release. This change is authored by Aya Levin <ayal [at]> on Mon Dec 24 09:48:42 2018 +0200. The commit for this change in Linux stable tree is 9d2cbdc (patch).

net/mlx5e: Allow MAC invalidation while spoofchk is ON

Prior to this patch the driver prohibited spoof checking on invalid MAC.
Now the user can set this configuration if it wishes to.

This is required since libvirt might invalidate the VF Mac by setting it
to zero, while spoofcheck is ON.

Fixes: 1ab2068a4c66 ("net/mlx5: Implement vports admin state backup/restore")
Signed-off-by: Aya Levin <[email protected]>
Reviewed-by: Eran Ben Elisha <[email protected]>
Signed-off-by: Saeed Mahameed <[email protected]>

There are 18 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index ab7a038..5b492b6 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1134,13 +1134,6 @@ static int esw_vport_ingress_config(struct mlx5_eswitch *esw,
    int err = 0;
    u8 *smac_v;

-   if (vport->info.spoofchk && !is_valid_ether_addr(vport->info.mac)) {
-       mlx5_core_warn(esw->dev,
-                  "vport[%d] configure ingress rules failed, illegal mac with spoofchk\n",
-                  vport->vport);
-       return -EPERM;
-   }
    esw_vport_cleanup_ingress_rules(esw, vport);

    if (!vport->info.vlan && !vport->info.qos && !vport->info.spoofchk) {
@@ -1827,13 +1820,10 @@ int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
    evport = &esw->vports[vport];

-   if (evport->info.spoofchk && !is_valid_ether_addr(mac)) {
+   if (evport->info.spoofchk && !is_valid_ether_addr(mac))
-                  "MAC invalidation is not allowed when spoofchk is on, vport(%d)\n",
+                  "Set invalid MAC while spoofchk is on, vport(%d)\n",
-       err = -EPERM;
-       goto unlock;
-   }

    err = mlx5_modify_nic_vport_mac_address(esw->dev, vport, mac);
    if (err) {
@@ -1979,6 +1969,10 @@ int mlx5_eswitch_set_vport_spoofchk(struct mlx5_eswitch *esw,
    evport = &esw->vports[vport];
    pschk = evport->info.spoofchk;
    evport->info.spoofchk = spoofchk;
+   if (pschk && !is_valid_ether_addr(evport->info.mac))
+       mlx5_core_warn(esw->dev,
+                  "Spoofchk in set while MAC is invalid, vport(%d)\n",
+                  evport->vport);
    if (evport->enabled && esw->mode == SRIOV_LEGACY)
        err = esw_vport_ingress_config(esw, evport);
    if (err)

Leave a Reply

Your email address will not be published. Required fields are marked *