From: Itamar Gozlan <igoz...@nvidia.com> This commit fixes two leaks in flow table management. The first leak was when the default miss table of a flow table was not reset to the default action when setting a new first matcher. The second leak was caused by a missing free for an RTC in the case of disconnecting the last matcher in a table's matcher list.
Fixes: b81f95ca770d ("net/mlx5/hws: support default miss table") Signed-off-by: Itamar Gozlan <igoz...@nvidia.com> Acked-by: Viacheslav Ovsiienko <viachesl...@nvidia.com> --- drivers/net/mlx5/hws/mlx5dr_matcher.c | 41 +++++++-------------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/drivers/net/mlx5/hws/mlx5dr_matcher.c b/drivers/net/mlx5/hws/mlx5dr_matcher.c index a82c182460..ebe42c44c6 100644 --- a/drivers/net/mlx5/hws/mlx5dr_matcher.c +++ b/drivers/net/mlx5/hws/mlx5dr_matcher.c @@ -253,15 +253,15 @@ static int mlx5dr_matcher_connect(struct mlx5dr_matcher *matcher) goto remove_from_list; } - if (prev) { - /* Reset next miss FT to default (drop refcount) */ - ret = mlx5dr_table_ft_set_default_next_ft(tbl, prev->end_ft); - if (ret) { - DR_LOG(ERR, "Failed to reset matcher ft default miss"); - goto remove_from_list; - } - } else { - /* Update tables missing to current table */ + /* Reset next miss FT to default (drop refcount) */ + ret = mlx5dr_table_ft_set_default_next_ft(tbl, prev ? prev->end_ft : tbl->ft); + if (ret) { + DR_LOG(ERR, "Failed to reset matcher ft default miss"); + goto remove_from_list; + } + + if (!prev) { + /* Update tables missing to current matcher in the table */ ret = mlx5dr_table_update_connected_miss_tables(tbl); if (ret) { DR_LOG(ERR, "Fatal error, failed to update connected miss table"); @@ -276,27 +276,6 @@ static int mlx5dr_matcher_connect(struct mlx5dr_matcher *matcher) return ret; } -static int mlx5dr_last_matcher_disconnect(struct mlx5dr_table *tbl, - struct mlx5dr_devx_obj *prev_ft) -{ - struct mlx5dr_cmd_ft_modify_attr ft_attr = {0}; - - if (tbl->default_miss.miss_tbl) { - /* Connect new last matcher to next miss_tbl if exists */ - return mlx5dr_table_connect_to_miss_table(tbl, - tbl->default_miss.miss_tbl); - } else { - ft_attr.modify_fs = MLX5_IFC_MODIFY_FLOW_TABLE_RTC_ID; - ft_attr.type = tbl->fw_ft_type; - /* Matcher is last, point prev end FT to default miss */ - mlx5dr_cmd_set_attr_connect_miss_tbl(tbl->ctx, - tbl->fw_ft_type, - tbl->type, - &ft_attr); - return mlx5dr_cmd_flow_table_modify(prev_ft, &ft_attr); - } -} - static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher) { struct mlx5dr_matcher *tmp_matcher, *prev_matcher; @@ -330,7 +309,7 @@ static int mlx5dr_matcher_disconnect(struct mlx5dr_matcher *matcher) goto matcher_reconnect; } } else { - ret = mlx5dr_last_matcher_disconnect(tbl, prev_ft); + ret = mlx5dr_table_connect_to_miss_table(tbl, tbl->default_miss.miss_tbl); if (ret) { DR_LOG(ERR, "Failed to disconnect last matcher"); goto matcher_reconnect; -- 2.25.1