From patchwork Thu Oct 17 09:45:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 837104 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2085.outbound.protection.outlook.com [40.107.220.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 2DAF5199E92; Thu, 17 Oct 2024 09:47:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158440; cv=fail; b=fZM81a6JOLgWDP7St6vk9mZm8RX6hQ2Npx01UN/dXolN7G5JcOcEO4M8UtYF46kdbTpSm9SvkLtGHbql71yLgXiROlej/C0jnJJbaj643cAka6dLi4o83HZC0lmi6B4jyhvjFIYRMJQWReB7mwrYAIbKPw6W+2cVq+aSd7IdFFs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158440; c=relaxed/simple; bh=goKL+L8i/+yheYPP/hZY9ujcT7qZ7MPDgYYlqUekWVM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=c8RfqX1Wm0tffGWflHL+hHM9QP5PNpW7HMvITsHp1RaX9ActMKGd5PCgP5mPE+UYsexofFZXmJWLhltmSaUTMdfJqoLigscL0zM+BuIgw+Q+8XeMh8EaV0o745mRnVPSIEp/Lh+8fS9tC6JemJCG96+6+J0VE5KpzGbR0dYRBG4= 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=uRm46AOV; arc=fail smtp.client-ip=40.107.220.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="uRm46AOV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LHQER6NbmPZ/SbHN9wTyJeX9SaNrE23UTDnfSylksgG5NTEu+1DofXwRXcvUavxDSEHhfFQc7FQEVgYPzE4KNKChjxPL0lN6+vgogqg9W+p3TTBAnWm28c5HNrcM1EJ9Qel6zJyHJdDChQrZFQX388V2FRRzYJdQbAFAe7Ok35mY8aJIBi9byWKqyU3oa9qVuMFpEimCHrDySCQtew6ZGPapY9Be3HNhpMWYNSWa4k57IS5/I4PHYeREEfGdqAjXoOmoHMJyu4vxNHxmiiwb4JeZZUWLJYS/FZL0ZEwMEl9MV6UqL/wjanGsDaRU/q2GzsItpAPKawuMWlEc9geuxQ== 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=ed1HrE/fQ/RaTQ4ZcWnmrS4KJWrqClFbqGRTCXm/uLI=; b=luPaOExBpuXk+gaY6lbLBb3NP7ZfIXvqNCtE4suApADBpwJ6GHe+BseDj7vuX+e7q3OWCSM2GfHxiIImEYPOkm8Y9hjo3F9u7ozCR+nJ8g52GM+Q46yXMoyFs4J9iWIoptj9RBvW2nSkHZMxoCgJ/A+SGbOU+iJpZfgN2P6I4nDwelH9Ohd9WeJj2ZYeVd2msDQZ42E5IIsOea4tTduJGdqcXuI6qQDAAnbVvqxk9K63a4iuOMr9BF0k6H2N+dSeTuDMnVsxRJsfACRwdeBxEALFtzPaYu0puxDkwkmRHC58XPiLl7fUNKI45qtCqW0nQ0UNOMUeD14eJs1Gj4HIrg== 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=ed1HrE/fQ/RaTQ4ZcWnmrS4KJWrqClFbqGRTCXm/uLI=; b=uRm46AOVcAUG71EkQkTaokwMpvt7vM+Uz+CtPNpTYSqSsrZjM0kELzSWmseAPH2aiTKTqsvcKk22nPrficgUVUqhJ0fBOT+fVocc5Hj38NRdt8/8far9w78gLm3v1+EAAi669feB12wkCaMewCzZK0EJ6a/+gV3R1MXkfHBzrTemyfVkKqNoGBKJXz6niEJEw1AnO5pxJt+87K1d1ifAGatG9QX+ktwKU8lZNnp2IxnWqZJvj1nTxenyuvwwCgi2uoAgFNZ1It1V9R3U919I6vtW5ZHnoowgZ5dFCXYPucnSzba3HN6bminVr7Cr6sIopn2U844FDCvqyRz/Jnyecw== Received: from SJ0PR03CA0108.namprd03.prod.outlook.com (2603:10b6:a03:333::23) by PH7PR12MB7796.namprd12.prod.outlook.com (2603:10b6:510:275::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19; Thu, 17 Oct 2024 09:47:12 +0000 Received: from SJ1PEPF00001CDF.namprd05.prod.outlook.com (2603:10b6:a03:333:cafe::a8) by SJ0PR03CA0108.outlook.office365.com (2603:10b6:a03:333::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18 via Frontend Transport; Thu, 17 Oct 2024 09:47:12 +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 SJ1PEPF00001CDF.mail.protection.outlook.com (10.167.242.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 09:47:11 +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; Thu, 17 Oct 2024 02:46:59 -0700 Received: from fedora.mtl.com (10.126.231.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; Thu, 17 Oct 2024 02:46:53 -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 , Willem de Bruijn , Subject: [PATCH net-next v2 01/10] selftests: net: lib: Introduce deferred commands Date: Thu, 17 Oct 2024 11:45:43 +0200 Message-ID: X-Mailer: git-send-email 2.47.0 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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00001CDF:EE_|PH7PR12MB7796:EE_ X-MS-Office365-Filtering-Correlation-Id: c66b8b15-7ec9-4a29-43d9-08dcee90ac7b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|376014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: U75vEWvp2godu3WCXkDduCMXvaIMVATzt1bwcXvoGxrJx8MI541l/Fs1fwNqTCKY37EPrjDIyk6Qrtl8uwvJBy+E2rth3FNEPzFPMxavEVBxvQvPUEZuZCzLn6UuF/sAWuPMfIWlLf4aDeeZMa4oR5x5qRhOAoDyofOm0s+xT6uExZo7tUeAv+VYaDDTZS8WlSyfUP0PNF8ouGqh3+hMBotjh9BPDCK+mx9zsnW2OrVOvZX1LIHcQVgd2MLUHVYd5oc/NyceuidGl+UPa4CPNyDqvJbMZD1yJziVG29p6VGcJO8CGw1r2uGFdea3Fo1R6pm3wSNZr9rd0YEMnct5FUdVjVVbLEwlxfsfyZ9UO7vOvHpFUH3GlG8CQ/kSfy/0L4SCuPWzLNWo+2ThZ0f1y3n5i7BpkWPTD5SEozxAuBSBLwOU3VmmtOhmWxapT9SXIFU7D3U/5QqAf4CD4aKwyE92KFPMThDbwTreW/WUkrtdzqijrDwJN8Sg5d0OowbSZ2Dmxhp21QRkV1XAsOPhF4RiAw1yoKgzkYE80BAEhOKf+MbHF/etPsbCNFjgcTxDRYpMiXh9rWJoUUX3cFWw28yWl5HEkhh3TMFs0z+L1UOaNeVsEblRhnoRsSTlXYkVXoE+Gzqh/W7KrlhWsylZbps6P7b3j10WLjKwmacsLJjNndN8jdmQaDXA6OObJphg9xoR+U6G37vG7T++NWYBwNjtnNb368Hwq2lBaWbeu9FFSXz85c206cIzRfak+YEykf/FvPrT4CIgPJT/1Dt1PxvlvhYeG44xFO7YmbRSCXhK6k+5MjyD7RmESI3MjoVOAMtSHF//aRJrG5PZpvHJe2zJnTimCqvsVtvAePzFisj5xhVxRnL4ZljjEAL9XbTtgXRPKpcct9XCtEVGurCrKyAKS7SKshx2wK0vLpT4lXkSNeiojpsIRVTlqJ2f1PYyNoEeeLmkwyAtDa36n9zP3Kfanx7lGID90ekkKnOu8NB7un+xgrNGuRRz+lR6lenZJ4I5pM1/c2CAjcKUBDbqChMS7i95cXV5c1/oUlF7NvpsfoKSroQSOWABi5wm/cYSfy0fXbSYSlrW6eJhQYn4s664lLEcYl8BauONYBABPh6hIPn3kMEmJtz6y0OqoB1HgIts74k6JIpQiFKrKvyZsA1D8Plv3oFI0wkheH5OddqTyUEeFHsWL1+cTUdvie4RqC4pd4EGQ190sI65sjDiHJd9b44M1l0DxcQmeS4L77bemK4eDNRg37FQNWX2KT692zoUQE3noMeobk7zmaJqlNT3MGx9OGgz5e52uVzmycN4eKn6wbTGnc9G0eHvDjDBFM5sVUXI5y1VAN/bpZCBZ75mK/KFqnY05Q3TiU0A+RxV4BLoxTGkq4jKAziJHtuwAQLdisua3IBCcznnzlll6g== 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)(7416014)(376014)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 09:47:11.6072 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c66b8b15-7ec9-4a29-43d9-08dcee90ac7b 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: SJ1PEPF00001CDF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7796 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 --- Notes: v2: - In __defer__schedule(), use ndefers in place of ${__DEFER__NJOBS[$ndefers_key]} 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..082f5d38321b --- /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]=$((ndefers + 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 Thu Oct 17 09:45:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 836451 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2044.outbound.protection.outlook.com [40.107.243.44]) (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 77A021D4150; Thu, 17 Oct 2024 09:47:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158448; cv=fail; b=dqWlEErtTbj8FL5vQm7ceRO4hksqrWlBBSDuACCmgcrZaN97sS6o4kh5IKsHW5rAJqZ3k+O0Dn+r9LpeoEOMQWc6HlQ+Wy7XOXuoocsmr/CVa/u8yLx113bzLj2zxdP4s7pQJCZfaERpt0Mud2i+DhBQA0CUTNpALZOR+nrdBf0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158448; c=relaxed/simple; bh=Wj8/eDIkFKqrizBwAIL+rGQ4mBwhFSnEvLRXdt6sRuQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pURFqHWtsGTrv6vbBgJTgNEYRFaQt/z8Gi+l3wmgvlKOTGD7Ej2P0qWG+iGXTR5uKNHcnJI5DPuqLOBTUs1dEUCjgMZdO/FavrZO7tBO4P33ik28R4OACU2PYYzzNYZWlkZbQlNaU0/TNalzzF4oOUVNe+/8ywljYuRCrTw2mtw= 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=PiuLB1Mq; arc=fail smtp.client-ip=40.107.243.44 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="PiuLB1Mq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=t5hSSRW25ZNT9m/u0EiuEVnCZxD2mLtDpbf9Wod93lELnVGzOINgPZ5zZwjxvorohk3PKagum8kInBACX1L9QP/1MFbrgJqL2KxD3hl+ELTESQ783zAzx53X1iy57zHOsZXCnidxGV4Ig5PO7YUKsdefDPDRzk6QxNXnmnfk0IxyOqAs1KnbHTYh04IGMBBXNHP4cISLIt4ghWyKplzsCXP0TGss2+H5RFGlV5puZttNsw7x99wyA2MHKUp5CpnHIvqsy2yRUs7ptAvDyIZWE0BTzmqUbaCuNVaeu/w3FLaUQLZOEmBWbw/xw9R03tXJGnq9/SDtJdxuadk7LM2obg== 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=mRu9PFsuxgI/koNo0/u3z5ZWoNOwVcDBN7+kYjpxri2Wks5cDmX/50GSBIk4QSl2S8HmYS2cn/Le6Re39CTM5nwKOFTWQetGRejEUWcjqqd8aqvRlMwmv2Da2sZ+ORp+xUBMWlJWTIBn/5fcdYtKCmhFt5yNq42b/eAYQLhCMiH0heGIBM9ynGKKr5Jrm4aVFe18n2cYSoAUtLhoR5YNI288wPhpScm3/IFrk+ReqgIgobyjvOELCTEmE6ZEjMeKFoNNiDnJKPJ6tiORNPuL6+MUICTDVxT1iWj+xPghMtrwaja3BwN+rZ3yqvHifWDhVcbx+lT4KILnjMtrMKSi+Q== 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=0VCQkaVJVw+WAjtwSfv9f7bEjAIvy3jeYEnEyvsHA9E=; b=PiuLB1MqMmwBzs1oqx47VdeSa90MsgbzajpXa6J4rXRiXZBwEDJ97v1a2Is4DUo+o+Yv0Syc9p25kmATA5mAdNkcJ3h927kSFuAtarN+Mo8zmRTNh7qyiZGC9wCA3Gu0tVz19F5acyWjBdU2t1tfLdvOKbAmj+40yBhBEVXOwgInPF252WiFUne/jU8Crn303PUaxmhamkGoF63dlpCVPmePeKuiyVMjv+QEZFeCGUWj+PrjIiiJAtWVOp9Hq04MvIiN4708hk3kfo+aazPl+52OAPgVi7fd26kwsYX+wAC7q907WgjHnrtRLJq20CiWAkMpTnBBZSpBePDyYSaHaw== Received: from SA1P222CA0151.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c3::21) by DS0PR12MB7874.namprd12.prod.outlook.com (2603:10b6:8:141::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 09:47:16 +0000 Received: from SN1PEPF0002636A.namprd02.prod.outlook.com (2603:10b6:806:3c3:cafe::bd) by SA1P222CA0151.outlook.office365.com (2603:10b6:806:3c3::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18 via Frontend Transport; Thu, 17 Oct 2024 09:47: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 SN1PEPF0002636A.mail.protection.outlook.com (10.167.241.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 09:47: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; Thu, 17 Oct 2024 02:47:05 -0700 Received: from fedora.mtl.com (10.126.231.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; Thu, 17 Oct 2024 02:46:59 -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 , Willem de Bruijn , Subject: [PATCH net-next v2 02/10] selftests: forwarding: Add a fallback cleanup() Date: Thu, 17 Oct 2024 11:45:44 +0200 Message-ID: <5204bce5de00855aae83bc66d8d6bc7b93a035ce.1729157566.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636A:EE_|DS0PR12MB7874:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f32c6ed-28c4-4a20-dda5-08dcee90af35 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|376014|36860700013|7416014; X-Microsoft-Antispam-Message-Info: wUas1+QTWHcxK+Tk4lttmClvFiECsyX2PGkA+BLbqYSo0keC09hkG5MSAlWol9ULdKb/ATmvy/Q4egUA5t3zUHrV0h5a85OnhNhuWEG01WllRCob+Jl6vhA5nhtXv0us7MTPs0HguII4KUhzCgoaYgt1EPDonoMUn255M4YLlf5bseQHzseIMWKiW/ItujqX+KGMKKPXShfrd2jMWoV3qiJa9BbUNwzu4w/Ove/3HHxt/jEQV1BPaVfQEOxfuNJ/Ix++QUwWzdBWKPZnfnmZavHe+x+dJf2XMWthtS9xNqOl1eyWb+HyBydUt7L1RffuzDXsMfXpiWrMvGm6+FoXiNyOncIzQd7HDgdrHjtEzKhnx4BIHC7ZLTpd8qrnfy+MEt5HlKDHEog6mi3eMjCNhBPJ2U5/xstLA5TDa3PX6YOvllTGe6U+LZ93GMXWs4ltHoJ7YkqQr9G9DGTys6T1FslKtBfqKylbq/an9z0oC1zU59ivpVhRjKxLiYOlWwsyQs5U4KkTznaZrvnynkv7IesyVR+G38gVIpvP2sd3kpTrZqVe+ed2bGWTeYvXc6ZUvZ8JS80YgqqFpLTxHtvDHrJfe4YjPVxhee1SKiV8rrtSxU4xTFqA6k0sEh6m4oQy53XTfSDI/f5V7pRSW5SQKgQKQvUhxYILvCeyCvXV3f1aqiLGcv5jS3qOL3wJGlUsCKjpO2rMeHL7OuSdp802bwMKTWXhIBLqS/aKlpY8I4ducEha3UdQ3htTle3YCnZ1yd7en3Oa8R7yWIRVAmr712/TW/VwOsUfVmRWaMHJWnMzWuvqKJKFt+VtQBTM7xhYU6Xge0Z7+lJH/tTdptNQshKRSi+ReorXN7wpyko2a1kpZ5D5wE1Ehh3TvSGAhQzkGz7aMRS8TAFCHcLBmEdUHtpWdaOxwsdM7oX98E/HzLWKh82AivhufgD4y5TxGzUZsn9hBNBYmRfG+2xTQscUeZX2LGEbBD31LcnoTdB7Sdtmgx6i/nDaZJDwHXEyJcZ0B51213OEP3rQbuUtz2M5IV1GMZx+6NrKSKr1oOgt9PSQ14uC7jiuINvbo9F2cRiaCi0fHgbzaIa6tEnB7uTAOaecSofHwEkvRXuN5xfhzWqf/Fw7pdconzFStBnSbGnyek6DmFoTkOV8AA27RZU9a/3xw7u1vCSCGOzz3o/REWom0o6S45NEFfu+yoCLEmyzDU2OOTlNrwD9madwsztibSlYEiW98zbLL915/o4JE4Cucu6okiVyy3sH5MuXUPxJobp7eNjjX23MFqqRB5mpKmrRnJHbXnYc0CQpRTqdLeQ3Pf1A/VQnVqqsXrh1UYCNGHzDtK+yC8Cl97ZeQEnj3L9OObRu0FqOZ+k0tNJir1hXGjnF9aQhPTGpJzLlY8v6abms1JfWTUetjApv7QnsVA== 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)(1800799024)(82310400026)(376014)(36860700013)(7416014); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 09:47:16.1074 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6f32c6ed-28c4-4a20-dda5-08dcee90af35 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: SN1PEPF0002636A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7874 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 Thu Oct 17 09:45:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 837103 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2087.outbound.protection.outlook.com [40.107.236.87]) (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 2052A1D47A3; Thu, 17 Oct 2024 09:47:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158454; cv=fail; b=KYbKDbYjLe5Jut8/wtpo86SG6JPXjlpXZBBgfKA2GhsiTnaBlR/07TMMbwAJ7MsybLpeWMqShxcZvTwERtlSQ7lKoQCwwNvSF+CB3WEGBUh8eA9wxNb2cFvzFxUn/ylDlrWruVjl9j19f304nA9xWIsAFjslmSyDYjYd4GEfyak= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158454; c=relaxed/simple; bh=ode908XCLSDd5G+QWaV3cUIGg0Wd4AxpyTA4eXEeS7Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nqlX7xYRZSb2I3LBmicMLsu/mtD5Ifl1olXltgsqktL0zIdImCSDUvQ0ij0y7kZKPA5+UWDzaCYU9LyFZquZGKqX90J8OBeQ4EVHTKNpWfm0lJxdYwYvWNXLqdFhc8SQAm5NoP6oWIraR6sHOQl17nHc45jBrtZVrKRL9xgxs28= 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=WCcNJDDI; arc=fail smtp.client-ip=40.107.236.87 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="WCcNJDDI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T3tgDSd0cy8EPV3vN+rlHxEY/TCzrMwASg8QdtN5apRya+j63F/Ho/0IAEB9RlZ5CwijOdGrZDuLl2Q0CEG006/pGry286aKlo9F3p+iLtpQC4/akxTDHU0TA1lkI/wrFlnF3u3RU87xsu7mZIj032aFwy5miuTIJHdnSN+RxMsddjM12Fw1oDQs/9/OUg9HFB5OnyiH3TrCb/lryPCjOksw5t3p1MHImuUv4OGsxsNF5jyoQXdNUkf2yGJc9IPw+MmGEa3nEG55w2gaYz8LU2TB9Rnu+FvqEDNBYNeJFPzUd9UtNTHcYgISZD2c2Hr53yvldHwsw8CDoQMS6UCc3g== 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=NO7oxLmn6xgqXqmGNoC+ZoR4NQpVu7tmSwdouWRfroGLbromc905/8tgQH5q8s+JE7qU23MoLr42VUL3/dTG9A8slp92oOV9D9nSW6qJb0IN3s7owWsAwDF7paCc3Kf0LHkdUGOIMumwq8yg5IYkZMsBM5ivrWGUs3uRSRW2z2rAV8NZhdFMCXzujHYKfaNAFXhyk+S93XduNn2Z4aqBY03BkCcBVOsQhmY6mx+lA60EgmCcd07etwI1F8q0QjW5Fv7svUn1oTeSlatKtQiOO3ArWeR7REjUKaB5Gr17Ivcj+w6JA/bbge688w99wuRu/o1HYCV7+p1Nt9NnY53cgg== 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=WCcNJDDIVn3dRtzjfVa86URLXHymd7w4vHpiGNmssKPl2katSdTSA37leuee/lcCwK1Th9vTAq9wUI9tlDgwnDpp6e5H8LcjdB1K2maMPJJwWDLQsl+RWvb1BoYL2kXjHrr2UDI4RuLv333kcb0xvAUoXt161yhfCNQIBdC7padU1Fgyc1Na47r4DDWqsNO9y9eAgk4LsTwd/iGqwHjOK8XWdgSJqREnjq4yTM519I9Ph9Hs1NZfAPAroNFRB9KLczbqlvOJlRH6/BeFLusvD1qIm13nyS2d4oTcbRXXhDPAHsSY7z8g+y5yVRAxc0VV0/1jxOk92S8JhybmHDz5nQ== Received: from SN7P222CA0016.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:124::16) by PH8PR12MB6796.namprd12.prod.outlook.com (2603:10b6:510:1c7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Thu, 17 Oct 2024 09:47:25 +0000 Received: from SN1PEPF0002636B.namprd02.prod.outlook.com (2603:10b6:806:124:cafe::4) by SN7P222CA0016.outlook.office365.com (2603:10b6:806:124::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.20 via Frontend Transport; Thu, 17 Oct 2024 09:47:24 +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 SN1PEPF0002636B.mail.protection.outlook.com (10.167.241.136) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 09:47:24 +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; Thu, 17 Oct 2024 02:47:11 -0700 Received: from fedora.mtl.com (10.126.231.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; Thu, 17 Oct 2024 02:47:05 -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 , Willem de Bruijn , Subject: [PATCH net-next v2 03/10] selftests: forwarding: lib: Allow passing PID to stop_traffic() Date: Thu, 17 Oct 2024 11:45:45 +0200 Message-ID: <7e4857d8fa061dc47e3c7684f284b848549c660f.1729157566.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636B:EE_|PH8PR12MB6796:EE_ X-MS-Office365-Filtering-Correlation-Id: 1f7c9a3e-ee5b-43a7-240f-08dcee90b426 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|7416014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: 4OJdC7lftpQ9YxAaA/r/i1njM7u0hQASHZg4lLbbzDM+4m9JV23buH7PrY9xBevPdesZc0wab4fjdOY3LRgfxQt0MdsyvEcPHfnNMpuu7XvroN0usMPjF22iZQxYmN1b1Il/TPbqZqinbzt3sOh4LErGvykSYOI8e4MntbmDcy+wCFZZeZpuEhl7oVPXU5/AJvfkY69nGwqvaAuINM74ykNBC7FTd94OaxCPDALwAZcl3c24DkFbrpB6y0ghJCqOnqprkxYeR+xXaJfLdrLtWUGfL8uiq40VmZ8mptdiaelaumqGq5t0ixcFQiO12aT5CGprHj7y9JE63HnXnG/uBhEDmYeY5ry/RupFlHoyTaOa36L/KqC7t8AIVy3pVlS6OF9rG9YdPmvMH8DDayoqobmbZ7v74E5smxjHj49C4t9DeT2uRjaL/5wA1cGLg6bl+S/6YUVHYOr6x48uh1kAnVZ7Tv31Ve/zF/dc/dQB0ZIY8aXkhcxa71c02P1HYqhBKwCzX8nq8TZ4j6Z9tdZYtnJNmgbYtF2c5mQ7sBfmXIeqVN0kgiinHLichC2NfJLCjzcwuCRKmy11+IbhDp0U47kaEtL+dx/C1sl6K6vIHYEn3rUJT83dBsM0x0lDQEsP3sNZUfPJ0xf/W/0bAfD5L0ipa7PvCD+WZ6EfXsdtteILhvHbXNXjrv73BFrZi165tEMXU46iBUjnL7xfaQOkCzS4tdNCf8d6CtPSKfDFlxapp3AYbHvywDIAj6henmxgg7fYkTynN5m4ql3zZAYjnnZ9YH7VyT7CObGdat9htygNN6Wq4ko1QvMKyLNOCuZosp4x0ZmWbiz0K4LACo0a5DzIb+RyrCbi4vZ/IIBNnxTwN+3Oos5WHTzepWlJrCgbuFanFvZ0dE5HNfElH3AyvU3b9Ki+wt6x6RLusId9fzaXpE/42+CsSOsJQ9qbtEpZ/md5PEnO2RKqxEM6zSZ8Pcnvd325zjjWGQKqqH4RR1BRRanaY51P9YntMooascEtpnnvx0dk2zUfBAe/XYGCdOsNgGcPNBSjAPmdumjz3Dp862F8wfvvlst5ZrN89OisvaUU4PHIYb7DX5cO3u6YzidnaXTpc7qAUPRTAQrJFZyle0sV/6P/SBlXm7dw/PK/gr7sE3cVNBnUZMLmwSyJW75cMw6klufN6k0lvMOj1amnVvLeoCWkxoADixRMbB2w7XCZchZhSUtuCqQvnYQ9LEJ/alctOnWU8prmx0kAElSUw2e2DFks61VrlXxL0CNH6X5yyintET0yWC2WugFsp7e0UOeGn+cy9mXVP62JEmLLcsyWdLJ1gjfD0qHjSok1KqHN20J8UUJ/xmxpKf0QNTlpyC8oT4RcCqNFo9yfwkD4geqXntrHeLZ0E/xF2MythMrcTw3obo/i9q9MTMJPew== 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)(376014)(7416014)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 09:47:24.3461 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f7c9a3e-ee5b-43a7-240f-08dcee90b426 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: SN1PEPF0002636B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6796 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 Thu Oct 17 09:45:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 837102 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2048.outbound.protection.outlook.com [40.107.236.48]) (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 4FA551D95B7; Thu, 17 Oct 2024 09:47:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158461; cv=fail; b=OUw75SlxLA7HNlN1YjIsxbCyhj6hxDh84krBSrLf5J4E8+ctkg8kBhOUvwcI05/d4kTXksJixM9FVXpHJVcB62LorQ8VcNe11VKrmtfiA8t1uXXWF6sZ8NY7uFT+OfrIuRmrplpL/CU5SXhvKkMsUVcVTs7/eim4f0gISjij+sY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158461; c=relaxed/simple; bh=ObiP0fdv8RsUImjMI8KYX0sTHl6ImZ4hXXxgX03zWac=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dHyZmg8oBImaqvfGrXUKzbWhv5FJwBpG5V2LSrWJlbpfkA/rH33UtLC9wb8Sq82IZirDwA+9e8hC9qqLJ6tMqEigjskuFCwDm1FpencWyCgVhD62jylVljeWt7IfowF5lEt1uzMQ2Q+LAPJVWgd4MppQcuydHpvbS74Bd40IEl8= 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=X+yA/4Fe; arc=fail smtp.client-ip=40.107.236.48 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="X+yA/4Fe" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tCxerneNtky99/BU+r97xQ+6tln8OHJM5aPBtiaawadvM6MeGa7zdjBC4YRIYybpxAFWkaF/r1J6/AUI2ErpJNOGoV1qwaULgRto0JqNMCFzrNTczn5QARfhSv+SCBHtKkZAb50nFGFrtlMgnsCT2er1oFzyiRK7HV2XRj9fo5Oye1PZjX76bQcutQdPK7tHxuQClw2xzzETXsb3Wj4Asr11T2I7U41ai7vnfdM6PT8vK3jhUQV5kHCSigU6FIAOIBUm96lq7ZnxI7ouC4vfIxcb+sMkJlQzxaII+MMu+4wy2AFMq1nh11+LPdKRY8rJlVnO+CviIydgG2rUr684Zg== 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=tUWwCXIicKaeDkEbKegr5aKgaKGTbwkoWH1Sy/opfow=; b=raE3dXx8ecUdUwydj6bR8jiO3NoX9tHxLGIylmSJmyeHQQphdamNlyScoUdeaFOya5RgRC05xiQjOKXpSjPCgQbYQyK9usP+fbsBMxvlkIUIDXofcoebctagROebwTevAY+23fUuYt1JQhPpgsBDINg/15fsw31h6TfzH+Bgm+7xjfbg/3LoEitbDbDf2fUKWzlqb374+Bv/fzi7fwzipC5XR6qVl6qKNGETre+++UiqSH6rggC6RXD78k4zgFVzAbhr43kI1eW7OLy9M5rABqo4dF9bu8vWm4zuvj7t1Un30fiWsr1Y36fvzQTgqjsTUF5ALSfK3vJ40AKAKzjE8w== 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=tUWwCXIicKaeDkEbKegr5aKgaKGTbwkoWH1Sy/opfow=; b=X+yA/4FeAcT0Rdmsx2/DK/wkOd9rjL5RjIEiUI/SNXXNaH4s3FU87MSo4LD2C3jFRR+mBVCO/poxq0Z2KQCi7ewt+pVjPWf3OFx2L5iPaZYLnQr5LEicFk3aOpw78n99q253GIEyWy9fzBPCGHTex4+TNwf7SnHUDd6adngNGI9iZk+HEcoxJW/Zzdj/fNZWrOVzjz15VTB3df8+m1/erJeKtP2qsm7VcKjJ4atqB73jLYfl16js3pv4rcr2hOfxey4nggrpOg8EDv99qbKCwZLS/lHM+ggSoU/4gLQECw665S5K3iFCB5FBbI+K9DVjx5CqiQEWwGzXsRq4PMfiYA== Received: from SN7PR04CA0182.namprd04.prod.outlook.com (2603:10b6:806:126::7) by CH3PR12MB7546.namprd12.prod.outlook.com (2603:10b6:610:149::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Thu, 17 Oct 2024 09:47:31 +0000 Received: from SN1PEPF00026367.namprd02.prod.outlook.com (2603:10b6:806:126:cafe::b7) by SN7PR04CA0182.outlook.office365.com (2603:10b6:806:126::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.20 via Frontend Transport; Thu, 17 Oct 2024 09:47:31 +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 SN1PEPF00026367.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 09:47:30 +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; Thu, 17 Oct 2024 02:47:18 -0700 Received: from fedora.mtl.com (10.126.231.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; Thu, 17 Oct 2024 02:47: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 , Willem de Bruijn , Subject: [PATCH net-next v2 04/10] selftests: RED: Use defer for test cleanup Date: Thu, 17 Oct 2024 11:45:46 +0200 Message-ID: <028390b4f8b61024eb58265b71fa09bbf506d615.1729157566.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026367:EE_|CH3PR12MB7546:EE_ X-MS-Office365-Filtering-Correlation-Id: 1d5694bc-e840-441f-72df-08dcee90b7f2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: HM5UNuHqi5y3fLHfkkbqXcdECn+x4KNK8q4zvgsASBaENeEtA/eagU6t3x6jftsl+MWGZACZJox58OI6iCuH3IO/xc4q62fEQoZ52AYVUBjmYGQRhcLszafPTaeEFyVslVqqn/cx2s3OR1soa8zI+0tifFxePwXOpDXL8wQvM3jls6lriro70Y0SrdrJkcoxpRChuHgkwYKHFiWizaRV7D//yPWC6KVLEOZoewt0tVZ2SxiujrW+E1OLxTvWCAoJUxMMBp4AbNvknrMTCqS/+JMTHg1RpQagwdt9TqjxXjDNy8Qi2c1YJAIxl2YRR7l5f+TH1tjjtHEqtDdaypBBCsgcoZ6gtelk8kfcmt5t6vLYh6kyVcaRFaS5Alcq6klr9aHS6k7xfu3FU/UWCoPm5iAm3m2LYC2FS6bKgGUMyxH/UhuxD7pxbTn4ICF19036tyB5zAc6GNteWvU4KFfQ4y4XBTutT9dH2kB0a07binHMUhf315s08xJZauiIBZCecUilNgBrYTnK6h1LHyiQga/ujX4s2IZjrnZMs+aKZSLOmL/GsT32bmkKRREhX7X7efRqgkiu383fRWjwk8kZ0C7/NPFXhPdnGGCShIDUwlZXVAa1xAPvSseguuwdTMl/p+9NVcLZBrbYqdIodORx3edID/oTOKDGS12zcr40vtUbYlzoKY9T4MFv4U2X0fxmkZPKpXVsGW8L7YJtk5TsOSr1csr0/4HJ4fgg/6gGijF8/4VuTEPJxCuiJee+rLShUX/WJplmsoUExPCbIgsUgH4HNE1npDPxjD8z2a/aV6fIf+NcsbtJI+6UqxyxrROpFSAfE50HMpg95oB6j/5MN6QgoW3x3Jyyvy7g2Jw74zxZA8lYUNRcyXtRbeMHBsoAbfVhfQQEDSUejaUxD2CiT9DUVGsIM6qc4xHpQbRuQT4ZniLoBiUta57eTxUujr/+Bw1m3p8T/4UH2TIDS21ErsLSZi5FhkGR96/AtZHXMZcw10VPg3VJ80uwp5ItNPDTLE6bCb7dpUrPMN1pgKLC1/jkevtemiDYFw8LRNIUilLuuPfxj+qVpxAQiAXweD304hID4fEsOLJxzNizieBi838WlwnFzK81jCSi4cg86zIiGZf+DKcWwo8yhhnreBvBMgq09TNUHsrx7KjhQQ68W727E1O+78BEiLaHPjlsyBDh62aUz3cFnwedoPz3604V92tpJDja51iMl5zJLpDsm57ZN14WgeZpV+Yg3rhsl3qGkY6AfRvymTiOguL3Nn9ktRpEMyxf0ylvQuC/hKSOZgxDm4fQ2A6U9JXxH3MqJ4pnUaJgeaYdryatlS2vca/WcEKRdQOELl0HhLCOFFUjJp+oMdmsgCZxgZ4Z6P3C1v3ECcpOemYDf1saX6ZIzwK+tb+T2NWuY00wh7MvSbBAfA== 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)(7416014)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 09:47:30.7495 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1d5694bc-e840-441f-72df-08dcee90b7f2 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: SN1PEPF00026367.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7546 Instead of having a suite of dedicated cleanup functions, use the defer framework to schedule cleanups right as their setup functions are run. The sleep after stop_traffic() in mlxsw selftests is necessary, but scheduling it as "defer sleep; defer stop_traffic" is silly. Instead, add a local helper to stop traffic and sleep afterwards. Signed-off-by: Petr Machata --- Notes: v2: - Defer stop_traffic including the sleep. The sleep is actually necessary and v1 was wrong in that it had the sleep prior to the stop_traffic invocation. .../drivers/net/mlxsw/sch_red_core.sh | 185 +++++++++--------- .../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, 149 insertions(+), 181 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..537d6baa77b7 100644 --- a/tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh @@ -75,6 +75,18 @@ source $lib_dir/lib.sh source $lib_dir/devlink_lib.sh source mlxsw_lib.sh +stop_traffic_sleep() +{ + local pid=$1; shift + + # Issuing a kill still leaves a bunch of packets lingering in the + # buffers. This traffic then arrives at the point where a follow-up test + # is already running, and can confuse the test. Therefore sleep after + # stopping traffic to flush any leftover packets. + stop_traffic "$pid" + sleep 1 +} + ipaddr() { local host=$1; shift @@ -89,39 +101,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 +143,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 +151,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 +213,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 +251,7 @@ setup_prepare() h3_mac=$(mac_get $h3) vrf_prepare + defer vrf_cleanup h1_create h2_create @@ -270,18 +259,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 +427,7 @@ __do_ecn_test() start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) \ $h3_mac tos=0x01 + defer stop_traffic_sleep $! sleep 1 ecn_test_common "$name" "$get_nmarked" $vlan $limit @@ -461,9 +439,6 @@ __do_ecn_test() build_backlog $vlan $((2 * limit)) udp >/dev/null 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 } do_ecn_test() @@ -471,7 +446,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 +456,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 +468,7 @@ do_ecn_nodrop_test() start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) \ $h3_mac tos=0x01 + defer stop_traffic_sleep $! sleep 1 ecn_test_common "$name" get_nmarked $vlan $limit @@ -502,12 +480,15 @@ do_ecn_nodrop_test() build_backlog $vlan $((2 * limit)) udp >/dev/null 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_ecn_nodrop_test() +{ + in_defer_scope \ + __do_ecn_nodrop_test "$@" } -do_red_test() +__do_red_test() { local vlan=$1; shift local limit=$1; shift @@ -518,6 +499,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_sleep $! # Pushing below the queue limit should work. RET=0 @@ -539,12 +521,15 @@ do_red_test() ((-15 <= pct && pct <= 15)) check_err $? "backlog $backlog / $limit expected <= 15% distance" log_test "TC $((vlan - 10)): RED backlog > limit" +} - stop_traffic - sleep 1 +do_red_test() +{ + in_defer_scope \ + __do_red_test "$@" } -do_mc_backlog_test() +__do_mc_backlog_test() { local vlan=$1; shift local limit=$1; shift @@ -554,7 +539,10 @@ do_mc_backlog_test() RET=0 start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) bc + defer stop_traffic_sleep $! + start_tcp_traffic $h2.$vlan $(ipaddr 2 $vlan) $(ipaddr 3 $vlan) bc + defer stop_traffic_sleep $! qbl=$(busywait 5000 until_counter_is ">= 500000" \ get_qdisc_backlog $vlan) @@ -567,13 +555,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 +579,7 @@ do_mark_test() start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) \ $h3_mac tos=0x01 + defer stop_traffic_sleep $! # Create a bit of a backlog and observe no mirroring due to marks. qevent_rule_install_$subtest @@ -617,12 +609,15 @@ do_mark_test() else log_test "TC $((vlan - 10)): marked packets $subtest'd" fi +} - stop_traffic - sleep 1 +do_mark_test() +{ + in_defer_scope \ + __do_mark_test "$@" } -do_drop_test() +__do_drop_test() { local vlan=$1; shift local limit=$1; shift @@ -637,6 +632,7 @@ do_drop_test() RET=0 start_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) $h3_mac + defer stop_traffic_sleep $! # Create a bit of a backlog and observe no mirroring due to drops. qevent_rule_install_$subtest @@ -671,9 +667,12 @@ do_drop_test() check_fail $? "$((now - base)) spurious packets observed after uninstall" 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() 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 Thu Oct 17 09:45:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 836450 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2063.outbound.protection.outlook.com [40.107.100.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 ABA601D47A3; Thu, 17 Oct 2024 09:47:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.63 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158460; cv=fail; b=LRPqWZrEBsiyj5wYInukwbeimOWTHqkaeHwlpmuuqCgiTJ2h2NXQy/mTJtXFJXjJH2Nl4iKEzWWm1QioXezy5Kmj98FhSGV5pQcmuIqswmHesyGkSugJuwQy0sD6PkVpIg8BKh2x/87A4P8ovaGG/yoa+btN8hjAxaQjS94OevM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158460; c=relaxed/simple; bh=9XZWsVsdy78ua9m+mpDUI5r/ZCBzuBv9qeHo1cyy37U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VzcUPKBb4LEUYhHu94yzrsIIBU+w+gfypYHwKZ31RvL5GWDjGChyJdMsG2qWZCzoaNVZXUjak9hhV6vzRXLzWnMly4AuOXj+TO1oP5BkMRRRnVHeF2vPDmqZVrnBtPVFDDWSPgb0iIV2kjpkROdXyxGbhcTPUUqm3/8PWQEehNA= 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=eQKT5h74; arc=fail smtp.client-ip=40.107.100.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="eQKT5h74" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MkPgBPyoPxKbH8EhdJGrBH7vazysxIfbnIZ2RSVM/1xWKgGlinBtGksBSN2l41scabPanAybhbjz1TnAgX75vSqPyT3p4IX79Rfhpc5evS83TI9Qu7z3eCqYynQSxhZYbptmwYvDZ9pAt9p3/TOwiKH/NlHXLLhqqPh3KItlYOHzecdacnBbVFGnKnxNVCZh+3ijRc4hFGm4i+UEGJGaHkdBQOqFQOXAVljUdUs29gkFhCLIXm0Rm3FRfq0JsmJn62sMWKHyDUQDFAWbtqhXO7xHmmssXhld4fZ9DtTr1JvlqMC5Ua2vPHAAQ3qKWI+m0rk3TIA1wqBhxLagLYwyRQ== 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=f8RLvd/Kt/5pb2/IIunlwDJ/N7I3FcSfkP45xHcQ4ZUbgLVdKvrFrCSvzwzLKdx8tANA2bcVHxYzruCQKSMDYuY5VLnt/NxpOAHCDTR/AyyFpc8D4NpT9NS3SPz9fnjK82VoVN+kT2Fmxrzn3GXRoNRzinwdWT1RHFoAyPmYwTobiSc1BECQReqUu2raNRKrSI2P9eYAmIk1ZE6uFZJQOKgIDOxCxsxhY4pIMwbznYCmMDmtEr+GyfSa/5X9oM//zMcz/ghz7IH6MyM/WHtLFYkFqw18lK2hEcfg9Vnj9i8SNCCYkTIJ3XS231OmZEbqJhMNvvLWUQrhsdnTKl/lFQ== 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=xSOfF2v7ewPViEBuf2+/sSDQpyGmcSLnmmrk3nLHXeQ=; b=eQKT5h74FvYnkyLG1L95fOzw/oO9h69Y8QDts3wjNCxvUbfsF6IhaZzzA5HpMi/fNvhxg4suMvVjNEzQdplTYRt/nWVKZ+bLsNxDAoO3wjDknTF0lYgDJ+P0f7gAt32MGjwkJOm+gst+Wt/izSMcFzHZ0qelfuFB4f+XdrTR+mwQwCHWEKbf0aNiwzSyu8a6gB7G4iQbyBhm6Bq86sliPorfHPz8yqBhxYiOdPQHXqk10OheHCt9yhJYl2FlNvU4JU6ds42MXiSH2ZtjUPVt+H58q9xp32PsxBWIu4laNpO2w8HTZFZN4KYWkn+goBEhQbQ8o/IZqQvPxNz5pbVeAg== Received: from SN7P220CA0017.NAMP220.PROD.OUTLOOK.COM (2603:10b6:806:123::22) by IA1PR12MB7518.namprd12.prod.outlook.com (2603:10b6:208:419::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Thu, 17 Oct 2024 09:47:30 +0000 Received: from SN1PEPF0002636E.namprd02.prod.outlook.com (2603:10b6:806:123:cafe::1a) by SN7P220CA0017.outlook.office365.com (2603:10b6:806:123::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18 via Frontend Transport; Thu, 17 Oct 2024 09:47:30 +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 SN1PEPF0002636E.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 09:47:30 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 17 Oct 2024 02:47:24 -0700 Received: from fedora.mtl.com (10.126.231.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; Thu, 17 Oct 2024 02:47: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 , Willem de Bruijn , Subject: [PATCH net-next v2 05/10] selftests: TBF: Use defer for test cleanup Date: Thu, 17 Oct 2024 11:45:47 +0200 Message-ID: X-Mailer: git-send-email 2.47.0 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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636E:EE_|IA1PR12MB7518:EE_ X-MS-Office365-Filtering-Correlation-Id: 5eecb860-5e58-44ab-6b30-08dcee90b7b4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|7416014|376014|82310400026; X-Microsoft-Antispam-Message-Info: r4OrxnmOXMNDgwEVySey8ZInd8xPXb/Zvc6Nt0H3JvXIX8hZSoISsv32ioPj3ewbVYwhm9aU3OKj6FPaYU6y7KoG1tLRn+0R8q9v6ZG5nFt5uN5cK3qYTdsWdKOULkZFIyDHqbzXjdBcLhEaUstQt/SNPaMXkElEnf0XyYsbS7Cnr6XQQKxQKriIFfPtFIgFC/I9UqV5cMQOpAW/GlwDVYyqdK+DurM19NFqb66IjNgXVyTqHudD5NeKdODfgY7aMEtbS/aK4v+e4pY0pnW30a2iOG2r8fSQDQgsb2ITlCTbqIaxEX3ivYAGqs/aoaDAs9pec7ug3/Q71TR05/ofLThN0nyXmLwWDCRKSXYisN+HMYchYN0tFzHgtT7YUowWPAhWd6DcOYwOzSWx6RKDrfN79gOkrjwNlGtMj9ezhse1IrXfVzvu7bpan8Ur1/ascIqIA95NBnSoOw5PyMl7ifOOjpWdpudlMgbWD2jMGLa4IFvxm0lpM8zlbud2D+OI4GFdbpfGK0i6H8p7TLNZs/zIqUNCifiuPxpKXCxs8pvvciw3uxYxnJ2TwzmKMFwP6LIKgy5oZX/HOaNBfZaOqU5fsr6hfy+RIENZiygigKodHzrptlox7yEu7YsjIXGPu0LYC6IAF/46Tm/K2co10FEYeVjxijaDRfCCnb7uhJ0lsxKdkx0O+cN0nOfB3sQpXfAdCVcb+ORT6zpj6VDtioIA1mZ4m+HorzSafQoyNq13IuTrXq4JqcX+q3SlTYDAWVdyJuu0ZYQ/xFfrdZvbkbmzEMw7xlkE03eMmS8I70UDw/vW/vQmph+G5lqUPOwfQNoRcgXn6cr9OPwN+dqDdgbjE7hNXTaraonQJ/DzgKpEMYkIRJz3+cWWbD8UuI1FwQBMZvuUJHor1ll4c8Cs1vaOQT/iqx/fnALMmSXYV8UEEh8igOF03YyLAc2TzTZA1HpOzWLodEbmT17jMBSHkcv3wThzRDJUpec8TQ2h2K3C91qmeAk0ohtken5cBmlM0dBimcFdJWhWNJRGO3iRaDVfEhVz6zv/NKroag1F2o7116NJV6iGZfCUUVpVgFW3QtLu6pxen+4ROAsztLepfBVPr5kcoaJ6O+NDIYmqe2uEDhjcgfRJ4zVB8Zfmxi4AoKdB+ZFFDKx5s+yJuCsL2ZvmEgjdfLbdPBgfO22DTewmgD/4YsG1upy6QEaR3+m5KwKYzLeBVx8/57cDyDXq/gQzMfQKDL2mwV4T8JT+K4d7n9lKt6Bp8cVMBvijK6lbRSEVtGtskBSpXuvC5EcY1Xv+plmzsxNvMrH7n1Axl6mfKzy1mpLabdwFfomnfem0HiQyEKnvsrZrXleJy6LM2gPaQwOVwzFzNienxnT8srN48N0VbpA3SAWrksfbVrkLwJmbKTr7/Yr595RAsbEqwg== 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)(1800799024)(36860700013)(7416014)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 09:47:30.2961 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5eecb860-5e58-44ab-6b30-08dcee90b7b4 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: SN1PEPF0002636E.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7518 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 Thu Oct 17 09:45:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 836449 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2051.outbound.protection.outlook.com [40.107.100.51]) (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 76A1C1DA0EB; Thu, 17 Oct 2024 09:47:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158469; cv=fail; b=iAxk70pUBx++r/GrYjl3PEO1ucAzkfLnc2XW9087QFWultwksDCX3UQZEEtO74w07WSzrqMby18foLA8T+wnPr2e1bz3Iym8mldT3aqkO1V06iEplQL1PVv/fy+sKQi8Nomnbs3uaGWRuyOZEX1hU4CgBDrPTcHUbdcKzVjrHP4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158469; c=relaxed/simple; bh=QmP4JnLTev14VFwGS4zTXKTeNR1iLxBEnCTfB5mvUkc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JLcmXjqUAF1AjjZl0BqnHJD44Nnwht9t8B7MyZbA9JCpHy3UmVSU12ECD3AHC/5KTQxduwQUOnl1/qkW7d2/FGl0FdGlz1rOfpLR8Kpb+LEpX4dvdDmoh1pCpohxWELxbgG9HXADH4neXY+x/zKsTSxgtWRzbuOf+Yms9DNZHlQ= 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=af45y+2l; arc=fail smtp.client-ip=40.107.100.51 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="af45y+2l" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DXL1GIWpljm3wx+uOWIk48zLb7eHtxqLMbBDZZdEd/8WkZ9xrSmKhV3OX72YNDNOID8JEg6rwAdIRAC4fxQXo308DK2Nq0B7E0H3msGq7ffFKV7Ls6N6PZXRuFjonupcs7uKRlYze+gvHlnWU83Kd1ZlsqSG7Zj3C/FZFwwUkEQvXydab/0usC4d22bSnO4JQWQSKcVHFYyyp7R+SKK+J+DffAoa2JnwzAgzDr+PZnngwfgCfE1Mce2FYukf7YAhq+IKQERfL6XZG6qkGiAzDQlbMgVMIKJ+9vH+irc/eR1AJy1tYn9nrWKqcA+4I1V4mjEiOvYGQW09r7V+ULO81g== 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=xx5MHDMPjEZMojDT9RhQ9tAF1+IjUM/RjTsN9Bv/oHFSz6slHuREgvO3kVtQVKFuuMB5O1hZq1NJ+zw+kyG/pK4RzOIi8LqTJD+gYqBzWLESmZ+DbQVE8+1jbMoGZdwf6na80XUMbincXifLSk30gkdm46AAoYpjn3cVY2uLu5NOtNQUtM/GyBmZYw5BCpMx2xhtMdhunJvgRKWGLEZDP0JcA4qZUCeViJPouKD0JCEAqkVkTJh0NauwELzbbY8/LH9Hc9uNVBtkhGy/gCo2B5GYeDcyiOif/K3J5Sk+KoBgx6Knx3ToIwCgIfW9UvuAzY9GqwRkUEjR4JmuX2ShGw== 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=XE4tiSQAFHiQC4a395xfqzFWq0VymUTdBw+LHLe9G9o=; b=af45y+2lqv3nAwb7s1cbISNDLGuyy6F8jgbd+a06YTaN5Q19hByaLXrEffbJ/WSwpv56KrNcfdkPMuj1t269WbbAXBpxQtWxV9OR8xWZgBqOmbXw2lyrejaKkW3bs3szkbxnj4Qt3JnCJ2SyXFrNSa0OiDHWSpeGMbE7sKce93G8PKVb0+rlUWaCQswuWHui9pQoZcSwsqhqSmLITA6pXnAvQRZEda/dPATV8Vh7ojiCNy6rZfXlB4BwAY6N66VJuH/X3ecKZ0SFEzZI9cd5LOINcEnKQa9yYNHJXD+G886D48rSpJBi0nd6ntYJNoCoXOoFUyW/Z9K2hUXZYw1Cmw== Received: from SN7PR04CA0194.namprd04.prod.outlook.com (2603:10b6:806:126::19) by IA0PR12MB8984.namprd12.prod.outlook.com (2603:10b6:208:492::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Thu, 17 Oct 2024 09:47:40 +0000 Received: from SN1PEPF00026367.namprd02.prod.outlook.com (2603:10b6:806:126:cafe::cf) by SN7PR04CA0194.outlook.office365.com (2603:10b6:806:126::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.19 via Frontend Transport; Thu, 17 Oct 2024 09:47:40 +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 SN1PEPF00026367.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 09:47:39 +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; Thu, 17 Oct 2024 02:47:30 -0700 Received: from fedora.mtl.com (10.126.231.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; Thu, 17 Oct 2024 02:47: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 , Willem de Bruijn , Subject: [PATCH net-next v2 06/10] selftests: ETS: Use defer for test cleanup Date: Thu, 17 Oct 2024 11:45:48 +0200 Message-ID: X-Mailer: git-send-email 2.47.0 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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026367:EE_|IA0PR12MB8984:EE_ X-MS-Office365-Filtering-Correlation-Id: f3eb8f07-5d0e-43cd-9523-08dcee90bd67 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: oH0JaVfBQjeTs3NvpIvR054RQVI2UeSKxzT3k9d9VfBpBm+STwHa/PsaPkcEjEarUErqjhafFRuE1Pt1AN95Hf3Eo2imHAR3pgB2q5Sp8TKC6o4krk2ie7Oipy6HNnzK9PDeNicehicI2L/04fATlcmcPsgyAvAKK0xm68FZEl/k5azwGjiIp85VxQnXOuCFvyS1pW++EW+aAs0TTqYlpM/KNNtEm912kB6yfEIthxZrKqARce8fh26n1IMBhoH9gtK7eNJSdxJBS5cPja5XvZR1Cq9Ck7KlxAtBQH5zGge6EgGj+NdsS+y0CTDK7EBKOuvyru/wtoS7qhbZPEfPSIAzQOnE0terOsXaglMf6tS++kw1elEhGgt8qjQoUcz0Sv2jGAt3i5gJjekzU3dlQ9ym/fsBwVmt5B+omVuK2ZoKTDPrwZUe1o5xItsDKmy/pUYqovPVF72gExe4Wpyu+uSdq7RYVw+/+Snl4N95CPX7PK9enq0+h8kchhV9MyoMuBw3KjOP7B8ZI2VF9gBDF9Qb4Dy5doOb6wvRZ+jJglAHfACE4iOuLm1OpadIVeleXtgg/AdsyYhSWegBAu7It9unwfjW/jtyGvpJXFK07292MjJDvxqVTTU74oItEVyb7SZ0JW71Ut1FAw5qj0WukNYErKCG9XzgWIw2dlRrDtEBHL5b5IGWCU07fptkPwYkuI6krFAIOwKSKU1FjgcpvycO/oQA1mnq6TSOgpZxn4XaaVGQ9wzgakbvolEUDeM6mbbi30fA1KxBZv+Q3X3xAUszITeHMoLFi1MVQxqVJWZnM0BQl3h7Fg+fhuGaSOH5FjQb5UxTet+znhv+HstTQAG6HRF35PlYyIumRDVXaiA3E79iNW1DlUthdbWms/uoZbnjmmnhvMH5tsytV55cdImyn2TSgFd/SD9kr+ePpKibwYvQGXcvwJP4TfD8849WAwJ2RTbacJIraR6GUt/le0Gass5M8/r8n29ULua4CF9hi1AscPeduVSR0TuBc4j9YWxwddJfNt3OcWeN39KTHMCX4G7NvO7T0xy3D1+skXTi2LRR2uTXKhpxsN0flZyj2HHHewLYkK3JvvsVQaYWzv2B7UYjbx3DKHMM6RoGXs5xFXE0axl70xYrNMi98DTCIDeaBH6si/HRh0XKPRoV7SNHbOYLzCxbYQcf8Ir4iAAQjygkEx+AcQlNwe+7y82O8CP4P6KZRTjz9Qgv9k4BAlz+xrWODI1p5OXkODPMasCA3rLwgwKuC1cpb/APfTQVfmgbuov80DoYl8v2woI2LNhfv2D4xuNBou7eHF5/SWfme0btFVKwMCtbHYTYpToWDMBT7EEgDbAj8ajhCYyLrUepM72JSulP3F547r/2NcLtHfNuETPXizSVNBaSWyCpMKF2GViJO1UF7Vh7EV9Gtg== 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)(7416014)(1800799024)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 09:47:39.8745 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f3eb8f07-5d0e-43cd-9523-08dcee90bd67 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: SN1PEPF00026367.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8984 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 Thu Oct 17 09:45:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 837101 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 85F021D4150; Thu, 17 Oct 2024 09:47:51 +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=1729158476; cv=fail; b=QqPVdhZFZ+X5AEhrlIzPmKdxb1g6DyF/cosBKokczECJiIkXkWE2K/EDy11R/LJhKIX7kxsYNKLHI0cN2XKd2NRtCsehR3FnLVBEPsZ/24oFUSrbhyprHJZ0KH7BSPoy0opUSbCeb61rJy09Aqn1ufif7v+P03CNqTrkk5jOCkc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158476; c=relaxed/simple; bh=4UNfkLX79XHO8aKgsnUpO3c4HNv3wG3RVLnm1Ac4Z9I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SLAxLBg4AD+ySGOsbcaaYmJL8bGKDcK3tVoL0t1QQJk/BjtUb9JTB4iIwFXV03zf2rMQrlmMAHuJNCVGYTAOy9OE4yln/cGGi2kHTIGKQUiP3f+s7wKD4oFRv9ARwrY9E6xPURepMqSHDUEGb+qDbkYkoF54ZqOk1jneRGS8Kos= 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=ej/d9Fgk; 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="ej/d9Fgk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=I82vD+CFA87di32UBd1bTS1gGo6IqyR9gLu9khZ+XGvPb18j8j94Zbk6NrecI4BoOyRWAHkb94D7svl+P4rKoGJDj0P2ixA9dZuBrBiYWmmack12W/Jt1mQ6lofDJct1ed7/HtB1WY7IP3TWFX9nIeiHbmRKZri5ARixSqjaehkQoxBCwV3PWFmb6DNJ9Hc2G93N8mzoSl1ih+ISUYecn08g4/Y3rcUNX17ez6D2vC3YjWq1kE8z5uHA1QTGER5bVDAJGKYGtH6iIjjs8wLnTsISkc9aexNfj1Vq/yOaBWZheX2oRr+ztEzdiNORiM/6CpDEB5YeSys+MeNpwbB+PQ== 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=upZYWKfQus7HKhwSb/5J2VBT5bfiYWY8+21/PC+HDp6xaWkR/e51EWOQgi/CIo3pRp17Q6onBZaEZI9aOJmvR42kdzpq0IPZOH1M4+BDIB+fXFGa2O8e2HYtml0b3pdh5AmiSYzbfUflaXAN3rQDexFmddSgLsLwyNwSPAxwPWU3vgXXf/Zcq3HO7Mi5oaY/XRkHAVawHFa6AJO4BdDqaglhKx2dUslhMyYjBn/8eaF5ZxQ0DOUKtr7gYa0X6RLdGJGsyv8mH8fwlUDuBf6vZK0kW62qN6vlb8kJVTeoUvQW+Yusinknhv0FzMkWyI5sn7k2eQzEk3oTSrfrki2sig== 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=ej/d9FgkdsEfY7vE1hwkmINFBHR8572K7fL2U5sciRF3WJ/f0M7SmPcr3x3BpQXOi6wMMb4WRVuD7BgUBhjF8C2Xq5e2MfjKfdN9dMDwINSl+gWxQQgPB/1H2TTulilbvbK8Xug2zs/J+f917U5gkCuIlJx59mJ+mrP8Qt6j54m5kg3Ru+sx186R1bvfZAn5yUkIOvuNLBUOSzOVVmVrwlonYKsb6BLwsl7z+LLAGkw4YgAfQsB/8B17LOLw1PfDg24TjwwGdf1hZmazbclrSgNTCCLik9BsG9w2TMKpwj0t4R7aBdm4r2kestA7wLVMQahIAZrWNdo9aMD6OPQlfQ== Received: from SA9PR13CA0089.namprd13.prod.outlook.com (2603:10b6:806:23::34) by PH0PR12MB5645.namprd12.prod.outlook.com (2603:10b6:510:140::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.18; Thu, 17 Oct 2024 09:47:45 +0000 Received: from SN1PEPF0002636D.namprd02.prod.outlook.com (2603:10b6:806:23:cafe::9b) by SA9PR13CA0089.outlook.office365.com (2603:10b6:806:23::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 09:47:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SN1PEPF0002636D.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 09:47:44 +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; Thu, 17 Oct 2024 02:47:36 -0700 Received: from fedora.mtl.com (10.126.231.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; Thu, 17 Oct 2024 02:47: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 , Willem de Bruijn , Subject: [PATCH net-next v2 07/10] selftests: mlxsw: qos_mc_aware: Use defer for test cleanup Date: Thu, 17 Oct 2024 11:45:49 +0200 Message-ID: <2eaee7a73a65f435a39df0a4b8f83b0702fc7832.1729157566.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636D:EE_|PH0PR12MB5645:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ac20efa-48c0-4096-aea8-08dcee90c04a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|7416014|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: Ay8ZJb3Rudi+jHo4opu6oyMIhmDRcs703s51V3HxemDwe3hX7tTjXzqUOhsaQcVeH1//FMc06zUNr2b8q6GP3L9ChOiL6r9kWPpjnBLvkRmHI6hMIAeiLmqT+PzzDIX0P8LzxVJrA6nm0GX+/JstCpBaJvo0bb+dllAVEiZrqyq0gNOToPe80sPWqQd/rqYd45/e20tgFTAKlH8CY+kYY82ZYIeqQVQO/Vf6a1JxD8EJe0nD8x9fZqoFGqwQIiwaFlgJR+TUDoOTh1dqbwjgqNTV27qJBs9H0F/hbdbc/LW7fwThxd90HPhEwgHiEmbWZ0O/6kbI0h9DqsJt9PsEloarCtuRfn/vqZqyBayRttiq3yTl7mUknQoeSS+oh40tMt3nucGxjwV5tmHjXfMg3fxvbkc/IIT1cxoLDH13/Z9uJmaD0uefXIS40cXKVllAHAJBmBenBdmRLkq7LA2Ws9dtoi94H6Puw51OMB3N/5TIdJ59PtvwB325gMKA1dhjGcbwxj94vkZCPUhetDxfyXuQe0As1Xe7UI0ioi9EMB+vUjQ+HWt4sFkMbOzqOapzqNL+/JFEzvMez6jz64x7hSxSXWOBtXgT2bRnpEMRjLke6DtEd8BdCTSkTZqzf66b7NXcncF4G7Nn4s7wjOnjIG2CoSVXHhZ4WN5Xhp/AlwMOhQt6Ip4/2PDqUZHc3IXklRMFKl/b41WJ7D0JQSsHHH1EPp7maQEzfSIWfQDXmLDq1G6iR8MSgUy4na1GiT3/Uq6TtddatN1dM6SOIz+7TJAnvHg0E6zqv8R3xttIoZJyY4EmgUjvf0LHamO4T41+ocPEoUGnFeCkEqnuvgWT+MXyw4nrXKRkS6wTSXKnkI4symJN/GDHHE5b1WSYLGG49dTjIJIuKI4tC3CFpd5zyOemDNWt69Ye0UKNr91stKYJ0EZnSQLpAvI5to+v0TBreHug+zknGiadziSmDASHHrHkf0Huai6tMhBASIhHGWm4mFNaQB9w0T6BYzsCKH8sgo64EcqXhtaLe0yC+AR+us00NW1Qh6D8977HgtKOiofSLr7erhc9bPFSnOjp919da75wv3sFJiXtAwumgxVN0Q3GqMzX6UoV+f9r2E9hIdLs6QONiG4lKaX6CMHgs5rHyBf9GmxWBWHYYAJt5L3Ou7URVfF/DHq+p+eGz1sBxOHcS5aNA/9alZbje1ySsAfW1FCnvN821KxFnHc+jmQzvBL335L0u8Wh8wSMbMSLPRJLlkgwjqe5XEApewyfMW2gNwOGv4UsnECXeIEolbL81Cm6hniSnFK7F7ouNWM6BCT6Ti8R4UNVE/of153NdkOWBj1tTlrDUuuCiABGTQbKuLvFNI6WO+MWhFJhRP1eGMS7+vblReJ7kjAGdmo6ccZ0qALWnXuVjbdbY6X4HkSsNw== 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)(7416014)(376014)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 09:47:44.7182 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ac20efa-48c0-4096-aea8-08dcee90c04a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF0002636D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5645 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 Thu Oct 17 09:45:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 836448 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2041.outbound.protection.outlook.com [40.107.93.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 490F81D959B; Thu, 17 Oct 2024 09:47:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158481; cv=fail; b=idDkBI9vHpKTruOBRyFGruq1V8IxKBaEOSXWluDKuR5Qwmh5xbqhJZzEU5AzzwdTrdhir1u6F1lixUCTbf9r1gJHGteVJ6/TSatnbFR9wwlbmT4Z464lTkOvQ24NA0+oliaTrPQxnivy7Kzx0IK/cv+YOkFrFtufl05IRqek4xw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158481; c=relaxed/simple; bh=rpy+x0vc78lZ4LbaVLMTj0KPKBxawl7m5ERl5vdien8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=u0YMpqt9tUcDqrzuI93NOE9UQlSDCpzs7qY+g+XFJuai/C2nXHtoxrOdPbpdX8e7xjmdjGdoPbTD9lAhQIX9QuBbA2RMYyqzqNBOsLtA42sPL/dLA+qK6Hl8dtzPIPAEPnz/oISmpUpD2NXljIqm9pdWol4j0qm3kPwV2HPUiXE= 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=Gz+UlybX; arc=fail smtp.client-ip=40.107.93.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="Gz+UlybX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rgeISKrVGKPoolxcEWEjdJ0PBz4i4EDGgssRWaG+DadonGGxABpyNm2oONrdO+VxVi/pVn3up8vNVU3PPHdkTWXl6zH9bxysUxs15vqJN4FypSk5KyPPVTEiu154wVo22NFLBqWtb0PpW8RdBEwoaontZuetxgw3QMfVLIV/03o4UoJk0idTDZ5+eWSh5aC53QXs5jX5u3LP2iTZliy+ket8cBxvw8hH+JNHfL1Hsr46NHsFuvyl6qxxu7WXs8h5yONr0cVBbq/EjjxXply6kTXGceDcxnHvrSfMcqTKZX3WKhDKJIuGosw6H09BZCHGYnFN8oLFEycGh36Ef0ij6A== 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=RoYSqZXcfF+MQcIPJzC6QdL/HI/qv/FLSH8/n5K23uFJMxUBB6hyzfFZX9Vj6RhUI8ga+b+e4lTygMDvjRda/BWrP275pgHv+caLbK3EShHReajRri5bTyLVwLsXoxra0mhjH+4UXugNJcio49Kb4+1QHU9zvW0d8hUjyQJii7kcTa7rURkukc4c5iV6/MXtCjg6El64buizToZ4izLkbNjkvzRs5/COZfpml0zb10+xFVLKhtEcqZ2ukhegVfOaGFcY34BK6xNG1tvg7ruIUCPpZNaGzCQ6iwNJmMRqW8NOo4Dy7PELMRecYNuqvl5TNy1stT9J3v2+Joa733qHng== 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=Gz+UlybXnw9ycCL4p16jkd0fwPUQVCtuNkacVN4vHtOquEzZU6usvBVoshqAVEzQU71sjsHsDfL0cIr07qo5fU3C8Pk53fsf9ScSmtyayoPuG4/0EfSCJLXTYWoOw74boC8Y/UxFfZlMgGtVow/Va9PXcI+mi23NEkI4wlfERau79czPzsnwL81HSliKwnvuB0bg3nmolGWbHeNhsOHfXDtU3f3nioSWNPWyXTjTdCxP/YlQSrWkKhnpA7ew0yaxsyZPODdgzYoG4ByTVIqlpCDjsAk19tI4xBQE921K2klzDbg49Q3fftsXCfalUR2th8HCvaIQ5DvCdRY/rACyIw== Received: from SA9PR13CA0090.namprd13.prod.outlook.com (2603:10b6:806:23::35) by BL1PR12MB5897.namprd12.prod.outlook.com (2603:10b6:208:395::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Thu, 17 Oct 2024 09:47:53 +0000 Received: from SN1PEPF0002636D.namprd02.prod.outlook.com (2603:10b6:806:23:cafe::42) by SA9PR13CA0090.outlook.office365.com (2603:10b6:806:23::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 09:47:52 +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 SN1PEPF0002636D.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 09:47:52 +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; Thu, 17 Oct 2024 02:47:41 -0700 Received: from fedora.mtl.com (10.126.231.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; Thu, 17 Oct 2024 02:47: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 , Willem de Bruijn , Subject: [PATCH net-next v2 08/10] selftests: mlxsw: qos_ets_strict: Use defer for test cleanup Date: Thu, 17 Oct 2024 11:45:50 +0200 Message-ID: <5a663c264a066846d1289c0c68df70afd6377d53.1729157566.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636D:EE_|BL1PR12MB5897:EE_ X-MS-Office365-Filtering-Correlation-Id: 1375f0f5-de93-4231-c799-08dcee90c4f2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|7416014|376014|36860700013|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: ubUfzfb/sCvbf0BOtn/som3U19WedIP3GRYKKXNKyj2fH5qIvlEhKUsY+TiaI+Fb1S77++uCH7u4JGO+e+o+rsLe/tyQKtopNBNNNnGQg498BHBCcbeN1m8V/SPgUk3pXunLyWH6h3hi01xa8w79w6fW8INcU1rj3DjJ6LhW5RnoPpucFQP89CeaXvMZ5H140QOYLvgL1v/MMIACwljSj0tzr+TaHEX9tYtMQ7wYQTorx05w/LAGPhnC38vxUgI+aw19MA4OFw5cuxpLTqgNvugGf8kWm/o9N0Aav9ER95RZnbwbVJzTb3vEEnzmFlglkXegZaAdrohu3CbCeeQUUMfM0NNRpATHCmHyJwqy1W6JpWKELV0Fjdb65YX85DoKK8Ot3y23punFF+4+k0yO6jRspssv30rkQXo16OGhV9GZwCm1s4yd8ifGSV987jEIIMEdhHOc/SsBuvAG/Pzu1BKdqKiqAKAQ02cxWNQRrp0KIHr1HvYU7BbdpY1czS5U+KO6RJms0MFRl20Nq8QePweLcCEemuefuf/O6hXzM1wN5euNsbrkLDc2FQ9EX+w4mxnlh7MfRerPYwPTHHjMjR2E8JSYQbxGqAHMCjzxV8rwH9Up+twgaBIwLbxnnHi99XTvOmPCuk99IEELlTHEt0vA9ksSAFUGSnpHj4XKsLdmHDyxCT3r9wJKBjEOSdoFAVoRl7mN+yuIo+EbtwwayUGq2mFGn0nwYklgFt58oP64g0KGNzCAQ5AWztaA39PMpR2xw/2w00CF4WiZSuwRYnT2u8irVYLTdkFWPA6YmNJoO1+gniKN5KYc9cmhTUEIrj+iMqN1xqs7hxV8C6w3P7ybUxcrtkiws6BT8HA7Si0HMWtJgTi4Icwm/i+RCrD5azSqeataddJVVnH3UU8zwRKAJWScTmcMKfAsI1X6ZuaE3NGwfse9P4ZRAG7heWz2ZzPx5DmJGe9dnZJ137Snq4JmOFJSSyBj3VHQUkjZPRy/B3RDE2qubsIRcaJtZOQDUuxmdfPlBnTCwORE69P9/EJSokudKUvZuCrM1EXSwoIZ37rLJmZtD9n4yqp40bKNDq0vYf/QI14zHWnbe71i1kGmsw2+EVMtiGYdEq1SvwUdKjgzgbdm+Vtnq36LDZBcMemSIetTraz+kfW3rS3CDHtjWzGihiuCfxYozoe+gas/aWOBoq2xVMHiIeLNNr/gnwuPnPHbLTlu3RizW6G2I5NhLRjK2+kqx9XkO1n5D39yJj7OHFwdIlciCwADCVXwPjxNaqkKm4JQC31A8lhetBYtTpqaRU6d2cvN+fMFDu2oRXhmDLLQARjfs7RJOO9enyP6Wp8Ro4mlbGFGqhDNV4mw1E8AZE7tCcopVjlhAG7UcwLolsVP8TV2F/1RzrGfgYdkaWahI8qKGu7/gfGsRg== 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)(7416014)(376014)(36860700013)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 09:47:52.5309 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1375f0f5-de93-4231-c799-08dcee90c4f2 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: SN1PEPF0002636D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5897 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 Thu Oct 17 09:45:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 837100 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2076.outbound.protection.outlook.com [40.107.92.76]) (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 201FE1DACA7; Thu, 17 Oct 2024 09:48:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158488; cv=fail; b=TjTZqPeJ0RXI/2RvottYinczrkscowaZYS51oA+ATdMJqnXafmt/nAsNBLifERBY7C8/znu6cijVibAEMsYgZvqMOOeVtAU4NyMNN1jmT8m0HzaDAuKs/qrR87MeP1ZDlMszqy8w0zl+Cha83Y44GL6kK8UCVUnhVDPdulBeH3s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158488; c=relaxed/simple; bh=9PGRiBQm/ApCeGx5PATZWY6/Ljsu3RCC40RCRLULLhQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NRVK0cKCywmU9kafegY0qETHf+I4wGtUFx1CP9pj0uuRUobqulvpjziEtX8Jz6k+idSUPawDHcvFGKDqoH9dj+LematrWthpCGJEW8PMuCSdggz0NWpEqZd4m9NbSjdSdMfGstkolljx7f6OZcv+aQym1X+8dyD6dT8ipbvRfbw= 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=VxO72ksG; arc=fail smtp.client-ip=40.107.92.76 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="VxO72ksG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NEnkLrL0W4ZQpMwrrZ1202vwALk3ADb+5N9OzkBvSLp3ZBFhGvyIiKbSvlVYR+W15yVF8ReIRj+p65iLYjlhBCM4uVOhaJihBNNlBc0LpEqXnESyDFM6AxSBH3WWYB9QW+xLhWuFIfkbKpVbl8L6zqRKcntebo8OTagpVoFxzG0DVLrHdXAX1X5ThpnFbJryTeraOis/3bV0qTQ8vyQ8ABqT/MICQtCxIO72TKIg373fuoXQlENP6Xbgm4AGGVT3f26yRCmjR9UwkBT680Zd5AlkfnhZ0svY5s3rXsFDzjR2ALiH4MdZhvgcpvXcPhm0tTcYxPe7wDiACYgFcyutHg== 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=iXO6fS3njF9sOFGrTKtOIEclGvnhxRJGhbp9quL1vXJ+zbYO955xSF78OyaTluyXaH5roMArBvh5L+i+AP6CHXhI3NwZ7sX1yaHvH+y0n+36ot1YhWruPEdn/l8Nu4/HGco9yok6IPkZwT6jlBmmsDkTzGZxbjMQFoHTvfReWoonEgNXlxs0r8PYHnF3LZ4Ey9Wgls6TJ/wxXRcVPE2BC7lyZg7+Ik7xZlnFB0NimBjX0SYAmyzKlZ4l5s5WErXD/ceeOxkZCHdvdkP/BaBLjAMP/MOWEiF18OE2yLTPAFZrFKpz/L72N3+xurYPQIqduIDA+wZBU2akf3dgDDj1tw== 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=q/1i1D71+QW3wXnzlxEgi0qBWvlZaqrZR/7tsBQ6nkQ=; b=VxO72ksGHtLVup59wWQH0KUWnvu9OC+4itMgZZFDLGzxEhHfzP5ZluGnBVt583jqSyWQ2RLYP8vOOj0O+MwgffbyLqmaeOePEDhpUDM8sOkDG5ghqx3y9VtGWM4fwrcFjzbTV1gaKdo7uWz+fM6EsNscTBwlPX80gAoJqqZKvrv3mIQqKbapldZ00SmT63hxTNwTe2SKD+y6n25Pxfpxxi8J6Kh9ZLRSioXdbIhs7nn9VKLt00ayJa9ZN++HDE972/MDVDwfQW5vy1zBNcIG2UwY2xA4MRJ+E/cufrnCD8O9Q/fgcH4SYAKImF9znjF/G/EoxMWvgAj34VHQcQ3svQ== Received: from SA9PR13CA0087.namprd13.prod.outlook.com (2603:10b6:806:23::32) by BL1PR12MB5706.namprd12.prod.outlook.com (2603:10b6:208:385::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17; Thu, 17 Oct 2024 09:48:00 +0000 Received: from SN1PEPF0002636D.namprd02.prod.outlook.com (2603:10b6:806:23:cafe::ea) by SA9PR13CA0087.outlook.office365.com (2603:10b6:806:23::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 09:47:59 +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 SN1PEPF0002636D.mail.protection.outlook.com (10.167.241.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 09:47:59 +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; Thu, 17 Oct 2024 02:47:47 -0700 Received: from fedora.mtl.com (10.126.231.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; Thu, 17 Oct 2024 02:47:42 -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 , Willem de Bruijn , Subject: [PATCH net-next v2 09/10] selftests: mlxsw: qos_max_descriptors: Use defer for test cleanup Date: Thu, 17 Oct 2024 11:45:51 +0200 Message-ID: <0386ddc48de2fb35608e4976262856a33d63c681.1729157566.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002636D:EE_|BL1PR12MB5706:EE_ X-MS-Office365-Filtering-Correlation-Id: a3041ac4-83d2-4641-bd6e-08dcee90c936 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: 3kmDgyblQeXL1HVfNkP69+U+qM2a4p5dVfT7cHsCib7DR7Ou3Bc5t6B+hRC9XS2rbBQaKHbW5jbf5de+O/WSqXICW/a5H3JHXuGhizo55ja9ecz9RHQ213rLhCvZTN1OGYyLlf0JAFjpjByw4dUHckoC1Rv0zv06NmQVOMnHsZjoYnE91DLaRUDx9CutRau89oUx+yZbIEhyOtmJ69i8MO0snFlvhuUtF2P+Ui0Y9JbTe0t0xHr0FyPdcB38Dn1W2MExXlp1ndy6ESD68CtpXQS0Bj0t47zyQ83BpM05umClaPGF1nN2nYT6ObaRjMXohUAgYR7a7AOzYt82nBSUYPpai9RkkZghc44Z8aMk1d9SsY6/VkOVB87m/8Yejts1O+eBMR2rmDyiwQusYIn1wmvqbcjpFbLSYOOC9KNipPJh3CaAuDgZ8tAYwFpg0AsU24YQj6Ko8T1/caNdR4Tt9VrTQ3qwW3BVZpvjpjthkm3QENDXuYqhjE6a90/NzawJmP3/vws+pAKcuYF3eazhEAvCtjxuAdi72CIg8dUpTW9zPAigTm9UivCHDwVQEemWnAjffAdP/W3rO/fZHMjJLfEZzZfvRxZZMUa7QRs6/IVbwCs+lrjUI9ItLjnjhLI8rXzGLIxud5wY36QGjQDxEgfgXcMIzZwj5ABoL/xEjiHJaQvZSAsNpyXQy4jrRGlbd91ja3ewlLgHPhw5SQMkqn4XrWLhCnJ3Nj9EBYgWKaO/oIhtZQzUW7hMKPpHl//fqdTKFJjAJXdabNIfywvuE8CKhefyzx3ZsOlzwcqMoVom8N7sLHorN+0D+HtABxdZ+j7Ys1yfODSGHd+5RagILWQtAAPZEirpR1eNjKHOldLFuu6ZehlSFfy5NYkmHKvnUXMA/yR7w6mlaBbnfCYtVQVQEGOLxS0PGnLHhzebuhE9y5fKf79FqPOezSP0Qre3+2yZXV2L9rFHDpcIWHphYhwcXRaMha4UHbXw78ObkNnZ6/9Fet6LBBen5ycWOOB3OlrpdSqIQH0h76KtJH2ho+Thj5AVCeVOuOB17XIvaguXWrLB4QTpdFl/T0qf8uxDi6pGUnB8bjxROZRZUDLzHu9wIZSvVQCumf4M8sIf5Tg+R7HCTBkmgkp2JJ/pC1ew8ZBe3Ou3OANPKUqI254g8H4tJQCwkjriqAIdobH5P4DzvPbqNb07LRgqFgdF5XKXNN25Z5TTycvGa8FfaGPuIODYaCeZqosoZ3vGH0HgAsmediBaf80JF2Z9xfjGfWGBO0bde+2HoBO4Vw1/XqZpfBu8JjI+ZL1FA6AAbavZJYJ5FnHm3omNe/FuAyTfBveKD1a74WOt6XwYWo4qazh9BRPhDb/yC9iZwF1cWjJCWEazKjhCdsaZ18x/izQL9F9cBmnzg+cjhprOf0rGT6rJrg== 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: 17 Oct 2024 09:47:59.6870 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a3041ac4-83d2-4641-bd6e-08dcee90c936 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: SN1PEPF0002636D.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5706 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 Thu Oct 17 09:45:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 836447 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2082.outbound.protection.outlook.com [40.107.96.82]) (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 001CE1DC195; Thu, 17 Oct 2024 09:48:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158496; cv=fail; b=ohaX/J0GkQoKQ9vGO7RQ4+ecX0GEbZSHFDt6tRKQ8wGBvtiEPysMTzORteX1+NhsPRFBNbO4f6s6NLN+8oaQZEYCW75WeR/jMJDADKPA0vrj2XIyU4NFYdffkTRv8Ftp0/zb/Q2u0pH6fVW+ovXMkZZkOrCnLwJfMb3TXwvT2QE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729158496; c=relaxed/simple; bh=CGbzMlnE8NQ2E0+7jxlDy4cOi2zh+2y9Mz8URLCBqXY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sx8B9qH4mM8s5gxvybIWYv8fBoYjJg+9PkC5TYCj5zdacGN77nNYEh43xOlpHgwr3UZlIyarEbkpngr+wxIbXeXJAOc/+8j0oQUKlFQ8EPld83dkvEov9PyZM8wmnDc3HoO3ybdPbxoQ88Fst2LgU6aAzaRs/rtKVE/ZReP8w+M= 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=d2OJRtzy; arc=fail smtp.client-ip=40.107.96.82 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="d2OJRtzy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QascfLlZ+FUws5GEc5cd6dh/bcyzYStTynsNLHVmcf/iGiUi0dcC9CQdXgj47Ts+KeHQ6QEBvo++CMynOvCeAJLoPXHLoBZ0SnDzYRQqhvBwEuFY7LLn5RH0h5CKskwmqb+KcmGrQDKV8UkR3mclGuD+ed3oKUe0G3taGhXOcA5Mw932JrSvS3ey1WU3Em9GCq267wwq8TuJLIaCfUlHfyDszol1kilivSKoDZmg72oPpZpNH5bT5nNrhX6gkHsf5ExnexwvL72UWLk01Uk+uTHmyFKQd2x6yZkssRuVZUnUCJ0fqOnY5QfWqQ6nuTrNmNuDCad++W6RLiVAnfAaRA== 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=Ib8I5wWb7V8pBi12NevO3rDukoCZ4UTBeC/BM8y2fJzFiDx0F6xWjoQ2rRwI3OoVyN1L5bRF4agwkLQQuyGkzlB7DYoiNJMDjcK3HLs6DnqV9kuCIO9IklpkfrTmfOyuSwo6sK9P5HeVy6wMxf4eM8tlNpkNaqSfV/xkYMWkCFtDGiNfuUJ1VlHiRG5jI+eynIUIb9fx5NgjgXUbUXL2RJIg8BY7m/4qT9w+qH0OWMUezeDa9XTmKWj+DyLII1q1d8gGCsCSnF50hKL34BAgBX2JJCXQjbI+Mbyt3jBQf05YDCvXkXIMRNN1wUA4iamgD5rEQvKa6pk22PrscakpAA== 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=d2OJRtzyeS0JTP7sgPoQX+jflD/ecIaa+9WKlzVosoCfGzaYiKDYDpzWnZkuNboWjpFft+mINtvYUKffk/6dvkspoyJOD/Ax1FnnXEQZggh162zyWug98JZaTLbzqSdjnbHjzC5OxDbBapzpz+ablsrPxEslgeL0bq2R0GuoQy2Vu/gwbWtgrUpEpCpWf/a7fHVP1m2ykBUsRwXvxAMW58SH/gRiS/aKtKgkS4fPcU6/k2U599ywPsQ2ffB2m4Krhu+Vg18PnWvsvgBSnqIfmmvrTBFnPBdglMVxN7JI+FHDROpX+8Xnj2SoMJVU7v5J0gHBZodyf629F28l7ur+WA== Received: from SN7PR04CA0024.namprd04.prod.outlook.com (2603:10b6:806:f2::29) by SN7PR12MB7854.namprd12.prod.outlook.com (2603:10b6:806:32b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Thu, 17 Oct 2024 09:48:08 +0000 Received: from SN1PEPF00026369.namprd02.prod.outlook.com (2603:10b6:806:f2:cafe::7a) by SN7PR04CA0024.outlook.office365.com (2603:10b6:806:f2::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18 via Frontend Transport; Thu, 17 Oct 2024 09:48:08 +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 SN1PEPF00026369.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.17 via Frontend Transport; Thu, 17 Oct 2024 09:48:08 +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; Thu, 17 Oct 2024 02:47:53 -0700 Received: from fedora.mtl.com (10.126.231.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; Thu, 17 Oct 2024 02:47:48 -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 , Willem de Bruijn , Subject: [PATCH net-next v2 10/10] selftests: mlxsw: devlink_trap_police: Use defer for test cleanup Date: Thu, 17 Oct 2024 11:45:52 +0200 Message-ID: <35d5fd1600f9440bc94ea683aeb66d6ee7921222.1729157566.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 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: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026369:EE_|SN7PR12MB7854:EE_ X-MS-Office365-Filtering-Correlation-Id: f000b2b4-17ef-4a20-0760-08dcee90ce67 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|7416014|82310400026; X-Microsoft-Antispam-Message-Info: iKJ+zDnaMb6ez+fYl/gJ8MFqaCmEuWDCmPz9YIhGiQKTXG92Hh9jL5L71uZRuAp1TRkFyBHFVB6eS92dizRV2l95Xs5G/Em2K7PIVLA1BHFi38pxkds7My8yQTGZChtidIaOMHTyQs//Vd5KQu8p2vctZAmMNc6Z/6DBwEnLrKmx2VB24TbwYmsWXsLBHKWwsyfDF2Y+PaStkYuUttZK1xmUzdXiaYqWh79KNYh51EtXYeBU/yDpmR4PR5oPtyi+8f/OnL8VnrpYCJVIknTwiE0cPr3Rs1YB1cplYmHNkRfptUp1SOd5S97CpP+9GQ4F/hDpYdhkdLb3Fb7imwLLCfI35cnJRCdEGt7ei0DalOKxOPrGqGFVQOfb03oYmS+WG3NwKcBFJ1sPUgKNS2E7LsvqY6QL2VHdfy00BS/VzvAuMg2gu9WOH/h5QC6P9WKJ3CYZVC5Rxq+Xd5QGA7LzVm78iqbWVRAsWLDON3svn6YF+4s8Vy/rbetSfkkq5a25Sm9Xr08YiECgk6feqCYX9KoWEGdeywHCN3MvX3qeQ8cxGQvA9ixADRwoK4uTZ23m3jhtURAWp2ysue0MsTRC1NDu01tbMWOh+wR6kft3hnrST4JOUaT28NQV0aOzHoJOuVIWo3mZitAvDCw5OI1TvthQA0+LYTmdEFFVZZw75hPGNDNpec/ZBxO/sSYHh+FxiOvbOJgzvHambsFrA50hD0O+HsfFOKs+A5fwUcEzDZRepSMYDDDO7tHrZIzpJh5BucJozwU2SVo26SZ+cFBzJUyi+wUiQyp0q3reDMcj8LNbStnJzeJAgxmrOSmqXOv1UhPagGNlTs2vdNRYtgzmWLjhBQkJEAIXLJdLBBEJ7Ukq0sm9SaV3qwU9bM6uCOz8a0sOaHpah1UpCdg6ag7jVYyKu3CkoDI165itWonlqlt1Y0CDcQ+L4UimxPc3w/w8XFBNgUdRlxePTehe+ty25WHNwcOX59tJ+coAXDOzdh5eT15ubpNhaGxv/f4WWPyWJQ3AA0ivQB9hQmTd4As9V92F02bnJL7MK43kUnhiYu1AaHCyQI5rDPtmwiqYnUOwZuW1LuEqkFKiXrveIMBWb7TfnstriOT8CGiEhuDTMzAjD7f1b4H1NJopL8ljKn/YjSL4LcJ+RlJ471UNJJ6/kJ9nE3iNt1v2gb8rVlUae1X1VnDVpaopnFTQrV+dcRIpkD8Cw382ak6JOCbV5ONwT0m5YnWLwppjroHq5dH05nNeMpLdq3jrDpF5UBGmFQ/Xp8ZiA18HYVBVijJHltDa/2efwoBAd3LwvfEckppFVAkRdXE9BoDIJstPZs1Zl4UjgFr42A7ZHV00iK1IUblv7oaSKhklP2BM/In305abG+2THZYtSJKXcwQAH1W1FaKi2BeafalntfiH7g3s4YdD0g== 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)(376014)(36860700013)(7416014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2024 09:48:08.3921 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f000b2b4-17ef-4a20-0760-08dcee90ce67 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: SN1PEPF00026369.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7854 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" }