From patchwork Wed Jan 17 15:04:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13521871 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2060.outbound.protection.outlook.com [40.107.94.60]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A55D20DD0 for ; Wed, 17 Jan 2024 15:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705503915; cv=fail; b=XGjAS/UC7WSUvZvOyMfbK5aqXy7J3ssRCY3kkhEpN6kOMeSPwFQUw7XHHXp7dX4SwYXH9/KaJMrGBwckwGxttDM3m9+PBuz747Y1805bjI+oAp7Ptp8K1VrBJ3VNaFd5SZmuismREyOF+KROvJmmTiRdYhQQo3E6DJxjknoWAVM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705503915; c=relaxed/simple; bh=ZNRfpCHMcvXBHMLnQ3GVOyHqJol1qYEPL8dT0lqnWkQ=; h=ARC-Message-Signature:ARC-Authentication-Results:DKIM-Signature: Received:Received:X-MS-Exchange-Authentication-Results: Received-SPF:Received:Received:Received:From:To:CC:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy:X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource: X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; b=TVBPrJGEbSufIPUMLuF/0aFwm0in5vO8gRfKjstvtVkY+Z0oOA4vLgSoFvnSTmMF1DxNQXC2Z2tn1hkJ+apa7UeDv1VWLzAbiCS1aSfE4mhTDyc5V9Zc8emQXxXXt50h5W2I1w8RPktJkLJVoZuTZcIYorgPzQUVMGjm7tDE7ug= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=AZwAP+IP; arc=fail smtp.client-ip=40.107.94.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="AZwAP+IP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TGYKIbwna4fNQdMHFFdiRvcC39S96fuiFIs3vEBt8wZRJubXn3ezZ150zwgt1XwLfsmAhnXzkC+vGXBH2i9ZLHctbVVRxzjfdM7ZT5ndi1pnQ7KbD31Rp61q8yJMhN0XUB4nnT6YzXwfMJz3xN2hYRsE+t/1MI7E55k7yqV8pQlZ2isVYgFHASuo94fDKy9v7sctwCzljRuqzOAOW768825K3F/YoYL8RkhubjEswmDFKBWbclaD93QbInuxQ3KkHMqlkEXEoXpK/5DLLuGEeQ2eHB4wIUM0rYFDjhIx3KM+ohTOtMofHkAhz6oPyLm7jS8zK47EX2aBAl04fnPPuw== 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=GGlP82V/d32NkOOVbQKjyi2+WMb7fsa2k3qbU0PD9CM=; b=EMv/x9+rWL1mbP6WvVq+u0ar5HopY5qI0yHc3PUHSzhw5FU83bKxGbDJ1ohvi0o5cZ9JA1EkAfyZL3I3beIKwAOI4iFRVwukKBK0WbaZBc595uJlhkbqeflcLFRdus3Ah8aomH+fz/dEKLjVGOYBAoHpAdqosJ00bg0rBpanszqY6vyqDoFgHERQw8lXZKU6mO0Qy9KFCaBlhg+A+CNFImnTrM/idskqoPAfh6Etpa/ww9KqB1SOLS+oy8cbcK+0xsydxTLVmCLu8PLFxotFntPLLPnyTWUY7qB0Ru8XUbKWmLItAqOpa4NRSDIly6d7qsg48Ykm1qiHMpGDFVCo7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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 (0) 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=GGlP82V/d32NkOOVbQKjyi2+WMb7fsa2k3qbU0PD9CM=; b=AZwAP+IPMD8XWzHnz1WVMNh3WE1RHblm9QpHjUVHKCj5ThQYjFD9FuMF6Yhq5V1E+WOCqFlKB7q/Dd/7UD+fGEoufDD7gGYcphHtKEFkUj1RYcf9UVA3R+ar2CTVJfVcB3DRqvfS+1p8y7AG3nE3na+lASh8Xs3Z5YpALOAcLJBKwTgNZ8Aw4kbTxXc6oUUhTXpexzVhczuB6miZdmZfSDz3PxKBWlPDnnmtO1uc735Mfd/QI+yMidVDnXbIF7zROWWlMLRHKR7HnEgkjH0oAN7nNEJZrmMzeaZ11aPPWyHM8obPdFTOakzmOBQhFP2RKemYOO/BGM7Mci87mPhFUQ== Received: from DM6PR07CA0125.namprd07.prod.outlook.com (2603:10b6:5:330::7) by MW4PR12MB7482.namprd12.prod.outlook.com (2603:10b6:303:212::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.23; Wed, 17 Jan 2024 15:05:08 +0000 Received: from CY4PEPF0000EDD1.namprd03.prod.outlook.com (2603:10b6:5:330:cafe::a7) by DM6PR07CA0125.outlook.office365.com (2603:10b6:5:330::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24 via Frontend Transport; Wed, 17 Jan 2024 15:05:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CY4PEPF0000EDD1.mail.protection.outlook.com (10.167.241.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.16 via Frontend Transport; Wed, 17 Jan 2024 15:05:05 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 17 Jan 2024 07:04:52 -0800 Received: from yaviefel.vdiclient.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 17 Jan 2024 07:04:46 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Amit Cohen , "Jiri Pirko" , Subject: [PATCH net 1/6] mlxsw: spectrum_acl_erp: Fix error flow of pool allocation failure Date: Wed, 17 Jan 2024 16:04:16 +0100 Message-ID: <4cfca254dfc0e5d283974801a24371c7b6db5989.1705502064.git.petrm@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD1:EE_|MW4PR12MB7482:EE_ X-MS-Office365-Filtering-Correlation-Id: f0ec9606-a21c-4196-08a3-08dc176db075 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WCUHHLEN16hADcWJiKlezH7bVnLDg8Au5rRrEg7F1NN0n3gTuQtRq79am9fofl8s3E9uOEg+LVdFLFTtc/myNMLRDnNq4LmhpFZYuefQy8KVA+oISor0B7FIZiU3KyiHrAZtUNs05g8iabWRW2tTUyS5lMSVks9F0/bD+2xfvdsOs0qWzpwqmCkDzLVSyYq2Ibf9St19iKPq8h59w6ugj1vwaLVimHmtUw0E+k8gYLU/xOxB8tCPxkLUhppBPi9uRKeIvijfXjA18pGD3V5c6kJgX/Q9THXsjqO3SQUQ+XQL3B1mszb8Dhn6BKJl9Lpex3Rq/1FDPS/5OuuGh2D1+FH2GPwxgY0VKfSufovm1MiAQ6bpotNauVqiA7INdIexB7gY7MI6Dd9lMn+7IRzRMDfLsI7LF5RmK99GIJdjIXiRNkIDyYQv9DtEzjs6VsDqndSlVw+i8q6H0dbPyeST0b1GU3td17dE8trWoLx/fZ9tEBW/XJZ6iWbzN3HGB6Gl1ZuQa5ZtpOTn2wqp8XIFH1BL1DmdfPgd5wMmHmRfLG6bIMhQW6nCGeBkBnudyESt9fkgEv7CwpMDlJp/+WqJRfBjAZ+db8/5SbvW9GdtK33rmgJmH9Gwfls7VgD9YvvKW50yEC4KzogRat2LrH9q4UraMIxroQcOPedoWHA7ZKxFmv7At/p6ZyS1h0lxTYEo/Ehg0OGB72v835QKYn9i5yAi+Q9Vf4Z6SMp/kio8pNNTAqyOF1RjqHgnfItUQSqR X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(346002)(396003)(136003)(376002)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(82310400011)(40470700004)(36840700001)(46966006)(26005)(6666004)(16526019)(2616005)(107886003)(336012)(7696005)(426003)(36860700001)(83380400001)(47076005)(5660300002)(4326008)(2906002)(8936002)(8676002)(41300700001)(478600001)(316002)(70586007)(110136005)(54906003)(70206006)(36756003)(86362001)(356005)(7636003)(82740400003)(40460700003)(40480700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2024 15:05:05.8008 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f0ec9606-a21c-4196-08a3-08dc176db075 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7482 X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen Lately, a bug was found when many TC filters are added - at some point, several bugs are printed to dmesg [1] and the switch is crashed with segmentation fault. The issue starts when gen_pool_free() fails because of unexpected behavior - a try to free memory which is already freed, this leads to BUG() call which crashes the switch and makes many other bugs. Trying to track down the unexpected behavior led to a bug in eRP code. The function mlxsw_sp_acl_erp_table_alloc() gets a pointer to the allocated index, sets the value and returns an error code. When gen_pool_alloc() fails it returns address 0, we track it and return -ENOBUFS outside, BUT the call for gen_pool_alloc() already override the index in erp_table structure. This is a problem when such allocation is done as part of table expansion. This is not a new table, which will not be used in case of allocation failure. We try to expand eRP table and override the current index (non-zero) with zero. Then, it leads to an unexpected behavior when address 0 is freed twice. Note that address 0 is valid in erp_table->base_index and indeed other tables use it. gen_pool_alloc() fails in case that there is no space left in the pre-allocated pool, in our case, the pool is limited to ACL_MAX_ERPT_BANK_SIZE, which is read from hardware. When more than max erp entries are required, we exceed the limit and return an error, this error leads to "Failed to migrate vregion" print. Fix this by changing erp_table->base_index only in case of a successful allocation. Add a test case for such a scenario. Without this fix it causes segmentation fault: $ TESTS="max_erp_entries_test" ./tc_flower.sh ./tc_flower.sh: line 988: 1560 Segmentation fault tc filter del dev $h2 ingress chain $i protocol ip pref $i handle $j flower &>/dev/null [1]: kernel BUG at lib/genalloc.c:508! invalid opcode: 0000 [#1] PREEMPT SMP CPU: 6 PID: 3531 Comm: tc Not tainted 6.7.0-rc5-custom-ga6893f479f5e #1 Hardware name: Mellanox Technologies Ltd. MSN4700/VMOD0010, BIOS 5.11 07/12/2021 RIP: 0010:gen_pool_free_owner+0xc9/0xe0 ... Call Trace: __mlxsw_sp_acl_erp_table_other_dec+0x70/0xa0 [mlxsw_spectrum] mlxsw_sp_acl_erp_mask_destroy+0xf5/0x110 [mlxsw_spectrum] objagg_obj_root_destroy+0x18/0x80 [objagg] objagg_obj_destroy+0x12c/0x130 [objagg] mlxsw_sp_acl_erp_mask_put+0x37/0x50 [mlxsw_spectrum] mlxsw_sp_acl_ctcam_region_entry_remove+0x74/0xa0 [mlxsw_spectrum] mlxsw_sp_acl_ctcam_entry_del+0x1e/0x40 [mlxsw_spectrum] mlxsw_sp_acl_tcam_ventry_del+0x78/0xd0 [mlxsw_spectrum] mlxsw_sp_flower_destroy+0x4d/0x70 [mlxsw_spectrum] mlxsw_sp_flow_block_cb+0x73/0xb0 [mlxsw_spectrum] tc_setup_cb_destroy+0xc1/0x180 fl_hw_destroy_filter+0x94/0xc0 [cls_flower] __fl_delete+0x1ac/0x1c0 [cls_flower] fl_destroy+0xc2/0x150 [cls_flower] tcf_proto_destroy+0x1a/0xa0 ... mlxsw_spectrum3 0000:07:00.0: Failed to migrate vregion mlxsw_spectrum3 0000:07:00.0: Failed to migrate vregion Fixes: f465261aa105 ("mlxsw: spectrum_acl: Implement common eRP core") Signed-off-by: Amit Cohen Signed-off-by: Ido Schimmel Signed-off-by: Petr Machata --- .../mellanox/mlxsw/spectrum_acl_erp.c | 8 +-- .../drivers/net/mlxsw/spectrum-2/tc_flower.sh | 52 ++++++++++++++++++- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c index 4c98950380d5..d231f4d2888b 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_erp.c @@ -301,6 +301,7 @@ mlxsw_sp_acl_erp_table_alloc(struct mlxsw_sp_acl_erp_core *erp_core, unsigned long *p_index) { unsigned int num_rows, entry_size; + unsigned long index; /* We only allow allocations of entire rows */ if (num_erps % erp_core->num_erp_banks != 0) @@ -309,10 +310,11 @@ mlxsw_sp_acl_erp_table_alloc(struct mlxsw_sp_acl_erp_core *erp_core, entry_size = erp_core->erpt_entries_size[region_type]; num_rows = num_erps / erp_core->num_erp_banks; - *p_index = gen_pool_alloc(erp_core->erp_tables, num_rows * entry_size); - if (*p_index == 0) + index = gen_pool_alloc(erp_core->erp_tables, num_rows * entry_size); + if (!index) return -ENOBUFS; - *p_index -= MLXSW_SP_ACL_ERP_GENALLOC_OFFSET; + + *p_index = index - MLXSW_SP_ACL_ERP_GENALLOC_OFFSET; return 0; } diff --git a/tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower.sh b/tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower.sh index fb850e0ec837..7bf56ea161e3 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower.sh @@ -10,7 +10,8 @@ lib_dir=$(dirname $0)/../../../../net/forwarding ALL_TESTS="single_mask_test identical_filters_test two_masks_test \ multiple_masks_test ctcam_edge_cases_test delta_simple_test \ delta_two_masks_one_key_test delta_simple_rehash_test \ - bloom_simple_test bloom_complex_test bloom_delta_test" + bloom_simple_test bloom_complex_test bloom_delta_test \ + max_erp_entries_test" NUM_NETIFS=2 source $lib_dir/lib.sh source $lib_dir/tc_common.sh @@ -983,6 +984,55 @@ bloom_delta_test() log_test "bloom delta test ($tcflags)" } +max_erp_entries_test() +{ + # The number of eRP entries is limited. Once the maximum number of eRPs + # has been reached, filters cannot be added. This test verifies that + # when this limit is reached, inserstion fails without crashing. + + RET=0 + + local num_masks=32 + local num_regions=15 + local chain_failed + local mask_failed + local ret + + if [[ "$tcflags" != "skip_sw" ]]; then + return 0; + fi + + for ((i=1; i < $num_regions; i++)); do + for ((j=$num_masks; j >= 0; j--)); do + tc filter add dev $h2 ingress chain $i protocol ip \ + pref $i handle $j flower $tcflags \ + dst_ip 192.1.0.0/$j &> /dev/null + ret=$? + + if [ $ret -ne 0 ]; then + chain_failed=$i + mask_failed=$j + break 2 + fi + done + done + + # We expect to exceed the maximum number of eRP entries, so that + # insertion eventually fails. Otherwise, the test should be adjusted to + # add more filters. + check_fail $ret "expected to exceed number of eRP entries" + + for ((; i >= 1; i--)); do + for ((j=0; j <= $num_masks; j++)); do + tc filter del dev $h2 ingress chain $i protocol ip \ + pref $i handle $j flower &> /dev/null + done + done + + log_test "max eRP entries test ($tcflags). " \ + "max chain $chain_failed, mask $mask_failed" +} + setup_prepare() { h1=${NETIFS[p1]} From patchwork Wed Jan 17 15:04:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13521872 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D618210F4 for ; Wed, 17 Jan 2024 15:05:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705503921; cv=fail; b=esZOt5Sm/3k5p5xFz0RhpcoRsh6t5TMDgY4vdyu5N/6nFa+ECdULEg+fXhh0yvgznD2njdv+TwDti7lk4M0ZOpju2Q0nI4pf6Ls3LvBOaKSkjwTgoPMctCnqMN016E/B3ZBL816KWHq3of/KNcgR+i85LP4Tl0AXvx7l6AzAOOY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705503921; c=relaxed/simple; bh=zUINnICJ4j3Qs+jgoTrvTfAFBmNd7ZgJdAFmcjTP4/E=; h=ARC-Message-Signature:ARC-Authentication-Results:DKIM-Signature: Received:Received:X-MS-Exchange-Authentication-Results: Received-SPF:Received:Received:Received:From:To:CC:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy:X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource: X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; b=Lmw9SFS1x++FGNaX/ixIrsWUoj4DnS5Ii/Uv/V2ll46RwYQ+ZKV07ULtgeWP6Cy4R5/GN0wGcoDYjh/2haG86UyDK+y0N5MHPes7NfhmogrIX04iU3KYYdD2NoHzh8jXpibVzs6dT/xc+pIN2YCQWnD/0wU7tP+sXWH7ee/LKRM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=XN2Mk4TA; arc=fail smtp.client-ip=40.107.236.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="XN2Mk4TA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GP2hmWqnd5sjD3XPmZFXw/MUa6etwWnTg8f4m8HEcU9ZYswtQpA6jFVhn3kbTvUjFcXwFf8WYU22mCoILe7Fad+hr5wzmm+zEszvMtB7TH5gWiTqWc3Ydd6B8fWEcySpRkAIzJ//nwP+//YHM9rgVKL2MB+QK8tcCzi8tTJy/6oec8vKTRfJvCYWwnpXCbKNVBX30LcHl7ZyGRbSc3up4vkmSrDj0wafinAu8ThhhIGPRilvHnFfEixaCH+WaRumlhlpfziWTrS+haYB1Zb/oswUaxvmYcVGIlbkQmQS86BGfSKSnrR/QqfsDlh5CiYkUrG6ty/d8Rkuo6CjRduajQ== 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=grp1A9s6Y34isnI3jlrgSFrlWxDA7/UeP7Y/+O14xUA=; b=fTwLxjysrUpJ8FRv8oyw9QM481SjkzG5KPNo1mYNrqLfSFKcaJtv1apNvgeYzKla85aDVsiiOJ8R6mlDMplsq09dEosoe1GDi3C8inwI00biJ1PZ0P7Jiu4TfvqzCRC3Y3zy0muiTxsnj6q1uvTcgzF7OH0RMT3dE6+YoL9SmwhcG6hIioB9vx4yysT79+LsqC9TDJRep5LycEKK/g0pbJQt84FMlDifEtbXeImWqF/JgYBUULwoyyRKps/M/V0kX3Vyrw9PZfpFPgogC7Sh60Oyo6ZEnrAB3EsuYhhKIFSBJ3cmQIXtU7UDUR1mu6kxumtK3SdSudwN2AgnzmHdBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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 (0) 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=grp1A9s6Y34isnI3jlrgSFrlWxDA7/UeP7Y/+O14xUA=; b=XN2Mk4TAvWzCN/d6xEnHeSG9TdaSd61wDx6d17MZOWMjSiAF6tKSBt8awI1u06XgWb2yFHPl/RrOBRxpJi6aVUBheJcDq81Acc/9ImN2+y5M0iO6q7yfN8RTApxbvfAclWbHhS2oed1gDv0qjIK8COXOUUIasp0kess0Vbl4mNSPKAh35CgUaQbzovwy5qnvfazA1RQT/30ZQIAiL7Dsu9nzf22cGg3hoEf7i0EeLGcRqFJRNNuqXqODSNj5DyTkYx5jy/NKSCvry0Dw39r9908M7tiS8NVKH7pc5woIhwpSkkGYMFlGB7zZHaQ6LyTDYSrwvm47zbKTDlAe6pdjVQ== Received: from CY5PR10CA0017.namprd10.prod.outlook.com (2603:10b6:930:1c::20) by CH3PR12MB8185.namprd12.prod.outlook.com (2603:10b6:610:123::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24; Wed, 17 Jan 2024 15:05:17 +0000 Received: from CY4PEPF0000EDD2.namprd03.prod.outlook.com (2603:10b6:930:1c:cafe::b3) by CY5PR10CA0017.outlook.office365.com (2603:10b6:930:1c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.23 via Frontend Transport; Wed, 17 Jan 2024 15:05:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CY4PEPF0000EDD2.mail.protection.outlook.com (10.167.241.206) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.16 via Frontend Transport; Wed, 17 Jan 2024 15:05:16 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 17 Jan 2024 07:04:59 -0800 Received: from yaviefel.vdiclient.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 17 Jan 2024 07:04:52 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Amit Cohen , "Jiri Pirko" , , Jiri Pirko Subject: [PATCH net 2/6] mlxsw: spectrum_acl_tcam: Fix NULL pointer dereference in error path Date: Wed, 17 Jan 2024 16:04:17 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD2:EE_|CH3PR12MB8185:EE_ X-MS-Office365-Filtering-Correlation-Id: 663249f9-5759-4044-7e45-08dc176db6e5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5CqykDZ8b09pK2oc2h0mVtFr07eLqD4ON4HQR7jM7gy/Kupf+oCF1N+G3dLTWne3EM6srZZlKKQsdasIABNmL1UFyiEKDnh7hBsUQGAJ8b2P3DTEL6g04OCSzql1jBtqwOGhnk+dRaTNInqS/0gmQnMi4lh9QrsLgZbQFoNu4Xu+oHUUQuctPGTNe8p+XuE4aQ+zBEm4s+dZi72NmOrXhtLiFnQsXvbhPT9QDzCLHBeza5lqksSaCYMmTRcfM9qFfcwaUDeodip4GH3epwttwuLYra73L1gltHA6AZw8shEi31/zCmH/yrvevhLafwoUWZrI6dPKeEE30icUzsRV3uIwdtAGDWDtO6Ty3zIxP/15nJBKN0mL9VVQh7M8GqgOf+yuyLAO702LX70pLaS5Uh99JFJZNn60Dpd/298wF8mVktMVWjl8xb8nO3GINtTHu8xv6W888Nq9jwpg8TYyE1QIHdk1U7D8h109/4lFLKq8/czC8lNmFSmKUc6D/7YQizfHym+nMdOJUMbvIocjcu0nEpsaU25XkCZ0Ny5GI+9umuLwgOQmyfDvPuABD5W1TKeQSPUjxzkKDtg42ccponw5fg6n6ZTLd7GFEU6QYXb7NecD27Pf2jCOrHfqTQ2KbXtNcrgbAHoqVCnZmxcmeFT41W9++RB0luXOndBus+FpVmaxbmB5IbI4hBW8e85RpcZiaVskooDYge3tzDqWYJNBF3jI0erOf4jUz49Zr+erO/Zixsy7yF/B8YeO1WL2 X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(136003)(39860400002)(346002)(396003)(376002)(230922051799003)(64100799003)(186009)(451199024)(82310400011)(1800799012)(36840700001)(46966006)(40470700004)(16526019)(356005)(36756003)(26005)(86362001)(478600001)(40460700003)(40480700001)(7636003)(2616005)(316002)(41300700001)(336012)(426003)(2906002)(107886003)(6666004)(7696005)(70586007)(70206006)(5660300002)(54906003)(83380400001)(110136005)(82740400003)(47076005)(4326008)(8676002)(8936002)(36860700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2024 15:05:16.6041 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 663249f9-5759-4044-7e45-08dc176db6e5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8185 X-Patchwork-Delegate: kuba@kernel.org From: Ido Schimmel When calling mlxsw_sp_acl_tcam_region_destroy() from an error path after failing to attach the region to an ACL group, we hit a NULL pointer dereference upon 'region->group->tcam' [1]. Fix by retrieving the 'tcam' pointer using mlxsw_sp_acl_to_tcam(). [1] BUG: kernel NULL pointer dereference, address: 0000000000000000 [...] RIP: 0010:mlxsw_sp_acl_tcam_region_destroy+0xa0/0xd0 [...] Call Trace: mlxsw_sp_acl_tcam_vchunk_get+0x88b/0xa20 mlxsw_sp_acl_tcam_ventry_add+0x25/0xe0 mlxsw_sp_acl_rule_add+0x47/0x240 mlxsw_sp_flower_replace+0x1a9/0x1d0 tc_setup_cb_add+0xdc/0x1c0 fl_hw_replace_filter+0x146/0x1f0 fl_change+0xc17/0x1360 tc_new_tfilter+0x472/0xb90 rtnetlink_rcv_msg+0x313/0x3b0 netlink_rcv_skb+0x58/0x100 netlink_unicast+0x244/0x390 netlink_sendmsg+0x1e4/0x440 ____sys_sendmsg+0x164/0x260 ___sys_sendmsg+0x9a/0xe0 __sys_sendmsg+0x7a/0xc0 do_syscall_64+0x40/0xe0 entry_SYSCALL_64_after_hwframe+0x63/0x6b Fixes: 22a677661f56 ("mlxsw: spectrum: Introduce ACL core with simple TCAM implementation") Signed-off-by: Ido Schimmel Reviewed-by: Amit Cohen Reviewed-by: Jiri Pirko Signed-off-by: Petr Machata --- drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c index d50786b0a6ce..7d1e91196e94 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c @@ -681,13 +681,13 @@ static void mlxsw_sp_acl_tcam_region_destroy(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_acl_tcam_region *region) { + struct mlxsw_sp_acl_tcam *tcam = mlxsw_sp_acl_to_tcam(mlxsw_sp->acl); const struct mlxsw_sp_acl_tcam_ops *ops = mlxsw_sp->acl_tcam_ops; ops->region_fini(mlxsw_sp, region->priv); mlxsw_sp_acl_tcam_region_disable(mlxsw_sp, region); mlxsw_sp_acl_tcam_region_free(mlxsw_sp, region); - mlxsw_sp_acl_tcam_region_id_put(region->group->tcam, - region->id); + mlxsw_sp_acl_tcam_region_id_put(tcam, region->id); kfree(region); } From patchwork Wed Jan 17 15:04:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13521873 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2083.outbound.protection.outlook.com [40.107.223.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09AA1200D8 for ; Wed, 17 Jan 2024 15:05:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705503928; cv=fail; b=VQDWN+qpS++1U1umcKXeaQNAruJEg4raNBK8wR8Pe4K+VmbeAuYSFEhYorUIX+8hA8aU5ZY0jMIfYs0G5id6dJvUhiTNQh9qyhjpzYeVlzeFXiAqc0j45vLGQT4OjXAtRqZw7qxcTdQBodME/K4vYtUNC0fiv4DLnVFH6ykWMgs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705503928; c=relaxed/simple; bh=fWAzbOYNP/ePVGd9P+4tw7/VsaAHnb87ZKuAIB1YuU0=; h=ARC-Message-Signature:ARC-Authentication-Results:DKIM-Signature: Received:Received:X-MS-Exchange-Authentication-Results: Received-SPF:Received:Received:Received:From:To:CC:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy:X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource: X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; b=dVFcM1hYDJmuZN/4WD4lKdVi2s+QMHvzfYxyXedZlebnZ6+MnkTqwWagEXioWLNjD23PN/ZSA3eITSO6lVn6K10/lFwBz/Zv4cwm5qep+joKwRuSeHJjZdyggZkghuq7JBAFzMsG2cQJPUWBPImAm31+Er75WOs8dw3rQzyN4VY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=CrohZNxs; arc=fail smtp.client-ip=40.107.223.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="CrohZNxs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R/1OgdBUWm//3wzlQN0RfGmU9tpdOOVQvVRf9e3SCf2Yj8n46HZfcnLv4UGr1/ky45Y66DWnsqIF7TLEXUUrOd/5saX79os4HDh3JUkWjRiE2U14hnkEL2LuODf45cy+BrW7GHsTN7sxRRYsetnguHKhD8OiwsJ/MM2KFrTcPg9TbllXY4x9W/7XBDL2zAqgqTc9UdeOkHlLFL0WELfwuLVDdI+u0jIqZnzC+Yy1u6WYmd4UDMdxWVDEU2IYqHxKtIxc+e5scV0tilYeYFk9HLYxp4bXXRMQdMM5TIy1r6RQwNo5fopOW0suMqIeuGViLtRGOfimyoh6tjcFyNxTVQ== 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=V/Gmm/Te6GfTLmfEqfHD9GC68uqHWmTqyK6LYoVJzdY=; b=DbHr7rxEGJZ/BMJa60vxsX2hFoiWz/e7GZCRwctBogRnfeqhMv79/Yx5Il7aMn6vc7hO0N3wwQ3D87IFtTro0mDzWl92zjAvNJiGZ2FT1u2jCZcmOF5OSnfCCmaW5USO5NZy8CsLdxza6JjWDEZiCwUs3bTw5fE0dQw9XqsrZI4lsjAf8etZqdgqOUQOxxkJ1mL+yBSX6TcZ8MS0QXpBY/FqlR9qR7G93remUVF/2zIYss7Dt653gNuuoHK28Su5cyJKNZJJQQhdcZt60spSgAsnK3ZXDHOAO/1dWUqs59mIVr90bWrUwmVP2OyRaTCXj9NFyF8Y0Zq4qAj6bOO3CA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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 (0) 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=V/Gmm/Te6GfTLmfEqfHD9GC68uqHWmTqyK6LYoVJzdY=; b=CrohZNxsw2sFmYGMaVviwv7CGUybI9l5c96+gb81CMmefohpJVTKy/9E2dcIQJPH2SEUjisTBGTaQ3P+g+DzGMNz14Xr5lnKX9DogdR5/+p2/EXCJbObwFl8HW+BsLa06ngOJO3pmuc3IBaR/eLF+O4QBvQMDYTyT1eBpAjMlN64u3DZPF/VtHOZ2vgxNPwRlX/sEDFZLYGYXKiGLQ+hW4wl+o4HcA3L0IGVBrUZqTm62YyRYspf+FYXsJDLylUv4AE9EdAjasaRqXR0vmseht4A7cVZysWpEpAMs9XaX9VWgSxChLkTi3T1t1XGDz4n1OAI9wk/Zj6H8928J+Wk4w== Received: from DM6PR07CA0115.namprd07.prod.outlook.com (2603:10b6:5:330::6) by SA1PR12MB5613.namprd12.prod.outlook.com (2603:10b6:806:22b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.23; Wed, 17 Jan 2024 15:05:23 +0000 Received: from CY4PEPF0000EDD1.namprd03.prod.outlook.com (2603:10b6:5:330:cafe::23) by DM6PR07CA0115.outlook.office365.com (2603:10b6:5:330::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24 via Frontend Transport; Wed, 17 Jan 2024 15:05:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CY4PEPF0000EDD1.mail.protection.outlook.com (10.167.241.205) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.16 via Frontend Transport; Wed, 17 Jan 2024 15:05:23 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 17 Jan 2024 07:05:04 -0800 Received: from yaviefel.vdiclient.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 17 Jan 2024 07:05:00 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Amit Cohen , "Jiri Pirko" , , Orel Hagag Subject: [PATCH net 3/6] mlxsw: spectrum_acl_tcam: Fix stack corruption Date: Wed, 17 Jan 2024 16:04:18 +0100 Message-ID: <2d91c89afba59c22587b444994ae419dbea8d876.1705502064.git.petrm@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD1:EE_|SA1PR12MB5613:EE_ X-MS-Office365-Filtering-Correlation-Id: a27e7d69-49cb-409b-b2c9-08dc176dbae5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EFLjU/UHyNybGge+2hHE1CuVH3UbhoPEw1dxxtraH0LKAR0lzt8EYh2W3798t9MB2BNxXzW0kv8v3Uez6evHjLAnAiJ0/Rbs6gjELr8lPNQBGerN4iQxLLzfm0fUG7zkbv9tamMQO9nstsBPB4jeCmA2RAiPqfEZY9NAJiHMFz4rDuaZyTzCqwzK5y45DQBqZ5NpyRhlhd7wiDJCMCtaeutByFBsnMui1s+Sr8w51Yem7XIAHstvhSqRjtmfeULVojjOhdb4DNJC8swGZthfhn/2aYEUmxQ+GDjNfW0Ws2++Ak6yZtJ/TLQlZwdG1dsaro4sJ43bRQvFH88zv0GzL96n+p9IKCQWHwdaO/aQbiXqu7oKWU6TJTD+gZCw/QlvRbDANoT1WwhXqs/yFK31GfbNXbyiGKtw7oihcz1VJ+Cj31uErus97zu5kDJbhxLVrofw2ki1qtYENYQw8kMGKPePKR0nyIyEOfaEUK7+11NFd9ol093kcbzyr3+WgjPv1nTnl7i6a2KzFzK+bqAbcZo1GC0L04UGktopdOoatYflg+VD/M9B9RftPIhxNbt9f8C0UG5l9yHXPQk+G0YRO5MmNc848CBMNr7rJer5nl+BSCWdK/OYGoWszZs2prRmRZtpfJvC2dCC80vo2ievqc/Z/j/vCzwI2EmYa4CDwcnlG3/sr1FxM5Chtt+RnowAbKBkLDXSSe7LQ3b12NLs6RKIohfDpTnr9tWQm27Lc2sCKpVtKw3+OOcApoh+BKZk X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(396003)(39860400002)(376002)(136003)(346002)(230922051799003)(186009)(82310400011)(64100799003)(451199024)(1800799012)(40470700004)(46966006)(36840700001)(40460700003)(40480700001)(26005)(6666004)(7696005)(107886003)(336012)(36860700001)(426003)(16526019)(2616005)(36756003)(86362001)(356005)(82740400003)(7636003)(8936002)(2906002)(41300700001)(4326008)(83380400001)(47076005)(5660300002)(316002)(478600001)(70586007)(8676002)(110136005)(70206006)(54906003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2024 15:05:23.3163 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a27e7d69-49cb-409b-b2c9-08dc176dbae5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5613 X-Patchwork-Delegate: kuba@kernel.org From: Ido Schimmel When tc filters are first added to a net device, the corresponding local port gets bound to an ACL group in the device. The group contains a list of ACLs. In turn, each ACL points to a different TCAM region where the filters are stored. During forwarding, the ACLs are sequentially evaluated until a match is found. One reason to place filters in different regions is when they are added with decreasing priorities and in an alternating order so that two consecutive filters can never fit in the same region because of their key usage. In Spectrum-2 and newer ASICs the firmware started to report that the maximum number of ACLs in a group is more than 16, but the layout of the register that configures ACL groups (PAGT) was not updated to account for that. It is therefore possible to hit stack corruption [1] in the rare case where more than 16 ACLs in a group are required. Fix by limiting the maximum ACL group size to the minimum between what the firmware reports and the maximum ACLs that fit in the PAGT register. Add a test case to make sure the machine does not crash when this condition is hit. [1] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: mlxsw_sp_acl_tcam_group_update+0x116/0x120 [...] dump_stack_lvl+0x36/0x50 panic+0x305/0x330 __stack_chk_fail+0x15/0x20 mlxsw_sp_acl_tcam_group_update+0x116/0x120 mlxsw_sp_acl_tcam_group_region_attach+0x69/0x110 mlxsw_sp_acl_tcam_vchunk_get+0x492/0xa20 mlxsw_sp_acl_tcam_ventry_add+0x25/0xe0 mlxsw_sp_acl_rule_add+0x47/0x240 mlxsw_sp_flower_replace+0x1a9/0x1d0 tc_setup_cb_add+0xdc/0x1c0 fl_hw_replace_filter+0x146/0x1f0 fl_change+0xc17/0x1360 tc_new_tfilter+0x472/0xb90 rtnetlink_rcv_msg+0x313/0x3b0 netlink_rcv_skb+0x58/0x100 netlink_unicast+0x244/0x390 netlink_sendmsg+0x1e4/0x440 ____sys_sendmsg+0x164/0x260 ___sys_sendmsg+0x9a/0xe0 __sys_sendmsg+0x7a/0xc0 do_syscall_64+0x40/0xe0 entry_SYSCALL_64_after_hwframe+0x63/0x6b Fixes: c3ab435466d5 ("mlxsw: spectrum: Extend to support Spectrum-2 ASIC") Reported-by: Orel Hagag Signed-off-by: Ido Schimmel Reviewed-by: Amit Cohen Signed-off-by: Petr Machata --- .../mellanox/mlxsw/spectrum_acl_tcam.c | 2 + .../drivers/net/mlxsw/spectrum-2/tc_flower.sh | 56 ++++++++++++++++++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c index 7d1e91196e94..50ea1eff02b2 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c @@ -1564,6 +1564,8 @@ int mlxsw_sp_acl_tcam_init(struct mlxsw_sp *mlxsw_sp, tcam->max_groups = max_groups; tcam->max_group_size = MLXSW_CORE_RES_GET(mlxsw_sp->core, ACL_MAX_GROUP_SIZE); + tcam->max_group_size = min_t(unsigned int, tcam->max_group_size, + MLXSW_REG_PAGT_ACL_MAX_NUM); err = ops->init(mlxsw_sp, tcam->priv, tcam); if (err) diff --git a/tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower.sh b/tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower.sh index 7bf56ea161e3..616d3581419c 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower.sh @@ -11,7 +11,7 @@ ALL_TESTS="single_mask_test identical_filters_test two_masks_test \ multiple_masks_test ctcam_edge_cases_test delta_simple_test \ delta_two_masks_one_key_test delta_simple_rehash_test \ bloom_simple_test bloom_complex_test bloom_delta_test \ - max_erp_entries_test" + max_erp_entries_test max_group_size_test" NUM_NETIFS=2 source $lib_dir/lib.sh source $lib_dir/tc_common.sh @@ -1033,6 +1033,60 @@ max_erp_entries_test() "max chain $chain_failed, mask $mask_failed" } +max_group_size_test() +{ + # The number of ACLs in an ACL group is limited. Once the maximum + # number of ACLs has been reached, filters cannot be added. This test + # verifies that when this limit is reached, insertion fails without + # crashing. + + RET=0 + + local num_acls=32 + local max_size + local ret + + if [[ "$tcflags" != "skip_sw" ]]; then + return 0; + fi + + for ((i=1; i < $num_acls; i++)); do + if [[ $(( i % 2 )) == 1 ]]; then + tc filter add dev $h2 ingress pref $i proto ipv4 \ + flower $tcflags dst_ip 198.51.100.1/32 \ + ip_proto tcp tcp_flags 0x01/0x01 \ + action drop &> /dev/null + else + tc filter add dev $h2 ingress pref $i proto ipv6 \ + flower $tcflags dst_ip 2001:db8:1::1/128 \ + action drop &> /dev/null + fi + + ret=$? + [[ $ret -ne 0 ]] && max_size=$((i - 1)) && break + done + + # We expect to exceed the maximum number of ACLs in a group, so that + # insertion eventually fails. Otherwise, the test should be adjusted to + # add more filters. + check_fail $ret "expected to exceed number of ACLs in a group" + + for ((; i >= 1; i--)); do + if [[ $(( i % 2 )) == 1 ]]; then + tc filter del dev $h2 ingress pref $i proto ipv4 \ + flower $tcflags dst_ip 198.51.100.1/32 \ + ip_proto tcp tcp_flags 0x01/0x01 \ + action drop &> /dev/null + else + tc filter del dev $h2 ingress pref $i proto ipv6 \ + flower $tcflags dst_ip 2001:db8:1::1/128 \ + action drop &> /dev/null + fi + done + + log_test "max ACL group size test ($tcflags). max size $max_size" +} + setup_prepare() { h1=${NETIFS[p1]} From patchwork Wed Jan 17 15:04:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13521874 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2050.outbound.protection.outlook.com [40.107.223.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C441C1F602 for ; Wed, 17 Jan 2024 15:05:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705503938; cv=fail; b=EKdkrR4bKAcnqmd7osYRYOdAskI3dxAQ+l8y30uIl0k47A2kzDfxDjxHjUv1ZXSVzaH+PyG61DXroe1QaRBDt5q1BXCKEQk8LafH7PDj3+TU4sNB1DOuH7SG4aKHwRgzmU9y4GU9TVNnRydZGgbUdb5H3vPidtJgBFzf34hMDbA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705503938; c=relaxed/simple; bh=qDKF9fKWKXG56CEBrp2xaIW6oTi3j2obXyJoV+yx574=; h=ARC-Message-Signature:ARC-Authentication-Results:DKIM-Signature: Received:Received:X-MS-Exchange-Authentication-Results: Received-SPF:Received:Received:Received:From:To:CC:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy:X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource: X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; b=jx7tu7ZxZntEESxcdztu5wcuOw7UOCaoLXjkPJ/alzjvorWwTFd1L97s4QJoTc6uvMO7dpPEdGuEuaQ1MXyDvWzMCts8Yy2gBZCdlH4XzbAA+ZkTlhgwoLDDUSfhVHpsY+4zymqS3M9yHZ2ZGsX41CTVzIH0mOPp54u3XcDpLjw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=FDHIq6U9; arc=fail smtp.client-ip=40.107.223.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="FDHIq6U9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C/T1mdoP8z8wf8Dr9QBFVU8khFIYDx0nO8ijCWKVIaXs1kZH/9SMI1vAhb4Kt0SNn87kY+5Wre/yDSQzZhXecmgKiQfCMYlc2OwpD6l7sXGyzyoyZsAop12MKVWzXk8IStAGz0/trLNotlV2zBw91E0myACg5FzeebIWBHx+dT9z4a3rzmHeLzQ8IMKNU0xX+njfQxf81K7sJUCsiC88ZvxFSVHa5OrEmlNSGgBPCOX0WnWeEShmU+09PvwyhzlFUZ9LrHNK6MMEQL+rpySdfuQG2J9wwG0UxMsW14hqobws8FQiwLLpfnIO+S6HBw06SYbh22r25LqVSICAFLzneg== 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=SevkloSzkgc8QFqNbvWsXuQqdl/t0+q7j1ThfO8oEw4=; b=dMhm2AClRLDlvU4N9m4LHglgOMueS5Qz8Gs3z7DR7PRJIRy22Yl3AmWnoEEFQQkrbg1N8ntq8s45jvbwWy3Y3gBfFW+zjE3JEk9CWDDWa0i44d+/lgujR5c0+8o8gbJ24gyaROVvAd1v3oIdIljhEt8pDZOddxSb/+JWb5QSaML/J9SMzCX82XYIhGX1yLums7Ys1t0uPwz2WdRAC1NCAWCOOUsj2j9eyEFij/GHKUK8ge7fJ20JfeBIC//xY7kUB0vo0U8SeDUIc7OvHgwZN/hNscWFm//fzAlU3YjOioymp2/4O/+rqUYO1x18Wx11WIav22jZeF+DzYY8pr/FcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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 (0) 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=SevkloSzkgc8QFqNbvWsXuQqdl/t0+q7j1ThfO8oEw4=; b=FDHIq6U9tiKP3zdGVwS7rrpx8sxjremCUm2jk2bNTjqhXiaqz3I3wLTiFErdHmRwnn7zPHB3H990Pr7PKL+fyZRCzLD0p7MwoeghwDoRHW9HqDd2vExIEclQE+6GoXuuv+VkrSEizo77dWGuxpnsvEhQ0dbZoc9WCufDwyfyhWCRttr3mjb2RErSpInmwLeIolkgDslpfVeEwFSIQadGj0nO2OUBvQTOz47hSSrpO8ae/gA/A/WI+MNp1aUYF2pqq2sjUq7fwp2Aa/0Mq5rKrz1Ug0GFKut5qydUlE1Y5zlL5zkpzaUsdNphPAVNz2VxgYw2XaSF0cBQ5zJ11egt/g== Received: from PA7P264CA0245.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:371::6) by DM4PR12MB5215.namprd12.prod.outlook.com (2603:10b6:5:397::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24; Wed, 17 Jan 2024 15:05:32 +0000 Received: from SN1PEPF0002636D.namprd02.prod.outlook.com (2603:10a6:102:371:cafe::38) by PA7P264CA0245.outlook.office365.com (2603:10a6:102:371::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.23 via Frontend Transport; Wed, 17 Jan 2024 15:05:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SN1PEPF0002636D.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.16 via Frontend Transport; Wed, 17 Jan 2024 15:05:30 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 17 Jan 2024 07:05:09 -0800 Received: from yaviefel.vdiclient.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 17 Jan 2024 07:05:05 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Amit Cohen , "Jiri Pirko" , , Maksym Yaremchuk Subject: [PATCH net 4/6] mlxsw: spectrum_router: Register netdevice notifier before nexthop Date: Wed, 17 Jan 2024 16:04:19 +0100 Message-ID: <74edb8d45d004e8d8f5318eede6ccc3d786d8ba9.1705502064.git.petrm@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636D:EE_|DM4PR12MB5215:EE_ X-MS-Office365-Filtering-Correlation-Id: 54e381cd-eb9a-4388-ca38-08dc176dbf7b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HcD5IcxcCmOmvi+TDJOag5L3v6Fl/LEkZXYmwDbn4XbwNPKRYJHycagy6SwlFk+7iYalybhC7jH4+KhqYzZgHbcwW/xWMd2k0mG8XgN5iXmihKY4V3absaQImXhAHADCs4dLVCNjnPuXfaGX3T6dAUDsd/MeymjhE34zrjx9SQYnD9QLp4bF2t4omE0fN8ptnbAtwhPDUtTiXyKq+Jlp9cGMtsTvmYBXG+mvrGYCY6Q1jv6N+k6Z526IH7LQtzdrIr2sQQjH80l/MMoOonhb1N7zY8pLst5G9lWCBdPKEeon9774TlzHtNDsS1hs4L8zdm7CRhiQqUOuIj/QzkvG9l+LJcsLPGrOGRMYfVHI8EtRAEjTNTH+sjF+K0M++BKxrfk2gzSeOEhGPmJ7UpLY4gKCnUTOgoCZ5LJ3SHaQAPWnGWgPAzyxqGjH6xECh7AgSqqxfKzKC7xovH9i5h73xjH+1BvWzzxRKeb0IV+HhJ25+ytWzL70R5UJv3wIBv8onfceolaCF7n05e74PlAgU5qvNSFmq4Z0yOTLaWYj0CNPPK315ucpxMRMSxQezhs4mYxat5gF/5Pcm48L/OOtB6piGpcSRMQk62KIzitENEfK/xpqCsm86bApoNRma1XWOBjfK2PCX40ybbw03UXK/MKuW+CKZ4LIfYN5fMLRSSvviEN8nY5CviQotqj5SL9JPCDDj5axpxSLiDVWUWlPWJ4vPZ2o3k/Ab0ee82hq3/CGKeFOuudoXATNQeyH4LhcvQnFPvp2m4EUjCCV+vn/rg== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(376002)(136003)(346002)(39860400002)(396003)(230173577357003)(230273577357003)(230922051799003)(82310400011)(1800799012)(451199024)(64100799003)(186009)(36840700001)(40470700004)(46966006)(4326008)(8936002)(426003)(2616005)(336012)(26005)(54906003)(110136005)(70586007)(70206006)(5660300002)(2906002)(66574015)(16526019)(107886003)(86362001)(36756003)(316002)(8676002)(478600001)(6666004)(7696005)(40480700001)(40460700003)(41300700001)(7636003)(356005)(82740400003)(83380400001)(47076005)(36860700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2024 15:05:30.9796 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54e381cd-eb9a-4388-ca38-08dc176dbf7b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5215 X-Patchwork-Delegate: kuba@kernel.org If there are IPIP nexthops at the time when the driver is loaded (or the devlink instance reloaded), the driver looks up the corresponding IPIP entry. But IPIP entries are only created as a result of netdevice notifications. Since the netdevice notifier is registered after the nexthop notifier, mlxsw_sp_nexthop_type_init() never finds the IPIP entry, registers the nexthop MLXSW_SP_NEXTHOP_TYPE_ETH, and fails to assign a CRIF to the nexthop. Later on when the CRIF is necessary, the WARN_ON in mlxsw_sp_nexthop_rif() triggers, causing the splat [1]. In order to fix the issue, reorder the netdevice notifier to be registered before the nexthop one. [1] (edited for clarity): WARNING: CPU: 1 PID: 1364 at drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:3245 mlxsw_sp_nexthop_rif (drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:3246 (discriminator 1)) mlxsw_spectrum Hardware name: Mellanox Technologies Ltd. MSN4410/VMOD0010, BIOS 5.11 01/06/2019 Call Trace: ? mlxsw_sp_nexthop_rif (drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:3246 (discriminator 1)) mlxsw_spectrum __mlxsw_sp_nexthop_eth_update (drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:3637) mlxsw_spectrum mlxsw_sp_nexthop_update (drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:3679 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:3727) mlxsw_spectrum mlxsw_sp_nexthop_group_update (drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:3757) mlxsw_spectrum mlxsw_sp_nexthop_group_refresh (drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:4112) mlxsw_spectrum mlxsw_sp_nexthop_obj_event (drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:5118 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:5191 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:5315 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:5500) mlxsw_spectrum nexthops_dump (net/ipv4/nexthop.c:217 net/ipv4/nexthop.c:440 net/ipv4/nexthop.c:3609) register_nexthop_notifier (net/ipv4/nexthop.c:3624) mlxsw_sp_router_init (drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:11486) mlxsw_spectrum mlxsw_sp_init (drivers/net/ethernet/mellanox/mlxsw/spectrum.c:3267) mlxsw_spectrum __mlxsw_core_bus_device_register (drivers/net/ethernet/mellanox/mlxsw/core.c:2202) mlxsw_core mlxsw_devlink_core_bus_device_reload_up (drivers/net/ethernet/mellanox/mlxsw/core.c:2265 drivers/net/ethernet/mellanox/mlxsw/core.c:1603) mlxsw_core devlink_reload (net/devlink/dev.c:314 net/devlink/dev.c:475) [...] Fixes: 9464a3d68ea9 ("mlxsw: spectrum_router: Track next hops at CRIFs") Reported-by: Maksym Yaremchuk Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- .../ethernet/mellanox/mlxsw/spectrum_router.c | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 2c255ed9b8a9..7164f9e6370f 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -11472,6 +11472,13 @@ int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp, if (err) goto err_register_netevent_notifier; + mlxsw_sp->router->netdevice_nb.notifier_call = + mlxsw_sp_router_netdevice_event; + err = register_netdevice_notifier_net(mlxsw_sp_net(mlxsw_sp), + &mlxsw_sp->router->netdevice_nb); + if (err) + goto err_register_netdev_notifier; + mlxsw_sp->router->nexthop_nb.notifier_call = mlxsw_sp_nexthop_obj_event; err = register_nexthop_notifier(mlxsw_sp_net(mlxsw_sp), @@ -11487,22 +11494,15 @@ int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp, if (err) goto err_register_fib_notifier; - mlxsw_sp->router->netdevice_nb.notifier_call = - mlxsw_sp_router_netdevice_event; - err = register_netdevice_notifier_net(mlxsw_sp_net(mlxsw_sp), - &mlxsw_sp->router->netdevice_nb); - if (err) - goto err_register_netdev_notifier; - return 0; -err_register_netdev_notifier: - unregister_fib_notifier(mlxsw_sp_net(mlxsw_sp), - &mlxsw_sp->router->fib_nb); err_register_fib_notifier: unregister_nexthop_notifier(mlxsw_sp_net(mlxsw_sp), &mlxsw_sp->router->nexthop_nb); err_register_nexthop_notifier: + unregister_netdevice_notifier_net(mlxsw_sp_net(mlxsw_sp), + &router->netdevice_nb); +err_register_netdev_notifier: unregister_netevent_notifier(&mlxsw_sp->router->netevent_nb); err_register_netevent_notifier: unregister_inet6addr_validator_notifier(&router->inet6addr_valid_nb); @@ -11550,11 +11550,11 @@ void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp) { struct mlxsw_sp_router *router = mlxsw_sp->router; - unregister_netdevice_notifier_net(mlxsw_sp_net(mlxsw_sp), - &router->netdevice_nb); unregister_fib_notifier(mlxsw_sp_net(mlxsw_sp), &router->fib_nb); unregister_nexthop_notifier(mlxsw_sp_net(mlxsw_sp), &router->nexthop_nb); + unregister_netdevice_notifier_net(mlxsw_sp_net(mlxsw_sp), + &router->netdevice_nb); unregister_netevent_notifier(&router->netevent_nb); unregister_inet6addr_validator_notifier(&router->inet6addr_valid_nb); unregister_inetaddr_validator_notifier(&router->inetaddr_valid_nb); From patchwork Wed Jan 17 15:04:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13521875 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E82421118; Wed, 17 Jan 2024 15:05:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705503944; cv=fail; b=kA0URNCYObDmGflWSC7K+GYtva1JWOxLCISLrWJMwkGCjP8F/UKo6Qu5K3b35abBQYmvvyfxKdFkrUr8pKtE3iLUHMp+EvkxxIu3aQJbIproRgX1Lem+cYx2+hPwIqqc0KOuvhh3BaatxLDarh58UtKDJQ25kOGkHSVq5gMZccY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705503944; c=relaxed/simple; bh=WMfjTjMwL7H27ofDAeTjbVZ2XAF6ytriF06T28C3WRg=; h=ARC-Message-Signature:ARC-Authentication-Results:DKIM-Signature: Received:Received:X-MS-Exchange-Authentication-Results: Received-SPF:Received:Received:Received:From:To:CC:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy:X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource: X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; b=q/o99Cz5T6zXmTvXTEGCT1bJvwa7eDAKnWstydAfPBHUFBGSDCK1R02oWSRGtkhCB2zGZpsfZ9vfPtl1vGnirRG/BxYkhl+2CCvFZtcY+uWG/A+UoXOtnF1k64z4ka+mXQdwwgLoehnb64WeisEGsjLFALGUQG6gxzm42HnuvXQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=IZakDPCg; arc=fail smtp.client-ip=40.107.236.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="IZakDPCg" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EptxNnyrJpTNsITCdNEr22B8DjoRJFbPtT/tPCYNZsYHwFzbv0b7VXKhAr/7OfXPIzGjfg+AxklGNJJmsu8PXTZ/gJWJ2yBNZFDUE6XKz2cz+zqR4C1mFaWDtZDRmDkjHdnzHbknrbPpUvadlcxe7/Lj+SFlNSiaTNSdk26yUfz1ybqDcsOwm7ryqaa0xoHi7Q6MEelV0AvRWfdgANQIQKlpCTv31fNXnC5qPrqpif2nLpG/vvN1AmIwMRmVyY91AhQRDFZmzzIlR1DOBbisGrx8N0qBeLrzkhliR0fCxlMAxil1VL6UfdhsqtGKep7jy8dMCLz1+JHROTyaYKLDLg== 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=KT+lDRneeybLpA8vH/YNgOJ3I7raKjOsdrzyZ1BPKJI=; b=jdSUBpJm1+Y2AuefVEFCSxtuwNlZoPIC09mJl+ONZDQavfekJtlSbivYNyUAs+EvWnnAe8O7eY6VAvfSivUItaUFANDMvY+gU2UgL6CEYHxTEFEz1J3tJPA92MXRZtlPsdyhRnJynj2Eyd4GVD12xcbmv+VpO5OfJdEkePNOB39mr/dlQRuJhHQAt6JjCXmslSbY64U511ueTo5iEg1AI+Qh7OFID9ZmTXLwsAAaILtcPpvWwBOnbixFxwI2M1rbc5vNKBY0N22/d8w7EOm3S2RQLcjM1aoFty57aZllw3WRZpFhovEvvIHYo+2wHErG15NLnuqsv2W2RjGbuV7Udg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net 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 (0) 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=KT+lDRneeybLpA8vH/YNgOJ3I7raKjOsdrzyZ1BPKJI=; b=IZakDPCguvwCCcgPkK0kx0UTHXALXpyGW+H0cJCpMbVwHyF85F0kIuUXSuH/qehHRScl6HP2cNDvqQAlnY6K/7wtMnfbJhfsPBOTrbat/hMbtg8a+38S1U0q0w4n/GSuKwXvuSozsCNndBY0fhtnlOxDT7V0A+ucwZNfbHgc3PCeTgIRVSfoPQQvL1A2huVWL+iP7u8Ep/xrf7U3dMUb5UTjUNNRPcmH1YoozTo1znHzhDCYbARjotJZYU7kFv+wSXilDkpCvtA5Kl+ye0b09jMjNb5g3qoVVBxhaWX8NQZrE9cukvO6cPT6uESnrrCXU3HNrw8Qvpf708iDS3T+2w== Received: from SA1P222CA0042.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:2d0::16) by SA1PR12MB7151.namprd12.prod.outlook.com (2603:10b6:806:2b1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.23; Wed, 17 Jan 2024 15:05:39 +0000 Received: from SN1PEPF0002636C.namprd02.prod.outlook.com (2603:10b6:806:2d0:cafe::d) by SA1P222CA0042.outlook.office365.com (2603:10b6:806:2d0::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.24 via Frontend Transport; Wed, 17 Jan 2024 15:05:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SN1PEPF0002636C.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.16 via Frontend Transport; Wed, 17 Jan 2024 15:05:37 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 17 Jan 2024 07:05:15 -0800 Received: from yaviefel.vdiclient.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 17 Jan 2024 07:05:10 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Amit Cohen , "Jiri Pirko" , , Shuah Khan , Subject: [PATCH net 5/6] selftests: mlxsw: qos_pfc: Remove wrong description Date: Wed, 17 Jan 2024 16:04:20 +0100 Message-ID: <0087e2d416aff7e444d15f7c2958fc1d438dc27e.1705502064.git.petrm@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636C:EE_|SA1PR12MB7151:EE_ X-MS-Office365-Filtering-Correlation-Id: 8db216f5-27e3-4b0d-ea98-08dc176dc34d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XfJPiae3KyTeu8rYRSFeqQbmq0tqPluQswGsGb//yUS0NCk7fcyBfBGgbXsbMfhsIVTZspF/47+/87oWXSxy9AddVynOJlu8b/HK1yzkuEa57pyzrMy3qCj5BBcq6uiY4ikb5kDmLumWIQfN8k6bF5OT4ZmKabTAx8AKczmHYvbc8n+wbXPuqjFh+J8YbKuwbU5lARQSCwToPuk4nsoSGhMESC26HCNZy9w2GFEoia/fwc0F5yWjB2QQL5mjC/6P81+hK9fFLvMxZSEGB+Zcus+z6iUcyJj7o32mziAP4qS3f0PooPW4SXAKo7Mo1RWNkG17QCyEmnXxLMRrpLP35YTcflpM+S4tBa8NssTy/upjnBQqdOhweWGH+1MBN5lh/rQzVskCjM3aqbca342Oom/54gfNBhPg1jSmbyfN/3oOVpiJs4q+pevh6CBIHOu2nLVPbZH8Nz4s2VHniUg7OOQAv8HzCbEnfwXIyHWUTxhRMJsRRhfHOz9KQa1s7mkIKU+PGJgDNH7gpgtDcWQ+gmT8PLxCNrt81J9qjsy/vzxlaJP+l8RdvrKzzfxNW1GvEts7JHDS5B0PauohCHlUsFj+UTfCdiqJyW3uUG3sBUkcA2qPLzuDh98f5mXcu/2K3nreddUeQ0z1YwklTL7sEw0hMHuFm5lGtGhzWBggbDej3W63Xhkd8Wwp70x0FsK/ZJly3KZUESq+UvwKTpborVU5Bh5JEzbGWO2H3Ocw9RHQeLjaKEAMyiHtfem6Mzy7 X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(376002)(136003)(396003)(346002)(230922051799003)(186009)(64100799003)(451199024)(82310400011)(1800799012)(40470700004)(36840700001)(46966006)(41300700001)(82740400003)(47076005)(83380400001)(36860700001)(36756003)(86362001)(356005)(7636003)(110136005)(70586007)(316002)(54906003)(8936002)(2906002)(4326008)(8676002)(5660300002)(16526019)(2616005)(336012)(426003)(26005)(70206006)(478600001)(6666004)(40460700003)(40480700001)(7696005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2024 15:05:37.3899 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8db216f5-27e3-4b0d-ea98-08dc176dc34d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7151 X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen In the diagram of the topology, $swp3 and $swp4 are described as 1Gbps ports. This is wrong information, the test does not configure such speed. Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Fixes: bfa804784e32 ("selftests: mlxsw: Add a PFC test") Signed-off-by: Amit Cohen Reviewed-by: Ido Schimmel Signed-off-by: Petr Machata --- tools/testing/selftests/drivers/net/mlxsw/qos_pfc.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_pfc.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_pfc.sh index 42ce602d8d49..49bef76083b8 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/qos_pfc.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/qos_pfc.sh @@ -40,7 +40,6 @@ # | + $swp1 $swp3 + + $swp4 | # | | iPOOL1 iPOOL0 | | iPOOL2 | # | | ePOOL4 ePOOL5 | | ePOOL4 | -# | | 1Gbps | | 1Gbps | # | | PFC:enabled=1 | | PFC:enabled=1 | # | +-|----------------------|-+ +-|------------------------+ | # | | + $swp1.111 $swp3.111 + | | + $swp4.111 | | From patchwork Wed Jan 17 15:04:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13521876 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2074.outbound.protection.outlook.com [40.107.244.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8031220DD9; Wed, 17 Jan 2024 15:05:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705503954; cv=fail; b=KCCZPt13tCknEXhNo8gXtQFeHxn8RgnUwfxrHOY0XJwg8uRDxPqv2WWVjcp9mOrM5nabLGHPlQRraMr5ZoQ1AysIs3gD3abAwwlv1RnWaU6DG93jRUQYHWWJ0MjK2G6vCgHYmKzwE8/mhE0F51PPSUYeVlcnVT3oQZB8q2E2s7E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705503954; c=relaxed/simple; bh=GgSwrFtJrTYot7ZpgRCJNi9bnD1HUCv4GzPEo/mcWLg=; h=ARC-Message-Signature:ARC-Authentication-Results:DKIM-Signature: Received:Received:X-MS-Exchange-Authentication-Results: Received-SPF:Received:Received:Received:From:To:CC:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy:X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource: X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; b=iC+iLKKeNRBoMKQH8obPPw/Pk0MFiyMGCFEXoFmd8I0VfGJ2guj62sI1CSiMcIcMa779+Vx+Cb79Ce26pCCZdMGIIt3cry/OO9c795tu+NJQlFGXOem3B3N19XHdB3X/kd3gDnVvwxVe00v/EBqOcVPKd6ed3SBdvSQXFDw3ilI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=hrOBWr54; arc=fail smtp.client-ip=40.107.244.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="hrOBWr54" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z9CxKDeOrX5ETt3FBPS7tx2J9Pp9/T9jGGo4hTJJxUROZreD1xIxMH7u3R70miRgUoi+zEM37s3SDp8buiF/Of8mK/2YtbZQnRxvHoc4VDTiHGPxofuK3juMKjH6vgpVYQPbcl9gMJd47dCoqzFLN7xd7ooUE1eSC3CsmxqSlF/UCKzNCm0wpLsLtBPbvm0g5ZlWOG8YHbPUiydhMmLzas8nS0UjHTQc7fHhY2AaZT509H7WqKGy6g6bNcdkyBIJZkiPV/oEJCcM6+tenXJIvXs6OCf++EZ9VgCfn9VwWpzXnXnhgu/5QDi8DRh7MGVecWnL1pwrrtS4+zAhkogsdA== 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=dqQQUfeOr20GLsiO1xqvRI4+QuBU/PlOhiGjUuQi1XM=; b=a6sc/YHprUR24qJfedNBG66Dx1n5uz5VbxdiosRYmUh+ECot2BpIHZhWas5f518au+FAD5hjZM73Cyhu1L5dk2agHL6LpI1vj0u5McaBR4LmBT00aRykbGwDkMsTZtWx2IlvAIvAtzC8jC4VVsdQHhmFT6LxZiiyFlKeDxJ4MJcPubbjoBVLA5XvRn6QSIRJRUffy2Vn5s+tU0t6to5P2hat/xNmfTY6mZ7OOGR1UPbDFkUZVB7DvIxCf68L0xfoRfG36g4muVWgFTyn+T9sCtRKlg9EnKWwj8ZW5mw9A3V+NbDR/Gt1/CzeziLItYxqiP/CYfLnR4Sb6fiYnXzEmg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net 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 (0) 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=dqQQUfeOr20GLsiO1xqvRI4+QuBU/PlOhiGjUuQi1XM=; b=hrOBWr54ejndwc5Xujhy5dJpPCMdfhhQfIlbkhZQAz9S7n0xJ1Qt0X9iy/Lj5gPpeHAeo5YD3GoJEzT+06Cm912LKYuZAyYp48iUATtfI7SRWNScffhXqdchA0QPXfItogLag8TA8JfDx4s8bpcwJPTGsnJ77t1vVAHHz96zpxCCy3x5A1jT0011znLnUNZwl6AwMM9+AtlIyQLNVlwdmQ5AjUJn0Rg+OVV1AG4VWivUgaLYjibs+KCjogBa5uPUQXPromFE5HOBQ7zgKp+RR2Z7EytckunIaOqeZmXfs/YAETgeTXLk7KatO8TZOynOxxP2cu0VvfjGMbERLslQPw== Received: from BYAPR03CA0029.namprd03.prod.outlook.com (2603:10b6:a02:a8::42) by SJ1PR12MB6169.namprd12.prod.outlook.com (2603:10b6:a03:45c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.26; Wed, 17 Jan 2024 15:05:50 +0000 Received: from DS3PEPF000099DD.namprd04.prod.outlook.com (2603:10b6:a02:a8:cafe::71) by BYAPR03CA0029.outlook.office365.com (2603:10b6:a02:a8::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.23 via Frontend Transport; Wed, 17 Jan 2024 15:05:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS3PEPF000099DD.mail.protection.outlook.com (10.167.17.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.16 via Frontend Transport; Wed, 17 Jan 2024 15:05:49 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 17 Jan 2024 07:05:20 -0800 Received: from yaviefel.vdiclient.nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 17 Jan 2024 07:05:16 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , Danielle Ratson , Amit Cohen , "Jiri Pirko" , , Shuah Khan , Subject: [PATCH net 6/6] selftests: mlxsw: qos_pfc: Adjust the test to support 8 lanes Date: Wed, 17 Jan 2024 16:04:21 +0100 Message-ID: <23ff11b7dff031eb04a41c0f5254a2b636cd8ebb.1705502064.git.petrm@nvidia.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DD:EE_|SJ1PR12MB6169:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b5f2255-c4fd-4c49-fb61-08dc176dca9b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c0Zw7pOqNkOBZrqqEGh/L9Ts9ZyHfUgfPB0+ck5JrEH2RGi8D6DWlNSH3bV7qc+9u/8V3MErL1obWBKWjU5tDgPWwJsl4smz1lT2I8ZiB5cT3XuGwUBGkYi2m5N2u2KcS4y5kcmCWB7b4pKCYIm07htM7Vn2AzLhkfi3ADrJT+Zkn+GN9LzzBMRAjha/s4KI4hgSgq1IVZvVqgw2ZSzDfRSVVHLdUShTGj5AfRFK52FWzIz+SYf7LB62YgoitplHrN1ocuUNH51r3577fp7Y4H4jmwYBchT2WAayTHPQ2/zudCcOqh1YNvkzfBK9urG0Zu7U8J5ArSuydCt59KsQfBXibU4HHvMwpitkPXYK/ZvaQUYl02zlVd7yrlD2Eeii8XWger4qktlr4DcndCX2ZrQxZh6QJ10Bq94nJhm73zFaWskpTw8QAGDY9AF0p+SAIdrtIEvPGuTjcTCDhFq8F4INGtOVBu6celnC1MMSNSc+E/bFzEoIVATQxfARwLvZXx5Ra7Wi8IymLDcnu5Gs6avMHQ0epSJTVljfoRv2tV7HnnncklHrPymnvoLK5SX6jydaml+WV62B0X1rg1ZSiO/hCwCLz2Q0647cfcYugw5P469Ti2qjj+LqRRp6CIDNI2VCGW8vThfNY7dMLq88wNxiRuOaMygiKLCiy1j4lRwNDYDzWImgnQ5GbX3edCYMYSyl3ologVm9RNBP/QAQqLPth4THpu9clwYfCfFcOsmDVeTT12cG0y6GHocV6QhB X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(376002)(136003)(39860400002)(346002)(396003)(230922051799003)(82310400011)(1800799012)(64100799003)(451199024)(186009)(36840700001)(46966006)(40470700004)(7696005)(6666004)(16526019)(426003)(356005)(336012)(26005)(5660300002)(83380400001)(4326008)(8936002)(41300700001)(47076005)(8676002)(110136005)(54906003)(70586007)(478600001)(316002)(2906002)(70206006)(7636003)(36756003)(82740400003)(86362001)(36860700001)(2616005)(40480700001)(40460700003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2024 15:05:49.6455 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1b5f2255-c4fd-4c49-fb61-08dc176dca9b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DD.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6169 X-Patchwork-Delegate: kuba@kernel.org From: Amit Cohen 'qos_pfc' test checks PFC behavior. The idea is to limit the traffic using a shaper somewhere in the flow of the packets. In this area, the buffer is smaller than the buffer at the beginning of the flow, so it fills up until there is no more space left. The test configures there PFC which is supposed to notice that the headroom is filling up and send PFC Xoff to indicate the transmitter to stop sending traffic for the priorities sharing this PG. The Xon/Xoff threshold is auto-configured and always equal to 2*(MTU rounded up to cell size). Even after sending the PFC Xoff packet, traffic will keep arriving until the transmitter receives and processes the PFC packet. This amount of traffic is known as the PFC delay allowance. Currently the buffer for the delay traffic is configured as 100KB. The MTU in the test is 10KB, therefore the threshold for Xoff is about 20KB. This allows 80KB extra to be stored in this buffer. 8-lane ports use two buffers among which the configured buffer is split, the Xoff threshold then applies to each buffer in parallel. The test does not take into account the behavior of 8-lane ports, when the ports are configured to 400Gbps with 8 lanes or 800Gbps with 8 lanes, packets are dropped and the test fails. Check if the relevant ports use 8 lanes, in such case double the size of the buffer, as the headroom is split half-half. Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Fixes: bfa804784e32 ("selftests: mlxsw: Add a PFC test") Signed-off-by: Amit Cohen Reviewed-by: Ido Schimmel Signed-off-by: Petr Machata --- .../selftests/drivers/net/mlxsw/qos_pfc.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_pfc.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_pfc.sh index 49bef76083b8..0f0f4f05807c 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/qos_pfc.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/qos_pfc.sh @@ -119,6 +119,9 @@ h2_destroy() switch_create() { + local lanes_swp4 + local pg1_size + # pools # ----- @@ -228,7 +231,20 @@ switch_create() dcb pfc set dev $swp4 prio-pfc all:off 1:on # PG0 will get autoconfigured to Xoff, give PG1 arbitrarily 100K, which # is (-2*MTU) about 80K of delay provision. - dcb buffer set dev $swp4 buffer-size all:0 1:$_100KB + pg1_size=$_100KB + + setup_wait_dev_with_timeout $swp4 + + lanes_swp4=$(ethtool $swp4 | grep 'Lanes:') + lanes_swp4=${lanes_swp4#*"Lanes: "} + + # 8-lane ports use two buffers among which the configured buffer + # is split, so double the size to get twice (20K + 80K). + if [[ $lanes_swp4 -eq 8 ]]; then + pg1_size=$((pg1_size * 2)) + fi + + dcb buffer set dev $swp4 buffer-size all:0 1:$pg1_size # bridges # -------