From patchwork Tue Jul 31 09:56:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10550547 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 2F0DB96FA for ; Tue, 31 Jul 2018 09:56:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 167822A583 for ; Tue, 31 Jul 2018 09:56:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 089822A64D; Tue, 31 Jul 2018 09:56:18 +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 66A6D2A583 for ; Tue, 31 Jul 2018 09:56:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731350AbeGaLfp (ORCPT ); Tue, 31 Jul 2018 07:35:45 -0400 Received: from mail-eopbgr30076.outbound.protection.outlook.com ([40.107.3.76]:2800 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729784AbeGaLfp (ORCPT ); Tue, 31 Jul 2018 07:35:45 -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=GnxTotn+YN8g2t6ttt7rTbxME9SOAlGIn5wyp1AGiMQ=; b=a2gCQ5kZrvCIcWOvBVF9rYDIos9z2uieqQWyvTFcWl6URt4YrDT/5/ViUEtinF8l1ibObEESnwA5VVruXUp4uCANn9tpPLQYmPQpTtMFTtAPQUA4Vbl2l9Of4bHt87wgCUhjhhgFEkFx11mkZKASU438dIaMJDJ9Ox6vIambN0U= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) by AM6PR05MB4181.eurprd05.prod.outlook.com (2603:10a6:209:40::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.14; Tue, 31 Jul 2018 09:56:08 +0000 From: Petr Machata To: netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: davem@davemloft.net, corbet@lwn.net, jiri@mellanox.com, idosch@mellanox.com, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, shuah@kernel.org, nikolay@cumulusnetworks.com, dsahern@gmail.com Subject: [PATCH net-next 1/7] net: ipv4: Control SKB reprioritization after forwarding In-Reply-To: References: Message-Id: <56e17ee7750b89ff350735ff7cbaf14c63864586.1533030830.git.petrm@mellanox.com> Date: Tue, 31 Jul 2018 11:56:03 +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: AM5PR0701CA0021.eurprd07.prod.outlook.com (2603:10a6:203:51::31) To AM6PR05MB4181.eurprd05.prod.outlook.com (2603:10a6:209:40::26) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b5fe9f57-48f0-407a-e876-08d5f6cbd6d3 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:AM6PR05MB4181; X-Microsoft-Exchange-Diagnostics: 1;AM6PR05MB4181;3:pZ0OjXxYzOR3jwnn4vAK/85hDMYYbulbZhzufTIR/ldot7IRMtkAZqMsszhSMClAVfyLd2IoyXibIjGw6dzWBeIlEB+Ltbf/XpzithFZt3ORth49/gtbGW7PjEfcu/NAyeUG7Bwifdt2731traaL3yuxX3bu4dt2FEqYAS2zWJ+3uigHbu9y0KZ8Ihu83mEtoYfZVYVWiGSvKy8aqhlykL1gQQdBykcJILrPV0Hpv+v9lps5FIKb9DXRCgvSFbRN;25:XBWLzXr5Pe/avlaaBHcR9baWBs0a+kqVGNwOdJIGsbP/7H0psxfQOVoWc/dzco4+0ZIgrPTcJGwPUY8WY/7n3ZL8fm3wQyz/SAQhIM44AUGfu05nRgLdfOOWE4jt2VePor2DDlswAjw2JLxJpwFURHhmROPBwcT0PTZTuE5ot1xNUoQau9fKtJlvIS/pk+onEGuIFsm1t0/nQQrUcCxu4H6RrDsSprm51X0ESFUFlywy8sYuswkup8LbyF34uJlzsOPTTSnCLVev0D8KwZijdSefUoAaZ6U/eBavBrtkrWsWt33pWKG4Q5040BuHbRRPhUsaYaR+ABNrkDxnpi2k3w==;31:tTGhqsQQ2iR8+P1G78FhUBm7nPh/zWd23FyVJoLdXx72J7eyMO2FCEXO+xY+S/W+/UyNohHeSpuzFahuqBnnveThHZfd45TxPxkrvOuDd673DxDcfkGe1RnmhvbvbhK3GufFvItOvbhRUnu4e6Jrl6eL/4D4r2ufAQQD0YRBiKtqAHbZUA/8gSsPcWfQi92V6VZYlKD+dDXu+cWyKSUAdupZhtk+J/WxBF2tRBtO71U= X-MS-TrafficTypeDiagnostic: AM6PR05MB4181: X-Microsoft-Exchange-Diagnostics: 1;AM6PR05MB4181;20:ACgZucd9uZ3mUI0xA8JI1SQOdPVQQ2r5BCr+TBNJOd+H52wDtHTIfy8hi/810iw4bD5nsqLA0OQL22xOTjAS8abzjTrrvIklYW9TExw+Bv11i49TzgRjqlcSGEcMLXfRItFMxZ+EY1fvFvZIabOdqX4CsWNMBLkFA01GU3MLL+CFfu5GnkRUTNcOrIzKQmyjxb3BEn9RT2ib242wLDDmc41s5U6vqiNEf7bgG97h2dnhF7y3+GmIdfWIJkIai1UDOS9GaqGhBsWPG7Rl0SlH3KynKdl39ENARVu+YEKbSqe3tHZUE7VEjLexdKVRvtJv8xifZnH7DckKezdtXWdHgUSmVRukuFbdGJXNZnHj6Ys9CT2lSIHDw0+O0rETCJAssLpn6MNBtnjCu3Igt2kpd5t4cvcMJcAd7+/xBigT643z1sDWxcVKE1vzhpiLS91aY2GZ5NyKdB7ws9gVilegwE7QsVuaq/iA8zmJVs1Doa0hc0fxoYAbmbQ0ic0fdwgT;4:2PVgViffXe9h8QsFPqWHcrdPqA3aSs9zhynpcXgPPEl2i+y+PbUeh42n67Gt4wm0wQYG9Zn+PPT9+V8HIQbjxHs5FNjQGG/jk5GvbK+EwC6Grq0hMxdcdR0Q6wKERj7f0EhHaDWiXuqDoDp0pmkqwqJjc2G8H4qnwVLIlDGUjJ4WoMQJon04Pph1aXRq2GSfWF07ea5y3sAD7p/AZ+JniPHxm9fn4snuSj+Wcc1S/MBh7my/qDDkZ3HDMlvfRRmg7yZAgbnvvdlA7EykypSC9A== 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)(3231311)(944501410)(52105095)(3002001)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123564045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016);SRVR:AM6PR05MB4181;BCL:0;PCL:0;RULEID:;SRVR:AM6PR05MB4181; X-Forefront-PRVS: 0750463DC9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(396003)(376002)(39860400002)(346002)(366004)(136003)(199004)(189003)(3846002)(8936002)(478600001)(6116002)(68736007)(81156014)(81166006)(8676002)(16586007)(58126008)(316002)(118296001)(97736004)(2906002)(305945005)(7736002)(25786009)(6486002)(39060400002)(7416002)(48376002)(4326008)(50466002)(6666003)(53936002)(5660300001)(14444005)(51416003)(106356001)(105586002)(52116002)(76176011)(66066001)(47776003)(11346002)(446003)(186003)(26005)(386003)(16526019)(36756003)(956004)(6496006)(476003)(486006)(2616005)(575784001)(86362001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM6PR05MB4181;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: 1;AM6PR05MB4181;23:0UCqS/ISBkWCj/cIABB1sMKmW/VjLWmrS9ZYmZRaraZXFMck9rzSLDwq8CVMuA0LCvt3u8zJr57sXTOVlzACeTJH9X8VdjAAMbJO1FUe64xKp7BAz6W9qsRjkCo0eFBq7CSx1mc65CKBBGkT1Zsm2jM2uuK3i3+gx8dOtne7MRczAVDV5XIrH2ZhQMyOJv8q7vs4QWjZYEl1871LdVjMfKh1kg7SebukIoI7C5hugvfrAwH947MUMUIJ5rQRaTCbg1Q0lYU3/Aj9LHNGuhP/LY0w51kbLfhfSzIsPyzaxRT5TJcaUTEA6xHI2VRY0/Vi1NuTBDDpFP0m8iQm1qjBpR0BBNcW0+SmGbPRCXGcdMWGVyvj1WuU6daPMweinaDuVljQ2QrkPeQ0AdToYAQBnuE8xRTHAnq5G2PlXfEc+6C5AY38OG3eu+rTqTeNsPHbHohFOv4dVh0esLgD+pvnC37+ygmW1u1wVtQioXJHFFmawiwFTazDAlM6kg4ooJZI9UBLXeEKKj/A+Bl7zJi1lHPs/AEEWHWzzW4RLmfCIfpsGVvb78qrI9lQqHQVa3TR5QZj4rui6H3JTeZ1sPnzbiQHaAgGRcOxoXTUiyyeVLRhxb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UNNp5uTBsKvz2burYFmeSRZF8GF+waApU+QMoN5w9hChVmO4ojWoUqD3NZjMA0phXdejssDRxQVEdO+Ayw7bsuqmEskVGvyfkv8E4MML3AnSrcmiU6GcuraU0OXOrFqrTq4/J74MBknEFvt063MAmUq0TteDipj5w8HK7q8xd884eOcntWoQRtLb0zjZnaoEwh0lmYkvDmGCHUbKOm7RoKRROek4vZy6v5BMljAjb7qxC/0rH3mvJkZMXZcW9AfudvI6J7QmJFczt3OeV7adD9xsbk8psm/3QL535+dRZprD2VUNKJGMX+8eGIr19y9nCcVaSHeYLACxdAKGTe48xrxTqCTCMJiSHk0ZvYyHuqXl5q2plCbLsBcDABjdS1PiyqIfCf+lcGVydVnlY2h7TJCvHjahEhkwx6eXLhE6TV7Qg4UTbYpCLpFe3v58u2giw==;5:lns9LxljILmxyxMBH4Yu9xbjNfdaBzgZdyo9dwmYtlt7TEsecF37TQ7jY4Cd/MdeO5Zc+02X2tm0+rMQOae7naJhaAJlHsBZiKy4q1dCbFucokCRydObi7h2P+hV8zJNB0clly3IqSRBWigo+B7WL48aunHcu+WEmg1JvjwOZP4=;7:OeVTtmfuYIq4z3bydGAgkOxnJuDaP3YEyrL3fIwOi9oNINtpycpQ7e5bo4aYJ7NqsJbIXYslD5WeY5TRMMFQbPGWAHGH+yJaQs+rrBZ9afBIjLRTHuvPdQWcrNZBlcLgoneDIwPchsXHvsMhkcjhe9OTvyfolrOnyHW1V1xeOP734G7CojbWNXHyVNdMDL6sr6VlDmg3wPavp4RgBLJfjY4ADTsdZrRukMxM4tLxmxyJjhd/8bm3xaeyJ/LR9PqV SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2018 09:56:08.0224 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b5fe9f57-48f0-407a-e876-08d5f6cbd6d3 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB4181 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 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 Reviewed-by: Ido Schimmel --- Documentation/networking/ip-sysctl.txt | 9 +++++++++ include/net/netns/ipv4.h | 1 + net/ipv4/af_inet.c | 1 + net/ipv4/ip_forward.c | 3 ++- net/ipv4/sysctl_net_ipv4.c | 9 +++++++++ 5 files changed, 22 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/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..e21dda015513 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -664,6 +664,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 = proc_dointvec_minmax, + .extra1 = &zero, + .extra2 = &one, + }, + { .procname = "ip_nonlocal_bind", .data = &init_net.ipv4.sysctl_ip_nonlocal_bind, .maxlen = sizeof(int), From patchwork Tue Jul 31 09:56:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10550549 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 C02A8174A for ; Tue, 31 Jul 2018 09:56:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A73BE2A544 for ; Tue, 31 Jul 2018 09:56:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B9462A5D3; Tue, 31 Jul 2018 09:56:23 +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 21A1E2A583 for ; Tue, 31 Jul 2018 09:56:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731503AbeGaLfw (ORCPT ); Tue, 31 Jul 2018 07:35:52 -0400 Received: from mail-he1eur01on0045.outbound.protection.outlook.com ([104.47.0.45]:62304 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731500AbeGaLfv (ORCPT ); Tue, 31 Jul 2018 07:35:51 -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=efwbVaSQFR5ERFmo1RdtxQiWHzsNe1jz5NOKb1E4snA=; b=RYRjRW0p+iBmH+jA/QAkUkBySQgsBWCK56cybz/qN7alP9c88IwOMrTJLAHDo8b4G2n8oguyzy4OROsuqDxzQb60kd8F56VJ3/NhJeFsZRryE9K5nYzTcuSrQJ/ofiLyURdyIOjgUQUs4k3onM9/oPVO/uDFTVk77yvgFfbBwcg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) by AM0PR05MB4178.eurprd05.prod.outlook.com (2603:10a6:208:57::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.19; Tue, 31 Jul 2018 09:56:14 +0000 From: Petr Machata To: netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: davem@davemloft.net, corbet@lwn.net, jiri@mellanox.com, idosch@mellanox.com, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, shuah@kernel.org, nikolay@cumulusnetworks.com, dsahern@gmail.com Subject: [PATCH net-next 2/7] net: ipv4: Notify about changes to ip_forward_update_priority In-Reply-To: References: Message-Id: <849e91253d822f6f37aee1688167de08418ce1b6.1533030830.git.petrm@mellanox.com> Date: Tue, 31 Jul 2018 11:56:08 +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: VI1PR08CA0132.eurprd08.prod.outlook.com (2603:10a6:800:d4::34) To AM0PR05MB4178.eurprd05.prod.outlook.com (2603:10a6:208:57::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 90dd4098-ed8a-41ac-21a4-08d5f6cbda64 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:AM0PR05MB4178; X-Microsoft-Exchange-Diagnostics: 1;AM0PR05MB4178;3:/N8FCTQ+meChfYGDrhvAJqHSaoKct9Ob+6JuOCi4EaTXH6ClchQX5okB5kpzSZk403PXKd3ZyBuM55SGqx22gZpeO78dkmCXmF1OL9lP9P893gzOTPJin4oWTsoHcGPNJLcRQmBB0HF6zqzM7FkALMSLl+OKmFDEDRNUxJ0NH4ZAi5Alrn9JAcQMU3sfRwdQwZu5asbppiJp1PElFf/XvnNgvhLHbFKXlb6ghgcvde5wshNE0/Y7a6E89uZNPLQF;25:b7IiQvqPaxeDF3nkrb9fftQ4EN40NMRbkZeNS8ibtgTW7Mniuv/sIqWI5qZ+XkaFQNNkkwsGAVHk0Yk+5j51x0WpaMRlBG4k+rrQXyVEOYBuH6ti9SvWC9Nx6IRO0cKHr2Nrv0/FRuyLNQ+Wiw8ENeCGRyz7e6G6RaekMOFzTPELdwBhROMcDiZtbo+yfKPCd8GXiJU0ppPpXETsCEY2NQTa+L3DQ11e/vTxAi9HSqTH1j/bADmZ9VFB9UAQddxrUDM9VDXNJynTKabbLYBlCYvNhjedc/NNHhq/rY7xeBANqFRfrjRVDzaRsCruN+/b1/6mIGMrMVPqacf+Vu/CJA==;31:30SULn0J9bUmsXJRHHBzQxICvGo1PBcqoLVAjXuARkCTLegnWK2NUetxwRk2pRUkLsq9m9NJa0v+hRGrUPHmVEjCNx4zNlyofyFYgnTIltIBYIpNR/MJsrpkIMjm+Fb11jgukFPRjCbZgxjKWlEYjLk2PvfIP8B6zM7UfMp7dkk+NsnZgnt2fqfYKUIgNjASx8a651RSKezwbfrpRguSqxlOaMqJOR9HAzdlxs+uLec= X-MS-TrafficTypeDiagnostic: AM0PR05MB4178: X-Microsoft-Exchange-Diagnostics: 1;AM0PR05MB4178;20:Z3WKuCq/MgWy7y3YRu/FLkAQOd9qQFIuKhU7tbliNXztDdAdRgpYARqLvtiTMwjPBS0VyCn8rM0u7yaxUxAR0SBVju8gUbIPD8MQ5LMgAUU/VwaOXmx2Hj0LNZPW7W/kVsk/yY+Ik6gsSl428BooFMz0DL80s/nEWmke97ubfYAzX40VtKeLBw3Pyh1UWOdJP1zL248Z2zVJQ5pvGNpayTmVj+aDx+sAgmRlC1oWuBRFAS1nehGZs7v+2RwyZuE0gZneHzUv6pnL+cOI0ZmQSJaXCt5Tj6TPGo5Aa8ciRQ0Sm/i0ALJQ3oTKpWRY3Wqj7kj1fKyP4+Rzsk6gO4oNdNwos0Uz/G/6cdcHJn+ePMLyli2Ph6TZZChkx2jnWcmaefG8y3gH34RdnbfZGE35OmFZtZtj+68/JDysf0Aw1YRkKMZYQokZyYns+CJGHP5L51xOkL27Iqh91XrTPbHPlGdlBlewrrp7TVS0z3wUVqll7cnMyCd5TxCzVVsEpftm;4:DBVPwQ5YmnGIScepFUlUUkSC0RPLswEC/BYFkXjbcW7SEoRRqAqTVdgAzSBrIWmHqN5vvgXktOjSTkuMTuNUuc+SpDRUzaEEwImgsBw+NEL+QYBj3pSme9HvQvdLi7D0XVaRYdYuCik/mnu4BVu8mr42czqo5rWZP5d644BmV3XEUA6X4fflct/afjsDuIMTKVxhK96N6QmXVA9ROCRX7Zou0tZH1+WDMW3mPX8pVPM46oE233YfWYU/LLnW2bjTTtD3Tyq49Tg5nrUQ2D+DVg== 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)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:AM0PR05MB4178;BCL:0;PCL:0;RULEID:;SRVR:AM0PR05MB4178; X-Forefront-PRVS: 0750463DC9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(376002)(366004)(346002)(39860400002)(396003)(136003)(189003)(199004)(11346002)(39060400002)(106356001)(26005)(6486002)(25786009)(52116002)(5660300001)(7736002)(118296001)(305945005)(51416003)(316002)(76176011)(4326008)(97736004)(16586007)(6496006)(8936002)(105586002)(81156014)(81166006)(446003)(16526019)(186003)(3846002)(6116002)(58126008)(53936002)(478600001)(36756003)(68736007)(47776003)(7416002)(6666003)(8676002)(476003)(2616005)(14444005)(66066001)(50466002)(48376002)(956004)(86362001)(486006)(2906002)(386003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR05MB4178;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: 1;AM0PR05MB4178;23:gxyjFkEpasDlrIdi4Ge7Y1qzsH+GeDRG9aGEzRlqXuzvFGunE7eDsCk5XZdn3Z9vfOXz3mOZTh8AM+4SYco6HyqjqjYECVUndvYzyXwR1d5Ww1TPIM3GJy1Ih4ogs3tuID8GTvzARli+XZQzRQMH37CPksO1txuKeIYG4EeE7e8Ja4UzDTEsGZhizj9Sr9XbMOdRKRC7d9Ecg/zyO0bK88LGwseU8d8rpM8ZrQUFiXnLneR+fNIJEe1kOVvjBj0Zx2pkgQhGIOn/PkVTauBW+HrGy4L7V469Ik61KKIXAfnEnB4UcLnj1UoGFXjm4TTKEHSkhkjFBa3ET1uzR1211eji2OZWbc7WkLJ0KTsIPhVVuS7+/YeW8LANOoBb8q1mNOT1c82UcY89ywLFv/UErcZEz4dbadzFZwkjvozP9udsVe7QF2+cvFc3+bex7Moa1dui+89Ix/XzckVB+TXzqBZl6o0OXVTcMDzOlRAHUUvD0dIKQrmKuMQaoQK5uTn5E8t4vps+rrEoh0W8NSEA8IHp7OznNNY+d7kLpAm6yHZygGPX2MhUmkrHVWG+DILrS4QqYGgFtlFjnDRL5t2unHwOXL45Ec+DC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N/3nz6fGrPcBbEveGpuG1Zck+ts5GTLveiWqQjSIeLf1R6hCL8jiCm71DonnqN8hAQeCGOKJHAl1sz75DCPb4V46rxNxyB/QezgfxnGlZxp58RfMKEKIbNCunHkb3+km/5cc/2BOAbUtF6jaM/MUmh0tMr0KC1dZ85Tn6wJ69st1b4WAwtywI7g9lBk0qLi1BmHnD7KN1e+9GwDNIXFHzHnPJUfTFCXHARqM8GBjIBn6RjE45yku47GnYqM/2B3BRg9QOmkE+bRVWFXkCneJpbuOEgNc1ya3kzN6ieo1Sh15FE4qmqUUjZnRs+9jlQ0S7sXmoYR2gQ85v2wbKM48StlS9+qCnz0Mda+07ti2xesENhr446acg+c017bJvEvy8MxeK5dMrPkT8Nbojc6ELdhdB2aONDlAFo7ugrYYvpRGyoJQ==;5:Pu0OOViatc/XG8u3nh6JQoo3IWU2i2ECQgHg6zMJPliPzqskmj80e/jkeBXW35e78RJTPd5ArgBDjwXyI6A22WU1HqG1HmnmNLc+fLQldI+gapUoTbfQM2mhIAOL1+76Wx6RQrTlBWDpL0v9l6UuM+X3MRH6KTLWBLUcXkk4Iik=;7:DbSidQsOFjW8smDXbpPbU6uwFb0WvyJKeUF4UMpAxxp+rwT4nxAM26QCaUq9WHukFNIJ2LqZaabLnYbQxiKriYYAED24mitLBS7Aq/iiW6fqBP6LYmvvbjUlNSEW0BdDbfddZD9NCYWO4ZN/FE3+eymmsZyNZkXqlwbHjgAmpKFe3XgYU/3vmScCZ40NLyL1maanqcYTit91MVg/tZG7hVLa3innxp+eD8onRbgy8vq+yds9ewMG3vbaKkiuDNNe SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2018 09:56:14.0178 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 90dd4098-ed8a-41ac-21a4-08d5f6cbda64 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4178 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 Drivers may make offloading decision based on whether ip_forward_update_priority is enabled or not. Therefore distribute netevent notifications to give them a chance to react to a change. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- include/net/netevent.h | 1 + net/ipv4/sysctl_net_ipv4.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) 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/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index e21dda015513..b92f422f2fa8 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) { @@ -668,7 +685,7 @@ static struct ctl_table ipv4_net_table[] = { .data = &init_net.ipv4.sysctl_ip_fwd_update_priority, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec_minmax, + .proc_handler = ipv4_fwd_update_priority, .extra1 = &zero, .extra2 = &one, }, From patchwork Tue Jul 31 09:56:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10550559 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 A0E9A14E2 for ; Tue, 31 Jul 2018 09:59:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 866DC2A160 for ; Tue, 31 Jul 2018 09:59:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 796DD2A5DA; Tue, 31 Jul 2018 09:59:11 +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 ECCBA2A160 for ; Tue, 31 Jul 2018 09:59:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731722AbeGaLim (ORCPT ); Tue, 31 Jul 2018 07:38:42 -0400 Received: from mail-eopbgr20052.outbound.protection.outlook.com ([40.107.2.52]:7414 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731500AbeGaLil (ORCPT ); Tue, 31 Jul 2018 07:38:41 -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=Q+7zDaDa4aZRUfreGtDNo0gTDvjJg+wUkyXctYmIpRg=; b=VQ9Cbi/5trFVoOJBD7AtH1Lm3lScA7AKR+UH91MiiR1fGy7HM6UG3klzBdLgKYgVWOwxi3qE2WsrlxunDLqw634Ww1mRSMAmTMbyzhKIOexcWGDevghbKJS5FCh3ymLECYQzG+86w4EAV4CjYte1Ff1ggfJoKu86A+zXrDvCvnE= 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.995.21; Tue, 31 Jul 2018 09:56:20 +0000 From: Petr Machata To: netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: davem@davemloft.net, corbet@lwn.net, jiri@mellanox.com, idosch@mellanox.com, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, shuah@kernel.org, nikolay@cumulusnetworks.com, dsahern@gmail.com Subject: [PATCH net-next 3/7] mlxsw: spectrum: Extract work-scheduling into a new function In-Reply-To: References: Message-Id: <125dc1a81caedb1a705953602c625f0cef77328e.1533030830.git.petrm@mellanox.com> Date: Tue, 31 Jul 2018 11:56:14 +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: HE1PR0301CA0007.eurprd03.prod.outlook.com (2603:10a6:3:76::17) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b9300dae-5979-4515-061e-08d5f6cbdede 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:axswc8iKeqAIPl9Q24MGSCvxucEQBe063k3DOOB7vg+IN1olVUSjMCPJP+6EPIC99dI3u39ZbwLdq04N9jjFPJwcFl9idGF4iSCT5vGfitl3btZ8RNGdCcv/v0XH0Km07AQmeORHQSnseIJrnotswvtiBxMRHen5jdVi/+swEbsDEpbpL5kQIVDsvL5Qah4PL41JN86afnoAmuNMNZI+smExaEDQyW7eQl/EezOmh2fy3aLPsB94Vu05sl+Ur71W;25:4XC1eZns3u1P4cGu7HC0fgAVdIhhM1KBpkzon/bPDgi0IXXUnIsJBQa9kGme5avimfxPTcLz94nTBYEqraytjBT9D/yDRdyJm8S/Vog5XDLOi2CLHiM5vXVsOz2daMbMS4ES9yxCn9XavsMK4jW3tCHexo8XVROJasM34j1h83klKUG43sw5z77nslFYYUVA5xyWSviz/1uXDxqJupTAIVVL56rzoBo1FRSAsSYYiR0ie0pzPOGr0UK2mTb5i8h7JiIQxG8+KlaSAFeFK7g8p590riRzecrCa2zz+Nmn8TezCAPmh5jzNfhlo0DYTovs62QJ/xIvIZLxw0TS/+d+EA==;31:l+LSZGihBPZk+FAmvXpflSeDFfsfiTsVCSNGTcYAFwGRsY8b44p2v7asBSNpCTTPSy5BBbtLDnDnRfoxEni0JdV8OQILcDWrHCbgZQmzvjg9FoBl2O7j8R6au/EqSztofkmXcgoah+MAyqtzaD4cyVDTe6Vc85MFDaJMe6I5IGt/X1R2MTuCctG1LdOALaTFSg+UO/E/CIzchI3vVxShOIjifG/OcMdHHM1axqJshWs= X-MS-TrafficTypeDiagnostic: VI1PR05MB4191: X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB4191;20:bymF9uQbicvVfjfJgzK0c3Jbov5W25+ouwfk0nunGVGujAfm6qZQbNUsOHI8Xa0mH1CkD2BEXkmy/hAG+YKh75DkOoqTW01GYR8w7kYB9RnGXAs3d2t/Zi183+NOrAdj3EJ4b7RMLzPGLTfCpVL7r+3iFI82MBze/I51UwHuOt7dazriIGgffPhss9G5hL6ExrBZDO0xg5TTNo/a8d0ZWRD8ZS5YQMWZTxZW0Ifvu6jgnL4zkBejybvWWc7CmiMS92RRdwjG1YPB424IExol2Bs8vvyzSJ9jVJ5lVJuEXXUbUU8VreHZG0/Xv3o5c3qT2wducQ83Uz3uBHhVPUiSRauZhoryuabn9V3dj0sj5X6vBvY6/Dzp8r8aj1BG5lpwwTbRLjSpv1KOZLQxZyKkbnVuUJDL1rhtCRAZl+YtByw74Rk+IEcj8JZ/iQzzyVaOtTov9u19ZBYWv3ia2KbyT/JjwDyPPVFF648cBbtKHWUNEx5wSVeGKnoE75+Lgou7;4:0m7LhOSJB8gcOd05mG/5pexGWzkn4AmRIjh2RuKNDq/Ubm6XOAQKSvUqEoV/7pSDEs5Qfu9BWnetxG4XlLRKfMLAhZH7/NE8dxW+4ESg0pQqcEpbVwqF8JHiUJ05Sjct/V9BjCR2sr0+xOoLqrOo07mq2DQbRpmKALF6XOkC4yIauNORQLjhS4vcnkhLjDhy5/W4knn0uQNdVCJU52ey5F8glEc62n+w31jepH3aQ3shAzmreKl1CEminn1DCwo2UX1IjzTSEAsEA/6SN3weBA== 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)(10201501046)(3002001)(3231311)(944501410)(52105095)(93006095)(93001095)(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: 0750463DC9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(39860400002)(396003)(366004)(346002)(376002)(136003)(199004)(189003)(26005)(58126008)(86362001)(47776003)(16526019)(3846002)(186003)(16586007)(6496006)(478600001)(52116002)(51416003)(386003)(105586002)(76176011)(316002)(106356001)(68736007)(97736004)(11346002)(6486002)(6116002)(7736002)(53936002)(305945005)(6666003)(39060400002)(8936002)(486006)(25786009)(4326008)(81166006)(66066001)(2906002)(956004)(476003)(8676002)(2616005)(81156014)(7416002)(446003)(36756003)(5660300001)(118296001)(48376002)(50466002)(14444005);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR05MB4191;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: 1;VI1PR05MB4191;23:jrA+VcOyQzc2hn3oaTwWC7eHpAnXhkXFIcm9x9GcNfFb+KP5j+gdI30b7q/9S7zvFJGbP9Zlao5CLwOR/aZLCypngmL8wd/UWu3+bJiCxX6Dj1okzQ+C4YIPV3mPdVmu307fA0Vwn4KnzHE/isAWziZh8Tr85L05gQAhnP0qcdYL3zEVadheJIEhFXmUx7mk2v2mxO2G4KI87ixafdTWAZh/aeKvwqzLJtPKwTQSlGpwNSC2+H7MXfTnVDoW7p0rBp2kw++qbpROUjx0XYVTngEDEzDF5Z61M5JtFmXhfagw0X+HgjKB95QSuxVjvCFe8ly8IXF5biNHiTqCev5rNviq0D8pknMZzIae+5tg9ZKIhT1w80JTeG0vpCXkcc2MCg/3C+OncrCZPze3d/eICeMZK6gcEw77X15lM/HM3wOTgD8OLAeXq21Ot6Ozu+f2H/8e67kyIpKoETiEcxJqsgvlIwA8Z0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hFcZSy7r7f5QULpEYA6gJdiAOaSqYAwhizyaOQ5b6y8= X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB4191;6:NulpR08AhZod8JtsmklspzR6QJZFKlL7UCqtk3mZD1cLMoOHYBjiDPJyOpCjsTrEXyLR7+VudXccZ8JGCQ0Ihy0IyzpjTguvTOo45BYYpjBXhCTAQycg3m9t47nSEgN48ZdJeV199hAatt50BqF/jRgNHQDli9cCx6S9ZWT0bnIFpxKUM6CpoA5Tylckudg96snXl5/gluVb52cZ1QWI5BxBlldZdyqc6fXQkCYUpbb++jawgDn1wIBiOp5+QF8kNuyq942CzcxRacN4FofjsblwRUt/nQD7Sv+ASqP2YtUPXJ400LgqZ/Ob8Mycm8KOv51P0afMkB9OniVSW6Nrw7genx7pezFvp9ZZz4sM1LkfPgQcb6YM6SHTKuapKmUkrPrVDi5TcFrGJWOeFHM4whj3jL6/ESNmh5QKAVU01ben7wkUDqpMPtIZ9H1l291zjr3aL8g1hIbmNoCAGccVSw==;5:qHoWQf+ou5LVGSB0ev1TXl09xPmNqzG6Akwezib1DtJcQVW4VEmcUdPyYbe3A5xeJoSaDG943zzsQnJH01Rl1Cxoqlk6x0pCWI8+Kad1IDnaZtMnwM/4cHaScxalR2XzERKLfy1pFNrydScCNQ9UxGDXSFTz8B7mb9NpL4EuS2I=;7:d1lRqjfmTnQ/AefZaRvjc5hSwwnvGjPu7RVdCCeVDSveNXKzeE4vcRIFNvOUd01e5UaWy6nyG+6tknsM5D7670rvzgXe7uVx6nDrPmTg9MSju0PR8eLLkTXDAm8+ZLS3Tg3yDeDHTORMkzE2QBDPlPpEKRhqG4SylKsj+1U9NgW5Sppt1TlwOn8uA/xkjvZXNOGSMsgd6Nf86RZea27Sdzb5ugWJNzGZQ8G9XE/lPEgMP1mZfHm1crkPLc55De+a SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2018 09:56:20.6589 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b9300dae-5979-4515-061e-08d5f6cbdede X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4191 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 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 Reviewed-by: Ido Schimmel --- .../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 8d67f0123699..5ee927626567 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -2436,17 +2436,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: @@ -2500,20 +2519,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 Tue Jul 31 09:56:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10550551 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 EE4F114E2 for ; Tue, 31 Jul 2018 09:56:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D37552A544 for ; Tue, 31 Jul 2018 09:56:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C533D2A5D3; Tue, 31 Jul 2018 09:56:36 +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 4960D2A544 for ; Tue, 31 Jul 2018 09:56:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731674AbeGaLgF (ORCPT ); Tue, 31 Jul 2018 07:36:05 -0400 Received: from mail-eopbgr80044.outbound.protection.outlook.com ([40.107.8.44]:37332 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731650AbeGaLgF (ORCPT ); Tue, 31 Jul 2018 07:36:05 -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=BUAValkslsveuy2LnnZP6kuENyQhpJiMyBOODMnZzc0=; b=vtDCIFds5HhJA0v5NnaIWWWXvawoWWy3XTUlaeEp15Rbkuc8rmAbNcLLxyJxHWLjdRFpi83EbVj7X+UoCLYkXjGfpYatoR97hKNVTQ9oSvU+eUbiveFdHKUVDwwKy5lKUv0AqGetXZVGT1BkfDnu7sUvx2XKSKvL+PR+/Fbo2Eg= Received: from t540p (78.45.160.211) by AM0PR05MB4180.eurprd05.prod.outlook.com (2603:10a6:208:57::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.19; Tue, 31 Jul 2018 09:56:27 +0000 From: Petr Machata To: netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: davem@davemloft.net, corbet@lwn.net, jiri@mellanox.com, idosch@mellanox.com, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, shuah@kernel.org, nikolay@cumulusnetworks.com, dsahern@gmail.com Subject: [PATCH net-next 4/7] mlxsw: spectrum_router: Handle sysctl_ip_fwd_update_priority In-Reply-To: References: Message-Id: <90eee3afe1efd213f07acd8461d981fd0b7bd343.1533030830.git.petrm@mellanox.com> Date: Tue, 31 Jul 2018 11:56:22 +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: AM0PR01CA0002.eurprd01.prod.exchangelabs.com (2603:10a6:208:69::15) To AM0PR05MB4180.eurprd05.prod.outlook.com (2603:10a6:208:57::29) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a65f4b17-4921-4eb3-1071-08d5f6cbe256 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:AM0PR05MB4180; X-Microsoft-Exchange-Diagnostics: 1;AM0PR05MB4180;3:+uihfsEblMyKSlOGNHDFQrsEIpwUG3wjmijWKRePP6CZ+2nBy+t3836cgxnXw4smKj2AR7k3vd8R2J3DA2hhJdHZojR/0pr40qbF9QZky8aqBHKVxWyH92DoX0uLQvBM5IUnPK/dk+zPMdMaTprPwB69psodOjO/Eu81PpCakrPYqbyTAdueprxCLbMTUn3Yw2AoyR+Ca6QpfWD6xiWs1ZFtlm/CXJ4dVIi4OYuH4ZQw2MqpV3IC3Ivp4ARJJfxN;25:3LB3R3qvPED8MCwQJFH24jq8wBeHH64cGFORTN1N47065lzs7IFdbHcHm+UDUcDiWk1aT0/tBiFi3tZ2J8JbvuEdxbW2KWiZRqn5iMAJZAzQ7A8zy95vG3J2alfonqXAloD9E2YwhGdH3LHaj2a28lN8a/j9eGoi1qqvhaAWO+ONXom32whHhdiben6Y27rmEdvl17trZfczxpkWbzsfREx1dnIwjEhBPrQtxB8BOsF8C8NSqRzW4//iexMliXsE7r1jgpORgnPOqRslo8kIuyTuv4lDV2CjUr07dbBOgRhHKCSL2Z7+A6mY3Xp2qXeL/4lxnDk2L70Geej2/NFU1g==;31:OLd409fu8YBIHk0mHRO40vue40V13SQSwjXwArVEtEjwetvjbbOtVPliLeE8UCqhaKd6uxcL4OGkVzX/jn7yOswubcW1FSY6e4xVg3rx8Zj0+1cGHIngnH5D3kTUBJQtlKsRkzDkvyfdl0jQD4V5lfKIokViimH4X04ODQ56rZKEMD2LEYXOkvY0HMe7nqCc6SvFpScb2WT/CY+RDQClWkBJOW/oW/A928I2Jo1dJ5o= X-MS-TrafficTypeDiagnostic: AM0PR05MB4180: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; X-Microsoft-Exchange-Diagnostics: 1;AM0PR05MB4180;20:KqxTmIevJj/p1m/HyvV/Kvd7UdW2MdL4PA5reVVQMlaXUZ1rVc/UX4g+NjxkI3ro+PQ5UqwPMxXOX9f/WAdxPepRq4PRUXuv2QHHQzMq3rye348LL0jQ2c2+PFsDuh0JYSU5IDAoMF3hVIu0M7X99I8YU4Hz1x4YvQ+zKlPYMhZfC4iArW7UgxlXdD9nQAkGA9FllTEPjpuH4DYI4k+8m7tlIc1uJnT02K0BaKwJ9qaNyLHzMgZUWs7mDulkBwXEjyddvlp+whgO4e6rJbgL+PLjiNI9U0UC26b7NgAPKumGADIf/4wzNrOxoZYnjQ4T3xU6vVFdB9V4yLz/7/4C1Bxz/WQdOOF4J9TbqFInnHvQJ35ghVuGe/EBbRoX/gJdq19Kncze/mWoOS1TSEB2xw3qrhDTa4EgMpsA2/7k9q/Js7yWIqULxaLw93o9xNPRUNdeFM5FR/Kj7YLgbeD6vPahITPQYubRBaQO0wtN0Z7Yqf6zaxJrCx1AQrmKvG1c;4:mPdGfU+OWN/pAnSbsHMcRICBgOC39N1lb6OJa5fhSOkBkpwBsZefgT2VoPdFBTCTBFwmuTPR41kvf4AMqHJ1cxwIHtyApeE0baMo/G87+zyR8YciKf/BKew+lbbdOuicgojklvF+TpBEOYVdb9ARs6l5YHtljU+ebBdXYlnjO8HqlrgSkFxPqdvJO/lHJ5GWpw1RTcDwY7eIG6pPIjgoWxhSLl2dcJSoUFXHBLqFuoCKYTeUisZQy9+L3psVAhGt6cFdnFgpQZnbw/l+kRySmA== 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)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:AM0PR05MB4180;BCL:0;PCL:0;RULEID:;SRVR:AM0PR05MB4180; X-Forefront-PRVS: 0750463DC9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(366004)(39860400002)(346002)(376002)(136003)(396003)(189003)(199004)(6666003)(6496006)(7416002)(11346002)(26005)(48376002)(47776003)(53936002)(316002)(50466002)(8936002)(186003)(81156014)(16526019)(446003)(68736007)(476003)(81166006)(2616005)(8676002)(486006)(6486002)(86362001)(305945005)(956004)(58126008)(7736002)(16586007)(97736004)(3846002)(105586002)(106356001)(6116002)(478600001)(76176011)(51416003)(2906002)(52116002)(66066001)(14444005)(25786009)(36756003)(39060400002)(4326008)(118296001)(386003)(5660300001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR05MB4180;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: 1;AM0PR05MB4180;23:JWHk/WMN21d5x4Fe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Xq3j9QrVI871fO0Fr3SnUenE3eAQnMp7fbk3KYPeVW9NiXzHa6hwhzW7pJdEg2HIu37HApaF86p00wrIbcPe+oLXRejq55vQLakV8K8ty2Es=;7:oFdwGl32yURNfX83PwIj+Kh9amtWkH0yUu0xzkjWtlZw8CRxeqAq12R4aM/B7PhiayXC3Nt5nUrLa835Ccp9kTPhDUMlXUP+p4csq3zvpSuIyJZPXNaYDsLgevQDggT/ChciOf0gZfyRRndlPemYaQEOWxhhB+8EG0fKGdjPWxoZvJGg6lbrUHxzi04BXNl6M67RZeeFlN6/S0JnFG6Ut+lbZcNUfSHfnrwhtelvSmJ/hc/zlt2EP7sPVCZk0xPr SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2018 09:56:27.3234 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a65f4b17-4921-4eb3-1071-08d5f6cbe256 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4180 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 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 Reviewed-by: Ido Schimmel --- 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 5ee927626567..eec7166fad62 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -2436,6 +2436,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 *)) @@ -2522,6 +2534,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; @@ -7390,6 +7405,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; @@ -7400,7 +7416,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 Tue Jul 31 09: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: 10550553 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 00BED14E0 for ; Tue, 31 Jul 2018 09:56:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC7FA2A544 for ; Tue, 31 Jul 2018 09:56:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0D252A5D3; Tue, 31 Jul 2018 09:56:40 +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 4C3362A544 for ; Tue, 31 Jul 2018 09:56:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731674AbeGaLgL (ORCPT ); Tue, 31 Jul 2018 07:36:11 -0400 Received: from mail-eopbgr10042.outbound.protection.outlook.com ([40.107.1.42]:41697 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731503AbeGaLgL (ORCPT ); Tue, 31 Jul 2018 07:36:11 -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=pxkkZRNH2z6ysnmzAIMne9rMz43xFTDKowLcjqD/pLI=; b=mYAKoU01i6AntPYAHV5HZR0s3vbkhsEbKuv+h66HK0Ad843T5NMgJwujrB4Sol0hJ8A8jnWyZAYv/zFj1Xy0OLrHAc6TOZbFax+rZi5J0l/2gk0wiArxSzWpdrleLkQx4HDXpCFJUhD4dfdUrNwNngq06QCu418wm7WBlOehuSk= 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; Tue, 31 Jul 2018 09:56:33 +0000 From: Petr Machata To: netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: davem@davemloft.net, corbet@lwn.net, jiri@mellanox.com, idosch@mellanox.com, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, shuah@kernel.org, nikolay@cumulusnetworks.com, dsahern@gmail.com Subject: [PATCH net-next 5/7] selftests: forwarding: Move lldpad waiting to lib.sh In-Reply-To: References: Message-Id: Date: Tue, 31 Jul 2018 11: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: HE1PR06CA0141.eurprd06.prod.outlook.com (2603:10a6:7:16::28) To AM6PR05MB4183.eurprd05.prod.outlook.com (2603:10a6:209:40::28) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6336cc35-c2f3-4a53-512a-08d5f6cbe6ab 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:UMD1msiKpq9Kj/vBdGO8XP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fgZBHsVFOsQhtz5eEZ94r1RFar9RceMO6cAOaBXCmz57zTNNAa9KMlIebkJ5J+U+w0TJpBzHp35J3qiDgznvO4LVi64qjvFsT0jW0MwxIQ9bbQAjMFKRjmNSsM39N/QqZaiXEUAdhUwYW3V0m7NAq8lOme8I7uDhAv84T21H/94DlYXnv8wckYiO+bZX5FQVcJt6LUf6YgprQLTUgLLDx/U2ZV3dsLETAm3Si2dL6PBuXAG7n5pGt7+oCRMmEy9JrkJGrNWUYNMc5LVHFIO8vPC8R5VNRTWEBgMeogJtRVvxTFeD25ZQjd5dvhtxK4A2J/;4:gdv89XoWi8J+XxYfDa4BU9KEmdM7DjRZiXst2wG0xqqOhUG/6GPvVyHgSutns42mxcvhaA6akV7RVwGB12rVN9SVqoF5b8CquM55WmLyzfmHzXbzSrRgryrz8WEyh8cdQ369RrsF9wL3oDiezOr7DSQ4q8lQeV4p/8H24ifdTbIMbNw+q/I0pHC2cuZjSSLXL9sr1lB17oP0v/442Hn/Z/tJ6rpNXuXhtMpe7QFhMPsvAqE5H+QSTrX23h/85VArBnyqCGZL/JXmM6zzUBPwpw== 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)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:AM6PR05MB4183;BCL:0;PCL:0;RULEID:;SRVR:AM6PR05MB4183; X-Forefront-PRVS: 0750463DC9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(396003)(39860400002)(136003)(366004)(346002)(376002)(199004)(189003)(956004)(47776003)(446003)(11346002)(16526019)(86362001)(478600001)(97736004)(7416002)(6666003)(5660300001)(14444005)(16586007)(486006)(51416003)(36756003)(186003)(476003)(2616005)(4326008)(6486002)(386003)(39060400002)(8936002)(53936002)(81166006)(118296001)(105586002)(26005)(305945005)(25786009)(106356001)(58126008)(68736007)(66066001)(48376002)(6496006)(50466002)(3846002)(52116002)(76176011)(81156014)(6116002)(2906002)(7736002)(8676002)(316002);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: 1;AM6PR05MB4183;23:fT3mx4h5aZ0t0vOJyKCynnWdU/jUNUvAHAccC1cNwAnWXK6r3sxUFV225QvXbolFDtak/1AV8O0lMrlwYr7aAgx3y/Gpy6PZAGIIXVccsosUDTBtxP8aMgCfJfgWXchCr7gfPJ9YulgSH/lgiXjDaA0fGrF2LO3S7Fv7dDCkP+Mj1fdN1+KGlVE4MvZljzM5eQRdxVuHC7SEjIWYC5OcGtINglv9koKbVk5o8ShNjYbw4WUhBIQY50OqWx1hvymbi/6q++TucsUheZ9vMyeE+3TjaYzf4qVYNXOsPIIpg7/0kBTW7JD5wc/3kg0WxTVqfJlUQrU1PinDKVXdzOlUQ0a9KqUIuGKYvETaI2QZYHvvkd5QHaZS9PoCbdUqTEgD8IDifMxZYibAB6sw4kQAtERq87v9EAZZAiNOto6QMVi4AhsIutxqioGBSy0i+wWzK+AMYBFMKBh4Dybp7rKb4kTW9seVVXHBBD5zrRzaYd5OkY+xsV7SB+c9+q6H4+qdZSKLPdCgX92a9W+hPC7XqsL2b6FGVGm+NDZsB4v/O/K7G3gG4eKj8vMUkQsQ4WKXExPPNhPoHADymU4OtF6Oxej/JpEgUmmHCZ6oTP7d9x0mUdBuHE6BKE6yn3Gtuv5H86SasONaM842Z6hNZDhUovFhzyAkDQNYHHjOZRhNphjFYVpj0DF6JYS/3BZHS47TyJ1vR2xNMfz9oFHsvPc78kv3Njbj+nJrlAIO7Ah5nxYdnngSECAu/+4gZ9pXOhDBwrmWoHsYLaug+sNBBR5kTnNzg796TQv6gLbky2SScWiqHELlLL/b0Ul13VO394zKjsCDybEYsoxpPF3M8jZlDFvGUkLEWJfqPLeeUwblW7VjkoDtM+edEZ2M1P5k10Th73hIb8W56fwAvmJYe2FHPLe6Lm0HOxiYkft6xhkgGClDeyno+8/iPMf0faEfJQDzP8JRaLJB8ubq2Jw5vezaicA6THDXxmB5FUEpfSZoD0jBijuCeqfApzd62QXVM+SF/f9M68YucIJTG+pSfkyuvVNG3NiY4gclnAsQZ4gdteQ5BX68Q0yVzPfT5Tx66LxaYqT40alwIoZhi41f47Wg5kFhhtVq2xLY2FKSIvbLPPGliFfS76ynEXMUXzmJNAqmRCElWoVsEKlnEvoDtRHthey2bju8WFd7kVWdpcqaDfeLguFPihF/j4XLwyWIZMds X-Microsoft-Antispam-Message-Info: S+w+zi+AMDsklAathaLqsFfhwlFd4c9DkFlZLEdfOrty08M8sb57l/i1IxU9D356CobBoeL5F9LPc77UOccevm3J5Ttqx9QzDp+krR9hGMzmEL0vtmg6qhLUNJ5wqMBpxAiAh7jD1Cci+RyUSov7hUbAyjrp5RxlwQoyuE85f7ZadpaFVdURmA72upYhGTP55sSIMwENK5kP6QWHooFDaKMIrBhsqkatpYrt0f1HqTKguqkYD8Jql3N3iou0gNZs71y3zGJPRFw8ce8SS622eXRgY29zzlmjQbmW6khQQvVzYdZOEtQZsvgHSZp0UJpKTN8V1L+NvvwYJnn//6LtmQy0rz477d4+9r1zP7dSjVs= X-Microsoft-Exchange-Diagnostics: 1;AM6PR05MB4183;6:A2MTh6RqDQYDs1aE8EgNp/AqVi7G9GtPdFzFwpRTPyMoM2Oq7NKwkVl5PRJ2woHbkqrzhGBfsMtvvgy/4j6qfXAMrqusyIuA5ouJd418uQj6jhCq+wp8pyAsehzsylpTqRLknyK1RmTHuroMK8hwyad3oKWInXZI0fBw2agSyT9ScCPBCHrcI251kCcACM9rNf4JWOKGY/OAWllCCBg8eXFUWqTcyn0ZbuS99f2pQqgyNp7esxZgSz096MTXmfGg2R+ebb1CbiAufPwXOKC02lYvwtbWXa0G/O6vzfdWKJl2v8yss8ONDNOqYVcKfPdqbTIv8pLYJ7jtuYSPi4flKYgLDQuLMRla3wobYzSCcq5X3jpeIaXS/QjF4XJhAPF/fd9eZXghrVfwuV1VdMnlenvgPhCqQZDmZb57oYHHK4tHBL8RjwQb5kCk8kMN2L1vLSMIe+spHG2gsIKKmuBvvA==;5:2XeeQjRWSF1tlbpKYyH1p7w9R7+wtoYVIi1uJhFTbZ5OGZ1tlwBr8E3ie+a7inoPh3/ajCFK4hxPxnbBLsZ9EKIu/vPYe6WkF2PUkoZQCTbx0EzNpOoL6MGohMmzjeZF6qcRgsc/C97Uysa0B3jm2t03yB4cUQe1eOrDwauDy5w=;7:B4zDIHoj9gfSGANJpbTIH5X5BscZyNKwfRWyukh6OpzgBEYj79mTyptOrc9oGDKXGx9kaempE+ZhNjcl1yviDOgV1eN7BmyhX0uLFk4iCbKhqRXQ5WMZcZeEAqMg7GRSEKs3OszPLGuypzOR6x7ApQiVvSmBV8IOFOtYDw5BIKcmOnWdE10ULH78tEy5pLT00gf6+ee255Zqww3uC+E9RWVf0EHLNhCa6TbAsCYrpCPlsKKuhmWVuN/EISPf4BqV SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2018 09:56:33.8292 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6336cc35-c2f3-4a53-512a-08d5f6cbe6ab X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB4183 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 The function lldpad_wait() will be useful for a test added by a following patch. Likewise would the "sleep 5" with its extensive comment. Therefore move lldpad_wait() to lib.sh in order to allow reuse. Rename it to lldpad_app_wait_set() to recognize that what this is intended to wait on are the pending APP sets. For the sleeping, add a function lldpad_app_wait_del(). That will serve to hold the related explanatory comment (which edit for clarity), and as a token in the caller to identify the sites where this sort of waiting takes place. That will serve when/if a better way to handle this business is found. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- .../selftests/drivers/net/mlxsw/qos_dscp_bridge.sh | 23 +++------------------- tools/testing/selftests/net/forwarding/lib.sh | 21 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh index cc527660a022..9e875ee8dc1c 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh @@ -103,16 +103,6 @@ dscp_map() done } -lldpad_wait() -{ - local dev=$1; shift - - while lldptool -t -i $dev -V APP -c app | grep -q pending; do - echo "$dev: waiting for lldpad to push pending APP updates" - sleep 5 - done -} - switch_create() { ip link add name br1 type bridge vlan_filtering 1 @@ -124,22 +114,15 @@ switch_create() lldptool -T -i $swp1 -V APP $(dscp_map 10) >/dev/null lldptool -T -i $swp2 -V APP $(dscp_map 20) >/dev/null - lldpad_wait $swp1 - lldpad_wait $swp2 + lldpad_app_wait_set $swp1 + lldpad_app_wait_set $swp2 } switch_destroy() { lldptool -T -i $swp2 -V APP -d $(dscp_map 20) >/dev/null lldptool -T -i $swp1 -V APP -d $(dscp_map 10) >/dev/null - - # Give lldpad a chance to push down the changes. If the device is downed - # too soon, the updates will be left pending, but will have been struck - # off the lldpad's DB already, and we won't be able to tell. Then on - # next test iteration this would cause weirdness as newly-added APP - # rules conflict with the old ones, sometimes getting stuck in an - # "unknown" state. - sleep 5 + lldpad_app_wait_del ip link set dev $swp2 nomaster ip link set dev $swp1 nomaster diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 843a6715924f..90af5cd23417 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -247,6 +247,27 @@ setup_wait() sleep $WAIT_TIME } +lldpad_app_wait_set() +{ + local dev=$1; shift + + while lldptool -t -i $dev -V APP -c app | grep -q pending; do + echo "$dev: waiting for lldpad to push pending APP updates" + sleep 5 + done +} + +lldpad_app_wait_del() +{ + # Give lldpad a chance to push down the changes. If the device is downed + # too soon, the updates will be left pending. However, they will have + # been struck off the lldpad's DB already, so we won't be able to tell + # they are pending. Then on next test iteration this would cause + # weirdness as newly-added APP rules conflict with the old ones, + # sometimes getting stuck in an "unknown" state. + sleep 5 +} + pre_cleanup() { if [ "${PAUSE_ON_CLEANUP}" = "yes" ]; then From patchwork Tue Jul 31 09:56:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10550555 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 66F2714E0 for ; Tue, 31 Jul 2018 09:56:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E61D2A544 for ; Tue, 31 Jul 2018 09:56:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 425ED2A5D3; Tue, 31 Jul 2018 09:56:48 +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 B30E72A544 for ; Tue, 31 Jul 2018 09:56:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731846AbeGaLgS (ORCPT ); Tue, 31 Jul 2018 07:36:18 -0400 Received: from mail-eopbgr00089.outbound.protection.outlook.com ([40.107.0.89]:55568 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731503AbeGaLgS (ORCPT ); Tue, 31 Jul 2018 07:36:18 -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=fyzJFC/wJuO4flzYHhRaNmXPKfJCqTEMCGD6gcByqb0=; b=Wg5fNvsXoPVm0foKh5VmXtStn+xFsDCsrilIi//pw0LTPfWuimHsiBKJ8RH9q7ZmDZk2S6Ah7HZthng5f8xehJWCuKKYbmqftkAzo2n3fbXYGb3kp9D2EpOtR39+Ls52pDX3B2xBhLVTYgREEN0blYv5cpxGLaBXMnJA8l5+ZXU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) by VI1PR05MB4190.eurprd05.prod.outlook.com (2603:10a6:803:4e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.19; Tue, 31 Jul 2018 09:56:41 +0000 From: Petr Machata To: netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: davem@davemloft.net, corbet@lwn.net, jiri@mellanox.com, idosch@mellanox.com, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, shuah@kernel.org, nikolay@cumulusnetworks.com, dsahern@gmail.com Subject: [PATCH net-next 6/7] selftests: forwarding: Move DSCP capture to lib.sh In-Reply-To: References: Message-Id: Date: Tue, 31 Jul 2018 11:56:35 +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: AM4PR0101CA0066.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::34) To VI1PR05MB4190.eurprd05.prod.outlook.com (2603:10a6:803:4e::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2df45db6-fe12-4685-5511-08d5f6cbeab4 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:VI1PR05MB4190; X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB4190;3:+atL5wSWocvGLsxVTTQZ81wmK4LEbK5x3Ewp4/9/95KxuKOYsB82HgScuXGx1J07Zj8cBF8LIxrOBsXGXwcWpud3TODRmuMEqfTp2cvGCvrbuvf+XraUBc4QdSCGDB2mmikm9mnqnqNYOv9nVGWCqCyKnFNgggfMnCp0ilLOkK98PSq5d32sElSIszwT/FLb/aI+32UE1YqPXsubefjJWozrhv5q5yaQRMACCopG5F+tIcGqIaRvIn0BLKc5lV5c;25:a9sfuJmoidDRz9RQlCScvwfoj6vZ+qoHrxFyoTrsIe8ZycAJM5nWIZDRSDN1zqA886WHOPmFZgp6Bg77cv8aQs1M6ARMLMPCDH0RO2pkQsJWZOaKEglUaLfrz/tVgRAvZWXpIyz+s2okZWSvS5BprdhVJ5XeeY6PHsKI6bhAFC61v0srujygwXG6TZG6OvQ3dYpaNQ03lXyVoqhtTWPHJFYdBuglsDzNFHR0Fh/lJKH2BvsbpfpBiIR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A0YvxgU+tGV6kIj1aGM6qtj+LxTwPOMUs+1Mf77ischuNvlFF3cl46W5aV1XpXw90FjRZo2VEUhqBtD0TvvfXqp8RHhOr+FyVJ59C+ktReZAg== 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)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:VI1PR05MB4190;BCL:0;PCL:0;RULEID:;SRVR:VI1PR05MB4190; X-Forefront-PRVS: 0750463DC9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(39860400002)(376002)(396003)(346002)(366004)(136003)(199004)(189003)(446003)(305945005)(486006)(11346002)(118296001)(476003)(97736004)(2616005)(956004)(6496006)(48376002)(50466002)(3846002)(53936002)(478600001)(105586002)(52116002)(76176011)(81166006)(51416003)(8936002)(81156014)(8676002)(7736002)(6666003)(47776003)(106356001)(186003)(5660300001)(66066001)(386003)(68736007)(86362001)(4326008)(6486002)(36756003)(16586007)(7416002)(6116002)(58126008)(25786009)(316002)(14444005)(16526019)(2906002)(26005)(39060400002);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR05MB4190;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: 1;VI1PR05MB4190;23:Tghnsa2cjW80vWaNEStq49Jcp1/zc2rEh+Pdcz3mTOXLzh9hmR9u9/3fRERMmuY6R4PXHO1YRHdKOKs0jdGo6By+Rw7jtb3ZFM5ic5n99CYopnRIBIqJEJpky51Gd4c4FJ79Jd510bnB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IR X-Microsoft-Antispam-Message-Info: FKY7GuxMDiNVdKbmqmz9HseoU0Sm6QTb/30Zec5/igSV2a/Of1oSS8t/YTup+WW0XSBQzzaw726KofxRsvHDVxkXr3vmXWSOUyNq6TlsSvb2wMcok9o/qaGt3glMBQTYww5eypp0HOEa0vmpwmikR8woM6QKIc5kpkLZsy361XdAF8OwiQiOc97Yue3D8U5tltRUS3t0odEZlmtypjjwctZOB2K+oK+ciAbI6OPCeAj9rxiZoxKfu7iMXvY/FyEcLTra8HSaN3zP7jz5NV1B3LqrL/Ta2L9GnfBQ8kcjdojyCKo6gEYW5iUFTkookx8ZxHyai154/H6d4RB1rmhCni8GZ7MlAmonPz/PorS2/gs= X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB4190;6:5shUrNMs2dm0akyMYOdiB+206xQDP39k2Q1T6YCYnUifohWnsxt28u3rXgh9Zy6tu2lnSS0i292gWwWGES3HHOWEtII7KrMOu5Aae1S5h/PUSxmQVrp5o5KPJErFGfTgVigNw9SjgKMdUBekMWCn8t+MFqyn/33PGELsFUaoRII/1ha+VWlVLKPm5hAsshScw6bIR/dU7O5Ul9pEIw5toFTgpCNXGBjS9zygm7pmYdTvGb9ATLdfdUKcFQ2PnKb9koMuYh9K4L3Mlyp1eDYrRG6k/SrMc8R28nsFsIgpIW4xnYJn3u7zQVvr+4paBSdha7Zm9yXkLBO22oFcAN7aQE7OUzcEemlT/eg951iw6afsfZoNHTQjOd/VaH9s70H+yXwb+7ni6DmWd5rS+B29QVIAS/CQh6YY7JzICyQUmN86jq3DRhbb3iOUrHBqFOF6gCUF9PkRCt/wj6+lumWhcw==;5:YrzTGn0m7GrAhGy3Nhist0yCCvuawaBXrgdx121UdeEpNbyanGKMEjTPFNilaZ8iBye80SoMdmvpXr7i+PkNzgTkzYp2hBUGTDjruxrjjqlWcTTgl0gQhAYxZbH3DJOYUYUwwaH/H1qNSHeh2rDE5zrtjrcIdqnXOLaDXeigCQI=;7:dVcePawJWh9iR23aYCYviOu8EtT4dtcD6oAdNx5scKfrEyH9AIuxdOqAz+YUjPRsUfmGPR38Z4vPFoKecqLlfzhUf/192QjhjhDWykqSB+xsdbuK7Um+YTuma6s1mBVqv9dIEzuIVNabzFEOG7upD9rZ7pnypayq9LdAaU4iwF7ixGBIyMVKbVneu/CH/W7fS9DZBtpS8PN7xnnbEglRic3UJjR6mHFDCUH+uehKogsoWteWFVUB1OdQRKo5oq+z SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2018 09:56:41.0877 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2df45db6-fe12-4685-5511-08d5f6cbeab4 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4190 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 dscp_capture_install() and dscp_capture_uninstall() are going to be useful for a test added by a following patch, move them therefore to lib.sh together with related helpers. While doing so, change the rule preference from mere DSCP value to DSCP+100 in order to support adding captures of packets with DSCP of 0. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- .../selftests/drivers/net/mlxsw/qos_dscp_bridge.sh | 42 ---------------------- tools/testing/selftests/net/forwarding/lib.sh | 42 ++++++++++++++++++++++ 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh index 9e875ee8dc1c..1ca631d5aaba 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh @@ -34,36 +34,6 @@ lib_dir=$(dirname $0)/../../../net/forwarding NUM_NETIFS=4 source $lib_dir/lib.sh -__dscp_capture_add_del() -{ - local add_del=$1; shift - local dev=$1; shift - local base=$1; shift - local dscp; - - for prio in {0..7}; do - dscp=$((base + prio)) - __icmp_capture_add_del $add_del $dscp "" $dev \ - "ip_tos $((dscp << 2))" - done -} - -dscp_capture_install() -{ - local dev=$1; shift - local base=$1; shift - - __dscp_capture_add_del add $dev $base -} - -dscp_capture_uninstall() -{ - local dev=$1; shift - local base=$1; shift - - __dscp_capture_add_del del $dev $base -} - h1_create() { local dscp; @@ -155,18 +125,6 @@ cleanup() vrf_cleanup } -dscp_fetch_stats() -{ - local dev=$1; shift - local base=$1; shift - - for prio in {0..7}; do - local dscp=$((base + prio)) - local t=$(tc_rule_stats_get $dev $dscp) - echo "[$dscp]=$t " - done -} - ping_ipv4() { ping_test $h1 192.0.2.2 diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 90af5cd23417..ca53b539aa2d 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -653,6 +653,48 @@ vlan_capture_uninstall() __vlan_capture_add_del del 100 "$@" } +__dscp_capture_add_del() +{ + local add_del=$1; shift + local dev=$1; shift + local base=$1; shift + local dscp; + + for prio in {0..7}; do + dscp=$((base + prio)) + __icmp_capture_add_del $add_del $((dscp + 100)) "" $dev \ + "skip_hw ip_tos $((dscp << 2))" + done +} + +dscp_capture_install() +{ + local dev=$1; shift + local base=$1; shift + + __dscp_capture_add_del add $dev $base +} + +dscp_capture_uninstall() +{ + local dev=$1; shift + local base=$1; shift + + __dscp_capture_add_del del $dev $base +} + +dscp_fetch_stats() +{ + local dev=$1; shift + local base=$1; shift + + for prio in {0..7}; do + local dscp=$((base + prio)) + local t=$(tc_rule_stats_get $dev $((dscp + 100))) + echo "[$dscp]=$t " + done +} + matchall_sink_create() { local dev=$1; shift From patchwork Tue Jul 31 09:56:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10550557 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 A03D614E0 for ; Tue, 31 Jul 2018 09:56:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 868D62A544 for ; Tue, 31 Jul 2018 09:56:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 798262A5D3; Tue, 31 Jul 2018 09:56:56 +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, LOTS_OF_MONEY,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 BD2A92A544 for ; Tue, 31 Jul 2018 09:56:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731908AbeGaLg0 (ORCPT ); Tue, 31 Jul 2018 07:36:26 -0400 Received: from mail-eopbgr10089.outbound.protection.outlook.com ([40.107.1.89]:33463 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731503AbeGaLg0 (ORCPT ); Tue, 31 Jul 2018 07:36:26 -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=5EN6NKCIp/5HkrnYxZsfnPA6lprStfSxqZHHAgzVX6k=; b=kP/kHPKLckbtaQsVDO01zQBnYOdQanbR1cDXZVE5yVlSdVZygzKrty1C8XVKoj6qKsMha1siwomJdO9tp5c3QbxTJrcX1/2l1keflsokMIby6mdiP4kL4mFQ7nZNr8AIsa9ttS+B5wutzsvDatCdhkF1NlWrsn5xEBve6lnc1L0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) by AM0PR05MB4179.eurprd05.prod.outlook.com (2603:10a6:208:57::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.19; Tue, 31 Jul 2018 09:56:47 +0000 From: Petr Machata To: netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: davem@davemloft.net, corbet@lwn.net, jiri@mellanox.com, idosch@mellanox.com, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, shuah@kernel.org, nikolay@cumulusnetworks.com, dsahern@gmail.com Subject: [PATCH net-next 7/7] selftests: mlxsw: Add test for ip_forward_update_priority In-Reply-To: References: Message-Id: <2b4f5320ed8e520ccde44474bfdaf47ee20dbc94.1533030830.git.petrm@mellanox.com> Date: Tue, 31 Jul 2018 11:56:42 +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: VI1P189CA0029.EURP189.PROD.OUTLOOK.COM (2603:10a6:802:2a::42) To AM0PR05MB4179.eurprd05.prod.outlook.com (2603:10a6:208:57::28) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7791b7ef-8f7d-4381-ab95-08d5f6cbee4d 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:AM0PR05MB4179; X-Microsoft-Exchange-Diagnostics: 1;AM0PR05MB4179;3:F4NnFlrj246lc9i0yi4uMjJM95W3IK5WspBLyeSU5GcSUQFZKDBSoifXsvMhMaqmiMrpK5EVS0Z9qkqDhVSLVMz8zj/it2JB7eNftnsYzygmiXkSG9N4a52uY8K3UeI7F/DKyh/kQAutv6OZwPGisltC8EGVuamFT1fUDCfloxuxxc8n1LlG5szRjYhPCP4+sQPaLXu+IfzhtlBia7ZuPeCHNRqyXdD5KjAXT7eySJ7tQG/v93e0uo6SBy3ImQMQ;25:IGw3/R7wfi40YL4BD/4qIdNhlQ/OM2Bp8yL40irUYOu5zmgMMIiiIB8zqXlWgfG6N2vwZHBMfyXZylH0URLKn9cL/0TfuZQ/CH+N2zBTU6EOXLgdHgh+MpP5dh5LX6NHLb7wlqPjcaaWf5lJN5ge+POD5d+0tupXknYqkxxt57+Z90902amNlPqkycNANS9J3qapXqJvsuzOUn7xRVy0XFQ678AGIBPN57hKc/ta5C77Obt+AQoJiCj8z0PRnAWqjPgkLabWGgt3aSDuJCRCkN5xOEgtx3pBz+/D9IWQPq8/F0MUIXgBSNZ30QQ/nB9sdUER6Mowavpjy3A9s8m5Qw==;31:G5W2naVhLVjENMnJ85yOzNjbnZvGtwww42NEnzK7H+glQ921NnpyOXvhDdfTr73ZLOtRXZCD+OAUVK0Apju6vk8XBQHkXn/yghIKzPO7PRblyHbvgSPMGXv7R5f544/yU1Q2EHE8w9U+0o4kSxk8gSoXf3RLnVi+Al9gKEONkGGlz/pzZW1RxxzjyHGtkKEuTmW28ctxhGOLz3gQ2McTcKH0DFGDAw/Jv88VgigCwTw= X-MS-TrafficTypeDiagnostic: AM0PR05MB4179: X-Microsoft-Exchange-Diagnostics: 1;AM0PR05MB4179;20:sTmZzadQpg7sBUPLUU/sXpEwPJblQNZv6Fk25/jJAjzqHX5ljwnrY3ct9gosIiklX85INRo14GP0aonO4pXfqXU81BffLxxTFEZzfX9ii1yYaMCvAty6j1aFSyVLsu2up77RTgtRqkLvhG72tdHMGK5chYbLOg7UG5UR4dISZm/tBwW7mdG4gMLw+TKUyRBH2cQbWLWSD71OmXIwkExl7D+L2H3ItAl9eIKD4Zeep+Bh0QLS/4gRzlJmcaMU6waOllUfeAfQmt7Mgkq/tfdRImTclZg/yZGlxLEJd3GwaFbsG78NKwfWtnZb2NdrOtJEF9j8Uhpuo86W57voCJCttLJ0RdRPXZtpsTGU421Koim07V9GrmxiR2xUeaNeLntkXm9wfUFFFVm+ZxqE6BIFJM62WUuYjVA+d5TKOB0sVJstm4BLxJSPLDHEkSqbcIV6oMnJGSYZkMWdt5KQpzd5IaCsY/kodPJq1mfKmR+DTYwvQ8SHaC71hU2OxGBl5PGb;4:KDqA1Apej2psMFggqLWCX/E4f+V/q6uHCNb5nMtXVQ2h2PpgDrXdw/QcO77aFAG07Oa5KZJmYjqkWPxtK1+sLAEE9J8IX9YnGdZfp6+VSXJvKFOhH8Jw7FUjL3YPEKjIRG0rlNsRyo8j1pWsPG1pT5eEPFWXDsI0+7+4SXD64nqRDYLNTdoYZ6XkfeeSsPfQSS1AXg4LsXsgA+GWGni+fTJ8J3ZQSfPoPz345LL5Pa4RecTKnjHJXGU3ojHF8RjgJj13hILjkM+UUqe42ce/NQ== 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)(3231311)(944501410)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016);SRVR:AM0PR05MB4179;BCL:0;PCL:0;RULEID:;SRVR:AM0PR05MB4179; X-Forefront-PRVS: 0750463DC9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(376002)(346002)(396003)(136003)(366004)(39860400002)(189003)(199004)(14444005)(36756003)(4326008)(575784001)(86362001)(2906002)(25786009)(53936002)(50466002)(39060400002)(48376002)(305945005)(7736002)(68736007)(8676002)(8936002)(81156014)(81166006)(6486002)(478600001)(66066001)(47776003)(51416003)(76176011)(52116002)(386003)(3846002)(6116002)(5660300001)(97736004)(6666003)(106356001)(105586002)(118296001)(476003)(58126008)(446003)(2616005)(956004)(7416002)(11346002)(26005)(6496006)(16526019)(316002)(486006)(186003)(16586007);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR05MB4179;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: 1;AM0PR05MB4179;23:/eZtzSTG1B15ntOHoGeTCYCgzBklrDQ538N/d+6pecSrU84iq7K+DmX4cT7ud6eMRrSZ6lkgluCEtV/bMD5Kjo7H8eN0R/2yQ7ZZu0AuBmfmkMN08uIVEmb7dh+Si5PIJTnqT/c9jlNqF0y7EM4nPMvkwWAN8b13rHSxUzYuyEB6d5q+1AKv7AY71kJR3YJ6VB3tm1hsk7sIgOrl1QcmyYzA2Ra+b4Pzh058gfZLKcC7eXjZ0INj5FPDby79Ptcu3h7uu4xGAundNq6zFYMu4szB25m3+ye97K5x/sz2UficbTZPUXqN9J+nPwnHAkEOiAgW0VGBvryiwspLwBZU8i/PjAE7EJLjoQqipS4GBAoqmzN7M/7gvXQsjwI81MxA/uO+j6Bg0IElCWhF+an857Rbsv+3pmrwlShHdin11xdH0tlkrm0F8EX7HtUGWhFlmzoNhcu84GYnFPs1Fw+pkPVTvpccTxZaRCC4gqAph56M6rEsVbAzNC0Faa4jD6a9fxx28I7kd8LAgs4VUGIU60SePuDxtiESN2rujBwkXQIbQxtX8AhuZu8pnCVkNOgzi7fOnu6oDLJ/lkTOLDJytnq9CSEWlaqtrUk7HaVGT4yILv50knL3KtO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vgh/gjq6T2v3MT0eDcxhdIFQMf0wEe5HScf0zbXO2jvE4PMiheHrX+5mvYXRSxJM9tbG/WLbLwf42WE+tRgnP7bEhg3JFS9Xt/I5PXVL5cabKzPkgiQRcdwECovSMh1P3ck7UuETinkQ7Usf/YqqoGDrKWwhhPuytmsITnyu2irRXbitlEgzpZTtZJizUECqu99AeHI0e7AJZZMZ77y/rNB4GLhVzrCNs+KPP/gU7gh38eev5qw/y0PFn1VlZDxZ+9iY4PQHu2HDqoJ09ysruKFhdPUd5/6hyBAmz2KPLBOxhHsHQOzP7jYsSw9YpRABQmScTyeACdq59PWamVizgpOM29rZCnqaCvkizzdK1wGxg+WmyF7AywRWlILF1n6EbuBrmryIPp1JkC3tZtchBvMxnsc8/pxVMn9Na1uMUWm0o+s8mw==;5:XT/no5qYueOSlYspdzH0P0uWd+mzE6wlPP1U5oP602wVSbIu5i8kbslwOfE+/ZASMZzTB7n62s7EDANkS/Ci3vyHSNF3LV85C5TfWCBhA6kw4ibiaV8IgjZnXoiaKFHBV7E9nuxAikdzg58n0ndsE91XEJBXdBjvg5UurbqtEP4=;7:SnCWRFFghtb9nu5ej47Jo9dlrOnvsEOhG1Yph/xLmDR1reVl7cEjhg4EN9u8lzcgchb3rWlVUI4EJGA87V0HZUpSPVn/n6u3Q0q1QboeYCnYEnku15YUaKddaNTANnd/Dl592/MY0esHWBWABiWI1n/ZK9yuqvkm1zJLpBXfWvL4rPHum8tBd+iU5QEq5NVLQW4eihI2bUE2CYyV8UGkA1J/qI0idc6X92st9Nc77xX0tzDzuJNrEWPVFF7H3T2D SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2018 09:56:47.3240 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7791b7ef-8f7d-4381-ab95-08d5f6cbee4d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4179 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 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 Reviewed-by: Ido Schimmel --- .../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..281d90766e12 --- /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 response 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_app_wait_set $swp1 + lldpad_app_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_app_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