]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mlxsw: spectrum_router: Mark RIF index as taken before creation
authorNir Dotan <nird@mellanox.com>
Sun, 20 Jan 2019 06:50:46 +0000 (06:50 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sun, 20 Jan 2019 19:12:57 +0000 (11:12 -0800)
The presence of an allocated RIF in mlxsw_sp->router->rifs[rif_index] marks
that rif_index as taken.
Set the marking of a taken RIF to happen before calling ops->create in
order to allow creation of a GRE underlay RIF, which may be allocated and
created as part of an overlay RIF creation.

Signed-off-by: Nir Dotan <nird@mellanox.com>
Reviewed-by: Petr Machata <petrm@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_router.c

index c55bd5af034122f58c87b5a889c3ab1f22d3b63d..1cac3836550389db113c0d6d5d6a9140d5f57407 100644 (file)
@@ -6303,6 +6303,7 @@ mlxsw_sp_rif_create(struct mlxsw_sp *mlxsw_sp,
                goto err_rif_alloc;
        }
        dev_hold(rif->dev);
+       mlxsw_sp->router->rifs[rif_index] = rif;
        rif->mlxsw_sp = mlxsw_sp;
        rif->ops = ops;
 
@@ -6329,7 +6330,6 @@ mlxsw_sp_rif_create(struct mlxsw_sp *mlxsw_sp,
        }
 
        mlxsw_sp_rif_counters_alloc(rif);
-       mlxsw_sp->router->rifs[rif_index] = rif;
 
        return rif;
 
@@ -6341,6 +6341,7 @@ err_configure:
        if (fid)
                mlxsw_sp_fid_put(fid);
 err_fid_get:
+       mlxsw_sp->router->rifs[rif_index] = NULL;
        dev_put(rif->dev);
        kfree(rif);
 err_rif_alloc:
@@ -6361,7 +6362,6 @@ static void mlxsw_sp_rif_destroy(struct mlxsw_sp_rif *rif)
        mlxsw_sp_router_rif_gone_sync(mlxsw_sp, rif);
        vr = &mlxsw_sp->router->vrs[rif->vr_id];
 
-       mlxsw_sp->router->rifs[rif->rif_index] = NULL;
        mlxsw_sp_rif_counters_free(rif);
        for (i = 0; i < MLXSW_SP_L3_PROTO_MAX; i++)
                mlxsw_sp_mr_rif_del(vr->mr_table[i], rif);
@@ -6369,6 +6369,7 @@ static void mlxsw_sp_rif_destroy(struct mlxsw_sp_rif *rif)
        if (fid)
                /* Loopback RIFs are not associated with a FID. */
                mlxsw_sp_fid_put(fid);
+       mlxsw_sp->router->rifs[rif->rif_index] = NULL;
        dev_put(rif->dev);
        kfree(rif);
        vr->rif_count--;