From patchwork Tue Jun 26 00:06:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10487577 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 B5C0D602D8 for ; Tue, 26 Jun 2018 00:08:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A69D928619 for ; Tue, 26 Jun 2018 00:08:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B67A2870B; Tue, 26 Jun 2018 00:08:03 +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 1AF2128619 for ; Tue, 26 Jun 2018 00:08:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933803AbeFZAH5 (ORCPT ); Mon, 25 Jun 2018 20:07:57 -0400 Received: from mail-eopbgr60048.outbound.protection.outlook.com ([40.107.6.48]:58432 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934290AbeFZAHL (ORCPT ); Mon, 25 Jun 2018 20:07:11 -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=pYRhjznfjnNa1pxcoQ/EFj0IXgDIPO3uenpi9hh4phM=; b=Ua4agYVpJtd2byyNpfbbnmx3ggM6bI/Vr2VuNocFfB6O/KzQdzoehymDmzcrHoIsKNNhWHziDbP4fdGvsIOzgCuJgUdrZL/d0ojyZQ64XEU4zpMONK03lknMlMWyldRUXAfjK622ZgF7tySTAu9ZN6QWYyHY1Cue1j4alShG90Y= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (89.176.83.59) by VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.884.23; Tue, 26 Jun 2018 00:07:08 +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/6] selftests: forwarding: Move multipath_eval() to lib.sh In-Reply-To: References: Message-Id: <1c9b763812fcda15c928f03a64e800aa670959b5.1529971148.git.petrm@mellanox.com> Date: Tue, 26 Jun 2018 02:06:06 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [89.176.83.59] X-ClientProxiedBy: CWLP265CA0112.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:51::28) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a4318178-10ad-4cfe-b8d5-08d5daf8c20c 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:VI1PR05MB4191; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 3:xndfK/QG3gO+Jq3BYrepj1EamoDX9T4GoQePGlJuO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DqqYR2TnVSauK5DuINykvzfEyVhdYYTDbCa9oZtIa4RDDFcOw/2YAQFqjTyiXvmZtnHi3402SgSnl4Q7P7VUPxupnhib36bu3dUxbf7URzVbezgZ4/feQkqZo6FpeLYdDmLKegK80dzJnihjF28cshosUOdCPUKgftjYDN60e7MODcweLxQ6rIjfAkWKEYa7K3Y/qfeJjzOzox1To2Kt/h7lXZLsRQ3K8kpoLVZ1BNQKDAKwNlfjSw8qNpaxpZxpdCspQrNPU3uaLLJ8sl03zwiVBBgvFafLtbVCIkyKJVlUWnbucIVu7fpNX5/9b; 4:q4j87kL2aR/7iVPK7MPwoq4C1surjaduwqze8JfTcwkelS9UrnzGqw2gk82N4tLURzeCUdNTOKiCVJJL/f/tPxho40ZbFVpZbKd6mxZuJ5yXuLYB8T9dcs+gQxM0/MXSDnXrbmyGwETpfTpq0TEgV81vef/n8S24oogbczESbHX9qoWHr2GGLuDjbWITLpA/jnIWslvWIqOv9oNHHVLZQKnV6KhSL7LP9hVvM33VYy7pJWgR+BlnmTW+dDNMCt+SBFsv2EjBnk9oHRxlp8EGhQ== 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)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:VI1PR05MB4191; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4191; X-Forefront-PRVS: 071518EF63 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(136003)(346002)(366004)(376002)(396003)(39860400002)(199004)(189003)(68736007)(66066001)(53936002)(6496006)(52116002)(3846002)(6116002)(118296001)(47776003)(6486002)(16586007)(316002)(58126008)(25786009)(478600001)(105586002)(7736002)(305945005)(106356001)(4326008)(81166006)(81156014)(51416003)(8676002)(8936002)(486006)(16526019)(86362001)(575784001)(26005)(186003)(5660300001)(446003)(97736004)(11346002)(476003)(956004)(2906002)(48376002)(386003)(50466002)(36756003)(76176011)(2616005); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4191; H:t540p; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR05MB4191; 23:U+aX9mkx8wsKuXG3PKWkaQiET+8SfUdXmiPMTOA/z?= =?us-ascii?Q?XiQcZuZ1e1mm4QDs93WIHgzQNyyzY9oh65gr9Cqg818zgW41ZNiP3dlhZFKk?= =?us-ascii?Q?y6nIBzqejGfWdWEOKNAbnf/AWQpMVrMb7zPHGdARQN794HufuiTMu/05ogVH?= =?us-ascii?Q?5qXDlbrAE5HC8Ls9RH3EEe48q/yXK+V2vagyteZ3tJdYdKBOuymsxLmiOz0R?= =?us-ascii?Q?iHxksEP987XnUoghgxAYuLbcc5OCam+LjZE3CNUHR8D7/Eb+Tw/WiXvAruXH?= =?us-ascii?Q?iRja5fLYMsBav7LEAzJgs9mS/Wf/D8g1Tu58z4kzcQPMsUpcZxeRXxuEoYEi?= =?us-ascii?Q?CfYXo/hfwYkHr4ugnIcVkHKGwSJvRamf5agfLnQDq970lWMGHOWVcL9bZCZj?= =?us-ascii?Q?2f5BsNu0RGEAH29GPV9qgN8vW8QCa1b96V5qtB1CnRel1HQPsRN8xuzQ1Lk9?= =?us-ascii?Q?yd2UVF6CK5TzCrntH+0gI6ZSFbWjlDU1uCaJXlqrCjzk/0JDeDcdCAQBY52b?= =?us-ascii?Q?pPJacKEPsJR12lYSULr+vcOGF9SUqZONaGVn3qL9dMMW4oueWgdnkmBDVXUn?= =?us-ascii?Q?kPUp63WGHTBl3S6EzA5XrtL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yEKNJ9rj/jKvDSsyn7h9M/pUSDHRET8aPPXVkQW/UVFxtPqfTsCN663gBIFfKEhgDQ7Rd1B3dNy+ioIHdMG X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2018 00:07:08.0620 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a4318178-10ad-4cfe-b8d5-08d5daf8c20c X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4191 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 This function will be useful for the GRE multipath test that is coming later. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- tools/testing/selftests/net/forwarding/lib.sh | 39 ++++++++++++++++++++++ .../selftests/net/forwarding/router_multipath.sh | 39 ---------------------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 7b18a53aa556..7fae805147ae 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -557,6 +557,45 @@ tests_run() done } +multipath_eval() +{ + local desc="$1" + local weight_rp12=$2 + local weight_rp13=$3 + local packets_rp12=$4 + local packets_rp13=$5 + local weights_ratio packets_ratio diff + + RET=0 + + if [[ "$packets_rp12" -eq "0" || "$packets_rp13" -eq "0" ]]; then + check_err 1 "Packet difference is 0" + log_test "Multipath" + log_info "Expected ratio $weights_ratio" + return + fi + + if [[ "$weight_rp12" -gt "$weight_rp13" ]]; then + weights_ratio=$(echo "scale=2; $weight_rp12 / $weight_rp13" \ + | bc -l) + packets_ratio=$(echo "scale=2; $packets_rp12 / $packets_rp13" \ + | bc -l) + else + weights_ratio=$(echo "scale=2; $weight_rp13 / $weight_rp12" | \ + bc -l) + packets_ratio=$(echo "scale=2; $packets_rp13 / $packets_rp12" | \ + bc -l) + fi + + diff=$(echo $weights_ratio - $packets_ratio | bc -l) + diff=${diff#-} + + test "$(echo "$diff / $weights_ratio > 0.15" | bc -l)" -eq 0 + check_err $? "Too large discrepancy between expected and measured ratios" + log_test "$desc" + log_info "Expected ratio $weights_ratio Measured ratio $packets_ratio" +} + ############################################################################## # Tests diff --git a/tools/testing/selftests/net/forwarding/router_multipath.sh b/tools/testing/selftests/net/forwarding/router_multipath.sh index 8b6d0fb6d604..79a209927962 100755 --- a/tools/testing/selftests/net/forwarding/router_multipath.sh +++ b/tools/testing/selftests/net/forwarding/router_multipath.sh @@ -159,45 +159,6 @@ router2_destroy() vrf_destroy "vrf-r2" } -multipath_eval() -{ - local desc="$1" - local weight_rp12=$2 - local weight_rp13=$3 - local packets_rp12=$4 - local packets_rp13=$5 - local weights_ratio packets_ratio diff - - RET=0 - - if [[ "$packets_rp12" -eq "0" || "$packets_rp13" -eq "0" ]]; then - check_err 1 "Packet difference is 0" - log_test "Multipath" - log_info "Expected ratio $weights_ratio" - return - fi - - if [[ "$weight_rp12" -gt "$weight_rp13" ]]; then - weights_ratio=$(echo "scale=2; $weight_rp12 / $weight_rp13" \ - | bc -l) - packets_ratio=$(echo "scale=2; $packets_rp12 / $packets_rp13" \ - | bc -l) - else - weights_ratio=$(echo "scale=2; $weight_rp13 / $weight_rp12" | \ - bc -l) - packets_ratio=$(echo "scale=2; $packets_rp13 / $packets_rp12" | \ - bc -l) - fi - - diff=$(echo $weights_ratio - $packets_ratio | bc -l) - diff=${diff#-} - - test "$(echo "$diff / $weights_ratio > 0.15" | bc -l)" -eq 0 - check_err $? "Too large discrepancy between expected and measured ratios" - log_test "$desc" - log_info "Expected ratio $weights_ratio Measured ratio $packets_ratio" -} - multipath4_test() { local desc="$1"