Skip to content

Commit 96b5b45

Browse files
chumakdSaeed Mahameed
authored andcommitted
net/mlx5e: Offload tuple rewrite for non-CT flows
Setting connection tracking OVS flows and then setting non-CT flows that use tuple rewrite action (e.g. mod_tp_dst), causes the latter flows not being offloaded. Fix by using a stricter condition in modify_header_match_supported() to check tuple rewrite support only for flows with CT action. The check is factored out into standalone modify_tuple_supported() function to aid readability. Fixes: 7e36fee ("net/mlx5e: CT: Don't offload tuple rewrites for established tuples") Signed-off-by: Dima Chumak <[email protected]> Reviewed-by: Paul Blakey <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 7d6c86e commit 96b5b45

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,8 @@ int mlx5_tc_ct_add_no_trk_match(struct mlx5_flow_spec *spec)
11811181

11821182
mlx5e_tc_match_to_reg_get_match(spec, CTSTATE_TO_REG,
11831183
&ctstate, &ctstate_mask);
1184-
if (ctstate_mask)
1184+
1185+
if ((ctstate & ctstate_mask) == MLX5_CT_STATE_TRK_BIT)
11851186
return -EOPNOTSUPP;
11861187

11871188
ctstate_mask |= MLX5_CT_STATE_TRK_BIT;

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

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2909,6 +2909,37 @@ static int is_action_keys_supported(const struct flow_action_entry *act,
29092909
return 0;
29102910
}
29112911

2912+
static bool modify_tuple_supported(bool modify_tuple, bool ct_clear,
2913+
bool ct_flow, struct netlink_ext_ack *extack,
2914+
struct mlx5e_priv *priv,
2915+
struct mlx5_flow_spec *spec)
2916+
{
2917+
if (!modify_tuple || ct_clear)
2918+
return true;
2919+
2920+
if (ct_flow) {
2921+
NL_SET_ERR_MSG_MOD(extack,
2922+
"can't offload tuple modification with non-clear ct()");
2923+
netdev_info(priv->netdev,
2924+
"can't offload tuple modification with non-clear ct()");
2925+
return false;
2926+
}
2927+
2928+
/* Add ct_state=-trk match so it will be offloaded for non ct flows
2929+
* (or after clear action), as otherwise, since the tuple is changed,
2930+
* we can't restore ct state
2931+
*/
2932+
if (mlx5_tc_ct_add_no_trk_match(spec)) {
2933+
NL_SET_ERR_MSG_MOD(extack,
2934+
"can't offload tuple modification with ct matches and no ct(clear) action");
2935+
netdev_info(priv->netdev,
2936+
"can't offload tuple modification with ct matches and no ct(clear) action");
2937+
return false;
2938+
}
2939+
2940+
return true;
2941+
}
2942+
29122943
static bool modify_header_match_supported(struct mlx5e_priv *priv,
29132944
struct mlx5_flow_spec *spec,
29142945
struct flow_action *flow_action,
@@ -2947,18 +2978,9 @@ static bool modify_header_match_supported(struct mlx5e_priv *priv,
29472978
return err;
29482979
}
29492980

2950-
/* Add ct_state=-trk match so it will be offloaded for non ct flows
2951-
* (or after clear action), as otherwise, since the tuple is changed,
2952-
* we can't restore ct state
2953-
*/
2954-
if (!ct_clear && modify_tuple &&
2955-
mlx5_tc_ct_add_no_trk_match(spec)) {
2956-
NL_SET_ERR_MSG_MOD(extack,
2957-
"can't offload tuple modify header with ct matches");
2958-
netdev_info(priv->netdev,
2959-
"can't offload tuple modify header with ct matches");
2981+
if (!modify_tuple_supported(modify_tuple, ct_clear, ct_flow, extack,
2982+
priv, spec))
29602983
return false;
2961-
}
29622984

29632985
ip_proto = MLX5_GET(fte_match_set_lyr_2_4, headers_v, ip_protocol);
29642986
if (modify_ip_header && ip_proto != IPPROTO_TCP &&

0 commit comments

Comments
 (0)