[dpdk-dev] [PATCH] ethdev: fix data type for port id

wangyunjian wangyunjian at huawei.com
Tue Oct 27 03:46:07 CET 2020


> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas at monjalon.net]
> Sent: Monday, October 26, 2020 8:34 PM
> To: Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru>
> Cc: wangyunjian <wangyunjian at huawei.com>; dev at dpdk.org;
> ferruh.yigit at intel.com; Lilijun (Jerry) <jerry.lilijun at huawei.com>; xudingke
> <xudingke at huawei.com>; matan at nvidia.com
> Subject: Re: [dpdk-dev] [PATCH] ethdev: fix data type for port id
> 
> 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 <wangyunjian at huawei.com>
> > >>
> > >> 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 = 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?
> 
> Yes could be another option.
> 

Add a check on RTE_MAX_ETHPORT in rte_eal_init()?



More information about the dev mailing list