[v1,2/2] net/mlx5: fix modify flex item error

Message ID 20240221071043.3309205-3-rongweil@nvidia.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series fix flex item modify error |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation warning apply issues

Commit Message

Rongwei Liu Feb. 21, 2024, 7:10 a.m. UTC
  In the rte_flow_field_data structure, the flex item handle is part
of union with other members like level/tag_index.

If the user wants to modify the flex item as source or destination,
there should not be any checking against zero.

Signed-off-by: Rongwei Liu <rongweil@nvidia.com>
Fixes: 7ea38955b ("ethdev: update MPLS header modification API")
Cc: michaelba@nvidia.com
Cc: stable@dpdk.org
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow.c    | 2 +-
 drivers/net/mlx5/mlx5_flow_hw.c | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)
  

Comments

Ferruh Yigit Feb. 21, 2024, 4:35 p.m. UTC | #1
On 2/21/2024 7:10 AM, Rongwei Liu wrote:
> In the rte_flow_field_data structure, the flex item handle is part
> of union with other members like level/tag_index.
> 
> If the user wants to modify the flex item as source or destination,
> there should not be any checking against zero.
> 
> Signed-off-by: Rongwei Liu <rongweil@nvidia.com>
> Fixes: 7ea38955b ("ethdev: update MPLS header modification API")
> Cc: michaelba@nvidia.com
> Cc: stable@dpdk.org
> Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
>

Hi Rongwei,

I can't (also CI can't) apply this patch, on which tree it is based on?
  
Ferruh Yigit Feb. 23, 2024, 12:06 p.m. UTC | #2
On 2/23/2024 3:21 AM, Rongwei Liu wrote:
> v2: rebase.
> 
> Rongwei Liu (2):
>   app/testpmd: fix modify tag typo
>   net/mlx5: fix modify flex item error
> 

Series applied to dpdk-next-net/main, thanks.
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 3c306a5f70..9caecc3db6 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -2369,7 +2369,7 @@  int
 flow_validate_modify_field_level(const struct rte_flow_field_data *data,
 				 struct rte_flow_error *error)
 {
-	if (data->level == 0)
+	if (data->level == 0 || data->field == RTE_FLOW_FIELD_FLEX_ITEM)
 		return 0;
 	if (data->field != RTE_FLOW_FIELD_TAG &&
 	    data->field != (enum rte_flow_field_id)MLX5_RTE_FLOW_FIELD_META_REG) {
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index efbf88f56d..6dde19c1b9 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -6104,7 +6104,8 @@  flow_hw_validate_action_modify_field(struct rte_eth_dev *dev,
 	ret = flow_hw_validate_modify_field_level(&action_conf->dst, false, error);
 	if (ret)
 		return ret;
-	if (!flow_hw_modify_field_is_geneve_opt(action_conf->dst.field)) {
+	if (action_conf->dst.field != RTE_FLOW_FIELD_FLEX_ITEM &&
+	    !flow_hw_modify_field_is_geneve_opt(action_conf->dst.field)) {
 		if (action_conf->dst.tag_index &&
 		    !flow_modify_field_support_tag_array(action_conf->dst.field))
 			return rte_flow_error_set(error, EINVAL,
@@ -6129,7 +6130,8 @@  flow_hw_validate_action_modify_field(struct rte_eth_dev *dev,
 				"destination field mask and template are not equal");
 	if (action_conf->src.field != RTE_FLOW_FIELD_POINTER &&
 	    action_conf->src.field != RTE_FLOW_FIELD_VALUE) {
-		if (!flow_hw_modify_field_is_geneve_opt(action_conf->src.field)) {
+		if (action_conf->src.field != RTE_FLOW_FIELD_FLEX_ITEM &&
+		    !flow_hw_modify_field_is_geneve_opt(action_conf->src.field)) {
 			if (action_conf->src.tag_index &&
 			    !flow_modify_field_support_tag_array(action_conf->src.field))
 				return rte_flow_error_set(error, EINVAL,