net/mlx5e: Clear mirred devices array if the rule is split
authorJianbo Liu <jianbol@nvidia.com>
Tue, 5 Sep 2023 17:48:45 +0000 (10:48 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 6 Sep 2023 05:18:05 +0000 (06:18 +0100)
In the cited commit, the mirred devices are recorded and checked while
parsing the actions. In order to avoid system crash, the duplicate
action in a single rule is not allowed.

But the rule is actually break down into several FTEs in different
tables, for either mirroring, or the specified types of actions which
use post action infrastructure.

It will reject certain action list by mistake, for example:
    actions:enp8s0f0_1,set(ipv4(ttl=63)),enp8s0f0_0,enp8s0f0_1.
Here the rule is split to two FTEs because of pedit action.

To fix this issue, when parsing the rule actions, reset if_count to
clear the mirred devices array if the rule is split to multiple
FTEs, and then the duplicate checking is restarted.

Fixes: 554fe75c1b3f ("net/mlx5e: Avoid duplicating rule destinations")
Signed-off-by: Jianbo Liu <jianbol@nvidia.com>
Reviewed-by: Vlad Buslov <vladbu@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ct.c
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/mirred.c
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.c
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/redirect_ingress.c
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan_mangle.c
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

index 92d3952dfa8b78fc067e515cd1c78b9662fea038..feeb41693c176eaeb805251d328610c23b4707d7 100644 (file)
@@ -17,8 +17,10 @@ tc_act_parse_ct(struct mlx5e_tc_act_parse_state *parse_state,
        if (err)
                return err;
 
-       if (mlx5e_is_eswitch_flow(parse_state->flow))
+       if (mlx5e_is_eswitch_flow(parse_state->flow)) {
                attr->esw_attr->split_count = attr->esw_attr->out_count;
+               parse_state->if_count = 0;
+       }
 
        attr->flags |= MLX5_ATTR_FLAG_CT;
 
index 291193f7120d5f68f982f75ccbb1e7238db1999b..f63402c480280c735dac1e219b14f4ca8ed0b5b2 100644 (file)
@@ -294,6 +294,7 @@ parse_mirred_ovs_master(struct mlx5e_tc_act_parse_state *parse_state,
        if (err)
                return err;
 
+       parse_state->if_count = 0;
        esw_attr->out_count++;
        return 0;
 }
index 3b272bbf4c53806ffc5559126ebe44491bc4d906..368a95fa77d3263faa2749c2c33e61ddbbc1aa91 100644 (file)
@@ -98,8 +98,10 @@ tc_act_parse_pedit(struct mlx5e_tc_act_parse_state *parse_state,
 
        attr->action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
 
-       if (ns_type == MLX5_FLOW_NAMESPACE_FDB)
+       if (ns_type == MLX5_FLOW_NAMESPACE_FDB) {
                esw_attr->split_count = esw_attr->out_count;
+               parse_state->if_count = 0;
+       }
 
        return 0;
 }
index ad09a8a5f36e0441f53cc039c27da72c4091b0a5..2d1d4a04501b47b85613cfc876d694b64e78442f 100644 (file)
@@ -66,6 +66,7 @@ tc_act_parse_redirect_ingress(struct mlx5e_tc_act_parse_state *parse_state,
        if (err)
                return err;
 
+       parse_state->if_count = 0;
        esw_attr->out_count++;
 
        return 0;
index c8a3eaf189f6ace825aff2c9641e61a0285ddb91..a13c5e707b83cfe62593cae080a3b880172fb6b8 100644 (file)
@@ -166,6 +166,7 @@ tc_act_parse_vlan(struct mlx5e_tc_act_parse_state *parse_state,
                return err;
 
        esw_attr->split_count = esw_attr->out_count;
+       parse_state->if_count = 0;
 
        return 0;
 }
index 310b992307607cc86a626c834195506308d64694..f17575b09788db241a3a39e0ca75a8a17c925346 100644 (file)
@@ -65,8 +65,10 @@ tc_act_parse_vlan_mangle(struct mlx5e_tc_act_parse_state *parse_state,
        if (err)
                return err;
 
-       if (ns_type == MLX5_FLOW_NAMESPACE_FDB)
+       if (ns_type == MLX5_FLOW_NAMESPACE_FDB) {
                attr->esw_attr->split_count = attr->esw_attr->out_count;
+               parse_state->if_count = 0;
+       }
 
        return 0;
 }
index 318083690fcd26a8134bbbc56edb6ef3dd3eabf2..c24828b688ac0aa049f3518aefdf21251da4e8d9 100644 (file)
@@ -3936,6 +3936,7 @@ parse_tc_actions(struct mlx5e_tc_act_parse_state *parse_state,
                        }
 
                        i_split = i + 1;
+                       parse_state->if_count = 0;
                        list_add(&attr->list, &flow->attrs);
                }