DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] mempool: check for invalid args on creation
@ 2018-07-17 10:37 Pablo de Lara
  2018-07-20 15:49 ` Andrew Rybchenko
  2018-08-02  0:35 ` [dpdk-dev] [PATCH v2] " Pablo de Lara
  0 siblings, 2 replies; 7+ messages in thread
From: Pablo de Lara @ 2018-07-17 10:37 UTC (permalink / raw)
  To: olivier.matz, arybchenko; +Cc: dev, Pablo de Lara

Currently, a mempool can be created if the number of
objects is zero or the size of these is zero.
In these scenarios, rte_mempool_create should return NULL,
as the mempool created is useless.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 lib/librte_mempool/rte_mempool.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 8c8b9f809..8c9573f1a 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -916,6 +916,18 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
 
+	/* asked for zero items */
+	if (n == 0) {
+		rte_errno = EINVAL;
+		return NULL;
+	}
+
+	/* asked for zero-sized elements */
+	if (elt_size == 0) {
+		rte_errno = EINVAL;
+		return NULL;
+	}
+
 	/* asked cache too big */
 	if (cache_size > RTE_MEMPOOL_CACHE_MAX_SIZE ||
 	    CALC_CACHE_FLUSHTHRESH(cache_size) > n) {
-- 
2.14.4

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

* Re: [dpdk-dev] [PATCH] mempool: check for invalid args on creation
  2018-07-17 10:37 [dpdk-dev] [PATCH] mempool: check for invalid args on creation Pablo de Lara
@ 2018-07-20 15:49 ` Andrew Rybchenko
  2018-08-01 18:16   ` De Lara Guarch, Pablo
  2018-08-02  0:35 ` [dpdk-dev] [PATCH v2] " Pablo de Lara
  1 sibling, 1 reply; 7+ messages in thread
From: Andrew Rybchenko @ 2018-07-20 15:49 UTC (permalink / raw)
  To: Pablo de Lara, olivier.matz; +Cc: dev

On 17.07.2018 13:37, Pablo de Lara wrote:
> Currently, a mempool can be created if the number of
> objects is zero or the size of these is zero.
> In these scenarios, rte_mempool_create should return NULL,
> as the mempool created is useless.
>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---
>   lib/librte_mempool/rte_mempool.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
>
> diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
> index 8c8b9f809..8c9573f1a 100644
> --- a/lib/librte_mempool/rte_mempool.c
> +++ b/lib/librte_mempool/rte_mempool.c
> @@ -916,6 +916,18 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
>   
>   	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
>   
> +	/* asked for zero items */
> +	if (n == 0) {
> +		rte_errno = EINVAL;
> +		return NULL;
> +	}

I agree which the check since attempt to populate it will most likely 
fail with -ENOSPC.

> +
> +	/* asked for zero-sized elements */
> +	if (elt_size == 0) {
> +		rte_errno = EINVAL;
> +		return NULL;
> +	}
> +

I'm not sure about this one. I could imagine the case when mempool 
elements are
used just as unique markers. So, I'm not sure that we should restrict 
such usage.

>   	/* asked cache too big */
>   	if (cache_size > RTE_MEMPOOL_CACHE_MAX_SIZE ||
>   	    CALC_CACHE_FLUSHTHRESH(cache_size) > n) {

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

* Re: [dpdk-dev] [PATCH] mempool: check for invalid args on creation
  2018-07-20 15:49 ` Andrew Rybchenko
@ 2018-08-01 18:16   ` De Lara Guarch, Pablo
  2018-08-02  7:15     ` Andrew Rybchenko
  0 siblings, 1 reply; 7+ messages in thread
From: De Lara Guarch, Pablo @ 2018-08-01 18:16 UTC (permalink / raw)
  To: Andrew Rybchenko, olivier.matz; +Cc: dev

Hi Andrew,

> -----Original Message-----
> From: Andrew Rybchenko [mailto:arybchenko@solarflare.com]
> Sent: Friday, July 20, 2018 4:49 PM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;
> olivier.matz@6wind.com
> Cc: dev@dpdk.org
> Subject: Re: [PATCH] mempool: check for invalid args on creation
> 
> On 17.07.2018 13:37, Pablo de Lara wrote:
> > Currently, a mempool can be created if the number of objects is zero
> > or the size of these is zero.
> > In these scenarios, rte_mempool_create should return NULL, as the
> > mempool created is useless.
> >
> > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> > ---
> >   lib/librte_mempool/rte_mempool.c | 12 ++++++++++++
> >   1 file changed, 12 insertions(+)
> >
> > diff --git a/lib/librte_mempool/rte_mempool.c
> > b/lib/librte_mempool/rte_mempool.c
> > index 8c8b9f809..8c9573f1a 100644
> > --- a/lib/librte_mempool/rte_mempool.c
> > +++ b/lib/librte_mempool/rte_mempool.c
> > @@ -916,6 +916,18 @@ rte_mempool_create_empty(const char *name,
> > unsigned n, unsigned elt_size,
> >
> >   	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head,
> > rte_mempool_list);
> >
> > +	/* asked for zero items */
> > +	if (n == 0) {
> > +		rte_errno = EINVAL;
> > +		return NULL;
> > +	}
> 
> I agree which the check since attempt to populate it will most likely fail with -
> ENOSPC.
> 
> > +
> > +	/* asked for zero-sized elements */
> > +	if (elt_size == 0) {
> > +		rte_errno = EINVAL;
> > +		return NULL;
> > +	}
> > +
> 
> I'm not sure about this one. I could imagine the case when mempool elements
> are used just as unique markers. So, I'm not sure that we should restrict such
> usage.

I can drop this one and send a v2 on the first check. Is that OK?

Thanks!
Pablo


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

* [dpdk-dev] [PATCH v2] mempool: check for invalid args on creation
  2018-07-17 10:37 [dpdk-dev] [PATCH] mempool: check for invalid args on creation Pablo de Lara
  2018-07-20 15:49 ` Andrew Rybchenko
@ 2018-08-02  0:35 ` Pablo de Lara
  2018-08-02 11:10   ` Andrew Rybchenko
  1 sibling, 1 reply; 7+ messages in thread
From: Pablo de Lara @ 2018-08-02  0:35 UTC (permalink / raw)
  To: olivier.matz, arybchenko; +Cc: dev, Pablo de Lara

Currently, a mempool can be created if the number of
objects is zero. However, in this scenario,
rte_mempool_create should return NULL,
as the mempool created is useless otherwise.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 lib/librte_mempool/rte_mempool.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 8c8b9f809..a24a14887 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -916,6 +916,12 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
 
 	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list);
 
+	/* asked for zero items */
+	if (n == 0) {
+		rte_errno = EINVAL;
+		return NULL;
+	}
+
 	/* asked cache too big */
 	if (cache_size > RTE_MEMPOOL_CACHE_MAX_SIZE ||
 	    CALC_CACHE_FLUSHTHRESH(cache_size) > n) {
-- 
2.17.1

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

* Re: [dpdk-dev] [PATCH] mempool: check for invalid args on creation
  2018-08-01 18:16   ` De Lara Guarch, Pablo
@ 2018-08-02  7:15     ` Andrew Rybchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Rybchenko @ 2018-08-02  7:15 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, olivier.matz; +Cc: dev

On 01.08.2018 21:16, De Lara Guarch, Pablo wrote:
> Hi Andrew,
>
>> -----Original Message-----
>> From: Andrew Rybchenko [mailto:arybchenko@solarflare.com]
>> Sent: Friday, July 20, 2018 4:49 PM
>> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;
>> olivier.matz@6wind.com
>> Cc: dev@dpdk.org
>> Subject: Re: [PATCH] mempool: check for invalid args on creation
>>
>> On 17.07.2018 13:37, Pablo de Lara wrote:
>>> Currently, a mempool can be created if the number of objects is zero
>>> or the size of these is zero.
>>> In these scenarios, rte_mempool_create should return NULL, as the
>>> mempool created is useless.
>>>
>>> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
>>> ---
>>>    lib/librte_mempool/rte_mempool.c | 12 ++++++++++++
>>>    1 file changed, 12 insertions(+)
>>>
>>> diff --git a/lib/librte_mempool/rte_mempool.c
>>> b/lib/librte_mempool/rte_mempool.c
>>> index 8c8b9f809..8c9573f1a 100644
>>> --- a/lib/librte_mempool/rte_mempool.c
>>> +++ b/lib/librte_mempool/rte_mempool.c
>>> @@ -916,6 +916,18 @@ rte_mempool_create_empty(const char *name,
>>> unsigned n, unsigned elt_size,
>>>
>>>    	mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head,
>>> rte_mempool_list);
>>>
>>> +	/* asked for zero items */
>>> +	if (n == 0) {
>>> +		rte_errno = EINVAL;
>>> +		return NULL;
>>> +	}
>> I agree which the check since attempt to populate it will most likely fail with -
>> ENOSPC.
>>
>>> +
>>> +	/* asked for zero-sized elements */
>>> +	if (elt_size == 0) {
>>> +		rte_errno = EINVAL;
>>> +		return NULL;
>>> +	}
>>> +
>> I'm not sure about this one. I could imagine the case when mempool elements
>> are used just as unique markers. So, I'm not sure that we should restrict such
>> usage.
> I can drop this one and send a v2 on the first check. Is that OK?

Yes. Thanks.

Andrew.

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

* Re: [dpdk-dev] [PATCH v2] mempool: check for invalid args on creation
  2018-08-02  0:35 ` [dpdk-dev] [PATCH v2] " Pablo de Lara
@ 2018-08-02 11:10   ` Andrew Rybchenko
  2018-08-05 13:35     ` Thomas Monjalon
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Rybchenko @ 2018-08-02 11:10 UTC (permalink / raw)
  To: Pablo de Lara, olivier.matz; +Cc: dev

On 02.08.2018 03:35, Pablo de Lara wrote:
> Currently, a mempool can be created if the number of
> objects is zero. However, in this scenario,
> rte_mempool_create should return NULL,
> as the mempool created is useless otherwise.
>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>

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

* Re: [dpdk-dev] [PATCH v2] mempool: check for invalid args on creation
  2018-08-02 11:10   ` Andrew Rybchenko
@ 2018-08-05 13:35     ` Thomas Monjalon
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2018-08-05 13:35 UTC (permalink / raw)
  To: Pablo de Lara; +Cc: dev, Andrew Rybchenko, olivier.matz

02/08/2018 13:10, Andrew Rybchenko:
> On 02.08.2018 03:35, Pablo de Lara wrote:
> > Currently, a mempool can be created if the number of
> > objects is zero. However, in this scenario,
> > rte_mempool_create should return NULL,
> > as the mempool created is useless otherwise.
> >
> > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> 
> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>

Applied, thanks

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

end of thread, other threads:[~2018-08-05 13:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-17 10:37 [dpdk-dev] [PATCH] mempool: check for invalid args on creation Pablo de Lara
2018-07-20 15:49 ` Andrew Rybchenko
2018-08-01 18:16   ` De Lara Guarch, Pablo
2018-08-02  7:15     ` Andrew Rybchenko
2018-08-02  0:35 ` [dpdk-dev] [PATCH v2] " Pablo de Lara
2018-08-02 11:10   ` Andrew Rybchenko
2018-08-05 13:35     ` Thomas Monjalon

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).