From patchwork Tue Jun 26 00:08:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10487585 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 6DF05603B5 for ; Tue, 26 Jun 2018 00:08:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5ED0228619 for ; Tue, 26 Jun 2018 00:08:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53AE52870B; Tue, 26 Jun 2018 00:08:24 +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 7C04828707 for ; Tue, 26 Jun 2018 00:08:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934113AbeFZAIW (ORCPT ); Mon, 25 Jun 2018 20:08:22 -0400 Received: from mail-eopbgr60048.outbound.protection.outlook.com ([40.107.6.48]:57568 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934069AbeFZAIU (ORCPT ); Mon, 25 Jun 2018 20:08:20 -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=PXp6nw8B6Mo4UhNy/6U53Au9uwzRA9HdnjCKGAiLIWs=; b=NMzrxArH5sSugfL2d+XfiaCPEmbA+MdgvNj7t3Xw4POFcYrvP4O+9FgQyaQ9grP7BKPOMx5Uef1TXp48dLqY2cHzxd5Z76WkxFaZ5lhW+iWDkZ3NlmVMXcL1dfWFIEbKTQfLHDCa5IEqZTD6K9QD70vw/ED7Uo7VTAulsYZYxQ8= 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:08:16 +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 5/6] selftests: forwarding: Test multipath tunneling In-Reply-To: References: Message-Id: <12d9b506ca912d654d38a005ac5259a6eef2f073.1529971148.git.petrm@mellanox.com> Date: Tue, 26 Jun 2018 02:08:05 +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: CWLP265CA0196.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:4e::16) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 094f3f1a-ac7d-4876-2729-08d5daf8eb21 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:3qNiymJ3bANHz/0ZuGxSNk7PYVjp5R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0Dcn19i2y2MLuhmLdjhCtLJyEkZYxdfqRHuguHh0WE8aPW/kVFvlfGDQpQQg6v5/yYWU0UaqEPAT0KUyVzIpgxK4Nw1oLjIcD5mKvJQ+Aao51vjpUIWBMBCCRrXKDX0Nj2XpT/HL8MBMHdr1DDnLZoeDwMDA8gvAEA39nHXsM8G/zBvZ8J2e59OIm8/bnQBEZy7EfZniub0HtyBRj2VOI8Ei0YiM4+UYvATBmzNqi392++tX0SjzMVFsA0vGy2rlKPwNlgKjpP9Gg2wE353rB4cCgZDEQPDGziDeTnfW0ZJOu86hMWI/RQJi; 4:LWmH255BMwhWWpKFobxdT3uamgK2m9K27GMaukUnoGSx0lXgNb5eYfDc3jzOVQODhv2Tnc0nYCbHuW33/Cpad9JrC4RsYktk104pEpawfNxxmc2hRixTm1bHYFqs9QKLaVRdZNUUAv9Hg1EdCNuMFSTSjDzlzrsCPldfYXz1RlHu1ZI3gEpIYPZKKB7Tb8xbNoW2KrfuFGGRIlYcot3qLbGDfyHHbnNVWBz5fy1T6KhKqPFV0a/n2eV+wgljfmuEOJcwWG2lBAIZQ2KdjHzcUAg3U1T9jR4Fff2le7wYIm/DPtmXgQVsRChxRMePdBv5 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)(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)(346002)(39860400002)(396003)(376002)(366004)(136003)(189003)(199004)(446003)(14444005)(6666003)(86362001)(26005)(186003)(5660300001)(97736004)(11346002)(16526019)(486006)(50466002)(36756003)(386003)(76176011)(2616005)(476003)(48376002)(956004)(2906002)(6496006)(52116002)(16586007)(316002)(6116002)(3846002)(118296001)(47776003)(6486002)(66066001)(68736007)(53936002)(106356001)(305945005)(7736002)(8936002)(51416003)(8676002)(4326008)(81166006)(81156014)(105586002)(58126008)(25786009)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4191; 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; VI1PR05MB4191; 23:Pnbxumm0ECsQR3QshCq8jAd2u4o1ZpN7iV52P9W5S?= =?us-ascii?Q?41GN6DepVDYy+PJRmpuWfkYYP4r6aAa3MSBmcsd6W03tKcG8VRKzYmYvvvA5?= =?us-ascii?Q?GGHs0GtgVSC4t+Wnx/Kojy0QkflzD2vUr+e/axEd9EX9swPsoJ3FgK0XEWHK?= =?us-ascii?Q?XAFuhd5QJXRrJXFYDYcmR0i/KzEq+kaQbt7jacjtRaU853DRSlxraPPyfw4c?= =?us-ascii?Q?FL/kFNOrKc6ZVUgjifH0jAHYcmSA8EPew24OXDn5+BoTLFGIBkCrepTVPmfL?= =?us-ascii?Q?pdBqkMQy033W8YHs5Opl1Zg1RbCoSdk6+x5eBzKB5YjE8kDCTYZAd3iFST+e?= =?us-ascii?Q?QU9mqsGLe86ownerB/nJA14Y+I6Am1TmORrsckktrmJDHnxNPK4g2InbPWHo?= =?us-ascii?Q?nFyFz15VbMjhUA+segis1NrcYd+cgKdKT2pODl/6O9hb88BoxksB0Ng4PeDf?= =?us-ascii?Q?fuOSHrLgbdfkuPijKub3kNxylJ9JkgM0DO0oL3tFQglvTxzc9lQo+y7z9nVP?= =?us-ascii?Q?bYTuigwsxLaDLiUjvHsZrvd3EK/XsU6FU1Gwl3tgu7lsiKlptf/DeLLefVmj?= =?us-ascii?Q?pGih4CnHkBTD9a6YDmgfw0Lp7JgWYvfxeluec9hJcydwPCg7loJTM+KjCPgC?= =?us-ascii?Q?qRihBG/oZCTNbo2ZkEIDtGLfJ+5R8jga7suXd/5fr6DalgmVTpDgFuJCz0X5?= =?us-ascii?Q?ORNW8JDq+kS81+BLyI9wdx5ABQuoeogtHswFQVwGImZKoUxqDVxb0NUDbV9c?= =?us-ascii?Q?QvgHn48nY7B4TErV0sYgslthmYN7j5JGcfBbm79CPiDoxFFOesgZ+qMy8FoG?= =?us-ascii?Q?AT0xS45z1SnkR9GP/j7JuU7lo1C1GGC0QaeFkuApmIlSLDoA5bm2829wejxS?= =?us-ascii?Q?RBgzz+C8ggkyAXMw3x7bw4Fx//jl1A5vtZqXrJtQo6QU7YXXfp2YV/HfjUC3?= =?us-ascii?Q?P8A24t8f2bRga8PmgJD26bC6yXSLf37GTHrXdem44kmZv2l8haPFrp6nxa9r?= =?us-ascii?Q?/PnRdvdAsztCBverBA2xFF+2dj+mkOaV8tCWELW/j8H9uWolnbrVampMERzE?= =?us-ascii?Q?RwLs5+GEw6ZHeCudCQXKvQF49btagWwknbLs4fUx0pKtDrzJPEwzwL8R2n18?= =?us-ascii?Q?wnsMAu6Z8R6L9xTTYA8W0X9ohT5FNkl4txrOWTvJyorRRr15y1xSg=3D=3D?= X-Microsoft-Antispam-Message-Info: z1CM8KvWMuKk2S6B7aaW3YUwdPEqM9P5EJX/OCFOdvmmN5/COKtKN1IHiSCbYLKQCXh708RL8RV2o5eMFgdq/ZqhMHVr/00jDM7cTDi0Zf07NSDsAbEYxF3BD1454nMgf8N59DWEknasFxler4Exfl7vK/eLtGGOHMcctVLJFLc/SzvwfvPO4ncyvceV0f8zJwFMhNV/Mqls4MNcsOvb7tN2jo2fXj2SM0X0eXBP+yZtwvpzBYJJpMtx/+BCCkMjlgpRDNlIU8j/4HtrebhvSKQwoP5AtTvDm6YuJQg7yixfIXIxDbIi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RgwFvX7aA2yktDL0V9R2SIH0JdtwI5R0T5BWXTz/xeol1JFzbsalZMvidLt6GZzy50RRTIac3st6EIMTS8VU9+hYpNa7L1WFpm+PozWU8UZfdpbisu2t4x X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2018 00:08:16.9825 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 094f3f1a-ac7d-4876-2729-08d5daf8eb21 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 Add a GRE-tunneling test such that there are two tunnels involved, with a multipath route listing both as next hops. Similarly to router_multipath.sh, test that the distribution of traffic to the tunnels honors the configured weights. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- .../selftests/net/forwarding/gre_multipath.sh | 354 +++++++++++++++++++++ 1 file changed, 354 insertions(+) create mode 100755 tools/testing/selftests/net/forwarding/gre_multipath.sh diff --git a/tools/testing/selftests/net/forwarding/gre_multipath.sh b/tools/testing/selftests/net/forwarding/gre_multipath.sh new file mode 100755 index 000000000000..982cc8c23200 --- /dev/null +++ b/tools/testing/selftests/net/forwarding/gre_multipath.sh @@ -0,0 +1,354 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# Test traffic distribution when a wECMP route forwards traffic to two GRE +# tunnels. +# +# +-------------------------+ +# | H1 | +# | $h1 + | +# | 192.0.2.1/28 | | +# | 2001:db8:1::1/64 | | +# +-------------------|-----+ +# | +# +-------------------|------------------------+ +# | SW1 | | +# | $ol1 + | +# | 192.0.2.2/28 | +# | 2001:db8:1::2/64 | +# | | +# | + g1a (gre) + g1b (gre) | +# | loc=192.0.2.65 loc=192.0.2.81 | +# | rem=192.0.2.66 --. rem=192.0.2.82 --. | +# | tos=inherit | tos=inherit | | +# | .------------------' | | +# | | .------------------' | +# | v v | +# | + $ul1.111 (vlan) + $ul1.222 (vlan) | +# | | 192.0.2.129/28 | 192.0.2.145/28 | +# | \ / | +# | \________________/ | +# | | | +# | + $ul1 | +# +------------|-------------------------------+ +# | +# +------------|-------------------------------+ +# | SW2 + $ul2 | +# | _______|________ | +# | / \ | +# | / \ | +# | + $ul2.111 (vlan) + $ul2.222 (vlan) | +# | ^ 192.0.2.130/28 ^ 192.0.2.146/28 | +# | | | | +# | | '------------------. | +# | '------------------. | | +# | + g2a (gre) | + g2b (gre) | | +# | loc=192.0.2.66 | loc=192.0.2.82 | | +# | rem=192.0.2.65 --' rem=192.0.2.81 --' | +# | tos=inherit tos=inherit | +# | | +# | $ol2 + | +# | 192.0.2.17/28 | | +# | 2001:db8:2::1/64 | | +# +-------------------|------------------------+ +# | +# +-------------------|-----+ +# | H2 | | +# | $h2 + | +# | 192.0.2.18/28 | +# | 2001:db8:2::2/64 | +# +-------------------------+ + +ALL_TESTS=" + ping_ipv4 + ping_ipv6 + multipath_ipv4 + multipath_ipv6 + multipath_ipv6_l4 +" + +NUM_NETIFS=6 +source lib.sh + +h1_create() +{ + simple_if_init $h1 192.0.2.1/28 2001:db8:1::1/64 + ip route add vrf v$h1 192.0.2.16/28 via 192.0.2.2 + ip route add vrf v$h1 2001:db8:2::/64 via 2001:db8:1::2 +} + +h1_destroy() +{ + ip route del vrf v$h1 2001:db8:2::/64 via 2001:db8:1::2 + ip route del vrf v$h1 192.0.2.16/28 via 192.0.2.2 + simple_if_fini $h1 192.0.2.1/28 +} + +sw1_create() +{ + simple_if_init $ol1 192.0.2.2/28 2001:db8:1::2/64 + __simple_if_init $ul1 v$ol1 + vlan_create $ul1 111 v$ol1 192.0.2.129/28 + vlan_create $ul1 222 v$ol1 192.0.2.145/28 + + tunnel_create g1a gre 192.0.2.65 192.0.2.66 tos inherit dev v$ol1 + __simple_if_init g1a v$ol1 192.0.2.65/32 + ip route add vrf v$ol1 192.0.2.66/32 via 192.0.2.130 + + tunnel_create g1b gre 192.0.2.81 192.0.2.82 tos inherit dev v$ol1 + __simple_if_init g1b v$ol1 192.0.2.81/32 + ip route add vrf v$ol1 192.0.2.82/32 via 192.0.2.146 + + ip route add vrf v$ol1 192.0.2.16/28 \ + nexthop dev g1a \ + nexthop dev g1b + ip route add vrf v$ol1 2001:db8:2::/64 \ + nexthop dev g1a \ + nexthop dev g1b + + tc qdisc add dev $ul1 clsact + tc filter add dev $ul1 egress pref 111 prot 802.1q \ + flower vlan_id 111 action pass + tc filter add dev $ul1 egress pref 222 prot 802.1q \ + flower vlan_id 222 action pass +} + +sw1_destroy() +{ + tc qdisc del dev $ul1 clsact + + ip route del vrf v$ol1 2001:db8:2::/64 + ip route del vrf v$ol1 192.0.2.16/28 + + ip route del vrf v$ol1 192.0.2.82/32 via 192.0.2.146 + __simple_if_fini g1b 192.0.2.81/32 + tunnel_destroy g1b + + ip route del vrf v$ol1 192.0.2.66/32 via 192.0.2.130 + __simple_if_fini g1a 192.0.2.65/32 + tunnel_destroy g1a + + vlan_destroy $ul1 222 + vlan_destroy $ul1 111 + __simple_if_fini $ul1 + simple_if_fini $ol1 192.0.2.2/28 2001:db8:1::2/64 +} + +sw2_create() +{ + simple_if_init $ol2 192.0.2.17/28 2001:db8:2::1/64 + __simple_if_init $ul2 v$ol2 + vlan_create $ul2 111 v$ol2 192.0.2.130/28 + vlan_create $ul2 222 v$ol2 192.0.2.146/28 + + tunnel_create g2a gre 192.0.2.66 192.0.2.65 tos inherit dev v$ol2 + __simple_if_init g2a v$ol2 192.0.2.66/32 + ip route add vrf v$ol2 192.0.2.65/32 via 192.0.2.129 + + tunnel_create g2b gre 192.0.2.82 192.0.2.81 tos inherit dev v$ol2 + __simple_if_init g2b v$ol2 192.0.2.82/32 + ip route add vrf v$ol2 192.0.2.81/32 via 192.0.2.145 + + ip route add vrf v$ol2 192.0.2.0/28 \ + nexthop dev g2a \ + nexthop dev g2b + ip route add vrf v$ol2 2001:db8:1::/64 \ + nexthop dev g2a \ + nexthop dev g2b +} + +sw2_destroy() +{ + ip route del vrf v$ol2 2001:db8:1::/64 + ip route del vrf v$ol2 192.0.2.0/28 + + ip route del vrf v$ol2 192.0.2.81/32 via 192.0.2.145 + __simple_if_fini g2b 192.0.2.82/32 + tunnel_destroy g2b + + ip route del vrf v$ol2 192.0.2.65/32 via 192.0.2.129 + __simple_if_fini g2a 192.0.2.66/32 + tunnel_destroy g2a + + vlan_destroy $ul2 222 + vlan_destroy $ul2 111 + __simple_if_fini $ul2 + simple_if_fini $ol2 192.0.2.17/28 2001:db8:2::1/64 +} + +h2_create() +{ + simple_if_init $h2 192.0.2.18/28 2001:db8:2::2/64 + ip route add vrf v$h2 192.0.2.0/28 via 192.0.2.17 + ip route add vrf v$h2 2001:db8:1::/64 via 2001:db8:2::1 +} + +h2_destroy() +{ + ip route del vrf v$h2 2001:db8:1::/64 via 2001:db8:2::1 + ip route del vrf v$h2 192.0.2.0/28 via 192.0.2.17 + simple_if_fini $h2 192.0.2.18/28 2001:db8:2::2/64 +} + +setup_prepare() +{ + h1=${NETIFS[p1]} + ol1=${NETIFS[p2]} + + ul1=${NETIFS[p3]} + ul2=${NETIFS[p4]} + + ol2=${NETIFS[p5]} + h2=${NETIFS[p6]} + + vrf_prepare + h1_create + sw1_create + sw2_create + h2_create +} + +cleanup() +{ + pre_cleanup + + h2_destroy + sw2_destroy + sw1_destroy + h1_destroy + vrf_cleanup +} + +multipath4_test() +{ + local what=$1; shift + local weight1=$1; shift + local weight2=$1; shift + + sysctl_set net.ipv4.fib_multipath_hash_policy 1 + ip route replace vrf v$ol1 192.0.2.16/28 \ + nexthop dev g1a weight $weight1 \ + nexthop dev g1b weight $weight2 + + local t0_111=$(tc_rule_stats_get $ul1 111 egress) + local t0_222=$(tc_rule_stats_get $ul1 222 egress) + + ip vrf exec v$h1 \ + $MZ $h1 -q -p 64 -A 192.0.2.1 -B 192.0.2.18 \ + -d 1msec -t udp "sp=1024,dp=0-32768" + + local t1_111=$(tc_rule_stats_get $ul1 111 egress) + local t1_222=$(tc_rule_stats_get $ul1 222 egress) + + local d111=$((t1_111 - t0_111)) + local d222=$((t1_222 - t0_222)) + multipath_eval "$what" $weight1 $weight2 $d111 $d222 + + ip route replace vrf v$ol1 192.0.2.16/28 \ + nexthop dev g1a \ + nexthop dev g1b + sysctl_restore net.ipv4.fib_multipath_hash_policy +} + +multipath6_l4_test() +{ + local what=$1; shift + local weight1=$1; shift + local weight2=$1; shift + + sysctl_set net.ipv6.fib_multipath_hash_policy 1 + ip route replace vrf v$ol1 2001:db8:2::/64 \ + nexthop dev g1a weight $weight1 \ + nexthop dev g1b weight $weight2 + + local t0_111=$(tc_rule_stats_get $ul1 111 egress) + local t0_222=$(tc_rule_stats_get $ul1 222 egress) + + ip vrf exec v$h1 \ + $MZ $h1 -6 -q -p 64 -A 2001:db8:1::1 -B 2001:db8:2::2 \ + -d 1msec -t udp "sp=1024,dp=0-32768" + + local t1_111=$(tc_rule_stats_get $ul1 111 egress) + local t1_222=$(tc_rule_stats_get $ul1 222 egress) + + local d111=$((t1_111 - t0_111)) + local d222=$((t1_222 - t0_222)) + multipath_eval "$what" $weight1 $weight2 $d111 $d222 + + ip route replace vrf v$ol1 2001:db8:2::/64 \ + nexthop dev g1a \ + nexthop dev g1b + sysctl_restore net.ipv6.fib_multipath_hash_policy +} + +multipath6_test() +{ + local what=$1; shift + local weight1=$1; shift + local weight2=$1; shift + + ip route replace vrf v$ol1 2001:db8:2::/64 \ + nexthop dev g1a weight $weight1 \ + nexthop dev g1b weight $weight2 + + local t0_111=$(tc_rule_stats_get $ul1 111 egress) + local t0_222=$(tc_rule_stats_get $ul1 222 egress) + + # Generate 16384 echo requests, each with a random flow label. + for ((i=0; i < 16384; ++i)); do + ip vrf exec v$h1 $PING6 2001:db8:2::2 -F 0 -c 1 -q &> /dev/null + done + + local t1_111=$(tc_rule_stats_get $ul1 111 egress) + local t1_222=$(tc_rule_stats_get $ul1 222 egress) + + local d111=$((t1_111 - t0_111)) + local d222=$((t1_222 - t0_222)) + multipath_eval "$what" $weight1 $weight2 $d111 $d222 + + ip route replace vrf v$ol1 2001:db8:2::/64 \ + nexthop dev g1a \ + nexthop dev g1b +} + +ping_ipv4() +{ + ping_test $h1 192.0.2.18 +} + +ping_ipv6() +{ + ping6_test $h1 2001:db8:2::2 +} + +multipath_ipv4() +{ + log_info "Running IPv4 multipath tests" + multipath4_test "ECMP" 1 1 + multipath4_test "Weighted MP 2:1" 2 1 + multipath4_test "Weighted MP 11:45" 11 45 +} + +multipath_ipv6() +{ + log_info "Running IPv6 multipath tests" + multipath6_test "ECMP" 1 1 + multipath6_test "Weighted MP 2:1" 2 1 + multipath6_test "Weighted MP 11:45" 11 45 +} + +multipath_ipv6_l4() +{ + log_info "Running IPv6 L4 hash multipath tests" + multipath6_l4_test "ECMP" 1 1 + multipath6_l4_test "Weighted MP 2:1" 2 1 + multipath6_l4_test "Weighted MP 11:45" 11 45 +} + +trap cleanup EXIT + +setup_prepare +setup_wait +tests_run + +exit $EXIT_STATUS