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

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

Checks

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

Commit Message

Eli Britstein Oct. 20, 2020, 1:19 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 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: 55e4c1d1ba73 ("net/mlx5: enforce limitation on IPv6 next proto")

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

Comments

Eli Britstein Oct. 20, 2020, 1:49 p.m. UTC | #1
++

On 10/20/2020 4:19 PM, Eli Britstein wrote:
> 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: 55e4c1d1ba73 ("net/mlx5: enforce limitation on IPv6 next proto")
>
> Signed-off-by: Eli Britstein <elibr@nvidia.com>
> Acked-by: Dekel Peled <dekelp@nvidia.com>
> ---
>   drivers/net/mlx5/mlx5_flow.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index c56dac89f9..e0ca8e06b1 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -1977,7 +1977,7 @@ 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)
> +	if (mask && mask->hdr.proto && spec)
>   		next_proto = mask->hdr.proto & spec->hdr.proto;
>   	if (item_flags & MLX5_FLOW_LAYER_IPV6_ENCAP) {
>   		if (next_proto == IPPROTO_IPIP || next_proto == IPPROTO_IPV6)
  
Matan Azrad Oct. 21, 2020, 2:22 p.m. UTC | #2
From: Eli Britstein
> 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: 55e4c1d1ba73 ("net/mlx5: enforce limitation on IPv6 next proto")
> 
> Signed-off-by: Eli Britstein <elibr@nvidia.com>
> Acked-by: Dekel Peled <dekelp@nvidia.com>
> ---
>  drivers/net/mlx5/mlx5_flow.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index c56dac89f9..e0ca8e06b1 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -1977,7 +1977,7 @@ 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)
> +	if (mask && mask->hdr.proto && spec)

If you want to be sure os specific proto only you need to check mask->hdr.proto==0xFF, no?

>  		next_proto = mask->hdr.proto & spec->hdr.proto;
>  	if (item_flags & MLX5_FLOW_LAYER_IPV6_ENCAP) {
>  		if (next_proto == IPPROTO_IPIP || next_proto ==
> IPPROTO_IPV6)
> --
> 2.28.0.546.g385c171
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index c56dac89f9..e0ca8e06b1 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -1977,7 +1977,7 @@  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)
+	if (mask && mask->hdr.proto && spec)
 		next_proto = mask->hdr.proto & spec->hdr.proto;
 	if (item_flags & MLX5_FLOW_LAYER_IPV6_ENCAP) {
 		if (next_proto == IPPROTO_IPIP || next_proto == IPPROTO_IPV6)