From patchwork Thu Jun 14 22:17:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10465413 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 38D116020F for ; Thu, 14 Jun 2018 22:19:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EB1028A10 for ; Thu, 14 Jun 2018 22:19:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FC6028A1B; Thu, 14 Jun 2018 22:19:14 +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=-2.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, MAILING_LIST_MULTI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B81C628A10 for ; Thu, 14 Jun 2018 22:19:12 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 416J1q0N50zF0wb for ; Fri, 15 Jun 2018 08:19:11 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="XCUM9MOU"; dkim-atps=neutral X-Original-To: linux-mlxsw@lists.ozlabs.org Delivered-To: linux-mlxsw@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mellanox.com (client-ip=2a01:111:f400:fe07::603; helo=eur02-am5-obe.outbound.protection.outlook.com; envelope-from=petrm@mellanox.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="XCUM9MOU"; dkim-atps=neutral Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02on0603.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe07::603]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 416J1l4VTczF0tX for ; Fri, 15 Jun 2018 08:19:07 +1000 (AEST) 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=SK57Eka8BAuM+DXsFjlGDKLZUaa4WguNMNZO+mq4I+k=; b=XCUM9MOUgEzpAl0pQtFkYrWO13K5QBtey8T7GfVmNcToJFFYvzOGLhV/d0pwK1uikQyLwcawn8Dv++/DCi+5835r2oeZAZLgLftGCwTrnD3R/h69a+1Uf76rvpot2px+BMhP9+w4+jRLnyssIZ/Tfh/Gt8INKtZBXF8+CDYunpU= 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.863.16; Thu, 14 Jun 2018 22:18:59 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw 5/5] selftests: forwarding: Test multipath tunneling In-Reply-To: References: Message-Id: <0e5d8cdca00f7f572f2b4daef1ff12a30d15b026.1529013676.git.petrm@mellanox.com> Date: Fri, 15 Jun 2018 00:17:57 +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: CWLP265CA0100.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:51::16) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4d2d8952-113c-4db2-af69-08d5d244d3c6 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB4191; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 3:8bwEbBCx6ZBatO6P1f8nP2buDbavw/tN2G6GdLEtRYfR7dPvQUnPyGvDNC8RHew8OcwoGrlRCe8pmOA2vPVDEjZ4BLQ2VXL2LTRz5fN2ciUr9c6zynOLOEhZPt7sP2d607PlyACocdTp9vKwSiZcdwkELPcx0w0KEw/wS6P1sX238Qth2Lp4dIWK2emo/WGICVndkSw9rKt20UOmsH+Cws03lv++pIX8hDeWbw5pvwz0FZYJANxdNq3w9AtIe86O; 25:KlRsG3CfDmTnYsm3BrSoUpNzhHFBxWmHjm6yIZwp+RYjRvNEIrZvdBLZhw4Bx5BdDo4UrB3BUP0EICEY04YK0RhN5/9VEIRwPapO2x76nd3KcD8o9KQHul1Lk+AGV1CxBd//ks9+yqd553M5YzIqloD8bajbwG9qp7lRP80Dk7dGw4ABvOy2ijU7MPT2/T0pOWG9ROPP7pvhMtkIMrTUJRwcfutzyi2+pmC6diLGzoMNce/ZgzvQ8LKnxDYxO/4ECuwqp5COHLsTHs3ei75x3ku05HQGgAnJz32uBRcGkQ0vJcYj2pvOTyLMiB8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S1YRCvPeywUQZgG/4Fe5EO8QipkPPwysFGrRmG1CSSDQeggO5jnYZYGtxGfB9ah16F07R2B+IQ/vnK/HpPvIOAwuPNki0cQCockJNqgbGwn8 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)(5005006)(8121501046)(93006095)(93001095)(3231254)(944501410)(52105095)(10201501046)(3002001)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:VI1PR05MB4191; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4191; X-Forefront-PRVS: 0703B549E4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39380400002)(396003)(346002)(39860400002)(366004)(189003)(199004)(86362001)(16526019)(53936002)(26005)(25786009)(50466002)(97736004)(68736007)(3846002)(6116002)(2351001)(186003)(6862004)(2906002)(36756003)(106356001)(48376002)(386003)(6486002)(11346002)(59450400001)(105586002)(8936002)(6496006)(446003)(486006)(305945005)(81166006)(81156014)(8676002)(5660300001)(6636002)(2616005)(76176011)(118296001)(476003)(956004)(51416003)(52116002)(16586007)(47776003)(37006003)(7736002)(58126008)(66066001)(316002)(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:alCIaIzSW5EYzC7ku274QmTsTnauuGx7EtdKLaKXt?= =?us-ascii?Q?P1RJ1z2xyfg4peLnMDAum1GuVOif4XGwaXgJn90akFhvKkVd4hoWQq+6R6i/?= =?us-ascii?Q?21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h5DNal18RfCAQu/Fm67fj4W1?= =?us-ascii?Q?kCd1kGA6EGDBtIYBrRnhcUCs7YQ8TosRd0M9NUaDEhyC5A+nj7EKizLweJrH?= =?us-ascii?Q?s2ox7cu+j0B/pXGzykvVMqAs9JBC7Tl8byd5uafwMGzG3NThfl4osryJHnp8?= =?us-ascii?Q?3WX5YIDkjwGmwJl8C1NcbRgXmAvN8lainnlxYzmjac1MerQvst3NNP6oYiw/?= =?us-ascii?Q?DBuuAjmNn+AODpisAP7jw0V6k3mFFbJfl4m1enYwv5oZ+qb+HW8PXU6rA=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Antispam-Message-Info: xKW+xlpy3NKUmZEh30fQu4wVom1FiPifHUJDBS//hD+8S4mzYoxtzTDZZASxQh1d4K446KgHZvNf3VoH18n4Bi4uAyLyMw0Fvv641TgE71nxIXVBq2M9T54k3MDSYF92/TtbQDEL1VpORy082tC0Ib0PRIsmVOIW5KrszJ5i89CL+yPtxah431hdBtL/24Mm X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 6:/AkF2zr2EmRMNN4udCdHZ2KUNCj/2a31LwPzRS32mLUD4Ye8cVGL5XVE2dLQMLWmCN7DuzvU4WMIJoJShXFX2pA0aH/IPl/FQ6tsvAfsEI1rqX553jlPvZoz1W7rXq9jcKAJ7cD7gcVh28hBK5BKDumSoOxyUT5phc9mx8NYwe03Kk11tqzA6ei0aPDFZwj/bYddT4tesU4zA64m57BLgzuVV1y19ohtpmCTqhlik8c5QcqSQh/klTbcwl98SZywMV1o+mLdZCuFQXUDp2QXGa+msfAexaEGlx58tEzePTXWYG/HBYkcA1ehWMUW4b8xHKnqRPaIDruR5HqK/nhLHF8VK8W5gaBK7/pzEtV1T1Ipj8CcQjmttDQrbwGqTxxsxlglm+sVUwJTqGeTTH4Q62JQkQU1TLyOlRjmXaDFscWJ0WhLdmROqKwffP9MlD37ufBuioAw6GqNY0wiJxVjAw==; 5:u+v1RhoFMrNJG+8RWcFue7Xmzr/j+jlIs043jiATzVo/jXoer231shnOJof6V6xHq5vUG0yXibM/VZLQf6so1+6/swVHm55cfMSxe8AgO80UG+sC7rwxIXzHidQ4MJsxW1sNu6OXoYjS1RaAYKtmwJ1em5BJSmU77hndAC9mgKg=; 24:d/Zx+KMP7I/8JpCE0mYnyB81OTpyCD4MK1bIw2OvSR/OJt/5RXi6v52/Q1udq2S1nkw3GKFz9wXQ9FmNBfpRoEPVF4d31obwiWLUKvjxGMU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 7:q4OAsxLovN3x/DahbjgdJPEwSlK48LWB61nksUfQKdXGCm3Ms08Ho4m+swG8PC6BAiWMgVPXR0tAd3WKeqHymJJkES/yF00BXPaxbsG2PDgNSvfCob8lk7a3MOGZ9vVj7hoNgtSAYo75LiMSl6ulwbNZqlMCtze1Ik4AGekZW+9DZNRCtgN0Az1OobBClQHxEmaGCaf4EnvwEqrc5DXIkdMn6Zi+zCpx1sHP9Owmten8DBwCS70RznSSF6wnlBp1 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2018 22:18:59.2163 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d2d8952-113c-4db2-af69-08d5d244d3c6 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4191 X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.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 --- .../selftests/net/forwarding/gre_multipath.sh | 296 +++++++++++++++++++++ 1 file changed, 296 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..a84aad52fbca --- /dev/null +++ b/tools/testing/selftests/net/forwarding/gre_multipath.sh @@ -0,0 +1,296 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +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