From patchwork Thu Jan 4 14:11:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Poirier X-Patchwork-Id: 13511155 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2042.outbound.protection.outlook.com [40.107.100.42]) (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 52AE82232A; Thu, 4 Jan 2024 14:12:01 +0000 (UTC) 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="GIjkJh03" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A/ij+/CcWALEUoDQ2vIvMjprnK9VYAAV/187ptcbl6Ya0iSO83ME2c+nnRGtrJOASZ2sAcJ2rirPszyaahVGeBvUUfxVqGIbONLTjv0yU48sAoJBZksv2TnD9WiUCvCWBY9or0nx0CqXbqxJEuc31rxEm+fYE7qLjLZiKIuttKGPB7fCG8DJ7Y0RTbJFzJxfBbHOuziVeFbBifgkp1VKhUjk+2bH/aZ84Nk+uOIzSYDKXY8Vn+YttlCIFf3g8DbCoiooySBsaE63zer7lDFHeD2RDSEgqEF37lNYKn79cMfT91yrmxUxNCoEM9IhAjy80Y9GFw0sRY0x+lrYhPZzyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=w/0gZYXKZeRlMiF3/ngynndfHX8DKTk8ge8fGB+p/Rg=; b=X/d3HcYNzq1M3ZfYZGCyh9jsOuvxDkPK0zTKg0jZLHH9n5wWsHybyckbG+l7kqWU02j59d9yM5SQHky487TUtZIItKbVstPTNrFAl7UiPgeBnTWTkvgR1ETvC8JwGVt2zIK+TywJAJeuDMhAi/xK3YFci7KyPfTXaDgdFyGNp4bUfztZqjKtzZClt+VAyh6VObO/LwX4FLU2enB8fyAXweNLwbshE1Iq5rNBjE4flQ4ui67PGsXLiRtPRSRqJKWcD6MJJ6MRc4uDJqdpVlg2fLfvInSia3pFTMFGklg46WMfFlslehSMvEaGvSSuEY4Q/syEbUJjLO7pKTbtE+Wvig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w/0gZYXKZeRlMiF3/ngynndfHX8DKTk8ge8fGB+p/Rg=; b=GIjkJh03CDk6T+V3aN36+7Ks4vhMVSqXap4oUDH8yOgqZZFxJjc3zfboZVvm0DmAt6qDpVsyaEFAsN+ABP6Tvsu0rL+D5wkunBTo6kkzoCZLzNxqbGd7g1RQRJYrHMR1JRDaZJGmoNSxaAawM0OrXhm+xW5K/4bNjRBPus+mBdymqHxFKyVIZrASSY2ObikL0+vQ9cToJSfmCq0Ya/YKsgiVat92E/l9g2hvSOUuO4SaRD9LtWTuf0+cQISM07tLCOy5HPJViPpkRIqHtKEC+9iHCJUBRwFW0UQ5gS07/4nDWKw+pnVYTELi6tL+ZGN2/9qGs9v/nhFAZJgEL7p3LQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) by DS7PR12MB8203.namprd12.prod.outlook.com (2603:10b6:8:e1::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.13; Thu, 4 Jan 2024 14:11:57 +0000 Received: from MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::ff68:f81b:d451:9765]) by MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::ff68:f81b:d451:9765%4]) with mapi id 15.20.7159.013; Thu, 4 Jan 2024 14:11:57 +0000 From: Benjamin Poirier To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Petr Machata , Nikolay Aleksandrov , Hangbin Liu , Vladimir Oltean , Ido Schimmel , Tobias Waldekranz , linux-kselftest@vger.kernel.org Subject: [PATCH net-next] selftests: forwarding: Avoid failures to source net/lib.sh Date: Thu, 4 Jan 2024 09:11:09 -0500 Message-ID: <20240104141109.100672-1-bpoirier@nvidia.com> X-Mailer: git-send-email 2.43.0 X-ClientProxiedBy: YQBPR01CA0088.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:3::24) To MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN2PR12MB4373:EE_|DS7PR12MB8203:EE_ X-MS-Office365-Filtering-Correlation-Id: e665e391-9849-4240-2ad6-08dc0d2f1c85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sDrhuZB4GYiNycQsGqifwVdt9A7qLLES8c7Eq+dvnZiiPpJL0cQZ8zd9P/01r/OLlso5GRBAPppmhUMFngAmFB8heauf569hLdOFDW3tPk4bECV1ML21LKnyEsPm7sJ/jEwVifEysavseALjjKFTc/AORFM9F1AAD4p8E5ttDmIqgo+pbTXtdhPckL+R9kUS12ahdRg78Y0KonqvCssQiReJxm8xK2oRZlX0D89/TFfKyvovc8n/PA1lCHHuorE5ldboSwqo5fna+JVt5RRTyLz9i/WKFly9dAHXfuJr5bdz8SdEqfyQCkqBvAlM0sxFtGKeePgcnyPaXKym5yR9R9LaiK4NTjxkMavK7xsf7/ThRWjviaPJttkIyVUmuAZLl0Bmcvxtz6nBZiSspDoATJ6WbHw67ZgQBqmExIEsoUqNyUF5coANOdKd4XRg6rDHtgoM7a3u1FFy2woeNPeNCIurBROC06T3me+mclbP5WoGHD4gDC6AXRtuAHy9iZu1gVdiuOq0HvcaG7q8NIXrCvXdrCcz2s5H6SBFWup2NRUv6jsVMJ9wzazfrTsNTjjnC0dLufjWA46z1qsIpE/39nlOr2NTPzP9UWhPnkd0kQY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB4373.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(376002)(346002)(136003)(366004)(396003)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(66946007)(66476007)(6486002)(66556008)(2616005)(316002)(4326008)(8936002)(6916009)(54906003)(1076003)(26005)(8676002)(966005)(83380400001)(478600001)(6666004)(41300700001)(2906002)(5660300002)(7416002)(6512007)(36756003)(38100700002)(86362001)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0lHKsHaS07r5Mv9kaSaLJ5zCTMoivBPebiiRBd0D0qs1FNXKmGlZnTxo5yzHAI2pHXME432kBzDcp3J4kPAVpXdXoq3u107ma7UDRcWDIL659e1h9NqY4cMlv90rYAnNg9/TndKHXzfL1qCiGZ6hDEYK01+c7jhOmS78lv/K20isFHbak8f2Y1n1ZY5U6rjl7pmVxvWXfrYwkYThc4OXSTFuWDkDlKHxqO/CrtiGk98ZjoFdjK1lI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q+oIRRZzjyDcuuqILDPvihXSSUrTEF7/RQv8iuqSO7DxYOFVhWSEK+IN1VnoUahMZk8xde7ncyNYxEE3B1iPwEPxkOxEb0hlqYTDRqW6Ds5UySl9Qb6IoUUM+K/VFrCEN+XlQMe5ycTs6OJer/ofQoqEj6VslY4PlcPNCmj6bzbYqEBKqY0UhXVs2tzUGr6GXYiz/04n4G5cV8BwnT5erHsefcHr1QL3HoThIq0b3lj4+GEllF0ihybeWWqAy2vLZ/GQVkhMGZtjIu580OLlJpp X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e665e391-9849-4240-2ad6-08dc0d2f1c85 X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4373.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jan 2024 14:11:57.4810 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: X2wMD062b5nneQ/QNJ+2TjeDLLd/fx4L+ZzJ6cywjfPqJAggpPFYJ2Oz6FlJSEl9cO0iZphEboXLil5wTXX2nw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8203 The expression "source ../lib.sh" added to net/forwarding/lib.sh in commit 25ae948b4478 ("selftests/net: add lib.sh") does not work for tests outside net/forwarding which source net/forwarding/lib.sh (1). It also does not work in some cases where only a subset of tests are exported (2). Avoid the problems mentioned above by replacing the faulty expression with a copy of the content from net/lib.sh which is used by files under net/forwarding. A more thorough solution which avoids duplicating content between net/lib.sh and net/forwarding/lib.sh has been posted here: https://lore.kernel.org/netdev/20231222135836.992841-1-bpoirier@nvidia.com/ The approach in the current patch is a stopgap solution to avoid submitting large changes at the eleventh hour of this development cycle. Example of problem 1) tools/testing/selftests/drivers/net/bonding$ ./dev_addr_lists.sh ./net_forwarding_lib.sh: line 41: ../lib.sh: No such file or directory TEST: bonding cleanup mode active-backup [ OK ] TEST: bonding cleanup mode 802.3ad [ OK ] TEST: bonding LACPDU multicast address to slave (from bond down) [ OK ] TEST: bonding LACPDU multicast address to slave (from bond up) [ OK ] An error message is printed but since the test does not use functions from net/lib.sh, the test results are not affected. Example of problem 2) tools/testing/selftests$ make install TARGETS="net/forwarding" tools/testing/selftests$ cd kselftest_install/net/forwarding/ tools/testing/selftests/kselftest_install/net/forwarding$ ./pedit_ip.sh veth{0..3} lib.sh: line 41: ../lib.sh: No such file or directory TEST: ping [ OK ] TEST: ping6 [ OK ] ./pedit_ip.sh: line 135: busywait: command not found TEST: dev veth1 ingress pedit ip src set 198.51.100.1 [FAIL] Expected to get 10 packets, but got . ./pedit_ip.sh: line 135: busywait: command not found TEST: dev veth2 egress pedit ip src set 198.51.100.1 [FAIL] Expected to get 10 packets, but got . ./pedit_ip.sh: line 135: busywait: command not found TEST: dev veth1 ingress pedit ip dst set 198.51.100.1 [FAIL] Expected to get 10 packets, but got . ./pedit_ip.sh: line 135: busywait: command not found TEST: dev veth2 egress pedit ip dst set 198.51.100.1 [FAIL] Expected to get 10 packets, but got . ./pedit_ip.sh: line 135: busywait: command not found TEST: dev veth1 ingress pedit ip6 src set 2001:db8:2::1 [FAIL] Expected to get 10 packets, but got . ./pedit_ip.sh: line 135: busywait: command not found TEST: dev veth2 egress pedit ip6 src set 2001:db8:2::1 [FAIL] Expected to get 10 packets, but got . ./pedit_ip.sh: line 135: busywait: command not found TEST: dev veth1 ingress pedit ip6 dst set 2001:db8:2::1 [FAIL] Expected to get 10 packets, but got . ./pedit_ip.sh: line 135: busywait: command not found TEST: dev veth2 egress pedit ip6 dst set 2001:db8:2::1 [FAIL] Expected to get 10 packets, but got . In this case, the test results are affected. Fixes: 25ae948b4478 ("selftests/net: add lib.sh") Suggested-by: Ido Schimmel Suggested-by: Petr Machata Reviewed-by: Ido Schimmel Tested-by: Petr Machata Signed-off-by: Benjamin Poirier Reviewed-by: Hangbin Liu --- tools/testing/selftests/net/forwarding/lib.sh | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 69ef2a40df21..8a61464ab6eb 100755 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -38,7 +38,32 @@ if [[ -f $relative_path/forwarding.config ]]; then source "$relative_path/forwarding.config" fi -source ../lib.sh +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + +busywait() +{ + local timeout=$1; shift + + local start_time="$(date -u +%s%3N)" + while true + do + local out + out=$("$@") + local ret=$? + if ((!ret)); then + echo -n "$out" + return 0 + fi + + local current_time="$(date -u +%s%3N)" + if ((current_time - start_time > timeout)); then + echo -n "$out" + return 1 + fi + done +} + ############################################################################## # Sanity checks