DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/i40e: fix parsing tunnel filter issue
@ 2017-01-24  2:44 Beilei Xing
  2017-01-24  2:58 ` Lu, Wenzhuo
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Beilei Xing @ 2017-01-24  2:44 UTC (permalink / raw)
  To: jingjing.wu; +Cc: wenzhuo.lu, dev

VNI of VXLAN is parsed wrongly. The root cause is that
array vni in item VXLAN also uses network byte ordering.

Fixes: d416530e6358 ("net/i40e: parse tunnel filter")

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_flow.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 76bb332..51b3223 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -1196,6 +1196,20 @@ i40e_check_tenant_id_mask(const uint8_t *mask)
 	return is_masked;
 }
 
+static uint32_t
+i40e_flow_set_tenant_id(const uint8_t *vni)
+{
+	uint32_t tenant_id;
+
+#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
+	tenant_id = (vni[0] << 16) | (vni[1] << 8) | vni[2];
+#else
+	tenant_id = vni[0] | (vni[1] << 8) | (vni[2] << 16);
+#endif
+
+	return tenant_id;
+}
+
 /* 1. Last in item should be NULL as range is not supported.
  * 2. Supported filter types: IMAC_IVLAN_TENID, IMAC_IVLAN,
  *    IMAC_TENID, OMAC_TENID_IMAC and IMAC.
@@ -1364,8 +1378,8 @@ i40e_flow_parse_vxlan_pattern(const struct rte_flow_item *pattern,
 			& I40E_TCI_MASK;
 		if (vxlan_spec && vxlan_mask && !is_vni_masked) {
 			/* If there's vxlan */
-			rte_memcpy(&filter->tenant_id, vxlan_spec->vni,
-				   RTE_DIM(vxlan_spec->vni));
+			filter->tenant_id =
+				i40e_flow_set_tenant_id(vxlan_spec->vni);
 			if (!o_eth_spec && !o_eth_mask &&
 				i_eth_spec && i_eth_mask)
 				filter->filter_type =
@@ -1402,8 +1416,8 @@ i40e_flow_parse_vxlan_pattern(const struct rte_flow_item *pattern,
 		/* If there's no inner vlan */
 		if (vxlan_spec && vxlan_mask && !is_vni_masked) {
 			/* If there's vxlan */
-			rte_memcpy(&filter->tenant_id, vxlan_spec->vni,
-				   RTE_DIM(vxlan_spec->vni));
+			filter->tenant_id =
+				i40e_flow_set_tenant_id(vxlan_spec->vni);
 			if (!o_eth_spec && !o_eth_mask &&
 				i_eth_spec && i_eth_mask)
 				filter->filter_type =
-- 
2.5.5

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] net/i40e: fix parsing tunnel filter issue
  2017-01-24  2:44 [dpdk-dev] [PATCH] net/i40e: fix parsing tunnel filter issue Beilei Xing
@ 2017-01-24  2:58 ` Lu, Wenzhuo
  2017-01-24 15:17 ` Ferruh Yigit
  2017-02-06  5:29 ` [dpdk-dev] [PATCH v2] " Beilei Xing
  2 siblings, 0 replies; 6+ messages in thread
From: Lu, Wenzhuo @ 2017-01-24  2:58 UTC (permalink / raw)
  To: Xing, Beilei, Wu, Jingjing; +Cc: dev

Hi,

> -----Original Message-----
> From: Xing, Beilei
> Sent: Tuesday, January 24, 2017 10:44 AM
> To: Wu, Jingjing
> Cc: Lu, Wenzhuo; dev@dpdk.org
> Subject: [PATCH] net/i40e: fix parsing tunnel filter issue
> 
> VNI of VXLAN is parsed wrongly. The root cause is that array vni in item VXLAN
> also uses network byte ordering.
> 
> Fixes: d416530e6358 ("net/i40e: parse tunnel filter")
> 
> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] net/i40e: fix parsing tunnel filter issue
  2017-01-24  2:44 [dpdk-dev] [PATCH] net/i40e: fix parsing tunnel filter issue Beilei Xing
  2017-01-24  2:58 ` Lu, Wenzhuo
@ 2017-01-24 15:17 ` Ferruh Yigit
  2017-02-06  1:38   ` Xing, Beilei
  2017-02-06  5:29 ` [dpdk-dev] [PATCH v2] " Beilei Xing
  2 siblings, 1 reply; 6+ messages in thread
From: Ferruh Yigit @ 2017-01-24 15:17 UTC (permalink / raw)
  To: Beilei Xing, jingjing.wu; +Cc: wenzhuo.lu, dev

On 1/24/2017 2:44 AM, Beilei Xing wrote:
> VNI of VXLAN is parsed wrongly. The root cause is that
> array vni in item VXLAN also uses network byte ordering.
> 
> Fixes: d416530e6358 ("net/i40e: parse tunnel filter")
> 
> Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> ---
>  drivers/net/i40e/i40e_flow.c | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
> index 76bb332..51b3223 100644
> --- a/drivers/net/i40e/i40e_flow.c
> +++ b/drivers/net/i40e/i40e_flow.c
> @@ -1196,6 +1196,20 @@ i40e_check_tenant_id_mask(const uint8_t *mask)
>  	return is_masked;
>  }
>  
> +static uint32_t
> +i40e_flow_set_tenant_id(const uint8_t *vni)
> +{
> +	uint32_t tenant_id;
> +
> +#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
> +	tenant_id = (vni[0] << 16) | (vni[1] << 8) | vni[2];
> +#else
> +	tenant_id = vni[0] | (vni[1] << 8) | (vni[2] << 16);
> +#endif

Instead of a new function, will following do the same?:

uint32_t tenant_id_be= 0;
rte_memcpy(((uint8_t *)&tenant_id_be + 1), vxlan_spec->vni, 3)
filter->tenant_id = rte_be_to_cpu(tenant_id_be);

I think it is easier to understand, what do you think?

Thanks,
ferruh

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] net/i40e: fix parsing tunnel filter issue
  2017-01-24 15:17 ` Ferruh Yigit
@ 2017-02-06  1:38   ` Xing, Beilei
  0 siblings, 0 replies; 6+ messages in thread
From: Xing, Beilei @ 2017-02-06  1:38 UTC (permalink / raw)
  To: Yigit, Ferruh, Wu, Jingjing; +Cc: Lu, Wenzhuo, dev

Hi Ferruh,

Sorry for late reply due to Chinese New Year.

> -----Original Message-----
> From: Yigit, Ferruh
> Sent: Tuesday, January 24, 2017 11:18 PM
> To: Xing, Beilei <beilei.xing@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>; dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix parsing tunnel filter issue
> 
> On 1/24/2017 2:44 AM, Beilei Xing wrote:
> > VNI of VXLAN is parsed wrongly. The root cause is that array vni in
> > item VXLAN also uses network byte ordering.
> >
> > Fixes: d416530e6358 ("net/i40e: parse tunnel filter")
> >
> > Signed-off-by: Beilei Xing <beilei.xing@intel.com>
> > ---
> >  drivers/net/i40e/i40e_flow.c | 22 ++++++++++++++++++----
> >  1 file changed, 18 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/i40e/i40e_flow.c
> > b/drivers/net/i40e/i40e_flow.c index 76bb332..51b3223 100644
> > --- a/drivers/net/i40e/i40e_flow.c
> > +++ b/drivers/net/i40e/i40e_flow.c
> > @@ -1196,6 +1196,20 @@ i40e_check_tenant_id_mask(const uint8_t
> *mask)
> >  	return is_masked;
> >  }
> >
> > +static uint32_t
> > +i40e_flow_set_tenant_id(const uint8_t *vni) {
> > +	uint32_t tenant_id;
> > +
> > +#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
> > +	tenant_id = (vni[0] << 16) | (vni[1] << 8) | vni[2]; #else
> > +	tenant_id = vni[0] | (vni[1] << 8) | (vni[2] << 16); #endif
> 
> Instead of a new function, will following do the same?:
> 
> uint32_t tenant_id_be= 0;
> rte_memcpy(((uint8_t *)&tenant_id_be + 1), vxlan_spec->vni, 3)
> filter->tenant_id = rte_be_to_cpu(tenant_id_be);
> 
> I think it is easier to understand, what do you think?

Agree. Thanks for the comments.

> 
> Thanks,
> ferruh

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH v2] net/i40e: fix parsing tunnel filter issue
  2017-01-24  2:44 [dpdk-dev] [PATCH] net/i40e: fix parsing tunnel filter issue Beilei Xing
  2017-01-24  2:58 ` Lu, Wenzhuo
  2017-01-24 15:17 ` Ferruh Yigit
@ 2017-02-06  5:29 ` Beilei Xing
  2017-02-07 14:12   ` Ferruh Yigit
  2 siblings, 1 reply; 6+ messages in thread
From: Beilei Xing @ 2017-02-06  5:29 UTC (permalink / raw)
  To: jingjing.wu; +Cc: wenzhuo.lu, dev

VNI of VXLAN is parsed wrongly. The root cause is that
array vni in item VXLAN also uses network byte ordering.

Fixes: d416530e6358 ("net/i40e: parse tunnel filter")

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
v2 changes:
 Use rte_be_to_cpu_32 api instead of the new function.

 drivers/net/i40e/i40e_flow.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 76bb332..c14eb22 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -1223,6 +1223,7 @@ i40e_flow_parse_vxlan_pattern(const struct rte_flow_item *pattern,
 	bool is_vni_masked = 0;
 	enum rte_flow_item_type item_type;
 	bool vxlan_flag = 0;
+	uint32_t tenant_id_be = 0;
 
 	for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) {
 		if (item->last) {
@@ -1364,8 +1365,9 @@ i40e_flow_parse_vxlan_pattern(const struct rte_flow_item *pattern,
 			& I40E_TCI_MASK;
 		if (vxlan_spec && vxlan_mask && !is_vni_masked) {
 			/* If there's vxlan */
-			rte_memcpy(&filter->tenant_id, vxlan_spec->vni,
-				   RTE_DIM(vxlan_spec->vni));
+			rte_memcpy(((uint8_t *)&tenant_id_be + 1),
+				   vxlan_spec->vni, 3);
+			filter->tenant_id = rte_be_to_cpu_32(tenant_id_be);
 			if (!o_eth_spec && !o_eth_mask &&
 				i_eth_spec && i_eth_mask)
 				filter->filter_type =
@@ -1402,8 +1404,9 @@ i40e_flow_parse_vxlan_pattern(const struct rte_flow_item *pattern,
 		/* If there's no inner vlan */
 		if (vxlan_spec && vxlan_mask && !is_vni_masked) {
 			/* If there's vxlan */
-			rte_memcpy(&filter->tenant_id, vxlan_spec->vni,
-				   RTE_DIM(vxlan_spec->vni));
+			rte_memcpy(((uint8_t *)&tenant_id_be + 1),
+				   vxlan_spec->vni, 3);
+			filter->tenant_id = rte_be_to_cpu_32(tenant_id_be);
 			if (!o_eth_spec && !o_eth_mask &&
 				i_eth_spec && i_eth_mask)
 				filter->filter_type =
-- 
2.5.5

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/i40e: fix parsing tunnel filter issue
  2017-02-06  5:29 ` [dpdk-dev] [PATCH v2] " Beilei Xing
@ 2017-02-07 14:12   ` Ferruh Yigit
  0 siblings, 0 replies; 6+ messages in thread
From: Ferruh Yigit @ 2017-02-07 14:12 UTC (permalink / raw)
  To: Beilei Xing, jingjing.wu; +Cc: wenzhuo.lu, dev

On 2/6/2017 5:29 AM, Beilei Xing wrote:
> VNI of VXLAN is parsed wrongly. The root cause is that
> array vni in item VXLAN also uses network byte ordering.
> 
> Fixes: d416530e6358 ("net/i40e: parse tunnel filter")
> 
> Signed-off-by: Beilei Xing <beilei.xing@intel.com>

Applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-02-07 14:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-24  2:44 [dpdk-dev] [PATCH] net/i40e: fix parsing tunnel filter issue Beilei Xing
2017-01-24  2:58 ` Lu, Wenzhuo
2017-01-24 15:17 ` Ferruh Yigit
2017-02-06  1:38   ` Xing, Beilei
2017-02-06  5:29 ` [dpdk-dev] [PATCH v2] " Beilei Xing
2017-02-07 14:12   ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).