From patchwork Fri Jul 27 23:00:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10547803 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 A4624112B for ; Fri, 27 Jul 2018 23:02:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93CA72C6D8 for ; Fri, 27 Jul 2018 23:02:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87ABB2C6DB; Fri, 27 Jul 2018 23:02:57 +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,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 891892C6D8 for ; Fri, 27 Jul 2018 23:02:54 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41ckyN11TMzF0kx for ; Sat, 28 Jul 2018 09:02:52 +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="TlhgGst7"; 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.0.51; helo=eur02-am5-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="TlhgGst7"; dkim-atps=neutral Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00051.outbound.protection.outlook.com [40.107.0.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41ckyD1kxLzF09Y for ; Sat, 28 Jul 2018 09:02:42 +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=M1latjNhd0BKPzL9suKB9ncyEH/Jq6MRS4mh2zjtUG8=; b=TlhgGst7aaMO5h509VI1IYbm0s97OUPj0DkVI/5a+Kln0dZBj9h/ljrzh9YJ5MrhXtd34wbqb72we0a4imNUv9rbXxZiY4Upe56n5FT3uIY4Ku95t81M8ZekAh5wQe5OmKuXXMLFomcQgYc9N7JhxEwyuNVUiCa98xoW11Y4Ahs= 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.973.21; Fri, 27 Jul 2018 23:02:35 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw v2 0/6] ipv4: Control SKB reprioritization after forwarding Date: Sat, 28 Jul 2018 01:00:19 +0200 Message-Id: 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: AM4PR0101CA0082.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::50) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 91a5e6ad-7fb7-479b-a7ba-08d5f4150afd X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB4191; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 3:a9FgEmqrNAWKiplK9CtcJZBGcgPMUX1u5E8uL4InBjxEuRNIiEYn38S6BfyQMEDSta2e1ML+yjmRkbJpYqaXWUXr2xrXcuNs5rHqUdk0NCA2Mq2Oljdd1BYxgsaY4b2nom5R7OQV64L6nP9VVxH0Cvj3bNHtWUEwC/2qLDIZVzhVQ5/CSfrM+UEJ3h4LDSwTt9a5y/37+dkywcCLEYotIGO81p0txPxB7OIvXfJa+HRs7CzOVocSgQG1SITfVKsD; 25:96jJn1WLFryoAiWmKtrQJVEbF2dsb/M2sJGcXtI8Ui/bnS1lQika/VrzM8fS2R09dNEzHonYcXhKsbT4ie/VO3kPZgD3JulaAuAPdKSUMTo6A+c22UEb2MoOat8Zr3yt69LSVRSoxT6aOgYcxa42A3aOpH8FpZKYh3+LpO/zh4PGwn1XqHfJZtN0OZJBmjOuuVe9YeaQ6UbefXTeFYyLl05Y7PYxt1pBMX+hHqRU1g3N5XmIte04iBqYElWMOspyvFd6yWWK5QRMFno//GlhgS6Hw8lFdAedwWOeE9AQFjuIFVUlZmpJlS/k+CB4NR5GI06ndInLbWNXAqgxDiP+Eg==; 31:cTjg15mI/go6Ir3fgFGlcq+pi5KqLFNT6GtHyllOfI5gdUInsymruo+WpUWWzxo2juj6SQ3//pXymWY/guLZYC2NjY1edS+d5WUp/giDOO59/ecIz1EFisWiyEZwhherc7sUitXf0PbmPCrKDRttjOncsLW4NDHDR29gFn5drINXnyOo/Zi9yWzxTq0kjec/G77t3nmiFVMuNUSjlb0c5lb0L/sbErh8f+IvwhlYUkQ= X-MS-TrafficTypeDiagnostic: VI1PR05MB4191: X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 20:xS9QeEgn81WplZLIkPfw37cE3TbEh4UYAgLVE+HC8v8jVBsMiidg8vISDPatqbaRJo0xD+nPGgGhdCIDCdvmlINbfurMDxcX1OIjWyRGO0grmYeyRyXcm/Vubfjbtw4HfWJICMZt0K8CKeA4XMmd+3HWRLjJzS67inmBNuQ1WgXr6R9w4fxg0GrHdk3//A7RqrGuFT6BMryKtPInHHNHayfqWEDNaf0kHynjXjcV2p1JzQoVQRlcJVUozt+PPAghVd/zOhHEzVj1nu5RL7GL3gupxcxvz3DQsN+rTxSED+rRhb2s+QbUXBlirGRyQ3I6NmnwYo5beQhRBYWu6pafmXelyo4XAtPkyWWIQLtx7FPb7cGyNoMgbTqiKsvIiP/ckLx0+Wep4wsWN9D1qxkHtSh3w9bkY1GxGeR05krxKOyzhYI5eGXOgHwJp8tkJ2zFWDfS0hLLjLh9ek2rzF0hFQcxEmE+ye9sGWeG8xKvYwkJg32Uh+DKBBHpvfUtIEJV; 4:CwfyVKyzDdSjKkTlWoUB5nSlhIy2N018/iyHfQ23eWhpqOy3xP7fkHmSIufZgVuKoFuTSMomO5hrDVu4xILgXE3ctqzAaJ47gdpNCQvLJeLMxgkvGlh4yilsWejdlQxARmoM9LdCwNNt9YBDvY86cdsRFeBM78WIf+gsPzclAl+PHizuZihgn/NZo7okyhKks9DkFxATrYt3oO1we0vwt9JX/YJIjTqxZYMx4/nRD/vsT8FDE+p36Xxl1CeMr6iluprK4QgWIUhuyiZEgKYsQQ== 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)(3231311)(944501410)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:VI1PR05MB4191; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4191; X-Forefront-PRVS: 07467C4D33 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(376002)(39860400002)(366004)(396003)(136003)(189003)(199004)(2906002)(52116002)(5660300001)(81156014)(6636002)(66066001)(6666003)(53936002)(81166006)(6862004)(47776003)(8676002)(16586007)(58126008)(16526019)(186003)(86362001)(37006003)(26005)(386003)(14444005)(51416003)(6496006)(48376002)(97736004)(50466002)(2351001)(25786009)(7736002)(305945005)(106356001)(316002)(105586002)(3846002)(486006)(8936002)(68736007)(2616005)(476003)(956004)(478600001)(6486002)(36756003)(6116002); 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:vX6Q2rxlET45atboG39DMAyCRMRyrE5gx6kXQE8ow?= IWe1R/QK83PBgwVSdln1rM7I5md91QFOkoyek8p2xyuJuB/U67K0ZnTdCeydlxV4caVOE32xPB2r1T+0IYyr+maIe7hwERx8peF4shpVARDKroCHAeTo50u7IaVzY3/FC+UdSUK8GaWau6WwpFe/ragvqH2niKbckZfeEgkaOseb3kmazrMzFCd8ZYm3xhjnT7TisWw2TF60phwHF/BHi6JdWddb4eFS5jIG1RtdHBB61p6/WgS9j6GsX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LNOjTePIUgzTV1/ReA4m+mac7oaQcRkq4y9m3WMST4N SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2018 23:02:35.5710 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91a5e6ad-7fb7-479b-a7ba-08d5f4150afd X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4191 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 After IPv4 packets are forwarded, the priority of the corresponding SKB is updated according to the TOS field of IPv4 header. This overrides any prioritization done earlier by e.g. an skbedit action or ingress-qos-map defined at a vlan device. Such overriding may not always be desirable. Even if the packet ends up being routed, which implies this is an L3 network node, an administrator may wish to preserve whatever prioritization was done earlier on in the pipeline. Therefore this patch set introduces a sysctl that controls this behavior, net.ipv4.ip_forward_update_priority. It's value is 1 by default to preserve the current behavior. Value changes prompt a new NETEVENT_IPV4_FWD_UPDATE_PRIORITY_UPDATE notification, so that the drivers can hook up whatever logic may depend on this value. All of the above is implemented in patch #1. In patches #2 and #3, mlxsw is adapted to recognize the sysctl. On initialization, the RGCR register that handles router configuration is set in accordance with the sysctl. The new notification is listened to and RGCR is reconfigured as necessary. In patches #4 to #6, a selftest is added to verify that mlxsw reflects the sysctl value as necessary. The test is expressed in terms of the recently-introduced ieee_setapp support, and works by observing how DSCP value gets rewritten depending on packet priority. For this reason, the test is added to the subdirectory drivers/net/mlxsw. Even though it's not particularly specific to mlxsw, it's not suitable for running on soft devices (which don't support the ieee_getapp et.al.). Changes from v1 to v2: - Adjust for the changes in net-next: add two patches that were originally in v3 of the DSCP rewrite patch set. - Insert patch #4 with lldpad waiting - Insert patch #5 with DSCP capture Changes from RFC to v1: - Fix wrong sysctl name in ip-sysctl.txt - Add notifications - Add mlxsw support Petr Machata (6): net: ipv4: Control SKB reprioritization after forwarding mlxsw: spectrum: Extract work-scheduling into a new function mlxsw: spectrum_router: Handle sysctl_ip_fwd_update_priority selftests: forwarding: lib: Move lldpad waiting here selftests: forwarding: lib: Move DSCP capture here selftests: mlxsw: Add test for ip_forward_update_priority Documentation/networking/ip-sysctl.txt | 9 + .../net/ethernet/mellanox/mlxsw/spectrum_router.c | 56 +++-- include/net/netevent.h | 1 + include/net/netns/ipv4.h | 1 + net/ipv4/af_inet.c | 1 + net/ipv4/ip_forward.c | 3 +- net/ipv4/sysctl_net_ipv4.c | 26 +++ .../selftests/drivers/net/mlxsw/qos_dscp_bridge.sh | 65 +----- .../selftests/drivers/net/mlxsw/qos_dscp_router.sh | 233 +++++++++++++++++++++ tools/testing/selftests/net/forwarding/lib.sh | 63 ++++++ 10 files changed, 379 insertions(+), 79 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/mlxsw/qos_dscp_router.sh