Skip to content

Commit 5d862ec

Browse files
w1ldptrSaeed Mahameed
authored andcommitted
net/mlx5: Fix post parse infra to only parse every action once
Caller of mlx5e_tc_act_post_parse() needs it to parse only the subset of actions starting after previous split and ending at the current action. However, that range is not provided as arguments and mlx5e_tc_act_post_parse() uses generic flow_action_for_each() that iterates over all flow actions. Not only this is redundant, it also causes a bug when mlx5e_tc_act->post_parse() callback is not idempotent since it will be called for every split. For example, ct action tc_act_post_parse_ct() callback obtains a reference to mlx5_ct_ft instance and calling it several times during parsing stage will cause reference counter imbalance. Fix the issue by providing a proper action range of the current split subset to mlx5e_tc_act_post_parse() and only calling mlx5e_tc_act->post_parse() for actions inside the subset range. Fixes: 8300f22 ("net/mlx5e: Create new flow attr for multi table actions") Signed-off-by: Vlad Buslov <vladbu@nvidia.com> Reviewed-by: Roi Dayan <roid@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
1 parent 1db1f21 commit 5d862ec

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ mlx5e_tc_act_init_parse_state(struct mlx5e_tc_act_parse_state *parse_state,
8484

8585
int
8686
mlx5e_tc_act_post_parse(struct mlx5e_tc_act_parse_state *parse_state,
87-
struct flow_action *flow_action,
87+
struct flow_action *flow_action, int from, int to,
8888
struct mlx5_flow_attr *attr,
8989
enum mlx5_flow_namespace_type ns_type)
9090
{
@@ -96,6 +96,11 @@ mlx5e_tc_act_post_parse(struct mlx5e_tc_act_parse_state *parse_state,
9696
priv = parse_state->flow->priv;
9797

9898
flow_action_for_each(i, act, flow_action) {
99+
if (i < from)
100+
continue;
101+
else if (i > to)
102+
break;
103+
99104
tc_act = mlx5e_tc_act_get(act->id, ns_type);
100105
if (!tc_act || !tc_act->post_parse)
101106
continue;

drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ mlx5e_tc_act_init_parse_state(struct mlx5e_tc_act_parse_state *parse_state,
112112

113113
int
114114
mlx5e_tc_act_post_parse(struct mlx5e_tc_act_parse_state *parse_state,
115-
struct flow_action *flow_action,
115+
struct flow_action *flow_action, int from, int to,
116116
struct mlx5_flow_attr *attr,
117117
enum mlx5_flow_namespace_type ns_type);
118118

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3859,8 +3859,8 @@ parse_tc_actions(struct mlx5e_tc_act_parse_state *parse_state,
38593859
struct mlx5_flow_attr *prev_attr;
38603860
struct flow_action_entry *act;
38613861
struct mlx5e_tc_act *tc_act;
3862+
int err, i, i_split = 0;
38623863
bool is_missable;
3863-
int err, i;
38643864

38653865
ns_type = mlx5e_get_flow_namespace(flow);
38663866
list_add(&attr->list, &flow->attrs);
@@ -3901,7 +3901,8 @@ parse_tc_actions(struct mlx5e_tc_act_parse_state *parse_state,
39013901
i < flow_action->num_entries - 1)) {
39023902
is_missable = tc_act->is_missable ? tc_act->is_missable(act) : false;
39033903

3904-
err = mlx5e_tc_act_post_parse(parse_state, flow_action, attr, ns_type);
3904+
err = mlx5e_tc_act_post_parse(parse_state, flow_action, i_split, i, attr,
3905+
ns_type);
39053906
if (err)
39063907
goto out_free_post_acts;
39073908

@@ -3911,6 +3912,7 @@ parse_tc_actions(struct mlx5e_tc_act_parse_state *parse_state,
39113912
goto out_free_post_acts;
39123913
}
39133914

3915+
i_split = i + 1;
39143916
list_add(&attr->list, &flow->attrs);
39153917
}
39163918

@@ -3925,7 +3927,7 @@ parse_tc_actions(struct mlx5e_tc_act_parse_state *parse_state,
39253927
}
39263928
}
39273929

3928-
err = mlx5e_tc_act_post_parse(parse_state, flow_action, attr, ns_type);
3930+
err = mlx5e_tc_act_post_parse(parse_state, flow_action, i_split, i, attr, ns_type);
39293931
if (err)
39303932
goto out_free_post_acts;
39313933

0 commit comments

Comments
 (0)