From patchwork Fri Jul 27 19:10:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10547637 X-Patchwork-Delegate: idosch@idosch.org 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 B818713BB for ; Fri, 27 Jul 2018 19:11:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A19F62C4AC for ; Fri, 27 Jul 2018 19:11:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 961622C495; Fri, 27 Jul 2018 19:11:15 +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 AA6F72C4AB for ; Fri, 27 Jul 2018 19:11:14 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41cdq50kcmzF14h for ; Sat, 28 Jul 2018 05:11:13 +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="wQcR6lRM"; 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.57; 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="wQcR6lRM"; dkim-atps=neutral Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60057.outbound.protection.outlook.com [40.107.6.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41cdpz224yzF0x4 for ; Sat, 28 Jul 2018 05:11:07 +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=M5IsvNx5e8H+7C3PuIRVuOzv7g/ZzU2ubmUNXPaaDAk=; b=wQcR6lRM2zBbbtYuBB4iFLnhL5RshUjehTkr0lji6OfdOFnostk+8wXHSZi9VrUqDJkzfgw04BgAifcq7Vqd8XIURmGxO6+YDuitj8Pk1DRF6pTQYxlVjFkvqhbudpIOdMGGcaKMuQ7fVOwnrHRVsD4CCX5tifuuPXMacDkLQ70= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) by AM6PR05MB4183.eurprd05.prod.outlook.com (2603:10a6:209:40::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.17; Fri, 27 Jul 2018 19:11:01 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw 1/4] net: ipv4: Control SKB reprioritization after forwarding In-Reply-To: References: Message-Id: <51877cdb3b04e987fd4ed4ee23a339eadbc39db6.1532717939.git.petrm@mellanox.com> Date: Fri, 27 Jul 2018 21:10:57 +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: AM4PR0101CA0063.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::31) To AM6PR05MB4183.eurprd05.prod.outlook.com (2603:10a6:209:40::28) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cc20600f-befa-4816-2b8e-08d5f3f4b13f X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4618075)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:AM6PR05MB4183; X-Microsoft-Exchange-Diagnostics: 1; AM6PR05MB4183; 3:u7z0gImrXZAvAfh8C2bm47gb+qnDzFVPEuUZkFMTOMF/O2OAjGs3Hejnl/kdYPn1H7tLzs5En6gRXLxlQA9lFYH2cVlpLovdf9P9xg4cd7N8NUB74zcRLg08UtYkl+O4TikJ4/3IyOSSdOaPNlHZdouQ/AKxhGSR8IDzzDv9JE8pUmSBiivdFhRX7wy3r+6XbNpTLeFvZOC5YCEIVw6cA9FUjILCpfFKKPOU1dlHlSikJF1nre3NBtbcxQkJm7cJ; 25:SlFjoNtlDQIxShpBVoVOuCUpCvK/I6mP2oh0qe1ent6QueosUmgnqg3QGoYHcoYneMu/RegABpsf+nmEAPA61yippbNdItYI/e/ih39i4BZBSIbJODp8Emz6oRaxcK2D1DYDuB6qeBi2EeAfmU3ovNFABCJnN5ox9C06pKu+6REbZUtESeyDUiVPcfFXeMKVyh6CTyPKDlqqSWSR35vUkCywpvaszBuTZJxPAccWvKgVlkmhExq5m8rwBU+jjO/2NKGhBdSHS0Pc7HV3b05bcBUjWk7LhJ9teTx5NCrDOfAiy+H+0i+a0w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lsr+mzenbG4ELDuPKVEgT/Ct9C6BWHdDikvG1C0/YsgVydmZbJbozrW9iRfKNojQ== 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)(3002001)(3231311)(944501410)(52105095)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:AM6PR05MB4183; BCL:0; PCL:0; RULEID:; SRVR:AM6PR05MB4183; X-Forefront-PRVS: 07467C4D33 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(376002)(396003)(366004)(39860400002)(136003)(199004)(189003)(66066001)(6116002)(478600001)(48376002)(81166006)(106356001)(50466002)(2351001)(68736007)(97736004)(3846002)(6862004)(81156014)(8676002)(118296001)(105586002)(76176011)(52116002)(2906002)(51416003)(47776003)(16586007)(58126008)(37006003)(446003)(316002)(14444005)(6496006)(5660300001)(575784001)(11346002)(86362001)(6486002)(486006)(53936002)(386003)(476003)(7736002)(2616005)(956004)(36756003)(26005)(16526019)(186003)(305945005)(8936002)(6636002)(25786009)(6666003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR05MB4183; 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; AM6PR05MB4183; 23:4cu/2wiOrjI+OxEbAjZPkGMGxf3ujMicG+xUOdUze?= uC0Isci2pwVIOCjMjo9w2hYVOqram48kNyPD+XsxIh21eRo064n6nRis2ULn9Sf+LECr+xbV/jXQSfk9ij450VlDxv61ljf/QxHPJ+OKkpA27hoiGUjHEjuRmtVHmygOX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bQYp9GCGEhMsC4s=; 7:ObIOO3uAX4PXN5ovi7LuEicXFOvNZvtMKQEpB4uOhwCyRsFdaf8gp3jDwdTlgDklChvOXNfWHeGrJb//Z97lKAT5QAoRnfSu+edFX6TOLA9cRzevim+YGGOTC6y3uTkKB5nCJDWwhJUuwsFSJSJRpAJtULVNv7/SKAvauAsmZYJXDcarPVY6bQZGGXEZAfensVTv7WvmHdigkVTSK4n/iMt6fJtswDOUvlXH68oU1VDOIJY0tnWVgVFReZe7s4GC SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2018 19:11:01.2351 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc20600f-befa-4816-2b8e-08d5f3f4b13f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB4183 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 introduce a sysctl that controls this behavior. Keep the default value at 1 to maintain backward-compatible behavior. Signed-off-by: Petr Machata --- Documentation/networking/ip-sysctl.txt | 9 +++++++++ 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 ++++++++++++++++++++++++++ 6 files changed, 40 insertions(+), 1 deletion(-) diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt index 77c37fb0b6a6..e74515ecaa9c 100644 --- a/Documentation/networking/ip-sysctl.txt +++ b/Documentation/networking/ip-sysctl.txt @@ -81,6 +81,15 @@ fib_multipath_hash_policy - INTEGER 0 - Layer 3 1 - Layer 4 +ip_forward_update_priority - INTEGER + Whether to update SKB priority from "TOS" field in IPv4 header after it + is forwarded. The new SKB priority is mapped from TOS field value + according to an rt_tos2priority table (see e.g. man tc-prio). + Default: 1 (Update priority.) + Possible values: + 0 - Do not update priority. + 1 - Update priority. + route/max_size - INTEGER Maximum number of routes allowed in the kernel. Increase this when using large numbers of interfaces and/or routes. diff --git a/include/net/netevent.h b/include/net/netevent.h index d9918261701c..4107016c3bb4 100644 --- a/include/net/netevent.h +++ b/include/net/netevent.h @@ -28,6 +28,7 @@ enum netevent_notif_type { NETEVENT_DELAY_PROBE_TIME_UPDATE, /* arg is struct neigh_parms ptr */ NETEVENT_IPV4_MPATH_HASH_UPDATE, /* arg is struct net ptr */ NETEVENT_IPV6_MPATH_HASH_UPDATE, /* arg is struct net ptr */ + NETEVENT_IPV4_FWD_UPDATE_PRIORITY_UPDATE, /* arg is struct net ptr */ }; int register_netevent_notifier(struct notifier_block *nb); diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h index 661348f23ea5..e47503b4e4d1 100644 --- a/include/net/netns/ipv4.h +++ b/include/net/netns/ipv4.h @@ -98,6 +98,7 @@ struct netns_ipv4 { int sysctl_ip_default_ttl; int sysctl_ip_no_pmtu_disc; int sysctl_ip_fwd_use_pmtu; + int sysctl_ip_fwd_update_priority; int sysctl_ip_nonlocal_bind; /* Shall we try to damage output packets if routing dev changes? */ int sysctl_ip_dynaddr; diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index f2a0a3bab6b5..d3cfbd89ca3a 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1802,6 +1802,7 @@ static __net_init int inet_init_net(struct net *net) * We set them here, in case sysctl is not compiled. */ net->ipv4.sysctl_ip_default_ttl = IPDEFTTL; + net->ipv4.sysctl_ip_fwd_update_priority = true; net->ipv4.sysctl_ip_dynaddr = 0; net->ipv4.sysctl_ip_early_demux = 1; net->ipv4.sysctl_udp_early_demux = 1; diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c index b54b948b0596..32662e9e5d21 100644 --- a/net/ipv4/ip_forward.c +++ b/net/ipv4/ip_forward.c @@ -143,7 +143,8 @@ int ip_forward(struct sk_buff *skb) !skb_sec_path(skb)) ip_rt_send_redirect(skb); - skb->priority = rt_tos2priority(iph->tos); + if (net->ipv4.sysctl_ip_fwd_update_priority) + skb->priority = rt_tos2priority(iph->tos); return NF_HOOK(NFPROTO_IPV4, NF_INET_FORWARD, net, NULL, skb, skb->dev, rt->dst.dev, diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 5fa335fd3852..6fcd1173ef9b 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -201,6 +201,23 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write, return ret; } +static int ipv4_fwd_update_priority(struct ctl_table *table, int write, + void __user *buffer, + size_t *lenp, loff_t *ppos) +{ + struct net *net; + int ret; + + net = container_of(table->data, struct net, + ipv4.sysctl_ip_fwd_update_priority); + ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); + if (write && ret == 0) + call_netevent_notifiers( + NETEVENT_IPV4_FWD_UPDATE_PRIORITY_UPDATE, net); + + return ret; +} + static int proc_tcp_congestion_control(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { @@ -664,6 +681,15 @@ static struct ctl_table ipv4_net_table[] = { .proc_handler = proc_dointvec, }, { + .procname = "ip_forward_update_priority", + .data = &init_net.ipv4.sysctl_ip_fwd_update_priority, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = ipv4_fwd_update_priority, + .extra1 = &zero, + .extra2 = &one, + }, + { .procname = "ip_nonlocal_bind", .data = &init_net.ipv4.sysctl_ip_nonlocal_bind, .maxlen = sizeof(int), From patchwork Fri Jul 27 19:11:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10547639 X-Patchwork-Delegate: idosch@idosch.org 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 D1B87112E for ; Fri, 27 Jul 2018 19:11:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C04202C4A5 for ; Fri, 27 Jul 2018 19:11:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE5F42C4C4; Fri, 27 Jul 2018 19:11:19 +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 EC5A52C4C2 for ; Fri, 27 Jul 2018 19:11:18 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41cdq92D0bzF19q for ; Sat, 28 Jul 2018 05:11:17 +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="J/Epfz3e"; 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.8.78; helo=eur04-vi1-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="J/Epfz3e"; dkim-atps=neutral Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80078.outbound.protection.outlook.com [40.107.8.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41cdq26r9szF16W for ; Sat, 28 Jul 2018 05:11:10 +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=XifDBL2a3YnELOPsjAVEI0W5RI97+X+L8ORXOKpoPJM=; b=J/Epfz3eCEOOO9rOvKIokp2WUIZcSpfKD80B7fL4ryLL2/ZWN16n/sm/GxCPRQ+6kkpWjSDe9piuFvC1JArX5fIy9m0Sbng9HLQ5Vrq23tS1NVrc9va255MzPtgux/VMK7jUBACiimXr/kXc8UEoxAvAXzw55giQZ5GNc6whKDo= Received: from t540p (78.45.160.211) by AM0PR05MB4177.eurprd05.prod.outlook.com (2603:10a6:208:57::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.19; Fri, 27 Jul 2018 19:11:05 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw 2/4] mlxsw: spectrum: Extract work-scheduling into a new function In-Reply-To: References: Message-Id: <2d58502993edcf6becf5d2bd6a51c16fef49aae3.1532717939.git.petrm@mellanox.com> Date: Fri, 27 Jul 2018 21:11:01 +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: VI1PR08CA0130.eurprd08.prod.outlook.com (2603:10a6:800:d4::32) To AM0PR05MB4177.eurprd05.prod.outlook.com (2603:10a6:208:57::26) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e178684d-ea76-41bc-04f6-08d5f3f4b3e3 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4618075)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:AM0PR05MB4177; X-Microsoft-Exchange-Diagnostics: 1; AM0PR05MB4177; 3:QDDwdeAh9pU/Ihdk+bn+ybzKfs72boFizxAgIhv4KecjZ7qG4a4Xt3vZODwCsQOmW7GMTvGxz4c0ZrC5Ks0nwyTP1EpEAsZbImaACJlm3YL8kgit1csbvFkY6YNCqMl27avnxgn6Y7iDCtw53BnNcyRd8jPsMNwqHiFRjChibyeH8UXP1tDiHslCgbgt41bRDe3Kr9TLTSqxcoOYLHuIuCaNbY8tAiEYweScinJOocSIoSWxyeIa11zPfTougXoN; 25:Sych7/mWkGdE6iw53G263quRW3u+FBXZLkA9+1tY9HfF/bPg30ePXZyypSoEi0iPNeMc8uDhAQr8kjrtPi7X0t09T26TlKOeTucUkPDjkxxrshr+6V6ic5LOult/+v4gFWPlqa1yQLwhqc7j9skvMMMwDAVxKKdU7A/a3VN9WKAmQSnJq0/aWvDwBPTFfqDQGrcW3nDi2/9KnITOfKRJiuxC7SxEz4CFi/k5v81SGQpf6LEXW2EY/w8hufNXEaEgY6UtE8cw5cnVKwzBit+yJ+tnz7RQrXAS8UmzUx2X7ctsyYEDTlX1yEi78P7o0xSYz0qoJxdfzUW8glrWBnOyGA==; 31:bcDBuEUD14N0uIBO31C+QtjMTEFahr7f1w28bubdBzzOPw7IlkUGJUa/uJFX+gUniY7Ywka2lJEY5WYmLoaRzoHGSheN7umrcokHt+Ex1TGvsiWunxH8nqSd0hyM/cGFdFFGLwv4jbAj/d083UJ4eaLqCz/RNzQVwXCwXD+34NF+RTXV5OmGJx3Tq/VZ++tmHHP/3pclbdT9hXR7TZILsD3IlOn4/wYSjfNeI1gkqzs= X-MS-TrafficTypeDiagnostic: AM0PR05MB4177: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; X-Microsoft-Exchange-Diagnostics: 1; AM0PR05MB4177; 20:AuJOswdz5L7sLxhrcMzLMI1PbCrJJs2q9L+e/qAma+I/ttITnivgCBd3gtjlA0DdrL8Iro/iwXnSDiZ5j7OhYcGItH6UgayaLp2nxeSE6a2eixTjmM/yVXiDnfrJiqC3Gr8XjYTIMYaxrFQ9goEc7Ex3nfWaFc9ICSZqx35TrYXEeGDKDsPCXPJMXlkdS4akNijuUaGGS1wC/hKyC2mHniCQffuqyKxyQA4rhDcKKLPfyELsHsZh9ET1/VOfJx58EG+NFsHL5iEEYFUZfH0StY7+XsTxJhelDfD5O+1ztLGFsEga2yCth1KSbz2ZdYsKBNnEmzDXw4X2Rrq9pgJSJ0pU5ROMjsa2JZ0TL8QySe6wHPW1+aE//blRuLip6UONYODPI5ZPo/LV0fnp5JVy63WAxvYoInwBR7oUyHmAmfU9hwJI1fMnZ0Z+lC2TU2dvWewizLtbhZayPoXXDB9n9px+gPnG3GchAL0JfIuc3Ys9AUsZ3ux5uH/4uzm9WT6e; 4:b2sIEz9VF8Bp9FbZLL1S6s4E+RJlFHkwAFnF0vxZ674VrpInwhgyVYmJHIvf7+pTqT7H2oCgsWdVFSUHOEfvnZ7OjPsWbDYZvv3z0Fu1zPBxDUgiwSdsCXaMpoT4cWrLZKAZ+ATjzRNDYoZBj+IhxBgmwzk6QzfV1KIYD/bzOE+2+LKgAyQeO1wc8O1blsT03RaE+3PyEOMayZf1atCJxFDswvHfR4/zj88B5e29NPwE01UyA6iT+Ui0Z75yK079v2BPBQxMRMsHt1A3co1hww== 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)(3002001)(3231311)(944501410)(52105095)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:AM0PR05MB4177; BCL:0; PCL:0; RULEID:; SRVR:AM0PR05MB4177; X-Forefront-PRVS: 07467C4D33 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(366004)(39860400002)(396003)(346002)(376002)(136003)(199004)(189003)(6486002)(186003)(16526019)(25786009)(5660300001)(26005)(48376002)(86362001)(386003)(6496006)(50466002)(305945005)(6636002)(7736002)(8936002)(66066001)(6666003)(47776003)(8676002)(2351001)(81166006)(81156014)(97736004)(446003)(11346002)(6116002)(58126008)(16586007)(37006003)(316002)(76176011)(2906002)(52116002)(6862004)(14444005)(956004)(118296001)(2616005)(51416003)(68736007)(36756003)(476003)(478600001)(486006)(53936002)(105586002)(3846002)(106356001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR05MB4177; 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-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RuRrXAlHFneeARIwWCzYEK7BgYBrTLiRFshNfM3AMYAIoaOIRRKsa3ebGSuWGJo8sutHU+Rk+/myGvi2yBqJH5QovlBj/lQ/1Zhd8/fGoyLAfbOF6VyX0A+cNwB6z9f4qIy9EiOmrawQA==; 5:IG10IkBwVRi1ypT6OEgdXR2xs8NHD7rTe8Qz2chNpl1YAgaYqLGsyM145F2n9DeRpLg5q3gu38u3jucgEQexBW9nL7n0PQjdT0V+hRN45SlwkWGjtLG60bE+oPC5/5cCZUC1vkmUp6nYuXIu/yg8xejoe5nLEL2Jxb4WV1RZxmI=; 7:ZTca0uZWtb1RpcQqeyrLNLpnZ9hMzmEF5eyHXnO8qC28WaiLhWU++wK4LQGi5KnGbBy0MijLG4g8RwEPRGjiyH+RzEN2gJDLeblIdeEECfSnpMVOqRTCRMf4BTULSO3XrSxfT6FLaA3tSu66tPDtV9MIY8XxpEGmZJX/Guyt11D9+PPfElRc/jdWA1ksFce90V4/2EmIxHY6rieUmZ7lk+t6abbWwUYd6l/DjxHQPvPB/gqY2aef0B9vnzewuZQ2 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2018 19:11:05.6551 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e178684d-ea76-41bc-04f6-08d5f3f4b3e3 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4177 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 The boilerplate to schedule NETEVENT_IPV4_MPATH_HASH_UPDATE and NETEVENT_IPV6_MPATH_HASH_UPDATE handling is almost equivalent to that of NETEVENT_IPV4_FWD_UPDATE_PRIORITY_UPDATE that's coming in the next patch. The only difference is which actual worker function should be called. Extract this boilerplate into a named function in order to allow reuse. Signed-off-by: Petr Machata --- .../net/ethernet/mellanox/mlxsw/spectrum_router.c | 38 +++++++++++++--------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 1d4c02a36432..08b105bfb65d 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -2402,17 +2402,36 @@ static void mlxsw_sp_router_mp_hash_event_work(struct work_struct *work) kfree(net_work); } +static int mlxsw_sp_router_schedule_work(struct net *net, + struct notifier_block *nb, + void (*cb)(struct work_struct *)) +{ + struct mlxsw_sp_netevent_work *net_work; + struct mlxsw_sp_router *router; + + if (!net_eq(net, &init_net)) + return NOTIFY_DONE; + + net_work = kzalloc(sizeof(*net_work), GFP_ATOMIC); + if (!net_work) + return NOTIFY_BAD; + + router = container_of(nb, struct mlxsw_sp_router, netevent_nb); + INIT_WORK(&net_work->work, cb); + net_work->mlxsw_sp = router->mlxsw_sp; + mlxsw_core_schedule_work(&net_work->work); + return NOTIFY_DONE; +} + static int mlxsw_sp_router_netevent_event(struct notifier_block *nb, unsigned long event, void *ptr) { struct mlxsw_sp_netevent_work *net_work; struct mlxsw_sp_port *mlxsw_sp_port; - struct mlxsw_sp_router *router; struct mlxsw_sp *mlxsw_sp; unsigned long interval; struct neigh_parms *p; struct neighbour *n; - struct net *net; switch (event) { case NETEVENT_DELAY_PROBE_TIME_UPDATE: @@ -2466,20 +2485,9 @@ static int mlxsw_sp_router_netevent_event(struct notifier_block *nb, break; case NETEVENT_IPV4_MPATH_HASH_UPDATE: case NETEVENT_IPV6_MPATH_HASH_UPDATE: - net = ptr; + return mlxsw_sp_router_schedule_work(ptr, nb, + mlxsw_sp_router_mp_hash_event_work); - if (!net_eq(net, &init_net)) - return NOTIFY_DONE; - - net_work = kzalloc(sizeof(*net_work), GFP_ATOMIC); - if (!net_work) - return NOTIFY_BAD; - - router = container_of(nb, struct mlxsw_sp_router, netevent_nb); - INIT_WORK(&net_work->work, mlxsw_sp_router_mp_hash_event_work); - net_work->mlxsw_sp = router->mlxsw_sp; - mlxsw_core_schedule_work(&net_work->work); - break; } return NOTIFY_DONE; From patchwork Fri Jul 27 19:11:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10547641 X-Patchwork-Delegate: idosch@idosch.org 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 9D2A913BB for ; Fri, 27 Jul 2018 19:11:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 864F42C4A5 for ; Fri, 27 Jul 2018 19:11:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82C952C4C0; Fri, 27 Jul 2018 19:11:26 +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 92CD02C4C6 for ; Fri, 27 Jul 2018 19:11:25 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41cdqJ00VJzF1BL for ; Sat, 28 Jul 2018 05:11:24 +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="BycKUVlV"; 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.42; 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="BycKUVlV"; dkim-atps=neutral Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60042.outbound.protection.outlook.com [40.107.6.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41cdq95sv6zF0jn for ; Sat, 28 Jul 2018 05:11:17 +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=Qy60Oh06zk1+H9A5BfzjM+sj5UelTdF8qe/tncLVPPk=; b=BycKUVlV2xQ2Ld20TG9b2eggDk+dLWPTaHbInpaHSjqz/+YKjt7JEgzM7ofN/LZ26xIqNfYMGAW0hJ84GMFf2KPNGwJe8vJzNjfmhEZP3SgcyAe85M9Pce7HpBs218E2WoITcgMF3oGV36xKvAQR5bZ9YXkpQnUE9/6YlDR0nO4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) by VI1PR05MB4192.eurprd05.prod.outlook.com (2603:10a6:803:4e::18) 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:11:10 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw 3/4] mlxsw: spectrum_router: Handle sysctl_ip_fwd_update_priority In-Reply-To: References: Message-Id: <869cf7b48e9226e275231a2b6412f2bdcffd674a.1532717939.git.petrm@mellanox.com> Date: Fri, 27 Jul 2018 21:11:06 +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: AM0PR01CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:208:69::20) To VI1PR05MB4192.eurprd05.prod.outlook.com (2603:10a6:803:4e::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e6c50728-5188-4011-dacb-08d5f3f4b703 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:VI1PR05MB4192; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4192; 3:QZOfQ1rzpMu49y0u8YnKtFlnE1MP0yFZqmjoRDeNzzYOKxb7idorqJ1Iq+Hg4202ZKKZ+dQ8g9xbIES8am/w/sRIiogfFLxlLFdq7DKuEI/MvhbKeMzowTDFQ5prSUo4Q1fmjr+JgUVGb826N3+OysLLfj3Exzz/pjqPKK8tvUSI2POy5SyVwXtGG2frZpyi/kUhEIoNy0R1PtOJgOgmqqU4qWQrJqZbd8QxTvMQXtn1DPmcGFUanusdx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5v/qUZepy5az2oYbHF0s0Yy7jplJpYtz5c4DWSqA9H3yEmyQhSSNL1rwbbIgqGB/bEDqAlCw1mx5qlUgTYdmuogp8lGzkvj4r2SC2Ac4ivF; 4:dOwj4+5FYC60VqPc5GZfcIspuZkX0OLsNEssSXbrrZsGb7hHyd1CZlA2SxGjhi9s8pOiW9S8SXqMgwz6drQUHUgvzZOyn4adIRZ6eG9Eqr7HZMPlX7IMUJ3+6tygeuQosvba23IHReTgwMrqZ1P29//bx7jyUdQQaFbWUSfC2ppSoyaIRvbKhkBTSJ2rfC6PxUdwSWGer+xdGhmtDOgD5BI5+F1T35FzUi9iTs0WmMlY6Ce08ALDB7PWLopaku7STvSF234obbmAXq6Qd9S57A== 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)(3002001)(3231311)(944501410)(52105095)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:VI1PR05MB4192; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4192; X-Forefront-PRVS: 07467C4D33 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(346002)(136003)(366004)(376002)(39860400002)(189003)(199004)(6862004)(105586002)(316002)(66066001)(2616005)(14444005)(52116002)(118296001)(106356001)(47776003)(2351001)(51416003)(478600001)(186003)(486006)(956004)(476003)(11346002)(386003)(53936002)(25786009)(16526019)(446003)(97736004)(6666003)(8936002)(6496006)(81166006)(6486002)(81156014)(76176011)(6636002)(8676002)(48376002)(37006003)(50466002)(36756003)(16586007)(86362001)(58126008)(68736007)(26005)(305945005)(6116002)(5660300001)(3846002)(7736002)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4192; 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; VI1PR05MB4192; 23:Km2FVM/0rVRFtLXIOqMUOkC8C43If/1rDpM/suUy/?= Y35RfJo1B8ua2+Y0QGZjq8HivSgah8h/eR7JBDKYrriHFvCsb7GTnb/hdQJ2m/i+/sAlTv9+AgnXfj3z4aEFG55eXvwejkvGhkmCxPMXv+dpA15nWejoyMulSn4TNcXA8BaUPvrWfl0gmexRgVuD6Q7BphnP3HqIrnP3EeP3OS7Icp0CVuN9sUZ2lzfCSpKfSgX3sL6AGU4lfWVDDIwUn8bqTl4ogzb55gV160229RTg8rv4MKi6Z9WEtkIHQ3DupWxmfpVfRJjYtZSSv91o+o8g8xg08bmn04ejtQwQDS1iArJrCZHu9kUDsqk5owBJBFIv9uIXxkJ4uiP/Q8JVNTziZAFpZ144+J8LOXX8nkkEPW/lUlPu2mc19m+ywRiO29aZzk4F+YPuQ3n0qQllgJ8ghyrpsAY9pWH75PU0a33L2v9TfN9GQHSWrjqUUc1XXgC8HE22pyh4h13b/EiEGdliKfL4Zv/dgVdMws2mxLRphsQI2764oOreiiL6r4qwab9W8C72/xJ9OKe8AI+ASECWEv6juxXxBbtvwFi8zNU5d6pBZUOKAiSwtJD9CgbUiiXAMaVwYcS/il5s71BdU9Z9XHZ27MJU5a2fsoFXPtb/nyTHD0QDU2yjEGChvck0Ou0TAezH1D0/U618QnoZF+D8E0DXmF8RuhjozlkgnNUrnd7VU2p21xQbCykneyiUJy1wogHzIL+2cdO7OC+uvRKdNEST2P6i/GZFGD6VJtnhJ/uzTQAfrGwiWKI4fcDwfyRbhLqMA9pm9j2dm0ohMknEL7VEf4Q+KHC3ZScPRHsYAmjQYN6h/d+6vzY+ikeqbmiqaWOGVJ6Jimzt47977cqTFAct7tbfzMM7eSUSktdRz0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by97Y2yaFHa+VBPsVMd0/fVmMc9PbQAXfElg9q9h3l31Vw4IoD+Dmq5gOQZg1HPKCQAPgboxFRbkWHKZCtiFM0cz0i0wlj5j7oksSFINvSFvbKYRpPZsNQsJ2SiXiqVItEZYFXTIvERWXHw==; 5:y/fPbQTz7SGlPFlEv8n13N2T36JUHl5QzOMWfmiT/3bd4j1wZxPZdPdSBpxDizILWpOmnVwg8VjMl9LZlf0PklxkrcBjij7UqsEuBm7ihHPRwHxROolWUXJMjW9QmF7FuERBp1emWvnYpWjZ0WMC50pMg6EnmHlF5vyTCj7mf9E=; 7:rEWnq6g5czFh3apT/I8gVZYgKcGXGWqcBLg16IPKacanv9vdBjVbZSIbV4x0Sd39AGNLVWGZtmOBIDTT3FEFIGETah14GsI5ddB3aUOZhl0MZuuO0r38q+yPSjzSxzOZf+OTlvqJ2U1oWSe2eIZOcW5wq2tTgaWGTukM/bDGE8KiygOfrcdEj1QO+G+e3E/rBFco1rX3PxGzZnNV2o8VelD3/WQs9C/VDFEY1K6wTFuESfRB7ce1wjd7pFG4NlIC SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2018 19:11:10.8189 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e6c50728-5188-4011-dacb-08d5f3f4b703 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4192 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 This sysctl setting controls whether packet priority should be updated after forwarding. Configure RGCR.usp accordingly so that the device is in sync with the kernel handling. Note that RGCR doesn't allow changing arbitrary parameters mid-operation, however "usp" is exempt and can be reconfigured. Also react to NETEVENT_IPV4_FWD_UPDATE_PRIORITY_UPDATE notifications that signify change in this configuration. Signed-off-by: Petr Machata --- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 08b105bfb65d..3a96307f51b0 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -2402,6 +2402,18 @@ static void mlxsw_sp_router_mp_hash_event_work(struct work_struct *work) kfree(net_work); } +static int __mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp); + +static void mlxsw_sp_router_update_priority_work(struct work_struct *work) +{ + struct mlxsw_sp_netevent_work *net_work = + container_of(work, struct mlxsw_sp_netevent_work, work); + struct mlxsw_sp *mlxsw_sp = net_work->mlxsw_sp; + + __mlxsw_sp_router_init(mlxsw_sp); + kfree(net_work); +} + static int mlxsw_sp_router_schedule_work(struct net *net, struct notifier_block *nb, void (*cb)(struct work_struct *)) @@ -2488,6 +2500,9 @@ static int mlxsw_sp_router_netevent_event(struct notifier_block *nb, return mlxsw_sp_router_schedule_work(ptr, nb, mlxsw_sp_router_mp_hash_event_work); + case NETEVENT_IPV4_FWD_UPDATE_PRIORITY_UPDATE: + return mlxsw_sp_router_schedule_work(ptr, nb, + mlxsw_sp_router_update_priority_work); } return NOTIFY_DONE; @@ -7356,6 +7371,7 @@ static int mlxsw_sp_dscp_init(struct mlxsw_sp *mlxsw_sp) static int __mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp) { + bool usp = init_net.ipv4.sysctl_ip_fwd_update_priority; char rgcr_pl[MLXSW_REG_RGCR_LEN]; u64 max_rifs; int err; @@ -7366,7 +7382,7 @@ static int __mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp) mlxsw_reg_rgcr_pack(rgcr_pl, true, true); mlxsw_reg_rgcr_max_router_interfaces_set(rgcr_pl, max_rifs); - mlxsw_reg_rgcr_usp_set(rgcr_pl, true); + mlxsw_reg_rgcr_usp_set(rgcr_pl, usp); err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rgcr), rgcr_pl); if (err) return err; From patchwork Fri Jul 27 19:11:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10547643 X-Patchwork-Delegate: idosch@idosch.org 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 69B31112E for ; Fri, 27 Jul 2018 19:11:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56F152C4AD for ; Fri, 27 Jul 2018 19:11:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 550952C4AE; Fri, 27 Jul 2018 19:11:32 +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,LOTS_OF_MONEY,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 541042C4C1 for ; Fri, 27 Jul 2018 19:11:31 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41cdqP4wcQzF1C6 for ; Sat, 28 Jul 2018 05:11:29 +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="VECbNtEB"; 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.55; 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="VECbNtEB"; dkim-atps=neutral Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60055.outbound.protection.outlook.com [40.107.6.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41cdqH3C0ZzF164 for ; Sat, 28 Jul 2018 05:11:23 +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=qX3xxYzGEf/fW06BPqSVntKls0heCHSlDU6ykrBQDmQ=; b=VECbNtEBI0EeBtiXuMf70GPAzZFSYk0YbbdCR5/TdDlzMa9TK+/RNMgiYpwACiQXc+D8m684sx3hHWRYNZqXy5GIoVQ/ZYDER8wRdwAi7+TruNj3UrZMAmyDUTyjoemronBjXa2gneHbIikVKjr4ywBpkAVNXRu6OStxqlTuhIM= 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:11:17 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw 4/4] selftests: mlxsw: Add test for ip_forward_update_priority In-Reply-To: References: Message-Id: <42ff6b9374ab214d15a72d55933d7e6d7a84dc8a.1532717939.git.petrm@mellanox.com> Date: Fri, 27 Jul 2018 21:11:11 +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: HE1PR02CA0109.eurprd02.prod.outlook.com (2603:10a6:7:29::38) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b6272d72-1692-42d6-a74b-08d5f3f4bb64 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:M+6u9NFefl3eV79XMJ/Ehdxs5rtZGn+vzxqyvytTv5I4mySoM3ULbdX723Ulfw62TjUIwF1YtmkdQiVuhH1/VrljLHm6Jl283VerO+fnebTccpZr4o9DiEJbtqk1OVZjG0jueT8olcy4EPwswUMpo4Y8PYSnMeu2ZEdcBTnbYhQCRRDRKY7Df9G3gIAjHbafLlMtJaE87l0BVzj/sZUSP+BY963jhXA2fr5NEx0Yv6kWeF34MExfErndHYP1sUUX; 25:PCZH+PMGSmxuJrVsiPWKSyNAB2s6bhhvfIANQ20aBb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FBkS13HCpmc7uaaKmPeIfSuZg1i5fu5Y6hlF368u; 4:5owYG9AwQQcwmjli4FMwxcf13V/DiO4UJ8voL20TAHmnhyw0VFt3fovSkoWtOAaXIrva5QIhPi+tMwcrLxOwcl8YS62nnuJmzhnQCvYs8eR21+x5Su5U88oXThQQ961I9N+I1eitYpyAMdSlhlvHRiaUBSVjtoi5/O75iF5AF4qqT3/EXy99rmzemy6bwyjRNr1xKQvHrnsdPje/uj3jBgK6+Hl7T8PMA/NVO4gFqSsFb2X279uh3yL/jF8+GGJPRQGjFsx7+uYK1JpL3dPTDA== 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)(11346002)(58126008)(186003)(16526019)(446003)(575784001)(86362001)(37006003)(386003)(26005)(14444005)(51416003)(76176011)(6496006)(50466002)(48376002)(97736004)(6116002)(2351001)(25786009)(7736002)(305945005)(3846002)(106356001)(316002)(105586002)(486006)(8936002)(118296001)(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:NrufsyHVdvESe+38Tmo8aBkDC9x52+vQYs+OOXir3?= bJsrETEsaHxmskVV+520ayun3w9xYovtH3lY1v6jKz3unrlnf5S7poObVVKueX0Z9/BR88+Pq0CW5QoHZJJCowMgU1aqKPqt5Fb3ExxX6rR91pdJqNwayMr9bVx7yCNvItTzj/HGvCh1KpVmw94sEaJuxJCwfAX9g+Hn1TNY2UCZdGY9oKlVf6+s6PZDZDjsS28mZ9156Ub4qA5NWQm9iSvL8gfpNou7FTFp/yjlUDQc5FiFoXOZT7/ecnNPZ5dt3oM8rpSj/NdOc+67S1y3qOTbdVSFRRiOeOOFCvUoOO5ydDKsRCnSpGI4EZW5tsqBv2UqE3iyRGlPYzY4vxiBn+n2qUHG+THGkAr8BYR+Y+ndj+hnjQYgq3yKIoXnoTFGrOrZR2trbDnZzSedu0qmEx5AjSe+BVMhUAdiaMGfEBQNlDIEm3U/ceejD+5aqAEU4Hs7DpwmWgu8vppaeRVCw0iAWvQIZM2QWJ7+jtBgUdpY1wCD0RGO21zZhWpbIX27bfHnUfKoDbizqcfJaUA41/TO2Uta8GKkbefjvTWSGT/xfe+irDr2P/YoQtgrEGQ6IYunSMlXOku3kc0fS80HpeQr03v0nY37oiD3luWUrM+HISjeJfM4dh8/MNEwAjC50ylpsJsr38qLCdDvpXbhDhm9ooJpGhTu7GKvsEILKI74XsF5BtwizKVYzGTwYwW5p5qRT12NAiX+DM7FXV4oLxmWT8mZw41M2rMIDCRRAOnNmRCPBrx4550XavT42sR62wKu3YYhXiWzT081mVfMNKIylkFiSsk+EkFsdEy7Te6NPvvrQt2coHHxIFmwIbH5NVgS0chFNR4kRL2QlOFkWPIOeyzqb+SS4/tjhjaZlnWgJcwnGdT/ABpXZXebFx6GqyqFZ8yzQol3Xb+aVCnZ8egRiQDrt59lyVXPFwUjZEPV+I3JDXe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fhwG+yqXCgNg91nLrMpBn/7y6T7lhLcZXFQLyQiEjPOI+IPtDakg4sCGKHt9ORJ0RghuQrlTs+1sRozjSjA==; 5:tyXxUwB0kfXGvrIAEhbziZmj6ee+CxOcQpFU56d0ZqiUIPJZidxrkrHIa017MyyNB7fy/kDwxGIy3X3VpN2L8rqLwqgAyyGI+yxhTXvBtDgUMI76DLAbhhJarn6Yh8X9x3FbeX4ATDXr5dJDUc8gSheXPv13i0kde9o/S7LWkYg=; 7:pLHZC5I8tNfF8Eo2q5rAKWCAMfnMnw2yh+HTXEgh/wk2EdqXIr5bjGvjo8iB2bFrOxOEB9aw4LARBCFVxnm33yZwjZLf+iAA+LYDdYRSpALpziRbsj/SwnGU5Ue7aNxdZxGb6czcEmxhUUXIzX1S1fc6VZyfQxJkvs8fvSLKaskkdnADKYaEh9LOYxA+RNqUx3FyVsS/MkO81J1S834Uq6P2oL0mZ4r3uMMRS3Ni6FV3nI7keAAqdDbDaAIU3wBY SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2018 19:11:17.9767 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b6272d72-1692-42d6-a74b-08d5f3f4bb64 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 Verify that with that sysctl turned off, DSCP prioritization and rewrite works the same way as in qos_dscp_bridge test. However when the sysctl is charged, there should be a reprioritization after routing stage, which will be observed by a different DSCP rewrite on egress. Signed-off-by: Petr Machata --- .../selftests/drivers/net/mlxsw/qos_dscp_router.sh | 233 +++++++++++++++++++++ 1 file changed, 233 insertions(+) create mode 100755 tools/testing/selftests/drivers/net/mlxsw/qos_dscp_router.sh diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_router.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_router.sh new file mode 100755 index 000000000000..81958cd89f13 --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_router.sh @@ -0,0 +1,233 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# Test for DSCP prioritization in the router. +# +# With ip_forward_update_priority disabled, the packets are expected to keep +# their DSCP (which in this test uses only values 0..7) intact as they are +# forwarded by the switch. That is verified at $h2. ICMP responses are formed +# with the same DSCP as the requests, and likewise pass through the switch +# intact, which is verified at $h1. +# +# With ip_forward_update_priority enabled, router reprioritizes the packets +# according to the table in reprioritize(). Thus, say, DSCP 7 maps to priority +# 4, which on egress maps back to DSCP 4. The resonse packet then gets +# reprioritized to 6, getting DSCP 6 on egress. +# +# +----------------------+ +----------------------+ +# | H1 | | H2 | +# | + $h1 | | $h2 + | +# | | 192.0.2.1/28 | | 192.0.2.18/28 | | +# +----|-----------------+ +----------------|-----+ +# | | +# +----|----------------------------------------------------------------|-----+ +# | SW | | | +# | + $swp1 $swp2 + | +# | 192.0.2.2/28 192.0.2.17/28 | +# | APP=0,5,0 .. 7,5,7 APP=0,5,0 .. 7,5,7 | +# +---------------------------------------------------------------------------+ + +ALL_TESTS=" + ping_ipv4 + test_update + test_no_update +" + +lib_dir=$(dirname $0)/../../../net/forwarding + +NUM_NETIFS=4 +source $lib_dir/lib.sh + +reprioritize() +{ + local in=$1; shift + + # This is based on rt_tos2priority in include/net/route.h. Assuming 1:1 + # mapping between priorities and TOS, it yields a new priority for a + # packet with ingress priority of $in. + local -a reprio=(0 0 2 2 6 6 4 4) + + echo ${reprio[$in]} +} + +h1_create() +{ + local dscp; + + simple_if_init $h1 192.0.2.1/28 + tc qdisc add dev $h1 clsact + dscp_capture_install $h1 0 + ip route add vrf v$h1 192.0.2.16/28 via 192.0.2.2 +} + +h1_destroy() +{ + ip route del vrf v$h1 192.0.2.16/28 via 192.0.2.2 + dscp_capture_uninstall $h1 0 + tc qdisc del dev $h1 clsact + simple_if_fini $h1 192.0.2.1/28 +} + +h2_create() +{ + simple_if_init $h2 192.0.2.18/28 + tc qdisc add dev $h2 clsact + dscp_capture_install $h2 0 + ip route add vrf v$h2 192.0.2.0/28 via 192.0.2.17 +} + +h2_destroy() +{ + ip route del vrf v$h2 192.0.2.0/28 via 192.0.2.17 + dscp_capture_uninstall $h2 0 + tc qdisc del dev $h2 clsact + simple_if_fini $h2 192.0.2.18/28 +} + +dscp_map() +{ + local base=$1; shift + + for prio in {0..7}; do + echo app=$prio,5,$((base + prio)) + done +} + +switch_create() +{ + simple_if_init $swp1 192.0.2.2/28 + __simple_if_init $swp2 v$swp1 192.0.2.17/28 + + lldptool -T -i $swp1 -V APP $(dscp_map 0) >/dev/null + lldptool -T -i $swp2 -V APP $(dscp_map 0) >/dev/null + lldpad_wait_set $swp1 + lldpad_wait_set $swp2 +} + +switch_destroy() +{ + lldptool -T -i $swp2 -V APP -d $(dscp_map 0) >/dev/null + lldptool -T -i $swp1 -V APP -d $(dscp_map 0) >/dev/null + lldpad_wait_del + + __simple_if_fini $swp2 192.0.2.17/28 + simple_if_fini $swp1 192.0.2.2/28 +} + +setup_prepare() +{ + h1=${NETIFS[p1]} + swp1=${NETIFS[p2]} + + swp2=${NETIFS[p3]} + h2=${NETIFS[p4]} + + vrf_prepare + + sysctl_set net.ipv4.ip_forward_update_priority 1 + h1_create + h2_create + switch_create +} + +cleanup() +{ + pre_cleanup + + switch_destroy + h2_destroy + h1_destroy + sysctl_restore net.ipv4.ip_forward_update_priority + + vrf_cleanup +} + +ping_ipv4() +{ + ping_test $h1 192.0.2.18 +} + +dscp_ping_test() +{ + local vrf_name=$1; shift + local sip=$1; shift + local dip=$1; shift + local prio=$1; shift + local reprio=$1; shift + local dev1=$1; shift + local dev2=$1; shift + + local prio2=$($reprio $prio) # ICMP Request egress prio + local prio3=$($reprio $prio2) # ICMP Response egress prio + + local dscp=$((prio << 2)) # ICMP Request ingress DSCP + local dscp2=$((prio2 << 2)) # ICMP Request egress DSCP + local dscp3=$((prio3 << 2)) # ICMP Response egress DSCP + + RET=0 + + eval "local -A dev1_t0s=($(dscp_fetch_stats $dev1 0))" + eval "local -A dev2_t0s=($(dscp_fetch_stats $dev2 0))" + + ip vrf exec $vrf_name \ + ${PING} -Q $dscp ${sip:+-I $sip} $dip \ + -c 10 -i 0.1 -w 2 &> /dev/null + + eval "local -A dev1_t1s=($(dscp_fetch_stats $dev1 0))" + eval "local -A dev2_t1s=($(dscp_fetch_stats $dev2 0))" + + for i in {0..7}; do + local dscpi=$((i << 2)) + local expect2=0 + local expect3=0 + + if ((i == prio2)); then + expect2=10 + fi + if ((i == prio3)); then + expect3=10 + fi + + local delta=$((dev2_t1s[$i] - dev2_t0s[$i])) + ((expect2 == delta)) + check_err $? "DSCP $dscpi@$dev2: Expected to capture $expect2 packets, got $delta." + + delta=$((dev1_t1s[$i] - dev1_t0s[$i])) + ((expect3 == delta)) + check_err $? "DSCP $dscpi@$dev1: Expected to capture $expect3 packets, got $delta." + done + + log_test "DSCP rewrite: $dscp-(prio $prio2)-$dscp2-(prio $prio3)-$dscp3" +} + +__test_update() +{ + local update=$1; shift + local reprio=$1; shift + + sysctl_restore net.ipv4.ip_forward_update_priority + sysctl_set net.ipv4.ip_forward_update_priority $update + + for prio in {0..7}; do + dscp_ping_test v$h1 192.0.2.1 192.0.2.18 $prio $reprio $h1 $h2 + done +} + +test_update() +{ + __test_update 1 reprioritize +} + +test_no_update() +{ + __test_update 0 echo +} + +trap cleanup EXIT + +setup_prepare +setup_wait + +tests_run + +exit $EXIT_STATUS