DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] hash: separate param checks in hash create func
@ 2024-07-26 14:54 Niall Meade
  2024-09-04 17:28 ` Medvedkin, Vladimir
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Niall Meade @ 2024-07-26 14:54 UTC (permalink / raw)
  To: Thomas Monjalon, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin
  Cc: dev, Niall Meade

Separated name, entries and key_len parameter checks in
rte_hash_create().  Also made the error messages more
informative/verbose to help with debugging. Also added myself to the
mailing list.

Signed-off-by: Niall Meade <niall.meade@intel.com>

---

I had name set to NULL in the parameters I was passing to
rte_hash_create() and the error message I got didn't specify which
parameter was invalid.
---
 .mailmap                   |  1 +
 lib/hash/rte_cuckoo_hash.c | 22 ++++++++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/.mailmap b/.mailmap
index 8aef1c59a4..e2a1d55203 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1054,6 +1054,7 @@ Nelson Escobar <neescoba@cisco.com>
 Nemanja Marjanovic <nemanja.marjanovic@intel.com>
 Netanel Belgazal <netanel@amazon.com>
 Netanel Gonen <netanelg@mellanox.com>
+Niall Meade <niall.meade@intel.com>
 Niall Power <niall.power@intel.com>
 Nicholas Pratte <npratte@iol.unh.edu>
 Nick Connolly <nick.connolly@arm.com> <nick.connolly@mayadata.io>
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 577b5839d3..97d55ca23b 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -190,11 +190,18 @@ rte_hash_create(const struct rte_hash_parameters *params)
 
 	/* Check for valid parameters */
 	if ((params->entries > RTE_HASH_ENTRIES_MAX) ||
-			(params->entries < RTE_HASH_BUCKET_ENTRIES) ||
-			(params->name == NULL) ||
-			(params->key_len == 0)) {
+			(params->entries < RTE_HASH_BUCKET_ENTRIES)) {
 		rte_errno = EINVAL;
-		HASH_LOG(ERR, "%s has invalid parameters", __func__);
+		HASH_LOG(ERR, "%s has invalid parameters, entries must be "
+		 "in the range %d to %d inclusive", __func__,
+		  RTE_HASH_BUCKET_ENTRIES, RTE_HASH_ENTRIES_MAX);
+		return NULL;
+	}
+
+	if (params->key_len == 0) {
+		rte_errno = EINVAL;
+		HASH_LOG(ERR, "%s has invalid parameters, key_len must be "
+		 "greater than 0", __func__);
 		return NULL;
 	}
 
@@ -204,6 +211,13 @@ rte_hash_create(const struct rte_hash_parameters *params)
 		return NULL;
 	}
 
+	if (params->name == NULL) {
+		rte_errno = EINVAL;
+		HASH_LOG(ERR, "%s has invalid parameters, name can't be NULL",
+			__func__);
+		return NULL;
+	}
+
 	/* Validate correct usage of extra options */
 	if ((params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY) &&
 	    (params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)) {
-- 
2.34.1

--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263


This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). Any review or distribution by others is
strictly prohibited. If you are not the intended recipient, please contact the
sender and delete all copies.


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

* Re: [PATCH] hash: separate param checks in hash create func
  2024-07-26 14:54 [PATCH] hash: separate param checks in hash create func Niall Meade
@ 2024-09-04 17:28 ` Medvedkin, Vladimir
  2024-10-07 21:08 ` Stephen Hemminger
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: Medvedkin, Vladimir @ 2024-09-04 17:28 UTC (permalink / raw)
  To: Niall Meade, Thomas Monjalon, Yipeng Wang, Sameh Gobriel,
	Bruce Richardson
  Cc: dev

Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>

On 26/07/2024 15:54, Niall Meade wrote:
> Separated name, entries and key_len parameter checks in
> rte_hash_create().  Also made the error messages more
> informative/verbose to help with debugging. Also added myself to the
> mailing list.
>
> Signed-off-by: Niall Meade <niall.meade@intel.com>
>
> ---
>
> I had name set to NULL in the parameters I was passing to
> rte_hash_create() and the error message I got didn't specify which
> parameter was invalid.
> ---
>   .mailmap                   |  1 +
>   lib/hash/rte_cuckoo_hash.c | 22 ++++++++++++++++++----
>   2 files changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/.mailmap b/.mailmap
> index 8aef1c59a4..e2a1d55203 100644
> --- a/.mailmap
> +++ b/.mailmap
> @@ -1054,6 +1054,7 @@ Nelson Escobar <neescoba@cisco.com>
>   Nemanja Marjanovic <nemanja.marjanovic@intel.com>
>   Netanel Belgazal <netanel@amazon.com>
>   Netanel Gonen <netanelg@mellanox.com>
> +Niall Meade <niall.meade@intel.com>
>   Niall Power <niall.power@intel.com>
>   Nicholas Pratte <npratte@iol.unh.edu>
>   Nick Connolly <nick.connolly@arm.com> <nick.connolly@mayadata.io>
> diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
> index 577b5839d3..97d55ca23b 100644
> --- a/lib/hash/rte_cuckoo_hash.c
> +++ b/lib/hash/rte_cuckoo_hash.c
> @@ -190,11 +190,18 @@ rte_hash_create(const struct rte_hash_parameters *params)
>   
>   	/* Check for valid parameters */
>   	if ((params->entries > RTE_HASH_ENTRIES_MAX) ||
> -			(params->entries < RTE_HASH_BUCKET_ENTRIES) ||
> -			(params->name == NULL) ||
> -			(params->key_len == 0)) {
> +			(params->entries < RTE_HASH_BUCKET_ENTRIES)) {
>   		rte_errno = EINVAL;
> -		HASH_LOG(ERR, "%s has invalid parameters", __func__);
> +		HASH_LOG(ERR, "%s has invalid parameters, entries must be "
> +		 "in the range %d to %d inclusive", __func__,
> +		  RTE_HASH_BUCKET_ENTRIES, RTE_HASH_ENTRIES_MAX);
> +		return NULL;
> +	}
> +
> +	if (params->key_len == 0) {
> +		rte_errno = EINVAL;
> +		HASH_LOG(ERR, "%s has invalid parameters, key_len must be "
> +		 "greater than 0", __func__);
>   		return NULL;
>   	}
>   
> @@ -204,6 +211,13 @@ rte_hash_create(const struct rte_hash_parameters *params)
>   		return NULL;
>   	}
>   
> +	if (params->name == NULL) {
> +		rte_errno = EINVAL;
> +		HASH_LOG(ERR, "%s has invalid parameters, name can't be NULL",
> +			__func__);
> +		return NULL;
> +	}
> +
>   	/* Validate correct usage of extra options */
>   	if ((params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY) &&
>   	    (params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)) {

-- 
Regards,
Vladimir


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

* Re: [PATCH] hash: separate param checks in hash create func
  2024-07-26 14:54 [PATCH] hash: separate param checks in hash create func Niall Meade
  2024-09-04 17:28 ` Medvedkin, Vladimir
@ 2024-10-07 21:08 ` Stephen Hemminger
  2024-10-10 16:46 ` [PATCH v2] " Niall Meade
  2024-10-17 15:10 ` [PATCH v4] hash: separate creation parameters checks Thomas Monjalon
  3 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2024-10-07 21:08 UTC (permalink / raw)
  To: Niall Meade
  Cc: Thomas Monjalon, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin, dev

On Fri, 26 Jul 2024 14:54:43 +0000
Niall Meade <niall.meade@intel.com> wrote:

> -		HASH_LOG(ERR, "%s has invalid parameters", __func__);
> +		HASH_LOG(ERR, "%s has invalid parameters, entries must be "
> +		 "in the range %d to %d inclusive", __func__,
> +		  RTE_HASH_BUCKET_ENTRIES, RTE_HASH_ENTRIES_MAX);

Suggest shorter wording and don't break messages across lines, it makes it
harder for the user to search for them. Suggest messages like:

		HASH_LOG(ERR, "%s() %u entries outside of range [%u..%u]",
			__func__, params->entries, 
			RTE_HASH_BUCKET_ENTRIES, RTE_HASH_ENTRIES_MAX);

Shorter is better.

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

* [PATCH v2] hash: separate param checks in hash create func
  2024-07-26 14:54 [PATCH] hash: separate param checks in hash create func Niall Meade
  2024-09-04 17:28 ` Medvedkin, Vladimir
  2024-10-07 21:08 ` Stephen Hemminger
@ 2024-10-10 16:46 ` Niall Meade
  2024-10-10 17:34   ` Stephen Hemminger
                     ` (2 more replies)
  2024-10-17 15:10 ` [PATCH v4] hash: separate creation parameters checks Thomas Monjalon
  3 siblings, 3 replies; 12+ messages in thread
From: Niall Meade @ 2024-10-10 16:46 UTC (permalink / raw)
  To: Thomas Monjalon, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin
  Cc: dev, Niall Meade

Separated name, entries and key_len parameter checks in
rte_hash_create().  Also made the error messages more
informative/verbose to help with debugging. Also added myself to the
mailing list.

Signed-off-by: Niall Meade <niall.meade@intel.com>

---
v2:
* change hash log messages to be one line

I had name set to NULL in the parameters I was passing to
rte_hash_create() and the error message I got didn't specify which
parameter was invalid.
---
 .mailmap                   |  1 +
 lib/hash/rte_cuckoo_hash.c | 21 +++++++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/.mailmap b/.mailmap
index a66da3c8cb..93df2effb2 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1055,6 +1055,7 @@ Nelson Escobar <neescoba@cisco.com>
 Nemanja Marjanovic <nemanja.marjanovic@intel.com>
 Netanel Belgazal <netanel@amazon.com>
 Netanel Gonen <netanelg@mellanox.com>
+Niall Meade <niall.meade@intel.com>
 Niall Power <niall.power@intel.com>
 Nicholas Pratte <npratte@iol.unh.edu>
 Nick Connolly <nick.connolly@arm.com> <nick.connolly@mayadata.io>
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 577b5839d3..2569f7d977 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -190,11 +190,17 @@ rte_hash_create(const struct rte_hash_parameters *params)
 
 	/* Check for valid parameters */
 	if ((params->entries > RTE_HASH_ENTRIES_MAX) ||
-			(params->entries < RTE_HASH_BUCKET_ENTRIES) ||
-			(params->name == NULL) ||
-			(params->key_len == 0)) {
+			(params->entries < RTE_HASH_BUCKET_ENTRIES)) {
 		rte_errno = EINVAL;
-		HASH_LOG(ERR, "%s has invalid parameters", __func__);
+		HASH_LOG(ERR, "%s() entries (%u) must be in range [%d, %d] inclusive",
+		__func__, params->entries, RTE_HASH_BUCKET_ENTRIES,
+		RTE_HASH_ENTRIES_MAX);
+		return NULL;
+	}
+
+	if (params->key_len == 0) {
+		rte_errno = EINVAL;
+		HASH_LOG(ERR, "%s() key_len must be greater than 0", __func__);
 		return NULL;
 	}
 
@@ -204,6 +210,13 @@ rte_hash_create(const struct rte_hash_parameters *params)
 		return NULL;
 	}
 
+	if (params->name == NULL) {
+		rte_errno = EINVAL;
+		HASH_LOG(ERR, "%s() has invalid parameters, name can't be NULL",
+			__func__);
+		return NULL;
+	}
+
 	/* Validate correct usage of extra options */
 	if ((params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY) &&
 	    (params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)) {
-- 
2.34.1

--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263


This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). Any review or distribution by others is
strictly prohibited. If you are not the intended recipient, please contact the
sender and delete all copies.


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

* Re: [PATCH v2] hash: separate param checks in hash create func
  2024-10-10 16:46 ` [PATCH v2] " Niall Meade
@ 2024-10-10 17:34   ` Stephen Hemminger
  2024-10-10 17:38   ` Stephen Hemminger
  2024-10-14 10:19   ` [PATCH v3] " Niall Meade
  2 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2024-10-10 17:34 UTC (permalink / raw)
  To: Niall Meade
  Cc: Thomas Monjalon, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin, dev

On Thu, 10 Oct 2024 16:46:02 +0000
Niall Meade <niall.meade@intel.com> wrote:

> --------------------------------------------------------------
> Intel Research and Development Ireland Limited
> Registered in Ireland
> Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
> Registered Number: 308263
> 
> 
> This e-mail and any attachments may contain confidential material for the sole
> use of the intended recipient(s). Any review or distribution by others is
> strictly prohibited. If you are not the intended recipient, please contact the
> sender and delete all copies.

Fix your lawyer footer. Technically any patches sent to public mailing lists
would have to be legally dropped.

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

* Re: [PATCH v2] hash: separate param checks in hash create func
  2024-10-10 16:46 ` [PATCH v2] " Niall Meade
  2024-10-10 17:34   ` Stephen Hemminger
@ 2024-10-10 17:38   ` Stephen Hemminger
  2024-10-14 10:19   ` [PATCH v3] " Niall Meade
  2 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2024-10-10 17:38 UTC (permalink / raw)
  To: Niall Meade
  Cc: Thomas Monjalon, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin, dev

On Thu, 10 Oct 2024 16:46:02 +0000
Niall Meade <niall.meade@intel.com> wrote:

> diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
> index 577b5839d3..2569f7d977 100644
> --- a/lib/hash/rte_cuckoo_hash.c
> +++ b/lib/hash/rte_cuckoo_hash.c
> @@ -190,11 +190,17 @@ rte_hash_create(const struct rte_hash_parameters *params)
>  
>  	/* Check for valid parameters */
>  	if ((params->entries > RTE_HASH_ENTRIES_MAX) ||
> -			(params->entries < RTE_HASH_BUCKET_ENTRIES) ||
> -			(params->name == NULL) ||
> -			(params->key_len == 0)) {
> +			(params->entries < RTE_HASH_BUCKET_ENTRIES)) {
>  		rte_errno = EINVAL;
> -		HASH_LOG(ERR, "%s has invalid parameters", __func__);
> +		HASH_LOG(ERR, "%s() entries (%u) must be in range [%d, %d] inclusive",
> +		__func__, params->entries, RTE_HASH_BUCKET_ENTRIES,
> +		RTE_HASH_ENTRIES_MAX);

Need to indent function args here.

> +		return NULL;
> +	}

Noticed this function is inconstitent about setting rte_errno.
Not sure if it matters.

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

* [PATCH v3] hash: separate param checks in hash create func
  2024-10-10 16:46 ` [PATCH v2] " Niall Meade
  2024-10-10 17:34   ` Stephen Hemminger
  2024-10-10 17:38   ` Stephen Hemminger
@ 2024-10-14 10:19   ` Niall Meade
  2024-10-14 15:28     ` Stephen Hemminger
  2024-10-17  7:44     ` Thomas Monjalon
  2 siblings, 2 replies; 12+ messages in thread
From: Niall Meade @ 2024-10-14 10:19 UTC (permalink / raw)
  To: Thomas Monjalon, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin
  Cc: dev, Niall Meade

Separated name, entries and key_len parameter checks in
rte_hash_create().  Also made the error messages more
informative/verbose to help with debugging. Also added myself to the
mailing list.

Signed-off-by: Niall Meade <niall.meade@intel.com>

---
v3:
* code indentation fix and rte_errno set correctly
v2:
* change hash log messages to be one line

I had name set to NULL in the parameters I was passing to
rte_hash_create() and the error message I got didn't specify which
parameter was invalid.
---
 .mailmap                   |  1 +
 lib/hash/rte_cuckoo_hash.c | 22 ++++++++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/.mailmap b/.mailmap
index a66da3c8cb..93df2effb2 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1055,6 +1055,7 @@ Nelson Escobar <neescoba@cisco.com>
 Nemanja Marjanovic <nemanja.marjanovic@intel.com>
 Netanel Belgazal <netanel@amazon.com>
 Netanel Gonen <netanelg@mellanox.com>
+Niall Meade <niall.meade@intel.com>
 Niall Power <niall.power@intel.com>
 Nicholas Pratte <npratte@iol.unh.edu>
 Nick Connolly <nick.connolly@arm.com> <nick.connolly@mayadata.io>
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 577b5839d3..9575e8aa0c 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -184,17 +184,24 @@ rte_hash_create(const struct rte_hash_parameters *params)
 	hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
 
 	if (params == NULL) {
+		rte_errno = EINVAL;
 		HASH_LOG(ERR, "%s has no parameters", __func__);
 		return NULL;
 	}
 
 	/* Check for valid parameters */
 	if ((params->entries > RTE_HASH_ENTRIES_MAX) ||
-			(params->entries < RTE_HASH_BUCKET_ENTRIES) ||
-			(params->name == NULL) ||
-			(params->key_len == 0)) {
+			(params->entries < RTE_HASH_BUCKET_ENTRIES)) {
+		rte_errno = EINVAL;
+		HASH_LOG(ERR, "%s() entries (%u) must be in range [%d, %d] inclusive",
+			__func__, params->entries, RTE_HASH_BUCKET_ENTRIES,
+			RTE_HASH_ENTRIES_MAX);
+		return NULL;
+	}
+
+	if (params->key_len == 0) {
 		rte_errno = EINVAL;
-		HASH_LOG(ERR, "%s has invalid parameters", __func__);
+		HASH_LOG(ERR, "%s() key_len must be greater than 0", __func__);
 		return NULL;
 	}
 
@@ -204,6 +211,13 @@ rte_hash_create(const struct rte_hash_parameters *params)
 		return NULL;
 	}
 
+	if (params->name == NULL) {
+		rte_errno = EINVAL;
+		HASH_LOG(ERR, "%s() has invalid parameters, name can't be NULL",
+			__func__);
+		return NULL;
+	}
+
 	/* Validate correct usage of extra options */
 	if ((params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY) &&
 	    (params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)) {
-- 
2.34.1


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

* Re: [PATCH v3] hash: separate param checks in hash create func
  2024-10-14 10:19   ` [PATCH v3] " Niall Meade
@ 2024-10-14 15:28     ` Stephen Hemminger
  2024-10-17  7:44     ` Thomas Monjalon
  1 sibling, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2024-10-14 15:28 UTC (permalink / raw)
  To: Niall Meade
  Cc: Thomas Monjalon, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
	Vladimir Medvedkin, dev

On Mon, 14 Oct 2024 10:19:16 +0000
Niall Meade <niall.meade@intel.com> wrote:

> Separated name, entries and key_len parameter checks in
> rte_hash_create().  Also made the error messages more
> informative/verbose to help with debugging. Also added myself to the
> mailing list.
> 
> Signed-off-by: Niall Meade <niall.meade@intel.com>


Acked-by: Stephen Hemminger <stephen@networkplumber.org>

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

* Re: [PATCH v3] hash: separate param checks in hash create func
  2024-10-14 10:19   ` [PATCH v3] " Niall Meade
  2024-10-14 15:28     ` Stephen Hemminger
@ 2024-10-17  7:44     ` Thomas Monjalon
  1 sibling, 0 replies; 12+ messages in thread
From: Thomas Monjalon @ 2024-10-17  7:44 UTC (permalink / raw)
  To: dev; +Cc: Niall Meade

Recheck-request: iol-unit-amd64-testing, iol-unit-arm64-testing



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

* [PATCH v4] hash: separate creation parameters checks
  2024-07-26 14:54 [PATCH] hash: separate param checks in hash create func Niall Meade
                   ` (2 preceding siblings ...)
  2024-10-10 16:46 ` [PATCH v2] " Niall Meade
@ 2024-10-17 15:10 ` Thomas Monjalon
  2024-10-18  8:37   ` Thomas Monjalon
  3 siblings, 1 reply; 12+ messages in thread
From: Thomas Monjalon @ 2024-10-17 15:10 UTC (permalink / raw)
  To: dev
  Cc: Niall Meade, Stephen Hemminger, Yipeng Wang, Sameh Gobriel,
	Bruce Richardson, Vladimir Medvedkin

From: Niall Meade <niall.meade@intel.com>

Separate name, entries and key_len parameter checks in rte_hash_create().
Also make the error messages more informative/verbose
to help with debugging.

Signed-off-by: Niall Meade <niall.meade@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
v4: formatting details
    sent for triggering a new CI run
---
 lib/hash/rte_cuckoo_hash.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 577b5839d3..9575e8aa0c 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -184,17 +184,24 @@ rte_hash_create(const struct rte_hash_parameters *params)
 	hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
 
 	if (params == NULL) {
+		rte_errno = EINVAL;
 		HASH_LOG(ERR, "%s has no parameters", __func__);
 		return NULL;
 	}
 
 	/* Check for valid parameters */
 	if ((params->entries > RTE_HASH_ENTRIES_MAX) ||
-			(params->entries < RTE_HASH_BUCKET_ENTRIES) ||
-			(params->name == NULL) ||
-			(params->key_len == 0)) {
+			(params->entries < RTE_HASH_BUCKET_ENTRIES)) {
 		rte_errno = EINVAL;
-		HASH_LOG(ERR, "%s has invalid parameters", __func__);
+		HASH_LOG(ERR, "%s() entries (%u) must be in range [%d, %d] inclusive",
+			__func__, params->entries, RTE_HASH_BUCKET_ENTRIES,
+			RTE_HASH_ENTRIES_MAX);
+		return NULL;
+	}
+
+	if (params->key_len == 0) {
+		rte_errno = EINVAL;
+		HASH_LOG(ERR, "%s() key_len must be greater than 0", __func__);
 		return NULL;
 	}
 
@@ -204,6 +211,13 @@ rte_hash_create(const struct rte_hash_parameters *params)
 		return NULL;
 	}
 
+	if (params->name == NULL) {
+		rte_errno = EINVAL;
+		HASH_LOG(ERR, "%s() has invalid parameters, name can't be NULL",
+			__func__);
+		return NULL;
+	}
+
 	/* Validate correct usage of extra options */
 	if ((params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY) &&
 	    (params->extra_flag & RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)) {
-- 
2.46.0


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

* Re: [PATCH v4] hash: separate creation parameters checks
  2024-10-17 15:10 ` [PATCH v4] hash: separate creation parameters checks Thomas Monjalon
@ 2024-10-18  8:37   ` Thomas Monjalon
  2024-10-18  9:26     ` Meade, Niall
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas Monjalon @ 2024-10-18  8:37 UTC (permalink / raw)
  To: Niall Meade
  Cc: dev, Stephen Hemminger, Yipeng Wang, Sameh Gobriel,
	Bruce Richardson, Vladimir Medvedkin

17/10/2024 17:10, Thomas Monjalon:
> From: Niall Meade <niall.meade@intel.com>
> 
> Separate name, entries and key_len parameter checks in rte_hash_create().
> Also make the error messages more informative/verbose
> to help with debugging.
> 
> Signed-off-by: Niall Meade <niall.meade@intel.com>
> Acked-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> v4: formatting details
>     sent for triggering a new CI run

The community CI lab is not in a good shape today
but I take the risk applying this patch.




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

* Re: [PATCH v4] hash: separate creation parameters checks
  2024-10-18  8:37   ` Thomas Monjalon
@ 2024-10-18  9:26     ` Meade, Niall
  0 siblings, 0 replies; 12+ messages in thread
From: Meade, Niall @ 2024-10-18  9:26 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev, Stephen Hemminger, Wang, Yipeng1, Gobriel, Sameh,
	Richardson, Bruce, Medvedkin, Vladimir

[-- Attachment #1: Type: text/plain, Size: 566 bytes --]

>17/10/2024 17:10, Thomas Monjalon:
>> From: Niall Meade <niall.meade@intel.com>
>>
>> Separate name, entries and key_len parameter checks in rte_hash_create().
>> Also make the error messages more informative/verbose
>> to help with debugging.
>>
>> Signed-off-by: Niall Meade <niall.meade@intel.com>
>> Acked-by: Stephen Hemminger <stephen@networkplumber.org>
>> ---
>> v4: formatting details
>>     sent for triggering a new CI run
>
>The community CI lab is not in a good shape today
>but I take the risk applying this patch.
Thanks Thomas




[-- Attachment #2: Type: text/html, Size: 3416 bytes --]

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

end of thread, other threads:[~2024-10-18  9:26 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-26 14:54 [PATCH] hash: separate param checks in hash create func Niall Meade
2024-09-04 17:28 ` Medvedkin, Vladimir
2024-10-07 21:08 ` Stephen Hemminger
2024-10-10 16:46 ` [PATCH v2] " Niall Meade
2024-10-10 17:34   ` Stephen Hemminger
2024-10-10 17:38   ` Stephen Hemminger
2024-10-14 10:19   ` [PATCH v3] " Niall Meade
2024-10-14 15:28     ` Stephen Hemminger
2024-10-17  7:44     ` Thomas Monjalon
2024-10-17 15:10 ` [PATCH v4] hash: separate creation parameters checks Thomas Monjalon
2024-10-18  8:37   ` Thomas Monjalon
2024-10-18  9:26     ` Meade, Niall

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