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 0EDF1A0548; Tue, 27 Apr 2021 13:06:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7C4C540142; Tue, 27 Apr 2021 13:06:08 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 10C974003D for ; Tue, 27 Apr 2021 13:06:06 +0200 (CEST) IronPort-SDR: OFKj7svNyhfBhQi9BUTH5zZx+0p/tRPxjEaPKdREUw/OICrbBk2arTIY6/+mXKKhy50qxK4JlA wxBik0M9WJFw== X-IronPort-AV: E=McAfee;i="6200,9189,9966"; a="281820700" X-IronPort-AV: E=Sophos;i="5.82,254,1613462400"; d="scan'208";a="281820700" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2021 04:06:05 -0700 IronPort-SDR: KuWvahtQ/je1GA0/pli2iPUkD/HldwdnmEXSMpedtPcyoJeM9FnWRBH5CAbMqW/jXAx7AU85CY VPqsvGWBLysw== X-IronPort-AV: E=Sophos;i="5.82,254,1613462400"; d="scan'208";a="457596813" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.221.231]) ([10.213.221.231]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2021 04:06:05 -0700 To: "Min Hu (Connor)" , dev@dpdk.org References: <1619520847-43907-1-git-send-email-humin29@huawei.com> From: Ferruh Yigit X-User: ferruhy Message-ID: <90356c3e-a4b5-be4b-1a42-12695738927c@intel.com> Date: Tue, 27 Apr 2021 12:06:01 +0100 MIME-Version: 1.0 In-Reply-To: <1619520847-43907-1-git-send-email-humin29@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v3] net/bonding: fix socket id check 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 Sender: "dev" On 4/27/2021 11:54 AM, Min Hu (Connor) wrote: > From: Chengchang Tang > > The socket ID entered by user is cast to an unsigned integer. However, > the value may be an illegal negative value, which may cause some > problems. In this case, an error should be returned. > > In addition, the socket ID may be an invalid positive number, which is > also processed in this patch. > > Fixes: 2efb58cbab6e ("bond: new link bonding library") > Cc: stable@dpdk.org > > Signed-off-by: Chengchang Tang > Signed-off-by: Min Hu (Connor) > --- > v3: > * changed type of socket id. > > v2: > * fixed socket id type. > --- > drivers/net/bonding/rte_eth_bond_args.c | 6 +++--- > drivers/net/bonding/rte_eth_bond_pmd.c | 4 ++-- > 2 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c > index 8c5f90d..977f3fe 100644 > --- a/drivers/net/bonding/rte_eth_bond_args.c > +++ b/drivers/net/bonding/rte_eth_bond_args.c > @@ -207,13 +207,13 @@ bond_ethdev_parse_socket_id_kvarg(const char *key __rte_unused, > return -1; > > errno = 0; > - socket_id = (uint8_t)strtol(value, &endptr, 10); > + socket_id = (int)strtol(value, &endptr, 10); > if (*endptr != 0 || errno != 0) > return -1; > > /* validate socket id value */ > - if (socket_id >= 0) { > - *(uint8_t *)extra_args = (uint8_t)socket_id; > + if (socket_id >= 0 && socket_id < RTE_MAX_NUMA_NODES) { > + *(int *)extra_args = socket_id; What do you think to keep this local 'socket_id' variable as "long int" as reasons commented on previous versions. > return 0; > } > return -1; > diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c > index 2e9cea5..4fad563 100644 > --- a/drivers/net/bonding/rte_eth_bond_pmd.c > +++ b/drivers/net/bonding/rte_eth_bond_pmd.c > @@ -3333,8 +3333,8 @@ bond_probe(struct rte_vdev_device *dev) > const char *name; > struct bond_dev_private *internals; > struct rte_kvargs *kvlist; > - uint8_t bonding_mode, socket_id/*, agg_mode*/; > - int arg_count, port_id; > + uint8_t bonding_mode /*, agg_mode*/; Can you please cleanup the 'agg_mode' while you are touching this. > + int arg_count, port_id, socket_id; Can you add it into new line, instead of appending? > uint8_t agg_mode; > struct rte_eth_dev *eth_dev; > >