From patchwork Thu Apr 26 23:18:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10367005 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 507E160386 for ; Thu, 26 Apr 2018 23:19:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4997F2929C for ; Thu, 26 Apr 2018 23:19:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DB1B2929E; Thu, 26 Apr 2018 23:19:28 +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, LOTS_OF_MONEY, 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 262D72929C for ; Thu, 26 Apr 2018 23:19:27 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40XCgx4GQpzF25l for ; Fri, 27 Apr 2018 09:19:25 +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="vrjSADaI"; 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=104.47.1.52; helo=eur01-ve1-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="vrjSADaI"; dkim-atps=neutral Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0052.outbound.protection.outlook.com [104.47.1.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40XCgs2P8VzF25Z for ; Fri, 27 Apr 2018 09:19:20 +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; bh=51iHejiYqx8ym5gHIYzEgQCqzG9f1gLTDpjypuePmP0=; b=vrjSADaIMvNllTOthigF7q08fxODp3nogWwPNdV6quE7/blKFR9sQQv0SX/dP7N6HgXJk3rdY1YMCrc1ubiKGwVXA9Nzw16f2Zm1YcnMC/N19caQn2mllcUYS9YDyR3DS4t/DDsylY/T6s+jOW3IDZufi96wdeQZUOjpbSoNaBE= 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_CBC_SHA384_P256) id 15.20.696.15; Thu, 26 Apr 2018 23:19:14 +0000 From: Petr Machata To: netdev@vger.kernel.org Subject: [PATCH net-next 2/7] selftests: forwarding: Add test for mirror to gretap In-Reply-To: References: Message-Id: Date: Fri, 27 Apr 2018 01:18:23 +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: HE1PR07CA0011.eurprd07.prod.outlook.com (2603:10a6:7:67::21) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB4191; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 3:A6oj2BuC5nzXHIFGIVaJs1a2CBmcAHSkwrMRoMt6B1lNtvcS7GxAI2ss+KyMdGyBWK/DlDetrz1ihmMBF1srAMv2ZETEK/I4p5va7XPYE46Fhdexb4RRTEUqcXuIAbY37Z2eF+b1V+E98gLjjjSWSQ+bjfW4UVZ4eH5rOjTMz5uWw+72Ip9UBUA2JVTo4ZLYRgYtEY7MdORF2bipvKFCSsdM55fn2qpe7BfpbOvNRy2d/GypMkHoq702r9ZDU7MY; 25:+lYc9ZCdANtizgwperkBbBWxuFlrFvBuWn3JxerdwBqGsNZfwpOHUPcyzivliPUu6dVwILQPuQTtR7uqQOJOSezRp/1ht0IVtBGWzdzGwe2ySS0Wnl2hWbWEMY+wy4/3MgsGh3A48xEJiG9me/b6NeTCLfEjpxOfMB+pLdE9cN3ZNHG8ByZUFSdoTdioFMHvZ144gJNtP7FaNHuxsd9FTeSAkjaIcTg6g8C0F1y+IS6iFsBeLDKpEdljaiotnVlg4rxtcZA8ioIOxJbqiZ4dDrKo4CKDSXxyiG76S7f4nYXUN5q/fhVQiOX1IFMo8JlFOzlKk9Fl9kAqWKYQoTvZ8w==; 31:95fyokIPw0HvId2koRnq4uFbNcXf8gDmVri8uKmgT21jAPE60O05iKXzMXDiTWOhKUWMTeWAZBF2V/rC/KLhY1mpMSnkpIng61JtjgzAqtDqKNa9HtMWUe3/c2fHSkT784LkKg9B+bmE/kmc17pq//8ghUJLbQM8ILyXpWU5+n807idN06dZjhl+qLD6k1sDtil7hCKLLYK8GKa3h1Jwrr/Zwwszh/8Q8bOWScnutvA= X-MS-TrafficTypeDiagnostic: VI1PR05MB4191: X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 20:jgLeTfc1CM1UJ9LSl5MGsaztE4A9KBmSJcZXnf9RCl7j96HJEr53RSA7DJBz8iInau5OmhqKSL4ho19YypVprzgQBGLBq1kv83jgy3Qj8Zb23dloIUYJwMHCp+CqmzRxOKfTT4A0MRq1zWW+MUsKO8O9eN6v8kn6DBYEaS5Foyr5HUx0kE5uaGiNpiqsWuKRa1yJNGw6hWsWy4rWEkZiGwxLlIWV+eReSuOwg9oHyKBYBlTLzLx2NpatAAq3Ifmf0ugflezna6f0XDbKT2yM/bgk6VkMc0vOj84XzOt4iyAdjW5J/Ic5TCeEfLQI5BrtocQAiVTFf6qroQoNYde/fz6ehOPedeUqcdKCovonrAUAZmm/vGdR3ozREathTfBNZjB5u4hbpPsCe7bh3hMN101hAwxv58DA0SFbluu32/Qc0Xd2feRn73KFEG/G0thNLzCU3qARwELcWnqMESHHQr5MVVydGUX0m/K1JI/yIc+efp8tgzPWpXTEOgSMcAXh; 4:ryv5EKOfv0R2Ae9T1DYVhj8C8C7cISWUeAsfpo5lPCwLepFR5O9ND0NY+qfGiZUTzfyjHF68HzLqKb3Bb6NG/85ZmSGJAQlehlEwOZtGMTnKq7b19I3BsPCXUy/23hqjS4chTdGG4P4UrCx2Y77+m3ghZBKJcWgiLLbm1MxX8N6gi0a6qRlhan9n/OpkAy0KRMzfktImsOosH03T3DsNSPq1yUxgd5HJ2eoaVqWczTWML2yvagrH260xx6IjtyBwHUo95KfOHFbFN/xINv0q8Q== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231232)(944501410)(52105095)(93006095)(93001095)(6055026)(6041310)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(6072148)(201708071742011); SRVR:VI1PR05MB4191; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4191; X-Forefront-PRVS: 0654257CF5 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(39860400002)(39380400002)(346002)(396003)(376002)(199004)(189003)(386003)(478600001)(6496006)(25786009)(4326008)(6116002)(2906002)(16526019)(2361001)(11346002)(7736002)(3846002)(956004)(446003)(2351001)(316002)(47776003)(16586007)(59450400001)(76176011)(36756003)(51416003)(52116002)(81156014)(8936002)(68736007)(81166006)(58126008)(8676002)(118296001)(26005)(97736004)(305945005)(6916009)(106356001)(2616005)(6486002)(476003)(53936002)(66066001)(5660300001)(105586002)(50466002)(486006)(86362001)(48376002)(186003)(6666003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4191; H:t540p; 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-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR05MB4191; 23:OmAw7z+tZbcBVqMdv2MpS7V5C14cDhS9N4HXp/FcM?= =?us-ascii?Q?hnL8IP3qU4ko/Q9ClXdzz584vojH/EXlBkb3sII3dWFBa9LHDPqeZ/XhIyNn?= =?us-ascii?Q?czFTLfH3nTm1s5WjRJu1Lxwaj/nBndplVkU2CfhOQ7U4aOr5V+lCQZtHjpx+?= =?us-ascii?Q?4ZpQYR+6FYKIZbDgohi1kolitf5qPQw7FuYpDkFYP/vmn/WabZOfbPRSOSxm?= =?us-ascii?Q?ORYsjeMntlnV5v+USrPGRq99x4c938qDoMVUymvcQ+dI8L1C7aqxW443Yhh7?= =?us-ascii?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SEJbpHQHZbxJk0xpXamEeziVaAjRWfY+WYCHO6UxDfCAbl7cpipNzkvs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 7:m5JsR2MJeYftLeZ0hW4hCeQnBa+5KBILAAYJaQOltbJKzALxhgHBQ7W1eHfI5lRqQubk8Ev2epolq5OHUXGSTmb/ILJlg7wE+YNJJYEbQ6zBpq8yqj9aOOIVzrfp2xKcehXr4RI+qklO768icKKtZ6s2BanEPM0ZEG9nJAlf8mA8pnhwURPHqbH6vszCfIgqNspzFGUVMiAxIdVuAlUrWWm+rhN38B6r2g7JE6uRnHcoDzUPvQRxcZCnwJTA6yCp X-MS-Office365-Filtering-Correlation-Id: ade25ab2-f00a-44bb-c98e-08d5abcc20dc X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2018 23:19:14.9249 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ade25ab2-f00a-44bb-c98e-08d5abcc20dc 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: , Cc: linux-mlxsw@lists.ozlabs.org, davem@davemloft.net Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org Sender: "Linux-mlxsw" X-Virus-Scanned: ClamAV using ClamSMTP Add a test for basic mirroring to gretap and ip6gretap netdevices. Signed-off-by: Petr Machata Reviewed-by: Jiri Pirko --- .../testing/selftests/net/forwarding/mirror_gre.sh | 139 +++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100755 tools/testing/selftests/net/forwarding/mirror_gre.sh diff --git a/tools/testing/selftests/net/forwarding/mirror_gre.sh b/tools/testing/selftests/net/forwarding/mirror_gre.sh new file mode 100755 index 0000000..a8abc73 --- /dev/null +++ b/tools/testing/selftests/net/forwarding/mirror_gre.sh @@ -0,0 +1,139 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# This test uses standard topology for testing gretap. See +# mirror_gre_topo_lib.sh for more details. +# +# Test for "tc action mirred egress mirror" when the device to mirror to is a +# gretap or ip6gretap netdevice. Expect that the packets come out encapsulated, +# and another gretap / ip6gretap netdevice is then capable of decapsulating the +# traffic. Test that the payload is what is expected (ICMP ping request or +# reply, depending on test). + +NUM_NETIFS=6 +source lib.sh +source mirror_lib.sh +source mirror_gre_lib.sh +source mirror_gre_topo_lib.sh + +setup_prepare() +{ + h1=${NETIFS[p1]} + swp1=${NETIFS[p2]} + + swp2=${NETIFS[p3]} + h2=${NETIFS[p4]} + + swp3=${NETIFS[p5]} + h3=${NETIFS[p6]} + + vrf_prepare + mirror_gre_topo_create + + ip address add dev $swp3 192.0.2.129/28 + ip address add dev $h3 192.0.2.130/28 + + ip address add dev $swp3 2001:db8:2::1/64 + ip address add dev $h3 2001:db8:2::2/64 +} + +cleanup() +{ + pre_cleanup + + ip address del dev $h3 2001:db8:2::2/64 + ip address del dev $swp3 2001:db8:2::1/64 + + ip address del dev $h3 192.0.2.130/28 + ip address del dev $swp3 192.0.2.129/28 + + mirror_gre_topo_destroy + vrf_cleanup +} + +test_span_gre_mac() +{ + local tundev=$1; shift + local direction=$1; shift + local prot=$1; shift + local what=$1; shift + + local swp3mac=$(mac_get $swp3) + local h3mac=$(mac_get $h3) + + RET=0 + + mirror_install $swp1 $direction $tundev "matchall $tcflags" + tc qdisc add dev $h3 clsact + tc filter add dev $h3 ingress pref 77 prot $prot \ + flower ip_proto 0x2f src_mac $swp3mac dst_mac $h3mac \ + action pass + + mirror_test v$h1 192.0.2.1 192.0.2.2 $h3 77 10 + + tc filter del dev $h3 ingress pref 77 + tc qdisc del dev $h3 clsact + mirror_uninstall $swp1 $direction + + log_test "$direction $what: envelope MAC ($tcflags)" +} + +test_two_spans() +{ + RET=0 + + mirror_install $swp1 ingress gt4 "matchall $tcflags" + mirror_install $swp1 egress gt6 "matchall $tcflags" + quick_test_span_gre_dir gt4 ingress + quick_test_span_gre_dir gt6 egress + + mirror_uninstall $swp1 ingress + fail_test_span_gre_dir gt4 ingress + quick_test_span_gre_dir gt6 egress + + mirror_install $swp1 ingress gt4 "matchall $tcflags" + mirror_uninstall $swp1 egress + quick_test_span_gre_dir gt4 ingress + fail_test_span_gre_dir gt6 egress + + mirror_uninstall $swp1 ingress + log_test "two simultaneously configured mirrors ($tcflags)" +} + +test_all() +{ + slow_path_trap_install $swp1 ingress + slow_path_trap_install $swp1 egress + + full_test_span_gre_dir gt4 ingress 8 0 "mirror to gretap" + full_test_span_gre_dir gt6 ingress 8 0 "mirror to ip6gretap" + full_test_span_gre_dir gt4 egress 0 8 "mirror to gretap" + full_test_span_gre_dir gt6 egress 0 8 "mirror to ip6gretap" + + test_span_gre_mac gt4 ingress ip "mirror to gretap" + test_span_gre_mac gt6 ingress ipv6 "mirror to ip6gretap" + test_span_gre_mac gt4 egress ip "mirror to gretap" + test_span_gre_mac gt6 egress ipv6 "mirror to ip6gretap" + + test_two_spans + + slow_path_trap_uninstall $swp1 egress + slow_path_trap_uninstall $swp1 ingress +} + +trap cleanup EXIT + +setup_prepare +setup_wait + +tcflags="skip_hw" +test_all + +if ! tc_offload_check; then + echo "WARN: Could not test offloaded functionality" +else + tcflags="skip_sw" + test_all +fi + +exit $EXIT_STATUS