From: Roi Dayan <roid@nvidia.com>
Date: Sun, 28 Nov 2021 11:49:17 +0200
Subject: net/mlx5e: TC, Reject rules with multiple CT actions
Patch-mainline: v5.18-rc1
Git-commit: 3b49a7edec1df4f7019b3b872124231197267205
References: jsc#PED-1549
The driver doesn't support multiple CT actions.
Multiple CT clear actions are ok as they are redundant also with
another CT actions.
Signed-off-by: Roi Dayan <roid@nvidia.com>
Reviewed-by: Oz Shlomo <ozsh@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h | 1 +
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c | 9 +++++++++
2 files changed, 10 insertions(+)
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/act.h
@@ -16,6 +16,7 @@ struct mlx5e_tc_act_parse_state {
unsigned int num_actions;
struct mlx5e_tc_flow *flow;
struct netlink_ext_ack *extack;
+ bool ct;
bool ct_clear;
bool encap;
bool decap;
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c
@@ -11,6 +11,7 @@ tc_act_can_offload_ct(struct mlx5e_tc_ac
int act_index,
struct mlx5_flow_attr *attr)
{
+ bool clear_action = act->ct.action & TCA_CT_ACT_CLEAR;
struct netlink_ext_ack *extack = parse_state->extack;
if (flow_flag_test(parse_state->flow, SAMPLE)) {
@@ -19,6 +20,11 @@ tc_act_can_offload_ct(struct mlx5e_tc_ac
return false;
}
+ if (parse_state->ct && !clear_action) {
+ NL_SET_ERR_MSG_MOD(extack, "Multiple CT actions are not supoported");
+ return false;
+ }
+
return true;
}
@@ -48,6 +54,9 @@ tc_act_parse_ct(struct mlx5e_tc_act_pars
parse_state->ct_clear = clear_action;
+ if (!clear_action)
+ parse_state->ct = true;
+
return 0;
}