From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A498CA034C for ; Tue, 21 Jun 2022 12:43:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9D976427F0; Tue, 21 Jun 2022 12:43:52 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2080.outbound.protection.outlook.com [40.107.243.80]) by mails.dpdk.org (Postfix) with ESMTP id 2552740151; Tue, 21 Jun 2022 12:43:50 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KCfFFssKXfwpUiZ0x1cEiwO4PY21tpFecw4xzK69ZAZ7yBF+/EY+OjhBXsM9EZyuqKECtM8ag5zn0KtskGb7Q2gNKvIPSvbXRkZ2kzQBtkWgQYS58x40e6BqPxegOHpkDUgg7bhImbuYrrrSNNf1eUMdJR9kljRarySq08jXPWv2ctIX8pL3z5ZabGhOmBcsD8V7xv4DOH/SoOn0f1et0Y2fr/9cM3AAFyKmvGoagseoTb1p1VgmUHdWIc0OI8uqWOLIJ1+7K/WwoRnuU14VsX1g1mkCYAtp9sXf9a6AHjKuEYouOiVYyDAsTm907IlDxNSeesKEHdqf1TphUBTNaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WyT+pA1Se0dejSiiazzwG6n+Eq4guKF3WTEktr8wpc4=; b=CJxrtOq5H0iuBnxm5d64VggJ0PhImx/YSnqqYE9ktrkppJ9jYAVdPYiEo2w+PBoAcAqJ17N194zQqXEfnUzMXgSYIaN9BD6f7onna5q0Z5nVgs3a+ZrMs8+cc/px3HfcbGnrfUpM1my+tvFfeyB4LxLYeNGwscBqDVwiNyZT7RyfoBld87P6EWln40SSn+bLfVC1rn0JD1ANphlWNitt39LcI0GIifRv7Kd4gf/Zd2kNh7iu3MppmIuu4W+gY+LirG4a98OrOvJxbnVxjXSp8zgSaqMuABb2+JVrTPXgeCM+8drlzAH6HSW5+b65bq4ijt1GFzsTPOFao5SljSzPIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.80.198) smtp.rcpttodomain=intel.com smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WyT+pA1Se0dejSiiazzwG6n+Eq4guKF3WTEktr8wpc4=; b=QTHJtHi+0hoxIbSDn1Y5Rktx6ToUPaT76MZFNbiML9QzS3OJAirf4BYfDG2O5PmZdJgKv9xhtpZ7R+cnuf9lNIJkHm0/Zjy2NwZX4K7sFRWJXg89uN7lWhAJlKnIWvA2+LqP9xN8fsgfmG91kGyxVV26QZMJkg72g3NCVdIiSEE= Received: from DS7PR05CA0043.namprd05.prod.outlook.com (2603:10b6:8:2f::22) by BYAPR02MB5110.namprd02.prod.outlook.com (2603:10b6:a03:62::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.21; Tue, 21 Jun 2022 10:43:48 +0000 Received: from DM3NAM02FT018.eop-nam02.prod.protection.outlook.com (2603:10b6:8:2f:cafe::87) by DS7PR05CA0043.outlook.office365.com (2603:10b6:8:2f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.9 via Frontend Transport; Tue, 21 Jun 2022 10:43:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.80.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.80.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.80.198; helo=xir-pvapexch01.xlnx.xilinx.com; pr=C Received: from xir-pvapexch01.xlnx.xilinx.com (149.199.80.198) by DM3NAM02FT018.mail.protection.outlook.com (10.13.4.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5353.14 via Frontend Transport; Tue, 21 Jun 2022 10:43:47 +0000 Received: from xir-pvapexch01.xlnx.xilinx.com (172.21.17.15) by xir-pvapexch01.xlnx.xilinx.com (172.21.17.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Tue, 21 Jun 2022 11:43:46 +0100 Received: from smtp.xilinx.com (172.21.105.197) by xir-pvapexch01.xlnx.xilinx.com (172.21.17.15) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 21 Jun 2022 11:43:46 +0100 Envelope-to: ke1x.zhang@intel.com, stable@dpdk.org, dev@dpdk.org, xiaoyun.li@intel.com, aman.deep.singh@intel.com, yuying.zhang@intel.com Received: from [10.71.119.54] (port=31743) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1o3bMI-0007d3-H6; Tue, 21 Jun 2022 11:43:46 +0100 Message-ID: Date: Tue, 21 Jun 2022 11:43:46 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v2] app/testpmd: fix quit testpmd with vfs and pf Content-Language: en-US To: Ke Zhang CC: , , , , References: <20220322071833.199619-1-ke1x.zhang@intel.com> <20220621092453.185583-1-ke1x.zhang@intel.com> From: Ferruh Yigit In-Reply-To: <20220621092453.185583-1-ke1x.zhang@intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0a7b1c5e-0292-4e4d-7980-08da5372ec18 X-MS-TrafficTypeDiagnostic: BYAPR02MB5110:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4sG3AIeXPSAle12ik6jvN2bySISA1GvXl2fpQqEZwMY1RO9rxM0Obx1Cdo1WP1dJUv3R0sd3/M1KipYGshXMjKnZZMqBexfZyXPHM9JvyPVTJdHXZqPUxMsdu0vu/qe2Zpcb5ofpbPCUfsc1KWStKFCQVVs6SndHXJ3hY8FAvxzkAQgiSp0PUkhMnQ6O1MihPAhFLSlvGxhWtmtbDouxjb644tV31gPhl8lgc/IWF6lRhnibq9h5WDMuhzHOAXGmJ/Rg7cV7LVKEvD2MEcbUJf2QXTBgDa+qDtIB3BBWs+ErtmsEelPYIjeSl7H3b4fCyiea/BZUDapZOgdTOUKY5AR2eTTPn42rrys9ltv4oMkawBry1gor+HoQkQHiedF3kaWXXFhu8Xgwl/h3VOGrFavLSktDov/McuUXuprKSv9eKdM2bUQoVveV97Lz7pGLODsiO30boG+lu8VFsECN9d0tpKqEBjU/9BBC7ZPBuTTlPp6G6zNYLgauL0h8ExAy3ogplhA8Hl+nK38K3EiGFCAGarNBLOMZAlH2WwOukzaDZK8C4+rQAc9Cjx0Z2gzogXF7y9KEAd5NbiASYoz7KlRJv3rLHUlQmRDv/MsMXW6dZsEe5gTFg8bCRrCMzl/gqsjD71IXGH0VFqd/F9qg9iYVeexNSyqUndiax0E78YM5Iwuz4ZXBuTXK88+zx7/9aBAYgL4ScsS1mSmK8TkcJFdoL//yJxXjIxO2uOG3unH3TTmAibHJwljMLwZyHKMf3H3khKyLwRRQp4yE1vPF2A== X-Forefront-Antispam-Report: CIP:149.199.80.198; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:xir-pvapexch01.xlnx.xilinx.com; PTR:unknown-80-198.xilinx.com; CAT:NONE; SFS:(13230016)(4636009)(396003)(39860400002)(136003)(376002)(346002)(40470700004)(36840700001)(46966006)(53546011)(40460700003)(336012)(26005)(5660300002)(47076005)(7636003)(426003)(186003)(82310400005)(2906002)(31686004)(8936002)(44832011)(9786002)(40480700001)(36756003)(70206006)(356005)(478600001)(41300700001)(31696002)(6916009)(8676002)(70586007)(2616005)(82740400003)(4326008)(316002)(54906003)(36860700001)(83380400001)(50156003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2022 10:43:47.6563 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0a7b1c5e-0292-4e4d-7980-08da5372ec18 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.80.198]; Helo=[xir-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: DM3NAM02FT018.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR02MB5110 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org 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@dpdk.org > > Signed-off-by: Ke Zhang Acked-by: Aman Singh Acked-by: Ferruh Yigit 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. > + */ > + for (index = count - 1 ; index >= 0 ; index--) { Space is not needed after ';'. Since these are minor, I will fix while merging.