From patchwork Thu Jul 5 19:09:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10510211 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 B044D600F5 for ; Thu, 5 Jul 2018 19:11:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C3362766D for ; Thu, 5 Jul 2018 19:11:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EF1C27853; Thu, 5 Jul 2018 19:11:23 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 DDE3B2766D for ; Thu, 5 Jul 2018 19:11:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754080AbeGETLV (ORCPT ); Thu, 5 Jul 2018 15:11:21 -0400 Received: from mail-eopbgr40087.outbound.protection.outlook.com ([40.107.4.87]:6575 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753927AbeGETLR (ORCPT ); Thu, 5 Jul 2018 15:11:17 -0400 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=Np0nG4+m+7py7voYOBkuWn+TcClitL6peA/JtJbN9Xk=; b=aI95uX+eVIF78GP830q1ri7keRxjuqB3QR8pHMsWMe3DT04O/VvMPc7zN9OA49dvrhPkXkmwG2OqYCobPMrts1/Rhll0t+ooLyKZxmd2JET85Rsi9D8SUqpkJ7PRCJJh8qDVbCUbuaD8e0HUJXY90YhOYhnEubhG2bNyKHGgi60= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) by VI1PR05MB4189.eurprd05.prod.outlook.com (2603:10a6:803:4e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.19; Thu, 5 Jul 2018 19:11:13 +0000 From: Petr Machata To: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: jiri@mellanox.com, idosch@mellanox.com, shuah@kernel.org, davem@davemloft.net Subject: [PATCH net-next 2/2] selftests: mlxsw: Add mlxsw-specific test for mirror to gretap In-Reply-To: Date: Thu, 05 Jul 2018 21:09:04 +0200 References: Message-Id: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [78.45.160.211] X-ClientProxiedBy: HE1PR06CA0153.eurprd06.prod.outlook.com (2603:10a6:7:16::40) To VI1PR05MB4189.eurprd05.prod.outlook.com (2603:10a6:803:4e::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e1ed5d37-7ad4-4896-f4c8-08d5e2ab13de X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB4189; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4189; 3:suxs0OhnOyXCNDEtKmlOIp06v6YWYKPvOXhntnK+UwNhDflT8TzP8yaJC7sDsnuiQa8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kBl3OCY6xCh5AxEe000hUst4dELKI0LSLgviy8UnUCpyttqFSLbcW8//yxzd5gT3M2yOTbGLXWfR6Lf+OnZl1XgnDNEiR6n4ZftgHujfp7jFdF1YwiDtgdC1WsGr7OXKQveo9hX78jTpdfDB9j6rOqdM4vY6hnaSCPnlo28CzH9NO7Exi/xwCy6vnKcdMRKxBgFVTOGn5nk1d3Q8bybCVGMZ9G5OXhnaHllel2zcQ2Josk45JwXhC0iO9hh/g8HenDodvK3LDFNOr9I7D6/BhGqwg; 4:/zrbPD/rQy/rOXuAkN0cr+6lcfJ7iFUsRYRds2zcIEJd5200nRqzBg7taWHy3J0OgXcUMDetVw8ndd66AlYeOYAUfmxWyK7q5KChHnhY/fp3Gs9P2QzebdY7Yq81Jw8AE85LsPHeJrZrglihQzM0LfZoES11Urgalh2ipYa4MpRhk3SC7ahR4WM5B7Pl/t+64UKrv0Meiu2jCvYph58owk4dl0ryWKcpxhbeeQ8m+dybLmc1WrJFIlZIV26vJbnVphUJ9KVK4VVxeC0851Pcrg== 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)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:VI1PR05MB4189; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4189; X-Forefront-PRVS: 0724FCD4CD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(39860400002)(136003)(396003)(346002)(376002)(189003)(199004)(53936002)(66066001)(6116002)(446003)(476003)(3846002)(5660300001)(2616005)(86362001)(11346002)(6666003)(47776003)(118296001)(26005)(8936002)(956004)(2906002)(186003)(486006)(68736007)(97736004)(16526019)(36756003)(50466002)(16586007)(386003)(4326008)(48376002)(81166006)(478600001)(81156014)(316002)(6486002)(106356001)(76176011)(51416003)(305945005)(52116002)(58126008)(7736002)(105586002)(6496006)(8676002)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4189; 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; VI1PR05MB4189; 23:g+oVXI8CVCXxJZqyMEIgHLcmfcaVRElOgE/Y+gvue?= =?us-ascii?Q?eE0nCturNgcXqJED9vFGpFYnfCfdw8xnTWg4WXXks0j3aUjtaBRgs9aJ1WP8?= =?us-ascii?Q?cEH+D0ComdE/N12QQQQqYzXpNHe395i3FbzMW4VgfNlQrhaSopf7m0biVJQF?= =?us-ascii?Q?boslYMtEaWZFzPGDqn/wG823gZeHA6ieTM6S3jt9gtDjLZP4XHLnnn6MxHQ6?= =?us-ascii?Q?7qX+FrKP+BpTw21RHsUfOqyx1egTTGr2kzvhQUvxQ/F+R0IrJu9uGNUJCTCi?= =?us-ascii?Q?lQ9/Gm2sUI/KwxdocQX4GzF6YJA3PP08qy3ErtcpAAh4QXJp17b+E6AEwG/w?= =?us-ascii?Q?LGIo1lR8otcBYvbQvWgRjBdAcvBdfj+QO9JHn5kkdCQPS442Y2RoIxVQt81r?= =?us-ascii?Q?PGk+jo8jfONJ3hnG0w/Nk82KkDUX/PeGhnGzuzEgPduYmntIiVze+3BL6Qo/?= =?us-ascii?Q?mdk41it76Vit6FxhgLrjGOVC9ynpJIDSlH5g5tEWW2RQAfHI3LYeXyLoZJGa?= =?us-ascii?Q?42z25Pb6OwRjNZHBisY2fjkOo7LfGogk/XAl/1WM5p1D2K5pcOWXCArBLKZK?= =?us-ascii?Q?q5gQOGPKLJ3KX5oGHCtHEb5onHUc8Fa0qjawumVRkcusr+e4AAURsTWc/9d8?= =?us-ascii?Q?I76q0b69GjysjzR6y05ZB7kg59V/XA3aonwqbk/N0oux0BzKL2oB/K2BkKxm?= =?us-ascii?Q?DJTkWKTzB3gUhJbP6/nSr6mfm1yOTa20deCNqfg+z0YOJhlvzYVRRITMkbBO?= =?us-ascii?Q?xId8OYmSuBBE0TJRZSxVLVsUbXQeU4qE9cpXRYHnBLO5HoYy5JhGJtG9y84r?= =?us-ascii?Q?7hpzTeFNMLvcQ2u/P1rqtkifTPoRnsBadnBG5VW3nmN+UVXbNYpGdHLWAvCO?= =?us-ascii?Q?QjulSrRE52AHvzqEX82nFdBc8t4N7qtuMbLvWaz+T2WdD6rKU/Uz5G9tpruC?= =?us-ascii?Q?JHjG85WmPspb+LIDZwNI9ld10PUdwJ3dxelVejO1NyBxm2akfS7RYgB6FLWd?= =?us-ascii?Q?O136roi22xMM+SDJJbE8a0oIMmTbLwOMer1KcoH0vYHS/iN3PklbxvtXqkhI?= =?us-ascii?Q?LCRlSj79vrhCsAxAIHs1meMG8rCdIa40IpltyMRltvNdwmgzpuUm6SRBIYN/?= =?us-ascii?Q?Ol5M/yuSy6UvJKJuZN6aOKzm9vhcjOW?= X-Microsoft-Antispam-Message-Info: UJn7Cj3QQaQ4kKCRA3tCo104+PEzYLnYWbOGhzdhkRSdc6fqDXABypIixHzyFLuNRq7UmeVc5Jocn7qdcPVpn3tjtZBPFhFvrKJ6UXroR7cuLL9hFBHCw3e6YPBr4ijO43R3x9H49xkXxJIE1uI/21xO9oHTboImjM290IGwSnHsq7LeRdhkJpii8f33emdfWSr12eIoME1vZhsL8urxFD5UCF/ltzViI+Imn+K9cqCAvQOJ0a216V/zTyaxqKlLFjP2c4Ug9wyVeAI34e8b6zHageAgtyFhbuVOQTGgoqa6bJniZouadnGZ4Zyo1LVdkzXiUZA6pkn+jv+mP4qciLPpt0j+M9QTSrxAS+cBTvk= X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4189; 6:qQBokCWnPgme0OWPcGDk3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atorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jul 2018 19:11:13.0007 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1ed5d37-7ad4-4896-f4c8-08d5e2ab13de X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4189 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 Test several aspects of offloading mirror to gretap and ip6gretap netdevices that are specific to mlxsw, such as requirements for TTL and TOS values. Signed-off-by: Petr Machata Reviewed-by: Jiri Pirko --- .../selftests/drivers/net/mlxsw/mirror_gre.sh | 217 +++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100755 tools/testing/selftests/drivers/net/mlxsw/mirror_gre.sh diff --git a/tools/testing/selftests/drivers/net/mlxsw/mirror_gre.sh b/tools/testing/selftests/drivers/net/mlxsw/mirror_gre.sh new file mode 100755 index 000000000000..76f1ab4898d9 --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/mirror_gre.sh @@ -0,0 +1,217 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# This test uses standard topology for testing gretap. See +# ../../../net/forwarding/mirror_gre_topo_lib.sh for more details. +# +# Test offloading various features of offloading gretap mirrors specific to +# mlxsw. + +lib_dir=$(dirname $0)/../../../net/forwarding + +NUM_NETIFS=6 +source $lib_dir/lib.sh +source $lib_dir/mirror_lib.sh +source $lib_dir/mirror_gre_lib.sh +source $lib_dir/mirror_gre_topo_lib.sh + +setup_keyful() +{ + tunnel_create gt6-key ip6gretap 2001:db8:3::1 2001:db8:3::2 \ + ttl 100 tos inherit allow-localremote \ + key 1234 + + tunnel_create h3-gt6-key ip6gretap 2001:db8:3::2 2001:db8:3::1 \ + key 1234 + ip link set h3-gt6-key vrf v$h3 + matchall_sink_create h3-gt6-key + + ip address add dev $swp3 2001:db8:3::1/64 + ip address add dev $h3 2001:db8:3::2/64 +} + +cleanup_keyful() +{ + ip address del dev $h3 2001:db8:3::2/64 + ip address del dev $swp3 2001:db8:3::1/64 + + tunnel_destroy h3-gt6-key + tunnel_destroy gt6-key +} + +setup_soft() +{ + # Set up a topology for testing underlay routes that point at an + # unsupported soft device. + + tunnel_create gt6-soft ip6gretap 2001:db8:4::1 2001:db8:4::2 \ + ttl 100 tos inherit allow-localremote + + tunnel_create h3-gt6-soft ip6gretap 2001:db8:4::2 2001:db8:4::1 + ip link set h3-gt6-soft vrf v$h3 + matchall_sink_create h3-gt6-soft + + ip link add name v1 type veth peer name v2 + ip link set dev v1 up + ip address add dev v1 2001:db8:4::1/64 + + ip link set dev v2 vrf v$h3 + ip link set dev v2 up + ip address add dev v2 2001:db8:4::2/64 +} + +cleanup_soft() +{ + ip link del dev v1 + + tunnel_destroy h3-gt6-soft + tunnel_destroy gt6-soft +} + +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 2001:db8:2::1/64 + ip address add dev $h3 2001:db8:2::2/64 + + ip address add dev $swp3 192.0.2.129/28 + ip address add dev $h3 192.0.2.130/28 + + setup_keyful + setup_soft +} + +cleanup() +{ + pre_cleanup + + cleanup_soft + cleanup_keyful + + 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_ttl_inherit() +{ + local tundev=$1; shift + local type=$1; shift + local what=$1; shift + + RET=0 + + ip link set dev $tundev type $type ttl inherit + mirror_install $swp1 ingress $tundev "matchall $tcflags" + fail_test_span_gre_dir $tundev ingress + + ip link set dev $tundev type $type ttl 100 + + quick_test_span_gre_dir $tundev ingress + mirror_uninstall $swp1 ingress + + log_test "$what: no offload on TTL of inherit ($tcflags)" +} + +test_span_gre_tos_fixed() +{ + local tundev=$1; shift + local type=$1; shift + local what=$1; shift + + RET=0 + + ip link set dev $tundev type $type tos 0x10 + mirror_install $swp1 ingress $tundev "matchall $tcflags" + fail_test_span_gre_dir $tundev ingress + + ip link set dev $tundev type $type tos inherit + quick_test_span_gre_dir $tundev ingress + mirror_uninstall $swp1 ingress + + log_test "$what: no offload on a fixed TOS ($tcflags)" +} + +test_span_failable() +{ + local should_fail=$1; shift + local tundev=$1; shift + local what=$1; shift + + RET=0 + + mirror_install $swp1 ingress $tundev "matchall $tcflags" + if ((should_fail)); then + fail_test_span_gre_dir $tundev ingress + else + quick_test_span_gre_dir $tundev ingress + fi + mirror_uninstall $swp1 ingress + + log_test "$what: should_fail=$should_fail ($tcflags)" +} + +test_failable() +{ + local should_fail=$1; shift + + test_span_failable $should_fail gt6-key "mirror to keyful gretap" + test_span_failable $should_fail gt6-soft "mirror to gretap w/ soft underlay" +} + +test_sw() +{ + slow_path_trap_install $swp1 ingress + slow_path_trap_install $swp1 egress + + test_failable 0 + + slow_path_trap_uninstall $swp1 egress + slow_path_trap_uninstall $swp1 ingress +} + +test_hw() +{ + test_failable 1 + + test_span_gre_tos_fixed gt4 gretap "mirror to gretap" + test_span_gre_tos_fixed gt6 ip6gretap "mirror to ip6gretap" + + test_span_gre_ttl_inherit gt4 gretap "mirror to gretap" + test_span_gre_ttl_inherit gt6 ip6gretap "mirror to ip6gretap" +} + +trap cleanup EXIT + +setup_prepare +setup_wait + +if ! tc_offload_check; then + check_err 1 "Could not test offloaded functionality" + log_test "mlxsw-specific tests for mirror to gretap" + exit +fi + +tcflags="skip_hw" +test_sw + +tcflags="skip_sw" +test_hw + +exit $EXIT_STATUS