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 01112A00BE; Tue, 28 Apr 2020 01:16:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 654391D527; Tue, 28 Apr 2020 01:16:39 +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 2FC281D51A for ; Tue, 28 Apr 2020 01:16:36 +0200 (CEST) Received: by mail-pl1-f196.google.com with SMTP id g2so7585700plo.3 for ; Mon, 27 Apr 2020 16:16:36 -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=aRKIl+ro7nwT7kyHYfHg+NdaLflA7tj3bCqL8gSTEls=; b=LzpS9MRfSIuRmDjCUWZCC5rNQos3WpgmSTNkGKiDMwmZVcMXYFZm24jTTH91IYETWG AhYFXD32e2TYezDCUqHCxF9Q8/y3tWns0/AVb5Epl/Z4eFJv9C92oYIK3YEm/Xu1gEMd 382u7FeqA2y23Glid2fPE7EXZkIHLLIG9SwMoWLX5cmaibJK/R8y3K68iLjSYQSbK6B2 Eiq2peMzIu1vqJy+V09pPOL27JyP5OqaGVSgWaiFBb5u1DoEnn1dzwljCzlTZoNoW2pq RmQNPvONQGlFxJRPfeh6EQ4QBbPmCO8oEqdnju9GFOgg27Ry3migmE4/kWUfuAIyRKcw EBAQ== 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=aRKIl+ro7nwT7kyHYfHg+NdaLflA7tj3bCqL8gSTEls=; b=hyWHGbdO34Ed+EINK4jVLo9vR+mL+VDAH/dt4ho40h993ICwPSmWuwNGbgYe37xG54 odwmjCGaoObpEjGHW5qcA08t3Z8oOP7T89XrqUVvcjAjRS4/zdo0MK9n4hHYEtPcP2l1 ALALZ0trBHpyASEYBAsiDz8FaTctrL3s1UE34VMU2n253f9yfcRioOfz7OPap8pP+S8T a1r7IzxyzhNaOa5AVtrbg8mR+kwNYGHpPOdItf7dflHPmN03wQeo+x+yuKLPS9o2DcNN RvsCYRH8NbodSV50axX8Xzn7wKQwHxrhvcqi8SGJ/CG+/e2w5Uj/mGOGFlnpZCbyhFHU 72FA== X-Gm-Message-State: AGi0PuYRQYOy/paO5Vhm2ipy0lx3XGqzPZMbKf7UvJCOwsM3Acnug9+o ntKWhIV1071rqH7ZVRy/F0mH5HnmiRg= X-Google-Smtp-Source: APiQypLA2IiV2KeVq6sK30zRNUeR1BX7Lt1F1vB5QAjQxGvrVwnt7/ddQZj8MOMjDsc9TrdHIXFmFw== X-Received: by 2002:a17:90a:2ac7:: with SMTP id i7mr1334928pjg.130.1588029394764; Mon, 27 Apr 2020 16:16:34 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2020 16:16:33 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Honnappa Nagarahalli , Konstantin Ananyev Date: Mon, 27 Apr 2020 16:16:22 -0700 Message-Id: <20200427231625.10135-2-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 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 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c index ebe5ccf0de68..e16dd45a82de 100644 --- a/lib/librte_ring/rte_ring.c +++ b/lib/librte_ring/rte_ring.c @@ -42,6 +42,11 @@ 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 (RING_F_SP_ENQ | RING_F_SC_DEQ | RING_F_EXACT_SZ | \ + RING_F_MP_RTS_ENQ | RING_F_MC_RTS_DEQ | \ + RING_F_MP_HTS_ENQ | RING_F_MC_HTS_DEQ ) + /* true if x is a power of 2 */ #define POWEROF2(x) ((((x)-1) & (x)) == 0) @@ -197,6 +202,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)); -- 2.20.1