[PATCH v2] app/testpmd: fix quit testpmd with vfs and pf
Ferruh Yigit
ferruh.yigit at xilinx.com
Tue Jun 21 11:20:00 CEST 2022
On 6/21/2022 10:03 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>
> ---
> app/test-pmd/testpmd.c | 27 ++++++++++++++++++++++-----
> 1 file changed, 22 insertions(+), 5 deletions(-)
>
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> index 04c39adc21..67b4941942 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -3491,17 +3491,34 @@ pmd_test_exit(void)
> }
> }
> #endif
> + portid_t ethports[RTE_MAX_ETHPORTS];
> + int count;
> + int index;
Hi Ke,
These variables only used in the 'if' block, to reduce the scope of them
can you please move them at the very top of the block:
if (ports != NULL) {
portid_t ethports[RTE_MAX_ETHPORTS];
int count = 0;
int index;
no_link_check = 1;
...
> if (ports != NULL) {
> no_link_check = 1;
> + count = 0;
> +
> + /* 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.
> + */
> + for (index = count - 1 ; index >= 0 ; index--) {
> + printf("\nStopping port %d...\n", ethports[index]);
> fflush(stdout);
> - stop_port(pt_id);
> + stop_port(ethports[index]);
> }
> - RTE_ETH_FOREACH_DEV(pt_id) {
> - printf("\nShutting down port %d...\n", pt_id);
> +
> + for (index = count - 1 ; index >= 0 ; index--) {
> + printf("\nShutting down port %d...\n", ethports[index]);
> fflush(stdout);
> - close_port(pt_id);
> + close_port(ethports[index]);
> }
> }
>
More information about the dev
mailing list