Skip to content

Commit aa9c44b

Browse files
Jianbo Liukuba-moo
authored andcommitted
net/mlx5e: Fix leak of Geneve TLV option object
Previously, a unique tunnel id was added for the matching on TC non-zero chains, to support inner header rewrite with goto action. Later, it was used to support VF tunnel offload for vxlan, then for Geneve and GRE. To support VF tunnel, a temporary mlx5_flow_spec is used to parse tunnel options. For Geneve, if there is TLV option, a object is created, or refcnt is added if already exists. But the temporary mlx5_flow_spec is directly freed after parsing, which causes the leak because no information regarding the object is saved in flow's mlx5_flow_spec, which is used to free the object when deleting the flow. To fix the leak, call mlx5_geneve_tlv_option_del() before free the temporary spec if it has TLV object. Fixes: 521933c ("net/mlx5e: Support Geneve and GRE with VF tunnel offload") Signed-off-by: Jianbo Liu <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Reviewed-by: Alex Lazar <[email protected]> Signed-off-by: Mark Bloch <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b833582 commit aa9c44b

File tree

1 file changed

+6
-6
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+6
-6
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,9 +2028,8 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
20282028
return err;
20292029
}
20302030

2031-
static bool mlx5_flow_has_geneve_opt(struct mlx5e_tc_flow *flow)
2031+
static bool mlx5_flow_has_geneve_opt(struct mlx5_flow_spec *spec)
20322032
{
2033-
struct mlx5_flow_spec *spec = &flow->attr->parse_attr->spec;
20342033
void *headers_v = MLX5_ADDR_OF(fte_match_param,
20352034
spec->match_value,
20362035
misc_parameters_3);
@@ -2069,7 +2068,7 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,
20692068
}
20702069
complete_all(&flow->del_hw_done);
20712070

2072-
if (mlx5_flow_has_geneve_opt(flow))
2071+
if (mlx5_flow_has_geneve_opt(&attr->parse_attr->spec))
20732072
mlx5_geneve_tlv_option_del(priv->mdev->geneve);
20742073

20752074
if (flow->decap_route)
@@ -2574,12 +2573,13 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,
25742573

25752574
err = mlx5e_tc_tun_parse(filter_dev, priv, tmp_spec, f, match_level);
25762575
if (err) {
2577-
kvfree(tmp_spec);
25782576
NL_SET_ERR_MSG_MOD(extack, "Failed to parse tunnel attributes");
25792577
netdev_warn(priv->netdev, "Failed to parse tunnel attributes");
2580-
return err;
2578+
} else {
2579+
err = mlx5e_tc_set_attr_rx_tun(flow, tmp_spec);
25812580
}
2582-
err = mlx5e_tc_set_attr_rx_tun(flow, tmp_spec);
2581+
if (mlx5_flow_has_geneve_opt(tmp_spec))
2582+
mlx5_geneve_tlv_option_del(priv->mdev->geneve);
25832583
kvfree(tmp_spec);
25842584
if (err)
25852585
return err;

0 commit comments

Comments
 (0)