From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5131342D8E; Thu, 29 Jun 2023 18:40:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 252D640EDB; Thu, 29 Jun 2023 18:40:42 +0200 (CEST) Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by mails.dpdk.org (Postfix) with ESMTP id 1D349406B7 for ; Thu, 29 Jun 2023 18:40:41 +0200 (CEST) Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-666eba6f3d6so587055b3a.3 for ; Thu, 29 Jun 2023 09:40:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688056840; x=1690648840; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=pBFPaAbHCfoPvwdN89lIxOKUJWrfR/hJUwusnHbDuP4=; b=oPHtswy+gdWSxEF4vM0RcgDq6y8qYj5GPnwyX8Smo9WejP1CjcD1hNKjyYEdiRayx7 MVcX8RDmiADDwVohE1kemXYBa7esKOB3/xLXOn3Ylztbl41l5AHhsddpGsWQxUK6KJK+ 7c9GbkLtQ4RshxiA6pRAJGW39tWeICHog9RxoX8CkHm4VoATELfzMmGrku1tpgXlYe8D v28AVevk8JCUWCRVEyDxlJYnpNjQfCoqFK/o3dMu6ALmgJEocFt0TXOzWWI1sN9mS2LY 3SBXq3S6e7BomvtLCbqHI2ODYtO9hSCvQCJYMjitKh+ad8j8jiRTNDJ2OLzBNNrt01iL UsfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688056840; x=1690648840; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pBFPaAbHCfoPvwdN89lIxOKUJWrfR/hJUwusnHbDuP4=; b=Vve8scFXZhZBgPAq+D6fx6fnmm3f95bH5XxVbdoiLqO8hoJtAjhY/fXKc0j7dpiSX2 rVeZH8yA6eqzMcV8l80uL3vyZrsHLv/Gf+vUN1ms7m+rpUwLAdcDGEGzAph9WBe7ne12 OXbkby4Dh5mmLelDAM/8stnCkSLXFhk76f5nl9CCHCdLHOzsvTDQXtPlH4GgKvXPjl1D SkqUsFQmB+Us845M4VnoxdVI+diAXEHN2DZlfshEj7iIXrTUda0Ilwq+Tym3xkNkg/FN uhngW2dw0t32jclpGfgqYrJDhtsD/6RgaW4w7dwSBHTAECmJaGjZQ77qyZVqKilpz7mC PU3w== X-Gm-Message-State: ABy/qLaZ9qgx94v0zMamFVQUfFmOBZdiNApcfC5Wa9i7JYOJriqrl2Fy DJOz8GPI+K47Sv3Wiuv5zkH8EQ== X-Google-Smtp-Source: APBJJlFQqDuyCIWVPYmxeFFrt8cveI1FTI4vv4Ug/c4XwMTfO7YCz6gpyXryBAXysUMp/3BWQHu0qQ== X-Received: by 2002:a05:6a00:1402:b0:66a:613f:87e1 with SMTP id l2-20020a056a00140200b0066a613f87e1mr540763pfu.8.1688056840290; Thu, 29 Jun 2023 09:40:40 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id u22-20020aa78496000000b00640f1e4a811sm6969645pfn.22.2023.06.29.09.40.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 09:40:40 -0700 (PDT) Date: Thu, 29 Jun 2023 09:40:38 -0700 From: Stephen Hemminger To: "Min Hu (Connor)" Cc: , , , , , Subject: Re: [dpdk-dev] [PATCH] lib: fix socket id type Message-ID: <20230629094038.4a074498@hermes.local> In-Reply-To: <1619516192-40499-1-git-send-email-humin29@huawei.com> References: <1619516192-40499-1-git-send-email-humin29@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Tue, 27 Apr 2021 17:36:32 +0800 "Min Hu (Connor)" wrote: > From: Chengchang Tang > > 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 > Signed-off-by: Min Hu (Connor) 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 */