On Tue, 27 Apr 2021 17:36:32 +0800 "Min Hu (Connor)" <humi...@huawei.com> wrote:
> From: Chengchang Tang <tangchengch...@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: sta...@dpdk.org > > Signed-off-by: Chengchang Tang <tangchengch...@huawei.com> > Signed-off-by: Min Hu (Connor) <humi...@huawei.com> An alternative way of handling this would be to add a compile time check that user did not exceed 255 for numa nodes. I.e: diff --git a/lib/efd/rte_efd.c b/lib/efd/rte_efd.c index dad962ce29bf..8a05909aa4ae 100644 --- a/lib/efd/rte_efd.c +++ b/lib/efd/rte_efd.c @@ -505,6 +505,8 @@ rte_efd_create(const char *name, uint32_t max_num_rules, uint32_t key_len, struct rte_ring *r = NULL; unsigned int i; + RTE_BUILD_BUG_ON(RTE_MAX_NUMA_NODES >= UINT8_MAX); + efd_list = RTE_TAILQ_CAST(rte_efd_tailq.head, rte_efd_list); if (online_cpu_socket_bitmask == 0) { diff --git a/lib/node/ip4_lookup.c b/lib/node/ip4_lookup.c index 8bce03d7db9d..0adcd0436b7b 100644 --- a/lib/node/ip4_lookup.c +++ b/lib/node/ip4_lookup.c @@ -128,6 +128,8 @@ rte_node_ip4_route_add(uint32_t ip, uint8_t depth, uint16_t next_hop, uint32_t val; int ret; + RTE_BUILD_BUG_ON(RTE_MAX_NUMA_NODES >= UINT8_MAX); + in.s_addr = htonl(ip); inet_ntop(AF_INET, &in, abuf, sizeof(abuf)); /* Embedded next node id into 24 bit next hop */