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 D6212A00BE for ; Mon, 7 Mar 2022 17:48:31 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C7A16411FE; Mon, 7 Mar 2022 17:48:31 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2040.outbound.protection.outlook.com [40.107.243.40]) by mails.dpdk.org (Postfix) with ESMTP id A52004014E; Mon, 7 Mar 2022 17:48:29 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=irzgCIdxfZhVT/cUa2fsVBn0Diz4ZPZoo2nuUQLnqJoGR3osOYI2AT43BzZa6aFMwlerlb8Grr1eWM57Q8wJkLsRhA8DZKPLHSIxYdkdjlfwI50Y4m9tI9F7szyHuysLdk/dB6l2cKI2Xx4CBxhuYtrtCmnM1ipsgzfTz8ljdG6d1mn3bG2jJuNqV41Q6WMHhl0gesvGGh5eKcG+AgbnyeiBbu2qy3WbXv1ivs+vojQPLT2Nh6PRJlQqa3XlMTmPe97aT4kMewei1BMxY7kCkA4owdGvNGLzd8pOco+vWnmQkxg1QfY0DPTBHt1jF8bd0II8WLMLo8lwuIjGk0IYxA== 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=N8/qEGtgf3xd+7xJ/XemkI31vOzTK0llGBjFbqShJtQ=; b=C50PcSoI/oCjtkKrSgS3PM4xunZDk1IPaT/VoC4NjLbp+4BLGiOQ+5Akgn5rbqFoj0IwLUfdaTWsoNhnKNAG4mC9cbtSVqqJUpwNCDnpxflh+prxe9ml9mijksdtXnH/XCMZYtVAnfzsUl5IF8qyXOLJZi63sVPPacNdSx2Sou7QBgNYZH9AgNPnEZb48ua7fbAyBMv/UdoZcSa8jiKs/HtubTbvsXx63LJ1hnIQWHRDFnjif9In/ehGewWhSrXO2HYhXINwkyD8+e2cIHBQOZpq8dKkYi63wvQNiJYL8Wjyt8xAptUQZxkS4r7JCdNy0dmnVHsU2iRI1yuV+B7gRQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) 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=N8/qEGtgf3xd+7xJ/XemkI31vOzTK0llGBjFbqShJtQ=; b=IerQh/O5/8qdawLnHApHQU9EFMRuFRjNf3C2V/ve1aWffm4cKg38arLKxetau9djixhM9L7YidX8o0HimkdG0jWszTAOzOAmkamcXx2cIvVNW9V7SbPbkw9aVkCH5JqdIeaCjX3qXopZfJh7cB+p6/Cz+Ue5dxhLcwAGE9CM5jDx3hvXugJyKdOVKtgxR8EBKp6N5nVGPsywwkeFGkCdwzOCFUHavDdtaoA7cmjH0/wY8PT8SBbCJO8gnb4iSYtiPC2x4jGp2aJ6+NsElRftrzucb7XnCDo2LYVe7qBVW2hO9IzmA3p07FU+rt6iPqxEcLLCu7BI665E9vTAR62ydQ== Received: from DM6PR13CA0051.namprd13.prod.outlook.com (2603:10b6:5:134::28) by CH2PR12MB3829.namprd12.prod.outlook.com (2603:10b6:610:2c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.13; Mon, 7 Mar 2022 16:48:27 +0000 Received: from DM6NAM11FT054.eop-nam11.prod.protection.outlook.com (2603:10b6:5:134:cafe::cd) by DM6PR13CA0051.outlook.office365.com (2603:10b6:5:134::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.17 via Frontend Transport; Mon, 7 Mar 2022 16:48:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) 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.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by DM6NAM11FT054.mail.protection.outlook.com (10.13.173.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5038.14 via Frontend Transport; Mon, 7 Mar 2022 16:48:27 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 7 Mar 2022 16:48:26 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Mon, 7 Mar 2022 08:48:25 -0800 Received: from nvidia.com (10.127.8.11) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.9 via Frontend Transport; Mon, 7 Mar 2022 08:48:23 -0800 From: Dmitry Kozlyuk To: CC: , Matan Azrad , Xiaoyun Li , Aman Singh , Yuying Zhang Subject: [PATCH] app/testpmd: fix use of indirect action after port close Date: Mon, 7 Mar 2022 18:48:21 +0200 Message-ID: <20220307164821.821406-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: aec09003-c7ee-418a-55dc-08da005a4d60 X-MS-TrafficTypeDiagnostic: CH2PR12MB3829: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: KQyYtsRq5s9kwyjJvgtpzYmkhCS682mMPuTnY7mdr1LcfUH+SI59q369g6I1oAn4BLpp59JQlfi5VDCFMaQKNBHPLEQlB99ehPXFiqLrgYllQYJ8o09fe+x3Bz/k7AuTTLT2VZBlanlXVrkdWIo/xKjcSCAF89C8ZrVAPSABVruGRzwp/5YCsMJOiByoJrFfLpJKQ6RaEIwm0zzEemBHmVP9BigpmG+UHCyVzFXlSlOlsc+vweuLQGi1LBIVVm51IKsGvg61/uJwPr/gZisoMxB5ijgViUZaDahRO81qZfCRSxpWG0DZZv4ZyisZVcmFbc8L77Z0Cd0Chz5TRzm+Dkp9n58RgisliMFgJBe8EzW06rCR2hi7ieZbflM4QVC8cTqpmb7ed4+1FO7T5YK19SL3+61iG/ZzZKh1NmDE12XRVU8WG3/NAYA3AQknVS0+Z6f8Djb0NuAk5dqvg83vJtpCQqxdbYW7mE0JNk3olRpFQ8dMaIrO72NkOAmrMIZGXlyzHSWL4FfaJTXTF+nvT3pzJSP2zO8sub0cvjvpKYMVbVfiUf6VTUPf5VvL71W6zx/YxDOIa9numAuELgkqH6kRSpsVzg5fRsD3VjuOJL0pclungSGvmkOQ8iuGVgJKdtgUHH4l8/06acD6jaorMUslO+kBiMtpe/L+qwS8VNXBG2fz1JuBYP4h/20cNfS9RH3XfrtV8/k6TsXaoMqvKg== X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(508600001)(8676002)(8936002)(47076005)(82310400004)(55016003)(316002)(54906003)(70206006)(4326008)(86362001)(70586007)(6916009)(36860700001)(83380400001)(40460700003)(5660300002)(6286002)(81166007)(356005)(7696005)(336012)(426003)(2616005)(186003)(26005)(1076003)(36756003)(2906002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2022 16:48:27.0156 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aec09003-c7ee-418a-55dc-08da005a4d60 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.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT054.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB3829 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 When a port was closed, 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. Automatically flush indirect actions when a port is closed. Fixes: 4b61b8774be9 ("ethdev: introduce indirect flow action") Cc: stable@dpdk.org Signed-off-by: Dmitry Kozlyuk Acked-by: Matan Azrad --- app/test-pmd/config.c | 31 +++++++++++++++++++++++++++++++ app/test-pmd/testpmd.c | 1 + app/test-pmd/testpmd.h | 1 + 3 files changed, 33 insertions(+) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index cc8e7aa138..04baa319e0 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1844,6 +1844,37 @@ port_action_handle_destroy(portid_t port_id, return ret; } +int +port_action_handle_flush(portid_t port_id) +{ + struct rte_port *port; + struct port_indirect_action **tmp; + int ret = 0; + + if (port_id_is_invalid(port_id, ENABLED_WARN) || + port_id == (portid_t)RTE_PORT_ALL) + return -EINVAL; + port = &ports[port_id]; + tmp = &port->actions_list; + while (*tmp != NULL) { + struct rte_flow_error error; + struct port_indirect_action *pia = *tmp; + + /* Poisoning to make sure PMDs update it in case of error. */ + memset(&error, 0x44, sizeof(error)); + if (pia->handle != NULL && + rte_flow_action_handle_destroy + (port_id, pia->handle, &error) != 0) { + printf("Indirect action #%u not destroyed\n", pia->id); + ret = port_flow_complain(&error); + tmp = &pia->next; + } else { + *tmp = pia->next; + free(pia); + } + } + return ret; +} /** Get indirect action by port + id */ struct rte_flow_action_handle * diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index fe2ce19f99..f07f76f8f5 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -3139,6 +3139,7 @@ close_port(portid_t pid) if (is_proc_primary()) { port_flow_flush(pi); port_flex_item_flush(pi); + port_action_handle_flush(pi); rte_eth_dev_close(pi); } diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 31f766c965..e25663e5b3 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -907,6 +907,7 @@ int port_action_handle_create(portid_t port_id, uint32_t id, const struct rte_flow_action *action); int port_action_handle_destroy(portid_t port_id, uint32_t n, const uint32_t *action); +int port_action_handle_flush(portid_t port_id); struct rte_flow_action_handle *port_action_handle_get_by_id(portid_t port_id, uint32_t id); int port_action_handle_update(portid_t port_id, uint32_t id, -- 2.25.1