From patchwork Mon Jul 30 12:44:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10549023 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 1042C13B8 for ; Mon, 30 Jul 2018 12:45:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 004502955E for ; Mon, 30 Jul 2018 12:45:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E83E2296A7; Mon, 30 Jul 2018 12:45:24 +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 DFD7A2955E for ; Mon, 30 Jul 2018 12:45:23 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41fK6T0tFbzF0jn for ; Mon, 30 Jul 2018 22:45:21 +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="GtJ4R8p2"; 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.1.51; helo=eur02-he1-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="GtJ4R8p2"; dkim-atps=neutral Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10051.outbound.protection.outlook.com [40.107.1.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 41fK6G0ZdDzF0gv for ; Mon, 30 Jul 2018 22:45:08 +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=NgfXmke6KrjzVkcUkeihiriLVU/v7M3xHBeG7u/TnRE=; b=GtJ4R8p22J44K73vJDmlWXae6kyeqTmeU3/VyYdml8bvtMqoOeyXVgEFcj87lcaxhKMp215QY1OJ9Dv70PILXC+X9c/Cq9rXg0FtR45bPOLUNX0ojEGJbVUdLHjRq8nXDQgQAHaXbprcxavMUJgwKTN50dpN46IqxwV3v2rZg5k= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) by AM6PR05MB4182.eurprd05.prod.outlook.com (2603:10a6:209:40::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.16; Mon, 30 Jul 2018 12:45:00 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw v3 0/7] ipv4: Control SKB reprioritization after forwarding Message-Id: Date: Mon, 30 Jul 2018 14:44:55 +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: HE1PR05CA0139.eurprd05.prod.outlook.com (2603:10a6:7:28::26) To AM6PR05MB4182.eurprd05.prod.outlook.com (2603:10a6:209:40::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 78044307-2d19-42e4-6b37-08d5f61a43f5 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:AM6PR05MB4182; X-Microsoft-Exchange-Diagnostics: 1; AM6PR05MB4182; 3:hdZ4VV801cvuCiA1DAiFMsCxukPd9lzaa0w/dvPkFnGH3KT0vEfzLCi3lh+vdMOUGKanv4B8nN0tiNtJMbPlQ/Tlhjd04XunXZJL0Yd6zoWhwB1obelQMvVDh9BlCrT83Z16tx/yMWNQXxeGpRVuX2ir3um9XwMdMXtixy4n7XCzrQ3emjM7hUB2rxz5FagN0m+VKfMtxzCGXAGUe5FOyUNEPpaDqbjEw+qa7wPc9OwQbgjix7lVILndzx15yyvy; 25:TGeUUqjDJfpbJtwBChFkhJuSu8NVkjdyhT8E2rWnYLMKGh17vOTpPCqwwmD302qL8OO8YPjRNDUP0m3VJ7vTTkNGUClgDk8luItahumEeflipDCfFfpTpzD1Y9X6X0g+stW6a7wzPHUEwtjjUohStVy3/IOyaRHwX00i+pMYU5n66MCSCyvgO1VeytJIz1/W1xS74FDZQCogSym/gzvM2Ddn21hR5gArHDtm8Vns/+0nyIiSkP9hsOPTcDfv6rb9MsLGz/Dt2gudQ7HPR6+gmb9w+8UygWusDzjcGXjszPOet5rsirFW/l80ziQMNvTmKz13m6mF9Yv+E6RXNe/dug==; 31:bAJRWmv6yH6uVZ8KoEEY9ZsprCwelNX5iOi1h9UmNqzKBNDG9dpJ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am-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:AM6PR05MB4182; BCL:0; PCL:0; RULEID:; SRVR:AM6PR05MB4182; X-Forefront-PRVS: 0749DC2CE6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(346002)(366004)(376002)(136003)(396003)(199004)(189003)(66066001)(25786009)(53936002)(48376002)(47776003)(26005)(7736002)(86362001)(16586007)(316002)(37006003)(58126008)(3846002)(6116002)(486006)(50466002)(81166006)(8676002)(51416003)(6862004)(81156014)(8936002)(52116002)(5660300001)(305945005)(6496006)(16526019)(186003)(386003)(6666003)(2906002)(6636002)(68736007)(97736004)(36756003)(14444005)(105586002)(106356001)(2351001)(6486002)(478600001)(2616005)(956004)(476003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR05MB4182; 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; AM6PR05MB4182; 23:j40dWf1HCEJDfY4bAnZ3xeVRyHkXQAoOFwQ7ZYh9l?= J0Sfzn9WgTXjoXChtuFQsjLS1oIscwMlMOLbf1lKj3SnyK44Qi7oqnXjqfSwsMEurOI+AyUvzHHlN7htTPcBMiI1VhFZyEQ/8ICHLRUXh87c/gF89Zxw0NNSDtB2Ck6tet734ZenMOPm9Q2NOqIKGuIFQNNtgm16poLlUW2oxqOARlIwQMtBkSCDsz6L8ITa/5TMXCaW5aptLukKS6VlySakgPtepw9bHHvqunCwiFc14T9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k3t8lWCngwU43XVvy7MOQFzlD1ju72EKD SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2018 12:45:00.8270 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 78044307-2d19-42e4-6b37-08d5f61a43f5 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB4182 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. All of the above is implemented in patch #1. 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. That is implemented in patch #2. In patches #3 and #4, 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 #5 to #7, 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_setapp et.al.). Changes from (internal) v2 to (internal) v3: - Split former patch #1 into patches #1 and #2. - In patch #2, in ipv4_fwd_update_priority(), wrap first argument of call_netevent_notifiers() to be on the same line as the call, even though the line is now 81 characters long. - In patch #5, rename lldpad_wait_{set,del}() to lldpad_app_wait_{set,del}(). Update references in patch #7 - Reword subject of patches #5 and #6. - Fix a typo in comment of patch #7. Changes from (internal) v1 to (internal) 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 (external) RFC to (internal) v1: - Fix wrong sysctl name in ip-sysctl.txt - Add notifications - Add mlxsw support Petr Machata (7): net: ipv4: Control SKB reprioritization after forwarding net: ipv4: Notify about changes to ip_forward_update_priority mlxsw: spectrum: Extract work-scheduling into a new function mlxsw: spectrum_router: Handle sysctl_ip_fwd_update_priority selftests: forwarding: Move lldpad waiting to lib.sh selftests: forwarding: Move DSCP capture to lib.sh 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