DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>, <byron.marohn@intel.com>,
	<yipeng1.wang@intel.com>, <ndabilpuram@marvell.com>,
	<pbhagavatula@marvell.com>
Subject: [dpdk-dev] [PATCH] lib: fix socket id type
Date: Tue, 27 Apr 2021 17:36:32 +0800	[thread overview]
Message-ID: <1619516192-40499-1-git-send-email-humin29@huawei.com> (raw)

From: Chengchang Tang <tangchengchang@huawei.com>

The variable type of the current socket ID is uint8_t. When traversing all
nodes, the socket ID is compared with RTE_MAX_NUMA_NODES. Since
RTE_MAX_NUMA_NODES has not been verified, it may be larger than UCHAR_MAX
theoretically. This would lead to an infinite loop.

This patch declares the socket ID type as 'int' or 'unsigned int' by
referring to the common practice in EAL.

Fixes: 56b6ef874f80 ("efd: new Elastic Flow Distributor library")
Fixes: f00708c2aa53 ("node: add IPv4 rewrite and lookup control")
Cc: stable@dpdk.org

Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 lib/efd/rte_efd.c     | 4 ++--
 lib/node/ip4_lookup.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c
index 77f4680..4d354d8 100644
--- a/lib/efd/rte_efd.c
+++ b/lib/efd/rte_efd.c
@@ -500,7 +500,7 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len,
 	struct rte_efd_table *table = NULL;
 	uint8_t *key_array = NULL;
 	uint32_t num_chunks, num_chunks_shift;
-	uint8_t socket_id;
+	unsigned int socket_id;
 	struct rte_efd_list *efd_list = NULL;
 	struct rte_tailq_entry *te;
 	uint64_t offline_table_size;
@@ -746,7 +746,7 @@ rte_efd_find_existing(const char *name)
 void
 rte_efd_free(struct rte_efd_table *table)
 {
-	uint8_t socket_id;
+	unsigned int socket_id;
 	struct rte_efd_list *efd_list;
 	struct rte_tailq_entry *te, *temp;
 
diff --git a/lib/node/ip4_lookup.c b/lib/node/ip4_lookup.c
index d083a72..4811378 100644
--- a/lib/node/ip4_lookup.c
+++ b/lib/node/ip4_lookup.c
@@ -129,7 +129,7 @@ rte_node_ip4_route_add(uint32_t ip, uint8_t depth, uint16_t next_hop,
 {
 	char abuf[INET6_ADDRSTRLEN];
 	struct in_addr in;
-	uint8_t socket;
+	int socket;
 	uint32_t val;
 	int ret;
 
-- 
2.7.4


             reply	other threads:[~2021-04-27  9:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27  9:36 Min Hu (Connor) [this message]
2023-06-29 16:40 ` Stephen Hemminger

Reply instructions:

You may reply publicly 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=1619516192-40499-1-git-send-email-humin29@huawei.com \
    --to=humin29@huawei.com \
    --cc=byron.marohn@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=ndabilpuram@marvell.com \
    --cc=pbhagavatula@marvell.com \
    --cc=yipeng1.wang@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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).