From patchwork Mon Nov 19 16:11:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10688887 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 6786717FE for ; Mon, 19 Nov 2018 16:11:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56AE82A0FD for ; Mon, 19 Nov 2018 16:11:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B0752A101; Mon, 19 Nov 2018 16:11:59 +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 7739E2A0FD for ; Mon, 19 Nov 2018 16:11:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730079AbeKTCf5 (ORCPT ); Mon, 19 Nov 2018 21:35:57 -0500 Received: from mail-eopbgr10079.outbound.protection.outlook.com ([40.107.1.79]:19425 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730051AbeKTCf4 (ORCPT ); Mon, 19 Nov 2018 21:35:56 -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=M9qFxeV5djllBPcc1BumjJCf0AbvxdVhreuanJh2yIc=; b=rsHfue6YlhFw03iLdTahfEpIrsPYWPiD8xn05h3V9Ym1ulvIZxk/lMQ/3A4Y6XswyKdtQXs4UpUaTjHkG16dfjHwdF8dfPBEm30F9m15k8MiNk2hS4e+s0ZEj5SMMK1/mBRT+Juy65uik9LwKtKMarkU0LGO/ZKI0Hn2yaKmtPA= Received: from AM0PR05MB4978.eurprd05.prod.outlook.com (20.177.42.95) by AM0PR05MB4899.eurprd05.prod.outlook.com (20.177.41.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.35; Mon, 19 Nov 2018 16:11:38 +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:38 +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 18/18] selftests: mlxsw: Add a test for VxLAN flooding Thread-Topic: [PATCH net-next 18/18] selftests: mlxsw: Add a test for VxLAN flooding Thread-Index: AQHUgCKG0dSUddAvw0yIOgHAi+X0ZA== Date: Mon, 19 Nov 2018 16:11:27 +0000 Message-ID: <20181119161006.5405-19-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;AM0PR05MB4899;6:/j6SUVOLuRPg6RpPAZRT4stVviV6r0LlQCxGLxzLZExvBgVwoKAbEhS1WJjJXTqNMRjQCq1XyIsLp2uv94/C2p2yjgDI/cnAn+XUna1oayHNyDpCvFGUD/BxNhTJrZJkFQHNbzCEeSgZu0vPOWwp0Pg4xWYgcvjADI46m5EoSACqqSUwtuRg4a59F+GzdHB2tbTrn83Gk/gkfbAeuB1ffYDDp7lu08t0EU2bUdHckhV+PUl3NBsjeNhVdcsGYsVii/syVQrzdezuqAUhLPHFkLWuLvYJOqqM+mFfWT+ITYxIo9YIS+qCyvt62fKrV2mQ3EM/daDp6hI2gUzBvbBMlVInlt5EveAsjqoxP12GDJDu5bD3tewLsMeoMgryyDthWWLpz/mTloPCRlxi3rAqAyWeaqQ/nw/Q9s2Xy3eE09ewoCz1dhNFUgqgibFS6bGj0kcCEPo+y5ndX33O3E19hg==;5:ZxU1NiFKS0JUi1nbccc14DZxGsFwqAQnrgAfCgopCu/RJ1k5GyvEXLUgZbsInwieIQ5L6fymrLEOvgMQjmmVZJPk7mVUwl7Ct8N9OceW+2HsF5aPaMBh4EMTgpG2TWu7clFoKerxtnkie344HdladrglbIeyO3Dgtye433oE0wo=;7:bkIpg2VCchCbRnHrZfhBP7i5qKs0NqAjoT1518WdJ+WKe6/UaRk8GxSl9vAhaKx36DcHYCF0Bn+AqrzjVtrRi2r2QAJAIIEKMO4QDEeqOq9Y41RT1TNVhPcNlpZPK8tqShv1B+rCgIYvK70b6LWQFQ== x-ms-office365-filtering-correlation-id: 5d95a615-6a14-4765-be3b-08d64e39a8e0 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:AM0PR05MB4899; x-ms-traffictypediagnostic: AM0PR05MB4899: 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)(3231415)(944501410)(52105112)(3002001)(10201501046)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991095);SRVR:AM0PR05MB4899;BCL:0;PCL:0;RULEID:;SRVR:AM0PR05MB4899; x-forefront-prvs: 08617F610C x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(376002)(39860400002)(346002)(366004)(136003)(396003)(199004)(189003)(8676002)(6666004)(386003)(68736007)(26005)(14454004)(36756003)(8936002)(1076002)(102836004)(3846002)(6116002)(6506007)(4326008)(186003)(81166006)(81156014)(52116002)(25786009)(11346002)(110136005)(316002)(478600001)(54906003)(76176011)(2906002)(6512007)(107886003)(53936002)(99286004)(2616005)(2501003)(7736002)(86362001)(446003)(66066001)(6436002)(476003)(5660300001)(305945005)(106356001)(14444005)(256004)(105586002)(6486002)(97736004)(71200400001)(486006)(71190400001)(2900100001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR05MB4899;H:AM0PR05MB4978.eurprd05.prod.outlook.com;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-antispam-message-info: xjGz0oTymdNICXo/p3R3YVpH8IxhjEOoexOeUfTpFR6KqbPs7KvkdYdQJepXfmW8W8QpaXI3NjJplvNHkAsX4S9S3y9l0Q8Gzha6oMdOhNBIZOu7FH6Z4FIf0N55yoYC9H8QGpcYfPYDzd3iFi8zEqHLtkgNr46gVsPye04nOqqjhgg/dYvn9xbvhYq2xeVsFGNoENU9lV61E8rIKUeIORem0KrT2tL/4rQU3ocxEdlORGvF5gnUf3lfpU27rOmNCzpkJ5ww6MnHf4rVuueMK//M13LVqa/PVb4G4YGDhGb80z4o+GJ553bXOIw+kHuD7rRQ51i0eMnvaIUApIRV0YG/e3mmFIAeuN29ILlcRAg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d95a615-6a14-4765-be3b-08d64e39a8e0 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Nov 2018 16:11:27.6930 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4899 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 The device stores flood records in a singly linked list where each record stores up to three IPv4 addresses of remote VTEPs. The test verifies that packets are correctly flooded in various cases such as deletion of a record in the middle of the list. Signed-off-by: Ido Schimmel Reviewed-by: Petr Machata --- .../drivers/net/mlxsw/vxlan_flooding.sh | 309 ++++++++++++++++++ 1 file changed, 309 insertions(+) create mode 100755 tools/testing/selftests/drivers/net/mlxsw/vxlan_flooding.sh diff --git a/tools/testing/selftests/drivers/net/mlxsw/vxlan_flooding.sh b/tools/testing/selftests/drivers/net/mlxsw/vxlan_flooding.sh new file mode 100755 index 000000000000..fedcb7b35af9 --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/vxlan_flooding.sh @@ -0,0 +1,309 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Test VxLAN flooding. The device stores flood records in a singly linked list +# where each record stores up to three IPv4 addresses of remote VTEPs. The test +# verifies that packets are correctly flooded in various cases such as deletion +# of a record in the middle of the list. +# +# +--------------------+ +# | H1 (vrf) | +# | + $h1 | +# | | 203.0.113.1/24| +# +----|---------------+ +# | +# +----|----------------------------------------------------------------------+ +# | SW | | +# | +--|--------------------------------------------------------------------+ | +# | | + $swp1 BR0 (802.1d) | | +# | | | | +# | | + vxlan0 (vxlan) | | +# | | local 198.51.100.1 | | +# | | remote 198.51.100.{2..13} | | +# | | id 10 dstport 4789 | | +# | +-----------------------------------------------------------------------+ | +# | | +# | 198.51.100.0/24 via 192.0.2.2 | +# | | +# | + $rp1 | +# | | 192.0.2.1/24 | +# +----|----------------------------------------------------------------------+ +# | +# +----|--------------------------------------------------------+ +# | | R2 (vrf) | +# | + $rp2 | +# | 192.0.2.2/24 | +# | | +# +-------------------------------------------------------------+ + +lib_dir=$(dirname $0)/../../../net/forwarding + +ALL_TESTS="flooding_test" +NUM_NETIFS=4 +source $lib_dir/tc_common.sh +source $lib_dir/lib.sh + +h1_create() +{ + simple_if_init $h1 203.0.113.1/24 +} + +h1_destroy() +{ + simple_if_fini $h1 203.0.113.1/24 +} + +switch_create() +{ + # Make sure the bridge uses the MAC address of the local port and + # not that of the VxLAN's device + ip link add dev br0 type bridge mcast_snooping 0 + ip link set dev br0 address $(mac_get $swp1) + + ip link add name vxlan0 type vxlan id 10 nolearning noudpcsum \ + ttl 20 tos inherit local 198.51.100.1 dstport 4789 + + ip address add 198.51.100.1/32 dev lo + + ip link set dev $swp1 master br0 + ip link set dev vxlan0 master br0 + + ip link set dev br0 up + ip link set dev $swp1 up + ip link set dev vxlan0 up +} + +switch_destroy() +{ + ip link set dev vxlan0 down + ip link set dev $swp1 down + ip link set dev br0 down + + ip link set dev vxlan0 nomaster + ip link set dev $swp1 nomaster + + ip address del 198.51.100.1/32 dev lo + + ip link del dev vxlan0 + + ip link del dev br0 +} + +router1_create() +{ + # This router is in the default VRF, where the VxLAN device is + # performing the L3 lookup + ip link set dev $rp1 up + ip address add 192.0.2.1/24 dev $rp1 + ip route add 198.51.100.0/24 via 192.0.2.2 +} + +router1_destroy() +{ + ip route del 198.51.100.0/24 via 192.0.2.2 + ip address del 192.0.2.1/24 dev $rp1 + ip link set dev $rp1 down +} + +router2_create() +{ + # This router is not in the default VRF, so use simple_if_init() + simple_if_init $rp2 192.0.2.2/24 +} + +router2_destroy() +{ + simple_if_fini $rp2 192.0.2.2/24 +} + +setup_prepare() +{ + h1=${NETIFS[p1]} + swp1=${NETIFS[p2]} + + rp1=${NETIFS[p3]} + rp2=${NETIFS[p4]} + + vrf_prepare + + h1_create + + switch_create + + router1_create + router2_create + + forwarding_enable +} + +cleanup() +{ + pre_cleanup + + forwarding_restore + + router2_destroy + router1_destroy + + switch_destroy + + h1_destroy + + vrf_cleanup +} + +flooding_remotes_add() +{ + local num_remotes=$1 + local lsb + local i + + for i in $(eval echo {1..$num_remotes}); do + lsb=$((i + 1)) + + bridge fdb append 00:00:00:00:00:00 dev vxlan0 self \ + dst 198.51.100.$lsb + done +} + +flooding_filters_add() +{ + local num_remotes=$1 + local lsb + local i + + tc qdisc add dev $rp2 clsact + + for i in $(eval echo {1..$num_remotes}); do + lsb=$((i + 1)) + + tc filter add dev $rp2 ingress protocol ip pref $i handle $i \ + flower ip_proto udp dst_ip 198.51.100.$lsb \ + dst_port 4789 skip_sw action drop + done +} + +flooding_filters_del() +{ + local num_remotes=$1 + local i + + for i in $(eval echo {1..$num_remotes}); do + tc filter del dev $rp2 ingress protocol ip pref $i \ + handle $i flower + done + + tc qdisc del dev $rp2 clsact +} + +flooding_check_packets() +{ + local packets=("$@") + local num_remotes=${#packets[@]} + local i + + for i in $(eval echo {1..$num_remotes}); do + tc_check_packets "dev $rp2 ingress" $i ${packets[i - 1]} + check_err $? "remote $i - did not get expected number of packets" + done +} + +flooding_test() +{ + # Use 12 remote VTEPs that will be stored in 4 records. The array + # 'packets' will store how many packets are expected to be received + # by each remote VTEP at each stage of the test + declare -a packets=(1 1 1 1 1 1 1 1 1 1 1 1) + local num_remotes=12 + + RET=0 + + # Add FDB entries for remote VTEPs and corresponding tc filters on the + # ingress of the nexthop router. These filters will count how many + # packets were flooded to each remote VTEP + flooding_remotes_add $num_remotes + flooding_filters_add $num_remotes + + # Send one packet and make sure it is flooded to all the remote VTEPs + $MZ $h1 -q -p 64 -b de:ad:be:ef:13:37 -t ip -c 1 + flooding_check_packets "${packets[@]}" + log_test "flood after 1 packet" + + # Delete the third record which corresponds to VTEPs with LSB 8..10 + # and check that packet is flooded correctly when we remove a record + # from the middle of the list + RET=0 + + packets=(2 2 2 2 2 2 1 1 1 2 2 2) + bridge fdb del 00:00:00:00:00:00 dev vxlan0 self dst 198.51.100.8 + bridge fdb del 00:00:00:00:00:00 dev vxlan0 self dst 198.51.100.9 + bridge fdb del 00:00:00:00:00:00 dev vxlan0 self dst 198.51.100.10 + + $MZ $h1 -q -p 64 -b de:ad:be:ef:13:37 -t ip -c 1 + flooding_check_packets "${packets[@]}" + log_test "flood after 2 packets" + + # Delete the first record and make sure the packet is flooded correctly + RET=0 + + packets=(2 2 2 3 3 3 1 1 1 3 3 3) + bridge fdb del 00:00:00:00:00:00 dev vxlan0 self dst 198.51.100.2 + bridge fdb del 00:00:00:00:00:00 dev vxlan0 self dst 198.51.100.3 + bridge fdb del 00:00:00:00:00:00 dev vxlan0 self dst 198.51.100.4 + + $MZ $h1 -q -p 64 -b de:ad:be:ef:13:37 -t ip -c 1 + flooding_check_packets "${packets[@]}" + log_test "flood after 3 packets" + + # Delete the last record and make sure the packet is flooded correctly + RET=0 + + packets=(2 2 2 4 4 4 1 1 1 3 3 3) + bridge fdb del 00:00:00:00:00:00 dev vxlan0 self dst 198.51.100.11 + bridge fdb del 00:00:00:00:00:00 dev vxlan0 self dst 198.51.100.12 + bridge fdb del 00:00:00:00:00:00 dev vxlan0 self dst 198.51.100.13 + + $MZ $h1 -q -p 64 -b de:ad:be:ef:13:37 -t ip -c 1 + flooding_check_packets "${packets[@]}" + log_test "flood after 4 packets" + + # Delete the last record, one entry at a time and make sure single + # entries are correctly removed + RET=0 + + packets=(2 2 2 4 5 5 1 1 1 3 3 3) + bridge fdb del 00:00:00:00:00:00 dev vxlan0 self dst 198.51.100.5 + + $MZ $h1 -q -p 64 -b de:ad:be:ef:13:37 -t ip -c 1 + flooding_check_packets "${packets[@]}" + log_test "flood after 5 packets" + + RET=0 + + packets=(2 2 2 4 5 6 1 1 1 3 3 3) + bridge fdb del 00:00:00:00:00:00 dev vxlan0 self dst 198.51.100.6 + + $MZ $h1 -q -p 64 -b de:ad:be:ef:13:37 -t ip -c 1 + flooding_check_packets "${packets[@]}" + log_test "flood after 6 packets" + + RET=0 + + packets=(2 2 2 4 5 6 1 1 1 3 3 3) + bridge fdb del 00:00:00:00:00:00 dev vxlan0 self dst 198.51.100.7 + + $MZ $h1 -q -p 64 -b de:ad:be:ef:13:37 -t ip -c 1 + flooding_check_packets "${packets[@]}" + log_test "flood after 7 packets" + + flooding_filters_del $num_remotes +} + +trap cleanup EXIT + +setup_prepare +setup_wait + +tests_run + +exit $EXIT_STATUS