net/mlx5: fix IPv6 next proto validation
diff mbox series

Message ID fc7c2ef6fc37f4337ad7a0980e351d6ae92a7a19.1603195768.git.dekelp@nvidia.com
State Superseded, archived
Delegated to: Raslan Darawsheh
Headers show
Series
  • net/mlx5: fix IPv6 next proto validation
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Dekel Peled Oct. 20, 2020, 12:09 p.m. UTC
Previous patch added validation of the IPv6 next proto field, in order
to overcome a known limitation.
One of the values checked is IPPROTO_HOPOPTS, which is currently defined
as value 0.
The same value 0 is received when next proto field is not specified for
matching, or has mask 0.

This patch updates the validation, to make sure next proto is not 0
before validating it.

Fixes: 55e4c1d1ba73 ("net/mlx5: enforce limitation on IPv6 next proto")

Signed-off-by: Dekel Peled <dekelp@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index c56dac8..74af207 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -1987,12 +1987,13 @@  struct mlx5_flow_tunnel_info {
 						  "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)
+	if (next_proto &&
+	    (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 "