From patchwork Thu Jun 28 16:56:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10494571 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 ECB99601BE for ; Thu, 28 Jun 2018 16:56:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76BC62A590 for ; Thu, 28 Jun 2018 16:56:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6ACAF2A596; Thu, 28 Jun 2018 16:56:45 +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 42BD22A590 for ; Thu, 28 Jun 2018 16:56:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967388AbeF1Q4j (ORCPT ); Thu, 28 Jun 2018 12:56:39 -0400 Received: from mail-eopbgr10040.outbound.protection.outlook.com ([40.107.1.40]:30544 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965914AbeF1Q4h (ORCPT ); Thu, 28 Jun 2018 12:56:37 -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=2R9atnUDhVDV6soZMGJt1o1rkPScDiknrdyJXyfpvXw=; b=LpI4MSe2XQlIzZ8yphpiVC6DxK1DFOLMQcKq27Nz83gg653WnefOprHt675vh71NU6097sMPPGivn48txPpOPNf6bwn3Bjj5nCpQI5aV3IAy0V/s2b6SC9gXdCCBc052BeHk5kblaDx6xAS7iQjb3nWvfd8KnPVi4030QNOMQvA= 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.884.24; Thu, 28 Jun 2018 16:56:32 +0000 From: Petr Machata To: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: davem@davemloft.net, shuah@kernel.org Subject: [PATCH net-next 2/4] selftests: forwarding: lib: Avoid trapping soft devices In-Reply-To: References: Message-Id: <5362f7c8db72d8450cfdd857c63bcf520d875edd.1530204784.git.petrm@mellanox.com> Date: Thu, 28 Jun 2018 18:56:28 +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: LO2P265CA0164.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::32) To DB7PR05MB4186.eurprd05.prod.outlook.com (2603:10a6:5:18::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 49ef4bb4-8f18-4926-1a97-08d5dd181a36 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600026)(711020)(48565401081)(2017052603328)(7153060)(7193020); SRVR:DB7PR05MB4186; X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4186; 3:9zSw25sdejxdlC3tjQzNoH49KZrD1meabT9pmq1mn411mHrZsonG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IrtLLPtP422NEWohR0/IH0bK9Fo+fj8d13O1qpxqmC1vb/mYy8Ja00m+rov8geNh5+RKhD/pIZ6YBr+1gpJ1DO8K2JLv24mJ6OcAGs9iiT+wnG5Q5Bg2XQ8Sax3yz8VrECaMewa4LnME39aya8gbaODEkva3NCNPRuNdO+mnucgqad+zUo9i316ZzC4DNBiLOPSyWTwN3mnXyyXIFqg1oQ3cyHErZn2BHFNWYU5wNtwF9JZLBqAkuV6woL6pBy25WlJnusvOx1NXYPL/6X/RfeVqj6Bx4gZgKP0YYF0NB/IX; 4:NdZcYjjnomJz+/9Fd12qN6UU+HF3Jysf7pnm3bcAfhjhFtmXThZKJjQATyWkjCJSLWibOLbDW4RvLzxSvrJ2WdZFFFzq9Dfd7TPVaJA012AF1cLmpUTNTkMJvBNLgI6pCgTLGp0ZfDeOGbwz9UijcZKx4DymeWNz4DtOOUk2NBrdn8LZiqM538nUuBQjR51D51+a81YJF4GN9UfnZCiUwdXBJuIguMEsFiMaBhoqkLkNPOa+sUXx5t3U1iTua3d4YsOVm5PRV+HkcDiL5vvPdQ== 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)(3231254)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:DB7PR05MB4186; BCL:0; PCL:0; RULEID:; SRVR:DB7PR05MB4186; X-Forefront-PRVS: 0717E25089 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(396003)(136003)(39860400002)(346002)(376002)(199004)(189003)(316002)(476003)(2616005)(486006)(16586007)(11346002)(2906002)(105586002)(956004)(106356001)(68736007)(6666003)(6486002)(5660300001)(58126008)(305945005)(4326008)(6116002)(81156014)(446003)(118296001)(25786009)(47776003)(97736004)(66066001)(8676002)(8936002)(386003)(86362001)(50466002)(48376002)(478600001)(16526019)(52116002)(6496006)(26005)(76176011)(7736002)(51416003)(36756003)(3846002)(53936002)(186003)(81166006); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR05MB4186; 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; DB7PR05MB4186; 23:XBd4VgrELiReONpjZsEFkZVCjVAcfigVA2Pqm2sXK?= =?us-ascii?Q?VWxmgnRdRtSjtasjvKuyR//4uGl3f2r/WWux6lugKHU4AYopjuZ2CBMS42OI?= =?us-ascii?Q?rOy6oXFLPkg5/4elxTAOLrITHaQjsyvwDyV9DDmeoxG7eFG21R4eazbPz4Cr?= =?us-ascii?Q?280s0w8v1DiqczxyVmqSqNfT7bSlOgqaD7idxfOvMCR1K1DxzbtE74wGRDTQ?= =?us-ascii?Q?C1hG6rGFlozsoXN5NFNGHeQd/csv0zuD0InyYei7vpUanas7ed6aJyzajslk?= =?us-ascii?Q?m6xrh3zcEAnFSAVYRJzAeIPRlaNExCiv+IS/wYgyQnwSMRXWmskKeY/GqOp4?= =?us-ascii?Q?/tCtgck3NgfINKUlGh68600OtbObcYgEf8/GzWX1VZ4Bs9a8UGMaSHBlQttI?= =?us-ascii?Q?6SZxprcqvtFVciig9qNH+ZSIzaxrKoJNYB2wZPOAHHsvXrmHuOZmOwvTP4jB?= =?us-ascii?Q?kYkNPqCYYp40dYqO1eSMUCYZ+vbjU0pdBdBPOcqLxUoxpiHTCVOOV4XRm7kl?= =?us-ascii?Q?6kkAQ+0ZsG0mrsYyMw8Q7oEBbdPUGkun03SNJNNrPK2OJhVBW9yuoeeKwKFk?= =?us-ascii?Q?WM+BkSjpP4/LEClO8INEmeuxhSmp93SCq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ostics: 1; DB7PR05MB4186; 6:FZzJbz/cotRPN5N/7YvRODWMFrkllrnbd/PCaWdS1ZuiPN0OXHNLS4HvJf2RqNjDqgW/w77FPgFubokabsV2rg37oA2Bx3ItRs9shDDJQod4FDrMPNdvdXnMa4KZkWStWnULMrQZ2O2CY6dw4s5HVX0RR7xtz8UZNdDr/STs7jOBhG7TqxiHAvIRv9g1Tc0qOAgnC4hStnTWIAuuyzVKEKUpjQl9EJWtDRu/tvT9KUdAsC1qsR3h7O1TGHiNExIbL8ov2tJ6u1d12Tc4YF5vr640RTJFDmHZUtSugIS5cvTCUTqG84/xZ0+KBfLRnIl+HfoV6vF6OnXmZt1uw3OjAZBFW8EFl150skvh97bhwL9QRH2doIQ3KzCUQ/Iq27kHGxcM2oQcNXrvdOKq/TR+qs1/yVFPLewCmvu1WdR83Zh8+CxGNuzv2ilyHkP+I/ORKNImtokO4+biByv9kzA80A==; 5:McNCnXa/Vm0jUyY24XYLCgtvKjaInimQPVHjrpz+fEGziYC/UBLIDYOSeLNbJX2B+SI95nvJbJtZ9/S0juWS/JB+xgN/2VIOgv3IrnOXlp99q6QlwQi9Du5ceb++ucM0kSg5qgWj66+3rWVEUbvFE68KG63IIiKDhdlkD5dA04A=; 24:6gUfb6UKaQFupTURUrcoKR5/57A4W7ZL7xCDXkqOnS9s4i3DjfFMaCHhNPaWQYuymqCc/q0qsMqnVnw8nHpdguE9NPXrUw/8QDUG9ckfl4I= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4186; 7:hAHKiWbh2gBvTNtOQBhnputSQ2Zpt6UvPgJvNa2RIxtted6qcznN1GOwgaMVnin6F4I7rfJolBv90vF4+MHRJMLsxpRBXdRN7wASxxNqf9FiFDvAkC4MfXxxhBX322DsUt+wcNQgRXawQafVVqrUvZ+MkTHubFlbFV0em/4CJidPZKirIgkgwpvyEPVa2nW46z3McZGj4ddus3geyg/rll9v49Ef1cw3P2iPceWnrwU+eWtkItZ3DaXokX0rGw8A X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2018 16:56:32.8375 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 49ef4bb4-8f18-4926-1a97-08d5dd181a36 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR05MB4186 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 There are several cases where traffic that would normally be forwarded in silicon needs to be observed in slow path. That's achieved by trapping such traffic, and the functions trap_install() and trap_uninstall() realize that. However, such treatment is obviously wrong if the device in question is actually a soft device not backed by an ASIC. Therefore try to trap if possible, but fall back to inserting a continue if not. Signed-off-by: Petr Machata --- tools/testing/selftests/net/forwarding/lib.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index ac1df4860fbe..d1f14f83979e 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -479,9 +479,15 @@ trap_install() local dev=$1; shift local direction=$1; shift - # For slow-path testing, we need to install a trap to get to - # slow path the packets that would otherwise be switched in HW. - tc filter add dev $dev $direction pref 1 flower skip_sw action trap + # Some devices may not support or need in-hardware trapping of traffic + # (e.g. the veth pairs that this library creates for non-existent + # loopbacks). Use continue instead, so that there is a filter in there + # (some tests check counters), and so that other filters are still + # processed. + tc filter add dev $dev $direction pref 1 \ + flower skip_sw action trap 2>/dev/null \ + || tc filter add dev $dev $direction pref 1 \ + flower action continue } trap_uninstall() @@ -489,11 +495,13 @@ trap_uninstall() local dev=$1; shift local direction=$1; shift - tc filter del dev $dev $direction pref 1 flower skip_sw + tc filter del dev $dev $direction pref 1 flower } slow_path_trap_install() { + # For slow-path testing, we need to install a trap to get to + # slow path the packets that would otherwise be switched in HW. if [ "${tcflags/skip_hw}" != "$tcflags" ]; then trap_install "$@" fi