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 0EC3EA0547; Thu, 16 Jun 2022 01:12:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B1D99410D0; Thu, 16 Jun 2022 01:12:25 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2076.outbound.protection.outlook.com [40.107.94.76]) by mails.dpdk.org (Postfix) with ESMTP id 1F88840E0F; Thu, 16 Jun 2022 01:12:24 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fdaQJoO7UyWvRRFC7XtG5hNVBLvIQaT8mcnI3joEW9PfG2d34XSseKuY9Dg6e9uXLOrxkOnIKJlcur4uR7AV+kd4rnV2D6MJCJ3ooCFnXwYsLOtS4qf0ajjJhXn8Tr+YSVJFRMaEzKe7MrW6TxyJeovPB++jxc+nyctjEMCxvHP2tLPB00o3CESr33EKKpFKZCpwjjxvpEE/HysPhb0ejBvH5U/sy0ISShHWnRxFMHyQLjA3jyBGl6mqlInBy/9ZrLl4cdYUxFEVnb+AToVHPDINdASzXKyuzGXvkqkZ5imNe4wRsUwLTPS8BwB8y8q6A3qHTuRmeYqsWrlSHJunuQ== 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=YMI60KlIHg1SrO1RY/uVbLEJGdUeThi6UeBr3coQC98=; b=YlT+1jSCjfqF8ne+9/7RF1HbphepoQEpJiwpOT9eZpGeV6lKa2o0hV4hXwvMtuBzx+ubzB8cK4pFY72TJdb7JSYLnwxzX3SpSZ0j/sb8bzQnXsr4t9Pz5X6eWNvPUsrd+hAqhRNLV5sCX0y0+GuvKsVKhraZgsv30ztiR3z4/HjdnKp4kdEqIvAOpJFdaYY94vYQ/CLxtB8lVN4RuGJ0nZgwuR+m/P24DaIqKEDncfopqgFQlOdnClki6OOJInI7nvAD321wMUowgBmHxc1Z6H+qDdQZsGoEHXc5Kc+/jHe5ZekPbN5f/7qVzu7fN/R1TJ4rbINqz5gBP3YGZ3LJFw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YMI60KlIHg1SrO1RY/uVbLEJGdUeThi6UeBr3coQC98=; b=W/CqFqqLxutmbZ0qQFEJWwl688Mp5BngO84ElAJBFWsMPmf63vBQmC1/6OgUgCMjT0tEfgbTH0y7R73GilO5iVhOVVky5cEYH5tfN7W4lrGBu5RMiR0YXtR8V3i9VU/4t6+iY+dXwRylhvB6pCXVPlBltbgTuD3DTK6UILZafrBJBPkvKhh/qKQuk06L9zyOQCrx3xqSnrOYgma8GzamOPMsJbL4iw4OYJ0BiVn0QWYmGH99wgGiw4lqUOi0j1aH34qaS7Qf7eG6FTtkODf9ha6jNe8o7yFUHXUkcn7k7es3pdplvwjgKFyT1uePXF6S0KXZDKl5Wqix14i5TPZ1vQ== Received: from BN0PR04CA0077.namprd04.prod.outlook.com (2603:10b6:408:ea::22) by DM4PR12MB5136.namprd12.prod.outlook.com (2603:10b6:5:393::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Wed, 15 Jun 2022 23:12:22 +0000 Received: from BN8NAM11FT040.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ea:cafe::e4) by BN0PR04CA0077.outlook.office365.com (2603:10b6:408:ea::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.17 via Frontend Transport; Wed, 15 Jun 2022 23:12:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.238) by BN8NAM11FT040.mail.protection.outlook.com (10.13.177.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5332.12 via Frontend Transport; Wed, 15 Jun 2022 23:12:21 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 15 Jun 2022 23:12:21 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 15 Jun 2022 16:12:20 -0700 Received: from nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.22 via Frontend Transport; Wed, 15 Jun 2022 16:12:18 -0700 From: Dmitry Kozlyuk To: CC: , Matan Azrad , Xiaoyun Li , Aman Singh , Yuying Zhang Subject: [PATCH] app/testpmd: cleanup port resources after implicit close Date: Thu, 16 Jun 2022 02:12:12 +0300 Message-ID: <20220615231212.44122-1-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c7c835ca-4751-40f1-a054-08da4f24808e X-MS-TrafficTypeDiagnostic: DM4PR12MB5136: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: He8jQ2y58BYu4slOdYdKmV+PhzoP0CEZvq7lWuMP5No+wKxefmExaXdVnUEMZEhaZqHikBHhTCxKmLfGcitUYeXOtIhP4SC2QvR6fXgc5swhG8F/Pn0mumVhiyTR30hqTkv84YkOnPh/6ztz8e8ZT/Izj/xqI0rqz3pRDnOyKuhi3Agy9EmeKcteAgA49Jbxyk44xJJS1HLpTktuMQ+WBxEK+HTaYnRXl3e7zOVgUJ2vNWLaQAyenw9VgDe4AFdd7yZzfX5uhvKbg4D1svXil0KkYGBLYcM003cuGw4eg06ZnQfcISwfhXM3LtKL395lkQk5PLO1o6inT7ztqZl+YNMMaJLAfB2Urz2qJzyk4CrUXXdKdk8Xj7rCm/YwpeldFZMcZtmEkj3WeAWyshYGm0xHty6dimFsLC4+vXJWLoBsLVF71xOAOm8khEKvvWoXmymBGkX5LLz7DXtSM9nAbGR+fGD2St9IbTCw/fCJFcFglXPX4p7zIuY4QAx97XWoj2X6cfk+w1KTK/7G0e6p4TcmcO67Xrr6T1APhvOt7WwzQPVbY0vDe+/JPCigzFvHhsXzRjBUSPp7WHBNA0cm/xPhpf/fKfUByvkXM6ebUgoWiVlmNXcZqrY/xk9O98fWLwUqLkvMRy/wlO4Fg7f6hUa5fofToewD84fttjDMVAW4NysL2rsiC60+tDFJkpvs7pJHnnfG45YWokOpfNq4ZQ== X-Forefront-Antispam-Report: CIP:12.22.5.238; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230016)(4636009)(46966006)(40470700004)(36840700001)(81166007)(6666004)(6286002)(40460700003)(55016003)(36756003)(36860700001)(356005)(8936002)(7696005)(26005)(2906002)(508600001)(336012)(47076005)(426003)(1076003)(4326008)(186003)(5660300002)(70206006)(82310400005)(8676002)(83380400001)(6916009)(2616005)(54906003)(70586007)(316002)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2022 23:12:21.8719 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c7c835ca-4751-40f1-a054-08da4f24808e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.238]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT040.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5136 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org When a port was closed implicitly closed by the PMD, for example, if it was a representor port and its master port was detached, flow indirect actions could remain with their handles no longer valid. If a newly attached device was assigned the same ID as the closed port, those indirect actions became accessible again. Any attempt to use them resulted in an undefined behavior. Flow flex items had no such issue on close, but had it on detach. Introduce flush_port_owned_resources() function for consistent cleanup and call it when a port is closed or detached. Make it flush flow rules and multicast addresses too because they logically belong to the port being removed. Fixes: 55509e3a49fb ("app/testpmd: support shared flow action") Fixes: 59f3a8acbcdb ("app/testpmd: add flex item commands") Cc: stable@dpdk.org Signed-off-by: Dmitry Kozlyuk Acked-by: Matan Azrad --- app/test-pmd/testpmd.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 04c39adc21..fe125e40e8 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -3202,6 +3202,15 @@ remove_invalid_ports(void) nb_cfg_ports = nb_fwd_ports; } +static void +flush_port_owned_resources(portid_t pi) +{ + mcast_addr_pool_destroy(pi); + port_flow_flush(pi); + port_flex_item_flush(pi); + port_action_handle_flush(pi); +} + void close_port(portid_t pid) { @@ -3238,10 +3247,7 @@ close_port(portid_t pid) } if (is_proc_primary()) { - mcast_addr_pool_destroy(pi); - port_flow_flush(pi); - port_flex_item_flush(pi); - port_action_handle_flush(pi); + flush_port_owned_resources(pi); rte_eth_dev_close(pi); } @@ -3386,7 +3392,7 @@ detach_device(struct rte_device *dev) sibling); return; } - port_flow_flush(sibling); + flush_port_owned_resources(sibling); } } @@ -3453,7 +3459,7 @@ detach_devargs(char *identifier) rte_devargs_reset(&da); return; } - port_flow_flush(port_id); + flush_port_owned_resources(port_id); } } -- 2.25.1