From patchwork Fri Apr 24 17:15:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69276 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 3F985A00C2; Fri, 24 Apr 2020 19:15:55 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 794881D444; Fri, 24 Apr 2020 19:15:49 +0200 (CEST) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by dpdk.org (Postfix) with ESMTP id DB4741D41D for ; Fri, 24 Apr 2020 19:15:46 +0200 (CEST) Received: by mail-pl1-f193.google.com with SMTP id v2so3956676plp.9 for ; Fri, 24 Apr 2020 10:15:46 -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=6GCgXGcSOZ4EiPAzi7gMeWDfnR8ZqHg4Q4RpHT3BA4I=; b=Wm3iMuD2tKZgMHpIgpc4WshMNEp91uqmixeoioz6GzWNTBdbjSJjKOmBeRaANjBikm Sc2DNe7L43DC5jj/QxzICib3rmmUCV2Df9EJEC+NJQ7f8QSdmIIy/XolQQBzu2XtT9xD 1GhDZnLkwlTRh1K53+Wegy6WlUTeXUpMwfGJTjcddlcQ41quG6ZsNG+wwaD+Dzw94qCx ldWPlKTR8wFwUwGhQzvocpMF9ciaXL14r0F2vQ2nQkK9BJ0Bl4JHUcjLf1AgQFs4+r7a IhvN+kzrelNjSwRFU0rllGBhLn6VD5Y4n1nWGtC1ltxF3mO1XG4lacYSN7b35Di7ZQTD rI0Q== 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=6GCgXGcSOZ4EiPAzi7gMeWDfnR8ZqHg4Q4RpHT3BA4I=; b=eoFfEoDxMvC1i3KukqUVDlXapnv2k2eJBzc9QQ2F/yODPiXdfd5KBjL6Cv2KYyQNMn mlYLpRFx+jaCWGLKNASujLxqs1JOll/nwzuM3TRYRhY2XkE+xWERL5SlWHhfM6m80PRr Ohy7bwPBwcYE88ow7I35IXTZeh4ydsmaR6fbqe9qu2rlm75SU6/LNmCXn3AgMEcEIQ4C NkaZl0zxhUjIkShnCK3D5W2ChmHVKaIXunnL0BxW8MX8PhCchtjp6HWOMR+IvMShrImp e81ZNfTDlsoLwofDVy/r4PjicA7+FDrgfVDBgmX9rfhP3EbNlzcXya+gQDAd8FRea11I LX8w== X-Gm-Message-State: AGi0Pubsq5LhUl2IgnvP2Qu9N24ldyaM95vS0Om9Aepv7LDlz6WMwdhI PAh9Vkq2ls5g9qEv8dDoFD1lxzYdj54= X-Google-Smtp-Source: APiQypJ/I7DfbBOEKRlxpM8fh0HoYCDbjYN18xWR58HX+SvnTq2btz5ow4TE5tq37kQauvMNhH+ABg== X-Received: by 2002:a17:90b:128d:: with SMTP id fw13mr7659083pjb.23.1587748545560; Fri, 24 Apr 2020 10:15:45 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 10:15:44 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Fri, 24 Apr 2020 10:15:33 -0700 Message-Id: <20200424171536.11535-2-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 Subject: [dpdk-dev] [PATCH v2 1/4] ring: future proof flag settings 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. These checks ensure that the extra bits can safely be used without risk of ABI breakage. Signed-off-by: Stephen Hemminger --- lib/librte_ring/rte_ring.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c index ebe5ccf0de68..70685121581f 100644 --- a/lib/librte_ring/rte_ring.c +++ b/lib/librte_ring/rte_ring.c @@ -42,6 +42,9 @@ static struct rte_tailq_elem rte_ring_tailq = { }; EAL_REGISTER_TAILQ(rte_ring_tailq) +/* mask of all valid flag values to ring_create() */ +#define RING_F_MASK 0x007F + /* true if x is a power of 2 */ #define POWEROF2(x) ((((x)-1) & (x)) == 0) @@ -197,6 +200,13 @@ rte_ring_init(struct rte_ring *r, const char *name, unsigned count, RTE_BUILD_BUG_ON(offsetof(struct rte_ring_headtail, tail) != offsetof(struct rte_ring_rts_headtail, tail.val.pos)); + /* future proof flags, only allow supported values */ + if (flags & ~RING_F_MASK) { + RTE_LOG(ERR, RING, + "Unsupported flags requested %#x\n", flags); + return -EINVAL; + } + /* init the ring structure */ memset(r, 0, sizeof(*r)); ret = strlcpy(r->name, name, sizeof(r->name)); From patchwork Fri Apr 24 17:15:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69277 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 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 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)) { From patchwork Fri Apr 24 17:15:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69278 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 9B0FDA00C2; Fri, 24 Apr 2020 19:16:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DDC601D440; Fri, 24 Apr 2020 19:15:54 +0200 (CEST) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id 850E41D447 for ; Fri, 24 Apr 2020 19:15:49 +0200 (CEST) Received: by mail-pl1-f196.google.com with SMTP id k18so3963497pll.6 for ; Fri, 24 Apr 2020 10:15:49 -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=5zDoPIQZJD4BR+6Ns9o1Oli/kD0TyZk6fTRGDLaM0dc=; b=QJjUu9lU9z257+aNM+N0wkTgROAoOGyqjwBD7dhmRj/CFttSV/pxIviE8fmC4hlaxi TBohZh4yHT3DbTVKCJKdPoKAE+wepTdl+WSYkKYuVoFrp9MxvVxPt6ndUmHIPnNQNrxD 01NT01ISVHheUm8tkBN9qhlPZ7PdJsAxO0c35j7U1WVf9ICgV/CIcsc2WNWUaAUv4qa7 O+Dgid/4azrIA3wsqxDQli8ev9HmEzfiJh7QyXyO37SoCO/wrF6tGgpoY55sCPi4SaW6 rsLP0USb+844Ho3kbgBjFSyQb4t04EIml7XOrK6tYHZimIpulKmepMkIA5FodILLM2jP f0dQ== 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=5zDoPIQZJD4BR+6Ns9o1Oli/kD0TyZk6fTRGDLaM0dc=; b=kfO/zJA/hDWZD9K8Jj2yFkY9T204dLUr2kIaZ8eZl6XUNmiGL3BTULEw7w+ms9QNWA /Ou48egTiOjAdVu2+uEl7XgCapc8yqgAu2smwi6l+QRRpBaFRXVY53J13hggoXTbTcfh 9gSmu67cCfxf3mrGMq24hKS0GiUhRZZGwwarN7ALuTIZ3rWxRTuaQABQJDiHDaCI/y5x jcm0+VAUtLkOwGkSo8FTgOWuGZuTPyvpAsQfA+hCtl3FfVMRa0L+guFPCfdtGpsRLy2m wCaB5Df58O8XERfPit/nlbbYhdhj6JIJhah3wNVzXBSxvcDhAy4iCt1yKYpCksUJ5i6z /0Ng== X-Gm-Message-State: AGi0PuZgTqq3GgFkcoBHh40fkcGAyW1LAf9Fv5u0mFw1oJfmFpDxpHQC qFXyt5KzsUU6oZhULmJEPk+zdoIo5vo= X-Google-Smtp-Source: APiQypKLeZQ3cwYDLHE6JT5lC41AywPX6gtPPIQcVspJ0v+QrBUfx9qFHi1d/xNRu8QW7VPMRvKWmA== X-Received: by 2002:a17:902:8e84:: with SMTP id bg4mr9673241plb.50.1587748548292; Fri, 24 Apr 2020 10:15:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 10:15:47 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Fri, 24 Apr 2020 10:15:35 -0700 Message-Id: <20200424171536.11535-4-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 Subject: [dpdk-dev] [PATCH v2 3/4] stack: 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_stack/rte_stack.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/librte_stack/rte_stack.c b/lib/librte_stack/rte_stack.c index d19824f00439..e58fa545fca4 100644 --- a/lib/librte_stack/rte_stack.c +++ b/lib/librte_stack/rte_stack.c @@ -59,6 +59,11 @@ rte_stack_create(const char *name, unsigned int count, int socket_id, unsigned int sz; int ret; + if (flags & ~(RTE_STACK_F_LF)) { + STACK_LOG_ERR("Unsupported stack flags %#x\n", flags); + return NULL; + } + #ifdef RTE_ARCH_64 RTE_BUILD_BUG_ON(sizeof(struct rte_stack_lf_head) != 16); #else From patchwork Fri Apr 24 17:15:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 69279 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 7ACB2A00C2; Fri, 24 Apr 2020 19:16:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3BA971D529; Fri, 24 Apr 2020 19:15:56 +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 DF5711D455 for ; Fri, 24 Apr 2020 19:15:50 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id v2so3956742plp.9 for ; Fri, 24 Apr 2020 10:15:50 -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=5g1dTUi5guNJR46ba7VAynNH00ugrf1kkX2Uc4mf1aA=; b=RjAu4ss9G5+1FLa4JlidW3QPZ1KLdayPW+q97H6dEoDWwbeR4ylO5MxGj+YsxRNcYp +OMufjzw4Qbml/LnbEm4pVh0Gvm7prubV+HzS5lMve42skU7rvpCSgnL/PMgrwBR8hKq 1hJf9KfJivncsFkg4DpCY5/VOVJvJEzm8ncZlwnYUiVis5F3oHAm39uoSPoRKsqu9an4 S+nG2gTRhG6HdauoAytogZDigVCG6TiQabrDPU+6JjAMghguMTUJFKvxJ0ZEB4Q92DQe fpSblcQd1E0L2ulS+Ikm96vQdhHhythyBjcKu3GBPRXQv/TQwhhAFGEyjKq0iRdlfg8B o3Kg== 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=5g1dTUi5guNJR46ba7VAynNH00ugrf1kkX2Uc4mf1aA=; b=WJsuMgo2Nwkvmk6rkn+Ck73SWyDt386qo+iPhRNZUhHozPJlBYWMtiHnTpNNt9D/kJ TrHQmpVcvlw8fyNgjFims8Guh66efGIYsvrl48OBCP6kyXs/NFIztrEg6SiwIizRUp/B 08pew3udSn0Zba2Fu/XTz1GqgCMsLxK3uIGyucMz2MVKNINKv/oAVI3CSZ/lYy8XvD3b U+AtVVw0DF4lfHfO4EaqDMbkJp2b/5Jz/I0FBGEf2n/Ig1rS5VRtjT0kPGS2ryNBHQIr xKuC5RBhX8SUn18agbJwbU4QiEsYmqLAoQAqUQKO5ye/NKPbHzWSa0smjn8T508H92pm Gf7w== X-Gm-Message-State: AGi0Pub4W52pBwGZdphYHLuq6zXhYX9duEELq4v8y8GbNG5fFGevs+oL RmuaIjx7fw4T6Bt1ZNggOjUu4Uc1s3w= X-Google-Smtp-Source: APiQypJh2ovN33jEO32P0zA/nGeSCeaPnqKNkfSY3VuhNK1rXBDdTXl188bp6ephmEWq5bAXkW2I+Q== X-Received: by 2002:a17:902:b111:: with SMTP id q17mr9983987plr.160.1587748549737; Fri, 24 Apr 2020 10:15:49 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 10:15:48 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Fri, 24 Apr 2020 10:15:36 -0700 Message-Id: <20200424171536.11535-5-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 Subject: [dpdk-dev] [PATCH v2 4/4] cfgfile: check flags value 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_cfgfile/rte_cfgfile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c index 9049fd9c2319..714717dd9007 100644 --- a/lib/librte_cfgfile/rte_cfgfile.c +++ b/lib/librte_cfgfile/rte_cfgfile.c @@ -272,6 +272,10 @@ rte_cfgfile_create(int flags) int i; struct rte_cfgfile *cfg; + /* future proof flags usage */ + if (flags & ~(CFG_FLAG_GLOBAL_SECTION | CFG_FLAG_EMPTY_VALUES)) + return NULL; + cfg = malloc(sizeof(*cfg)); if (cfg == NULL)