From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 30809A04B5; Tue, 27 Oct 2020 03:46:22 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6BF2E1E2B; Tue, 27 Oct 2020 03:46:20 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by dpdk.org (Postfix) with ESMTP id 5C591100C for ; Tue, 27 Oct 2020 03:46:18 +0100 (CET) Received: from DGGEMM403-HUB.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4CKx0q5WX7z4ybn; Tue, 27 Oct 2020 10:46:19 +0800 (CST) Received: from DGGEMM533-MBX.china.huawei.com ([169.254.5.167]) by DGGEMM403-HUB.china.huawei.com ([10.3.20.211]) with mapi id 14.03.0487.000; Tue, 27 Oct 2020 10:46:07 +0800 From: wangyunjian To: Thomas Monjalon , Andrew Rybchenko CC: "dev@dpdk.org" , "ferruh.yigit@intel.com" , "Lilijun (Jerry)" , xudingke , "matan@nvidia.com" Thread-Topic: [dpdk-dev] [PATCH] ethdev: fix data type for port id Thread-Index: AQHWq5L49iVUYPzeC06SfSzdCtm9ZqmpSgQAgAABDwCAAABQgIABc33A Date: Tue, 27 Oct 2020 02:46:07 +0000 Message-ID: <34EFBCA9F01B0748BEB6B629CE643AE60DAD8144@DGGEMM533-MBX.china.huawei.com> References: <2394739.RyDTFpqa36@thomas> <805008d1-0e44-3cae-4997-80afacb79bd6@oktetlabs.ru> <3765724.HKehNzLIeC@thomas> In-Reply-To: <3765724.HKehNzLIeC@thomas> Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.174.187.156] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected Subject: Re: [dpdk-dev] [PATCH] ethdev: fix data type for port id X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" > -----Original Message----- > From: Thomas Monjalon [mailto:thomas@monjalon.net] > Sent: Monday, October 26, 2020 8:34 PM > To: Andrew Rybchenko > Cc: wangyunjian ; dev@dpdk.org; > ferruh.yigit@intel.com; Lilijun (Jerry) ; xudin= gke > ; matan@nvidia.com > Subject: Re: [dpdk-dev] [PATCH] ethdev: fix data type for port id >=20 > 26/10/2020 13:33, Andrew Rybchenko: > > On 10/26/20 3:29 PM, Thomas Monjalon wrote: > > > 26/10/2020 13:24, wangyunjian: > > >> From: Yunjian Wang > > >> > > >> The ethdev port id should be 16 bits now. This patch fixes the data > > >> type of the variable for 'pid', changing from uint32_t to uint16_t. > > >> > > >> Fixes: 5b7ba31148a8 ("ethdev: add port ownership") > > > > > > It was 32-bit on purpose, to avoid overflow in this loop: > > > for (pid =3D 0; pid < RTE_MAX_ETHPORTS; pid++) > > > > > > It is now replaced by RTE_ETH_FOREACH_VALID_DEV, but I wonder > > > whether we still have this theoritical overflow risk. > > > If yes, we should change more variables to 32-bit. > > > > Ah, it is too tricky. May be it is better to ensure that > > RTE_MAX_ETHPORTS is less or equal to UINT16_MAX? >=20 > Yes could be another option. >=20 Add a check on RTE_MAX_ETHPORT in rte_eal_init()?