From patchwork Wed Feb 12 23:08:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 65776 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 52874A0542; Thu, 13 Feb 2020 00:08:41 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BF0311BF8E; Thu, 13 Feb 2020 00:08:27 +0100 (CET) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by dpdk.org (Postfix) with ESMTP id F1E201BE94 for ; Thu, 13 Feb 2020 00:08:23 +0100 (CET) Received: by mail-pg1-f177.google.com with SMTP id b35so1852577pgm.13 for ; Wed, 12 Feb 2020 15:08:23 -0800 (PST) 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=PJQB60zD512/Vw0ZwGfoCiedGxgfUVAlGAbDGQb2P2lLhURCykhAeRdQqrtuEp09uA qJHmsUeQAKxDNgeOlLhwnkSUSInqi9CJncHCbefg1bXafex5czQ/cZOHgZ+Jnh/nBw+s 7EDKbB1OBqa7JgVDqGHY6qKETgkgK4cc0vCsRYZC4hiE9pip35yccyb1rJH5P78sia5G EFC/Dw9/tDvk73HdTJysMoqiABK8NQRoQKcSUQh+kjJWb5xrnc2j2lT8yxIZVc+BEild Kgq5xq5bqwy6J3LstBlpPsxBdA9Nm61a/xPn7tsnisnGIEJYyXHVH8K/lBZi873zko2J Ctqg== 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=Qx4e0B20PyiUrYPajYzimm5TzwxKaxTpeW2s93VMUFYX1JXHT5fzzecAKHAjYyV7da p3dZqw2i6wKYFdkfLsWLB/xsyZaP5F1Swi241ZeJIqX0xX9I2X0P8Y0XVgUAq1BmHQ+F OZapaMlIomnsEUQAIHTqyjj2lVcd/OrN2Cm9PW3aVm9OrSJqC6Wx+Ut7hq4zA5WtlljA 8H26R11y0LK6zgmI6HpCZNy90ii8+45ZetL4E7+mgKqMXl1a+BzyeUWG5gK6+1EvO5p0 e+D4Wdr8veuRsI88lfRgOgJOEniBh8X88K3vnbb6+gEDI/W9/taLGKNMFGyW/roZfBRa 8LXw== X-Gm-Message-State: APjAAAUj5clI53D7ccTf7BNXoEhbbGw9eQLOm6i3Ck7tZE2l3jSFHH5S PRwiIttDlxShqCozIHgpJzOwCqa20cc= X-Google-Smtp-Source: APXvYqyo6voklbtVAh84VTFCh/Kx1Wy7eyuyWaBu5OvhhmllcUX+1iIrdwLMhvAjf0SlCBEPkyNTwQ== X-Received: by 2002:a62:15d8:: with SMTP id 207mr3481415pfv.40.1581548902554; Wed, 12 Feb 2020 15:08:22 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id f18sm198301pgn.2.2020.02.12.15.08.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Feb 2020 15:08:21 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Wed, 12 Feb 2020 15:08:08 -0800 Message-Id: <20200212230810.2837-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200212230810.2837-1-stephen@networkplumber.org> References: <20200212230810.2837-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC 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)) {