[V3,1/1] net/mlx5: fix IPv6 next proto validation

Message ID 20201022082629.9160-1-elibr@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series [V3,1/1] net/mlx5: fix IPv6 next proto validation |

Checks

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

Commit Message

Eli Britstein Oct. 22, 2020, 8:26 a.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 defined as 0.
If proto field is not specified for matching, or mask=0, as in the
following, a wrong validation takes place.
flow create 0 ingress pattern eth / ipv6 has_frag_ext is 0 / end actions
drop / end
Fix the validation only on proto asked by the user.

Fixes: 92be60e1b541 ("net/mlx5: enforce limitation on IPv6 next proto")

Signed-off-by: Eli Britstein <elibr@nvidia.com>
Acked-by: Dekel Peled <dekelp@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Raslan Darawsheh Oct. 22, 2020, 10:01 a.m. UTC | #1
Hi,

> -----Original Message-----
> From: Eli Britstein <elibr@nvidia.com>
> Sent: Thursday, October 22, 2020 11:26 AM
> To: dev@dpdk.org
> Cc: Dekel Peled <dekelp@nvidia.com>; Ori Kam <orika@nvidia.com>; Matan
> Azrad <matan@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>; Slava
> Ovsiienko <viacheslavo@nvidia.com>; Shahaf Shuler <shahafs@nvidia.com>;
> Asaf Penso <asafp@nvidia.com>; Eli Britstein <elibr@nvidia.com>
> Subject: [PATCH V3 1/1] net/mlx5: fix IPv6 next proto validation
> 
> 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 defined as 0.
> If proto field is not specified for matching, or mask=0, as in the
> following, a wrong validation takes place.
> flow create 0 ingress pattern eth / ipv6 has_frag_ext is 0 / end actions
> drop / end
> Fix the validation only on proto asked by the user.
> 
> Fixes: 92be60e1b541 ("net/mlx5: enforce limitation on IPv6 next proto")
> 
> Signed-off-by: Eli Britstein <elibr@nvidia.com>
> Acked-by: Dekel Peled <dekelp@nvidia.com>
> Acked-by: Matan Azrad <matan@nvidia.com>
> ---
>  drivers/net/mlx5/mlx5_flow.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index 22fb4ee60a..d7243a878b 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -1979,8 +1979,8 @@ 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 && spec)
> -		next_proto = mask->hdr.proto & spec->hdr.proto;
> +	if (mask && mask->hdr.proto == UINT8_MAX && spec)
> +		next_proto = spec->hdr.proto;
>  	if (item_flags & MLX5_FLOW_LAYER_IPV6_ENCAP) {
>  		if (next_proto == IPPROTO_IPIP || next_proto ==
> IPPROTO_IPV6)
>  			return rte_flow_error_set(error, EINVAL,
> --
> 2.28.0.546.g385c171


Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh
  
Ferruh Yigit Oct. 22, 2020, 4:38 p.m. UTC | #2
On 10/22/2020 11:01 AM, Raslan Darawsheh wrote:
> Hi,
> 
>> -----Original Message-----
>> From: Eli Britstein <elibr@nvidia.com>
>> Sent: Thursday, October 22, 2020 11:26 AM
>> To: dev@dpdk.org
>> Cc: Dekel Peled <dekelp@nvidia.com>; Ori Kam <orika@nvidia.com>; Matan
>> Azrad <matan@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>; Slava
>> Ovsiienko <viacheslavo@nvidia.com>; Shahaf Shuler <shahafs@nvidia.com>;
>> Asaf Penso <asafp@nvidia.com>; Eli Britstein <elibr@nvidia.com>
>> Subject: [PATCH V3 1/1] net/mlx5: fix IPv6 next proto validation
>>
>> 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 defined as 0.
>> If proto field is not specified for matching, or mask=0, as in the
>> following, a wrong validation takes place.
>> flow create 0 ingress pattern eth / ipv6 has_frag_ext is 0 / end actions
>> drop / end
>> Fix the validation only on proto asked by the user.
>>
>> Fixes: 92be60e1b541 ("net/mlx5: enforce limitation on IPv6 next proto")
>>
>> Signed-off-by: Eli Britstein <elibr@nvidia.com>
>> Acked-by: Dekel Peled <dekelp@nvidia.com>
>> Acked-by: Matan Azrad <matan@nvidia.com>
> 
> 
> Patch applied to next-net-mlx,
> 

Squashed into relevant commit in next-net, thanks.
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 22fb4ee60a..d7243a878b 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -1979,8 +1979,8 @@  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 && spec)
-		next_proto = mask->hdr.proto & spec->hdr.proto;
+	if (mask && mask->hdr.proto == UINT8_MAX && spec)
+		next_proto = spec->hdr.proto;
 	if (item_flags & MLX5_FLOW_LAYER_IPV6_ENCAP) {
 		if (next_proto == IPPROTO_IPIP || next_proto == IPPROTO_IPV6)
 			return rte_flow_error_set(error, EINVAL,