Skip to content

Commit 1f2856c

Browse files
Paul BlakeySaeed Mahameed
authored andcommitted
net/mlx5: CT: Fix header-rewrite re-use for tupels
Tuple entries that don't have nat configured for them which are added to the ct nat table will always create a new modify header, as we don't check for possible re-use on them. The same for tuples that have nat configured for them but are added to ct table. Fix the above by only avoiding wasteful re-use lookup for actually natted entries in ct nat table. Fixes: 7fac5c2 ("net/mlx5: CT: Avoid reusing modify header context for natted entries") Signed-off-by: Paul Blakey <[email protected]> Reviewed-by: Ariel Levkovich <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 66cb64e commit 1f2856c

File tree

1 file changed

+11
-8
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/en

1 file changed

+11
-8
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ mlx5_tc_ct_entry_create_mod_hdr(struct mlx5_tc_ct_priv *ct_priv,
715715
struct mlx5_flow_attr *attr,
716716
struct flow_rule *flow_rule,
717717
struct mlx5e_mod_hdr_handle **mh,
718-
u8 zone_restore_id, bool nat)
718+
u8 zone_restore_id, bool nat_table, bool has_nat)
719719
{
720720
DECLARE_MOD_HDR_ACTS_ACTIONS(actions_arr, MLX5_CT_MIN_MOD_ACTS);
721721
DECLARE_MOD_HDR_ACTS(mod_acts, actions_arr);
@@ -731,11 +731,12 @@ mlx5_tc_ct_entry_create_mod_hdr(struct mlx5_tc_ct_priv *ct_priv,
731731
&attr->ct_attr.ct_labels_id);
732732
if (err)
733733
return -EOPNOTSUPP;
734-
if (nat) {
735-
err = mlx5_tc_ct_entry_create_nat(ct_priv, flow_rule,
736-
&mod_acts);
737-
if (err)
738-
goto err_mapping;
734+
if (nat_table) {
735+
if (has_nat) {
736+
err = mlx5_tc_ct_entry_create_nat(ct_priv, flow_rule, &mod_acts);
737+
if (err)
738+
goto err_mapping;
739+
}
739740

740741
ct_state |= MLX5_CT_STATE_NAT_BIT;
741742
}
@@ -750,7 +751,7 @@ mlx5_tc_ct_entry_create_mod_hdr(struct mlx5_tc_ct_priv *ct_priv,
750751
if (err)
751752
goto err_mapping;
752753

753-
if (nat) {
754+
if (nat_table && has_nat) {
754755
attr->modify_hdr = mlx5_modify_header_alloc(ct_priv->dev, ct_priv->ns_type,
755756
mod_acts.num_actions,
756757
mod_acts.actions);
@@ -818,7 +819,9 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,
818819

819820
err = mlx5_tc_ct_entry_create_mod_hdr(ct_priv, attr, flow_rule,
820821
&zone_rule->mh,
821-
zone_restore_id, nat);
822+
zone_restore_id,
823+
nat,
824+
mlx5_tc_ct_entry_has_nat(entry));
822825
if (err) {
823826
ct_dbg("Failed to create ct entry mod hdr");
824827
goto err_mod_hdr;

0 commit comments

Comments
 (0)