[v2] net/mlx5: fix incorrect L3/L4 layer chosen with tunnel

Message ID 1574338170-167657-1-git-send-email-suanmingm@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series [v2] net/mlx5: fix incorrect L3/L4 layer chosen with tunnel |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compilation success Compile Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation fail Compilation issues
ci/travis-robot success Travis build: passed

Commit Message

Suanming Mou Nov. 21, 2019, 12:09 p.m. UTC
  For tunnel mode, there maybe two L3/L4 layer match pattern items,
the inner layer follows the outer layer as the latter layer item,
the TTL and port modify actions should handle the outermost layer.

Current the outer and inner L3/L4 layers are both regared as the
outer layer in flow_dv_attr_init(), it caueses actions may use the
incorrect latter inner protocal for header modifier.

Check former L3/L4 outer layer existence avoid set the incorrect inner
layer to the flow attr.

Fixes: 4bb14c83df95 ("net/mlx5: support modify header using Direct Verbs")
Cc: dekelp@mellanox.com
Cc: stable@dpdk.org

Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
---

v2:
* Add L4 layer check.

---
 drivers/net/mlx5/mlx5_flow_dv.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
  

Comments

Suanming Mou Nov. 22, 2019, 1:29 a.m. UTC | #1
On 11/21/2019 8:09 PM, Suanming Mou wrote:
> For tunnel mode, there maybe two L3/L4 layer match pattern items,
> the inner layer follows the outer layer as the latter layer item,
> the TTL and port modify actions should handle the outermost layer.
>
> Current the outer and inner L3/L4 layers are both regared as the
> outer layer in flow_dv_attr_init(), it caueses actions may use the
> incorrect latter inner protocal for header modifier.
>
> Check former L3/L4 outer layer existence avoid set the incorrect inner
> layer to the flow attr.
>
> Fixes: 4bb14c83df95 ("net/mlx5: support modify header using Direct Verbs")
> Cc: dekelp@mellanox.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
> ---
>
> v2:
> * Add L4 layer check.
>
> ---
>   drivers/net/mlx5/mlx5_flow_dv.c | 15 +++++++++++----
>   1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
> index c402a8d..688291f 100644
> --- a/drivers/net/mlx5/mlx5_flow_dv.c
> +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> @@ -73,6 +73,9 @@
>   /**
>    * Initialize flow attributes structure according to flow items' types.
>    *
> + * flow_dv_validate() avoids multiple L3/L4 layers cases other than tunnel
> + * mode. For tunnel mode, the items to be modified are the outermost ones.
> + *
>    * @param[in] item
>    *   Pointer to item specification.
>    * @param[out] attr
> @@ -84,16 +87,20 @@
>   	for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
>   		switch (item->type) {
>   		case RTE_FLOW_ITEM_TYPE_IPV4:
> -			attr->ipv4 = 1;
> +			if (!attr->ipv6)
> +				attr->ipv4 = 1;
>   			break;
>   		case RTE_FLOW_ITEM_TYPE_IPV6:
> -			attr->ipv6 = 1;
> +			if (!attr->ipv4)
> +				attr->ipv6 = 1;
>   			break;
>   		case RTE_FLOW_ITEM_TYPE_UDP:
> -			attr->udp = 1;
> +			if (!attr->tcp)
> +				attr->udp = 1;
>   			break;
>   		case RTE_FLOW_ITEM_TYPE_TCP:
> -			attr->tcp = 1;
> +			if (!attr->udp)
> +				attr->tcp = 1;
>   			break;
>   		default:
>   			break;

Sorry for that v2 mail missed mail to Matan and Slava. Just add.

Thanks

SuanmingMou
  
Matan Azrad Nov. 24, 2019, 7:05 a.m. UTC | #2
From: Suanming Mou
> On 11/21/2019 8:09 PM, Suanming Mou wrote:
> > For tunnel mode, there maybe two L3/L4 layer match pattern items, the
> > inner layer follows the outer layer as the latter layer item, the TTL
> > and port modify actions should handle the outermost layer.
> >
> > Current the outer and inner L3/L4 layers are both regared as the outer
> > layer in flow_dv_attr_init(), it caueses actions may use the incorrect
> > latter inner protocal for header modifier.
> >
> > Check former L3/L4 outer layer existence avoid set the incorrect inner
> > layer to the flow attr.
> >
> > Fixes: 4bb14c83df95 ("net/mlx5: support modify header using Direct
> > Verbs")
> > Cc: dekelp@mellanox.com
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
  
Raslan Darawsheh Nov. 24, 2019, 9:15 a.m. UTC | #3
Hi,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Suanming Mou
> Sent: Thursday, November 21, 2019 2:10 PM
> To: dev@dpdk.org
> Cc: Dekel Peled <dekelp@mellanox.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH v2] net/mlx5: fix incorrect L3/L4 layer chosen
> with tunnel
> 
> For tunnel mode, there maybe two L3/L4 layer match pattern items,
> the inner layer follows the outer layer as the latter layer item,
> the TTL and port modify actions should handle the outermost layer.
> 
> Current the outer and inner L3/L4 layers are both regared as the
> outer layer in flow_dv_attr_init(), it caueses actions may use the
> incorrect latter inner protocal for header modifier.
> 
> Check former L3/L4 outer layer existence avoid set the incorrect inner
> layer to the flow attr.
> 
> Fixes: 4bb14c83df95 ("net/mlx5: support modify header using Direct Verbs")
> Cc: dekelp@mellanox.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
> ---
> 
> v2:
> * Add L4 layer check.
> 
> ---
>  drivers/net/mlx5/mlx5_flow_dv.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_flow_dv.c
> b/drivers/net/mlx5/mlx5_flow_dv.c
> index c402a8d..688291f 100644
> --- a/drivers/net/mlx5/mlx5_flow_dv.c
> +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> @@ -73,6 +73,9 @@
>  /**
>   * Initialize flow attributes structure according to flow items' types.
>   *
> + * flow_dv_validate() avoids multiple L3/L4 layers cases other than tunnel
> + * mode. For tunnel mode, the items to be modified are the outermost
> ones.
> + *
>   * @param[in] item
>   *   Pointer to item specification.
>   * @param[out] attr
> @@ -84,16 +87,20 @@
>  	for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
>  		switch (item->type) {
>  		case RTE_FLOW_ITEM_TYPE_IPV4:
> -			attr->ipv4 = 1;
> +			if (!attr->ipv6)
> +				attr->ipv4 = 1;
>  			break;
>  		case RTE_FLOW_ITEM_TYPE_IPV6:
> -			attr->ipv6 = 1;
> +			if (!attr->ipv4)
> +				attr->ipv6 = 1;
>  			break;
>  		case RTE_FLOW_ITEM_TYPE_UDP:
> -			attr->udp = 1;
> +			if (!attr->tcp)
> +				attr->udp = 1;
>  			break;
>  		case RTE_FLOW_ITEM_TYPE_TCP:
> -			attr->tcp = 1;
> +			if (!attr->udp)
> +				attr->tcp = 1;
>  			break;
>  		default:
>  			break;
> --
> 1.8.3.1


Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index c402a8d..688291f 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -73,6 +73,9 @@ 
 /**
  * Initialize flow attributes structure according to flow items' types.
  *
+ * flow_dv_validate() avoids multiple L3/L4 layers cases other than tunnel
+ * mode. For tunnel mode, the items to be modified are the outermost ones.
+ *
  * @param[in] item
  *   Pointer to item specification.
  * @param[out] attr
@@ -84,16 +87,20 @@ 
 	for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
 		switch (item->type) {
 		case RTE_FLOW_ITEM_TYPE_IPV4:
-			attr->ipv4 = 1;
+			if (!attr->ipv6)
+				attr->ipv4 = 1;
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
-			attr->ipv6 = 1;
+			if (!attr->ipv4)
+				attr->ipv6 = 1;
 			break;
 		case RTE_FLOW_ITEM_TYPE_UDP:
-			attr->udp = 1;
+			if (!attr->tcp)
+				attr->udp = 1;
 			break;
 		case RTE_FLOW_ITEM_TYPE_TCP:
-			attr->tcp = 1;
+			if (!attr->udp)
+				attr->tcp = 1;
 			break;
 		default:
 			break;