From patchwork Sat Jun 30 00:49:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10497783 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 C550B60327 for ; Sat, 30 Jun 2018 00:50:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A43F528B30 for ; Sat, 30 Jun 2018 00:50:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95749295B0; Sat, 30 Jun 2018 00:50:32 +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 06CE728B30 for ; Sat, 30 Jun 2018 00:50:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935280AbeF3Aub (ORCPT ); Fri, 29 Jun 2018 20:50:31 -0400 Received: from mail-db5eur01on0055.outbound.protection.outlook.com ([104.47.2.55]:16736 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933750AbeF3Aua (ORCPT ); Fri, 29 Jun 2018 20:50:30 -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=IJYzDi/5jlIQT3KRsJBFAU6aS48BqGCTLPncbYLygdI=; b=G/wRxSqBDQOU2V3JbOrsGRd57E5rWCQRAo5bNccBVhwFTv9QCnd8JSnUQDkpzsTkHXlvRvxgWCQnyG/tr0u0FsSZhJqJ1mNtJHkX89i98V57iQPXJZ40aAPLKwHafVnXqKHVAoFBUqrsSFSzzuXnqXW+u2qqAw0aKIoKIcO3om0= 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_GCM_SHA384) id 15.20.906.25; Sat, 30 Jun 2018 00:50:26 +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 07/13] selftests: mlxsw: Add router test In-Reply-To: References: Message-Id: <61c5407aa07f12b79d5f66cadd5cb2a031a841c7.1530319109.git.petrm@mellanox.com> Date: Sat, 30 Jun 2018 02:49:32 +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: HE1PR09CA0057.eurprd09.prod.outlook.com (2603:10a6:7:3c::25) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a87ae2d0-4a88-4f27-60bf-08d5de2378b1 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(48565401081)(5600052)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB4191; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 3:8p5evJ552jHmazKuG9bHMXs+7wKR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NBEaGn9J5thjUeDWfpwENvBwVQ5zQAiNJ7MxWmIRjIQkjn2KEpH+GHBvNRsWn2F7A9GkWBGZA/he8kJWCRRuOb0EPXel608d6L6+3JADX2DOWwCbVo/qGFIKBoLRI88XW6uHgQwhi8smpWq+5INp2rceovUr+AHzP7kp5J7a9jeUP7yNuzwBG7uvQX1qSxJnrkUvQxKyaBaUglX5mQzU5Bzrb06iTt0EZPpoCjY7BQiOuwzhHPcSQ9a9r5t4l6zH/oY0cWQujVPNYMRSlT1MDeKZLlkRKbNEgH9w4W4l631Tz+vxldeU2CHmFZiMiq4husn; 4:kpOMo05axe7GdhLL0xWMSpQQUhDhYPWyTQc1eDtkdcM9mDe0dZp6EMLb90jzasIuRxgbIbTNAW7T3CGXEPcSWWk56mBmilnU0lPu7XIo6rVFjmSFf3nk8Jzz00NspAgVwwdPcPHNxfdRBXFZ6f+fTJQDleejvCFzyUQojjTZOBXFsKWDtLBneaXfbYCgD8FQ0x7iThVpyQNxkj70j7wR8RGoQFEmW/mLqBWGk/Fk6q6lsRuqyOg5TkQ3Gy6kAubmeOzw0UieTBt8ptRaMNP6uA== 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)(3231254)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:VI1PR05MB4191; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4191; X-Forefront-PRVS: 0719EC6A9A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(346002)(366004)(39860400002)(396003)(136003)(189003)(199004)(86362001)(478600001)(476003)(486006)(68736007)(956004)(2616005)(6116002)(6496006)(2906002)(66066001)(52116002)(3846002)(47776003)(76176011)(53936002)(5660300001)(4326008)(14444005)(446003)(11346002)(51416003)(6486002)(36756003)(48376002)(118296001)(386003)(50466002)(16526019)(105586002)(186003)(26005)(106356001)(97736004)(25786009)(8936002)(316002)(6666003)(81166006)(7736002)(16586007)(8676002)(305945005)(58126008)(81156014)(473944003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4191; 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; VI1PR05MB4191; 23:Y4nLQZADG/CMeL8Szm/iAaEHU2NlY5FzwsjHcgFcG?= =?us-ascii?Q?sraaHrnyACZXi+R7c2OiGyUK9sgJ84TNtMm2Q9CAqxt7joWjXmkWypIXPB0n?= =?us-ascii?Q?XyuOiE6IRP38fndtwmNCH+KYyy/uDI6+iApUqIEwCDLNyZ0QZ5ZolEvHuoL1?= =?us-ascii?Q?iOE710rNS/xJcyfsN0V26uj0NpxL+zu57AZz6nqhS1ms2C0ATH0vA/jdnznj?= =?us-ascii?Q?0SDmUa/GRdzL6jlrNE4Itd35sba0fjeaZpWhDoB68VtD/cMHEBbYS3TkDjvO?= =?us-ascii?Q?9MqO+oCEO0AKM/Qi26ni4+Bvq91DWtUmo7oTb/P2ndka4rxjiIHx7iP4z6fS?= =?us-ascii?Q?0dCuiyTMHhU5LdZfvxXCJCNy6ozPnWaqt2++v1Kv0avFP7RSiCWW/J/t5d+8?= =?us-ascii?Q?pd7raoosrVBu4eMGhxVQmtwQXujzarIJ0x/4f93jmLUockdVOXaqv+4EdE7B?= =?us-ascii?Q?948LRi/uRiLKpA3oFPzItnI9saEKxkGplzs+JEeSBOjU1CXKMz6DZfoAENRm?= =?us-ascii?Q?wfrj3Ve8Vh7FbBa/F14iFIcyoNnImXqxNgkjos6FyMR72cqn1RA2Gm+u4KJj?= =?us-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J8dth+LAMV1WZc+cGyWYqrqZP18jndlNF55hFbx88l5010StjiqbLH0S0rzyEMvGI= X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 6:lFrOQskLP9ZPPJi/FtRxMdHKjbdrgAfK6qzccMp0Tfg0N6cgXhzdgjDiz0sBHX8m36EBJ21LBKZ2VGAqpbD0Nw1vM4wCVpth8yN34tu68PrO7ZGi1Dm4VYZacFflcb/BcyLhZuvuhgog9NVxS2qI0zeDiyYrq3wL2w2kp/krLSSjFptbgENwq3ENauSF2dDCzJBBsr7/pBTymQOl0mO9s7/JQvQc7cqldBNvAzCkxfyq21qmu+UR211IcqHJ1fPre+GZv2zpTzHYYXAMCv0tew27UCgHcV7DuO5PfhZ72z1b7h64TPMb7Xbo/FDc2Ldszyp/eSsFywT64jLBpl1vQU9EKuQA460zXEVwPeGca1h/91G9bE+x9s5Q8kmWtf4jFsbZzsP6/VoN1H4i9L2eBviFoMkMhEJEExKh/n06WebyzEdvsIhNUWnxc9kfhkUyAG/3+AdGR6nKikEEVkJTEw==; 5:arx9Q+F3grrjRUqV4NMZKX/6RJcU0kjcF4VItlUnN2qoukwP4ZZwK2RWErkU+PPRYzNzOeF3JNdI+KPAYOFTkP3TojBs3j+2l2suPOtwHkB/qA/BTjmVNeI+aKmbQtnbiwEXI2ndx81b1MJMotfbBH3B5Uwk2RQHySh5C0UiHBE=; 24:p+RFrHP03lDTWzFSfX/Z+eTO+mlKfN+FR042+tGPCtT4qZZ4qotnFFcwNuWUub4sSJ4LvqUk3i52XetCLfuwpd4oLb6tJXMyTj2sc6TsyFk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 7:+aI5dd1dvv1eUEwS87tZgGslT3gWM6LHYKp6kKoHidxK5ePsHvb4FdmpKxDKP8+vSzV86xPQa4j+dt9rMyFugNkQZoCFSKwU5B7qQyijtO12xX5l16uRiEXLK9cZVMzXnBQfBr9FY/6IQt8LbHDZaPMcpWcOSTn8VNKRPyQCzmN21FbKEo8rCQ77+DtHHPkJYNltqhC0BHZIiLGWQKaDKxI+1tTRdToiNOJS7yCeLE/Y77qorYL6R7GXMGnDMYps X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2018 00:50:26.1917 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a87ae2d0-4a88-4f27-60bf-08d5de2378b1 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 From: Arkadi Sharshevsky This test aims for both stand alone and internal usage by the resource infra. The test receives the number routes to offload and checks: - The routes were offloaded correctly - Traffic for each route. Signed-off-by: Arkadi Sharshevsky Signed-off-by: Yuval Mintz Reviewed-by: Petr Machata Signed-off-by: Petr Machata --- .../selftests/drivers/net/mlxsw/router_scale.sh | 167 +++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 tools/testing/selftests/drivers/net/mlxsw/router_scale.sh diff --git a/tools/testing/selftests/drivers/net/mlxsw/router_scale.sh b/tools/testing/selftests/drivers/net/mlxsw/router_scale.sh new file mode 100644 index 000000000000..d231649b4f01 --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/router_scale.sh @@ -0,0 +1,167 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +ROUTER_NUM_NETIFS=4 + +router_h1_create() +{ + simple_if_init $h1 192.0.1.1/24 + ip route add 193.0.0.0/8 via 192.0.1.2 dev $h1 +} + +router_h1_destroy() +{ + ip route del 193.0.0.0/8 via 192.0.1.2 dev $h1 + simple_if_fini $h1 192.0.1.1/24 +} + +router_h2_create() +{ + simple_if_init $h2 192.0.2.1/24 + tc qdisc add dev $h2 handle ffff: ingress +} + +router_h2_destroy() +{ + tc qdisc del dev $h2 handle ffff: ingress + simple_if_fini $h2 192.0.2.1/24 +} + +router_create() +{ + ip link set dev $rp1 up + ip link set dev $rp2 up + + ip address add 192.0.1.2/24 dev $rp1 + ip address add 192.0.2.2/24 dev $rp2 +} + +router_destroy() +{ + ip address del 192.0.2.2/24 dev $rp2 + ip address del 192.0.1.2/24 dev $rp1 + + ip link set dev $rp2 down + ip link set dev $rp1 down +} + +router_setup_prepare() +{ + h1=${NETIFS[p1]} + rp1=${NETIFS[p2]} + + rp2=${NETIFS[p3]} + h2=${NETIFS[p4]} + + h1mac=$(mac_get $h1) + rp1mac=$(mac_get $rp1) + + vrf_prepare + + router_h1_create + router_h2_create + + router_create +} + +router_offload_validate() +{ + local route_count=$1 + local offloaded_count + + offloaded_count=$(ip route | grep -o 'offload' | wc -l) + [[ $offloaded_count -ge $route_count ]] +} + +router_routes_create() +{ + local route_count=$1 + local count=0 + + ROUTE_FILE="$(mktemp)" + + for i in {0..255} + do + for j in {0..255} + do + for k in {0..255} + do + if [[ $count -eq $route_count ]]; then + break 3 + fi + + echo route add 193.${i}.${j}.${k}/32 via \ + 192.0.2.1 dev $rp2 >> $ROUTE_FILE + ((count++)) + done + done + done + + ip -b $ROUTE_FILE &> /dev/null +} + +router_routes_destroy() +{ + if [[ -v ROUTE_FILE ]]; then + rm -f $ROUTE_FILE + fi +} + +router_test() +{ + local route_count=$1 + local should_fail=$2 + local count=0 + + RET=0 + + router_routes_create $route_count + + router_offload_validate $route_count + check_err_fail $should_fail $? "Offload of $route_count routes" + if [[ $RET -ne 0 ]] || [[ $should_fail -eq 1 ]]; then + return + fi + + tc filter add dev $h2 ingress protocol ip pref 1 flower \ + skip_sw dst_ip 193.0.0.0/8 action drop + + for i in {0..255} + do + for j in {0..255} + do + for k in {0..255} + do + if [[ $count -eq $route_count ]]; then + break 3 + fi + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $rp1mac \ + -A 192.0.1.1 -B 193.${i}.${j}.${k} \ + -t ip -q + ((count++)) + done + done + done + + tc_check_packets "dev $h2 ingress" 1 $route_count + check_err $? "Offload mismatch" + + tc filter del dev $h2 ingress protocol ip pref 1 flower \ + skip_sw dst_ip 193.0.0.0/8 action drop + + router_routes_destroy +} + +router_cleanup() +{ + pre_cleanup + + router_routes_destroy + router_destroy + + router_h2_destroy + router_h1_destroy + + vrf_cleanup +}