From patchwork Thu May 24 14:27:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10424899 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 B02B760327 for ; Thu, 24 May 2018 14:28:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4D0628987 for ; Thu, 24 May 2018 14:28:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7EB42943C; Thu, 24 May 2018 14:28:10 +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 EBB2728987 for ; Thu, 24 May 2018 14:28:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033307AbeEXO2F (ORCPT ); Thu, 24 May 2018 10:28:05 -0400 Received: from mail-ve1eur01on0051.outbound.protection.outlook.com ([104.47.1.51]:63552 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1031005AbeEXO2E (ORCPT ); Thu, 24 May 2018 10:28:04 -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=RO5K2S6qHnONviQd0ZHtuCqu1zgsWyBCBDQ4tNgDd/c=; b=VuP8dcmhLHEEBXohszLgIVmXkrJbWTFMPwv2Ee5W4Etumwn6iBxlJWHOy3zoZR4G3lufOZU464ILgP2rJcq2ScYNrPImMNgV2xr8cVpluR5EFBPZQnF18jfCZ7hC6+1ZuYDdiXOulRP/vRkaODoEqwktPjlvKprBEz8nZi5rT98= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) 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.797.11; Thu, 24 May 2018 14:27:59 +0000 From: Petr Machata To: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: davem@davemloft.net, shuah@kernel.org, idosch@mellanox.com, jiri@mellanox.com Subject: [PATCH net-next 08/10] selftests: forwarding: Test mirror-to-gre w/ UL VLAN+802.1q In-Reply-To: References: Message-Id: <0d431918534794d3ebadb15c3938808808b0bc45.1527171860.git.petrm@mellanox.com> Date: Thu, 24 May 2018 16:27:55 +0200 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: LO2P265CA0034.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:61::22) 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)(5600026)(48565401081)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB4191; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 3:w/XBrhUOKDFBz4UBLqx5v9FPpXPCTo6YYhM3Yglo2SBq3CN/ZuVoIpT9MPa3qbg3tTfXI78IahAFr5BZjO2kGMdq0N47OXqiafd16Yfr+XQtWduaQS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IbysSOMBKPayfbBE7Avvv4hIDCoEkg8IsVRfu7BDnSjNVGIRvw7xbr8zLrUwQhrC987CgChARtFZYwTzR6ADdj4pvS4/qPkr50aquJ7Hxv9opKBl68I2SyKRfyvsFrFds3+VaFbjHPdCJUNTUknH76gnRtl8hvyWl3sw2oAI+6ypxOpYsUdVXYS8vlN1+Iy32uyBOfdfU9eDjjcyOWzQ6ILwn+Xhh0WfCN; 4:35OZlQ4QFDBteMflht8GBfuOrkKAM5PcfFkVRMcGblMH40dTdivgy9R02V3LGpYt39j+4clt6EGLCaPjuTNdpyNld8kx86DSdeLGmrByaTauDf1ushLURGWJyj3EsE6MMuh3ubRVvuMb4EnUwq1o98cI0rHuAel1vTiY5JwTZsab9gET2W+sF8pzjwp+hANkSbv29gvib0mcQ9M6ZIbimB1+rQ0a2znue/jh6jsn1poYyq16ybheqWfRlb3DEA34dysyFHKpzOEhI9coMm9srA== 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)(3002001)(10201501046)(3231254)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:VI1PR05MB4191; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4191; X-Forefront-PRVS: 0682FC00E8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(376002)(39860400002)(346002)(366004)(396003)(199004)(189003)(478600001)(86362001)(2616005)(476003)(36756003)(956004)(11346002)(8676002)(118296001)(6486002)(81156014)(81166006)(8936002)(58126008)(16526019)(4326008)(107886003)(486006)(446003)(53936002)(386003)(6666003)(52116002)(51416003)(26005)(105586002)(16586007)(316002)(106356001)(97736004)(305945005)(25786009)(2906002)(7736002)(6116002)(3846002)(5660300001)(48376002)(68736007)(47776003)(50466002)(66066001)(6496006)(76176011); 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:AE36AgW7cz4bn6F8XPoO1kB3S0UH3JhSr6EvDuQ3A?= =?us-ascii?Q?8eS5zwUR5N8Q9WcW5iKLPUtQ98Pv1UOBiRgiNr3ZuPo3vDqerTAzi8HPltbT?= =?us-ascii?Q?Pw9QDaw9iVA9ocYsuAgeUiApniqVaaCnwtSiLmJDuPdbSl0DI86jTWrRMSZi?= =?us-ascii?Q?SSeqFqElTbkcy6bfiYx9kcrKEQA+7StzxjxAKXVb17hCZWa5gOk1kzS54HEB?= =?us-ascii?Q?3228//XYYQozdoNuUy0sdU62ZzrjoT3hC0fKBgrafycqDDtI+5SbZylic6G5?= =?us-ascii?Q?gscjKnZZCCCITewX7Zf9UbPs5UOSoOEOMCK5jxGNsX2fdBMA89DaK5AyztAd?= =?us-ascii?Q?jslT+OF0CB0EQYCB9n7qqlYJX66XC7w8oY1yXy3vtY5k7mx+Xj5P5al94lKC?= =?us-ascii?Q?UgLRLQXLzrmsoLQuKaYBvwLDRjAZ8vSctFptXekRQ5eQ7AgYcu6nuZI86s3z?= =?us-ascii?Q?rEN15g0yznbPY/q4v2XIc9+3NTTexMBJrkaWuevPY6BiYCn6zsFZa/PJmCHD?= =?us-ascii?Q?i6lQZC1V5eU9T+jpe5IuE5YbuN+9HY589x5PFqnjADnh3I44kING3XauEB6S?= =?us-ascii?Q?M7en7DNeYP7Butnq9uCBYA9uyBN2RYryRqdXMQMx5lcFcNbeaNq+z6T8hUwZ?= =?us-ascii?Q?JtaaTbRSQd1XnNHk6qNgw2PqsTutmIFX7AX44PrfSzDjNh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VIOxbIJ8v6Il9KsP47rt/+tx9l2AEaFtDbgmwlv+10QeS2go5NLais5ypPL1BsKKYNmEU5bhN3wS4PI/1weoqaOsruXoCsczjwa3+d2vZ7ZdVHJ7E34VUv3rsRnkqPT/NiWbl2tcDLih3SF+oKd3p439jvHnnO5WjIBE/W6nbW6v6wGrD185WuXDLtdD8Cskl9PzRpeJt748jE/i7oYxuTsOjHYFB0pj1lx6cU/A638zmePLeQL8SltzkUuM6ZY4A==; 5:oZAmaA0vuwbPV3ttprzNR80mSdC9CvPyc73RHA1PZTxDsZoxOsp1QiP+RABlOCCUSpxFuirHwVjWxg9PIBHtGVbC7nO0Ish7CcXMXrKx6zCPA+d03hSrmZLfUgUE4ilmhNGWsl4zON52vG75cepIJSVg2mXhECQGYIQqZt0+Bck=; 24:EWEMhV8oIb3WjaE8dz5sbnY7xS7QCcJNsIV9wGw0opOjZnnc995cX1J74bxB6Aztc7vSt+nzMH43s3O1f+bdFphp/I+bzR7wtin4TYudtMw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 7:qtgLoLNcvZjCzgw/qO9e0sac//DppGxPc78StzBko9Lq9UoLXzVaxRwXeD5hP1gS15EpFG7apeLLDlolW3biJtbELCMCEoztsOItrGqOVuHmEUxZdqdQtPT6hhPCDNTEfPjv6IKfeluXSQszAGXCoa5uYksH2T1r59Hhhg63o/LKhIGMvuWkiazlwd30uPi8RNOyNkmt6+2PAkh3EN9KKU7Z7nWnk04V3SKKKD0BRbSd3utVChh9YUiq7FgY8cWU X-MS-Office365-Filtering-Correlation-Id: 6db988a8-b6f6-4989-b2fd-08d5c1828d3b X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2018 14:27:59.6889 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6db988a8-b6f6-4989-b2fd-08d5c1828d3b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4191 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 for "tc action mirred egress mirror" that mirrors to GRE when the underlay route points at a vlan device on top of a bridge device with vlan filtering (802.1q). Signed-off-by: Petr Machata --- .../net/forwarding/mirror_gre_vlan_bridge_1q.sh | 140 +++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100755 tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh diff --git a/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh b/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh new file mode 100755 index 0000000..01ec28a --- /dev/null +++ b/tools/testing/selftests/net/forwarding/mirror_gre_vlan_bridge_1q.sh @@ -0,0 +1,140 @@ +#!/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 underlay route points at a +# vlan device on top of a bridge device with vlan filtering (802.1q). + +ALL_TESTS=" + test_gretap + test_ip6gretap + test_gretap_forbidden + test_ip6gretap_forbidden +" + +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 + + vlan_create br1 555 "" 192.0.2.129/32 2001:db8:2::1/128 + bridge vlan add dev br1 vid 555 self + ip route rep 192.0.2.130/32 dev br1.555 + ip -6 route rep 2001:db8:2::2/128 dev br1.555 + + vlan_create $h3 555 v$h3 192.0.2.130/28 2001:db8:2::2/64 + + ip link set dev $swp3 master br1 + bridge vlan add dev $swp3 vid 555 +} + +cleanup() +{ + pre_cleanup + + ip link set dev $swp3 nomaster + vlan_destroy $h3 555 + vlan_destroy br1 555 + + mirror_gre_topo_destroy + vrf_cleanup +} + +test_vlan_match() +{ + local tundev=$1; shift + local vlan_match=$1; shift + local what=$1; shift + + full_test_span_gre_dir_vlan $tundev ingress "$vlan_match" 8 0 "$what" + full_test_span_gre_dir_vlan $tundev egress "$vlan_match" 0 8 "$what" +} + +test_gretap() +{ + test_vlan_match gt4 'vlan_id 555 vlan_ethtype ip' "mirror to gretap" +} + +test_ip6gretap() +{ + test_vlan_match gt6 'vlan_id 555 vlan_ethtype ipv6' "mirror to ip6gretap" +} + +test_span_gre_forbidden() +{ + local tundev=$1; shift + local what=$1; shift + + RET=0 + + # Run the pass-test first, to prime neighbor table. + mirror_install $swp1 ingress $tundev "matchall $tcflags" + quick_test_span_gre_dir $tundev ingress + + # Now forbid the VLAN at the bridge and see it fail. + bridge vlan del dev br1 vid 555 self + sleep 1 + + fail_test_span_gre_dir $tundev ingress + mirror_uninstall $swp1 ingress + + bridge vlan add dev br1 vid 555 self + sleep 1 + + log_test "$what: vlan forbidden at a bridge ($tcflags)" +} + +test_gretap_forbidden() +{ + test_span_gre_forbidden gt4 "mirror to gretap" +} + +test_ip6gretap_forbidden() +{ + test_span_gre_forbidden gt4 "mirror to ip6gretap" +} + +test_all() +{ + slow_path_trap_install $swp1 ingress + slow_path_trap_install $swp1 egress + + tests_run + + 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