net/mlx5e: Fix leak of Geneve TLV option object
[ Upstream commit aa9c44b842096c553871bc68a8cebc7861fa192b ]
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: 521933cdc4
("net/mlx5e: Support Geneve and GRE with VF tunnel offload")
Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Alex Lazar <alazar@nvidia.com>
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Link: https://patch.msgid.link/20250610151514.1094735-9-mbloch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
a810e48477
commit
77a72d7497
@@ -1915,9 +1915,8 @@ err_out:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool mlx5_flow_has_geneve_opt(struct mlx5e_tc_flow *flow)
|
static bool mlx5_flow_has_geneve_opt(struct mlx5_flow_spec *spec)
|
||||||
{
|
{
|
||||||
struct mlx5_flow_spec *spec = &flow->attr->parse_attr->spec;
|
|
||||||
void *headers_v = MLX5_ADDR_OF(fte_match_param,
|
void *headers_v = MLX5_ADDR_OF(fte_match_param,
|
||||||
spec->match_value,
|
spec->match_value,
|
||||||
misc_parameters_3);
|
misc_parameters_3);
|
||||||
@@ -1956,7 +1955,7 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,
|
|||||||
}
|
}
|
||||||
complete_all(&flow->del_hw_done);
|
complete_all(&flow->del_hw_done);
|
||||||
|
|
||||||
if (mlx5_flow_has_geneve_opt(flow))
|
if (mlx5_flow_has_geneve_opt(&attr->parse_attr->spec))
|
||||||
mlx5_geneve_tlv_option_del(priv->mdev->geneve);
|
mlx5_geneve_tlv_option_del(priv->mdev->geneve);
|
||||||
|
|
||||||
if (flow->decap_route)
|
if (flow->decap_route)
|
||||||
@@ -2456,12 +2455,13 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,
|
|||||||
|
|
||||||
err = mlx5e_tc_tun_parse(filter_dev, priv, tmp_spec, f, match_level);
|
err = mlx5e_tc_tun_parse(filter_dev, priv, tmp_spec, f, match_level);
|
||||||
if (err) {
|
if (err) {
|
||||||
kvfree(tmp_spec);
|
|
||||||
NL_SET_ERR_MSG_MOD(extack, "Failed to parse tunnel attributes");
|
NL_SET_ERR_MSG_MOD(extack, "Failed to parse tunnel attributes");
|
||||||
netdev_warn(priv->netdev, "Failed to parse tunnel attributes");
|
netdev_warn(priv->netdev, "Failed to parse tunnel attributes");
|
||||||
return err;
|
} else {
|
||||||
|
err = mlx5e_tc_set_attr_rx_tun(flow, tmp_spec);
|
||||||
}
|
}
|
||||||
err = mlx5e_tc_set_attr_rx_tun(flow, tmp_spec);
|
if (mlx5_flow_has_geneve_opt(tmp_spec))
|
||||||
|
mlx5_geneve_tlv_option_del(priv->mdev->geneve);
|
||||||
kvfree(tmp_spec);
|
kvfree(tmp_spec);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
Reference in New Issue
Block a user