[dpdk-dev] [PATCH v5 1/4] examples/multi_process/client_server_mp: check port validity
Matan Azrad
matan at mellanox.com
Tue Aug 6 22:03:22 CEST 2019
Hi
From: Stephen Hemminger
> Sent: Tuesday, August 6, 2019 6:40 PM
> To: Matan Azrad <matan at mellanox.com>
> Cc: dev at dpdk.org; Stephen Hemminger <sthemmin at microsoft.com>
> Subject: Re: [dpdk-dev] [PATCH v5 1/4]
> examples/multi_process/client_server_mp: check port validity
>
> On Tue, 6 Aug 2019 08:19:01 +0000
> Matan Azrad <matan at mellanox.com> wrote:
>
> > From: Stephen Hemminger
> > > On Sun, 4 Aug 2019 08:31:54 +0000
> > > Matan Azrad <matan at mellanox.com> wrote:
> > >
> > > > > > > /* convert parameter to a number and verify */
> > > > > > > pm = strtoul(portmask, &end, 16);
> > > > > > > - if (end == NULL || *end != '\0' || pm == 0)
> > > > > > > + if (end == NULL || *end != '\0' || pm > UINT16_MAX || pm
> > > == 0)
> > > > > >
> > > > > > Why pm > UINT16_MAX ? should be something like > (1 <<
> > > > > RTE_MAX_ETHPORTS) - 1.
> > > > > > And need to be sure pm type can hold RTE_MAX_ETHPORTS bits,
> > > > > otherwise port 0 may unlikely be all the time visible in the loop below.
> > > > > >
> > > > >
> > > > > The DPDK assumes a lot of places that unsigned long will hold a
> > > > > port
> > > mask.
> > > >
> > > > So, all are bugs, no?
> > >
> > > I don't think 32 bit build is that well tested. But yes a mask needs
> > > to hold 64 ports.
> >
> > What if someone changes RTE_MAX_ETHPORTS to be bigger than 64 in
> config file?
> >
> > Assume the user changes RTE_MAX_ETHPORTS to 128, and there is a valid
> port in range [64, 127].
> > Then, assume the failsafe sub device owns port ID 0.
> >
> > Because the mask bits are not enough to handle the above range, you will
> get port 0 as valid port - bug.
> >
> > I think you need one more check to the RTE_MAX_ETHPORTS > 64 case.
>
> Not really needed.
>
> The DPDK has lots of hard coded assumptions of all ports fitting in 64 bits.
> Examples include testpmd/parameters.c etc.
Yes, I understand, but the user should know not to change the default value of
RTE_MAX_ETHPORTS, at least it should be documented.
> The original concept of a small set of assigned values for portid is not going to
> scale. It really should have been more like ifindex; something that is not used
> by common API's much larger range; and assigned purely sequentially.
>
> The API's should all be using names, but the DPDK port naming is also a
> mess...
Port ID is OK, user can run port info, then to find the wanted port ID and configure it by port id list\bitmap.
More information about the dev
mailing list