From patchwork Mon Nov 19 16:11:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10688857 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E00EC17FE for ; Mon, 19 Nov 2018 16:11:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD64629947 for ; Mon, 19 Nov 2018 16:11:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCC1C2A0F8; Mon, 19 Nov 2018 16:11:22 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 5326729947 for ; Mon, 19 Nov 2018 16:11:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729965AbeKTCfW (ORCPT ); Mon, 19 Nov 2018 21:35:22 -0500 Received: from mail-eopbgr140072.outbound.protection.outlook.com ([40.107.14.72]:6759 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729922AbeKTCfW (ORCPT ); Mon, 19 Nov 2018 21:35:22 -0500 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=9x966SAR4Ya20+4NA+AizR7Y5vKMI60kuMWe514s4eQ=; b=NQyz/t+FhGLf1Mc16dTsCHbo+BbD+iwLZ4bFXvPEeKfJ/MPsLHV19FqYRLjclk4hm65gQfOJURYVB8wAsJF4xPdrbiqa9/zjXAmjWBF9lcXHZLFKBBJUNvJGWJMulwHGcfLpKpF+SbhFxVbSn0nr131eW/7q9LGAhzJ5K7e70Uk= Received: from AM0PR05MB4978.eurprd05.prod.outlook.com (20.177.42.95) by AM0PR05MB6225.eurprd05.prod.outlook.com (20.178.115.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.30; Mon, 19 Nov 2018 16:11:09 +0000 Received: from AM0PR05MB4978.eurprd05.prod.outlook.com ([fe80::f953:cde4:ff8d:501a]) by AM0PR05MB4978.eurprd05.prod.outlook.com ([fe80::f953:cde4:ff8d:501a%4]) with mapi id 15.20.1339.026; Mon, 19 Nov 2018 16:11:09 +0000 From: Ido Schimmel To: "netdev@vger.kernel.org" , "linux-kselftest@vger.kernel.org" CC: "davem@davemloft.net" , "shuah@kernel.org" , Jiri Pirko , Petr Machata , "roopa@cumulusnetworks.com" , mlxsw , Ido Schimmel Subject: [PATCH net-next 02/18] selftests: forwarding: lib: Support NUM_NETIFS of 0 Thread-Topic: [PATCH net-next 02/18] selftests: forwarding: lib: Support NUM_NETIFS of 0 Thread-Index: AQHUgCJ7rAiabL0lfkqmie7+a5oe6g== Date: Mon, 19 Nov 2018 16:11:08 +0000 Message-ID: <20181119161006.5405-3-idosch@mellanox.com> References: <20181119161006.5405-1-idosch@mellanox.com> In-Reply-To: <20181119161006.5405-1-idosch@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM5PR0601CA0031.eurprd06.prod.outlook.com (2603:10a6:203:68::17) To AM0PR05MB4978.eurprd05.prod.outlook.com (2603:10a6:208:d0::31) authentication-results: spf=none (sender IP is ) smtp.mailfrom=idosch@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;AM0PR05MB6225;6:JoOOr8owH1vtSvrjUHxWycrEiMSR8VcGHPJEMMIZ5f6GpG8dPvF0WoY0lvFoVH8Kh17+Ngi4VWOSq/iseyKOLuG/pkTSs1ZPY59TyKy84yI7LxbbTdfhFOxTmYSN1OB6D8B2i1S9ml0FdZSg4HAKFL52SN+Dm21IRZvovNZR5BUE4oI9NiQ5EOo+cfArSqxyVEPFgnoClTHvafzdKUsdzdysD+f1++N6KnvS07J34hXVIIeQZJdkodWQ/hPCewhDHrFaQwXURmcKjQkDCwwQE0cv+BSullYMbYEkSl4wJvg+Xk4fGv1sxPgjBcQ+4IyB+Yot7fPWc/YUoh5bQsggfKsXiNCsdYg5zlYL9YwCtMdiKgB7HssbmbcAFttyHeEs7tMJ4TVl8+Y9YXCqZebEXMTqxcM1tQojPt73ao0Irk2X5uMcDIOkqJogG8K/4kQQ+jm//kJ64cweDQWgSjaFMQ==;5:VeaL9O5kP5CG4xhjj8b88RZxyhmD4T7K6YtsGsXSLNkViDlaIbvOCbQt3nztCCj5avX/KnzDLLBSAbIKfKnaPmUmu7z9DA12c3+4BQBZVJzwKxvKjiMWtbT0gy/5UL9LK8+7wRj0ItVBBKfeylb+VURe8sz8re/j7uS1e0jm8ss=;7:v74HO7IoMbodFVWZMVpSKLj49X40Z7NvLVA4O6iYFQgUCV2vjG7hZoZCZjkCPxE6OvHrye2EiGvY8kRpt2MsXnAS99utgUWTFHmp7RAakgNk/ftspkmJq3kV5lJzCaQLvcfWzk54/kkjiy5dcCxfTQ== x-ms-office365-filtering-correlation-id: 833be1c5-001d-45d5-2d11-08d64e399dbb x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:AM0PR05MB6225; x-ms-traffictypediagnostic: AM0PR05MB6225: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(788757137089); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(3231415)(944501410)(52105112)(6055026)(148016)(149066)(150057)(6041310)(20161123564045)(20161123562045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:AM0PR05MB6225;BCL:0;PCL:0;RULEID:;SRVR:AM0PR05MB6225; x-forefront-prvs: 08617F610C x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(136003)(39860400002)(366004)(376002)(396003)(189003)(199004)(71200400001)(71190400001)(478600001)(110136005)(54906003)(316002)(386003)(102836004)(14454004)(2906002)(2501003)(107886003)(26005)(97736004)(25786009)(256004)(4326008)(53936002)(6512007)(105586002)(68736007)(106356001)(1076002)(8676002)(186003)(3846002)(2900100001)(446003)(6116002)(6486002)(7736002)(6436002)(486006)(305945005)(76176011)(52116002)(2616005)(6506007)(36756003)(99286004)(66066001)(81156014)(81166006)(11346002)(86362001)(575784001)(8936002)(5660300001)(476003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR05MB6225;H:AM0PR05MB4978.eurprd05.prod.outlook.com;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-antispam-message-info: VAmRyM0OQ452uB7kwjcZCnnPN3IINirnoubc4d6ixs+SVXBjzIVG2sch0mC4vbCvbGWFt56WBJqi8aveoz+90BlIkGXoWaRH8j0xvBCND+ln3pbCGQ7QD1Y+yferpSavj8g1M5z+rKoDSTyAb7oOEXZJwpZDITm4SiHgsMa/0SZ2Ma8TbT1IA44Kn+j+AztOlyWw/tyvhsIOBm5y3CpBOJxcaJAdpBTAAYG3hpS1SmpGreJ0wv7s8jrH2vNc/oX/8Xpr7no1ksTEvZ6D2dQakk6X7xq/VgXzbGQLfrtobVIh87MetlJspAo/i6OqFflmi8IlFgFtMHvdlJSvFhXxSRgqX1W79EVVD52KgoW879k= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 833be1c5-001d-45d5-2d11-08d64e399dbb X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Nov 2018 16:11:08.9718 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB6225 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 From: Petr Machata So far the case of NUM_NETIFS of 0 has not been interesting. However if one wishes to reuse the lib.sh routines in a setup of a separate namespace, being able to import like this is handy. Therefore replace the {1..$NUM_NETIFS} references, which cause iteration over 1 and 0, with an explicit for loop like we do in setup_wait() and tc_offload_check(), so that for NUM_NETIFS of 0 no iteration is done. Signed-off-by: Petr Machata Signed-off-by: Ido Schimmel --- tools/testing/selftests/net/forwarding/lib.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 85d253546684..bb0e9fdf893e 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -104,7 +104,7 @@ create_netif_veth() { local i - for i in $(eval echo {1..$NUM_NETIFS}); do + for ((i = 1; i <= NUM_NETIFS; ++i)); do local j=$((i+1)) ip link show dev ${NETIFS[p$i]} &> /dev/null @@ -135,7 +135,7 @@ if [[ "$NETIF_CREATE" = "yes" ]]; then create_netif fi -for i in $(eval echo {1..$NUM_NETIFS}); do +for ((i = 1; i <= NUM_NETIFS; ++i)); do ip link show dev ${NETIFS[p$i]} &> /dev/null if [[ $? -ne 0 ]]; then echo "SKIP: could not find all required interfaces"