Skip to content

Commit aded104

Browse files
author
Saeed Mahameed
committed
net/mlx5e: CT: Fix stack usage compiler warning
Fix the following warnings: [-Werror=frame-larger-than=] In function ‘mlx5_tc_ct_entry_add_rule’: drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c:541:1: error: the frame size of 1136 bytes is larger than 1024 bytes In function ‘__mlx5_tc_ct_flow_offload’: drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c:1049:1: error: the frame size of 1168 bytes is larger than 1024 bytes Fixes: 4c3844d ("net/mlx5e: CT: Introduce connection tracking") Signed-off-by: Saeed Mahameed <[email protected]> Reviewed-by: Paul Blakey <[email protected]>
1 parent 3cfc433 commit aded104

File tree

1 file changed

+22
-9
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/en

1 file changed

+22
-9
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -484,19 +484,23 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,
484484
struct mlx5_ct_zone_rule *zone_rule = &entry->zone_rules[nat];
485485
struct mlx5_esw_flow_attr *attr = &zone_rule->attr;
486486
struct mlx5_eswitch *esw = ct_priv->esw;
487-
struct mlx5_flow_spec spec = {};
487+
struct mlx5_flow_spec *spec = NULL;
488488
u32 tupleid = 1;
489489
int err;
490490

491491
zone_rule->nat = nat;
492492

493+
spec = kzalloc(sizeof(*spec), GFP_KERNEL);
494+
if (!spec)
495+
return -ENOMEM;
496+
493497
/* Get tuple unique id */
494498
err = idr_alloc_u32(&ct_priv->tuple_ids, zone_rule, &tupleid,
495499
TUPLE_ID_MAX, GFP_KERNEL);
496500
if (err) {
497501
netdev_warn(ct_priv->netdev,
498502
"Failed to allocate tuple id, err: %d\n", err);
499-
return err;
503+
goto err_idr_alloc;
500504
}
501505
zone_rule->tupleid = tupleid;
502506

@@ -517,18 +521,19 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,
517521
attr->counter = entry->counter;
518522
attr->flags |= MLX5_ESW_ATTR_FLAG_NO_IN_PORT;
519523

520-
mlx5_tc_ct_set_tuple_match(&spec, flow_rule);
521-
mlx5e_tc_match_to_reg_match(&spec, ZONE_TO_REG,
524+
mlx5_tc_ct_set_tuple_match(spec, flow_rule);
525+
mlx5e_tc_match_to_reg_match(spec, ZONE_TO_REG,
522526
entry->zone & MLX5_CT_ZONE_MASK,
523527
MLX5_CT_ZONE_MASK);
524528

525-
zone_rule->rule = mlx5_eswitch_add_offloaded_rule(esw, &spec, attr);
529+
zone_rule->rule = mlx5_eswitch_add_offloaded_rule(esw, spec, attr);
526530
if (IS_ERR(zone_rule->rule)) {
527531
err = PTR_ERR(zone_rule->rule);
528532
ct_dbg("Failed to add ct entry rule, nat: %d", nat);
529533
goto err_rule;
530534
}
531535

536+
kfree(spec);
532537
ct_dbg("Offloaded ct entry rule in zone %d", entry->zone);
533538

534539
return 0;
@@ -537,6 +542,8 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,
537542
mlx5_modify_header_dealloc(esw->dev, attr->modify_hdr);
538543
err_mod_hdr:
539544
idr_remove(&ct_priv->tuple_ids, zone_rule->tupleid);
545+
err_idr_alloc:
546+
kfree(spec);
540547
return err;
541548
}
542549

@@ -884,8 +891,8 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,
884891
struct mlx5_tc_ct_priv *ct_priv = mlx5_tc_ct_get_ct_priv(priv);
885892
bool nat = attr->ct_attr.ct_action & TCA_CT_ACT_NAT;
886893
struct mlx5e_tc_mod_hdr_acts pre_mod_acts = {};
894+
struct mlx5_flow_spec *post_ct_spec = NULL;
887895
struct mlx5_eswitch *esw = ct_priv->esw;
888-
struct mlx5_flow_spec post_ct_spec = {};
889896
struct mlx5_esw_flow_attr *pre_ct_attr;
890897
struct mlx5_modify_hdr *mod_hdr;
891898
struct mlx5_flow_handle *rule;
@@ -894,9 +901,13 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,
894901
struct mlx5_ct_ft *ft;
895902
u32 fte_id = 1;
896903

904+
post_ct_spec = kzalloc(sizeof(*post_ct_spec), GFP_KERNEL);
897905
ct_flow = kzalloc(sizeof(*ct_flow), GFP_KERNEL);
898-
if (!ct_flow)
906+
if (!post_ct_spec || !ct_flow) {
907+
kfree(post_ct_spec);
908+
kfree(ct_flow);
899909
return -ENOMEM;
910+
}
900911

901912
/* Register for CT established events */
902913
ft = mlx5_tc_ct_add_ft_cb(ct_priv, attr->ct_attr.zone,
@@ -991,7 +1002,7 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,
9911002
/* Post ct rule matches on fte_id and executes original rule's
9921003
* tc rule action
9931004
*/
994-
mlx5e_tc_match_to_reg_match(&post_ct_spec, FTEID_TO_REG,
1005+
mlx5e_tc_match_to_reg_match(post_ct_spec, FTEID_TO_REG,
9951006
fte_id, MLX5_FTE_ID_MASK);
9961007

9971008
/* Put post_ct rule on post_ct fdb */
@@ -1002,7 +1013,7 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,
10021013
ct_flow->post_ct_attr.inner_match_level = MLX5_MATCH_NONE;
10031014
ct_flow->post_ct_attr.outer_match_level = MLX5_MATCH_NONE;
10041015
ct_flow->post_ct_attr.action &= ~(MLX5_FLOW_CONTEXT_ACTION_DECAP);
1005-
rule = mlx5_eswitch_add_offloaded_rule(esw, &post_ct_spec,
1016+
rule = mlx5_eswitch_add_offloaded_rule(esw, post_ct_spec,
10061017
&ct_flow->post_ct_attr);
10071018
ct_flow->post_ct_rule = rule;
10081019
if (IS_ERR(ct_flow->post_ct_rule)) {
@@ -1026,6 +1037,7 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,
10261037
attr->ct_attr.ct_flow = ct_flow;
10271038
*flow_rule = ct_flow->post_ct_rule;
10281039
dealloc_mod_hdr_actions(&pre_mod_acts);
1040+
kfree(post_ct_spec);
10291041

10301042
return 0;
10311043

@@ -1042,6 +1054,7 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,
10421054
err_idr:
10431055
mlx5_tc_ct_del_ft_cb(ct_priv, ft);
10441056
err_ft:
1057+
kfree(post_ct_spec);
10451058
kfree(ct_flow);
10461059
netdev_warn(priv->netdev, "Failed to offload ct flow, err %d\n", err);
10471060
return err;

0 commit comments

Comments
 (0)