net/mlx5: fix IPv6 flow item validation for VERB API

Message ID 20220307171731.3643-1-getelson@nvidia.com (mailing list archive)
State Changes Requested, archived
Delegated to: Raslan Darawsheh
Headers
Series net/mlx5: fix IPv6 flow item validation for VERB API |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Gregory Etelson March 7, 2022, 5:17 p.m. UTC
  In case the PMD was activated over VERB API,
limit IPv6 flow item next protocol mask value to 0 or 0xFF.
The limitation is required for RSS flow action TCP and UDP types.

Cc: stable@dpdk.org

Fixes: 491757372f98 ("net/mlx5: enforce limitation on IPv6 next protocol")
Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)
  

Comments

Raslan Darawsheh March 8, 2022, 9:09 a.m. UTC | #1
Hi,

> -----Original Message-----
> From: Gregory Etelson <getelson@nvidia.com>
> Sent: Monday, March 7, 2022 7:18 PM
> To: dev@dpdk.org
> Cc: Gregory Etelson <getelson@nvidia.com>; Matan Azrad
> <matan@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>;
> stable@dpdk.org; Slava Ovsiienko <viacheslavo@nvidia.com>; Dekel Peled
> <dekelp@nvidia.com>; Ori Kam <orika@nvidia.com>
> Subject: [PATCH] net/mlx5: fix IPv6 flow item validation for VERB API
> 
> In case the PMD was activated over VERB API, limit IPv6 flow item next
> protocol mask value to 0 or 0xFF.
> The limitation is required for RSS flow action TCP and UDP types.
> 
> Cc: stable@dpdk.org
> 
> Fixes: 491757372f98 ("net/mlx5: enforce limitation on IPv6 next protocol")
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh
  
Raslan Darawsheh March 8, 2022, 4:54 p.m. UTC | #2
Hi,

> -----Original Message-----
> From: Raslan Darawsheh
> Sent: Tuesday, March 8, 2022 11:10 AM
> To: Gregory Etelson <getelson@nvidia.com>; dev@dpdk.org
> Cc: Matan Azrad <matan@nvidia.com>; stable@dpdk.org; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Dekel Peled <dekelp@nvidia.com>; Ori Kam
> <orika@nvidia.com>
> Subject: RE: [PATCH] net/mlx5: fix IPv6 flow item validation for VERB API
> 
> Hi,
> 
> > -----Original Message-----
> > From: Gregory Etelson <getelson@nvidia.com>
> > Sent: Monday, March 7, 2022 7:18 PM
> > To: dev@dpdk.org
> > Cc: Gregory Etelson <getelson@nvidia.com>; Matan Azrad
> > <matan@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>;
> > stable@dpdk.org; Slava Ovsiienko <viacheslavo@nvidia.com>; Dekel Peled
> > <dekelp@nvidia.com>; Ori Kam <orika@nvidia.com>
> > Subject: [PATCH] net/mlx5: fix IPv6 flow item validation for VERB API
> >
> > In case the PMD was activated over VERB API, limit IPv6 flow item next
> > protocol mask value to 0 or 0xFF.
> > The limitation is required for RSS flow action TCP and UDP types.
> >
> > Cc: stable@dpdk.org
> >
> > Fixes: 491757372f98 ("net/mlx5: enforce limitation on IPv6 next
> > protocol")
> > Signed-off-by: Gregory Etelson <getelson@nvidia.com>
> > Acked-by: Matan Azrad <matan@nvidia.com>
> 
> Patch applied to next-net-mlx,
> 
> Kindest regards,
> Raslan Darawsheh

Dropping this patch from next-net-mlx as it introduces a new bug with dv_flow_en, 


Kindest regards,
Raslan Darawsheh
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 312649b732..97f05d7d30 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -2562,8 +2562,6 @@  mlx5_flow_validate_item_ipv6(const struct rte_flow_item *item,
 					  RTE_FLOW_ERROR_TYPE_ITEM, item,
 					  "IPv6 cannot follow L2/VLAN layer "
 					  "which ether type is not IPv6");
-	if (mask && mask->hdr.proto == UINT8_MAX && spec)
-		next_proto = spec->hdr.proto;
 	if (item_flags & MLX5_FLOW_LAYER_TUNNEL) {
 		if (next_proto == IPPROTO_IPIP || next_proto == IPPROTO_IPV6)
 			return rte_flow_error_set(error, EINVAL,
@@ -2572,16 +2570,6 @@  mlx5_flow_validate_item_ipv6(const struct rte_flow_item *item,
 						  "multiple tunnel "
 						  "not supported");
 	}
-	if (next_proto == IPPROTO_HOPOPTS  ||
-	    next_proto == IPPROTO_ROUTING  ||
-	    next_proto == IPPROTO_FRAGMENT ||
-	    next_proto == IPPROTO_ESP	   ||
-	    next_proto == IPPROTO_AH	   ||
-	    next_proto == IPPROTO_DSTOPTS)
-		return rte_flow_error_set(error, EINVAL,
-					  RTE_FLOW_ERROR_TYPE_ITEM, item,
-					  "IPv6 proto (next header) should "
-					  "not be set as extension header");
 	if (item_flags & MLX5_FLOW_LAYER_IPIP)
 		return rte_flow_error_set(error, EINVAL,
 					  RTE_FLOW_ERROR_TYPE_ITEM, item,
@@ -2609,6 +2597,21 @@  mlx5_flow_validate_item_ipv6(const struct rte_flow_item *item,
 					MLX5_ITEM_RANGE_NOT_ACCEPTED, error);
 	if (ret < 0)
 		return ret;
+	if (mask->hdr.proto != 0 && mask->hdr.proto != 0xff)
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ITEM_MASK, mask,
+					  "partial mask is not supported for protocol");
+	next_proto = spec->hdr.proto & mask->hdr.proto;
+	if (next_proto == IPPROTO_HOPOPTS  ||
+	    next_proto == IPPROTO_ROUTING  ||
+	    next_proto == IPPROTO_FRAGMENT ||
+	    next_proto == IPPROTO_ESP	   ||
+	    next_proto == IPPROTO_AH	   ||
+	    next_proto == IPPROTO_DSTOPTS)
+		return rte_flow_error_set(error, EINVAL,
+					  RTE_FLOW_ERROR_TYPE_ITEM, item,
+					  "IPv6 proto (next header) should "
+					  "not be set as extension header");
 	return 0;
 }