From patchwork Mon Nov 19 16:11:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10688863 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 2C2036C5 for ; Mon, 19 Nov 2018 16:11:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C9502A0DC for ; Mon, 19 Nov 2018 16:11:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 103572A0FD; Mon, 19 Nov 2018 16:11:33 +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 4B0AA2A101 for ; Mon, 19 Nov 2018 16:11:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730032AbeKTCfd (ORCPT ); Mon, 19 Nov 2018 21:35:33 -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 S1729957AbeKTCfa (ORCPT ); Mon, 19 Nov 2018 21:35:30 -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=TeFgEGJUl312xFXMNELKPooMutmrW0grH+WMyp/QG1E=; b=M9D8irngvPYu1PGS6qCgIvG5IMlgEVGsFK9FCpiJ+iaZaVygXa+L9OyxhhO6i5B0nd9SYCkKtzzknLhxzO7d7zaSkgv6EYAm08kOWw1LDx6YDP9uNhT54D0+UiQsFG7sHs1ElwYL0e94NocmSAfGXLh1qEolWKRg5y1G3k8PKps= 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:15 +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:15 +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 07/18] selftests: forwarding: Add a skeleton of vxlan_bridge_1d Thread-Topic: [PATCH net-next 07/18] selftests: forwarding: Add a skeleton of vxlan_bridge_1d Thread-Index: AQHUgCJ+JEG4IMBJHU6Ah2pQW8rNSA== Date: Mon, 19 Nov 2018 16:11:14 +0000 Message-ID: <20181119161006.5405-8-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:yohiT1uPcC0INMy0PTSbvYA8cvEusTxzmjEl0xRSiG9VRJFcIIXEBVWlUVyLRjE6H+lXicdp8hT6Eyv2ZZ+ehu0zAuAzrm8V8E+bW6SYC2LqPssNPS6xZ9+b0OTTbI5RxyuFo4WOhrYYmS4d25rh8bFy5eAo6NGXvJZ1kTk5vi8gi1d9saPfq8jhGBwb3QlKmirJ7thTqorPw3OcQ1hEana3f+xHWl3F6M5eBoQm58RomTzhaWk80XQJXL/7eANoRR7VAuKF822FfodPA92xwodllL0FSghToqCstzAOjJhJH5rLRNuZ7p9ymFTKTVZZdWd6cV/ZeKPe5Tsiw1gabCB4uXxQ3qJOtaw5I0gPIVKJlwgfBZuhWd4T9qMSAeqV+T4KA1pi/8WjdhmCaDvI0t3ksqS49QwhIoWf7LhsJ0v54Pe9po4kmTPpX45qUyMjPsHjZyBx4/XtNkGC+08YcA==;5:MJlktS7CfKA8HM3uQeJj3lqYdj0KUmzrtZHcdstdh0Pd9Hw/uZ+MuWcUO51KEdz8iuUiBySp5Xuw74X9+Xw2wgcNuKDa+lMYNQXmIhdi8qC4c9USY3OJSMEaXOtfbYCFkCq7qPbOM1VPqPD9uSl5qWeFKDWNWoSurTkjRj8GCk4=;7:PgyZbiDApUpqiZTDOnm3N+38oti2wTYfDUT7kyqhYf6c1h0IMu/1HYUu0yBpf3V8q40fkI4pSakAJDEJKJ7ZaEj6+UqZxT/NIwWMURKNBxv6pJX1R4RmUIRRdmoxQ/Oju28WXK0P0o3ihCz0tWBQHw== x-ms-office365-filtering-correlation-id: 384327c3-11c9-4011-7d8b-08d64e39a146 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:; 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)(14444005)(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)(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: 4JJtwPf06YIGUBfU6foHwKs1i+FhXUP8CiwMgY58MeUhilQBfPJ8vd4GEyF/3K9rkxRiuoYZRswNx8/BxlOvTU2owUOOaNhh+vOAB3kL04EBxSHC04Bw/RV5pP/HArPdTUyadK+AibuIeFF+a0Sf8u2tFUQGaz06Yr7JhPsioMfCknVr5FJa+go2YNgGdgXALrgNrSyq1REpk2jecliXcIid0jsBd6FBB78V2bNlos228Hvcdw8exOasHT3R4r2n2pmk3UGen+1N9aldrS7f5Z2aFmAvY3ujPvJGOtSXdb4TNIQEvfMjII78xQiHTMvoF7TiGzSDAvjV+nmRCyiDTxMWy9OcgcJQFPoJ8BPCjq8= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 384327c3-11c9-4011-7d8b-08d64e39a146 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Nov 2018 16:11:14.8750 (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 This skeleton sets up a topology with three VXLAN endpoints: one "local", possibly offloaded, and two "remote", formed using veth pairs and likely purely software bridges. The "local" endpoint is connected to host systems by a VLAN-unaware bridge. Since VXLAN tunnels must be unique per namespace, each of the "remote" endpoints is in its own namespace. H3 forms the bridge between the three domains. Signed-off-by: Petr Machata Signed-off-by: Ido Schimmel --- .../net/forwarding/vxlan_bridge_1d.sh | 296 ++++++++++++++++++ 1 file changed, 296 insertions(+) create mode 100755 tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh diff --git a/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh b/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh new file mode 100755 index 000000000000..af88e1c146a7 --- /dev/null +++ b/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh @@ -0,0 +1,296 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# +--------------------+ +----------------------+ +# | H1 (vrf) | | H2 (vrf) | +# | + $h1 | | + $h2 | +# | | 192.0.2.1/28 | | | 192.0.2.2/28 | +# +----|---------------+ +--|-------------------+ +# | | +# +----|--------------------------------------------------|-------------------+ +# | SW | | | +# | +--|--------------------------------------------------|-----------------+ | +# | | + $swp1 BR1 (802.1d) + $swp2 | | +# | | | | +# | | + vx1 (vxlan) | | +# | | local 192.0.2.17 | | +# | | remote 192.0.2.34 192.0.2.50 | | +# | | id 1000 dstport $VXPORT | | +# | +-----------------------------------------------------------------------+ | +# | | +# | 192.0.2.32/28 via 192.0.2.18 | +# | 192.0.2.48/28 via 192.0.2.18 | +# | | +# | + $rp1 | +# | | 192.0.2.17/28 | +# +----|----------------------------------------------------------------------+ +# | +# +----|--------------------------------------------------------+ +# | | VRP2 (vrf) | +# | + $rp2 | +# | 192.0.2.18/28 | +# | | (maybe) HW +# ============================================================================= +# | | (likely) SW +# | + v1 (veth) + v3 (veth) | +# | | 192.0.2.33/28 | 192.0.2.49/28 | +# +----|---------------------------------------|----------------+ +# | | +# +----|------------------------------+ +----|------------------------------+ +# | + v2 (veth) NS1 (netns) | | + v4 (veth) NS2 (netns) | +# | 192.0.2.34/28 | | 192.0.2.50/28 | +# | | | | +# | 192.0.2.16/28 via 192.0.2.33 | | 192.0.2.16/28 via 192.0.2.49 | +# | 192.0.2.50/32 via 192.0.2.33 | | 192.0.2.34/32 via 192.0.2.49 | +# | | | | +# | +-------------------------------+ | | +-------------------------------+ | +# | | BR2 (802.1d) | | | | BR2 (802.1d) | | +# | | + vx2 (vxlan) | | | | + vx2 (vxlan) | | +# | | local 192.0.2.34 | | | | local 192.0.2.50 | | +# | | remote 192.0.2.17 | | | | remote 192.0.2.17 | | +# | | remote 192.0.2.50 | | | | remote 192.0.2.34 | | +# | | id 1000 dstport $VXPORT | | | | id 1000 dstport $VXPORT | | +# | | | | | | | | +# | | + w1 (veth) | | | | + w1 (veth) | | +# | +--|----------------------------+ | | +--|----------------------------+ | +# | | | | | | +# | +--|----------------------------+ | | +--|----------------------------+ | +# | | | VW2 (vrf) | | | | | VW2 (vrf) | | +# | | + w2 (veth) | | | | + w2 (veth) | | +# | | 192.0.2.3/28 | | | | 192.0.2.4/28 | | +# | +-------------------------------+ | | +-------------------------------+ | +# +-----------------------------------+ +-----------------------------------+ + +: ${VXPORT:=4789} +export VXPORT + +: ${ALL_TESTS:=" + "} + +NUM_NETIFS=6 +source lib.sh + +h1_create() +{ + simple_if_init $h1 192.0.2.1/28 + tc qdisc add dev $h1 clsact +} + +h1_destroy() +{ + tc qdisc del dev $h1 clsact + simple_if_fini $h1 192.0.2.1/28 +} + +h2_create() +{ + simple_if_init $h2 192.0.2.2/28 + tc qdisc add dev $h2 clsact +} + +h2_destroy() +{ + tc qdisc del dev $h2 clsact + simple_if_fini $h2 192.0.2.2/28 +} + +rp1_set_addr() +{ + ip address add dev $rp1 192.0.2.17/28 + + ip route add 192.0.2.32/28 nexthop via 192.0.2.18 + ip route add 192.0.2.48/28 nexthop via 192.0.2.18 +} + +rp1_unset_addr() +{ + ip route del 192.0.2.48/28 nexthop via 192.0.2.18 + ip route del 192.0.2.32/28 nexthop via 192.0.2.18 + + ip address del dev $rp1 192.0.2.17/28 +} + +switch_create() +{ + ip link add name br1 type bridge vlan_filtering 0 mcast_snooping 0 + # Make sure the bridge uses the MAC address of the local port and not + # that of the VxLAN's device. + ip link set dev br1 address $(mac_get $swp1) + ip link set dev br1 up + + ip link set dev $rp1 up + rp1_set_addr + + ip link add name vx1 type vxlan id 1000 \ + local 192.0.2.17 dstport "$VXPORT" \ + nolearning noudpcsum tos inherit ttl 100 + ip link set dev vx1 up + + ip link set dev vx1 master br1 + ip link set dev $swp1 master br1 + ip link set dev $swp1 up + + ip link set dev $swp2 master br1 + ip link set dev $swp2 up + + bridge fdb append dev vx1 00:00:00:00:00:00 dst 192.0.2.34 self + bridge fdb append dev vx1 00:00:00:00:00:00 dst 192.0.2.50 self +} + +switch_destroy() +{ + rp1_unset_addr + ip link set dev $rp1 down + + bridge fdb del dev vx1 00:00:00:00:00:00 dst 192.0.2.50 self + bridge fdb del dev vx1 00:00:00:00:00:00 dst 192.0.2.34 self + + ip link set dev vx1 nomaster + ip link set dev vx1 down + ip link del dev vx1 + + ip link set dev $swp2 down + ip link set dev $swp2 nomaster + + ip link set dev $swp1 down + ip link set dev $swp1 nomaster + + ip link set dev br1 down + ip link del dev br1 +} + +vrp2_create() +{ + simple_if_init $rp2 192.0.2.18/28 + __simple_if_init v1 v$rp2 192.0.2.33/28 + __simple_if_init v3 v$rp2 192.0.2.49/28 + tc qdisc add dev v1 clsact +} + +vrp2_destroy() +{ + tc qdisc del dev v1 clsact + __simple_if_fini v3 192.0.2.49/28 + __simple_if_fini v1 192.0.2.33/28 + simple_if_fini $rp2 192.0.2.18/28 +} + +ns_init_common() +{ + local in_if=$1; shift + local in_addr=$1; shift + local other_in_addr=$1; shift + local nh_addr=$1; shift + local host_addr=$1; shift + + ip link set dev $in_if up + ip address add dev $in_if $in_addr/28 + tc qdisc add dev $in_if clsact + + ip link add name br2 type bridge vlan_filtering 0 + ip link set dev br2 up + + ip link add name w1 type veth peer name w2 + + ip link set dev w1 master br2 + ip link set dev w1 up + + ip link add name vx2 type vxlan id 1000 local $in_addr dstport "$VXPORT" + ip link set dev vx2 up + bridge fdb append dev vx2 00:00:00:00:00:00 dst 192.0.2.17 self + bridge fdb append dev vx2 00:00:00:00:00:00 dst $other_in_addr self + + ip link set dev vx2 master br2 + tc qdisc add dev vx2 clsact + + simple_if_init w2 $host_addr/28 + + ip route add 192.0.2.16/28 nexthop via $nh_addr + ip route add $other_in_addr/32 nexthop via $nh_addr +} +export -f ns_init_common + +ns1_create() +{ + ip netns add ns1 + ip link set dev v2 netns ns1 + in_ns ns1 \ + ns_init_common v2 192.0.2.34 192.0.2.50 192.0.2.33 192.0.2.3 +} + +ns1_destroy() +{ + ip netns exec ns1 ip link set dev v2 netns 1 + ip netns del ns1 +} + +ns2_create() +{ + ip netns add ns2 + ip link set dev v4 netns ns2 + in_ns ns2 \ + ns_init_common v4 192.0.2.50 192.0.2.34 192.0.2.49 192.0.2.4 +} + +ns2_destroy() +{ + ip netns exec ns2 ip link set dev v4 netns 1 + ip netns del ns2 +} + +setup_prepare() +{ + h1=${NETIFS[p1]} + swp1=${NETIFS[p2]} + + swp2=${NETIFS[p3]} + h2=${NETIFS[p4]} + + rp1=${NETIFS[p5]} + rp2=${NETIFS[p6]} + + vrf_prepare + forwarding_enable + + h1_create + h2_create + switch_create + + ip link add name v1 type veth peer name v2 + ip link add name v3 type veth peer name v4 + vrp2_create + ns1_create + ns2_create +} + +cleanup() +{ + pre_cleanup + + ns2_destroy + ns1_destroy + vrp2_destroy + ip link del dev v3 + ip link del dev v1 + + switch_destroy + h2_destroy + h1_destroy + + forwarding_restore + vrf_cleanup +} + +test_all() +{ + echo "Running tests with UDP port $VXPORT" + tests_run +} + +trap cleanup EXIT + +setup_prepare +setup_wait +test_all + +exit $EXIT_STATUS