From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AE302A00C2; Fri, 24 Apr 2020 19:16:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 22E9C1D506; Fri, 24 Apr 2020 19:15:51 +0200 (CEST) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id 40ECC1D440 for ; Fri, 24 Apr 2020 19:15:48 +0200 (CEST) Received: by mail-pf1-f194.google.com with SMTP id d184so5095522pfd.4 for ; Fri, 24 Apr 2020 10:15:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jwFO6sSmu+SCeWP4DmHibzOitYajREV6wKXeSiQbxpQ=; b=xR2R7spKJM/UDjl2m1jFTuKdE+6H1tcDn6ptzvEtR0InbLBc4DFp2K9lY8rc4wgSYe 8naX1cm2VBzeMnSZISV+G/Ih57QFNW4HPTeB4Ps5/YRJIJqGZtGQV8A8vAXPi9oXNgrh 93qZElVCPV+si0yh/FWv4A4q+eMbxMdItxb59B6le5mgV+MIHye3DmtCYPdf4VdtEjGy 9Is0sAQo+GkNvXw7NqeZIa6IMwXz6LrrSYPTunMQyNJaXhKBGNxM5D7iKi0LCjdc9KAZ CwZ2nfNO2p3OoPPz92LSCuvRo4FyxSytuvMZMz5sjbYgeRJ93tlJML/TGUOUz9RvmJB8 dmYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jwFO6sSmu+SCeWP4DmHibzOitYajREV6wKXeSiQbxpQ=; b=oituFX+V9h50Cn2ECTIJ3A6uDcteKyFJO6ld8NGR1JoMpPC4U12r0a5NW8xMdilEm6 /z+0ozX8/nUUU2RE5gxk/rL0AC7reJKPMeVcmXXkRo+K7cumD0qUQi+XzuHhqPk4Lj0W jVimXHrNZZRVJhqW9ZkroRxsJWznOJxq/CFHUSU2OSdiGLX8HMLzMX+3LEVGCdDM6Idq 0nvMBWkyv7EE05CqTpSCZ7zTJnuZZ65W1mjsvRG4TJyfYgenAaqRAJuvccC4n4pWNnch EY046pWYjR4jSRsOb7Rezmbf1cpBkQ5HHAdsghnAoAnF+90Pqz8eezQ1+R3gBS4olU/+ Nw0w== X-Gm-Message-State: AGi0PuasZqge6KFejDOE6x3zSxpGq2jTW1tCU7GDH2gO9svj6P4GwkT0 SDmlaFTXBYb49oroG5JoGfyegiJV7/Y= X-Google-Smtp-Source: APiQypJs0NuR42aKxUGhTOH867z9dl2GKEPUrLRbsBPtWRMFcGG0VXZp3wKrzBIQZbhjk8TfKucv3Q== X-Received: by 2002:a62:be0c:: with SMTP id l12mr8843627pff.95.1587748546923; Fri, 24 Apr 2020 10:15:46 -0700 (PDT) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id w3sm6153245pfn.115.2020.04.24.10.15.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 10:15:45 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Fri, 24 Apr 2020 10:15:34 -0700 Message-Id: <20200424171536.11535-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200424171536.11535-1-stephen@networkplumber.org> References: <20200212230810.2837-1-stephen@networkplumber.org> <20200424171536.11535-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 2/4] hash: check flags on creation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" All API's should check that they support the flag values passed. If an application passes an invalid flag it could cause problems in later ABI. Signed-off-by: Stephen Hemminger --- lib/librte_hash/rte_cuckoo_hash.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c index 6af8ca42e94f..ab9cd91b4955 100644 --- a/lib/librte_hash/rte_cuckoo_hash.c +++ b/lib/librte_hash/rte_cuckoo_hash.c @@ -32,6 +32,9 @@ #include "rte_hash.h" #include "rte_cuckoo_hash.h" +/* Mask of all flags supported by this version */ +#define RTE_HASH_EXTRA_FLAGS_MASK 0x2f + #define FOR_EACH_BUCKET(CURRENT_BKT, START_BUCKET) \ for (CURRENT_BKT = START_BUCKET; \ CURRENT_BKT != NULL; \ @@ -164,6 +167,12 @@ rte_hash_create(const struct rte_hash_parameters *params) return NULL; } + if (params->extra_flag & ~RTE_HASH_EXTRA_FLAGS_MASK) { + rte_errno = EINVAL; + RTE_LOG(ERR, HASH, "rte_hash_create: unsupported extra flags\n"); + 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.20.1