From patchwork Fri Jul 27 19:10:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10547633 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 1170C112E for ; Fri, 27 Jul 2018 19:11:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F387C2C49A for ; Fri, 27 Jul 2018 19:11:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1CE62C404; Fri, 27 Jul 2018 19:11:07 +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 B81312C4AD for ; Fri, 27 Jul 2018 19:11:05 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41cdpw0m90zF12j for ; Sat, 28 Jul 2018 05:11:04 +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="BeCxOAdR"; 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=40.107.8.71; helo=eur04-vi1-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="BeCxOAdR"; dkim-atps=neutral Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80071.outbound.protection.outlook.com [40.107.8.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41cdpn3CwFzF0wy for ; Sat, 28 Jul 2018 05:10:57 +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:X-MS-Exchange-SenderADCheck; bh=EOj2pK6E3YNEPAYCcI+AmHf2FpSCMfFMRQy3kqbIRK4=; b=BeCxOAdRr7RPkq9ZVn8vv8dMzlwUAP+0SLN2gMis1CP/CDowouHYTfDvLmCV/aaLB8EFGpHzYFE/1PvSducNrmmGZGS0DA5FJiYXvYpL5m0U/8amFptoUkEu4QVissV7Nurc6ekWns53tFCX1pnuAd57hEOXj1W3l2GH5BSdm1Q= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) by DB7PR05MB4186.eurprd05.prod.outlook.com (2603:10a6:5:18::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.21; Fri, 27 Jul 2018 19:10:50 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw v3 10/10] selftests: mlxsw: Add test for trust-DSCP In-Reply-To: References: Message-Id: <004a2da52c5031aa49732e89778d1690035db905.1532716714.git.petrm@mellanox.com> Date: Fri, 27 Jul 2018 21:10:44 +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: HE1PR0301CA0015.eurprd03.prod.outlook.com (2603:10a6:3:76::25) To DB7PR05MB4186.eurprd05.prod.outlook.com (2603:10a6:5:18::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1685cf06-d619-41d6-72ca-08d5f3f4aaea X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4618075)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:DB7PR05MB4186; X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4186; 3:Z3coMKjKdSqXoIp0SIP+IAAGq5hmRMcjIQVIgnzQHTPdZtmzyKJBcM2hrplpcmTjjH+PD6GhI0t/28mquRxRydBcHc9uGVNenWckKkMCyBlzDtRVkox4swA5NBLjzsEPpP3o3SGgltojDDMUF0vsJ4uWbnY+z1pfBOSkJxfWpf6ZAF7YngfviD6OzI0UNQROo6rM9xKvDQNmGa3ER7XTIkQpJldSE/81eTc/WZ769Ajm+Icp7QXK5ed60+NZ8dB8; 25:fNGW7ABLyZz+5GGg98he5Ql4yoJ6V/IYqX8/eUKmHS2KCgUjwF4d3RqNDtoujX+3+Dc8SJWiSxl5KDb5nrdLW+56x4UbG5ZUU/f00UuFnH7Ivaft9q47LOTi5V3z6kIChwb1+5flnZL1AubsVe7bQocUTU3tvVaJBUzqUBlTdV7AiDt9eyHr2+EsRvMVuWj0EJBBxs43TnB+W1n7snR9ZjM0TCrcNEudw8ABbvNfAZIW8oHxLhYOyo31ZiOWs+icLltGH/ir3vulC9I+lXKvvJNY/v9ZFOp9/ki4I8qhsq+fEci+JoHkla3cpzT7Ybs0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rD1wG8pIGsy6cGnLyAtZUKoeQUSVV/qnILEXNaFSVy/zusiXy+wrSKfYtgJ1PLgRe4G+IzXRIJK+ppHovEV3qc3/vegRjdjgoQIw X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(190756311086443); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:DB7PR05MB4186; BCL:0; PCL:0; RULEID:; SRVR:DB7PR05MB4186; X-Forefront-PRVS: 07467C4D33 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(136003)(39860400002)(366004)(396003)(376002)(346002)(189003)(199004)(16586007)(76176011)(6496006)(36756003)(6486002)(53936002)(48376002)(478600001)(97736004)(2351001)(6666003)(50466002)(8936002)(81166006)(118296001)(8676002)(106356001)(81156014)(25786009)(6862004)(68736007)(6636002)(2616005)(486006)(476003)(956004)(3846002)(6116002)(446003)(7736002)(66066001)(305945005)(186003)(16526019)(47776003)(105586002)(2906002)(51416003)(26005)(5660300001)(11346002)(316002)(86362001)(575784001)(386003)(58126008)(37006003)(52116002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR05MB4186; 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; DB7PR05MB4186; 23:wOqxON9HDeRe/rksSirKeokJadjMlGSSKNGGLdOoH?= XcxU7aYzyIwOIHO6hpYsbWnr+eY2GGMwAy0xIsncZhQ23nP6mOB6fDQYTRJtWK3caVNpAjf/OqPtwIrvA60/f5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GPIiM4em10ofG7M=; 7:7rV4VBnfaumhin/xd3e/vSoZlEcoh4AfNA7M5bWQJhCuS5nGwGFFEzv3Yt7KLNRTvLxBoWAEhOOp2J9vNR/S7VLYucW2h/q/RynqC5PQ/FQMhtfy6fKl2yVykTIEm5jKWYU4GYoa03FFBD7be0dJUVci4aYdNjIF+QwqzL0XlSzqyyl91YPL79A1IIV0231xnvwMvXjLtfjFhQisGKLJrfzxHMM+y+ZEDefyrckqxM+E6pfwSg21VJzX6ilhLx9b SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2018 19:10:50.1135 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1685cf06-d619-41d6-72ca-08d5f3f4aaea X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR05MB4186 X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org X-Virus-Scanned: ClamAV using ClamSMTP Add a test that exercises the new code. Send DSCP-tagged packets, and observe how they are prioritized in the switch and the DSCP is updated on egress again. Signed-off-by: Petr Machata --- .../selftests/drivers/net/mlxsw/qos_dscp_bridge.sh | 189 +++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100755 tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh new file mode 100755 index 000000000000..d29d4582b13c --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh @@ -0,0 +1,189 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# Test for DSCP prioritization and rewrite. Packets ingress $swp1 with a DSCP +# tag and are prioritized according to the map at $swp1. They egress $swp2 and +# the DSCP value is updated to match the map at that interface. The updated DSCP +# tag is verified at $h2. +# +# ICMP responses are produced with the same DSCP tag that arrived at $h2. They +# go through prioritization at $swp2 and DSCP retagging at $swp1. The tag is +# verified at $h1--it should match the original tag. +# +# +----------------------+ +----------------------+ +# | H1 | | H2 | +# | + $h1 | | $h2 + | +# | | 192.0.2.1/28 | | 192.0.2.2/28 | | +# +----|-----------------+ +----------------|-----+ +# | | +# +----|----------------------------------------------------------------|-----+ +# | SW | | | +# | +-|----------------------------------------------------------------|-+ | +# | | + $swp1 BR $swp2 + | | +# | | APP=0,5,10 .. 7,5,17 APP=0,5,20 .. 7,5,27 | | +# | +--------------------------------------------------------------------+ | +# +---------------------------------------------------------------------------+ + +ALL_TESTS=" + ping_ipv4 + test_dscp +" + +lib_dir=$(dirname $0)/../../../net/forwarding + +NUM_NETIFS=4 +source $lib_dir/lib.sh + +h1_create() +{ + local dscp; + + simple_if_init $h1 192.0.2.1/28 + tc qdisc add dev $h1 clsact + dscp_capture_install $h1 10 +} + +h1_destroy() +{ + dscp_capture_uninstall $h1 10 + 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 + dscp_capture_install $h2 20 +} + +h2_destroy() +{ + dscp_capture_uninstall $h2 20 + tc qdisc del dev $h2 clsact + simple_if_fini $h2 192.0.2.2/28 +} + +dscp_map() +{ + local base=$1; shift + + for prio in {0..7}; do + echo app=$prio,5,$((base + prio)) + done +} + +switch_create() +{ + ip link add name br1 type bridge vlan_filtering 1 + ip link set dev br1 up + 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 + + lldptool -T -i $swp1 -V APP $(dscp_map 10) >/dev/null + lldptool -T -i $swp2 -V APP $(dscp_map 20) >/dev/null + lldpad_wait_set $swp1 + lldpad_wait_set $swp2 +} + +switch_destroy() +{ + lldptool -T -i $swp2 -V APP -d $(dscp_map 20) >/dev/null + lldptool -T -i $swp1 -V APP -d $(dscp_map 10) >/dev/null + lldpad_wait_del + + ip link set dev $swp2 nomaster + ip link set dev $swp1 nomaster + ip link del dev br1 +} + +setup_prepare() +{ + h1=${NETIFS[p1]} + swp1=${NETIFS[p2]} + + swp2=${NETIFS[p3]} + h2=${NETIFS[p4]} + + vrf_prepare + + h1_create + h2_create + switch_create +} + +cleanup() +{ + pre_cleanup + + switch_destroy + h2_destroy + h1_destroy + + vrf_cleanup +} + +ping_ipv4() +{ + ping_test $h1 192.0.2.2 +} + +dscp_ping_test() +{ + local vrf_name=$1; shift + local sip=$1; shift + local dip=$1; shift + local prio=$1; shift + local dev_10=$1; shift + local dev_20=$1; shift + + local dscp_10=$(((prio + 10) << 2)) + local dscp_20=$(((prio + 20) << 2)) + + RET=0 + + local -A t0s + eval "t0s=($(dscp_fetch_stats $dev_10 10) + $(dscp_fetch_stats $dev_20 20))" + + ip vrf exec $vrf_name \ + ${PING} -Q $dscp_10 ${sip:+-I $sip} $dip \ + -c 10 -i 0.1 -w 2 &> /dev/null + + local -A t1s + eval "t1s=($(dscp_fetch_stats $dev_10 10) + $(dscp_fetch_stats $dev_20 20))" + + for key in ${!t0s[@]}; do + local expect + if ((key == prio+10 || key == prio+20)); then + expect=10 + else + expect=0 + fi + + local delta=$((t1s[$key] - t0s[$key])) + ((expect == delta)) + check_err $? "DSCP $key: Expected to capture $expect packets, got $delta." + done + + log_test "DSCP rewrite: $dscp_10-(prio $prio)-$dscp_20" +} + +test_dscp() +{ + for prio in {0..7}; do + dscp_ping_test v$h1 192.0.2.1 192.0.2.2 $prio $h1 $h2 + done +} + +trap cleanup EXIT + +setup_prepare +setup_wait + +tests_run + +exit $EXIT_STATUS