Commit 4c8594ad authored by Roi Dayan's avatar Roi Dayan Committed by Saeed Mahameed
Browse files

net/mlx5e: CT: Fix freeing ct_label mapping



Add missing mapping remove call when removing ct rule,
as the mapping was allocated when ct rule was adding with ct_label.
Also there is a missing mapping remove call in error flow.

Fixes: 54b154ec ("net/mlx5e: CT: Map 128 bits labels to 32 bit map ID")
Signed-off-by: default avatarRoi Dayan <roid@mellanox.com>
Reviewed-by: default avatarEli Britstein <elibr@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 12a240a4
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -699,6 +699,7 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,
err_rule:
	mlx5e_mod_hdr_detach(ct_priv->esw->dev,
			     &esw->offloads.mod_hdr, zone_rule->mh);
	mapping_remove(ct_priv->labels_mapping, attr->ct_attr.ct_labels_id);
err_mod_hdr:
	kfree(spec);
	return err;
@@ -958,8 +959,18 @@ mlx5_tc_ct_add_no_trk_match(struct mlx5e_priv *priv,
	return 0;
}

void mlx5_tc_ct_match_del(struct mlx5e_priv *priv, struct mlx5_ct_attr *ct_attr)
{
	struct mlx5_tc_ct_priv *ct_priv = mlx5_tc_ct_get_ct_priv(priv);

	if (!ct_priv || !ct_attr->ct_labels_id)
		return;

	mapping_remove(ct_priv->labels_mapping, ct_attr->ct_labels_id);
}

int
mlx5_tc_ct_parse_match(struct mlx5e_priv *priv,
mlx5_tc_ct_match_add(struct mlx5e_priv *priv,
		     struct mlx5_flow_spec *spec,
		     struct flow_cls_offload *f,
		     struct mlx5_ct_attr *ct_attr,
+16 −10
Original line number Diff line number Diff line
@@ -87,8 +87,11 @@ mlx5_tc_ct_init(struct mlx5_rep_uplink_priv *uplink_priv);
void
mlx5_tc_ct_clean(struct mlx5_rep_uplink_priv *uplink_priv);

void
mlx5_tc_ct_match_del(struct mlx5e_priv *priv, struct mlx5_ct_attr *ct_attr);

int
mlx5_tc_ct_parse_match(struct mlx5e_priv *priv,
mlx5_tc_ct_match_add(struct mlx5e_priv *priv,
		     struct mlx5_flow_spec *spec,
		     struct flow_cls_offload *f,
		     struct mlx5_ct_attr *ct_attr,
@@ -130,8 +133,11 @@ mlx5_tc_ct_clean(struct mlx5_rep_uplink_priv *uplink_priv)
{
}

static inline void
mlx5_tc_ct_match_del(struct mlx5e_priv *priv, struct mlx5_ct_attr *ct_attr) {}

static inline int
mlx5_tc_ct_parse_match(struct mlx5e_priv *priv,
mlx5_tc_ct_match_add(struct mlx5e_priv *priv,
		     struct mlx5_flow_spec *spec,
		     struct flow_cls_offload *f,
		     struct mlx5_ct_attr *ct_attr,
+4 −2
Original line number Diff line number Diff line
@@ -1312,6 +1312,8 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,
		}
	kvfree(attr->parse_attr);

	mlx5_tc_ct_match_del(priv, &flow->esw_attr->ct_attr);

	if (attr->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)
		mlx5e_detach_mod_hdr(priv, flow);

@@ -4399,7 +4401,7 @@ __mlx5e_add_fdb_flow(struct mlx5e_priv *priv,
		goto err_free;

	/* actions validation depends on parsing the ct matches first */
	err = mlx5_tc_ct_parse_match(priv, &parse_attr->spec, f,
	err = mlx5_tc_ct_match_add(priv, &parse_attr->spec, f,
				   &flow->esw_attr->ct_attr, extack);
	if (err)
		goto err_free;