DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] ethdev: fix variable length flow elements support
@ 2021-10-26  9:05 Gregory Etelson
  2021-11-03 21:04 ` Ferruh Yigit
  2021-11-04 11:27 ` [dpdk-dev] [PATCH v2] " Gregory Etelson
  0 siblings, 2 replies; 7+ messages in thread
From: Gregory Etelson @ 2021-10-26  9:05 UTC (permalink / raw)
  To: dev, getelson
  Cc: matan, rasland, Viacheslav Ovsiienko, Ori Kam, Thomas Monjalon,
	Ferruh Yigit, Andrew Rybchenko

RTE flow API defines two flow items and actions types - common
and PMD private. Common RTE flow types are defined in rte_flow.h
while PMD private types restricted to specific PMD only.
RTE flow API allows PMD private types in flow rule,
but it must not try to interpret private item or acton properties.

Current implementation tried to locate PMD private element, item or
action, in common flow elements records.

The patch restricts access to common flow elements records for
non-private PMD types only.

Fixes: 6cf72047332b ("ethdev: support flow elements with variable length")

Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 lib/ethdev/rte_flow.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index d268784532..a93f68abbc 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -54,11 +54,13 @@ rte_flow_conv_copy(void *buf, const void *data, const size_t size,
 	/**
 	 * Allow PMD private flow item
 	 */
-	size_t sz = type >= 0 ? desc[type].size : sizeof(void *);
+	bool rte_type = type >= 0;
+
+	size_t sz = rte_type ? desc[type].size : sizeof(void *);
 	if (buf == NULL || data == NULL)
 		return 0;
 	rte_memcpy(buf, data, (size > sz ? sz : size));
-	if (desc[type].desc_fn)
+	if (rte_type && desc[type].desc_fn)
 		sz += desc[type].desc_fn(size > 0 ? buf : NULL, data);
 	return sz;
 }
-- 
2.33.1


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

* Re: [dpdk-dev] [PATCH] ethdev: fix variable length flow elements support
  2021-10-26  9:05 [dpdk-dev] [PATCH] ethdev: fix variable length flow elements support Gregory Etelson
@ 2021-11-03 21:04 ` Ferruh Yigit
  2021-11-04  5:33   ` Gregory Etelson
  2021-11-04 11:27 ` [dpdk-dev] [PATCH v2] " Gregory Etelson
  1 sibling, 1 reply; 7+ messages in thread
From: Ferruh Yigit @ 2021-11-03 21:04 UTC (permalink / raw)
  To: Gregory Etelson, Ori Kam
  Cc: matan, rasland, Viacheslav Ovsiienko, Thomas Monjalon,
	Andrew Rybchenko, dev

On 10/26/2021 10:05 AM, Gregory Etelson wrote:
> RTE flow API defines two flow items and actions types - common
> and PMD private. Common RTE flow types are defined in rte_flow.h
> while PMD private types restricted to specific PMD only.
> RTE flow API allows PMD private types in flow rule,
> but it must not try to interpret private item or acton properties.
> 
> Current implementation tried to locate PMD private element, item or
> action, in common flow elements records.
> 
> The patch restricts access to common flow elements records for
> non-private PMD types only.
> 
> Fixes: 6cf72047332b ("ethdev: support flow elements with variable length")
> 
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> ---
>   lib/ethdev/rte_flow.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
> index d268784532..a93f68abbc 100644
> --- a/lib/ethdev/rte_flow.c
> +++ b/lib/ethdev/rte_flow.c
> @@ -54,11 +54,13 @@ rte_flow_conv_copy(void *buf, const void *data, const size_t size,
>   	/**
>   	 * Allow PMD private flow item
>   	 */
> -	size_t sz = type >= 0 ? desc[type].size : sizeof(void *);
> +	bool rte_type = type >= 0;
> +
> +	size_t sz = rte_type ? desc[type].size : sizeof(void *);
>   	if (buf == NULL || data == NULL)
>   		return 0;
>   	rte_memcpy(buf, data, (size > sz ? sz : size));
> -	if (desc[type].desc_fn)

Was this (possible) negative array index intentional, or are you fixing it?

> +	if (rte_type && desc[type].desc_fn)
>   		sz += desc[type].desc_fn(size > 0 ? buf : NULL, data);
>   	return sz;
>   }
> 


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

* Re: [dpdk-dev] [PATCH] ethdev: fix variable length flow elements support
  2021-11-03 21:04 ` Ferruh Yigit
@ 2021-11-04  5:33   ` Gregory Etelson
  2021-11-04  9:10     ` Ferruh Yigit
  0 siblings, 1 reply; 7+ messages in thread
From: Gregory Etelson @ 2021-11-04  5:33 UTC (permalink / raw)
  To: Ferruh Yigit, Ori Kam
  Cc: Matan Azrad, Raslan Darawsheh, Slava Ovsiienko,
	NBU-Contact-Thomas Monjalon, Andrew Rybchenko, dev

Hello Ferruh,

> >   lib/ethdev/rte_flow.c | 6 ++++--
> >   1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/lib/ethdev/rte_flow.c
> b/lib/ethdev/rte_flow.c
> > index d268784532..a93f68abbc 100644
> > --- a/lib/ethdev/rte_flow.c
> > +++ b/lib/ethdev/rte_flow.c
> > @@ -54,11 +54,13 @@
> rte_flow_conv_copy(void *buf, const void *data,
> const size_t size,
> >       /**
> >        * Allow PMD private flow item
> >        */
> > -     size_t sz = type >= 0 ? desc[type].size :
> sizeof(void *);
> > +     bool rte_type = type >= 0;
> > +
> > +     size_t sz = rte_type ? desc[type].size :
> sizeof(void *);
> >       if (buf == NULL || data == NULL)
> >               return 0;
> >       rte_memcpy(buf, data, (size > sz ? sz :
> size));
> > -     if (desc[type].desc_fn)
> 
> Was this (possible) negative array index
> intentional, or are you fixing it?
> 

Negative type values assigned to PMD private items and actions. 
RTE allows private PMD types in flow rules since 
5d1bff8fe2 ethdev: allow negative values in flow rule types
We construct flow rules with private PMD types
to implement tunnel offload.
However, negative type must not be used as index in
rte_flow_desc_item[] and rte_flow_desc_action[] arrays.

> > +     if (rte_type && desc[type].desc_fn)
> >               sz += desc[type].desc_fn(size > 0 ? buf
> : NULL, data);
> >       return sz;
> >   }
> >


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

* Re: [dpdk-dev] [PATCH] ethdev: fix variable length flow elements support
  2021-11-04  5:33   ` Gregory Etelson
@ 2021-11-04  9:10     ` Ferruh Yigit
  2021-11-04  9:20       ` Gregory Etelson
  0 siblings, 1 reply; 7+ messages in thread
From: Ferruh Yigit @ 2021-11-04  9:10 UTC (permalink / raw)
  To: Gregory Etelson, Ori Kam
  Cc: Matan Azrad, Raslan Darawsheh, Slava Ovsiienko,
	NBU-Contact-Thomas Monjalon, Andrew Rybchenko, dev

On 11/4/2021 5:33 AM, Gregory Etelson wrote:
> Hello Ferruh,
> 
>>>    lib/ethdev/rte_flow.c | 6 ++++--
>>>    1 file changed, 4 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/lib/ethdev/rte_flow.c
>> b/lib/ethdev/rte_flow.c
>>> index d268784532..a93f68abbc 100644
>>> --- a/lib/ethdev/rte_flow.c
>>> +++ b/lib/ethdev/rte_flow.c
>>> @@ -54,11 +54,13 @@
>> rte_flow_conv_copy(void *buf, const void *data,
>> const size_t size,
>>>        /**
>>>         * Allow PMD private flow item
>>>         */
>>> -     size_t sz = type >= 0 ? desc[type].size :
>> sizeof(void *);
>>> +     bool rte_type = type >= 0;
>>> +
>>> +     size_t sz = rte_type ? desc[type].size :
>> sizeof(void *);
>>>        if (buf == NULL || data == NULL)
>>>                return 0;
>>>        rte_memcpy(buf, data, (size > sz ? sz :
>> size));
>>> -     if (desc[type].desc_fn)
>>
>> Was this (possible) negative array index
>> intentional, or are you fixing it?
>>
> 
> Negative type values assigned to PMD private items and actions.
> RTE allows private PMD types in flow rules since
> 5d1bff8fe2 ethdev: allow negative values in flow rule types
> We construct flow rules with private PMD types
> to implement tunnel offload.
> However, negative type must not be used as index in
> rte_flow_desc_item[] and rte_flow_desc_action[] arrays.
> 

That is what I assumed, but wasn't clear from commit log, commit log
reads as it is updating an intended usage.

>>> +     if (rte_type && desc[type].desc_fn)
>>>                sz += desc[type].desc_fn(size > 0 ? buf
>> : NULL, data);
>>>        return sz;
>>>    }
>>>
> 


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

* Re: [dpdk-dev] [PATCH] ethdev: fix variable length flow elements support
  2021-11-04  9:10     ` Ferruh Yigit
@ 2021-11-04  9:20       ` Gregory Etelson
  0 siblings, 0 replies; 7+ messages in thread
From: Gregory Etelson @ 2021-11-04  9:20 UTC (permalink / raw)
  To: Ferruh Yigit, Ori Kam
  Cc: Matan Azrad, Raslan Darawsheh, Slava Ovsiienko,
	NBU-Contact-Thomas Monjalon, Andrew Rybchenko, dev

Hello Ferruh,

..snip..
> >
> > Negative type values assigned to PMD private
> items and actions.
> > RTE allows private PMD types in flow rules
> since
> > 5d1bff8fe2 ethdev: allow negative values in
> flow rule types
> > We construct flow rules with private PMD
> types
> > to implement tunnel offload.
> > However, negative type must not be used as
> index in
> > rte_flow_desc_item[] and
> rte_flow_desc_action[] arrays.
> >
> 
> That is what I assumed, but wasn't clear from
> commit log, commit log
> reads as it is updating an intended usage.
> 

I'll update the commit message in v2.

> >>> +     if (rte_type && desc[type].desc_fn)
> >>>                sz += desc[type].desc_fn(size > 0 ?
> buf
> >> : NULL, data);
> >>>        return sz;
> >>>    }
> >>>
> >

Regards,
Gregory


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

* [dpdk-dev] [PATCH v2] ethdev: fix variable length flow elements support
  2021-10-26  9:05 [dpdk-dev] [PATCH] ethdev: fix variable length flow elements support Gregory Etelson
  2021-11-03 21:04 ` Ferruh Yigit
@ 2021-11-04 11:27 ` Gregory Etelson
  2021-11-04 12:46   ` Ferruh Yigit
  1 sibling, 1 reply; 7+ messages in thread
From: Gregory Etelson @ 2021-11-04 11:27 UTC (permalink / raw)
  To: dev, getelson, viacheslavo
  Cc: ferruh.yigit, Ori Kam, Thomas Monjalon, Andrew Rybchenko

RTE flow API defines two flow elements types - common and PMD private.
Common RTE flow types are defined in rte_flow.h while PMD private
types exists inside specific PMD only. Application can create a flow
rule with PMD private items or actions. RTE flow API restricts
private PMD types to negative values.

Current implementation tried to use negative PMD private item type
value as index in the rte_flow_desc_item[] array.

The patch allows access to rte_flow_desc_item[] and
rte_flow_desc_action[] arrays to non-private PMD types only.

Fixes: 6cf72047332b ("ethdev: support flow elements with variable length")
Signed-off-by: Gregory Etelson <getelson@nvidia.com>
---
v2: Update the patch comment.
---
 lib/ethdev/rte_flow.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c
index d268784532..a93f68abbc 100644
--- a/lib/ethdev/rte_flow.c
+++ b/lib/ethdev/rte_flow.c
@@ -54,11 +54,13 @@ rte_flow_conv_copy(void *buf, const void *data, const size_t size,
 	/**
 	 * Allow PMD private flow item
 	 */
-	size_t sz = type >= 0 ? desc[type].size : sizeof(void *);
+	bool rte_type = type >= 0;
+
+	size_t sz = rte_type ? desc[type].size : sizeof(void *);
 	if (buf == NULL || data == NULL)
 		return 0;
 	rte_memcpy(buf, data, (size > sz ? sz : size));
-	if (desc[type].desc_fn)
+	if (rte_type && desc[type].desc_fn)
 		sz += desc[type].desc_fn(size > 0 ? buf : NULL, data);
 	return sz;
 }
-- 
2.33.1


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

* Re: [dpdk-dev] [PATCH v2] ethdev: fix variable length flow elements support
  2021-11-04 11:27 ` [dpdk-dev] [PATCH v2] " Gregory Etelson
@ 2021-11-04 12:46   ` Ferruh Yigit
  0 siblings, 0 replies; 7+ messages in thread
From: Ferruh Yigit @ 2021-11-04 12:46 UTC (permalink / raw)
  To: Gregory Etelson, dev, viacheslavo
  Cc: Ori Kam, Thomas Monjalon, Andrew Rybchenko

On 11/4/2021 11:27 AM, Gregory Etelson wrote:
> RTE flow API defines two flow elements types - common and PMD private.
> Common RTE flow types are defined in rte_flow.h while PMD private
> types exists inside specific PMD only. Application can create a flow
> rule with PMD private items or actions. RTE flow API restricts
> private PMD types to negative values.
> 
> Current implementation tried to use negative PMD private item type
> value as index in the rte_flow_desc_item[] array.
> 
> The patch allows access to rte_flow_desc_item[] and
> rte_flow_desc_action[] arrays to non-private PMD types only.
> 
> Fixes: 6cf72047332b ("ethdev: support flow elements with variable length")
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

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

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

end of thread, other threads:[~2021-11-04 12:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-26  9:05 [dpdk-dev] [PATCH] ethdev: fix variable length flow elements support Gregory Etelson
2021-11-03 21:04 ` Ferruh Yigit
2021-11-04  5:33   ` Gregory Etelson
2021-11-04  9:10     ` Ferruh Yigit
2021-11-04  9:20       ` Gregory Etelson
2021-11-04 11:27 ` [dpdk-dev] [PATCH v2] " Gregory Etelson
2021-11-04 12:46   ` 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).