From patchwork Wed Oct 9 12:06: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: 13828254 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2049.outbound.protection.outlook.com [40.107.236.49]) (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 0F6CA18EFE0; Wed, 9 Oct 2024 12:09:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475781; cv=fail; b=XermYYnB+DHGOOhT0v02Fntr/G9nkmDL/dDRYeyZKZSQmOuXe7NJdTK9zYU+AkDz9wOa4CkDYV3c2GXQt+cDuH8xa70QZSg/8JUpREs1pWS1qX6SyWFr96VQ79APk5iqsjA/7VRrOGCcyKkDY/WlhEVBI+PT/rGc3lac0zl8IN4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475781; c=relaxed/simple; bh=OL5goZHBJbRlNFj2bFadNkqzCi7d8A05WZnaF2eL+q4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NvUyn1KjQoiE4mceEAOwhR17dLBmT7lwVAVmBz9JJ0+e0i7nEq3swdILfvC7MuXf2Gv3nEQ9o6BJsixQlounPULzzNhOKlSWQCKk+PI2noadqf7aqq5IMNwDWMUVmbuJbe0TiD0XVvMi7vxKMIX8BehLvOR05/k5I6Y+JZN/Uyc= 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=ap6b5lzT; arc=fail smtp.client-ip=40.107.236.49 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="ap6b5lzT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zDABkp5QW7Wc6uXHipECfPiEGZqCbmo+wd15ZwzzuQt5Y/DPIYdaILuVm3XtvajxyyUOseCTi9PGTsAOv0G3HlKnwlkQtmQEIDCIj6Mo/MlwNHP3W/JfPUZXwcBgH2PJB5EpI3t7dQVDGJsn9zA+3+tHruIrPDawzicwMo+qK1XCVj92uH52dgGAAN+kB427phK2nhQkEhXUlig6yL8HnkmgnQ1aLkiS8pc0Ylzxw6rp4AVSYB9OvKtO6qc2duosh/x4Tr9UirJHl7AtnFZzwskGnTU1O7RvLlYsg+95UGXSG/uAJdzSY47wWNjiqyUSW3NEmYSO22IWipUvuvF1fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=zkTCV4+EcwE0hlJwb2+2DJW+HxzhVE4nJxzpnMGXTI8=; b=swnSbbz/AJL9e4SJXIav69DQNB8/4OagmYRr3RJ7+Og7Rxjgc59ito+BC24f0qGyhr6ftuhjIRwPeY87Ixp9hyBk3RaNv4FwiOgxKrxwbYpYUwL8XstRG+bvKIjFvoahacDqoRv3FZICxbVv0bdJkGCYW0WD15GRjJ7bvbdx46nRIC1ESTol3fYG8eYk5xEhPum5VNeGON7LGmdlx5ZYGvfnrCRMOM+yt6dWvRRs3m/kOQqcqZ+SORxLKyR7KejF6/ZhipKSOdCrV7+R35aL6V0coKHvRSIx3tlrX8+NJymbu0v/2J8BHHW2p/sUQu4rzgXSZEPm4LJCsMkznSXDgQ== 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=zkTCV4+EcwE0hlJwb2+2DJW+HxzhVE4nJxzpnMGXTI8=; b=ap6b5lzTrzqMi0UoQZ1Ivkvc2GSptE1zZBHhbiqsms2OVBt51pHqeDuy6VVsmuSIpTCpgg2ymBhfF+cirJW5MzCuYHsRK4KV9KMoyjrdmAOxBW1xFtZjikFPF82n0Aur1nxmVbl9JL0/H5cQhDLVKoKsTTy67qLhvXU/fg0yMnwAI/5Qzm/+KomU77LC4EvxFfy15KvAnSSimbDpQ2hRA2WLWvXTTEnYm/9NhzQY2rLDVdsl9pk594jn3vT56Krsj/RX4DbkH921j13+o+IEHX9uTJMUwj8qG+yNdw2P07B+o+IOYJ74LAH/xjGxsLn5cYkDE9nTXGil0Jj7EzNfnQ== Received: from CH2PR19CA0021.namprd19.prod.outlook.com (2603:10b6:610:4d::31) by DM6PR12MB4043.namprd12.prod.outlook.com (2603:10b6:5:216::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 12:09:34 +0000 Received: from DS2PEPF00003444.namprd04.prod.outlook.com (2603:10b6:610:4d:cafe::ba) by CH2PR19CA0021.outlook.office365.com (2603:10b6:610:4d::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Wed, 9 Oct 2024 12:09:34 +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 DS2PEPF00003444.mail.protection.outlook.com (10.167.17.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 12:09:33 +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.1544.4; Wed, 9 Oct 2024 05:09:24 -0700 Received: from localhost.localdomain (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.1544.4; Wed, 9 Oct 2024 05:09:18 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: , Shuah Khan , "Benjamin Poirier" , Hangbin Liu , "Vladimir Oltean" , Ido Schimmel , "Przemek Kitszel" , Petr Machata , Subject: [PATCH net-next 01/10] selftests: net: lib: Introduce deferred commands Date: Wed, 9 Oct 2024 14:06:19 +0200 Message-ID: <5c0506e2d1bcdd513b9917716702c9bc5f656198.1728473602.git.petrm@nvidia.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003444:EE_|DM6PR12MB4043:EE_ X-MS-Office365-Filtering-Correlation-Id: a996ea20-d2db-446f-495b-08dce85b3cbc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: 9uAy+xrO4sFFNFM2/zsWvM13QqF+Kq9hJcKVALqWyGL5arLiSPqTcQ3nsPeeBAdZxwgZiBi5Q2+DLUZJ7qtE+c9rupgKfXGQyjyEV39Qma+J5GWpp8rVRcCL0ALhO9ydF+j8AZER9mEvLzg8a46Qn1ZqRO5wIn2OcSs2ROrDLoKPh8ogimcwwA658y2Fyty7XQc2TqvmdM1V3DVv+y/fbRc7OrDk3tWxW2NBX/VbLf7wbyDLVQgxhRREGfwuxGanKiOvIvdPa3rdqYeXT+LjavG/Vq1+pdCJc3VodNZOW4ja7I4Z3XSuLxabBGZrkhKDmw/DZLXmI2IpP0ns5DZJfA04nmgqqPs9MfDYLENsSJIWVVLGcx4vhuTXuakZuZ4ogfN941K+jSwlc6m23WxEkuG44Qu+66j7zxv2x3HVBCcT3zMTckNaNQoB5UUbyJxYC8sBL7SW5P0hyGUe/pr87WhLFF7V2v2nVRYIc9VEZzh2oqFH33rMIS5ubT/NREHuaqZ+0v+WMdSszojks3XJmmSLRElyN3TTadRiZkImMe7NHbtMQRVlJBctlx7Zs97nMaBAbmNkNgFcHX8/2Tf3IoyfLK+cjX3ud2c07tBVh/W1g+GU3RiiUQSidV0pjfFTvlR2oz+GWuqCDKTi+gaTTCV4W3x1N3mK/gX7LjPUSZ0BOik+oEq310li4V3NQEzRQkKmGhF0Crggb5EVS5UR5GQT5hyMmEmxx1v737deOv5iJRIT8ajk7vCJxx+3RNM2GSLKTkXBSw3tYM/pZCu3yqIVEy3ImLuhCxkdMxbft5tSWhNo1VebFeFhbdCmF3bxP/wzOyUPROj/mW4TplRfDaSNPyC3DkFNrDnLUcXRw+OEbNhKn3az2A3uEv8J0C+4nZF2JGt1Rvb1kwAyATkqoZBEITstBqn7qPGScFfy9j/qoK7gdeGzsOMhYXpELcb/81zvfAbtapCxFeFRyjgYSgFjsmxvjjhZYoKywl4sjFaYhE5IjRXV7DKMMPpAPlX6yfzVI9P8DcHLzciMNzTIBIaOfMyLJB16BIj9BXg7utXZlofd95Y/ijGXpkS4adsynyhz24JszrwU+sAnUPQT1UnWTuecx/Yb3oF5AbBRYUQozTE5OTwTUZ9ZZjkHmcIRqZjlsBlRL1reb1GgVuEReHe2ooyXbgH/E8+tT8KBbbOvMZTjNxpHa3U5nUB4eaDjNrqelO9dt3WCrvRULe65qAJ6GbKmde8rVzGUj21ESkOJm/pCf6dhQVHOdZE7HuzHzR8XCR0eSsDtMfLxuCy9jBZLXGx1iBdizsockVHmF6ZaWrx6TKQeqMG2GYFdkPraPbFw9Nx9iOKWz7SQMoJiS98MkVd+w+lNSEj8R/H2IaWp8smHv0qxQ5WXVQqScLV8 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:(13230040)(376014)(7416014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 12:09:33.7002 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a996ea20-d2db-446f-495b-08dce85b3cbc 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: DS2PEPF00003444.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4043 In commit 8510801a9dbd ("selftests: drv-net: add ability to schedule cleanup with defer()"), a defer helper was added to Python selftests. The idea is to keep cleanup commands close to their dirtying counterparts, thereby making it more transparent what is cleaning up what, making it harder to miss a cleanup, and make the whole cleanup business exception safe. All these benefits are applicable to bash as well, exception safety can be interpreted in terms of safety vs. a SIGINT. This patch therefore introduces a framework of several helpers that serve to schedule cleanups in bash selftests: - defer_scope_push(), defer_scope_pop(): Deferred statements can be batched together in scopes. When a scope is popped, the deferred commands scheduled in that scope are executed in the order opposite to order of their scheduling. - defer(): Schedules a defer to the most recently pushed scope (or the default scope if none was pushed.) - defer_prio(): Schedules a defer on the priority track. The priority defer queue is run before the default defer queue when scope is popped. The issue that this is addressing is specifically the one of restoring devlink shared buffer threshold type. When setting up static thresholds, one has to first change the threshold type to static, then override the individual thresholds. When cleaning up, it would be natural to reset the threshold values first, then change the threshold type. But the values that are valid for dynamic thresholds are generally invalid for static thresholds and vice versa. Attempts to restore the values first would be bounced. Thus one has to first reset the threshold type, then adjust the thresholds. (You could argue that the shared buffer threshold type API is broken and you would be right, but here we are.) This cannot be solved by pure defers easily. I considered making it possible to disable an existing defer, so that one could then schedule a new defer and disable the original. But this forward-shifting of the defer job would have to take place after every threshold-adjusting command, which would make it very awkward to schedule these jobs. - defer_scopes_cleanup(): Pops any unpopped scopes, including the default one. The selftests that use defer should run this in their exit trap. This is important to get cleanups of interrupted scripts. - in_defer_scope(): Sometimes a function would like to introduce a new defer scope, then run whatever it is that it wants to run, and then pop the scope to run the deferred cleanups. The helper in_defer_scope() can be used to run another command within such environment, such that any scheduled defers run after the command finishes. The framework is added as a separate file lib/sh/defer.sh so that it can be used by all bash selftests, including those that do not currently use lib.sh. lib.sh however includes the file by default, because ideally all tests would use these helpers instead of hand-rolling their cleanups. Signed-off-by: Petr Machata --- tools/testing/selftests/net/forwarding/lib.sh | 3 +- tools/testing/selftests/net/lib.sh | 3 + tools/testing/selftests/net/lib/Makefile | 2 +- tools/testing/selftests/net/lib/sh/defer.sh | 115 ++++++++++++++++++ 4 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/net/lib/sh/defer.sh diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index c992e385159c..d24b6af7ebfa 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -1403,7 +1403,8 @@ tests_run() local current_test for current_test in ${TESTS:-$ALL_TESTS}; do - $current_test + in_defer_scope \ + $current_test done } diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh index be8707bfb46e..c8991cc6bf28 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -1,6 +1,9 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 +net_dir=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")") +source "$net_dir/lib/sh/defer.sh" + ############################################################################## # Defines diff --git a/tools/testing/selftests/net/lib/Makefile b/tools/testing/selftests/net/lib/Makefile index 82c3264b115e..18b9443454a9 100644 --- a/tools/testing/selftests/net/lib/Makefile +++ b/tools/testing/selftests/net/lib/Makefile @@ -10,6 +10,6 @@ TEST_FILES += ../../../../net/ynl TEST_GEN_FILES += csum -TEST_INCLUDES := $(wildcard py/*.py) +TEST_INCLUDES := $(wildcard py/*.py sh/*.sh) include ../../lib.mk diff --git a/tools/testing/selftests/net/lib/sh/defer.sh b/tools/testing/selftests/net/lib/sh/defer.sh new file mode 100644 index 000000000000..8d205c3f0445 --- /dev/null +++ b/tools/testing/selftests/net/lib/sh/defer.sh @@ -0,0 +1,115 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# map[(scope_id,track,cleanup_id) -> cleanup_command] +# track={d=default | p=priority} +declare -A __DEFER__JOBS + +# map[(scope_id,track) -> # cleanup_commands] +declare -A __DEFER__NJOBS + +# scope_id of the topmost scope. +__DEFER__SCOPE_ID=0 + +__defer__ndefer_key() +{ + local track=$1; shift + + echo $__DEFER__SCOPE_ID,$track +} + +__defer__defer_key() +{ + local track=$1; shift + local defer_ix=$1; shift + + echo $__DEFER__SCOPE_ID,$track,$defer_ix +} + +__defer__ndefers() +{ + local track=$1; shift + + echo ${__DEFER__NJOBS[$(__defer__ndefer_key $track)]} +} + +__defer__run() +{ + local track=$1; shift + local defer_ix=$1; shift + local defer_key=$(__defer__defer_key $track $defer_ix) + + ${__DEFER__JOBS[$defer_key]} + unset __DEFER__JOBS[$defer_key] +} + +__defer__schedule() +{ + local track=$1; shift + local ndefers=$(__defer__ndefers $track) + local ndefers_key=$(__defer__ndefer_key $track) + local defer_key=$(__defer__defer_key $track $ndefers) + local defer="$@" + + __DEFER__JOBS[$defer_key]="$defer" + __DEFER__NJOBS[$ndefers_key]=$((${__DEFER__NJOBS[$ndefers_key]} + 1)) +} + +__defer__scope_wipe() +{ + __DEFER__NJOBS[$(__defer__ndefer_key d)]=0 + __DEFER__NJOBS[$(__defer__ndefer_key p)]=0 +} + +defer_scope_push() +{ + ((__DEFER__SCOPE_ID++)) + __defer__scope_wipe +} + +defer_scope_pop() +{ + local defer_ix + + for ((defer_ix=$(__defer__ndefers p); defer_ix-->0; )); do + __defer__run p $defer_ix + done + + for ((defer_ix=$(__defer__ndefers d); defer_ix-->0; )); do + __defer__run d $defer_ix + done + + __defer__scope_wipe + ((__DEFER__SCOPE_ID--)) +} + +defer() +{ + __defer__schedule d "$@" +} + +defer_prio() +{ + __defer__schedule p "$@" +} + +defer_scopes_cleanup() +{ + while ((__DEFER__SCOPE_ID >= 0)); do + defer_scope_pop + done +} + +in_defer_scope() +{ + local ret + + defer_scope_push + "$@" + ret=$? + defer_scope_pop + + return $ret +} + +__defer__scope_wipe From patchwork Wed Oct 9 12:06: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: 13828256 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2088.outbound.protection.outlook.com [40.107.93.88]) (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 9F20C192B95; Wed, 9 Oct 2024 12:09:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475789; cv=fail; b=VBBpYgfN0/B1UwJkGIjRTFDPsRil08Ld9sgBBFxYElAvZVN01DTkvjsKfq/RVX+zGKVh1npPxfktZATIdg3bFWriN5Vyu2Du1nf2UPtG0sCRMX+Y9gCdz8aqZfIuQz/ZVhT8LcgZ/WF/y03y0JhY6hQG/WCNCxo411o4+NCCi74= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475789; c=relaxed/simple; bh=Wj8/eDIkFKqrizBwAIL+rGQ4mBwhFSnEvLRXdt6sRuQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YZBNwSKtL1+W7fU6QJksv7t+n2mabe81sLCZEINKPQJ3NXlqlJvQkWEL7V/YANQDHFE8jWb7W2vKWky4WWZNBL97xH4D9t6nHXGPVfhXe9k/kqCco2awEgtLxxrP8XT9FxDNK9hOQ9aOKWovD8481ZBXfEtK/AyziyJ+1F8YoMQ= 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=LBaYf1FN; arc=fail smtp.client-ip=40.107.93.88 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="LBaYf1FN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PoAMvym0n3hTCj1RLRhYQwr5rzTF3ttG3P/pApMxlbO0B2I8G45gcaDjxfj7qsRiRFFNcA+MyVloR9IemW33uB+Rk5tMW1fnDqj+bF6qqRAWwW0fFhRBlDmOUbcPbNf/0LiN2q1vq906cp1q9rA2YiFln7GWeaeLTyUxP8e1Qs70mFuTl1OSOj/f13vb0YlnszpK4lsg3HB/Qfx96w8SJjjbNX80D9EHiAGjjUbtgVGdh3oJCMTFL5Rl1JNZy8F56al46y0O7FNGd8+sLNXcBGQG2WPz78nZ6lgnKuq1axrLOCRBr6qZO+RMWsWQVxsN04EyjgxyeseH5EF97OA0/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=0VCQkaVJVw+WAjtwSfv9f7bEjAIvy3jeYEnEyvsHA9E=; b=loXxz2/b5N+izNBUxzUrl/c7RvBtF4rYcGdJUjV3BaQ6buzi+MRtEeSuNNHOx7Z60oNcKTAmhJyjnj5ACByfuUj/9xMZ4uqFuhoNCBJCW3t4mkeBk3VVsDQm+TQdhD6r7Nl23Apd0okQX/GhC93dyZjprXHVFJdDuTLmM77wzK7TEH/l2XFYW22is1spuCFpwYjV3d+e04BdENNk7dkCJKae/oyrTuyQuRmOZLYactBcggfp1Ilu+lM/GFe8iVYP+Sog96gEva0djzDfTt6bz4JjEqHWIjFkCKoXCZrTlfU+oOyvpZCjOyQVz4VsiLVLoJAXNCQ1Ne9Rh684hX33+g== 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=0VCQkaVJVw+WAjtwSfv9f7bEjAIvy3jeYEnEyvsHA9E=; b=LBaYf1FNM30Rzo4Q4KtL6zkujEMCaBW0G++APRXaW6s3fvXaXDrL34msmpoxsZTL8m0MR+yVIUffOGkYtx6vn1adq6nff412RuJvvdWtnL3MfTCt+TvTv7eLoktGE16WtqlI85Gr+QgCyEhIVIVNjlUNRkPL0j4PTzbcC+N6FswQbNgw6gUGw6WYlKjaxBvygR1ObDhgI+G0FJBZCHR9USErlNzKtsiak4AZLo5cfDJjTCOWV6iYSFeI4e+dl7Vp6IxG5xRGA6xqRm9ykRZdjTNMYkKLkyzB7enum05Oyw9KNpbQoyPdNg59hJBSVlipOPEJGGEs32diO7P7D2AxyA== Received: from CH0PR03CA0256.namprd03.prod.outlook.com (2603:10b6:610:e5::21) by MN2PR12MB4046.namprd12.prod.outlook.com (2603:10b6:208:1da::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 12:09:42 +0000 Received: from DS2PEPF00003446.namprd04.prod.outlook.com (2603:10b6:610:e5:cafe::e0) by CH0PR03CA0256.outlook.office365.com (2603:10b6:610:e5::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18 via Frontend Transport; Wed, 9 Oct 2024 12:09:42 +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 DS2PEPF00003446.mail.protection.outlook.com (10.167.17.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 12:09:41 +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.1544.4; Wed, 9 Oct 2024 05:09:30 -0700 Received: from localhost.localdomain (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.1544.4; Wed, 9 Oct 2024 05:09:24 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: , Shuah Khan , "Benjamin Poirier" , Hangbin Liu , "Vladimir Oltean" , Ido Schimmel , "Przemek Kitszel" , Petr Machata , Subject: [PATCH net-next 02/10] selftests: forwarding: Add a fallback cleanup() Date: Wed, 9 Oct 2024 14:06:20 +0200 Message-ID: X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003446:EE_|MN2PR12MB4046:EE_ X-MS-Office365-Filtering-Correlation-Id: ac27af0b-c884-4263-dbf6-08dce85b4157 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: kf5dj8iCCcYv/QCyzUvlb7sJLzUSm3RixSl02a6G3Qhi1P1mMBJRit61+rdVPdvY8VJR1Ig4DEh6HdbvYFyO7M1aZYI2tkfGQlsLY1NgEViz+hanEk34RvxObRaQ/00f+UIIuf9nmU19HNJGDgYWJ3yIed7A7fbPdwhPDDwP4yRjaZzvSMyJ6sioa7Elfh9/ZxHD1QXw9jFfLvXpLzb65UUIglaGDLHcgtSR+qzcg8emvX+xhYFNMr+w+JSCTd6MGc4j9XtqZ6k3K9dVTzKvGYsdAAdF4y+qJQTdl/g49G+5ma51dcmnSf/OTmMsurwem4Ggf1Q3AICjnkyaAyggJYOdTImCisF/rWLwH/3BrWn0BMO1c6mDjtfTpn9m0c/dqFBE1oQ3o6cwx7TBsrlcEJOaGBijb4+pox84dGTS4IK6UFsbJkWwMLn6gDVzyYKnIXMoJr/4LjQSvg6mMWXmL1WdyOGVbGd62oGzNkf6XqIg/QvPhNyqADyBIrZZTg+2miOpbHyvgbznLw7Od0bDeTmRxcyxGHJg7ak4tGouXakaPGOVAE5PAPXti143/grT2MXzM5hS9l7ysVVkbOxBteA3OLjdiKwTQ+1uBE2OB21WG1hdppSUtsA+saqh8lDb49GITUQMjS5HYTqksE7RTOWz+NeJwcwavq5qkXwv5bDh3AlCuQ0uQEgp+ji+Q4RacnOziMA+acILIIxnLD9YZRxYz9aT6gEHO3OCdt9++zl/89gMavEBjfQ+hUybPmCaCyJO9lvug/saH01QrdTfWrNPAOxz6W0GwWoe9134jd2DjpSN2mR5zstUvwfLu3+d4LyC4zgu/H6YVg0kkpvLMw2d4SAaFZW06WT7g8x0SfBfSQCqUb5OZAHzAR14C0zMIDqL7lNRCz6NVldZ3nNeKayZ8lZo4Bmzvhsfo2OQeodw1V8vaKMlsdNbYfpbVxVsQTI3Wrx0marogHBblmIT9qBdhY1pnrB6XtqxIppPa+t7pd3KFuctqHIm6IenYxcPSsPmdAeNUY+e7StCTK7Vlb/V4XHDlpMjnvuFXaym0JYFr4LtCpqO1IYbygFPWBZ4/BpLzgNKMXWywlD7Q0jN72t6siqLzuVzA+6E4iTp1H1HETFuW+2zZym5YGV41UN7ACGQZENsRqOYLpLr2OfnOoSfsRYpyuWZNMG4z5cM1j0GzHaocoAS3EjeBO6w2/uZljyvtYTVwtQKJ8Hn1t3XT/xta6N/nNrdgZwJ73v2lNOYyRAEaf5RYHiTENGL+kc/P3bpR9IGUiKbvN6gJ8GeinpYrpeQWgad8i35EtTdGAUOgEz2IGlXZmC4fT5+ZhHHkhiY+E7ConIIFxjrcEozcDMCZpDDOWGH7IspchGPUG8= 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:(13230040)(36860700013)(376014)(7416014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 12:09:41.4305 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac27af0b-c884-4263-dbf6-08dce85b4157 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: DS2PEPF00003446.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4046 Consistent use of defers obviates the need for a separate test-specific cleanup function -- everything is just taken care of in defers. So in this patch, introduce a cleanup() helper in the forwarding lib.sh, which calls just pre_cleanup() and defer_scopes_cleanup(). Selftests are obviously still free to override the function. Since pre_cleanup() is too entangled with forwarding-specific minutia, the function cannot currently be in net/lib.sh. Signed-off-by: Petr Machata --- tools/testing/selftests/net/forwarding/lib.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index d24b6af7ebfa..76e6d7698caf 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -1408,6 +1408,12 @@ tests_run() done } +cleanup() +{ + pre_cleanup + defer_scopes_cleanup +} + multipath_eval() { local desc="$1" From patchwork Wed Oct 9 12:06: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: 13828257 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2072.outbound.protection.outlook.com [40.107.94.72]) (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 554FE190074; Wed, 9 Oct 2024 12:09:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475797; cv=fail; b=j+sgXI1KAyULGYDDeHRwnh8kxtv0N157CV9/ukzRW2gecoP8ymjXR2c6K6JjK8EhS+libxwgpBCPP/LsGZw3zRV13DXzqPcHBVXjXcACqjsOCfR4t2KRZ7d6GHqE1R32FkSSkcImRb51QyVTGIXXbfNq/2YvE7frzpRRHL0ZdGA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475797; c=relaxed/simple; bh=ode908XCLSDd5G+QWaV3cUIGg0Wd4AxpyTA4eXEeS7Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N8j+G1zwPTyKgzsKLrRNebtx4WVv7R7+cONAtYM8XoDseQk8zBjzIQTNEIZIu3w4CQkhtS9fNQMZoF+snLGs/vDJmi5Uo7yG4wNRUJ2ySlRRn6BvbtJXUAMRuFR3LdE28KC73lD2yF6gJma+1TaAE36m3dqrJlr7gOfmzIiOA1Q= 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=pEjEezs9; arc=fail smtp.client-ip=40.107.94.72 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="pEjEezs9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B5Mm1vGaCQLDwP9+Jjk3shqVDQR6FfKWNE3m1yuJBKAYNChlVXzaG2L4IFft4sQTZ2daDHghF4zSxStTfr9rCgkwTbBiS7eCKqAbmBhOZ2L72R5SaNE6I/mvFKcJrdRMGaQa706dphf0JCtGWnx8XITmU5i8q9sv8PtPNeGSLB66cnMBi19VcqONanrp3tjsGccuKDOz/pYus1L+DvVqmhDh2tWyRZAxaQIN9fEqI/OetkaHmNSbPRu+MIdIwbfgxPNSJc4peOnBoR+o6WrhFdX48D2fT7/HGMIeYOEkjcXq4JlLc79B8E0Ej1PQkkIKEKCkmh5SRaGMAF0IlPdsKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Cb+B/zKUwixV0+EP3ly1AHKv3dETzlNyG43ysfafncY=; b=HpjvdHKckScL5M84gUL+FfoQz5QR9jxa/ZJc2BQ+slCQ1d4/Jr+S/VxjR1JC4xPVXPuJBKrZsAdbSLLVWJU0zyCnEtwsr14r4y666RmOH7OktjQ2gRs54c48pJqJlv8w7Ix5FSwiRYM7sJ3GczSbWBHD4iEY5Hip3ZaFEzmtuyC/GR3ANupyF7yi6JUdGduqxdFCLSAHsNaDisqN3HRCY0Kw6IqmcYlDu2qlCnALVxjMGaGdmn+l3LrnbnOeSPAoNSzpTceFGvcvexRx+cj6JoEzpeC7iZ1ZHw6RPuQhwipPwz3ETcjxS+VXIOxiHYKlvSO/v2igo3jQPN4/FIb8gA== 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=Cb+B/zKUwixV0+EP3ly1AHKv3dETzlNyG43ysfafncY=; b=pEjEezs9YhJzd+vY3+cDgzAFgamuLjZ6Qh7G5ZNXJrkXcInO7UWrAIVvtm8GJUFU4g5JFu9mxJ38HixqWYdD91Rvlrc+lAZHa6N0YufTlf9lqlpP/2qzegT6neoF0/bKf+vQDNeMYjSISz3JtgpY+x0nrRKHl7+rj8ytATXYv2otHHzQoKfnOiH6BoF9UrQv7aPXs9yD4uNyg0jWA0P7SMd/Q+G6nFS31F2FqmaUGIIHeD8UwvcavNiOjoWY5wQddXQVRzKhw1Iwu6mLZj46TcUNMVFAG6/D+rRfWwymSE2EAe420F334dtZT5huCxac2CZVdpJaz7AC0ZUPZPaFfA== Received: from CH2PR16CA0027.namprd16.prod.outlook.com (2603:10b6:610:50::37) by CH2PR12MB4071.namprd12.prod.outlook.com (2603:10b6:610:7b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.25; Wed, 9 Oct 2024 12:09:51 +0000 Received: from DS2PEPF00003441.namprd04.prod.outlook.com (2603:10b6:610:50:cafe::cf) by CH2PR16CA0027.outlook.office365.com (2603:10b6:610:50::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18 via Frontend Transport; Wed, 9 Oct 2024 12:09:51 +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 DS2PEPF00003441.mail.protection.outlook.com (10.167.17.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 12:09:50 +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.1544.4; Wed, 9 Oct 2024 05:09:36 -0700 Received: from localhost.localdomain (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.1544.4; Wed, 9 Oct 2024 05:09:30 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: , Shuah Khan , "Benjamin Poirier" , Hangbin Liu , "Vladimir Oltean" , Ido Schimmel , "Przemek Kitszel" , Petr Machata , Subject: [PATCH net-next 03/10] selftests: forwarding: lib: Allow passing PID to stop_traffic() Date: Wed, 9 Oct 2024 14:06:21 +0200 Message-ID: <4d7cb2f1a05beef5076372b19da4b7d3f08b79d2.1728473602.git.petrm@nvidia.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003441:EE_|CH2PR12MB4071:EE_ X-MS-Office365-Filtering-Correlation-Id: df53bf79-37f3-466a-f96a-08dce85b4707 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: xOEjA6XzKsFr2dqPoCNY7rZ/uNwt4e4HKUDDdUZ2UMveJ6nDQpc5R0ZSI2sAnZvNt2cRmsfhTeZYCS2QWwxWwWJO1ithOEpHz0bpQNjJwE+TBAf9ZAM4gYgFgskOY2RmOj2X2Vbf1N7OhAoNXL885l4eZef+DfifJWgWAr0fMBVwEKuf/2yjL25guwlgWNrbbAJzReArIfnNI98d74Pzcvx5BhtTMQ1DJjvteTB8YJh+aNDpmL/JR0aDbO3D4U+s6/2hPk8XrvXMw3RTvhgU6S/VyU/p3iyHJBtbeEkXK3ILFrIE9IC5gvKoR4grNWPRC/tJfUONU7ztUYr59VnT6sLtrm+nIAapLC32rFaiSDuKwRVZGHMZznBtYHuMJfi3SwpCs/M1YZmDPP48SSUIqY6EIXXLxmeRd+/ih9ra1lVUyD8fd44gswMnE4Ben0AkMssNOEd0VqyRTmoYNvRG2dUpvRuKzngpbivIc2hjMt25B/IPcW47iZk66m8hpofTHpGsv8CXEHrJqt78sRIrM8SGX0RQEXJrrRsDbYc3VJoHAZ1wpfObSld+/CTyn723O6L1Cdp7FnUAe/Bd9TjJtZdqFbD/ExFyrfdf7eVjvSff7PybMSFqY3DbAkfGbsFqYU4W13ZrHih8Qn7rRYvbCUXMZXReUKZagnLTmBBQqdAlbpy6+co/OtptgeOQ/TPdGHASEDSiLLBFL857ZEnhnQdLQ+S3Ehzx/yA+1PKY8Cot9tORN2GxVZYDCISfAOGY+Zg2UwGGN5H1meqiGKlZpR3QetaSb91R2atahYca6FK6XWW/VFIr+X1uo47PJZHhQgq/L8i3OS9t0Zn8GisX4mPctMJi77rZxRB1bDWoR1mGZ/uitUxYXCzQMBFpv0ZYGr8skkLONnpDluwHofgZzmLdCSttMY7xR9V1qXWFH7Vw+ori+6BN5/Iv7VWKN9bx1PIJSp+yMP7mo7DgZlTmAjkY9+sSf0AeEPmNFhPc4EAs8NIApRP5AgFVOeObK9J7ngvy06bf4UV5ZrE7a3Gz+ueLH37+BHUSo28WcZNgevjAbqBYF96aC4O2BWH3l8YJ6bFel1W3ZY1gYgn4Ll6GcKQQ9J7aRTMDtb4H081MN+F66lTv8XrVHe6GWRX1J7aGGoVPS33WqX5rp6/tGTuMjkXOgy/+hY6Ed1vcvlZnr+nZ8a04GaxX2IA3twehaZCaLSWHwMOSuPwXBtmrDBAcuGC/krlKvR8lVvqB/eKcWpuFafHR2dGPhld9MbMltPXkhiPKeu17B4MPOFKlOLbhVSZ++U8JfxPJuiKWgHCHRe6M5+zwjjUbpA3G0gMyeScesR7paGCHdyLylxMpUGlPOexf63V2F6Sv16Z22HuuX3lRJiHt/zoZQN90/MbF3IKM 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:(13230040)(376014)(7416014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 12:09:50.9734 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df53bf79-37f3-466a-f96a-08dce85b4707 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: DS2PEPF00003441.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4071 Now that it is possible to schedule a deferral of stop_traffic() right after the traffic is started, we do not have to rely on the %% magic to kill the background process that was started last. Instead we can just give the PID explicitly. This makes it possible to start other background processes after the traffic is started without confusing the cleanup. Signed-off-by: Petr Machata --- tools/testing/selftests/net/forwarding/lib.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 76e6d7698caf..89c25f72b10c 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -1768,8 +1768,10 @@ start_tcp_traffic() stop_traffic() { + local pid=${1-%%}; shift + # Suppress noise from killing mausezahn. - { kill %% && wait %%; } 2>/dev/null + { kill $pid && wait $pid; } 2>/dev/null } declare -A cappid From patchwork Wed Oct 9 12:06:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13828258 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2072.outbound.protection.outlook.com [40.107.243.72]) (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 9B683190072; Wed, 9 Oct 2024 12:10:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475806; cv=fail; b=OkOQaU8WqBL6vLP3nCcaART8Opy743k+VTaXUac9dIwPA2CM13nZIoK5GbUMgPcQ7oip1/j//d+01kndTC6L51snRTrvk/LcUvHvDNLpB4MqRY3lo9odyFznbvwdKtnq8avcYJIclEMjwL5rzMhP5ngKdLUilMI4KBMgi+HVSJM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475806; c=relaxed/simple; bh=8FeHgnu8XPZFIQPh46hfO1wL67MoXO2GmCilOZvv0hE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ilVTGILufsbby6tuOJtGauktIOvRDLsk35Tf5fN95XwpONJPhFR9OYzsTMn5KsT18EcT0Npx5sl9A1Ka4Y2Yk6xQADYtuBds9S758MEdUXE5YC0UANOKiHP3pvjcXHotUTAKSQoDgR76XUdQJJOL8HlFfKHP0pUKd6dwcnPYKTE= 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=rgxxqW/1; arc=fail smtp.client-ip=40.107.243.72 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="rgxxqW/1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RVh63GZAa/ev0fo2fJ3go4WmTISbtsuP/rb0+RTG0X5L/pe9a8Klib1K8DC2cYfltp0+T6iJLkiJuisliP0RM8BEf/os/Ek9SHDmgUp0U9j+wgW8EG1LzS9VmqegGKpm2lpYeKGY66NNdwnKK6P7+YIK4axJNvKzO/KTDbQUkM7cQQikD5TWcHx91dzZM7oRRsCvoUrIxNcNMDyk0kpObzaWdcMth5qApia1YMgb1pCjfuwXkhhbOfHhFa3rRUtS/fjn4UREL7/W8btwaC0ivdfGLkBOCqXbDbdIgd3kguN21fDpwDqW4gbKg+/AwOINF9OCQCgXLFkyqBK02Wfj4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=mdTTnlYBHQlQHID0X87dRqC1r0FasPlp7JtQZQzKR4s=; b=YqI1I+w5GNoOWIZvw6++clP9dMRQJ0GveQFw3Uk9Wt3qFmMsoJ/Dk8ujbguGTmtwxsrzLvBIR3M+sLuOBYJTXrwW2GRxixEyCvYR7XPVuACx1fz7O5d3CV5M2zain2Q0gP9uH/ouDMzL3mq8/Ty07XqjyAsThYGii4nViEYmts4GJLiWSWWLoa2MozKwohXPj7r88a3kLQMTXMnRvGUixJuLK9VNUMBOa2uSSkDXKRbrdA9hT7G3lT/rYXGJmyESgg9MFYtnTR4WU1x+O4lMvVp+Zt4mSUO0ExEYDgxsNonzm7B3B/It+VF/UjeYgVBoa3FUSRwFKCeNRcHyOHDH4A== 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=mdTTnlYBHQlQHID0X87dRqC1r0FasPlp7JtQZQzKR4s=; b=rgxxqW/1Cvz1l61g9Q75kALM935eDq711a1cef3Yf2iZhJY1p08z1Ke1gOzYXPiO4KoAeMZFvdB2f7nP2Nc1NixKk67G2gE3ombf3BzXWdiLXG+Tybm2Sid2yGclvNOwLhaaCq3nza9MPzXiE8CZyYyInckiMAP6FuKxMmyMLod4zm57tRzSbIwdqokx+ADndiPgnrmZCVttFnyc3SDNG/3N5e3+Hnrls6yGTDONBf1DYgrgCSVOYaedzGQ17obsHwcsbep04j/quO4cstWfeGI4I6bVdto1tiBemASuDHKkRS/BuNyNdKBdYN/Rk1rQ97MSU4qtAwcBY5swyI47uw== Received: from CH3P221CA0027.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1e7::28) by SJ2PR12MB7845.namprd12.prod.outlook.com (2603:10b6:a03:4ce::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 12:09:57 +0000 Received: from DS2PEPF00003442.namprd04.prod.outlook.com (2603:10b6:610:1e7:cafe::15) by CH3P221CA0027.outlook.office365.com (2603:10b6:610:1e7::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Wed, 9 Oct 2024 12:09:57 +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 DS2PEPF00003442.mail.protection.outlook.com (10.167.17.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 12:09:56 +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.1544.4; Wed, 9 Oct 2024 05:09:43 -0700 Received: from localhost.localdomain (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.1544.4; Wed, 9 Oct 2024 05:09:36 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: , Shuah Khan , "Benjamin Poirier" , Hangbin Liu , "Vladimir Oltean" , Ido Schimmel , "Przemek Kitszel" , Petr Machata , Subject: [PATCH net-next 04/10] selftests: RED: Use defer for test cleanup Date: Wed, 9 Oct 2024 14:06:22 +0200 Message-ID: <4a9b24fa7e582bdf457b550bb27bb1e227f05b48.1728473602.git.petrm@nvidia.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003442:EE_|SJ2PR12MB7845:EE_ X-MS-Office365-Filtering-Correlation-Id: ba746ed9-b426-47b9-8c1f-08dce85b4a7f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: H7/bEZrdwDhBGiq7pP4pT1O1v4EF8kPI9XnQ3MAd+7mcDMmHngoksOFH6wpfDQNmeHdmCydgJ0xzK7ChOFIlukh5LlkX84F1qd2x7hw4s0FwWg5ZNMz/QRxAx7WhkQkLa02f4Ze1DHnbWsQvv3OkBANjebsCAJGOjbOpUqXrcNzrZ5GjWYq1eFdt3PLpf0vjbhNb9xCqMWZWefGe4XQEfiW0M16iWQc3vbWoqVm9wReaWZZCJotYFqUT5qTIH3btRW/vf0Oe+IJFo7EQJl0K1M0KR4T+Xl9SWI4D5yHkiEVXv08tE8BKgEFk7KUQg9G0feo1vRSrZc66fo958CQblmKbqvGsco35pT427hIEptk5o7fvkbZAfI0B5nlrtwaTF9AJwftHnIhrCRa0lqa6Efoy+rXXdaayS3EFSni9SHZrabIPW8gcNgQ/1k5ByQ2BTT6WqNB/E0di74/sNU8UW9DPFQnfiudwMdEwnBAwYotsvIzgyqY8oyA88q054m6zK9c9kaPobo3lv4fxDa218PkKG6iMWQMbEvrZR+lkA63XJ9VSRfnJ7+QanVJv6ecu22gSkQzwWvE1BWtdkmIvQrSkCzx41KP/U+3XrhJyPpztdm++8uCsoFE3y8ozJiNQgrinwauGYivhyvafJWVOx96jwBzoDIcsYbk/JuNpgf1FVdjw1GWdNtxHr7R5ZszyluXqxgHvT9mH3oa3HTIkgjNst8EKihmELws9xieNeJYfo8xkgD5n4BRzkezxD8xLMnRKEQJdEqRUBzaFrVD9O061NcNis76GKVBOAw7ecEab5faYWENa00d2u7DSt7kzSECrXv8HNAcezdzIfhocFFkEL41vDdc9tq8fovhDVg1W+Ul4xrkSiioXVx+RTTgcsM4BWaAqyapESn+3SL0N2bWRbq7q+1GWMUkv2ZlHweaSrfH+4MtWOt7yFOqLHd+kQLM4G1X7I3d5Nn79SmAXsz0zOQhwHQGa2/mYCo6rJKwE9X+e2Ea2TaGmOCOovjQdPTeWlC/ZDO4gLNfp/OHFcJDkA1T8E19JO8ZuP2aRbUw/UZvSyaO/eD0VuIWURF6KuygGQ7PEMp/EJhEQw92z6IRhCsbP5N6mMmSH0ZTojjtxBL7tlQU1/lqDZtXYhgr037NMw3MzjN5FuOEvSKeEa7MYwYMCsZXuAGupt0BdqR0UuT9vw4/+KYtme3yKdCtCvKcQKG/RsSyu6mTJ5x82LbygX06YAnJfVGkNOiM2WC/EkKXgMdJ4JbrJF+456a2Rc8Jv9mfcUXOC5no4123QN8qoiyCor4nmlh/C2UN2l/LlSW1DGIY+QIomv+u8xVtrzYVFO+2YYMOZZawZ9vqA2M8qvvHIuATsPGq2cT5Q1nmfxbd3Vsg+znVpm/k2WHo1 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:(13230040)(376014)(7416014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 12:09:56.7902 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ba746ed9-b426-47b9-8c1f-08dce85b4a7f 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: DS2PEPF00003442.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7845 Instead of having a suite of dedicated cleanup functions, use the defer framework to schedule cleanups right as their setup functions are run. Signed-off-by: Petr Machata --- .../drivers/net/mlxsw/sch_red_core.sh | 171 +++++++++--------- .../drivers/net/mlxsw/sch_red_ets.sh | 24 +-- .../drivers/net/mlxsw/sch_red_root.sh | 18 +- .../selftests/net/forwarding/sch_red.sh | 103 ++++------- 4 files changed, 141 insertions(+), 175 deletions(-) diff --git a/tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh b/tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh index f4c324957dcc..4282142c8eca 100644 --- a/tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh @@ -89,39 +89,31 @@ host_create() local host=$1; shift simple_if_init $dev + defer simple_if_fini $dev + mtu_set $dev 10000 + defer mtu_restore $dev vlan_create $dev 10 v$dev $(ipaddr $host 10)/28 + defer vlan_destroy $dev 10 ip link set dev $dev.10 type vlan egress 0:0 vlan_create $dev 11 v$dev $(ipaddr $host 11)/28 + defer vlan_destroy $dev 11 ip link set dev $dev.11 type vlan egress 0:1 } -host_destroy() -{ - local dev=$1; shift - - vlan_destroy $dev 11 - vlan_destroy $dev 10 - mtu_restore $dev - simple_if_fini $dev -} - h1_create() { host_create $h1 1 } -h1_destroy() -{ - host_destroy $h1 -} - h2_create() { host_create $h2 2 + tc qdisc add dev $h2 clsact + defer tc qdisc del dev $h2 clsact # Some of the tests in this suite use multicast traffic. As this traffic # enters BR2_10 resp. BR2_11, it is flooded to all other ports. Thus @@ -139,13 +131,7 @@ h2_create() tc qdisc replace dev $h2 root handle 10: tbf rate 200mbit \ burst 128K limit 1G -} - -h2_destroy() -{ - tc qdisc del dev $h2 root handle 10: - tc qdisc del dev $h2 clsact - host_destroy $h2 + defer tc qdisc del dev $h2 root handle 10: } h3_create() @@ -153,40 +139,54 @@ h3_create() host_create $h3 3 } -h3_destroy() -{ - host_destroy $h3 -} - switch_create() { local intf local vlan ip link add dev br1_10 type bridge + defer ip link del dev br1_10 + ip link add dev br1_11 type bridge + defer ip link del dev br1_11 ip link add dev br2_10 type bridge + defer ip link del dev br2_10 + ip link add dev br2_11 type bridge + defer ip link del dev br2_11 for intf in $swp1 $swp2 $swp3 $swp4 $swp5; do ip link set dev $intf up + defer ip link set dev $intf down + mtu_set $intf 10000 + defer mtu_restore $intf done for intf in $swp1 $swp4; do for vlan in 10 11; do vlan_create $intf $vlan + defer vlan_destroy $intf $vlan + ip link set dev $intf.$vlan master br1_$vlan + defer ip link set dev $intf.$vlan nomaster + ip link set dev $intf.$vlan up + defer ip link set dev $intf.$vlan up done done for intf in $swp2 $swp3 $swp5; do for vlan in 10 11; do vlan_create $intf $vlan + defer vlan_destroy $intf $vlan + ip link set dev $intf.$vlan master br2_$vlan + defer ip link set dev $intf.$vlan nomaster + ip link set dev $intf.$vlan up + defer ip link set dev $intf.$vlan up done done @@ -201,49 +201,25 @@ switch_create() for intf in $swp3 $swp4; do tc qdisc replace dev $intf root handle 1: tbf rate 200mbit \ burst 128K limit 1G + defer tc qdisc del dev $intf root handle 1: done ip link set dev br1_10 up + defer ip link set dev br1_10 down + ip link set dev br1_11 up + defer ip link set dev br1_11 down + ip link set dev br2_10 up + defer ip link set dev br2_10 down + ip link set dev br2_11 up + defer ip link set dev br2_11 down local size=$(devlink_pool_size_thtype 0 | cut -d' ' -f 1) devlink_port_pool_th_save $swp3 8 devlink_port_pool_th_set $swp3 8 $size -} - -switch_destroy() -{ - local intf - local vlan - - devlink_port_pool_th_restore $swp3 8 - - ip link set dev br2_11 down - ip link set dev br2_10 down - ip link set dev br1_11 down - ip link set dev br1_10 down - - for intf in $swp4 $swp3; do - tc qdisc del dev $intf root handle 1: - done - - for intf in $swp5 $swp3 $swp2 $swp4 $swp1; do - for vlan in 11 10; do - ip link set dev $intf.$vlan down - ip link set dev $intf.$vlan nomaster - vlan_destroy $intf $vlan - done - - mtu_restore $intf - ip link set dev $intf down - done - - ip link del dev br2_11 - ip link del dev br2_10 - ip link del dev br1_11 - ip link del dev br1_10 + defer devlink_port_pool_th_restore $swp3 8 } setup_prepare() @@ -263,6 +239,7 @@ setup_prepare() h3_mac=$(mac_get $h3) vrf_prepare + defer vrf_cleanup h1_create h2_create @@ -270,18 +247,6 @@ setup_prepare() switch_create } -cleanup() -{ - pre_cleanup - - switch_destroy - h3_destroy - h2_destroy - h1_destroy - - vrf_cleanup -} - ping_ipv4() { ping_test $h1.10 $(ipaddr 3 10) " from host 1, vlan 10" @@ -450,6 +415,7 @@ __do_ecn_test() start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) \ $h3_mac tos=0x01 + defer stop_traffic $! sleep 1 ecn_test_common "$name" "$get_nmarked" $vlan $limit @@ -462,7 +428,6 @@ __do_ecn_test() check_fail $? "UDP traffic went into backlog instead of being early-dropped" log_test "TC $((vlan - 10)): $name backlog > limit: UDP early-dropped" - stop_traffic sleep 1 } @@ -471,7 +436,8 @@ do_ecn_test() local vlan=$1; shift local limit=$1; shift - __do_ecn_test get_nmarked "$vlan" "$limit" + in_defer_scope \ + __do_ecn_test get_nmarked "$vlan" "$limit" } do_ecn_test_perband() @@ -480,10 +446,11 @@ do_ecn_test_perband() local limit=$1; shift mlxsw_only_on_spectrum 3+ || return - __do_ecn_test get_qdisc_nmarked "$vlan" "$limit" "per-band ECN" + in_defer_scope \ + __do_ecn_test get_qdisc_nmarked "$vlan" "$limit" "per-band ECN" } -do_ecn_nodrop_test() +__do_ecn_nodrop_test() { local vlan=$1; shift local limit=$1; shift @@ -491,6 +458,7 @@ do_ecn_nodrop_test() start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) \ $h3_mac tos=0x01 + defer stop_traffic $! sleep 1 ecn_test_common "$name" get_nmarked $vlan $limit @@ -503,11 +471,16 @@ do_ecn_nodrop_test() check_err $? "UDP traffic was early-dropped instead of getting into backlog" log_test "TC $((vlan - 10)): $name backlog > limit: UDP not dropped" - stop_traffic sleep 1 } -do_red_test() +do_ecn_nodrop_test() +{ + in_defer_scope \ + __do_ecn_nodrop_test "$@" +} + +__do_red_test() { local vlan=$1; shift local limit=$1; shift @@ -518,6 +491,7 @@ do_red_test() # is above limit. start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) \ $h3_mac tos=0x01 + defer stop_traffic $! # Pushing below the queue limit should work. RET=0 @@ -540,11 +514,16 @@ do_red_test() check_err $? "backlog $backlog / $limit expected <= 15% distance" log_test "TC $((vlan - 10)): RED backlog > limit" - stop_traffic sleep 1 } -do_mc_backlog_test() +do_red_test() +{ + in_defer_scope \ + __do_red_test "$@" +} + +__do_mc_backlog_test() { local vlan=$1; shift local limit=$1; shift @@ -554,7 +533,10 @@ do_mc_backlog_test() RET=0 start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) bc + defer stop_traffic $! + start_tcp_traffic $h2.$vlan $(ipaddr 2 $vlan) $(ipaddr 3 $vlan) bc + defer stop_traffic $! qbl=$(busywait 5000 until_counter_is ">= 500000" \ get_qdisc_backlog $vlan) @@ -567,13 +549,16 @@ do_mc_backlog_test() get_mc_transmit_queue $vlan) check_err $? "MC backlog reported by qdisc not visible in ethtool" - stop_traffic - stop_traffic - log_test "TC $((vlan - 10)): Qdisc reports MC backlog" } -do_mark_test() +do_mc_backlog_test() +{ + in_defer_scope \ + __do_mc_backlog_test "$@" +} + +__do_mark_test() { local vlan=$1; shift local limit=$1; shift @@ -588,6 +573,7 @@ do_mark_test() start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) \ $h3_mac tos=0x01 + defer stop_traffic $! # Create a bit of a backlog and observe no mirroring due to marks. qevent_rule_install_$subtest @@ -618,11 +604,16 @@ do_mark_test() log_test "TC $((vlan - 10)): marked packets $subtest'd" fi - stop_traffic sleep 1 } -do_drop_test() +do_mark_test() +{ + in_defer_scope \ + __do_mark_test "$@" +} + +__do_drop_test() { local vlan=$1; shift local limit=$1; shift @@ -637,6 +628,7 @@ do_drop_test() RET=0 start_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) $h3_mac + defer stop_traffic $! # Create a bit of a backlog and observe no mirroring due to drops. qevent_rule_install_$subtest @@ -672,10 +664,15 @@ do_drop_test() log_test "TC $((vlan - 10)): ${trigger}ped packets $subtest'd" - stop_traffic sleep 1 } +do_drop_test() +{ + in_defer_scope \ + __do_drop_test "$@" +} + qevent_rule_install_mirror() { tc filter add block 10 pref 1234 handle 102 matchall skip_sw \ diff --git a/tools/testing/selftests/drivers/net/mlxsw/sch_red_ets.sh b/tools/testing/selftests/drivers/net/mlxsw/sch_red_ets.sh index 576067b207a8..8902a115d9cd 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/sch_red_ets.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/sch_red_ets.sh @@ -80,36 +80,34 @@ uninstall_qdisc() ecn_test() { install_qdisc ecn + defer uninstall_qdisc do_ecn_test 10 $BACKLOG1 do_ecn_test 11 $BACKLOG2 - - uninstall_qdisc } ecn_test_perband() { install_qdisc ecn + defer uninstall_qdisc do_ecn_test_perband 10 $BACKLOG1 do_ecn_test_perband 11 $BACKLOG2 - - uninstall_qdisc } ecn_nodrop_test() { install_qdisc ecn nodrop + defer uninstall_qdisc do_ecn_nodrop_test 10 $BACKLOG1 do_ecn_nodrop_test 11 $BACKLOG2 - - uninstall_qdisc } red_test() { install_qdisc + defer uninstall_qdisc # Make sure that we get the non-zero value if there is any. local cur=$(busywait 1100 until_counter_is "> 0" \ @@ -120,50 +118,44 @@ red_test() do_red_test 10 $BACKLOG1 do_red_test 11 $BACKLOG2 - - uninstall_qdisc } mc_backlog_test() { install_qdisc + defer uninstall_qdisc # Note that the backlog numbers here do not correspond to RED # configuration, but are arbitrary. do_mc_backlog_test 10 $BACKLOG1 do_mc_backlog_test 11 $BACKLOG2 - - uninstall_qdisc } red_mirror_test() { install_qdisc qevent early_drop block 10 + defer uninstall_qdisc do_drop_mirror_test 10 $BACKLOG1 early_drop do_drop_mirror_test 11 $BACKLOG2 early_drop - - uninstall_qdisc } red_trap_test() { install_qdisc qevent early_drop block 10 + defer uninstall_qdisc do_drop_trap_test 10 $BACKLOG1 early_drop do_drop_trap_test 11 $BACKLOG2 early_drop - - uninstall_qdisc } ecn_mirror_test() { install_qdisc ecn qevent mark block 10 + defer uninstall_qdisc do_mark_mirror_test 10 $BACKLOG1 do_mark_mirror_test 11 $BACKLOG2 - - uninstall_qdisc } bail_on_lldpad "configure DCB" "configure Qdiscs" diff --git a/tools/testing/selftests/drivers/net/mlxsw/sch_red_root.sh b/tools/testing/selftests/drivers/net/mlxsw/sch_red_root.sh index 159108d02895..e9043771787b 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/sch_red_root.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/sch_red_root.sh @@ -32,45 +32,51 @@ uninstall_qdisc() ecn_test() { install_qdisc ecn + defer uninstall_qdisc + do_ecn_test 10 $BACKLOG - uninstall_qdisc } ecn_test_perband() { install_qdisc ecn + defer uninstall_qdisc + do_ecn_test_perband 10 $BACKLOG - uninstall_qdisc } ecn_nodrop_test() { install_qdisc ecn nodrop + defer uninstall_qdisc + do_ecn_nodrop_test 10 $BACKLOG - uninstall_qdisc } red_test() { install_qdisc + defer uninstall_qdisc + do_red_test 10 $BACKLOG - uninstall_qdisc } mc_backlog_test() { install_qdisc + defer uninstall_qdisc + # Note that the backlog value here does not correspond to RED # configuration, but is arbitrary. do_mc_backlog_test 10 $BACKLOG - uninstall_qdisc } red_mirror_test() { install_qdisc qevent early_drop block 10 + defer uninstall_qdisc + do_drop_mirror_test 10 $BACKLOG - uninstall_qdisc } bail_on_lldpad "configure DCB" "configure Qdiscs" diff --git a/tools/testing/selftests/net/forwarding/sch_red.sh b/tools/testing/selftests/net/forwarding/sch_red.sh index 17f28644568e..af166662b78a 100755 --- a/tools/testing/selftests/net/forwarding/sch_red.sh +++ b/tools/testing/selftests/net/forwarding/sch_red.sh @@ -53,71 +53,63 @@ PKTSZ=1400 h1_create() { simple_if_init $h1 192.0.2.1/28 + defer simple_if_fini $h1 192.0.2.1/28 + mtu_set $h1 10000 + defer mtu_restore $h1 + tc qdisc replace dev $h1 root handle 1: tbf \ rate 10Mbit burst 10K limit 1M -} - -h1_destroy() -{ - tc qdisc del dev $h1 root - mtu_restore $h1 - simple_if_fini $h1 192.0.2.1/28 + defer tc qdisc del dev $h1 root } h2_create() { simple_if_init $h2 192.0.2.2/28 + defer simple_if_fini $h2 192.0.2.2/28 + mtu_set $h2 10000 -} - -h2_destroy() -{ - mtu_restore $h2 - simple_if_fini $h2 192.0.2.2/28 + defer mtu_restore $h2 } h3_create() { simple_if_init $h3 192.0.2.3/28 + defer simple_if_fini $h3 192.0.2.3/28 + mtu_set $h3 10000 -} - -h3_destroy() -{ - mtu_restore $h3 - simple_if_fini $h3 192.0.2.3/28 + defer mtu_restore $h3 } switch_create() { ip link add dev br up type bridge + defer ip link del dev br + ip link set dev $swp1 up master br + defer ip link set dev $swp1 down nomaster + ip link set dev $swp2 up master br + defer ip link set dev $swp2 down nomaster + ip link set dev $swp3 up master br + defer ip link set dev $swp3 down nomaster mtu_set $swp1 10000 + defer mtu_restore $h1 + mtu_set $swp2 10000 + defer mtu_restore $h2 + mtu_set $swp3 10000 + defer mtu_restore $h3 tc qdisc replace dev $swp3 root handle 1: tbf \ rate 10Mbit burst 10K limit 1M + defer tc qdisc del dev $swp3 root + ip link add name _drop_test up type dummy -} - -switch_destroy() -{ - ip link del dev _drop_test - tc qdisc del dev $swp3 root - - mtu_restore $h3 - mtu_restore $h2 - mtu_restore $h1 - - ip link set dev $swp3 down nomaster - ip link set dev $swp2 down nomaster - ip link set dev $swp1 down nomaster - ip link del dev br + defer ip link del dev _drop_test } setup_prepare() @@ -134,6 +126,7 @@ setup_prepare() h3_mac=$(mac_get $h3) vrf_prepare + defer vrf_cleanup h1_create h2_create @@ -141,18 +134,6 @@ setup_prepare() switch_create } -cleanup() -{ - pre_cleanup - - switch_destroy - h3_destroy - h2_destroy - h1_destroy - - vrf_cleanup -} - ping_ipv4() { ping_test $h1 192.0.2.3 " from host 1" @@ -287,6 +268,7 @@ do_ecn_test() $MZ $h1 -p $PKTSZ -A 192.0.2.1 -B 192.0.2.3 -c 0 \ -a own -b $h3_mac -t tcp -q tos=0x01 & + defer stop_traffic $! sleep 1 ecn_test_common "$name" $limit @@ -298,9 +280,6 @@ do_ecn_test() build_backlog $((2 * limit)) udp >/dev/null check_fail $? "UDP traffic went into backlog instead of being early-dropped" log_test "$name backlog > limit: UDP early-dropped" - - stop_traffic - sleep 1 } do_ecn_nodrop_test() @@ -310,6 +289,7 @@ do_ecn_nodrop_test() $MZ $h1 -p $PKTSZ -A 192.0.2.1 -B 192.0.2.3 -c 0 \ -a own -b $h3_mac -t tcp -q tos=0x01 & + defer stop_traffic $! sleep 1 ecn_test_common "$name" $limit @@ -321,9 +301,6 @@ do_ecn_nodrop_test() build_backlog $((2 * limit)) udp >/dev/null check_err $? "UDP traffic was early-dropped instead of getting into backlog" log_test "$name backlog > limit: UDP not dropped" - - stop_traffic - sleep 1 } do_red_test() @@ -336,6 +313,7 @@ do_red_test() # is above limit. $MZ $h1 -p $PKTSZ -A 192.0.2.1 -B 192.0.2.3 -c 0 \ -a own -b $h3_mac -t tcp -q tos=0x01 & + defer stop_traffic $! # Pushing below the queue limit should work. RET=0 @@ -352,9 +330,6 @@ do_red_test() pct=$(check_marking "== 0") check_err $? "backlog $backlog / $limit Got $pct% marked packets, expected == 0." log_test "RED backlog > limit" - - stop_traffic - sleep 1 } do_red_qevent_test() @@ -369,6 +344,7 @@ do_red_qevent_test() $MZ $h1 -p $PKTSZ -A 192.0.2.1 -B 192.0.2.3 -c 0 \ -a own -b $h3_mac -t udp -q & + defer stop_traffic $! sleep 1 tc filter add block 10 pref 1234 handle 102 matchall skip_hw \ @@ -396,9 +372,6 @@ do_red_qevent_test() check_err $? "Dropped packets still observed: 0 expected, $((now - base)) seen" log_test "RED early_dropped packets mirrored" - - stop_traffic - sleep 1 } do_ecn_qevent_test() @@ -410,6 +383,7 @@ do_ecn_qevent_test() $MZ $h1 -p $PKTSZ -A 192.0.2.1 -B 192.0.2.3 -c 0 \ -a own -b $h3_mac -t tcp -q tos=0x01 & + defer stop_traffic $! sleep 1 tc filter add block 10 pref 1234 handle 102 matchall skip_hw \ @@ -428,9 +402,6 @@ do_ecn_qevent_test() tc filter del block 10 pref 1234 handle 102 matchall log_test "ECN marked packets mirrored" - - stop_traffic - sleep 1 } install_qdisc() @@ -451,36 +422,36 @@ uninstall_qdisc() ecn_test() { install_qdisc ecn + defer uninstall_qdisc xfail_on_slow do_ecn_test $BACKLOG - uninstall_qdisc } ecn_nodrop_test() { install_qdisc ecn nodrop + defer uninstall_qdisc xfail_on_slow do_ecn_nodrop_test $BACKLOG - uninstall_qdisc } red_test() { install_qdisc + defer uninstall_qdisc xfail_on_slow do_red_test $BACKLOG - uninstall_qdisc } red_qevent_test() { install_qdisc qevent early_drop block 10 + defer uninstall_qdisc xfail_on_slow do_red_qevent_test $BACKLOG - uninstall_qdisc } ecn_qevent_test() { install_qdisc ecn qevent mark block 10 + defer uninstall_qdisc xfail_on_slow do_ecn_qevent_test $BACKLOG - uninstall_qdisc } trap cleanup EXIT From patchwork Wed Oct 9 12:06:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13828259 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2059.outbound.protection.outlook.com [40.107.237.59]) (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 1C58D193419; Wed, 9 Oct 2024 12:10:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475811; cv=fail; b=hlPVQa1Ae7c74QYkVFZDjGkst0EnbhOl0U3+c4caIYPkXYn96EWBqpsmJEVh/lCLN8Km9nfl25f0zuQkDhAyKAkTNPMCy1aliyrrf0uXSAWYRfcbegN/pPk+MS1b6hCymi0R6hoSqwtTqadd33LF2phqZ3dGMa68O89u3dvdS+I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475811; c=relaxed/simple; bh=9XZWsVsdy78ua9m+mpDUI5r/ZCBzuBv9qeHo1cyy37U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PP4btKkhsICU/idikjLnIymaaIoDLlExS8/7VSyAuY2y1O1vCEAwWtqThnqUNkZKQDNCfomxfQn9VEKn+y9yZCuEErXiFlbMmJ8pYPFXfvD8o1Ml8iF8NOa7glxqg2u+bQqfXNfkpZI8qx74U1fkY2SpPeB1h9++AJ9QT8TADCU= 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=Btu8ZoTy; arc=fail smtp.client-ip=40.107.237.59 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="Btu8ZoTy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=a0lJ+p2E82iL4c8ZpOqxVd8KUgKDxyZxyFphlJ1sBNVEyhkY95QOyxxHj885TmVkRKTKnrtWnjtHcgDys56RLW6wLiJy3NnCM5HeB8D8Emjc7sHrWNYvxP2Lq5qzRwjudCSjqCIJr6gQG4lvuq6mZjaWY7lHacRsoIo2w/iqURYfXeXQnZzjepUHbCUnVdDpl9BCyefI+LBqH2EHqz03lZWUpySEAjI53k+NACFGaJO62ehpWPgy/0MOWyEcbIrmqvhPPAfp19020DwYA7lGs3zMYMCR5bOkhACHLgNZeq736f6WCOHd6jNccuqA6Dj+xABDdtVRBk2OnGLmNyL+Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=xSOfF2v7ewPViEBuf2+/sSDQpyGmcSLnmmrk3nLHXeQ=; b=VLd5SboJo3KR0f1SbSxksCtqrokrhZL0FTRn10fkMy6w1Pr+wTMyzCW/JIL+b/1GLUkUh0lFufnM+EW30sxKoVXOo50d05Cd1/kywxQJ15sxW99Qga/sPnKcz9JXGz3TunsxL7eD2lSwgIDpnI9WonXEw+J1kW5pepmo18apj7cg2MYnZtZaMXD9cu1IOQMhuVKDiSZlD0GGrapRwawhdckCsTYbKiUJAfDrCDx02PQX63u7fmoMsTxFJ1EXJc/NZVW3x3ETL6JOuL2GJWRXIVY3+IsxkRkSDgj7btatrJLh6f16V28IrB1jmFQoLcphqppTNFnH8louFWuhi7Vv7w== 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=xSOfF2v7ewPViEBuf2+/sSDQpyGmcSLnmmrk3nLHXeQ=; b=Btu8ZoTytpPrIlVnSBnmsxYMkMpZDxQsd+5tMjmFAb9VRY22eolFT/L1rR/Q+R3oZix01+Lh3qXiywE67eJZRxwFF1jNFA+NSm4Z3U5PcjygLxZJmP8vMiz81XNcQBLOuoZ1YvqcSR4yDQ/YTZ62AgvJZ3D/z90j0jYG9758GbViknt0a15HjbqM3Qs/TuHlADhQ0k1RCSb3nstx7X7kD5YNGuzvg3adIPt5IMeVX/7cMAKTMFNRGgWzTI4NFSufnagSvCLfHV/wpWpvxStf2hCYpcQb5GK+HwhHGYEhq+77SYkvIv5cW0ZNwjFU1SbEh6qU2l6RcQp3F+vfX2wCqA== Received: from CH3P221CA0016.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1e7::8) by MW6PR12MB9000.namprd12.prod.outlook.com (2603:10b6:303:24b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.23; Wed, 9 Oct 2024 12:10:05 +0000 Received: from DS2PEPF00003442.namprd04.prod.outlook.com (2603:10b6:610:1e7:cafe::14) by CH3P221CA0016.outlook.office365.com (2603:10b6:610:1e7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.24 via Frontend Transport; Wed, 9 Oct 2024 12:10:05 +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 DS2PEPF00003442.mail.protection.outlook.com (10.167.17.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 12:10:04 +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.1544.4; Wed, 9 Oct 2024 05:09:50 -0700 Received: from localhost.localdomain (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.1544.4; Wed, 9 Oct 2024 05:09:44 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: , Shuah Khan , "Benjamin Poirier" , Hangbin Liu , "Vladimir Oltean" , Ido Schimmel , "Przemek Kitszel" , Petr Machata , Subject: [PATCH net-next 05/10] selftests: TBF: Use defer for test cleanup Date: Wed, 9 Oct 2024 14:06:23 +0200 Message-ID: X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003442:EE_|MW6PR12MB9000:EE_ X-MS-Office365-Filtering-Correlation-Id: 906ce7f4-398a-41f9-8b13-08dce85b4f52 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: Rxcsz2iWmkTE0IlunWgoI/2c2AwFTg2TpxO3qafX9XwB8PSMlZdsH6yA1591H2Pc1TVcZx7RyEYgoNVKH85whZOD1GhSu68fvUwZp42XXFHG2K3IutvPvOIl5caYOlq62AtkIoUj20pJqBtuH13oLFTHrnujVhMaSwVEgUVoVmPL4CPvQE6UdhEudbythvplhzgSmE99wLVlIhY+8CqHQZtED8dKHf6V8e8+v5hCrailU/b9NgLCViA/F5TKrnzZjMPoFK8q2K0jllBWqOhfNrgnSiJYEzsuantEvbs9UWFRZWxbqUxpPjed1216fPDEGy2KgOr+1qxukfIi+VuT8h+KuMlCyqTMLG+8coVJvYGoSCkotTUDSz7xqlD1A7Ow/bTa0CmGm5Jg4mMLA00wlbdoWbJj2onYkOZTwmKr/8Fm/XkXDpIXbAD/pEM/jT9SkSwYTaVv9lelAJB6SXk669Str7yQ1DfqP0nfl5C+z8XFoY7jI0np8WMzgLzfAk19y2blL+UxBw3IgrMgQpPJ8SgVOZRgHYUliwwrm01u9lWcTKfkQ7mKO9zAtQ2qo2xUKHLwa1F3jGxoF4E45jJqkV9GQSsVREu+oXHnyIgYv1TaOaZ7vB/U0UpMH8bKt1tiLMuOnipXJKBCWk46IoRCu0X0XjJ7jURKng7IAdbJgR2MTqjoEza4zmAo7Wr3Rtri1KRfj13xRBSfPxpPhUPOM3fsYafeDoDXAf6bsAat0NTUIgPyLVKQGExkCHz0GCDWMFT+jddEh6QVXLzeWK9+F8QhPa0GL9GAP00VLRlb5CNXl8jTzwlSX7P6oD8ZNyCJsviYfM86KEln/CkVOjWmZMoBj7A02UN06P0irrl7gURN7nw1sBg51NCma6MgRcjNkphoO4zxZ45HJuaX3M/qjqlxer0KDS3fOcLp8n4MHz3IHyv0o/OUVlzcPWP/H42j97lUN0qbcNzlfZQzXCJkhJWYpkzOWMcOJ/BUnmnLKzCbQbck/cxWhf7U9XnFanFCR9QnE6Opj+vE4GfA5LYhbfg3jquA8X8AJKBbUMZ3dqFkuQVkEl1ikowouvQ87nc7MiKlPRFzMfsKnmAZvAkGbV9a/CnZJovixKkQTbiTgZAxOM3uzIRuBm3ZKkYNukq/DZrIeTHg8lqjtgjRCuws/MoW0mSmQMYvv2u2xx7vQeghmYQ1k+7/SdYdbuSUWcDBonMVJYqWBJxNIH17g18thgtjTW39OgfNWDTIt1QdQhbscuasSFkk+mJoLVNosqDcTsK/Hn78Auw2HNVnjlq4b1kRIqFT5oAyZDNLyilIHnWGxBLsSxTRjIFQYxCYm6cUxfwr95KJR6/gc291JEQev9M/jNFuiJRFZgJZNrplyr4= 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:(13230040)(376014)(7416014)(82310400026)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 12:10:04.8839 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 906ce7f4-398a-41f9-8b13-08dce85b4f52 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: DS2PEPF00003442.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB9000 Use the defer framework to schedule cleanups as soon as the command is executed. Signed-off-by: Petr Machata --- .../selftests/net/forwarding/sch_tbf_core.sh | 91 ++++++------------- .../net/forwarding/sch_tbf_etsprio.sh | 7 +- .../selftests/net/forwarding/sch_tbf_root.sh | 3 +- 3 files changed, 36 insertions(+), 65 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/sch_tbf_core.sh b/tools/testing/selftests/net/forwarding/sch_tbf_core.sh index 9cd884d4a5de..ec309a5086bc 100644 --- a/tools/testing/selftests/net/forwarding/sch_tbf_core.sh +++ b/tools/testing/selftests/net/forwarding/sch_tbf_core.sh @@ -60,68 +60,65 @@ host_create() local host=$1; shift simple_if_init $dev + defer simple_if_fini $dev + mtu_set $dev 10000 + defer mtu_restore $dev vlan_create $dev 10 v$dev $(ipaddr $host 10)/28 + defer vlan_destroy $dev 10 ip link set dev $dev.10 type vlan egress 0:0 vlan_create $dev 11 v$dev $(ipaddr $host 11)/28 + defer vlan_destroy $dev 11 ip link set dev $dev.11 type vlan egress 0:1 } -host_destroy() -{ - local dev=$1; shift - - vlan_destroy $dev 11 - vlan_destroy $dev 10 - mtu_restore $dev - simple_if_fini $dev -} - h1_create() { host_create $h1 1 } -h1_destroy() -{ - host_destroy $h1 -} - h2_create() { host_create $h2 2 tc qdisc add dev $h2 clsact + defer tc qdisc del dev $h2 clsact + tc filter add dev $h2 ingress pref 1010 prot 802.1q \ flower $TCFLAGS vlan_id 10 action pass tc filter add dev $h2 ingress pref 1011 prot 802.1q \ flower $TCFLAGS vlan_id 11 action pass } -h2_destroy() -{ - tc qdisc del dev $h2 clsact - host_destroy $h2 -} - switch_create() { local intf local vlan ip link add dev br10 type bridge + defer ip link del dev br10 + ip link add dev br11 type bridge + defer ip link del dev br11 for intf in $swp1 $swp2; do ip link set dev $intf up + defer ip link set dev $intf down + mtu_set $intf 10000 + defer mtu_restore $intf for vlan in 10 11; do vlan_create $intf $vlan + defer vlan_destroy $intf $vlan + ip link set dev $intf.$vlan master br$vlan + defer ip link set dev $intf.$vlan nomaster + ip link set dev $intf.$vlan up + defer ip link set dev $intf.$vlan down done done @@ -130,34 +127,10 @@ switch_create() done ip link set dev br10 up + defer ip link set dev br10 down + ip link set dev br11 up -} - -switch_destroy() -{ - local intf - local vlan - - # A test may have been interrupted mid-run, with Qdisc installed. Delete - # it here. - tc qdisc del dev $swp2 root 2>/dev/null - - ip link set dev br11 down - ip link set dev br10 down - - for intf in $swp2 $swp1; do - for vlan in 11 10; do - ip link set dev $intf.$vlan down - ip link set dev $intf.$vlan nomaster - vlan_destroy $intf $vlan - done - - mtu_restore $intf - ip link set dev $intf down - done - - ip link del dev br11 - ip link del dev br10 + defer ip link set dev br11 down } setup_prepare() @@ -177,23 +150,13 @@ setup_prepare() h2_mac=$(mac_get $h2) vrf_prepare + defer vrf_cleanup h1_create h2_create switch_create } -cleanup() -{ - pre_cleanup - - switch_destroy - h2_destroy - h1_destroy - - vrf_cleanup -} - ping_ipv4() { ping_test $h1.10 $(ipaddr 2 10) " vlan 10" @@ -207,18 +170,18 @@ tbf_get_counter() tc_rule_stats_get $h2 10$vlan ingress .bytes } -do_tbf_test() +__tbf_test() { local vlan=$1; shift local mbit=$1; shift start_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 2 $vlan) $h2_mac + defer stop_traffic $! sleep 5 # Wait for the burst to dwindle local t2=$(busywait_for_counter 1000 +1 tbf_get_counter $vlan) sleep 10 local t3=$(tbf_get_counter $vlan) - stop_traffic RET=0 @@ -231,3 +194,9 @@ do_tbf_test() log_test "TC $((vlan - 10)): TBF rate ${mbit}Mbit" } + +do_tbf_test() +{ + in_defer_scope \ + __tbf_test "$@" +} diff --git a/tools/testing/selftests/net/forwarding/sch_tbf_etsprio.sh b/tools/testing/selftests/net/forwarding/sch_tbf_etsprio.sh index df9bcd6a811a..c182a04282bc 100644 --- a/tools/testing/selftests/net/forwarding/sch_tbf_etsprio.sh +++ b/tools/testing/selftests/net/forwarding/sch_tbf_etsprio.sh @@ -30,8 +30,9 @@ tbf_test() # This test is used for both ETS and PRIO. Even though we only need two # bands, PRIO demands a minimum of three. tc qdisc add dev $swp2 root handle 10: $QDISC 3 priomap 2 1 0 + defer tc qdisc del dev $swp2 root + tbf_test_one 128K - tc qdisc del dev $swp2 root } tbf_root_test() @@ -42,6 +43,8 @@ tbf_root_test() tc qdisc replace dev $swp2 root handle 1: \ tbf rate 400Mbit burst $bs limit 1M + defer tc qdisc del dev $swp2 root + tc qdisc replace dev $swp2 parent 1:1 handle 10: \ $QDISC 3 priomap 2 1 0 tc qdisc replace dev $swp2 parent 10:3 handle 103: \ @@ -53,8 +56,6 @@ tbf_root_test() do_tbf_test 10 400 $bs do_tbf_test 11 400 $bs - - tc qdisc del dev $swp2 root } if type -t sch_tbf_pre_hook >/dev/null; then diff --git a/tools/testing/selftests/net/forwarding/sch_tbf_root.sh b/tools/testing/selftests/net/forwarding/sch_tbf_root.sh index 96c997be0d03..9f20320f8d84 100755 --- a/tools/testing/selftests/net/forwarding/sch_tbf_root.sh +++ b/tools/testing/selftests/net/forwarding/sch_tbf_root.sh @@ -14,13 +14,14 @@ tbf_test_one() tc qdisc replace dev $swp2 root handle 108: tbf \ rate 400Mbit burst $bs limit 1M + defer tc qdisc del dev $swp2 root + do_tbf_test 10 400 $bs } tbf_test() { tbf_test_one 128K - tc qdisc del dev $swp2 root } if type -t sch_tbf_pre_hook >/dev/null; then From patchwork Wed Oct 9 12:06:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13828260 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2069.outbound.protection.outlook.com [40.107.92.69]) (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 B68CA192B96; Wed, 9 Oct 2024 12:10:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475817; cv=fail; b=cPAYMFNvVWMFud8ii537msLGCKGv5m7yz4mEfuVQAT3l9YX0b4k29FXay20mBq5QvjUaDFMqgNQm5ln6m/uVTXOggsmm+dmtMCSFUosUpFQDKVhEHWfHwi0QiHvib1JR1bsmM7AFHxwv68NBufOUH66hV7JMKlJyGB5llWQQ2P8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475817; c=relaxed/simple; bh=QmP4JnLTev14VFwGS4zTXKTeNR1iLxBEnCTfB5mvUkc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IjeGOaPMJOsTSt9up4dOEOSJWyz06BnUjzEgnj87ux2MQ5RYFZLZAw13xLxXTnGklkKRzYA32J3b6+GISxkogyTOxurbKHyGWJ3UXHAdx1TeZO/qDVDHBuolvTPLBojOCansuk2G0THkSUhLzMTm9oP9K4QoBuL/EspZGPro2K4= 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=aLK7JcAb; arc=fail smtp.client-ip=40.107.92.69 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="aLK7JcAb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LaE4Ba0GaZMkCBiNQSVUVlRzDDR0kZsuDL2zeL52WSZcexmPlBK5oHqw4BA8Bx+JcIU0k6os3KsxA5pf9maupanN7vwjk0onEENQtbqTRfUFaJXIvUgxAyGi9mVEmv7WYk7H0diifE3lJZCt1y7hUOJtxIy0nP4hjLJiHRUufNoElHk87f15NWHFw5tcl64VHp/LzMK99yB14xV2xMrHFVQjRJCyF1jyPw37y1an3ZeQWVkvnCc3sJxcKPULmcFTZoyNuwK9+hIQYE0D/QkDT/tI6Phy4NU4ga+WwJSQp6RWaxFGYIrH0syYNF4+j/Jxp5dFMvDxHT2Wv67HKATHAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=XE4tiSQAFHiQC4a395xfqzFWq0VymUTdBw+LHLe9G9o=; b=FNF4ZWuncOtugKNvhcSzOMikKeXXZOjm6BN7bSZU/mcWQnZpAf4RLcp8TRHNrvXRJmD3YAgG7OWJffKUrRaH2Qu0yC5OIqoYfWtyRww5hs95jwof/mNtqzztFCOceh4F6WdBIfi+BAX5zjfKNgRv1N25xj8WvzCjkW7ZE0P1OJDeh8NPEs/0F6ihjzPu+j43FuK0cjOHHlaAwh5pllW/K0FnsKaBJlfBLS4/Gg6ZOyIoHLUcstw8sBm+yxmpJTcBtFGUDNqNmKDpnQTVOMSBDVobvsfXsAX39VTLtH65NHRNfo+C6PwcbpSXCY1extmDktyhG8HR2UIzePF5Zt+qqA== 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=XE4tiSQAFHiQC4a395xfqzFWq0VymUTdBw+LHLe9G9o=; b=aLK7JcAbGQgXZOzOLmOJn8SMVV5olyGGc3HdaDF6HkFkkHu70S4cy2WsziDMjmMoJZFaSsIhqqId9rC+zwy0QOL5S379FylOA1eGyCv0BiFSdMxZYC2V8V2dZimwc+12X3usnkb2jO7espjPT3eHao+xMlcBQOykhSzl4LEKp5oGKYl97PTijJYFO9dXfsbOkZ5+qMTKVOWDFTChKavMUHdhd7/i67vH2nj6jJUm7huYfmZ/VBiA55gb4AO3TosbncS+5M2LyV9BQZ7aIVTeTl2STLYQLP/SYyLOTA0goQrsmeo/6BnCU/hQMBhvwRu5lvuzevZQEkQTPpSWIqILiA== Received: from CH0PR03CA0449.namprd03.prod.outlook.com (2603:10b6:610:10e::25) by DM6PR12MB4354.namprd12.prod.outlook.com (2603:10b6:5:28f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 12:10:07 +0000 Received: from DS2PEPF00003448.namprd04.prod.outlook.com (2603:10b6:610:10e:cafe::f3) by CH0PR03CA0449.outlook.office365.com (2603:10b6:610:10e::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Wed, 9 Oct 2024 12:10: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 DS2PEPF00003448.mail.protection.outlook.com (10.167.17.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 12:10:07 +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.1544.4; Wed, 9 Oct 2024 05:09:57 -0700 Received: from localhost.localdomain (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.1544.4; Wed, 9 Oct 2024 05:09:51 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: , Shuah Khan , "Benjamin Poirier" , Hangbin Liu , "Vladimir Oltean" , Ido Schimmel , "Przemek Kitszel" , Petr Machata , Subject: [PATCH net-next 06/10] selftests: ETS: Use defer for test cleanup Date: Wed, 9 Oct 2024 14:06:24 +0200 Message-ID: X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003448:EE_|DM6PR12MB4354:EE_ X-MS-Office365-Filtering-Correlation-Id: 41399f9b-b815-4f5f-88a3-08dce85b50e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: trvOJDeecgIgGA4btrKqfj6Z2L8GuknJuKyfjBYJ0ZvWhohFSoukW0xVv9Y/I8GFPiIJLiPVg2j6vEreAh/g6Lhyw+uVnC62f08OTGmrkx8vish2FXit+xMqzajDjS0+TUvWSwXPGkDKGLgT7XNKj9U3XEjYSwEjzyAuO2jIvYE6AgV+DhQrZLZbR3XNbe27evzvGCiH8udKCYax5uA++ZsLFaCtpZCYc5G7lN+tGQeqkNy544dis4H0dBx/+exhe9VWUz+98ITJQ9zD9ADLAJUE+e/Ag6s829Hm5xyapI57l4akyy3gCRHcGRRLilty8hjaaRDebaG4Q9SqzTpvxRng+bXLwrLSPouvGEwTU/ldu3hQTQd18SoNrLrM8TZ+yHmQlWC53RahWJyC+Bih+Xg41+ggwlxbg0N63bb3nZ5Ay8WY7CsYlCbP2Cn8vjVpQ6uwcWJmviWjU0EALnw80ul71X7Y/48cIA+MsombJ1IFArg536uWPVZiTWYgO6PfjDiJ46RySbdfVS7TJseBNJvGLkMyp1GqhQSFrn/4nSSLNzz7O7dRF/lg01RxvQwjJenjQDYT19MlH0y0f+fZrvFWsPcwXX/eM4Tvz1qb6cXoVPjrS9dQ0jIp7qfb4dqiUSKSaB1AcXQPTpl0VQQwNe9DZ39aGmnZzBulztxDJh+VMeEiO57QyIN0f1s2moiLbX+JP/mgwyQOn3Jhnut4FaN7P+8RfyFdbSp1qjmOtI7iU1jSSCOob18hZc3bLa3Eh+v7ZNzTJXoLmGVpvowaPhkWN+TRBCrH1uvfSVxBiJYGbY0kOWLKFANN2mJxTUHSP+k7d18mgerL1IUdx0BCL2KAw/PZEwNm5j6aAIoAdD7Tfiw9ulB+zsE+T95HO38cLjZ+FDFFGeSjii4o56cIdYeoguSrcUSYN6FimN4VoUsw7nSJ0X0wG+PmUq3e/V81qNUTLgBQbz62ezWmKZyhLrDs2lYOkVwDAttTjzlIIyC5ohd1ZA8B8Odd7qVKMFTdvacugoGEFjWvVehc3tl0lTeedrRq8saRyXc9qmw8CpnIHKTxPhMK3NBbUMitXyfaz1ioIEQr4ckFfLUuAQ5LARG77kyPucG2ZVF6ma0nzemhQ2dxylT9cRyTCGJDwn2Ms532y6hIqj85nDF5PFtYl6He2GqwuAT74la9ffD5gjJHOolH3r2cE8QO0Q1emQzyWvQiUHfEM6OjyRxIlKD9/TiPH+hMN7P8KJG1glxX9FnZWYsccLJeuoHfqZyBil7MkW1n/3y7PmERvjHjHhKo3ddebEwVbwK4535YSbzX5MySVQdCQr13auerXVaxW+q5Qyh9j8ARto/KAZs+27mJqV02TNS7rlwwsxKZXVk8XYc= 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:(13230040)(376014)(7416014)(36860700013)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 12:10:07.5118 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41399f9b-b815-4f5f-88a3-08dce85b50e3 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: DS2PEPF00003448.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4354 Use the defer framework to schedule cleanups as soon as the command is executed. Signed-off-by: Petr Machata --- .../selftests/drivers/net/mlxsw/sch_ets.sh | 26 +++--- .../selftests/net/forwarding/sch_ets.sh | 7 +- .../selftests/net/forwarding/sch_ets_core.sh | 81 +++++++------------ .../selftests/net/forwarding/sch_ets_tests.sh | 14 ++-- 4 files changed, 50 insertions(+), 78 deletions(-) diff --git a/tools/testing/selftests/drivers/net/mlxsw/sch_ets.sh b/tools/testing/selftests/drivers/net/mlxsw/sch_ets.sh index 139175fd03e7..4aaceb6b2b60 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/sch_ets.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/sch_ets.sh @@ -21,6 +21,7 @@ switch_create() # Create a bottleneck so that the DWRR process can kick in. tc qdisc replace dev $swp2 root handle 3: tbf rate 1gbit \ burst 128K limit 1G + defer tc qdisc del dev $swp2 root handle 3: ets_switch_create @@ -30,16 +31,27 @@ switch_create() # for the DWRR process. devlink_port_pool_th_save $swp1 0 devlink_port_pool_th_set $swp1 0 12 + defer devlink_port_pool_th_restore $swp1 0 + devlink_tc_bind_pool_th_save $swp1 0 ingress devlink_tc_bind_pool_th_set $swp1 0 ingress 0 12 + defer devlink_tc_bind_pool_th_restore $swp1 0 ingress + devlink_port_pool_th_save $swp2 4 devlink_port_pool_th_set $swp2 4 12 + defer devlink_port_pool_th_restore $swp2 4 + devlink_tc_bind_pool_th_save $swp2 7 egress devlink_tc_bind_pool_th_set $swp2 7 egress 4 5 + defer devlink_tc_bind_pool_th_restore $swp2 7 egress + devlink_tc_bind_pool_th_save $swp2 6 egress devlink_tc_bind_pool_th_set $swp2 6 egress 4 5 + defer devlink_tc_bind_pool_th_restore $swp2 6 egress + devlink_tc_bind_pool_th_save $swp2 5 egress devlink_tc_bind_pool_th_set $swp2 5 egress 4 5 + defer devlink_tc_bind_pool_th_restore $swp2 5 egress # Note: sch_ets_core.sh uses VLAN ingress-qos-map to assign packet # priorities at $swp1 based on their 802.1p headers. ingress-qos-map is @@ -47,20 +59,6 @@ switch_create() # 1:1, which is the mapping currently hard-coded by the driver. } -switch_destroy() -{ - devlink_tc_bind_pool_th_restore $swp2 5 egress - devlink_tc_bind_pool_th_restore $swp2 6 egress - devlink_tc_bind_pool_th_restore $swp2 7 egress - devlink_port_pool_th_restore $swp2 4 - devlink_tc_bind_pool_th_restore $swp1 0 ingress - devlink_port_pool_th_restore $swp1 0 - - ets_switch_destroy - - tc qdisc del dev $swp2 root handle 3: -} - # Callback from sch_ets_tests.sh collect_stats() { diff --git a/tools/testing/selftests/net/forwarding/sch_ets.sh b/tools/testing/selftests/net/forwarding/sch_ets.sh index e60c8b4818cc..1f6f53e284b5 100755 --- a/tools/testing/selftests/net/forwarding/sch_ets.sh +++ b/tools/testing/selftests/net/forwarding/sch_ets.sh @@ -24,15 +24,10 @@ switch_create() # Create a bottleneck so that the DWRR process can kick in. tc qdisc add dev $swp2 root handle 1: tbf \ rate 1Gbit burst 1Mbit latency 100ms + defer tc qdisc del dev $swp2 root PARENT="parent 1:" } -switch_destroy() -{ - ets_switch_destroy - tc qdisc del dev $swp2 root -} - # Callback from sch_ets_tests.sh collect_stats() { diff --git a/tools/testing/selftests/net/forwarding/sch_ets_core.sh b/tools/testing/selftests/net/forwarding/sch_ets_core.sh index f906fcc66572..8f9922c695b0 100644 --- a/tools/testing/selftests/net/forwarding/sch_ets_core.sh +++ b/tools/testing/selftests/net/forwarding/sch_ets_core.sh @@ -166,89 +166,78 @@ h1_create() local i; simple_if_init $h1 + defer simple_if_fini $h1 + mtu_set $h1 9900 + defer mtu_restore $h1 + for i in {0..2}; do vlan_create $h1 1$i v$h1 $(sip $i)/28 + defer vlan_destroy $h1 1$i ip link set dev $h1.1$i type vlan egress 0:$i done } -h1_destroy() -{ - local i - - for i in {0..2}; do - vlan_destroy $h1 1$i - done - mtu_restore $h1 - simple_if_fini $h1 -} - h2_create() { local i simple_if_init $h2 + defer simple_if_fini $h2 + mtu_set $h2 9900 + defer mtu_restore $h2 + for i in {0..2}; do vlan_create $h2 1$i v$h2 $(dip $i)/28 + defer vlan_destroy $h2 1$i done } -h2_destroy() -{ - local i - - for i in {0..2}; do - vlan_destroy $h2 1$i - done - mtu_restore $h2 - simple_if_fini $h2 -} - ets_switch_create() { local i ip link set dev $swp1 up + defer ip link set dev $swp1 down + mtu_set $swp1 9900 + defer mtu_restore $swp1 ip link set dev $swp2 up + defer ip link set dev $swp2 down + mtu_set $swp2 9900 + defer mtu_restore $swp2 for i in {0..2}; do vlan_create $swp1 1$i + defer vlan_destroy $swp1 1$i ip link set dev $swp1.1$i type vlan ingress 0:0 1:1 2:2 vlan_create $swp2 1$i + defer vlan_destroy $swp2 1$i ip link add dev br1$i type bridge + defer ip link del dev br1$i + ip link set dev $swp1.1$i master br1$i + defer ip link set dev $swp1.1$i nomaster + ip link set dev $swp2.1$i master br1$i + defer ip link set dev $swp2.1$i nomaster ip link set dev br1$i up + defer ip link set dev br1$i down + ip link set dev $swp1.1$i up + defer ip link set dev $swp1.1$i down + ip link set dev $swp2.1$i up + defer ip link set dev $swp2.1$i down done -} -ets_switch_destroy() -{ - local i - - ets_delete_qdisc - - for i in {0..2}; do - ip link del dev br1$i - vlan_destroy $swp2 1$i - vlan_destroy $swp1 1$i - done - - mtu_restore $swp2 - ip link set dev $swp2 down - - mtu_restore $swp1 - ip link set dev $swp1 down + defer ets_delete_qdisc } setup_prepare() @@ -263,23 +252,13 @@ setup_prepare() hut=$h2 vrf_prepare + defer vrf_cleanup h1_create h2_create switch_create } -cleanup() -{ - pre_cleanup - - switch_destroy - h2_destroy - h1_destroy - - vrf_cleanup -} - ping_ipv4() { ping_test $h1.10 $(dip 0) " vlan 10" diff --git a/tools/testing/selftests/net/forwarding/sch_ets_tests.sh b/tools/testing/selftests/net/forwarding/sch_ets_tests.sh index f9d26a7911bb..08240d3e3c87 100644 --- a/tools/testing/selftests/net/forwarding/sch_ets_tests.sh +++ b/tools/testing/selftests/net/forwarding/sch_ets_tests.sh @@ -90,6 +90,7 @@ __ets_dwrr_test() for stream in ${streams[@]}; do ets_start_traffic $stream + defer stop_traffic $! done sleep 10 @@ -120,25 +121,24 @@ __ets_dwrr_test() ${d[0]} ${d[$i]} fi done - - for stream in ${streams[@]}; do - stop_traffic - done } ets_dwrr_test_012() { - __ets_dwrr_test 0 1 2 + in_defer_scope \ + __ets_dwrr_test 0 1 2 } ets_dwrr_test_01() { - __ets_dwrr_test 0 1 + in_defer_scope \ + __ets_dwrr_test 0 1 } ets_dwrr_test_12() { - __ets_dwrr_test 1 2 + in_defer_scope \ + __ets_dwrr_test 1 2 } ets_qdisc_setup() From patchwork Wed Oct 9 12:06:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13828261 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2085.outbound.protection.outlook.com [40.107.212.85]) (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 E177F19006F; Wed, 9 Oct 2024 12:10:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475825; cv=fail; b=JeWK2ntgqwr6qOE/Fw60m5taYvBuTNkKshzPmJdvkX/ukT9GYFaoM6znLNoALJqgXPoSLzfuboOKF3M5/4SUZzepElqVBvZUQUoezk6LQ7Y78RXyxWDOHCkYUbL4M81D/wBqrmrDk3RE+HZ5xe96my5IL86es3Ci7gOnfwU+DEw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475825; c=relaxed/simple; bh=4UNfkLX79XHO8aKgsnUpO3c4HNv3wG3RVLnm1Ac4Z9I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oT2Pt++sqa5/98TH6PyZ13rF5IKnN7I+xdE6BIx8L/h8/uTXRA8xoxBxMJzA2pekW7zRlNJm6kAh+dZ6YbMYx8rowk9Iyxp7Jf9/UXAKy+AauHqhDBbAo6C2pg96W8wPiKak3H6+WtFWTp+/f3hMVel+JXqgBl9j55aWvmTNFts= 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=pzuyFao+; arc=fail smtp.client-ip=40.107.212.85 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="pzuyFao+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=h2VvOLdPKD1yI1SMLKgt9fl/f6dbtPaSDU4RqFLns0KzBV+Bhof8eXnlsYPLgMe37wV+qTW5uCGsxv+HXdieaTPkJgWlDY0ENeh3yjlsXihNykxwOU8Kz98YNfxH1x0c27aD/3ZCODJunQ/tBylVF+MHP2DmZOfwSEmVQcABOli63jD7yiEC+xsGiy4AaY04NjhwzycgdzLEWxhZmTR3iK70pnTCfLfio5E0zId2eq3l6Kis+Kmwmk0fJ04Nk9XVGxbU67AxGZRyV3ZFhLsUf1vvD20WvK/AfYz4fnPCDeaSQIz79/7FZMhUTZiMmUrILeD8vMeta/y3uJLDW8KgVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=JgdWFkLtUuUoAJpufCbEn6aSijjX17z8SapfV8QrB5o=; b=ZJRhtg9NE6Gn4PgVfT/r7eykqbtwpQxE/HYo3wyTc+oOA0nu89iyyx611ADSm9O2G3ayvlcFJNjluOglQW3tFXhwXAFqfRd4LbqEL8/qSPFuMWpiE/aS+qO4U7MSU7xs8YUeND+nG/iRdPlUGHQIkGr4jn9QAIK3vt6ykKS3VWyPT2DVW5x0WYueK/1QK+mwgKfPv/0PNOcPqJbD0J/xuQiGrQiaCPKQYfXXFhOVHe5cLKheXdMFFZFSPEs4+EtHdJw2RbBVkkfb9btDVggktFWLya/KLv2dHf89O4KkCyZ0b+20q9hQAXIXoe/m4LoRShDZipF2Xkkd6pzbTVjwdw== 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=JgdWFkLtUuUoAJpufCbEn6aSijjX17z8SapfV8QrB5o=; b=pzuyFao+oofvmq/8A8U+PrIzeVV34SWkuqX0VcVTGqRX7gQwgYDF/j5/S0tMkmz0UnKPaE5qo3eWbMwANS0bD/WHtDMG2toHoSAjaTRpfNK29o1zNHtP/kmqeo5vD/I63pkKp4PYOP3GWEE4RfHP5QIctjhUI6qSpoCOUcGA1+6hbmR9T33qlhwOlb+PnGEGxCdkE8jhtECJTS/6rUOjwmgQ0i69iezxOYsUX9Sxs9pK2ZmXoyMUMeX40+YV7z1mAo2fdDQWdja+H7EY4271qWtUKKNBmGwhvLa2BSVX4rgpJNpgHSXO/9YsaTXuY7nBYMEQGZ7k1h3JBeCdFMRnAQ== Received: from CH0PR03CA0263.namprd03.prod.outlook.com (2603:10b6:610:e5::28) by SJ1PR12MB6026.namprd12.prod.outlook.com (2603:10b6:a03:48b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.22; Wed, 9 Oct 2024 12:10:17 +0000 Received: from DS2PEPF00003446.namprd04.prod.outlook.com (2603:10b6:610:e5:cafe::bb) by CH0PR03CA0263.outlook.office365.com (2603:10b6:610:e5::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Wed, 9 Oct 2024 12:10:16 +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 DS2PEPF00003446.mail.protection.outlook.com (10.167.17.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 12:10: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.1544.4; Wed, 9 Oct 2024 05:10:04 -0700 Received: from localhost.localdomain (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.1544.4; Wed, 9 Oct 2024 05:09:58 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: , Shuah Khan , "Benjamin Poirier" , Hangbin Liu , "Vladimir Oltean" , Ido Schimmel , "Przemek Kitszel" , Petr Machata , Subject: [PATCH net-next 07/10] selftests: mlxsw: qos_mc_aware: Use defer for test cleanup Date: Wed, 9 Oct 2024 14:06:25 +0200 Message-ID: X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003446:EE_|SJ1PR12MB6026:EE_ X-MS-Office365-Filtering-Correlation-Id: 7457bc28-5e09-43c1-842e-08dce85b563b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: N2X/WR6sf8kLEcGq6fiA8q0yQB3c9aJUJCI82+SCvsVeH+Qxsou6sxzk/a9oVICxZv4BM84Ds+6q6TwJYhlgSREM5QPPhhDC8FE2EGfU0Bn5EJ4J5oK0zeo96RNJOtmyH9NGYycQPgp2mrLw+0+WXSjMOEJuey6dFT9aGr18quoiRUqvnoW+yWh9kGiPpVtuSMRD0D6umpYmvWd28YG/DwgJzG7IzeCIb3+tO9B0MJ7+E8yshq0X+Dkj65EWYNHOk7gyyKqokbx/acd7BgLcSSjIic7/C8HrlC2wXJYIVSEocfNA2vYB+liRWiYYn0D8SmCspIIFtHpKevyJ6yKZF9KERblfBIe6gXw+K+a5VZfFmAWa51aqfWQPeH26w57YW3epwW1JVL6+//QAiZlY2vPCbKTr1qPkIbEmBIPrls7839hxTmFboqgFyQfMg/iPxMvQVoKhjjQrlHlPNd2K9ofWu6JF8Egx2lJfZbeL2TkMJqGUUBsoIcJO5VSJu+cKiHlFKuKiCGWpzdkKnzv0dhNZjCL0wvm8o13IxRKzB0SEZWmC+BWdYNiwDM0k8D3c+E84yllCDK91IzhHAnvsNSONRu/u+uKp9c/eYGnA5j7GJd/GXnKeIxFMiTdBMUyRP1DBkwh0WWL0pv3f9f1dcvZwbF3ZeP+yoGGg2Oy8c1uR7BdMxhYKvmS7H67Sf9gkw92OTXjPshjFhh8HO2nJMmVFmcBm927HweOq3JiuFtfIceBkPgU29ggneZthH2BzOi0QAlwt02hzVc1RtfhIngpQJLEckId0Bs3EpqafDmop1h0EU5W2NEKr0Tzvz5BCqUYvolckuhkZt+ycHe1zPqvT+HQQcS8qsJeYoNLEIMoDDwwzSyTy7esHpl5cZzAbrnMBtYsY/e49vP0Enf9BiosLrhmG+YLJjEdgniKR2ipzBVwnOfMFuTD9/2kzP2QKfuOfW2j5t4/kmiucxycJVwcj96oYo1FJ9uJyiOlxAZW2VZPV18P6ebsXXE/Z7iohEMMqLo/+ZKTDxsbG2JZK8E8EhmQ/GffKXfDzXoByXxyzQpVxrcVAzZ3azwNa/kB0mx9ZW+0AYx6en+nFr62MBFrKv2w7OUy3YhRkmI8c60zzWETtUSSKVnHr+f1/J3Bzuc1+7g7vUfdkvjg9OLkJDCmyfxNd1mjOFVDcSY9F9heEIqlmORsi4vCz4PJ/8DwJN1Ru9w1X40g/lCRTkveMeQ6jOv0LsD4mvPcNL2Q9JuBeFpK0nJnJdjV4K93DPxNlIppvnSCn719eQYwld/pzO3iBsFONFg46fkqnAdeveKPOYXiJRz1f2FiUdUFpjbWg31li25C5pLVMDoSTpqAax+L3BmrZPCXe6godoYZyFFQ= 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:(13230040)(82310400026)(36860700013)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 12:10:16.4770 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7457bc28-5e09-43c1-842e-08dce85b563b 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: DS2PEPF00003446.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6026 Use the defer framework to schedule cleanups as soon as the command is executed. Signed-off-by: Petr Machata --- .../drivers/net/mlxsw/qos_mc_aware.sh | 146 ++++++++---------- 1 file changed, 68 insertions(+), 78 deletions(-) diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh index 6d892de43fa8..cd4a5c21360c 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh @@ -73,122 +73,114 @@ source qos_lib.sh h1_create() { simple_if_init $h1 192.0.2.65/28 + defer simple_if_fini $h1 192.0.2.65/28 + mtu_set $h1 10000 -} - -h1_destroy() -{ - mtu_restore $h1 - simple_if_fini $h1 192.0.2.65/28 + defer mtu_restore $h1 } h2_create() { simple_if_init $h2 + defer simple_if_fini $h2 + mtu_set $h2 10000 + defer mtu_restore $h2 vlan_create $h2 111 v$h2 192.0.2.129/28 + defer vlan_destroy $h2 111 ip link set dev $h2.111 type vlan egress-qos-map 0:1 } -h2_destroy() -{ - vlan_destroy $h2 111 - - mtu_restore $h2 - simple_if_fini $h2 -} - h3_create() { simple_if_init $h3 192.0.2.66/28 + defer simple_if_fini $h3 192.0.2.66/28 + mtu_set $h3 10000 + defer mtu_restore $h3 vlan_create $h3 111 v$h3 192.0.2.130/28 -} - -h3_destroy() -{ - vlan_destroy $h3 111 - - mtu_restore $h3 - simple_if_fini $h3 192.0.2.66/28 + defer vlan_destroy $h3 111 } switch_create() { ip link set dev $swp1 up + defer ip link set dev $swp1 down + mtu_set $swp1 10000 + defer mtu_restore $swp1 ip link set dev $swp2 up + defer ip link set dev $swp2 down + mtu_set $swp2 10000 + defer mtu_restore $swp2 ip link set dev $swp3 up + defer ip link set dev $swp3 down + mtu_set $swp3 10000 + defer mtu_restore $swp3 vlan_create $swp2 111 + defer vlan_destroy $swp2 111 + vlan_create $swp3 111 + defer vlan_destroy $swp3 111 tc qdisc replace dev $swp3 root handle 3: tbf rate 1gbit \ burst 128K limit 1G + defer tc qdisc del dev $swp3 root handle 3: + tc qdisc replace dev $swp3 parent 3:3 handle 33: \ prio bands 8 priomap 7 7 7 7 7 7 7 7 + defer tc qdisc del dev $swp3 parent 3:3 handle 33: ip link add name br1 type bridge vlan_filtering 0 + defer ip link del dev br1 ip link set dev br1 addrgenmode none ip link set dev br1 up + ip link set dev $swp1 master br1 + defer ip link set dev $swp1 nomaster + ip link set dev $swp3 master br1 + defer ip link set dev $swp3 nomaster ip link add name br111 type bridge vlan_filtering 0 + defer ip link del dev br111 ip link set dev br111 addrgenmode none ip link set dev br111 up + ip link set dev $swp2.111 master br111 + defer ip link set dev $swp2.111 nomaster + ip link set dev $swp3.111 master br111 + defer ip link set dev $swp3.111 nomaster # Make sure that ingress quotas are smaller than egress so that there is # room for both streams of traffic to be admitted to shared buffer. devlink_port_pool_th_save $swp1 0 devlink_port_pool_th_set $swp1 0 5 + defer devlink_port_pool_th_restore $swp1 0 + devlink_tc_bind_pool_th_save $swp1 0 ingress devlink_tc_bind_pool_th_set $swp1 0 ingress 0 5 + defer devlink_tc_bind_pool_th_restore $swp1 0 ingress devlink_port_pool_th_save $swp2 0 devlink_port_pool_th_set $swp2 0 5 + defer devlink_port_pool_th_restore $swp2 0 + devlink_tc_bind_pool_th_save $swp2 1 ingress devlink_tc_bind_pool_th_set $swp2 1 ingress 0 5 + defer devlink_tc_bind_pool_th_restore $swp2 1 ingress devlink_port_pool_th_save $swp3 4 devlink_port_pool_th_set $swp3 4 12 -} - -switch_destroy() -{ - devlink_port_pool_th_restore $swp3 4 - - devlink_tc_bind_pool_th_restore $swp2 1 ingress - devlink_port_pool_th_restore $swp2 0 - - devlink_tc_bind_pool_th_restore $swp1 0 ingress - devlink_port_pool_th_restore $swp1 0 - - ip link del dev br111 - ip link del dev br1 - - tc qdisc del dev $swp3 parent 3:3 handle 33: - tc qdisc del dev $swp3 root handle 3: - - vlan_destroy $swp3 111 - vlan_destroy $swp2 111 - - mtu_restore $swp3 - ip link set dev $swp3 down - - mtu_restore $swp2 - ip link set dev $swp2 down - - mtu_restore $swp1 - ip link set dev $swp1 down + defer devlink_port_pool_th_restore $swp3 4 } setup_prepare() @@ -205,6 +197,7 @@ setup_prepare() h3mac=$(mac_get $h3) vrf_prepare + defer vrf_cleanup h1_create h2_create @@ -212,45 +205,45 @@ setup_prepare() switch_create } -cleanup() -{ - pre_cleanup - - switch_destroy - h3_destroy - h2_destroy - h1_destroy - - vrf_cleanup -} - ping_ipv4() { ping_test $h2 192.0.2.130 } -test_mc_aware() +__run_uc_measure_rate() { - RET=0 - + local what=$1; shift local -a uc_rate + start_traffic $h2.111 192.0.2.129 192.0.2.130 $h3mac - uc_rate=($(measure_rate $swp2 $h3 rx_octets_prio_1 "UC-only")) - check_err $? "Could not get high enough UC-only ingress rate" - stop_traffic + defer stop_traffic $! + + uc_rate=($(measure_rate $swp2 $h3 rx_octets_prio_1 "$what")) + check_err $? "Could not get high enough $what ingress rate" + + echo ${uc_rate[@]} +} + +run_uc_measure_rate() +{ + in_defer_scope __run_uc_measure_rate "$@" +} + +test_mc_aware() +{ + RET=0 + + local -a uc_rate=($(run_uc_measure_rate "UC-only")) local ucth1=${uc_rate[1]} start_traffic $h1 192.0.2.65 bc bc + defer stop_traffic $! local d0=$(date +%s) local t0=$(ethtool_stats_get $h3 rx_octets_prio_0) local u0=$(ethtool_stats_get $swp1 rx_octets_prio_0) - local -a uc_rate_2 - start_traffic $h2.111 192.0.2.129 192.0.2.130 $h3mac - uc_rate_2=($(measure_rate $swp2 $h3 rx_octets_prio_1 "UC+MC")) - check_err $? "Could not get high enough UC+MC ingress rate" - stop_traffic + local -a uc_rate_2=($(run_uc_measure_rate "UC+MC")) local ucth2=${uc_rate_2[1]} local d1=$(date +%s) @@ -272,8 +265,6 @@ test_mc_aware() local mc_ir=$(rate $u0 $u1 $interval) local mc_er=$(rate $t0 $t1 $interval) - stop_traffic - log_test "UC performance under MC overload" echo "UC-only throughput $(humanize $ucth1)" @@ -297,6 +288,7 @@ test_uc_aware() RET=0 start_traffic $h2.111 192.0.2.129 192.0.2.130 $h3mac + defer stop_traffic $! local d0=$(date +%s) local t0=$(ethtool_stats_get $h3 rx_octets_prio_1) @@ -326,8 +318,6 @@ test_uc_aware() ((attempts == passes)) check_err $? - stop_traffic - log_test "MC performance under UC overload" echo " ingress UC throughput $(humanize ${uc_ir})" echo " egress UC throughput $(humanize ${uc_er})" From patchwork Wed Oct 9 12:06:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13828262 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2063.outbound.protection.outlook.com [40.107.236.63]) (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 9393A190072; Wed, 9 Oct 2024 12:10:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475832; cv=fail; b=X0VUmVU/JqIK1+XF78sqgZvduxowvAyVsHMowkpe91kS6kYhu1jCL4T5/n1E7OyPL2GY0GqvuWuniSsKx4Y/P4xYJNP2R1KsNlGpsvPQo0c7zEzugBC9TcZWqXCr/+qtJ+25cBi6sRB+O72SH/KqTzcicLgJYyMGEeRoxk/pQXQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475832; c=relaxed/simple; bh=rpy+x0vc78lZ4LbaVLMTj0KPKBxawl7m5ERl5vdien8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZBR+L3R/1Dk3zfgIkpN/A0pEruape+uOAreGP5qFr78EoJrma9hKSOGP+fdcy9Cn6d3aiLMGMa2AMzk5sFL6u/TLlwOcZzLyJ2/pR49kpHygp2yoCO7d1BhVhBibIgTzrrfRyzNmvMfuBM6nd/QtDGU5HbiInKSAKI0/RDN5AAU= 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=flTHLlHb; arc=fail smtp.client-ip=40.107.236.63 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="flTHLlHb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=asVgra5A2OJW2k5FW4dcxTREy+HzfNXs5SgnlJhOFnJdm1zQ0jJXhg5cJZUiV2+DMpSusjRwj9Mk4qDKKGAopfpdHT/RNHhtlNbe+ITU0XgYF0CSoJmGT1sN8aPAaMvqv6mpyy5dYrZvPWHrMBj32qzpJD56Mn6w+6iK9sUkV/4dJpMF/vGQHXxOVDWQFbD5s5lVSLdUxQ09wSlnz1UKH9kFPCNIlNgw/TFHMxsLhRvzGefiqCauAX//inKjcVXxu4MgGtQkU2bBjj+o7N7N/HqDFiqui4x4V7X5gKLEMeQZLzRm2e/rfyoxCpCsyIdbor3h4iSl2SwVJYK5HtiULw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=A0UuiXORT+ug6c0oBl32NLkP0UqjlEWaC7OnNoaxuUE=; b=F/2s+yivFLmRHKWb7EBIzsdBskNRtpigEDewaZJyExH+lLwkjUzkPF3kc2xf4ZVAF7ciHASSpflX7s+E3V/RHrMGMWKoFfjHxmYcEFoJHdOCurLcYenJHgSUswDXrOVXtrI/soIAhrW24uZ2LFLH3F+afcASWVBmxpgnCOvntexPGKwVaCV0i7l9yyJvBzBWKFA9s3iQGU5cOINSPcpqZjH1GsMdJIBt1g5PZU3dXq1y/2ldgYEnakMCiw9+4ohtZYqr/9QjcFtftUyb+SUIK1WdokBtQcvHPYW7RoM6EteC21NbtMCmuilv4xthnlxSlVu189XlPYBEV+HjlhF4/A== 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=A0UuiXORT+ug6c0oBl32NLkP0UqjlEWaC7OnNoaxuUE=; b=flTHLlHb0tj5WFtv6flS9eGGNPLfVE8I9X9rHtaEcAe91GV17PGBrh5rj/V6uk1DAlAxkQGPZWAK2BJDWyh4WI11ZjnnMT6sVL8gGSNSYpQqMRWD+bAYEzSqB3Cbz7COrbqdzbm6YPkleBHXY3Kf98cpQaqfFQWNWu/ZRVzmFaI5m2epYBpKd28L4IhrnAGdDIEU3N+A6RHnRctaK9s4+1Cp/yp4E31Mz2GdfZir4I57D4xZ303SSFrEEhaqETodW78fZk8X3lVk9aTk3msiU+61XiP0j/rhIK4P8Lkj1D1Ch2ueWLZ0c7cL4mBhCTiEk1U2ydvplUkoQl/d/dTmbw== Received: from CH0PR03CA0444.namprd03.prod.outlook.com (2603:10b6:610:10e::12) by PH7PR12MB8108.namprd12.prod.outlook.com (2603:10b6:510:2bc::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Wed, 9 Oct 2024 12:10:26 +0000 Received: from DS2PEPF00003448.namprd04.prod.outlook.com (2603:10b6:610:10e:cafe::9f) by CH0PR03CA0444.outlook.office365.com (2603:10b6:610:10e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Wed, 9 Oct 2024 12:10:25 +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 DS2PEPF00003448.mail.protection.outlook.com (10.167.17.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 12:10:25 +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.1544.4; Wed, 9 Oct 2024 05:10:11 -0700 Received: from localhost.localdomain (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.1544.4; Wed, 9 Oct 2024 05:10:04 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: , Shuah Khan , "Benjamin Poirier" , Hangbin Liu , "Vladimir Oltean" , Ido Schimmel , "Przemek Kitszel" , Petr Machata , Subject: [PATCH net-next 08/10] selftests: mlxsw: qos_ets_strict: Use defer for test cleanup Date: Wed, 9 Oct 2024 14:06:26 +0200 Message-ID: <2c6f94b03d019ee4244459bb0829fcd70134c91c.1728473602.git.petrm@nvidia.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003448:EE_|PH7PR12MB8108:EE_ X-MS-Office365-Filtering-Correlation-Id: f25e14c8-cb95-401a-aaa2-08dce85b5bc6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: 6R6fiCP5jcHnwBNTsbf3P6azc3TlYuFC8UpFgoXr/C4lSfRFsqK/2ZQS7aqtZVvBgAknxOsNHBfrsslJ6udoD+hxyBNFEfadPcnqRK1f9zrlOoM3iAWK7XcJ3ojkpsCMEK0b0ZBGWrutxc3dYOPNtslo/oXM19gPnSNJ3tjn04OEtnLsmP4MBaNBfsWmyfcyWr+9lj5BK7gpN6MD5cKahCvMdzlLGJaJIm+vmWV1P62l14X35Vhil397jLs8jVZCpEEt4RXbNg5gX9dwNMFAce6VE1xe20ljqS9eFny0j70O1mn7Ocm+dYip6iABJ3mB9hhoowhqzjnT2m3eF9an2Sf4P3bfgopCeaznRBx3VfccfqUcDMgfLDV4cnLvfSCzFOudAxOUvoYgYnZZnuTlUZ8kZdL5uRnMc6voUfgImJa175hlbK0HEyNxiV9Q9eZrBnzbEiHY9gZtsuQdAbqXrkhrmUqx4sO9vDcnD6fkUVG3Q0lQW3nrDNgywfYpCYdnTZGejcfnhhgPUa9A/BoAYr1ZTYuZu534rY8Tm8eFuBvJkc7N0uhSlZRBnKSScgUXKVYdtlHUP1w6eU83o1S9Es7JwhogZoogh4EVG/5xAQoWS+ug8ztQa072fH7OYRwmQ55s32a16CEAwRA/8L9i2yTMRverSkYdfpQElLDG7YFJ4gypqfWn/RvqqtQErva8ujP2pI7Dd8RCm9I/GBMiR1wG3GUgLadktSFYL05c5hjWkKsbJSXt3kIyhpiMmt/In/cCblwkY/Sf+y0I4iMLx1S6fcqS9LKOpkvUMd4f3/wkw6Cin0bBQjTFQow7Jc/6V01eZEPt8ssW7fk3QZ0804+LkVVOmxXyRODao3PtINPXStRz5LaIeg4ssbHnAZR9INTeMFG1gIJoGWkot8cYvmuOQHPG10H4MGHriI1EANV+fuAVRVI6jn1gUDO0T3OCcwvTY3wl+09HWZpUfTZm9Iep6RsiJ4l6zZNlZvdpAXlZBtWLE5lHyWW80A2EgLtpbZuHLzJRvJjFRTUjZkvmvNVo7g3MM48eGvj/85BVc49kmEmGcR9Z7ZBN/aeAdRC56RqrV2td9ndYAPm2x7rUYjJ47JmqNrzGLdY8eEVf9108t95Fk0/CYkb9teKJqoA236SOVmh87rCd5Wm8MUhy4Cdx1XD9Lu2skdks1WS23TNtmaymPWa5z2vyelCI5FhKYyYFrqhExzS8FYvzvNSWToEF4124Z2IINB/jhwC32on2HXHSDXnMl7i8MFLz95CKAQLdLMgma560Qmqh0MT/+ydHpNGZzTgqKVDLg5b9yJLX54A2uLoY2yLW5PFE2DZ9EVP4K6i86oDtKtkuye/yW0vwrk21KpFWqao6ck6KxGw= 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:(13230040)(1800799024)(7416014)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 12:10:25.7775 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f25e14c8-cb95-401a-aaa2-08dce85b5bc6 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: DS2PEPF00003448.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8108 Use the defer framework to schedule cleanups as soon as the command is executed. Signed-off-by: Petr Machata --- .../drivers/net/mlxsw/qos_ets_strict.sh | 167 +++++++++--------- 1 file changed, 85 insertions(+), 82 deletions(-) diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_ets_strict.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_ets_strict.sh index fee74f215cec..d5b6f2cc9a29 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/qos_ets_strict.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/qos_ets_strict.sh @@ -58,65 +58,62 @@ source qos_lib.sh h1_create() { simple_if_init $h1 + defer simple_if_fini $h1 + mtu_set $h1 10000 + defer mtu_restore $h1 vlan_create $h1 111 v$h1 192.0.2.33/28 + defer vlan_destroy $h1 111 ip link set dev $h1.111 type vlan egress-qos-map 0:1 } -h1_destroy() -{ - vlan_destroy $h1 111 - - mtu_restore $h1 - simple_if_fini $h1 -} - h2_create() { simple_if_init $h2 + defer simple_if_fini $h2 + mtu_set $h2 10000 + defer mtu_restore $h2 vlan_create $h2 222 v$h2 192.0.2.65/28 + defer vlan_destroy $h2 222 ip link set dev $h2.222 type vlan egress-qos-map 0:2 } -h2_destroy() -{ - vlan_destroy $h2 222 - - mtu_restore $h2 - simple_if_fini $h2 -} - h3_create() { simple_if_init $h3 + defer simple_if_fini $h3 + mtu_set $h3 10000 + defer mtu_restore $h3 vlan_create $h3 111 v$h3 192.0.2.34/28 + defer vlan_destroy $h3 111 + vlan_create $h3 222 v$h3 192.0.2.66/28 -} - -h3_destroy() -{ - vlan_destroy $h3 222 - vlan_destroy $h3 111 - - mtu_restore $h3 - simple_if_fini $h3 + defer vlan_destroy $h3 222 } switch_create() { ip link set dev $swp1 up + defer ip link set dev $swp1 down + mtu_set $swp1 10000 + defer mtu_restore $swp1 ip link set dev $swp2 up + defer ip link set dev $swp2 down + mtu_set $swp2 10000 + defer mtu_restore $swp2 # prio n -> TC n, strict scheduling lldptool -T -i $swp3 -V ETS-CFG up2tc=0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7 + defer lldptool -T -i $swp3 -V ETS-CFG up2tc=0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0 + lldptool -T -i $swp3 -V ETS-CFG tsa=$( )"0:strict,"$( )"1:strict,"$( @@ -129,85 +126,90 @@ switch_create() sleep 1 ip link set dev $swp3 up + defer ip link set dev $swp3 down + mtu_set $swp3 10000 + defer mtu_restore $swp3 + tc qdisc replace dev $swp3 root handle 101: tbf rate 1gbit \ burst 128K limit 1G + defer tc qdisc del dev $swp3 root handle 101: vlan_create $swp1 111 + defer vlan_destroy $swp1 111 + vlan_create $swp2 222 + defer vlan_destroy $swp2 222 + vlan_create $swp3 111 + defer vlan_destroy $swp3 111 + vlan_create $swp3 222 + defer vlan_destroy $swp3 222 ip link add name br111 type bridge vlan_filtering 0 + defer ip link del dev br111 ip link set dev br111 addrgenmode none + ip link set dev br111 up + defer ip link set dev br111 down + ip link set dev $swp1.111 master br111 + defer ip link set dev $swp1.111 nomaster + ip link set dev $swp3.111 master br111 + defer ip link set dev $swp3.111 nomaster ip link add name br222 type bridge vlan_filtering 0 + defer ip link del dev br222 ip link set dev br222 addrgenmode none + ip link set dev br222 up + defer ip link set dev br222 down + ip link set dev $swp2.222 master br222 + defer ip link set dev $swp2.222 nomaster + ip link set dev $swp3.222 master br222 + defer ip link set dev $swp3.222 nomaster # Make sure that ingress quotas are smaller than egress so that there is # room for both streams of traffic to be admitted to shared buffer. devlink_pool_size_thtype_save 0 devlink_pool_size_thtype_set 0 dynamic 10000000 + defer devlink_pool_size_thtype_restore 0 + devlink_pool_size_thtype_save 4 devlink_pool_size_thtype_set 4 dynamic 10000000 + defer devlink_pool_size_thtype_restore 4 devlink_port_pool_th_save $swp1 0 devlink_port_pool_th_set $swp1 0 6 + defer devlink_port_pool_th_restore $swp1 0 + devlink_tc_bind_pool_th_save $swp1 1 ingress devlink_tc_bind_pool_th_set $swp1 1 ingress 0 6 + defer devlink_tc_bind_pool_th_restore $swp1 1 ingress devlink_port_pool_th_save $swp2 0 devlink_port_pool_th_set $swp2 0 6 + defer devlink_port_pool_th_restore $swp2 0 + devlink_tc_bind_pool_th_save $swp2 2 ingress devlink_tc_bind_pool_th_set $swp2 2 ingress 0 6 + defer devlink_tc_bind_pool_th_restore $swp2 2 ingress devlink_tc_bind_pool_th_save $swp3 1 egress devlink_tc_bind_pool_th_set $swp3 1 egress 4 7 + defer devlink_tc_bind_pool_th_restore $swp3 1 egress + devlink_tc_bind_pool_th_save $swp3 2 egress devlink_tc_bind_pool_th_set $swp3 2 egress 4 7 + defer devlink_tc_bind_pool_th_restore $swp3 2 egress + devlink_port_pool_th_save $swp3 4 devlink_port_pool_th_set $swp3 4 7 -} - -switch_destroy() -{ - devlink_port_pool_th_restore $swp3 4 - devlink_tc_bind_pool_th_restore $swp3 2 egress - devlink_tc_bind_pool_th_restore $swp3 1 egress - - devlink_tc_bind_pool_th_restore $swp2 2 ingress - devlink_port_pool_th_restore $swp2 0 - - devlink_tc_bind_pool_th_restore $swp1 1 ingress - devlink_port_pool_th_restore $swp1 0 - - devlink_pool_size_thtype_restore 4 - devlink_pool_size_thtype_restore 0 - - ip link del dev br222 - ip link del dev br111 - - vlan_destroy $swp3 222 - vlan_destroy $swp3 111 - vlan_destroy $swp2 222 - vlan_destroy $swp1 111 - - tc qdisc del dev $swp3 root handle 101: - mtu_restore $swp3 - ip link set dev $swp3 down - lldptool -T -i $swp3 -V ETS-CFG up2tc=0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0 - - mtu_restore $swp2 - ip link set dev $swp2 down - - mtu_restore $swp1 - ip link set dev $swp1 down + defer devlink_port_pool_th_restore $swp3 4 } setup_prepare() @@ -224,6 +226,7 @@ setup_prepare() h3mac=$(mac_get $h3) vrf_prepare + defer vrf_cleanup h1_create h2_create @@ -231,18 +234,6 @@ setup_prepare() switch_create } -cleanup() -{ - pre_cleanup - - switch_destroy - h3_destroy - h2_destroy - h1_destroy - - vrf_cleanup -} - ping_ipv4() { ping_test $h1 192.0.2.34 " from H1" @@ -261,21 +252,38 @@ rel() " } +__run_hi_measure_rate() +{ + local what=$1; shift + local -a uc_rate + + start_traffic $h2.222 192.0.2.65 192.0.2.66 $h3mac + defer stop_traffic $! + + uc_rate=($(measure_rate $swp2 $h3 rx_octets_prio_2 "$what")) + check_err $? "Could not get high enough $what ingress rate" + + echo ${uc_rate[@]} +} + +run_hi_measure_rate() +{ + in_defer_scope __run_hi_measure_rate "$@" +} + test_ets_strict() { RET=0 # Run high-prio traffic on its own. - start_traffic $h2.222 192.0.2.65 192.0.2.66 $h3mac local -a rate_2 - rate_2=($(measure_rate $swp2 $h3 rx_octets_prio_2 "prio 2")) - check_err $? "Could not get high enough prio-2 ingress rate" + rate_2=($(run_hi_measure_rate "prio 2")) local rate_2_in=${rate_2[0]} local rate_2_eg=${rate_2[1]} - stop_traffic # $h2.222 # Start low-prio stream. start_traffic $h1.111 192.0.2.33 192.0.2.34 $h3mac + defer stop_traffic $! local -a rate_1 rate_1=($(measure_rate $swp1 $h3 rx_octets_prio_1 "prio 1")) @@ -290,14 +298,9 @@ test_ets_strict() check_err $(bc <<< "$rel21 > 105") # Start the high-prio stream--now both streams run. - start_traffic $h2.222 192.0.2.65 192.0.2.66 $h3mac - rate_3=($(measure_rate $swp2 $h3 rx_octets_prio_2 "prio 2 w/ 1")) - check_err $? "Could not get high enough prio-2 ingress rate with prio-1" + rate_3=($(run_hi_measure_rate "prio 2+1")) local rate_3_in=${rate_3[0]} local rate_3_eg=${rate_3[1]} - stop_traffic # $h2.222 - - stop_traffic # $h1.111 # High-prio should have about the same throughput whether or not # low-prio is in the system. From patchwork Wed Oct 9 12:06:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13828264 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2074.outbound.protection.outlook.com [40.107.96.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 C83CB19006F; Wed, 9 Oct 2024 12:10:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475844; cv=fail; b=kTF/Ry9FsiAkZm2Kh5k2XpQr5in87R3ULZXrDxR1r2wCi47Kc9PM+Sm0C+z2Tow+6pL8rIMDJjaC6FTXlsgF0chkvu8WRab5Sg44XcFt4G7FrjLwl7OQYQpuFFtQiRMwqnGYP9g82vKrL6tvtf9xYw4BK6aBdylTk9y50VNDl00= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475844; c=relaxed/simple; bh=9PGRiBQm/ApCeGx5PATZWY6/Ljsu3RCC40RCRLULLhQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iFNWCYrH9XBDSRifu3d2910+avxmBRBCzZf8pTmud4vK2WL8DCwnA9GAwOIUcVzEvX6KntLIle/tYriMXmAmBufdQMmhX/XArGFUjcTTjf9vVKk+nO5LtjgtIeUGlUi29kGGw2nPJe4LIE7d6DuyX6WNZTK4R6pzdMGnK4KoNk8= 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=cQqwm/g+; arc=fail smtp.client-ip=40.107.96.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="cQqwm/g+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=r2uX2f4WcCcKWvqYguwTaMdm2rH94ie4rE/E/wsCIFx6CrzPsWl9GolvugoL6lcajdV75yUAWvq5/CNymVHjyJaih6NCXhUpKI5h6G4gBknQzwNNw63p4LcB+oj5OaUzsmHZYRxz6T3GdIUWmW5CZOSsPWQgngAVELk+aCo1KGXzUeqwvW/q3spXNFQttqQSI/7aFqA/mwbpXtT4h9aOm0mu2nozGqR52Aaoqu3ksGXb4Zwfq7DrwEq7o7+eSdx0EFVs2ZIkhgwl5hMzknvlvtxglzw3wc8H3DSF6R/iF0kIKQchhuTbovqv2v10IXVxU0eDyEc/mDUzzn3XzqtbvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=q/1i1D71+QW3wXnzlxEgi0qBWvlZaqrZR/7tsBQ6nkQ=; b=y/fEFMSwunj40QIESce9OPQ+riMOtbMNKYNhqLPq1n4/tNw5WbwnkWs74Nl2LVcBjEvwnF/pTUDgTbOZSB7uexFiOITfNraah6XLvaFOv3TzmOufhTMKSGplGxscmXQ3T9t92at7AxGKQ3DPEIaOXiRYEskLx/cJ+njeolzzScyhN04QFYhpmPKUD8j6M4AFh7BzQKyurC8ZWovOw64K/TYufyv6sYtgStxJjYHXj7MeXqMxOB1K29A8qHqxOb2jkcZrHhvYZir57aPYK4Ecge/KP30dekJ965Fl5i1Q9RzWXvZI4/XiPF3X1HTW5cuILy3L6QijzUwJScE6VRqIqA== 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=q/1i1D71+QW3wXnzlxEgi0qBWvlZaqrZR/7tsBQ6nkQ=; b=cQqwm/g+KXlpCaGxDkhI6kByQcd6JSi+qqSgxTytCbisURIukJGEBLLe/8X0WSzlA7sGOe/CPpAJ4Q+Fn9Re3A4nAP8TVx1MIQ7J2c7tdRGoPBlh1awCazrB6/8zkNhfLTA01whZB1hy4hkLD0ZCbYKua3V8CJ6XUPmuKZcAxY71TsrXco3jhgA8TIP7+xZgtJx7zsZ3dsah+/z0TxuI9SMqhRM3wOYFnRPWXPBOrPQKwstqs19LZtNU35cdi5almib/06rTcHzVqEUW8qNo0br0AO3dkx2xM6SX28VWtpX/2wOGwlUGWvJi8Yr6AVwcsw6CFTkM/qsFkJTZSg18EA== Received: from DM6PR02CA0060.namprd02.prod.outlook.com (2603:10b6:5:177::37) by CY8PR12MB7633.namprd12.prod.outlook.com (2603:10b6:930:9c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Wed, 9 Oct 2024 12:10:36 +0000 Received: from DS2PEPF00003445.namprd04.prod.outlook.com (2603:10b6:5:177:cafe::60) by DM6PR02CA0060.outlook.office365.com (2603:10b6:5:177::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Wed, 9 Oct 2024 12:10:36 +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 DS2PEPF00003445.mail.protection.outlook.com (10.167.17.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 12:10:36 +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.1544.4; Wed, 9 Oct 2024 05:10:19 -0700 Received: from localhost.localdomain (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.1544.4; Wed, 9 Oct 2024 05:10:11 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: , Shuah Khan , "Benjamin Poirier" , Hangbin Liu , "Vladimir Oltean" , Ido Schimmel , "Przemek Kitszel" , Petr Machata , Subject: [PATCH net-next 09/10] selftests: mlxsw: qos_max_descriptors: Use defer for test cleanup Date: Wed, 9 Oct 2024 14:06:27 +0200 Message-ID: <1871e147c5f3ea3af68bd5fbc7285895d123d869.1728473602.git.petrm@nvidia.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003445:EE_|CY8PR12MB7633:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a41d884-3257-4ed7-8177-08dce85b620c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: 3h0S6WqCRHXpUNIODYRCY2FfeXIN5V9FJP7Z35CxfXsBcG+JlYHV3hpOosIlT91D1Bkqmwi6LffqWWyWYQqIfXnvRCFQB/xCgqCGNqYkil/QO7T9VIIrVpBEfZmezmbjNTDytH3RMh27ym2oy1lbjGEipoXL0Lwe78z/zepbq9pJqgsRRMSUSHyobXmOXdMLhDsapTsmp7DzQgAPUoItUXrB273TH/2lx1Auon4q2PLKhryyv02GqLx+Xd/FsLPZz9J3zxyV0hx3A+ugiPfKtDH76MiemYusKy6huYo9HT0Sy1KeXktr+i/iKknFIh88Jl3dLHEVKsojXFLwbXuLvcyEancDopEk74e6ZNhGbzBSD8QSEZkDldM+4lNCaRYRI/V5ggnFbYlyytP2aWfelyn2t0Rcb7VqUIJTSMBHL81GmviGtnWtP1iHvdAM9ZY4pvDm6lIfLT7Ojj8aCd5ZPh0K8OQOZvV6pO6l7MhPhN0z86TP/OGYq0bMEGvq1Wc4I2cnFTQxN3djYEbQH54F2a3qnRHlG2xze9hYt570842smvPwQyfCMN6N1lEWy6V49hGeAWwbMWJMnnzDIRCfg/9agJOkxHpi079A282bQbRmd2pfWtYQro7M3IEYTrGEYSleo3mcznDxp/xmoVbcosx/Z8JIOfydZ1k2zOXW625eBXCw+hZZB+nga3YDAIZGcDauEAZWS9w6PRTpCEcELOoIDAxbshI/nuRhu+knPR+bksfgnJD5XG3unyu+dbU9gq4h/kobebwiXQdgnSEws3uGovIE7zRDcL0/HujKGUrWfKrbsVlnr6AFV5cUpPcmedb0PcI7ePfjMekS4rh+quQRTi8CJyuVIbTFbGJM34enP9ckacnF/yL+a0Bs0irThuAAVx7KtIqqr895G00fKf/LVGg3VNMu4xdjx0t908rXWhPy9HLL8g9Rt1U8wuG96IL67PwmfcDeH+BERL34A3mLogk15O8vIGMejmooQeurXLNgMAuRjUIkeQr5iWwao4pnqlbzDvqRbR1iZ5jhTvBTwcY39wIM1ZjZgkKBvRQdxORQUcR8KF6aGetOLpIgyP+pr5QUKYNe+HC4MUvwYgCTQUGpNvXTeOmCq/vCOX/byQzO2lk1byh6dgj3oaeEcL8ZN3gPVkZ513SHLIiN8oogNV4GBcUq9FeTKy080kpy0sdUUtOr6yFQYlNv2pbvoladQARsoe60l4VXGG0SZW94ZsSQOy1BVvhEtaTXLS1jyObS/Iwo448TKUqVspmWoYkPYMhGamIAKT0A3V1LJPRosO6SZqd2lS94uPeeCk65E409a1LZYHJD8Qq0wpfLXMxomJvn/qG/LBOToGIExZeN6KNjFJB5bNRSE4PWr1E= 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:(13230040)(36860700013)(376014)(7416014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 12:10:36.2860 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8a41d884-3257-4ed7-8177-08dce85b620c 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: DS2PEPF00003445.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7633 Use the defer framework to schedule cleanups as soon as the command is executed. Signed-off-by: Petr Machata --- .../drivers/net/mlxsw/qos_max_descriptors.sh | 118 ++++++------------ 1 file changed, 41 insertions(+), 77 deletions(-) diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_max_descriptors.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_max_descriptors.sh index 5ac4f795e333..2b5d2c2751d5 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/qos_max_descriptors.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/qos_max_descriptors.sh @@ -69,127 +69,103 @@ mlxsw_only_on_spectrum 2+ || exit h1_create() { simple_if_init $h1 + defer simple_if_fini $h1 vlan_create $h1 111 v$h1 192.0.2.33/28 + defer vlan_destroy $h1 111 ip link set dev $h1.111 type vlan egress-qos-map 0:1 } -h1_destroy() -{ - vlan_destroy $h1 111 - - simple_if_fini $h1 -} - h2_create() { simple_if_init $h2 + defer simple_if_fini $h2 vlan_create $h2 111 v$h2 192.0.2.34/28 -} - -h2_destroy() -{ - vlan_destroy $h2 111 - - simple_if_fini $h2 + defer vlan_destroy $h2 111 } switch_create() { # pools # ----- + # devlink_pool_size_thtype_restore needs to be done first so that we can + # reset the various limits to values that are only valid for the + # original static / dynamic setting. devlink_pool_size_thtype_save 1 - devlink_pool_size_thtype_save 6 - - devlink_port_pool_th_save $swp1 1 - devlink_port_pool_th_save $swp2 6 - - devlink_tc_bind_pool_th_save $swp1 1 ingress - devlink_tc_bind_pool_th_save $swp2 1 egress - devlink_pool_size_thtype_set 1 dynamic $MAX_POOL_SIZE + defer_prio devlink_pool_size_thtype_restore 1 + + devlink_pool_size_thtype_save 6 devlink_pool_size_thtype_set 6 static $MAX_POOL_SIZE + defer_prio devlink_pool_size_thtype_restore 6 # $swp1 # ----- ip link set dev $swp1 up + defer ip link set dev $swp1 down + vlan_create $swp1 111 + defer vlan_destroy $swp1 111 ip link set dev $swp1.111 type vlan ingress-qos-map 0:0 1:1 + devlink_port_pool_th_save $swp1 1 devlink_port_pool_th_set $swp1 1 16 + defer devlink_tc_bind_pool_th_restore $swp1 1 ingress + + devlink_tc_bind_pool_th_save $swp1 1 ingress devlink_tc_bind_pool_th_set $swp1 1 ingress 1 16 + defer devlink_port_pool_th_restore $swp1 1 tc qdisc replace dev $swp1 root handle 1: \ ets bands 8 strict 8 priomap 7 6 + defer tc qdisc del dev $swp1 root + dcb buffer set dev $swp1 prio-buffer all:0 1:1 + defer dcb buffer set dev $swp1 prio-buffer all:0 # $swp2 # ----- ip link set dev $swp2 up + defer ip link set dev $swp2 down + vlan_create $swp2 111 + defer vlan_destroy $swp2 111 ip link set dev $swp2.111 type vlan egress-qos-map 0:0 1:1 + devlink_port_pool_th_save $swp2 6 devlink_port_pool_th_set $swp2 6 $MAX_POOL_SIZE + defer devlink_tc_bind_pool_th_restore $swp2 1 egress + + devlink_tc_bind_pool_th_save $swp2 1 egress devlink_tc_bind_pool_th_set $swp2 1 egress 6 $MAX_POOL_SIZE + defer devlink_port_pool_th_restore $swp2 6 tc qdisc replace dev $swp2 root handle 1: tbf rate $SHAPER_RATE \ burst 128K limit 500M + defer tc qdisc del dev $swp2 root + tc qdisc replace dev $swp2 parent 1:1 handle 11: \ ets bands 8 strict 8 priomap 7 6 + defer tc qdisc del dev $swp2 parent 1:1 handle 11: # bridge # ------ ip link add name br1 type bridge vlan_filtering 0 + defer ip link del dev br1 + ip link set dev $swp1.111 master br1 + defer ip link set dev $swp1.111 nomaster + ip link set dev br1 up + defer ip link set dev br1 down ip link set dev $swp2.111 master br1 -} - -switch_destroy() -{ - # Do this first so that we can reset the limits to values that are only - # valid for the original static / dynamic setting. - devlink_pool_size_thtype_restore 6 - devlink_pool_size_thtype_restore 1 - - # bridge - # ------ - - ip link set dev $swp2.111 nomaster - - ip link set dev br1 down - ip link set dev $swp1.111 nomaster - ip link del dev br1 - - # $swp2 - # ----- - - tc qdisc del dev $swp2 parent 1:1 handle 11: - tc qdisc del dev $swp2 root - - devlink_tc_bind_pool_th_restore $swp2 1 egress - devlink_port_pool_th_restore $swp2 6 - - vlan_destroy $swp2 111 - ip link set dev $swp2 down - - # $swp1 - # ----- - - dcb buffer set dev $swp1 prio-buffer all:0 - tc qdisc del dev $swp1 root - - devlink_tc_bind_pool_th_restore $swp1 1 ingress - devlink_port_pool_th_restore $swp1 1 - - vlan_destroy $swp1 111 - ip link set dev $swp1 down + defer ip link set dev $swp2.111 nomaster } setup_prepare() @@ -203,23 +179,13 @@ setup_prepare() h2mac=$(mac_get $h2) vrf_prepare + defer vrf_cleanup h1_create h2_create switch_create } -cleanup() -{ - pre_cleanup - - switch_destroy - h2_destroy - h1_destroy - - vrf_cleanup -} - ping_ipv4() { ping_test $h1 192.0.2.34 " h1->h2" @@ -251,6 +217,7 @@ max_descriptors() log_info "Send many small packets, packet size = $pktsize bytes" start_traffic_pktsize $pktsize $h1.111 192.0.2.33 192.0.2.34 $h2mac + defer stop_traffic $! # Sleep to wait for congestion. sleep 5 @@ -268,9 +235,6 @@ max_descriptors() check_err $(bc <<< "$perc_used < $exp_perc_used") \ "Expected > $exp_perc_used% of descriptors, handle $perc_used%" - stop_traffic - sleep 1 - log_test "Maximum descriptors usage. The percentage used is $perc_used%" } From patchwork Wed Oct 9 12:06:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13828263 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2053.outbound.protection.outlook.com [40.107.220.53]) (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 9751B192D6E; Wed, 9 Oct 2024 12:10:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475843; cv=fail; b=hNgm4p3kslQJcaxYJ/uwZLnRb9rN4jXtBPMyiMndaD4QXy/L6ju7oonkImqKa6Yg4yBY3HP53lnaD4fuWiOqtj6iLVCLpbnOKkob9qVIPe+D+p3H4inhwTkkkkCdKdWPpxasFmNIc4o81ASgJx/GYb+8EVW7hVKSwEs7TP0t6AM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728475843; c=relaxed/simple; bh=CGbzMlnE8NQ2E0+7jxlDy4cOi2zh+2y9Mz8URLCBqXY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Npj6XnjA1g/gi9+voNk7C8/4BHAGFMlw/hEui4OxoE0MhfoH1ESCoCYEhK3at6nmgb3CaBE/kldZwqoxdnveGnk4HCs13JVeT9XqgBIvVE9t5DTcOMdLK6e9xIDnhfvxudTcGVeaosUrfO8WoduOJ0pqYijaPzkk+uJhjkdcbMc= 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=ZrpOUSFG; arc=fail smtp.client-ip=40.107.220.53 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="ZrpOUSFG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QFlAq/qi2RkSFvEd3FbgXn7WPg+NEIiumd+AGkfwkYzJmWUsoyyMW5u5SHb6VhpWUMOdmJu/Qi90CFuqv5gKgWrcjtFq1HrYeK+y9Di8U5v6qW/3Y/rucD6b/G4W1jcN4ly+4d11GR3RUvPu8MvfVRrbUVZyDk6/XQyhBENqxV3lBO/tPmJMdFsZ55EJYrbWr4AOgkxPh7DWgsV2kTOCxhkzHN5C7qVxJj0r8Kym440GuY9Xz7XXq41I9gI3RsnPC9DSWKk3Bc6LnZnwFh+JR13bpfT3H8lWPz8n0kQXP+BgB2vcIZracrvtg6o8wRkazsVdC9WRja9x8JMGoF/b1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=jd6MnZn98keCO6B5yBoxOZkIOQOubnd8AutPhbtdt6g=; b=pd+CCfqV2ubzQndoWuqNzjPXM9wJFNOdUm+yKzohGKMHNanE3DPSBcBlmE7z5UdD47gFEPaXJIipQX3EkLbWN+KGV3KXzBptCGSLgov9qxDb/JlwtIko0Tj9Q5kNyL7UT/EgSVCtP5fUK1HyZIQt67O+Ff175Tl7pitRnuvh+DPBSIU4adcIryhTQJohdaWSbLOxB76yIj1rcbPpex3oIURW12IzKRdTBQNvaekMspmbxXKxbj74Xb8/dG+mxBfZZvBK5UqIKnqCztJy1YKYnc/vj64FaTaFyUKsbE5tZToRNpNOWxNaqZvuj3Y5Dc1EHJCQH4UHQdS4ywnwDjccYQ== 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=jd6MnZn98keCO6B5yBoxOZkIOQOubnd8AutPhbtdt6g=; b=ZrpOUSFGP/4MCdj5rPfE1/HKfnFS/dyAMxe/IH36x6F30HgjCD4cthdXjAtSAxPNPZGiMUTHO8zG5Br9/ZXzNFJBy5nK0Ti/4KNqZSZ1ajgs/xllZYIrdxJqTDyic+sCxpIP6LNkFS6qMZCKrpCCvAsjK33bX818HRdxqqWlSYkT70jJhBLzdomFMr2N3Xxzrt6ufOEdB8XLq4Kmgygm4QM0FgjfUVf1m4YRByUdYUlNw8ldSgYWrFP6HaU5qIB8sDPZF9voZeeXD6+VpTLBzXlQCOjjOEgmK4SvFLmw9bA56knOgULNxOKcHALFiPdbBi2DFkls8oiqgEaX3gHPeg== Received: from CH2PR16CA0012.namprd16.prod.outlook.com (2603:10b6:610:50::22) by IA0PR12MB8930.namprd12.prod.outlook.com (2603:10b6:208:481::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.22; Wed, 9 Oct 2024 12:10:38 +0000 Received: from DS2PEPF00003441.namprd04.prod.outlook.com (2603:10b6:610:50:cafe::41) by CH2PR16CA0012.outlook.office365.com (2603:10b6:610:50::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.17 via Frontend Transport; Wed, 9 Oct 2024 12:10:38 +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 DS2PEPF00003441.mail.protection.outlook.com (10.167.17.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.13 via Frontend Transport; Wed, 9 Oct 2024 12:10:38 +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.1544.4; Wed, 9 Oct 2024 05:10:26 -0700 Received: from localhost.localdomain (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.1544.4; Wed, 9 Oct 2024 05:10:19 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: , Shuah Khan , "Benjamin Poirier" , Hangbin Liu , "Vladimir Oltean" , Ido Schimmel , "Przemek Kitszel" , Petr Machata , Subject: [PATCH net-next 10/10] selftests: mlxsw: devlink_trap_police: Use defer for test cleanup Date: Wed, 9 Oct 2024 14:06:28 +0200 Message-ID: X-Mailer: git-send-email 2.46.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003441:EE_|IA0PR12MB8930:EE_ X-MS-Office365-Filtering-Correlation-Id: d8133f0b-a2f9-4424-89a1-08dce85b632a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|1800799024|7416014|36860700013; X-Microsoft-Antispam-Message-Info: kHQH4bGdNUg5rPYRrEVl43vWcES+NFfWFP/Q/HDRVoU5aRMjJBTyutiLz+BkAIVTUYVka71JIX1X/7t2n8nP0Ols3s6XL4pD+bt1HFsU7mN5S77jhV7aOhUphqyLk/tpXMJRrRPl0RrmWXFBE3w/J0QWCuIa648WMw1MaoIqBqHiJ+qdXKfB84ql0MufGgtyxkbsUJ/UANdMZ/NP0Ib00bSiUjrEKs29+Ld8Z02BjdSQDzPy01HUuzxf/kH+xlzG2KELGriDv595OC3LgblM80CP0jG35l8L6f5eOTZgOq/4dU7fvHBp2PXgotXNMr1mOv14csB1DRnZc+yqfNDUBDiSe3sqam4GzWuQV6EOqpW2MawVuhtMTWurwkrqCBoVIKW5WNDXv6Gy84KT9S4GmRGCJurxs5936O5NxBzFWXfw6/O0cn6rXftImWpThOBEGFLC4SWH9wwSrybf/Ym/Pt+mJEbC8iYkb8sNz696Ii/DBWxrODwJvdoA4qS1BiWHF1kYox2HMfKtZTfbHJ1j/Ux1V2U0k4dSx0dyyzAY6fOVlT+e7wSDM+gWJb1UmS0TjDXB4I6ex4aRw1st0bF57G5e1Z0C57F+qFPKgzzMLNZEr8OoVuCN3o2SbpuxPItBv4Qa7iqS1nUGwbMAjmNFxpHZzbvaGVwewgjibm46LE6HSKZ+AjCCGfnUOcAYiiUjzPQGKzFdmw7ovBiU0xQ+0Dx/C42Shs7DBapJA+uRK14fVpSN8A1zBjBWp0U/JSkGyVh/gktXpAUgPWbfCMILNjx3Xi7xTVsqj4S5kS6Wqv78hE1PLXU5cjIdAfFOHjmnB3TSDVNpldKAL5xboVV0g9uKd9b3c5hi55SSftOxDLIFjOR1FPqoeq3VwrfcMaBIsn6wHG58tXSvJlr3Oy/3JPG+Wz+gpAJEWGS6SkHd3B78pVPqiS6WnI/wY3PFp1Az6pAEJgaSZay4n0ARjWCotNMcPWYYVZnjfq7l1LgBccE47XRk6+JxvaO5pBSC9HctVPEX9Pd2pFFTkXUbs/CyRIt5z1PrhQxlRdVPQZL6jOwMo/8GJnYKhZOasV0Q1gndTxA+VfAItTsfgHFBf/ju15aVPkDH11ykXifEQP3A4adeCDpABrDPl08QdVuUP6WXiTgLOfkgUk1xcPmhazS36HTcEQBA4mrfEeaT2A4cDCqUEXev3qEH+rRjnasxTdzQeqGpXW6+agI4KBkhY0i/b28Gz21Q7Gi39y8RHCDtGjx/BriLL6eG01m9bLquc1KfxOuuX4NbH1mg1RslCgCiDZzbnE4sP+RjvJoFU9xgyYzCbAKldoZcano+1gYDHQtFGFs2kLMWjJL2EMtpunC8NubC0Kl4w8zpFU3l87h6KMAQ2qCje3g+/iCQhcAoJgXk 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:(13230040)(376014)(82310400026)(1800799024)(7416014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2024 12:10:38.1761 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d8133f0b-a2f9-4424-89a1-08dce85b632a 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: DS2PEPF00003441.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8930 Use the defer framework to schedule cleanups as soon as the command is executed. Note that the start_traffic commands in __burst_test() are each sending a fixed number of packets (note the -c flag) and then ending. They therefore do not need a matching stop_traffic. Signed-off-by: Petr Machata --- .../drivers/net/mlxsw/devlink_trap_policer.sh | 85 ++++++++----------- 1 file changed, 36 insertions(+), 49 deletions(-) diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_policer.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_policer.sh index 0bd5ffc218ac..29a672c2270f 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_policer.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_policer.sh @@ -45,63 +45,52 @@ source $lib_dir/devlink_lib.sh h1_create() { simple_if_init $h1 192.0.2.1/24 + defer simple_if_fini $h1 192.0.2.1/24 + mtu_set $h1 10000 + defer mtu_restore $h1 ip -4 route add default vrf v$h1 nexthop via 192.0.2.2 -} - -h1_destroy() -{ - ip -4 route del default vrf v$h1 nexthop via 192.0.2.2 - - mtu_restore $h1 - simple_if_fini $h1 192.0.2.1/24 + defer ip -4 route del default vrf v$h1 nexthop via 192.0.2.2 } h2_create() { simple_if_init $h2 198.51.100.1/24 + defer simple_if_fini $h2 198.51.100.1/24 + mtu_set $h2 10000 + defer mtu_restore $h2 ip -4 route add default vrf v$h2 nexthop via 198.51.100.2 -} - -h2_destroy() -{ - ip -4 route del default vrf v$h2 nexthop via 198.51.100.2 - - mtu_restore $h2 - simple_if_fini $h2 198.51.100.1/24 + defer ip -4 route del default vrf v$h2 nexthop via 198.51.100.2 } router_create() { ip link set dev $rp1 up + defer ip link set dev $rp1 down + ip link set dev $rp2 up + defer ip link set dev $rp2 down __addr_add_del $rp1 add 192.0.2.2/24 + defer __addr_add_del $rp1 del 192.0.2.2/24 + __addr_add_del $rp2 add 198.51.100.2/24 + defer __addr_add_del $rp2 del 198.51.100.2/24 + mtu_set $rp1 10000 + defer mtu_restore $rp1 + mtu_set $rp2 10000 + defer mtu_restore $rp2 ip -4 route add blackhole 198.51.100.100 + defer ip -4 route del blackhole 198.51.100.100 devlink trap set $DEVLINK_DEV trap blackhole_route action trap -} - -router_destroy() -{ - devlink trap set $DEVLINK_DEV trap blackhole_route action drop - - ip -4 route del blackhole 198.51.100.100 - - mtu_restore $rp2 - mtu_restore $rp1 - __addr_add_del $rp2 del 198.51.100.2/24 - __addr_add_del $rp1 del 192.0.2.2/24 - - ip link set dev $rp2 down - ip link set dev $rp1 down + defer devlink trap set $DEVLINK_DEV trap blackhole_route action drop } setup_prepare() @@ -114,7 +103,11 @@ setup_prepare() rp1_mac=$(mac_get $rp1) + # Reload to ensure devlink-trap settings are back to default. + defer devlink_reload + vrf_prepare + defer vrf_cleanup h1_create h2_create @@ -122,21 +115,6 @@ setup_prepare() router_create } -cleanup() -{ - pre_cleanup - - router_destroy - - h2_destroy - h1_destroy - - vrf_cleanup - - # Reload to ensure devlink-trap settings are back to default. - devlink_reload -} - rate_limits_test() { RET=0 @@ -214,7 +192,10 @@ __rate_test() # by the policer. Make sure measured received rate is about 1000 pps log_info "=== Tx rate: Highest, Policer rate: 1000 pps ===" + defer_scope_push + start_traffic $h1 192.0.2.1 198.51.100.100 $rp1_mac + defer stop_traffic $! sleep 5 # Take measurements when rate is stable @@ -229,13 +210,16 @@ __rate_test() check_err $? "Expected non-zero policer drop rate, got 0" log_info "Measured policer drop rate of $drop_rate pps" - stop_traffic + defer_scope_pop # Send packets at a rate of 1000 pps and make sure they are not dropped # by the policer log_info "=== Tx rate: 1000 pps, Policer rate: 1000 pps ===" + defer_scope_push + start_traffic $h1 192.0.2.1 198.51.100.100 $rp1_mac -d 1msec + defer stop_traffic $! sleep 5 # Take measurements when rate is stable @@ -244,7 +228,7 @@ __rate_test() check_err $? "Expected zero policer drop rate, got a drop rate of $drop_rate pps" log_info "Measured policer drop rate of $drop_rate pps" - stop_traffic + defer_scope_pop # Unbind the policer and send packets at highest possible rate. Make # sure they are not dropped by the policer and that the measured @@ -253,7 +237,10 @@ __rate_test() devlink trap group set $DEVLINK_DEV group l3_drops nopolicer + defer_scope_push + start_traffic $h1 192.0.2.1 198.51.100.100 $rp1_mac + defer stop_traffic $! rate=$(trap_rate_get) (( rate > 1000 )) @@ -265,7 +252,7 @@ __rate_test() check_err $? "Expected zero policer drop rate, got a drop rate of $drop_rate pps" log_info "Measured policer drop rate of $drop_rate pps" - stop_traffic + defer_scope_pop log_test "Trap policer rate" }