Revert "net/mlx5e: E-Switch, Initialize eswitch only if eswitch manager" [Linux 5.0]

This Linux kernel change "Revert “net/mlx5e: E-Switch, Initialize eswitch only if eswitch manager”" is included in the Linux 5.0 release. This change is authored by Bodong Wang <bodong [at]> on Sun Jan 13 22:47:26 2019 -0600. The commit for this change in Linux stable tree is 4e046de (patch).

Revert "net/mlx5e: E-Switch, Initialize eswitch only if eswitch manager"

This reverts commit 5f5991f36dce1e69dd8bd7495763eec2e28f08e7.

With the original commit, eswitch instance will not be initialized for
a function which is vport group manager but not eswitch manager such as
host PF on SmartNIC (BlueField) card. This will result in a kernel crash
when such a vport group manager is trying to access vports in its group.
E.g, PF vport manager (not eswitch manager) tries to configure the MAC
of its VF vport, a kernel trace will happen similar as bellow:

 BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
 RIP: 0010:mlx5_eswitch_get_vport_config+0xc/0x180 [mlx5_core]

Fixes: 5f5991f36dce ("net/mlx5e: E-Switch, Initialize eswitch only if eswitch manager")
Signed-off-by: Bodong Wang <[email protected]>
Reported-by: Yuval Avnery <[email protected]>
Reviewed-by: Daniel Jurgens <[email protected]>
Reviewed-by: Or Gerlitz <[email protected]>
Signed-off-by: Saeed Mahameed <[email protected]>

There are 4 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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index a44ea7b..ab7a038 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1728,7 +1728,7 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev)
    int vport_num;
    int err;

-   if (!MLX5_ESWITCH_MANAGER(dev))
+   if (!MLX5_VPORT_MANAGER(dev))
        return 0;

@@ -1797,7 +1797,7 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev)

 void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw)
-   if (!esw || !MLX5_ESWITCH_MANAGER(esw->dev))
+   if (!esw || !MLX5_VPORT_MANAGER(esw->dev))

    esw_info(esw->dev, "cleanup\n");

Leave a Reply

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