From patchwork Thu May 24 14:27:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10424891 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 F05EC6019D for ; Thu, 24 May 2018 14:27:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0193B28987 for ; Thu, 24 May 2018 14:27:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA812295D9; Thu, 24 May 2018 14:27:42 +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 5BF6928987 for ; Thu, 24 May 2018 14:27:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033277AbeEXO1h (ORCPT ); Thu, 24 May 2018 10:27:37 -0400 Received: from mail-ve1eur01on0057.outbound.protection.outlook.com ([104.47.1.57]:1868 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1033285AbeEXO1d (ORCPT ); Thu, 24 May 2018 10:27:33 -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=cYd35k1Di6pQprigPgdq3BA3lxudFloIMd8G30RRG1o=; b=yOpeF70+xDzGy5cluXyEXsP/b33nOBCWj1c2XbV8ucXvOXbUxY6ss7tJP8uWqQ3aGcYjLMCqnsTN3eUt+tu1rK4QQqkqpfK/4n0Z9+Lb04BUNLcbPxOasK0p1BqURas+KbZIX1Mx3P5PHRSh3uSUrh4INPrCGBf231ilE8RqW38= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) by DB7PR05MB4188.eurprd05.prod.outlook.com (2603:10a6:5:18::29) 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:30 +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 04/10] selftests: forwarding: lib: Support VLAN devices In-Reply-To: References: Message-Id: <8f2315290ed342c054168a424962219b151a990c.1527171860.git.petrm@mellanox.com> Date: Thu, 24 May 2018 16:27:26 +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: LO2P265CA0149.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::17) To DB7PR05MB4188.eurprd05.prod.outlook.com (2603:10a6:5:18::29) 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:DB7PR05MB4188; X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4188; 3:LeznbBORt+JwASNWgiJfeOEJUsu5FyglcgEBi59RW7fEidEPEAP8Iy+F18pcrDvmVrjOnepY0/WxDkE4kedSyBzlrpJCKCEfr/gnBr4Pj1uLXgjzjb8P6nTvekDt2KLKrsrLkgw5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QBCgTGZT/ddU3EXVVtai7GFd7BRS3Tq9oiRIS+bqJctSHfjocKCrHO7tsBkIaNy8ll0bI1pDPxIWKfV17Wcp30mmFgYuyAuCt3dHjsAR0iKM9sa+b0UnU7hTmvPDfhUG3Af+FmTzh6W6XBpGF0mvVDZHyF5wxJbevNqAbeAxbBgTAsmUWJVEC91KSl0ZH0PVUygsiGsyG//ntHBX/EJFaZhKv2q3Fz7K; 4:WB2TFRR/QCowNijpR/sRSUUFdt1QAMQs7aFZMEdXaa2NUgutVJPf5UFHG00NRCdM1JHf3iJ9n1rsZ1z+762ujSMFc0iJzjBFkNfRW7GjKT0s8U7Iz1zwPbBHmnACwj5/TMLAcTJtqR6FAWQLiSs4/8xiLD2zhH2d/WfREocbWQIhxiAp4eRLAHo5doo/yezkvFgLuZBfEYP72DLcg9TEYwhlN+ckLavvS0fV0z8dH8ql9q2zg8hOrDOaeG42lbuoyizehhM8qftcFg9G6HoF/g== 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)(10201501046)(3002001)(93006095)(93001095)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123564045)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:DB7PR05MB4188; BCL:0; PCL:0; RULEID:; SRVR:DB7PR05MB4188; X-Forefront-PRVS: 0682FC00E8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(39860400002)(366004)(396003)(346002)(376002)(199004)(189003)(6666003)(386003)(97736004)(86362001)(4326008)(6496006)(47776003)(6486002)(2906002)(36756003)(26005)(76176011)(5660300001)(51416003)(52116002)(478600001)(107886003)(3846002)(6116002)(16526019)(25786009)(2616005)(956004)(476003)(58126008)(486006)(316002)(53936002)(16586007)(8936002)(68736007)(446003)(66066001)(11346002)(8676002)(48376002)(118296001)(81166006)(50466002)(81156014)(105586002)(106356001)(7736002)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR05MB4188; 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; DB7PR05MB4188; 23:gu8+4N3mOapQglmlTw+Wvob/2utfgp/SlE9701uU1?= =?us-ascii?Q?1HI47/N5S3MI2u2covpsw01mcpBEZYLjkWyqLFQDmbpizskw3bwaKWWXO1nc?= =?us-ascii?Q?MyKKaqEWaiiulA6Hiuf/H32JPLb5ue2JIPQlhcP9xLj0X4jDBSc5aBiQlqGc?= =?us-ascii?Q?dAnzBNERH0gpyy6HZ+bUB3u7l+ujVMTVAjLt745LiWiVo56F6xseJNoxUcQv?= =?us-ascii?Q?6hfEo6/xo64bhXZ6XRDm0KktI5ql+TnL3Q/EwGv3fGjBddAmevequieyswTJ?= =?us-ascii?Q?kE2xf1tRkVlzTvGFsje576weX4EomRR/OE8XLicUX/MDbvsDMxQaxR3B8+a8?= =?us-ascii?Q?pEe/O1GrLsrxUKfUmhOJgBzWx/Q4+Pgr/vhdJ/gn1rWBxTAjuEAGS1v1+odO?= =?us-ascii?Q?nz5jmpbDjI2qFkr3Hjt5XAUxmQrPHuEYySRrcmtQbUDU20s2LywMWmr37+3u?= =?us-ascii?Q?pMc8oRqJfWdqc1wUk/zlNNLfu0OMViIPl3IqOuScxZ3bPXFrpbalFDwYtsSY?= =?us-ascii?Q?GqWor6lhfJ/qP9DJSMNDb4GT7/OvN2ISdTltmw5T0LSDfaKW1TrQNc8eFcoL?= =?us-ascii?Q?x1f3fmd43/RXnwwi5OWFVL+Qjq6HleNtqsdsHl8r26jlR2sPjV3X2F3e/Ynj?= =?us-ascii?Q?Tc8Q8dEb6HswJTTUNh9casZZBk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5YX4gLpfygBrPPcAaLFm+wJzua3uX78ncMIaAFWkZ5xOlZEeflAtmn2Af8PhjguYE+PAVIR6m3Ar67wZbnmi4FuZ3fgUbTRmvWOoE1wL7TG8qI2bf9Qs3fpYecxEKI4pqbCMWLg8a1RxbNvUyUAwBWpfSoIifhpiKDjsPJX8FaohUZFITXzZriV9urqM5SO0BPWh9rNBo2GFbyBm9h+Uue1S334+d7p7hqNTm3pmjCz/EthI0Y1BsMWxZVD+KVT9V4Zt6sEzLlhaLhDQ==; 5:glxaiV7wVW2B3l4pz+y0M8RYR3MzwaQMqDzhygALuS8C1zSo75zK1DUZkxYD1jwFWdZ1WnxOd4m6Zzo+EeBldfQg6eiWigbpchg0dgH9HSMWaLyXzrt9+lgJV+8kiO5//15CCVfwPyCN7+s6xu85eUCzAbd/s8Jl74QIT+rK/9I=; 24:dgoXw546O9wU7HShHj7a/nULaEcmqDumwr5C3Ue4PVbvkBuSwEKPONO1J6EDx7ASjuJFDHBWMzBWSM901qM5Tht5QqyY/Uy4SjcAEQE+uEY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4188; 7:YtMVTmAvO+leQtXRY0VD/bEvbiOshWSvcKOw8sJai/SnEslGg3tfiSUZNx0raWkj+65yrfLjmjeM+DMkv9QbCfC8dcE7zbwACp4IYK+pJ2iZlwyCOFaRNL9JjFF4Jf0PHmUM4yI8TpwdxjpgRdGSwRGipBBJiFSUzyfjGXG1Tl15CDBYe2udWLXyC2ROPk+7o1ATolyZSDOa286cy5t5LgKwXuKhkrLQ3ZFl5HfvyEkvWxcqn+PWMxW/yIcQg4gk X-MS-Office365-Filtering-Correlation-Id: 1ccc7ffa-e8f6-4d0b-1a8b-08d5c1827bcb X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2018 14:27:30.6016 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1ccc7ffa-e8f6-4d0b-1a8b-08d5c1827bcb X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR05MB4188 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 Add vlan_create() and vlan_destroy() to manage VLAN netdevices. Signed-off-by: Petr Machata --- tools/testing/selftests/net/forwarding/lib.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index d5aa864..11c481c 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -362,6 +362,31 @@ tunnel_destroy() ip link del dev $name } +vlan_create() +{ + local if_name=$1; shift + local vid=$1; shift + local vrf=$1; shift + local ips=("${@}") + local name=$if_name.$vid + + ip link add name $name link $if_name type vlan id $vid + if [ "$vrf" != "" ]; then + ip link set dev $name master $vrf + fi + ip link set dev $name up + __addr_add_del $name add "${ips[@]}" +} + +vlan_destroy() +{ + local if_name=$1; shift + local vid=$1; shift + local name=$if_name.$vid + + ip link del dev $name +} + master_name_get() { local if_name=$1