From patchwork Fri Jul 27 19:06:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10547635 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 7A73413BB for ; Fri, 27 Jul 2018 19:11:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 681832C448 for ; Fri, 27 Jul 2018 19:11:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 545772C4AC; Fri, 27 Jul 2018 19:11:13 +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 E0CAF2C420 for ; Fri, 27 Jul 2018 19:11:11 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41cdq21y4mzF14h for ; Sat, 28 Jul 2018 05:11:10 +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="yykIRnCh"; 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.6.44; helo=eur04-db3-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="yykIRnCh"; dkim-atps=neutral Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60044.outbound.protection.outlook.com [40.107.6.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41cdpw0ythzF13G for ; Sat, 28 Jul 2018 05:11:03 +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=8n46bjrsGPoUeAGAUAElbysZRFVsLROijEYT/hz1T8w=; b=yykIRnChb5Xfl82d1eVei3yHd4N4qUrFLxO/26wI4FSd0KwhHwy56Q0dvS7bNGcXoymFlwYJEw65MEZjobQC4Dx8cSRA9e6IpeKsByB7g2CRUaO3AUdHaW7LDsKpUGeGxFA8trsb3lrjF1/2XX9RmhiF7X4n37onrUiL1HSN4ks= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) 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 19:10:56 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw 0/4] ipv4: Control SKB reprioritization after forwarding Date: Fri, 27 Jul 2018 21:06:09 +0200 Message-Id: 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: AM5PR0701CA0020.eurprd07.prod.outlook.com (2603:10a6:203:51::30) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f930d515-b844-4ae8-b618-08d5f3f4ae85 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:xgMwsZHbRxTphm3yjbF8T+13hkBsV+BcCKPwkJLJvExg40IH79vj3TVBhEtirBIVrTSCtRBgQWw36Dh5/gfaMB3h6UGLURLfvbXO1HuMlmMxY3yNutPviIHhYOfd9L9Mh8Ohe6Us2upvxvgzG+fYEePDGeak4yrkmLcJB2jWOOXuiWAzUblccPGa/9CgoIixcXvfdF3f+UPjUAMMNKBzn3OfVxHN9AkoyqUR61l0PMh3i5Hm4OVxbQZtQFpDoqXg; 25:Ov03eZdif8UxjP1wAlkjPchTwJ+63JBtK81JpYpA1X5KBebZt4IX9z5UxJFajnq7jOSbQ30H14BcYXGaLq6hgbule5fl4xyIsIWbN1cwJdEbQ6ogJ/T6LEgFjaT+4O3cfXqUcvVuBV8kvLKUWZav7sqLePlY0fkipeVjR1rGeOA9M8IjIeWTASRLpBd1gSwTgqpnHdRALPmL/w63OF7BHJITYeNQkoMECzIAvCaAZ/lZRouiAo5ZVzSRHXDL0Sm62BZ905KXW4bjd/pPGHxIoxFNyyrLlov9AlNl+TlCl9yXtVG4zrn4dvaLHXhDiOzATdspmhqeNzRUy3V1aDpfeA==; 31:irz5i9ROjizmF+/xFuxgO43o6vftK08ijRwyTngPCCQHAenNddB+BWvGst2YpNXTLUEF0dK85lCneuGaKQt5tMkyq3W3LyAaoGvcU1ZNfB8ncVZHyWHsOt7t8w25X3acr57T7eB5AFIiIwGixxnOSZcx8GtpN6sJ1dB0+n0zWbB8+agKZ5KgjVP7GF4Z6CaDZ9p/OMCtTHi/xBe2V803J3YYAmtsFWBwcBt+GIAdUoQ= X-MS-TrafficTypeDiagnostic: VI1PR05MB4191: X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 20:oqOrYT6luXu31bLZE1sZoY9uUcNLUHehUuw9U/QwzAyjhUchzas3hMtUU2IxK8jcaMqxxSy2DO1zHikLAmNyjguHHTgDO+JUFUO6AGEJtSBhNcdAT1JYNt4+D/bWH/QSZHJAlCKs5CwLKL/n2/ZqMr0nzvDG9bqHeGYIhSH6z+zNVpfPGc8a1xOAFlswfOmfPzr471n7DVlWMnM7QUq9nhzc0Rx7k5Sm1VPrQ+kKpXTQrZUFNbaQBgfF2kb/3wrU4Flgl6HUHGghkiB058rVAZ60xcB8YLHpgn5JZDwwALX80I/njWkEwZHW8ix2gO6qNJvwEFTTdg9it3VnEaH7trrxDjgPWd0RB9IPAy+LOWhnC7TFniHdAjYZ/KFeLrwEtxO2D7ll14GI2Ob6zessekeGbJwPStku8a2xfvaUocIs7HURWTrXhRPr6b1+leRRov2K02B06N1n1DpqNeQXDME+tRU4LLEf03Nf2PSsIAweNJOnUK44EbQcZYV6qVuY; 4:MyjV3w9RgVYhSUzxjNCwitM8kKw9nJYrfeI+4Lbu/1XN7nIdFpUWvLxfro5kNQOFXdDP22pcA46N5c3pVHVuDNuK7yThjB7s5WDUylSbLaAcCJiDmVs15FX7Zp9/TsGOYMblOAZrge8J4+iCzjDnKB5IDrwsjw2aCrKCaGNOjX+PK/N76brtkHFSgacOSKMftAZrFLBfaS5HI2O8qpTIWSxWiMNAEhVysE6dMgNRwUPIQLp2324WghZlVtrJk9kpYtvztz4vcOL7vqnvtED7MQ== 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)(10201501046)(3002001)(93006095)(93001095)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(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)(5660300001)(52116002)(81156014)(53936002)(66066001)(6666003)(6636002)(6862004)(47776003)(81166006)(8676002)(16586007)(58126008)(186003)(16526019)(86362001)(37006003)(386003)(26005)(14444005)(51416003)(6496006)(50466002)(48376002)(97736004)(6116002)(2351001)(25786009)(7736002)(305945005)(3846002)(106356001)(316002)(105586002)(486006)(8936002)(68736007)(956004)(2616005)(476003)(478600001)(6486002)(36756003); 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:z94nISXI/uWRjszIHW2fQx0+laPnoKJ7hYea0XJI9?= iJDsUn4y3a7iysxGDaIFQPNV8Yp1riQ+ZNrN/cajQ33Ub6iu+3BUJBzC6XHIjJAGjznm0gmvsoNObToo7YGjRcRoUrhD+iDc1nfvm7j49CeKPZMzrITZhz4tF/F9iykbo6OpBmVsYz7tZboqgbC7M+bIbCPIc5X/XN12QTPdfF9Q+RGGPReiRPu/Uu1u9NkLcoAUEql1O97pvMFnCmGNYAdSyvEOF2YCHOBcjpMSjUcK27dm+tQYoNpSy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ZsmRWqoqAo8rxDTRLpPtKOStyt8tMAbyzsQg5OhIsqixf5t34Vby89 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2018 19:10:56.6173 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f930d515-b844-4ae8-b618-08d5f3f4ae85 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 patch #3, 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 RFC to v1: - Fix wrong sysctl name in ip-sysctl.txt - Add notification chain - Add mlxsw support Petr Machata (4): 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: 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_router.sh | 233 +++++++++++++++++++++ 8 files changed, 313 insertions(+), 17 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/mlxsw/qos_dscp_router.sh