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 46F25A00BE; Tue, 28 Apr 2020 01:16:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F21461D536; Tue, 28 Apr 2020 01:16:40 +0200 (CEST) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id C89BC1D525 for ; Tue, 28 Apr 2020 01:16:37 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id f8so7587352plt.2 for ; Mon, 27 Apr 2020 16:16:37 -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=6oDEUl/PDWsgmpzz1xVVLsltS+mvEAJqg27so1VHvD8=; b=SnhxiBJCMhpTUudtjH+DYuWGhK8eHRbqwzbLD5O5vay4Ve8dpH//jxFAc7gRNI+EGt 0PGG3NJOqM/yhSlrj+yISRKARNg91ExSiRhKd2MNG/EmfYCucjiNova013l2AHouXfhA gOr+55uZxVJ8N4Tlt/1DyEDBEprRXXITMrzlMGhyPzfF91qQy7D6FI+BZqIbSzEs9w/O OKUSz9tBTrN8gOdbUPIBBaegThktrsx0bxTbB1V02Hu4FQ4tdKehjuvlwYKVvc0Tyx2+ lliaa3fJAwDXhE7bkFZLRuhkh+O/393b+qMj6k08GVL6jTpE4qLYQDaMDbCGbuVwk4jh yq/Q== 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=6oDEUl/PDWsgmpzz1xVVLsltS+mvEAJqg27so1VHvD8=; b=ZJBhInCPuDsAsS3/HFpOwtDYWnrEeiLvKpK8RJV2o1ejdelbrP5BqjDjphhU2MLGgo ApTlvatSqsRkVgTdY6nznGzCgzg79iEnIc5ikxKMm/QZqQN2ZNXDj1t4wSNvwV/dWF/h 8Vb6M/g7D/rHD8IkdeJxgX7IG2kKeVArJRU3IVgb6CrxqZPsN8rqdk68NrqjGWP6FFyE /DJhjy1tO1rn3m9k9pxG/OfOwp3+N6cFcBSH7z+T/6mtsU1G1K03LrFKzF5tmvjH4zl6 EdfM3ByzG6+0bFEHpBrLrlawYhbdOaYk8M78YEVwjHHjThVtxCq3kobMkmB0o6s1vRWE AppA== X-Gm-Message-State: AGi0PuZBgRy75ClC3uOBBxUi7C07UJ0LFH0xiY/Z/47Lw/x60H9zD45f xyemOBb/fYW5tQGA2ev1RZhAvWyHVlA= X-Google-Smtp-Source: APiQypL2AecSyWquY5YNh7az/rQn0pMZUwCseoJlpQyNnR15DX52m5IQlQlVrZ6nafWwXEMSUkHqHQ== X-Received: by 2002:a17:90a:e2c1:: with SMTP id fr1mr1340295pjb.124.1588029396565; Mon, 27 Apr 2020 16:16:36 -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 kb10sm353104pjb.6.2020.04.27.16.16.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2020 16:16:35 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Yipeng Wang , Sameh Gobriel , Bruce Richardson Date: Mon, 27 Apr 2020 16:16:23 -0700 Message-Id: <20200427231625.10135-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200427231625.10135-1-stephen@networkplumber.org> References: <20200212230810.2837-1-stephen@networkplumber.org> <20200427231625.10135-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c index 38767a8a164f..d54bbb47edcb 100644 --- a/lib/librte_hash/rte_cuckoo_hash.c +++ b/lib/librte_hash/rte_cuckoo_hash.c @@ -32,6 +32,14 @@ #include "rte_hash.h" #include "rte_cuckoo_hash.h" +/* Mask of all flags supported by this version */ +#define RTE_HASH_EXTRA_FLAGS_MASK (RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT | \ + RTE_HASH_EXTRA_FLAGS_MULTI_WRITER_ADD | \ + RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY | \ + RTE_HASH_EXTRA_FLAGS_EXT_TABLE | \ + RTE_HASH_EXTRA_FLAGS_NO_FREE_ON_DEL | \ + RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF) + #define FOR_EACH_BUCKET(CURRENT_BKT, START_BUCKET) \ for (CURRENT_BKT = START_BUCKET; \ CURRENT_BKT != NULL; \ @@ -164,6 +172,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