[PATCH v2] app/testpmd: fix quit testpmd with vfs and pf

Thomas Monjalon thomas at monjalon.net
Wed Jun 22 23:31:18 CEST 2022


Sorry, this patch looks really wrong, I cannot pull it into the main branch.
See below for an explanation.


21/06/2022 12:43, Ferruh Yigit:
> On 6/21/2022 10:24 AM, Ke Zhang wrote:
> > When testpmd startups with pf and vfs,this error occurs when quitting,
> > results in pf is released before vfs ,so the vf would access an
> > freed heap memory.
> > 
> > The solution is two steps:
> > 1. Fetch the valid port value from RTE_ETH_FOREACH_DEV.
> > 2. free the port in reverse order.
> > 
> > Fixes: 08fd782b8454 ("app/testpmd: fix quit to stop all ports before close")
> > Cc: stable at dpdk.org
> > 
> > Signed-off-by: Ke Zhang <ke1x.zhang at intel.com>
> 
> Acked-by: Aman Singh <aman.deep.singh at intel.com>
> Acked-by: Ferruh Yigit <ferruh.yigit at xilinx.com>
> 
> Applied to dpdk-next-net/main, thanks.
> 
> 
> > ---
> >   app/test-pmd/testpmd.c | 26 +++++++++++++++++++++-----
> >   1 file changed, 21 insertions(+), 5 deletions(-)
> > 
> > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> > index 04c39adc21..c01ecf7279 100644
> > --- a/app/test-pmd/testpmd.c
> > +++ b/app/test-pmd/testpmd.c
> > @@ -3492,16 +3492,32 @@ pmd_test_exit(void)
> >   	}
> >   #endif
> >   	if (ports != NULL) {
> > +		portid_t ethports[RTE_MAX_ETHPORTS];
> > +		int count = 0;
> > +		int index = 0;
>  >   		no_link_check = 1;
> 
> No need to initialize 'index'.
> 
> And better to have an empty line after deceleration block.
> 
> > +
> > +		/* Fetch the valid port id from port list*/
> >   		RTE_ETH_FOREACH_DEV(pt_id) {
> > -			printf("\nStopping port %d...\n", pt_id);
> > +			ethports[count] = pt_id;
> > +			count++;
> > +		}
> > +
> > +		/*
> > +		 * Free the port from Reverse order, as general,
> > +		 * PF port < VF port, VF should be free before PF
> > +		 * be free.

No sorry, this is wrong.
The port ID says nothing.
If a port is closed before creating a VF,
it can be VF < PF.

> > +		 */
> > +		for (index = count - 1 ; index >= 0 ; index--) {
> 
> Space is not needed after ';'.
> 
> 
> Since these are minor, I will fix while merging.





More information about the stable mailing list