DPDK patches and discussions
 help / color / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>,
	Konstantin Ananyev <konstantin.ananyev@intel.com>
Subject: [dpdk-dev] [PATCH v3 1/4] ring: future proof flag settings
Date: Mon, 27 Apr 2020 16:16:22 -0700
Message-ID: <20200427231625.10135-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20200427231625.10135-1-stephen@networkplumber.org>

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 <stephen@networkplumber.org>
---
 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


  reply index

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-12 23:08 [dpdk-dev] [RFC 0/4] Enforce flag checking in API's Stephen Hemminger
2020-02-12 23:08 ` [dpdk-dev] [RFC 1/4] ring: future proof flag settings Stephen Hemminger
2020-02-13 11:12   ` Ananyev, Konstantin
2020-02-12 23:08 ` [dpdk-dev] [RFC 2/4] hash: check flags on creation Stephen Hemminger
2020-02-12 23:08 ` [dpdk-dev] [RFC 3/4] stack: " Stephen Hemminger
2020-02-12 23:08 ` [dpdk-dev] [RFC 4/4] cfgfile: check flags value Stephen Hemminger
2020-04-24 17:15 ` [dpdk-dev] [PATCH v2 0/4] enforce checking on flag values in API's Stephen Hemminger
2020-04-24 17:15   ` [dpdk-dev] [PATCH v2 1/4] ring: future proof flag settings Stephen Hemminger
2020-04-24 18:07     ` Honnappa Nagarahalli
2020-04-24 19:02       ` Stephen Hemminger
2020-04-25  9:20         ` Ananyev, Konstantin
2020-04-24 17:15   ` [dpdk-dev] [PATCH v2 2/4] hash: check flags on creation Stephen Hemminger
2020-04-24 17:15   ` [dpdk-dev] [PATCH v2 3/4] stack: " Stephen Hemminger
2020-04-24 17:15   ` [dpdk-dev] [PATCH v2 4/4] cfgfile: check flags value Stephen Hemminger
2020-04-27 23:16 ` [dpdk-dev] [PATCH v3 0/4] Enforce checking on flag values in API's Stephen Hemminger
2020-04-27 23:16   ` Stephen Hemminger [this message]
2020-04-28  4:12     ` [dpdk-dev] [PATCH v3 1/4] ring: future proof flag settings Honnappa Nagarahalli
2020-04-27 23:16   ` [dpdk-dev] [PATCH v3 2/4] hash: check flags on creation Stephen Hemminger
2020-04-29  1:08     ` Wang, Yipeng1
2020-04-27 23:16   ` [dpdk-dev] [PATCH v3 3/4] stack: " Stephen Hemminger
2020-05-02  2:36     ` Eads, Gage
2020-04-27 23:16   ` [dpdk-dev] [PATCH v3 4/4] cfgfile: check flags value Stephen Hemminger
2020-04-28 10:24     ` Bruce Richardson
2020-04-28 10:28   ` [dpdk-dev] [PATCH v3 0/4] Enforce checking on flag values in API's Bruce Richardson
2020-06-16 15:47     ` Thomas Monjalon
2020-04-28 11:04   ` Ananyev, Konstantin

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200427231625.10135-2-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=honnappa.nagarahalli@arm.com \
    --cc=konstantin.ananyev@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox