From patchwork Mon Nov 19 16:11:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10688877 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 133606C5 for ; Mon, 19 Nov 2018 16:11:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03F182A0FD for ; Mon, 19 Nov 2018 16:11:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBE9D2A0FE; Mon, 19 Nov 2018 16:11:47 +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 1885D29947 for ; Mon, 19 Nov 2018 16:11:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730053AbeKTCfp (ORCPT ); Mon, 19 Nov 2018 21:35:45 -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 S1730008AbeKTCfo (ORCPT ); Mon, 19 Nov 2018 21:35:44 -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=/ChedlF9vlXz0xNvqvT/MP/SdpyxDGu1/qgCkQWnB9Y=; b=PPB9c/HJBd/tOEr5tKD7rA1epH5ze51DdNYg5fqTR0CucGnYLW9nIM/V80Pw5eCMmXDbf8XwtkWjLzTPZQNlSf3z37HPPDGwMByQYiUlqTwrSAJA9e+RpL2rzjtJbGn0bO6flAMMo6gXE+3iTDzN2iy2jEK6feq1NIWIqkk9w8U= 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:30 +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:30 +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 15/18] selftests: forwarding: vxlan_bridge_1d: Add an ECN decap test Thread-Topic: [PATCH net-next 15/18] selftests: forwarding: vxlan_bridge_1d: Add an ECN decap test Thread-Index: AQHUgCKE4GIuCc3vr0iWU9uy2GMx7w== Date: Mon, 19 Nov 2018 16:11:24 +0000 Message-ID: <20181119161006.5405-16-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:kUtmvV3zpwYtpgC3prAqksE4y2pwS5yKQs8Ua2zP9VeqMwWSzpCScM6g15U/l7C0fFEsap8JqsFyJ5oGmKyl7b17OQ8U3RYKZo47u6QHu5AsuM8ljXh8207XWPjKNzOhuVgcP77y239klN31U6ZCVvwjvwCOKtPgLAYqCKXHqydzLpOLPYOny2+44Zb1CMW+5kNVUDdJt8b+sd6is5atf0mVnehA+ac9oQJh+/fxiLAwWCBHCz4wGSyOp6pfiPcrUI6vq1kmlVCWoMppwmvw1ux6kEozc1EcttCtCB3pd8EzAclQKC4LFhXJEeWALOtewIvReE1ldIpXZx7j5RX03ag3t7No1aHgxpQfUTEXT6i98ZrydqZ+yCpzA+cJnTizhNBAMf/SXy091+8UNhFOx/8GPeKCnRg70NoDkZjmhqBWv6T6K5d4eh4U7IzEpa14zwG7dhoNDtsFDPxeUnnKdg==;5:bb1AECs9xTQhoTbmi3LIET2Nums712N4A1INrfJ0Ulw9hTAs9Ghl/GHZ9wGRvbhTd5B85BWBXUvk2FUwgCzPoYZZEN552rLex8Fznr8cvGiGY1anEMtjqZr5xQD690sc1MiLhCiH47L5mpoB7g4a01djJAtUkrXKLLY60q6iGAo=;7:K9hlA1Bmqz6OWc223UepkQb7TXFl/bvMyZ8SWWZOjpZBFsrL5MRiFeL73/6CTNow27qXGOBYsV9aT9gY6QfHu+q4oqZ7SwoQg6qwrUp91hGsj2kXpw1JB/RNL2/EO8xKzjMjhPl90/a7Y/GHjOTIOA== x-ms-office365-filtering-correlation-id: 61f86db5-bec7-4ba8-1a64-08d64e39a6c7 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: tPZn2V56iPsYzjoyPNylBM4Gmr7Df0Mo6Q4ExKQRdfHJaY5KALf+eoxrqDyCTX8HFnaR8TkmCDuR3ytnrhOXrtGjbiYE+AIXf/WHmFUYAbJMCbhH7C4ICjCZt/nl9tUYTze5HB16ToNod9tT/ehxBlrHnNls+L9sgO6nV4i2/YBFrDPxULaDesOIM9aui4D+QFieczJzYmui/4TXEjk+ftv8CZBxziWVeF/zXawFrsoGxmCnsnpxR1K/hOrEcpNAJPmS9U6Fm9Jh20VUMKamVYUWNtCPPNLe9CuyDId6zVgQCeMspaR6WyLlOoOvDlv2v2GA0B4KGKtVEgluwQJ087uqA028kDjQWf15ILuqUk4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61f86db5-bec7-4ba8-1a64-08d64e39a6c7 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Nov 2018 16:11:24.0814 (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 From: Petr Machata Test that when decapsulating from VXLAN, the values of inner and outer TOS are handled appropriately. Because VXLAN driver on its own won't produce the arbitrary TOS combinations necessary to test this feature, simply open-code a single ICMP packet and have mausezahn assemble it. Signed-off-by: Petr Machata Signed-off-by: Ido Schimmel --- .../net/forwarding/vxlan_bridge_1d.sh | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh b/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh index 82a124cbd523..5cc6ac74eb74 100755 --- a/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh +++ b/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh @@ -71,6 +71,7 @@ export VXPORT test_ttl test_tos test_ecn_encap + test_ecn_decap reapply_config ping_ipv4 test_flood @@ -547,6 +548,121 @@ test_ecn_encap() __test_ecn_encap 0x03 0x02 } +vxlan_encapped_ping_do() +{ + local count=$1; shift + local dev=$1; shift + local next_hop_mac=$1; shift + local dest_ip=$1; shift + local dest_mac=$1; shift + local inner_tos=$1; shift + local outer_tos=$1; shift + + $MZ $dev -c $count -d 100msec -q \ + -b $next_hop_mac -B $dest_ip \ + -t udp tos=$outer_tos,sp=23456,dp=$VXPORT,p=$(: + )"08:"$( : VXLAN flags + )"00:00:00:"$( : VXLAN reserved + )"00:03:e8:"$( : VXLAN VNI + )"00:"$( : VXLAN reserved + )"$dest_mac:"$( : ETH daddr + )"$(mac_get w2):"$( : ETH saddr + )"08:00:"$( : ETH type + )"45:"$( : IP version + IHL + )"$inner_tos:"$( : IP TOS + )"00:54:"$( : IP total length + )"99:83:"$( : IP identification + )"40:00:"$( : IP flags + frag off + )"40:"$( : IP TTL + )"01:"$( : IP proto + )"00:00:"$( : IP header csum + )"c0:00:02:03:"$( : IP saddr: 192.0.2.3 + )"c0:00:02:01:"$( : IP daddr: 192.0.2.1 + )"08:"$( : ICMP type + )"00:"$( : ICMP code + )"8b:f2:"$( : ICMP csum + )"1f:6a:"$( : ICMP request identifier + )"00:01:"$( : ICMP request sequence number + )"4f:ff:c5:5b:00:00:00:00:"$( : ICMP payload + )"6d:74:0b:00:00:00:00:00:"$( : + )"10:11:12:13:14:15:16:17:"$( : + )"18:19:1a:1b:1c:1d:1e:1f:"$( : + )"20:21:22:23:24:25:26:27:"$( : + )"28:29:2a:2b:2c:2d:2e:2f:"$( : + )"30:31:32:33:34:35:36:37" +} +export -f vxlan_encapped_ping_do + +vxlan_encapped_ping_test() +{ + local ping_dev=$1; shift + local nh_dev=$1; shift + local ping_dip=$1; shift + local inner_tos=$1; shift + local outer_tos=$1; shift + local stat_get=$1; shift + local expect=$1; shift + + local t0=$($stat_get) + + in_ns ns1 \ + vxlan_encapped_ping_do 10 $ping_dev $(mac_get $nh_dev) \ + $ping_dip $(mac_get $h1) \ + $inner_tos $outer_tos + + local t1=$($stat_get) + local delta=$((t1 - t0)) + + # Tolerate a couple stray extra packets. + ((expect <= delta && delta <= expect + 2)) + check_err $? "Expected to capture $expect packets, got $delta." +} +export -f vxlan_encapped_ping_test + +__test_ecn_decap() +{ + local orig_inner_tos=$1; shift + local orig_outer_tos=$1; shift + local decapped_tos=$1; shift + + RET=0 + + tc filter add dev $h1 ingress pref 77 prot ip \ + flower ip_tos $decapped_tos action pass + sleep 1 + vxlan_encapped_ping_test v2 v1 192.0.2.17 \ + $orig_inner_tos $orig_outer_tos \ + "tc_rule_stats_get $h1 77 ingress" 10 + tc filter del dev $h1 ingress pref 77 + + log_test "VXLAN: ECN decap: $orig_outer_tos/$orig_inner_tos->$decapped_tos" +} + +test_ecn_decap_error() +{ + local orig_inner_tos=00 + local orig_outer_tos=03 + + RET=0 + + vxlan_encapped_ping_test v2 v1 192.0.2.17 \ + $orig_inner_tos $orig_outer_tos \ + "link_stats_rx_errors_get vx1" 10 + + log_test "VXLAN: ECN decap: $orig_outer_tos/$orig_inner_tos->error" +} + +test_ecn_decap() +{ + # In accordance with INET_ECN_decapsulate() + __test_ecn_decap 00 00 0x00 + __test_ecn_decap 01 01 0x01 + __test_ecn_decap 02 01 0x02 + __test_ecn_decap 01 03 0x03 + __test_ecn_decap 02 03 0x03 + test_ecn_decap_error +} + test_all() { echo "Running tests with UDP port $VXPORT"