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 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 Content-Transfer-Encoding: 8bit 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)); -- 2.20.1