From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D621745B08; Thu, 10 Oct 2024 18:46:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AB38B402A3; Thu, 10 Oct 2024 18:46:27 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by mails.dpdk.org (Postfix) with ESMTP id 6BD0C40144 for ; Thu, 10 Oct 2024 18:46:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728578787; x=1760114787; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=i9kKOGZFXhIfCFXiQ4GL4rauqNyKEdyBOMfSE0hzc6c=; b=lc40AzmDsw8/cynOjGXd5YRO6RLyO3UPq0uaPgGaDfeKgEYDJXDniZzL gBwHAxQrKHMDWlU+cfooa4QuHUuAVu0mbZ74ogEXACNFxMaXrNrfXPC3C Y8NsGdJ2y8EFni9R9+dsjRfLfvUlJrQzetPwSqt/VRXwxS38H1LHwRRgV k6MZKIGRORQFEOeKwVsij8eq8BB5yNzsGyOVaotg3RAWdkPtOXU2gYuuA TO2HvOMpXGmlEJ6h7cgIu4pRPEpQedl6//t7T6tqfTCkjmOuRTKinL6Rt UodiOcAGmquSpVhOf9ojOaE2kKsTvQg7AtFBuQROuWCH1QvDR179gPGqW w==; X-CSE-ConnectionGUID: FATXxTZrTEqcdXRa38WdKg== X-CSE-MsgGUID: BIeHby//Q8SV3Ua3VTESOg== X-IronPort-AV: E=McAfee;i="6700,10204,11220"; a="28108638" X-IronPort-AV: E=Sophos;i="6.11,193,1725346800"; d="scan'208";a="28108638" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2024 09:46:25 -0700 X-CSE-ConnectionGUID: UftBUNv+Q3mX8YqVQRSmpQ== X-CSE-MsgGUID: 6NJEJP0wSjmpI69EWA9giA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,193,1725346800"; d="scan'208";a="76264828" Received: from unknown (HELO silpixa00401183.ir.intel.com) ([10.55.128.177]) by fmviesa006.fm.intel.com with ESMTP; 10 Oct 2024 09:46:24 -0700 From: Niall Meade To: Thomas Monjalon , Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin Cc: dev@dpdk.org, Niall Meade Subject: [PATCH v2] hash: separate param checks in hash create func Date: Thu, 10 Oct 2024 16:46:02 +0000 Message-Id: <20241010164602.1794534-1-niall.meade@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240726145443.1058676-1-niall.meade@intel.com> References: <20240726145443.1058676-1-niall.meade@intel.com> MIME-Version: 1.0 Organization: Intel Research and Development Ireland Ltd - Co. Reg. #308263 - Collinstown Industrial Park, Leixlip, County Kildare, Ireland Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- 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 Nemanja Marjanovic Netanel Belgazal Netanel Gonen +Niall Meade Niall Power Nicholas Pratte Nick Connolly 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.