From patchwork Thu Jun 28 16:56:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10494569 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 604F460532 for ; Thu, 28 Jun 2018 16:56:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCC162A2C1 for ; Thu, 28 Jun 2018 16:56:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D11792A3D6; Thu, 28 Jun 2018 16:56:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F4632A2C1 for ; Thu, 28 Jun 2018 16:56:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966073AbeF1Q4d (ORCPT ); Thu, 28 Jun 2018 12:56:33 -0400 Received: from mail-eopbgr10082.outbound.protection.outlook.com ([40.107.1.82]:39225 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965914AbeF1Q4b (ORCPT ); Thu, 28 Jun 2018 12:56:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZDjVvAVYFA5SfD/tXf32XMq6MP8olgXjGXeD+tCT+j8=; b=n6oVUConlfPRqdH6B90gDVVRCVJ44cHc0PChMryd5X/0rBaeg4Lj9kEcPv8PmKpkXSWPqScwVjZ9nXikJrt2/nQMbkvGE9QgufRdI2tqbQb9RQc/V3pDtw0Q8roaIJ3wL6gjZExI2v7kMOpNNI7raPe1avXEfWxI0tu07xDQMWc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) by AM6PR05MB4183.eurprd05.prod.outlook.com (2603:10a6:209:40::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.884.23; Thu, 28 Jun 2018 16:56:27 +0000 From: Petr Machata To: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: davem@davemloft.net, shuah@kernel.org Subject: [PATCH net-next 1/4] selftests: forwarding: lib: Split out setup_wait_dev() In-Reply-To: References: Message-Id: <141750f970e14c36b70c86bc67cf2ed952eb61ab.1530204784.git.petrm@mellanox.com> Date: Thu, 28 Jun 2018 18:56:20 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [78.45.160.211] X-ClientProxiedBy: HE1PR0701CA0065.eurprd07.prod.outlook.com (2603:10a6:3:9e::33) To AM6PR05MB4183.eurprd05.prod.outlook.com (2603:10a6:209:40::28) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ed832b63-cab9-4191-7912-08d5dd181708 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600026)(711020)(48565401081)(2017052603328)(7153060)(7193020); SRVR:AM6PR05MB4183; X-Microsoft-Exchange-Diagnostics: 1; AM6PR05MB4183; 3:CPZuOATL7xoWasJVI1lOeXtbT9FFGl2YF/19qe5E+Cg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dEJZwiESwDdZHCaLGAsWLloZLerr+ps1C6ytOVF+1bcRjoBm3KkLaTwXrLFBQ0/aM3KRwR9IGd3x9Byw+UWcR6UU7GaahILWPWKzFjxhFFEMx3uvbwbq66zJ7ox+rGcC4lsNQ4YOKPZGMReSoeWvMGNQvEU4qKBjl6gT9CxRQy0q8dgUceWZAxCbNct4aS/kWiy/1JjxR+bN2KC4lrF80ft7JQUXGDyNlYSw+KbQUwKhF7Q9OCsWnetBwKsi1u/WUWk/0X1O0rxUixoUFNI7c9f49+bsen0wbC4kTBSXGqgsNT; 4:Jc7BkBLnKtNge8SXbnB9pgx8Tya4xipkM8c2kWea2xKmTdqWu+m69JiGu8EgpWN7HBV5awLSOd9+XOIxbDwyHfFaamIeEdF1I/QH3obbNHkE10zGaTNBNpSCWS6j8pUxrcc1HZqXq24Tx8nL7SiTDto5tfERwf4k8Dakj3ZvjL7mp/pk2txgHSsVNKSHAwBoN8xeC5cxCpnJtpSS8SAtt8o5J9VAxaogY8C4lnMvb9AFRdPL9LrTnTlakLhCfKUfKrYCIgYo2lBL/86BJ+C3AA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231254)(944501410)(52105095)(93006095)(93001095)(3002001)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:AM6PR05MB4183; BCL:0; PCL:0; RULEID:; SRVR:AM6PR05MB4183; X-Forefront-PRVS: 0717E25089 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(376002)(136003)(366004)(396003)(39860400002)(189003)(199004)(2906002)(305945005)(51416003)(76176011)(52116002)(97736004)(36756003)(7736002)(16526019)(106356001)(105586002)(26005)(5660300001)(6666003)(3846002)(81156014)(11346002)(25786009)(486006)(4326008)(6486002)(2616005)(186003)(956004)(86362001)(16586007)(386003)(66066001)(478600001)(8936002)(48376002)(53936002)(6496006)(58126008)(47776003)(8676002)(68736007)(118296001)(81166006)(6116002)(50466002)(446003)(476003)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR05MB4183; H:t540p; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM6PR05MB4183; 23:psz1YNY0GFk9OaIqQT8THW2//9bdDw8Fyms0yBJGX?= =?us-ascii?Q?JSmjcY8tK7y9g3kbV/LMW8lknGx+G05yilPnEIftnanXZiz3rvLX9Ye7VJD3?= =?us-ascii?Q?Qbbgcm2/nVyrZ126sWmgyfec64r5UeoH5d2B5d5ChG45DZr0Qe1ziel3fSFQ?= =?us-ascii?Q?fnLIGHFFWlVd7bu5l4ihM409XuEGM1kKPCIHx+PLmguYl6E9Tm3o5es7zBBj?= =?us-ascii?Q?RwRHSPoA36fck28aSfbL+LDyw+6KQDVzOI05DlcPgrWSWjJdgSkQsFABWzku?= =?us-ascii?Q?RiWwlDGDbAm1QH4wBXfJSbmWr6coRi6BS7D7wDKwClvNqKpzg9s1MLH6YkDh?= =?us-ascii?Q?snDwzF4BfouiG3+bTmVeoRI1w5rIMY4/vduwteWwU21ukipGo6VoQmaQYHno?= =?us-ascii?Q?3DOWRb8pY71P9G9RfE45fmNreC503cYbWT95qoQPj7B11fW7w5JgrMQ9Lm1U?= =?us-ascii?Q?n7JSbno7YzXl7dKU9YLbhAG/6hNADag84w99CqYEKVPOi9gcz9TGoxVt9/DA?= =?us-ascii?Q?EKNc8jOej4cfHM65RXlTTucbt8ESgAG2PMzrFQzjWVp9rMQG1BCC5be7m8L+?= =?us-ascii?Q?N3mRxS+cZ+76/oPDMOn4LsMQyoLXV0R0+bF7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1; AM6PR05MB4183; 6:ND7spilP2WTmOAUXEmuB81dajrdCSO3nK7F0lu8mIuxqfDl6j1HhrTDtFYW4ObDlbkF1c/r1mK/OBhLSFLmcjrbe72+rh4Cx7No1JbFxM/JlwLcVJmNWc1u8l8CVFuJT+GF2AvI4YqyURiyf+1j9ACxVWYs6LMjRym2mkdbAdplCQDOCwcSObf07f3GnFvfRg+kFSfUeDvP2h84SkK6hLOk6IvJno1nBe5Lv2Z0J7M1oQQM5sYvFvlbtEdavpxa7xnATAQooKWv0b6R8Z/yhlGAGqGa27w/UYhuK5YU6xX6CUMafVyKOPCgylbEI/nMMUr6BLArA6NuoVHev6MO5G2jV750j5KL2QEvXxVODzuDB0SqPZyejwSg+adQBShN3twJ4IIgxINCiHHFs9oc7WdDM6I/jP49Plf3/+TBhJ1eRJkRBHVYlIvaARVRQd12N/VlOsjT+gmzP2keJy8xu4w==; 5:GfNZsED88HQSyBMB0FeOvOK03v+OfZG9GObSC6HlX/5iDOqq68aIlpqL9sjZBWQHsBnfdZFiM/N+MxVh4WWgLGaAgI85O66vkeVor3HXuQcDGeDhX/MhAWU2ah8CyuuELGwhsEXpddLkTW8+YYSJ3tYaE0e6jKw0FNxONj72+Sc=; 24:Jiiy/T2MIS1tNwIS58e4UI4SdQkYlKkezBLUBOZNK4gt9yVJvD6P4DH4OSj6lploUFbTesH6rbK4UH4sHRUPDffVXNIToReQBbaV96o6+GQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM6PR05MB4183; 7:JaATR7HRiiomrJsYXF3pxIyUAXAueKgraPQCoeAELwNuchaa1YuC4qxfK4qjxSrUy1LL6oEYgAo1d57/iCWAgT7ZufPVxhrVwpKWqisBiVGEIw4sfINloQ1RDM1N5e40HN+IaaVkvD0SFBQXdDEk6qs2qZbT9Ogazv/mt3ynVliP/jj61eb4oeiSA99OUVOuueqontgCVdE9CWnAB++wu1qeRrvJ9WZDyxb3BiS99FEurOE3QRtNyyTSI9UL50ee X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2018 16:56:27.1771 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ed832b63-cab9-4191-7912-08d5dd181708 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB4183 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Split out of setup_wait() a function setup_wait_dev() that waits for a single device. This gives tests the opportunity to wait for a selected device after they tinkered with its upness. Signed-off-by: Petr Machata --- tools/testing/selftests/net/forwarding/lib.sh | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 1dfdf14894e2..ac1df4860fbe 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -185,18 +185,25 @@ log_info() echo "INFO: $msg" } +setup_wait_dev() +{ + local dev=$1; shift + + while true; do + ip link show dev $dev up \ + | grep 'state UP' &> /dev/null + if [[ $? -ne 0 ]]; then + sleep 1 + else + break + fi + done +} + setup_wait() { for i in $(eval echo {1..$NUM_NETIFS}); do - while true; do - ip link show dev ${NETIFS[p$i]} up \ - | grep 'state UP' &> /dev/null - if [[ $? -ne 0 ]]; then - sleep 1 - else - break - fi - done + setup_wait_dev ${NETIFS[p$i]} done # Make sure links are ready.