From patchwork Tue Jul 31 22:36: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: 10551487 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 67848174A for ; Tue, 31 Jul 2018 22:36:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 576DC2851D for ; Tue, 31 Jul 2018 22:36:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4ACA52B2DE; Tue, 31 Jul 2018 22:36:49 +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 AFB252851D for ; Tue, 31 Jul 2018 22:36:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732627AbeHAATS (ORCPT ); Tue, 31 Jul 2018 20:19:18 -0400 Received: from mail-eopbgr20083.outbound.protection.outlook.com ([40.107.2.83]:10421 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732567AbeHAATR (ORCPT ); Tue, 31 Jul 2018 20:19:17 -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=vYfH6hQY17eIUV6jhW705/SHJ9RapsCAlW9okZeQ7LY=; b=g8qAXVynjMAl4oHCTakRBGKB1M66l6L+0yUCiHI6yYeDYBIeUQzDKbFVFXe82zzxkm+UjhE9mpEeoo4LJ26GG4rgQjUm+wTgL/NlXFiO46q6JfCj/befQtCk5duTyLCpRmxsNV6aNXUlbagcc3tNRF+Bq+OgfeC73FOuw3MqP4Y= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (89.176.83.59) by VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.21; Tue, 31 Jul 2018 22:36: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 v2 1/7] net: ipv4: Control SKB reprioritization after forwarding In-Reply-To: References: Message-Id: Date: Wed, 01 Aug 2018 00:36:03 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [89.176.83.59] X-ClientProxiedBy: DB6PR0202CA0018.eurprd02.prod.outlook.com (2603:10a6:4:29::28) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 449d39c6-fffe-491a-4e02-08d5f7361698 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;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BExgGdoDEJbv8LixCFOQ8T7NYccyv6cUO4OhUogJ06rB1Do4m4YPexea/kX3mqiK+wR61HxnJWMk07IfD3jmNgM9HWDt7SxBZkXJ9MQgJFtLY/oqTQMd0iI3/B5FS7FWyiEN8sLxnWIg2w91ywlV/sPxFeoUKlwyMBxMCIoyvNIc7sY3lTtQgL4w8P91z7N+T/nRgGe9on0CcEnatTPGyI4Jf9UYY2qVttxypmNHz7THngiLSVlNTtCG3WxHAUfm7dOWwCFxTCA0ciYULV70maSI7i538NZ2ubMgjhsxNbKtMBq/UzAEA8w9zxQJP/w5Joa1OnWkk1mr/UTCVI+ZTERQFNBNYBVmwUQ33jd;4:krjn/mGrLj2Dab+6lq5iTC2OBt+atZt1JIP++5IcWd2Br0K8jBteXnE41lcyFWxUlSZE2gRoJZz3Vv/WtIfmzmDEnBmGAP4+ktf0SDoF+XHDnU93W+qglwhu+T6QNVPs3KDmt9Rl+5hJ+x+uwSilLuBoEqtg7a6XpuhlxUeoX5ppz/pdUO1x9L/Tg7ZyT+nByxFuXqAQsAdLHmL1xk1BYdgmFUaLfUZyWhxHuM1iZPWpu6quh1n8V5/3pcfZxV/o35rFgcW9bnGRKnqYU1WftQ== 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)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016);SRVR:VI1PR05MB4191;BCL:0;PCL:0;RULEID:;SRVR:VI1PR05MB4191; X-Forefront-PRVS: 0750463DC9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(366004)(346002)(376002)(136003)(396003)(39860400002)(189003)(199004)(36756003)(2906002)(956004)(81166006)(486006)(81156014)(476003)(2616005)(8676002)(39060400002)(305945005)(8936002)(4326008)(6666003)(25786009)(50466002)(48376002)(118296001)(5660300001)(14444005)(7416002)(66066001)(446003)(52116002)(51416003)(478600001)(3846002)(16586007)(26005)(86362001)(575784001)(6496006)(47776003)(52396003)(186003)(58126008)(6116002)(11346002)(6486002)(16526019)(53936002)(7736002)(76176011)(68736007)(105586002)(106356001)(97736004)(316002)(386003);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: 1;VI1PR05MB4191;23:qfSkkKui1IidfELWOmx70mj1ExDE7Vrymq6SJ/T7hSoOdj9/XMOVQW2kmAVoTNf2BZeB7YbvYg+iLA3mcLURk4SDD7YBctY/g4PEAyi3Ps09rqG/v3Y333lX5t/4JD2oAsNqU0dONRinG7vJ+h8zspxQleDknGovQTg0Jc1AooP785ZPfAGLMP15iIFJkSPcYapiWiu6aq8pkr4vBt5ZLTblVkQz46Bwgs2hvE6dcEs/P+u74CE28qAPOxibl/UpH2gS+9lo2E2X3yYUXCDMVwXg+F2o+yizRwTfQjjXcINKb/0YykqpDRSVPylA0MufjgG6gFBI8zEOpKJPuk36SwGTxwZEryaplOlMJLpQkn2KCMof8DMJgrhYNH1Ts3edHwl9H6FdswMj1pAQ16Yt0TUIMuNshirMs6qMXub1iJMM6dMQZMlm9LNOUoHqnE+RYXosNBRStLANuFz2A72WYPBdXYXuBgPPHjXwjtDpdyi4YorUxSgc4VI4TmkCb5HTl78ysTxy4YIYN1ezWNVnUa0uG8+qzzLicPGEpntr5sZQFL7F2ulN7mx7LTM9+khNqbMLtzdWR2oXvRwjrAG/PQGF8hws0Oe7b+3ZMRB5bsNhB1Q4E7iR8COebVD3Ra3HSDtGwy9YG/buS5FnuNFo7xybt4tdMweeHDHA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AD3nD0fWQeYQ7ZG0fIGrx3zx9dfAaKqNoErZ1iqPfunJQepILBhXuk2ghEfYOkFCru+kqEzLZxG1t/+tmvW376mjK8qyfetgjWc+cZvETnlHHvFUl60JtN5mprndRSS7peIIX47cGp1A6fSPXp1WaRd+9zb9SvF8T1YgKbi5Skq2jcso8nb4F9ylKkHy2DE4s9lUlJuOPbVhFZUHi9yVAD0SkG3l9/qTyhvx9TX3gae/lDXSASOhZReyycvk+VwnBI8ikGDLrt/xiPKarw9GS85LpdHlD4jriRBYtkd21XQBUK1gWiIBFXPMS26ehNLE4Vu8tW2+ztNdC1CScr6j9uf971HgFFk1ZxM1TGYzRsUQ5wVvpPGZCW33YfV5FmhGxslckTsPeLlbHns1Z5CIK+yA==;5:QEy+XcaWrqm/FaJwwAnDavpiRUFaKEmxK2eLzIxRzs5yQJQw8bxPZJMxrhLwu/HKsDsuYxPDDQPPdr4Z1jfBZQWcmtouSBFQU3fFSY7p3hWBGV07oANf9L/mhfdzKE7eTPeMv6egQvXv6c0UsvJNZxksMQFMqWB/+qV3VPYZxZ8=;7:d+oYcTnsA62ew1HnK2Cgd5whW7FWhRqYTaZ8MjXIi1GxmhxHC6pGF5TWWN7nStetro8OnOPY5DswET/EJTvBUWChZ4/6wYFs+UGjosKLXQyuHyYSr+gnCALI3/ZdrFJKNAB6sr/aN8eDh6NRhYIpseGRcUo23U0488RwnTVsasPhZAWfdO4gygCGwIOJ8gJ59XH3kKhGvBL2cg9goZqYbLyURILTARecEZYUeRAKbyAwedE1Femf6UcLBbc2Ka/F SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2018 22:36:41.0459 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 449d39c6-fffe-491a-4e02-08d5f7361698 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 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..8eb6c74819b8 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 = 1; 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 22:36: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: 10551489 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 51FE613BB for ; Tue, 31 Jul 2018 22:37:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40F372B2DB for ; Tue, 31 Jul 2018 22:37:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 351522B2E0; Tue, 31 Jul 2018 22:37:43 +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 B91C32B2DB for ; Tue, 31 Jul 2018 22:37:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732696AbeHAAUL (ORCPT ); Tue, 31 Jul 2018 20:20:11 -0400 Received: from mail-eopbgr20053.outbound.protection.outlook.com ([40.107.2.53]:10870 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732123AbeHAAUK (ORCPT ); Tue, 31 Jul 2018 20:20:10 -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=NsUGwuLX4UkYDUVm+QzBcCQqqQ+INk8tQUUtSOHLEBB5CRyCDteS9H1Ee9HcpmJtvKwqsbpVeRarAEzjbGqHpgp4sM/pIJ4iDUVmoRnwxN7EIzn0zQgTCJvm0LpFOqQV12bEPkHRwD2tUGTJCfKqZq3BfkXusVB0GRSxIuK3yDU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (89.176.83.59) by VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.21; Tue, 31 Jul 2018 22:37:34 +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 v2 2/7] net: ipv4: Notify about changes to ip_forward_update_priority In-Reply-To: References: Message-Id: <55313c0467f038b52be81b48c270747848c0ad21.1533076217.git.petrm@mellanox.com> Date: Wed, 01 Aug 2018 00:36:42 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [89.176.83.59] X-ClientProxiedBy: HE1PR05CA0227.eurprd05.prod.outlook.com (2603:10a6:3:fa::27) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 78c3fac4-50f9-489d-de00-08d5f73636ca 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:VI1PR05MB4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ZXeI3VQIWtV0TV4YEF10iKuDrdyIhO++bhSGAIk60gNRABevQf6HX923DhJH/bbV/LuW3prhPRFaigkL8rdCvdZi8bAsbdu/7GT1sZkRx1YRozrUjYWL/yEa+lrRDavvY6DDNIGmbph/I5+zhk2hldTmKozmDJ/o5JKM/9WllsMXRLbgF+ZoSU2OLMD4IxVJbStQ9YoAlh7VTtTTYF735R77f4ULuKtUsRBaeSg8tTHxPwMiF3msVylAlresjvceHqTmVwr/Z6BP1uNHRiMszxTYBzml9iNAtsNnWQJd/20Zp/fQPaen8hvEw4vj8gLRY4u+1bc1/pNgjZQlFptcCZ5ihdrNXQocIIximkPSMpq5uzYFIAFUMZ1rG0M36vtu2svTnxVuW0xTw;4:+Un/J4TofGq17oBKqTfz5a2TsQVr/Ch56Ri8JWATMood7WURHeTDWDXh9BV1lBEcxOvvMA3vSI9bXk4w9o9Za4hs5cotZycVUSK+oabPhv/vn2n4Chli/a4S3bOIP44OsfYrSJZVq2vKW2SjNuXeln2NaZx6pTxSoRlEonm0k+m2PI82cAfNdJAf3oR2MaSp29yTXkRSZ0O9Srvwa2Mn5zDEtSu69yGLut4amcjUBXtWsSVwHwOHnXvDH5l3UwYi5zF8DCWuDwY60O/jNngnHg== 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)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016);SRVR:VI1PR05MB4191;BCL:0;PCL:0;RULEID:;SRVR:VI1PR05MB4191; X-Forefront-PRVS: 0750463DC9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(366004)(346002)(376002)(136003)(396003)(39860400002)(189003)(199004)(36756003)(2906002)(956004)(81166006)(486006)(81156014)(476003)(2616005)(8676002)(39060400002)(305945005)(8936002)(4326008)(6666003)(25786009)(50466002)(48376002)(118296001)(5660300001)(14444005)(7416002)(66066001)(446003)(52116002)(51416003)(478600001)(3846002)(16586007)(26005)(86362001)(6496006)(47776003)(52396003)(186003)(58126008)(6116002)(11346002)(6486002)(16526019)(53936002)(7736002)(76176011)(68736007)(105586002)(106356001)(97736004)(316002)(386003);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: 1;VI1PR05MB4191;23:PxFe5Vpg/3VzIOrtn1KNDX4ofFYb57nrMSHblWgBSyR+YtZJXypWN2yPM77Wt0gJKPCOJIm4JiYYgHkl1HKRKpDkGbFXXL/rdgTNARNNRl8f+RcLaFnZ45dVHR3WXGuyujPRwGo9vfhaw8g8xHTk5aRZMi+OjQNbHezzXWV64DMPfMMjS7vCT8dsaetO8Nsq5EvZJpFww1LqMzh1t1bpmQlk0l49wLm8SVcd4KfeEJfn9+mDKA2z+sdXksDDrW86b2ICiZyJLJb3AE5b4L/VjBSq/TqQbtngckoZ7FGyR0vbPC9QOWb3mXTcp2rDWYnx2sHCnroCCMQnwvG5Vy92Vq1kkCZZoDJKxt10rBbpeO2lEmZ6WSh91fPz6bm4LQsp7pmuCGiXAq15KetTciD2aMXCm9mfwK+8WLr5aBozu5AaPQt/UyYETPCUfqLW33+rP2SLAeBfzERtR25DQr1LAB5OEyIRBTnV40x5moDSInZ3fi0XruUE/vMiTT2/avWdODnAPcOW/5ciB1hKqgSQgAGM2UeCslMKzBBEJ5/zxin5fIZP9nttgr09/9ce8q5iM/HfzrGlPlrefgm9xusFBkHtu7bQmjzLjUemi5sNw3mlMv9uTP+NDqKts/giJ7ibptQhBsATUqL5GcQAyvZ3DEVV41xAswzau964fMh9uHfRJnpgi6hA17So31soXQi8LofW9503FE6wUtpuxcBd6PBsB9EIIX/0OZh3FelHEqpJ6juqZZaBM7biuzpSCK+GNkzdnaR6cLqULoNWHI6NjK4LJPYZgTyOVQO+vLZKuLBpsRpAk1aLzNWnN7OGzSJ18Q69WkbUtTPed2mITkNJpbNMzc5qXnrfx7YqyACYnPTJc/d20929Qn45vGgzYydN1QfQIkp3okM4JhES/UT1TcT1vEjEpkoCiebfnnsoo5RtlBIgiumFKteRrXTwjHIpen4Byu0PQM0C92EoQLL4yJPEGXQTTpKp/nhgKNVpdHyI7qaWuizm3JY4Y5fAMJwnuV2EQvWQWzu0v4St4npY0vsWrhlftCMWhIxXN/mbbOrWR/rmKWaQQtRsB329VSW9O38IKfsSfFCfjKosTJ45UjmCo+XxF5XcESXXVsVwNEn80pPCRp8jtB4ZCe90L2Yz/+LWhR5SoPDEBzgWY/gsSLJG90bx7CXkP3fKDaNZ3eaq56e20HyvR4vLUu2NVYvDCnrX1kllYy758xTjtOdHEw== X-Microsoft-Antispam-Message-Info: bZtLqa1bSVeLceUN7av6HV246Cq+Hol4i/aKuiSI9e9EfgkrRZeE683OhBZeJmEFxeak5loIJ4QEqKVYu5+6liRO92LIlXL16YEDgKrDllZRId91WUJcuahIfDMK9VDyuheFbNFJcM9M5fwzpPIlum1zVIM11hwpUszwgwaQVC2yIaGWcKuBa4XFJxnqo9cKoUx8Hh/c9dWpxwTt/AEaRyerVDEKdGXcyzqoWSkLwkiP6MUMDnO6ZQdaJxOC2k5juMG40XyIhfOLVvXmj31YqKQBTRRO0CjBaZ8tCpYiwwdoocPvYcOrPhJoLqdJFLZB3fZWNePeBglRoz/JC/tsInuowaaprLDo0py50fXU5A8= X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB4191;6:VBYWyPGz0cuaehAV4Zn5GC1SSKDUyKyRYgaocZniZYe4WMRfdX0kScK8OSVEhAckWp5cj8pi+vZTVkD54hqElrWGGNRVRrmjMOA/VTp7HECBnf+6ZTtdgKpgr1FPFW1/vGi5jxIjbL/YcIZBz1iCiluFmj6ixDcXFeGDPAJxlcpsIauhY9ggHvPaI6vafywxvBTOwF2jgt4yqulYkJeXNq0on5DCUah7hxaawQZyGme7+YvxrURI6MLFPKdnoi5eEZTpWN35KMFmMpp1GCLp/+01I0MffX2/OnNIsPAEzZwnl7H0jHQ/OcIsBsvr1AwccgYXDlCoPvfKAJ/lbngtOwnOygW3mi7bA6tV2dYkGpZIT4WCoWhZGlPPtZJayY8vUzYsXpa6ee5qVtfyn+TJnx8eLr7uy3nqeQ0jVLeWnQ9yyUJCpPyeMz0LUcDAbU698zMbdJRakZ7SREeN2/x8NQ==;5:k7JrJcLQXh9VNV+Q8Sjp2iohYyxiQ/om2S5aGFyUb5xrByRU+iDOHg2peAo4PVk0DrUGO/R0pmRtG92xAYG/LL9lsn5n33tUOrL6kfPwIWnNTIsbt8yuJ6Wc6uboDi+NRtjLdcOuEhPhzeaoLb1MVushU3EBxxEPZy0iSf4ZOwM=;7:rVJ1ojm/jnaWeafyrMW7hLiplTCOvp5dAHJtkX27qua3aYUGO5wb/688LclHmaEvAI2WXFG4jhlQ6OAXi6Fo+lb5eZ0+fG1dhkd4+zqkoexUymVEIQaZL1GEIYJ1qwj605BFWF6/EYCJ66aUcRAg3/IgY1f2xJCBx5JoYAnHfSjOgxEtkOMk55v5NNjb6HW17TtKgspKGNfcIUVhAsLnRRmMCPT/xPsq/XA1FENuP9DJwFX60u33uXhZYZLjfe0d SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2018 22:37:34.8723 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 78c3fac4-50f9-489d-de00-08d5f73636ca 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 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 22:37:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10551491 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 24D7A13BB for ; Tue, 31 Jul 2018 22:38:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 132492B2D6 for ; Tue, 31 Jul 2018 22:38:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 04D952B326; Tue, 31 Jul 2018 22:38:09 +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 8492A2B2D6 for ; Tue, 31 Jul 2018 22:38:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732660AbeHAAUi (ORCPT ); Tue, 31 Jul 2018 20:20:38 -0400 Received: from mail-eopbgr20054.outbound.protection.outlook.com ([40.107.2.54]:2896 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732123AbeHAAUi (ORCPT ); Tue, 31 Jul 2018 20:20:38 -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=KEgL6hG4w4yr26oLhzpEb5673a/U59h61lRwGyVcjwIrqR4jUrSXpRM/M9Ptn3UBphBwkxOuBfzpNvJwW3USydN9Y1+YLgxwurOQU2yyj9vYyTVl45ARK3jvtZqACme2VeG7bJ0w5sBdayvz99jCFvRTygMFMCKoK/Y64fsbH4c= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (89.176.83.59) by VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.21; Tue, 31 Jul 2018 22:38:02 +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 v2 3/7] mlxsw: spectrum: Extract work-scheduling into a new function In-Reply-To: References: Message-Id: <81de49a9f677be1d741076e7f4aabb90bbc441cf.1533076217.git.petrm@mellanox.com> Date: Wed, 01 Aug 2018 00:37:36 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [89.176.83.59] X-ClientProxiedBy: AM4PR05CA0028.eurprd05.prod.outlook.com (2603:10a6:205::41) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cc1aa5e7-3166-41cd-31f4-08d5f73646b5 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:FLTG6pTwSORvhokK8N8DZT2iIUuoXvCdr4E8V5TIf0qGoDKCvAu2Di9o2Qb9GvxX4ah+k9dKV9g0/woiiJBvAhfUjMDJUrY/3docbSq5WaxfUWrxo0n+557J7Iy1sjtY0kbVwqh/QDvt789VSIsN9+UTpLKuS8nGNOdZds4BoAE1aqp7/KlO/dMnqS9WrdLQORlkC4p6KiU9lzxYVH/IlATyCpiNs2E77ALxCzKo9Qxa4WCoh09K37f/Tq+PSd8v;25:+scX64h2dVsAhfvDsfGS3yjkLFZXjJwtYjtI3pLzLTJBNVFMBzf6DlIb4A3BUIhvxdNrSk3IVOTdLh4sWZP2GLDtMLRggeMeuCMlcwzlfO+EG3vYav1dwA1ZjBcjIRA4a8ULOMywYQAYGXvfM+9IB6wzKwqmZMx2ECO1OJjpmHvOpLHIpMsr3mK8pFXuD3pqMuMCYcB0FfONuqecVJDmFshGqwlWJKzVuqfqQQ9+JYVVK+hoLTlHw3o9NU/C9DL0u2e5wqiCZr7jQ/OD4/KtIWh2Dub8+dGa1Q8fIrKJ4hNuQy/Gsc7SSuxV8NqSYDlVzDOg+kaYQCBwddGBAbrctg==;31:NHf2+DtkQPUMnxT9ujVTMD+tUMvXIFaY4ubmdSL+KfNo0vAUegyjKBnPvugYi2A5K5uwcRR7VLMwH4In6HpkH4khK96H6/agDJWeH8r+BCHDyZuRRzuJFj0vVGv57QCTG6yYVVgxomB++QQy84kiQI3oxeEehbjxge288uk2qG0sq3ovC0jZ5v3QCtW4nBP8RoaGctRBoxYJiFZp8dFQpqgfQ+R0ZcrcNyoili9uNhU= X-MS-TrafficTypeDiagnostic: VI1PR05MB4191: X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB4191;20:JG6HHkPx+VMdZhP0QWyJ799lQuDIyTP1Tk+4c3qZPfeQw/Yy7WYaPbeZe4Z9vhl3GHbu+KtLo5cd2Dh7d4r0qOtFzsejBH6UA6azTkeGltOnj3bMDGJ801nqcKlULlkSzZQVpqsxrlgQSso2zS8R9mlVmu8CvqG34YHnh3Qxhpjfs5rb47Ia4NVEihkyCoJW0U98Fzuo04yQkHtWgUKdNQiim28qUzkzRhqIIEjtu8A4OSyHiMMrrQNUodj53doDG2tzrwYyKUk267XHkGwcWNPGuuGdryjxNdqFmv3ey+/fv/rHagI2cg182cREvJGG/svE+mInqpi1oX75XRgHpxTcotd3l2Y6vuKi5to93P7vSrHkEd6VIGm7qavnNy1LB0EeWfZXPnEcFVRSnlrRUsm6lt1clExZ+0rHmiebeP4mFEeFwRilJAMs0FGZpO/DOdGUlGHR4llgbMFm+VYvgXC0tMn2nWwapmbwJSHZtD945AEEiQiXl3ncrUzJr9b1;4:k0mD891bF6o8X3lf5ueskaqak9HWi9CfV3HZnV6oAL1rEj1BBBT9ftLdROweIis4izpZ936cw9/soRF/WPzHubgzaVdZ8NCaH0LdzH74GdlFplMt2+DwYTIZXIvEz6EuYwKAqy44MEk1uKxZCQ74aZw/PYw5NsXCVJMQDbGdNNloWyRffy7HgB6ntrG/RmDvgvNposA7uCa6cuSqLmAnf40V8Z5FrTwQuq+1Zo5gJJYhzYTHIKAyo3HRJskZuwJCb9HApyEVa6DJ79efQQ/Wig== 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)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016);SRVR:VI1PR05MB4191;BCL:0;PCL:0;RULEID:;SRVR:VI1PR05MB4191; X-Forefront-PRVS: 0750463DC9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(366004)(346002)(376002)(136003)(396003)(39860400002)(189003)(199004)(36756003)(2906002)(956004)(81166006)(486006)(81156014)(476003)(2616005)(8676002)(39060400002)(305945005)(8936002)(4326008)(6666003)(25786009)(50466002)(48376002)(118296001)(5660300001)(14444005)(7416002)(66066001)(446003)(52116002)(51416003)(478600001)(3846002)(16586007)(26005)(86362001)(6496006)(47776003)(52396003)(186003)(58126008)(6116002)(11346002)(6486002)(16526019)(53936002)(7736002)(76176011)(68736007)(105586002)(106356001)(97736004)(316002)(386003);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: 1;VI1PR05MB4191;23:hNb1EHG0gsku0K6qoTlAttLcyq1pkqQUwvhSCymZI+qx4FnS3gKLNjAoNVZA2K0BqM+2eA8IoMzX6a/tB6UbKl+WSCk6JdMtn+T94OcFGRF+snooHyH7X4yMa+eufD0idrNNAuPWKQUE6XHweAJ7k6OMBqsvlHp6cCCTQQiGx7cDxMPopWXpl5UOJCGz6UwgjiD4NJLlQHNmVC3k/EkTZ71zoYGo5BGwZU9v9r8HD9WbaR2tTd8HI+bGXYoCZCThxFVn36xsKQ3QjepeBkZsoVFos9b+3mN3jlnvL7Z5EUSV2R818TQDhfL+1TEX0wE4mPF2NSLvubuCgx7IECG+c0hG2fKEtfFO3/QC/l07iiSTHuu0faG2zPeS1s/s2JRSJ37BQVZ/UxlKT5AJy0fncJhV1lHofQjRi6MLn1Xc+UVwmuGB89D1GsmoeieYuHQmnlz4IzxYoD9DKXW8RUg3TxIXYbaefLxew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eOUScMW54joTo8hFXnycSuPsOYCQUTo91dkEepMrhN38px0uf49OZB5mkvPem9ZPA/o= X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB4191;6:z176vO97vyFcXUDMo0yu4rRuj+EpAQPIL2637ZYbAb8pXWeOfO0aq8Dc6MN4BYXwH79ou7lIF3C8YPPS9BagsEMOpj+NdIzxvGyQ6PB8EJu45dKY6vP4YBPGtDIjus2qaXmRproJYGaQiGY6JCt0DbAzZvTAuk7aKPaaj04T/gB4ror41cJRzjEL3RtfbUYsz1qXvloBtg7fBtYuiTiahE0JrUrxn8+zoL0e/jIGKMXYb2yUFRlK5+EM+7OZTJB6dzCQuPyqw06ygdT7Q/sh2SoDNJgF4O53ipiWyIr/6LzbKi8Zpt38nO5MwLXdOC58PIZtKH0D3eD7P5kqJbLzKtZ2++BOmhg5HovyyJLsLVgYhR3y0A+uenJEoU3xx8XpzNPuNZAsNWpDg3lR3on8CKYxSVUNQaKG18pLaf3lZCfP1bhwCeol8/hYuL2h6coKuVKLxOIYs89I1oFzqna8rg==;5:iOaVxplp03u+Q/0PJuWg71gfA+45CoThYoGNH4Q81uvARE9nPDOePgr7gVHOYPkPeB2u5N266DcNt8Ib9NKEGKvffXXd7PSiBMseOrB/zbAj4T+CDomj95J98vgzzKCcZEP4N9nMN2ewg6Z6tPHV3e9IDoI8FfWxsMMDge1+r7c=;7:q4wa7PODCAZpJoQFqSFwPR6BhhC8Dy1+xZojTQP/lTyN6WEW1zGBRTt9xE8Px27DK6JgxIc5GV9pNVX8SB0cANMLSLTOioBZgtV8H1wJroz5s/DoLJELp26PuVP8oPEwJ/z14oWMttgt9JL6VDDH2zlmx9/pYXe/DszlU96TF+GA2CcSbZv2azu+GEgf/lwQ1RI326S50h+b8dtQVKauo2KDoWae9Ul7LMUr+tSvUqXp6Xu37Avc5xks4TGSDcBL SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2018 22:38:02.0221 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc1aa5e7-3166-41cd-31f4-08d5f73646b5 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 22:38: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: 10551495 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 43280174A for ; Tue, 31 Jul 2018 22:39:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 334222B323 for ; Tue, 31 Jul 2018 22:39:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 265B02B329; Tue, 31 Jul 2018 22:39:06 +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 7D2A62B323 for ; Tue, 31 Jul 2018 22:39:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732646AbeHAAVf (ORCPT ); Tue, 31 Jul 2018 20:21:35 -0400 Received: from mail-eopbgr20044.outbound.protection.outlook.com ([40.107.2.44]:54942 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732123AbeHAAVf (ORCPT ); Tue, 31 Jul 2018 20:21:35 -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=aGOFggM/jufFQ2X686skvCaw5hCQgoR9d7N64vTuxbm1TjEA2gZ9JDkbaKqKkR03iYpzSyK3bAjLwARyPd/IbQfGt/SvhuseFtv/vesAWgV6UHmdmiuRBm7j1vOhH6E+rpN+7wRW/QeIY3SKtLmGcePLZIIMhWBPa+Zv23fBW+E= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (89.176.83.59) by VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.21; Tue, 31 Jul 2018 22:38:57 +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 v2 4/7] mlxsw: spectrum_router: Handle sysctl_ip_fwd_update_priority In-Reply-To: References: Message-Id: <612b9ef595e1cec62711aade431dfbf721499147.1533076217.git.petrm@mellanox.com> Date: Wed, 01 Aug 2018 00:38:03 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [89.176.83.59] X-ClientProxiedBy: HE1PR06CA0160.eurprd06.prod.outlook.com (2603:10a6:7:16::47) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cca586d4-239e-4f2e-2da6-08d5f73667f6 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:P4qpHZ0hSLrWOHKknk29YOncxZv2S1LYvGEgjhTrr4QxFIFKE/UfwI0bmNBXYQS/TBbjW+3sLN4YMrUHSGe/2fmagAwamojg3f2QoBubQ0bv14H3+DRvEa27Slh0d74IhEwjO2NVDBh0xiUR4AGSsC2ypIKjfX/hwd0puJLvi8YUsPBE543Bh4hPRqkcUjlABrfKrYkwIkyL8KCZRDz8CPQ5BQULgF18dkmKkE6ZPCV+wbf9Buny0xe3OQ2/2V7a;25:sXH+PJ5oMTt2dWT683VMVe3MVx2kdlMcpGJMxblF6PWBWRhffkRaZ7R/q6TA5jMauA9KLeoa2ZyqYAcFxJBGaRucMcxy7m9v2SGT3sNCUCSsMFAzG6yP8ygD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J0gPGzU2snBz290K+fPfXymM2elBQDdo42z+RVTIFcF2QgAtHDNAj5K6TjEf0giPELgzQ/Dnd47FWbTiEmPBP+ac1Ajtjl8P4H6KTNlSkf/0J3aKk/YNjkZkMvZa2XFo7+6OAeRLi4d3ofyuiXzcvEJVJJS+jp7mIqMm28yAvimubctCK2y795u9ODoiTiX7ccN7vw52ujzTj0gRo4d+AqcK1GUAcAtpsbYbydQ2cmqvhF4isguOg== 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)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016);SRVR:VI1PR05MB4191;BCL:0;PCL:0;RULEID:;SRVR:VI1PR05MB4191; X-Forefront-PRVS: 0750463DC9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(366004)(346002)(376002)(136003)(396003)(39860400002)(189003)(199004)(36756003)(2906002)(956004)(81166006)(486006)(81156014)(476003)(2616005)(8676002)(39060400002)(305945005)(8936002)(4326008)(6666003)(25786009)(50466002)(48376002)(118296001)(5660300001)(14444005)(7416002)(66066001)(446003)(52116002)(51416003)(478600001)(3846002)(16586007)(26005)(86362001)(6496006)(47776003)(52396003)(186003)(58126008)(6116002)(11346002)(6486002)(16526019)(53936002)(7736002)(76176011)(68736007)(105586002)(106356001)(97736004)(316002)(386003);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: 1;VI1PR05MB4191;23:IB7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FbF8R22k4VDss1WL1hAJ++GYflOMJDXLuaPqmLukzW4tAsvSkXDnoyFmLZ+SBIKyj5U1TlgUmUOkgOfZk69oopXcILlmAKtiEkjDdZg/jlfERXKqdC9j2M1CwCd8mnWdWyMxrbHq3ruSGxhNs83X28=;7:drclrz6eMhFNROsztAz9UBBFXUex7Qq69RV3Y4728PIqC0hgVkKYhUGdM2F443YXGvlwd5IAzOFx+E4GZcnwHTGEYQuUM3zR/6QQEYTGoQc6srijf1SFXMqzM0TKjOV64o2Bu+IgXTArjMt3z1otF2B3WdNvfu2vmMvivd6rmwy3ms3lKJdeeDSxyhvFux6M1Mwyft7fAfGxYazYFmIVTTXWN5RsiPXTAxybLknsCUTzeHKQ1aMvfnqa0OgWz15E SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2018 22:38:57.2054 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cca586d4-239e-4f2e-2da6-08d5f73667f6 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 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 22:38:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10551497 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 CA76D174A for ; Tue, 31 Jul 2018 22:39:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA0582B323 for ; Tue, 31 Jul 2018 22:39:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACF202B329; Tue, 31 Jul 2018 22:39:30 +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 2C77D2B323 for ; Tue, 31 Jul 2018 22:39:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732659AbeHAAWA (ORCPT ); Tue, 31 Jul 2018 20:22:00 -0400 Received: from mail-eopbgr20055.outbound.protection.outlook.com ([40.107.2.55]:21521 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732123AbeHAAV7 (ORCPT ); Tue, 31 Jul 2018 20:21:59 -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=iPxslGJfUzjJ/kzCgDRwlGnZlw4na1PjPGxnpiQGvYiUwifQN0ztfb3UDghjMqm/MhEmVSwcWJyOU9XVX1LJd1vYekEQjoboiN9HgX7hoyInnt8+o+ozmcjd8G/ajkmfhgUtlPgGLvUwdn2LLxhlqgjimtwOnF9GGy+YxcZ9coU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (89.176.83.59) by VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.21; Tue, 31 Jul 2018 22:39:24 +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 v2 5/7] selftests: forwarding: Move lldpad waiting to lib.sh In-Reply-To: References: Message-Id: <94801d18bfb830355aa1b3c8be46492b5711fdc0.1533076217.git.petrm@mellanox.com> Date: Wed, 01 Aug 2018 00:38:59 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [89.176.83.59] X-ClientProxiedBy: VI1P189CA0017.EURP189.PROD.OUTLOOK.COM (2603:10a6:802:2a::30) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c0018962-f7ab-4c70-e92d-08d5f73677aa 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:mNvwwI3+5m7WbUuP9qLAt0WB8kF1SsScCw3CbaCh8w4nyuDNn3jqJLEljzuKcsrs7g3JrBC0zmlvZUVO1HiYGDfIfeAq1ZzEx9gxhGcwv9HQiSz1Si4z8mlDp4tpD1KZFU0fk091BREPhLa+5xM+Y6ZGdUj0IaaeDBNiirvzTVjjV22QNOVTN7l/CVk0b3n4M1sInjM456hykQlKf1c10gm/l0LyabJV2deYj2uUsxAWKC9uO2nkX8WXUty+3PUy;25:8nYbIaTolDfGd1FCAoP8d0vAKIXRRrI6bfgbev9GpALX4WZw6z+jRFCWrYxsFJpABd8R5XmREozbM5DtV851bl8aHEROexMZ0FfBOw3M+i7S0VFZcK8B6BtLJejjV38jfa/TF+2X5BpWSkO0+Xy9A2XnrurBqxrzeC+Kbe40lOeCntcGylLaT9VEYTUc5vvLSqIS8KkO4i6UgpmUpuoZBboEdY57EBMm0Gp8o0kzs8IXawrQoE5+4Ql9Je4E1YmDa3AhHuyKJm3FRe+1tTmUVjNcNUo5Jz6rrnNoXRsDKXPhRu1I1+Ln5IieHQgtUhIjrSPVFCfQq/kM4AmsQybLJA==;31:me/5C8bUago+OoAUBChIR9nP0GV//krKF7S5uLcBvfl4eGdt8VHn4o0mzFrPE8rpA9Xvn7sp4W4SfbnF3S0sbc1lbl0qiIc4VGLMfSav+Gjqi6mMGFrlIJI28c+WMPG7kG3cn5+RZ5pX56uPRb9W0CzAhan73oyGKIgXq48PGI4Y/QxKQljHiFAVM1197I0EGE6c3FXzDs3fzqSylTpXtD/7dGreGVHyAxvcCZKgr5I= X-MS-TrafficTypeDiagnostic: VI1PR05MB4191: X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB4191;20:0iX8Q9f62C7dVE3E2PI7DPxsl8+zKKZ3KAgGX9ye5nK1idJv4l4QRo5smMp7uEugupKNttnN63t4Glz2vn3TQuGSqZ7sKC7JBrBUAW2XvWeclhutuA+D2e4BU1Zo9+1mnftmn6LhOIoNU10WUTBye0FWdLbt/5pMmvBIXeJiK8JZpswrzjDyQ6C0nqRBrrprMV22Ezzrvclcu+JOit9jYxhx+HfUv52H6fRrXHpNGMei0UYtnRnJIQArcNmPTY4cZvHYdY2MI8HqDGT+oUmEG/CQ6M/+R2z/5iWuB0rInsXiFJQcODlUWOMBBtsTPR2DhiATBA/c8FwijEfECoi/PQrC5gp2yRKxRry3NOxdsQ+UdNMWUFAPQp7Imwxok7NhRI6R0/Yu+eggYGIBDh5q32oYWQn7QcH1m0bOzCpi+IdecHkq38QYe2vDqEJUAgSHn66YDaBT7wcqASzeqzfed5YX4/DA1SwbH3GHkFRSouAEFZHb2q7lT+rJMQx/0C6Q;4:rxZMnQ6brVFe7QG3YxrwUhxNr9pG30aGXi/Hy0B2Oye+ug80w5f859nhfHuBLEiruUKFhuKisH7KAL6oOBc8ZI//q0TjrDeM5N4oMXONGMghEBa/VZ0yemgAE9yFYzug8z3IDtt+uei5c6EIopVISS3Lsx6leUguS8ZAE6zNxIanyT8q5mphCs5UwEDYJd0VbCJLObDR+qupuh+sL0Ixy+Z+R7jLrpVTykuQ0x2R1nEAWaMvtiMQo1PmXEBGKQNlS9mNQAWpGPvCsKaot7EHbw== 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)(366004)(346002)(376002)(136003)(396003)(39860400002)(189003)(199004)(36756003)(2906002)(956004)(81166006)(486006)(81156014)(476003)(2616005)(8676002)(39060400002)(305945005)(8936002)(4326008)(6666003)(25786009)(50466002)(48376002)(118296001)(5660300001)(14444005)(7416002)(66066001)(446003)(52116002)(51416003)(478600001)(3846002)(16586007)(26005)(86362001)(6496006)(47776003)(52396003)(186003)(58126008)(6116002)(11346002)(6486002)(16526019)(53936002)(7736002)(76176011)(68736007)(105586002)(106356001)(97736004)(316002)(386003);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: 1;VI1PR05MB4191;23:8lhs74VIndpOZFqOA0q+UNSAIKT4IwdCOO0eMJimnKNO2tnadT0ndyNthCgFSTJ+dTER46sdB0MbI6yTyesNzWJ+vCUsqQzZo5S8xbx8XXbecboD0o3DssBU9qbWzf630PyDWZU7Fz7xR+EDZraE5fkMQmmBuNp0IrjJjDDW5ea9MgQkW3kX3akX1Z9Ft1sU9h34Wbn231Sj9W+501TAPZvJHhehwNizIaKPs2NmuvXjRyGv1IEAnkgZ+6YsXSHN2LQ9mO1cosWJUVSG45dHpLR8OsRnL+YgYomvSPxMKpBjUNTO06UIYyBmNHPjSxgL3NFOAcXIM1TYhkBdmi9FSzeOtHN/0HQXu0sMdTrDIR/Q3x8iP/DmhwS4SB4mbzrdVPxZGHIQeXHNW6zPC4Oeoa5IdPrSfLcTiVPT/OUg1PGFwjb1CQaGpKRrOJLUbVh3m1wSQUZ1dO2kDoGm/hFbgR+oNOCWGUTxAld2pncHHFB1c0c3ytoqixZ5bte00d9KKmyOkS/ylXInsbWjMu+gb0CiIbuqbveCYJPdiUsmeE2r2lXGv4bQEVbH6IDDOC4lleLmmXCK4vjSIsaAcTQ7ZDe/LWb53gyVB5TNxqi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vrabh58wQx28rvydWVd7Iup1yDiIFkOHmkGmUXHj8CUA+PYOVp8i9pA/vExggpQIWKDSF3IforZLMc4/cZdXUVD1Bpt6BXzYTjklakJef/geyfWsyc31pUZxm/gzL1m1P82dTTQyg0SgZjDY/ZL8EdBrEUuj2+pqC3l2MdzF03vCHsRZ7F+4w47hnQvv+iWP4kvQoDepRzaHQaxBw+6fbZKYCNz5jBoPmSCIg3JOj/3vScoFxDpYtnWxr1PjVQA3Y+8U7qp5AUsqEidZWejaywMiiE7vS85MR4nL1Kas3TXmTMDcvQ7230qlPzycKWBb783nNM051zOPEJleCT9k/n01X91x7NP5EaJK7b+0hFqKGHG7oAdSqrpClXoOHPWSxENbTYV2mp2d2dYGOY2S3XWYOlPQIDz1bZt5b8h6ZK05sac/NyVyNPQ==;5:qW9KLa+D/4QgxKeTsV5DV1pq1tYH2PrxWcCbnVX2UmtSsYL4JmKORVDu4loC5SHGIsYd0b6GIb9M1ttP+KS0UY6iiZDoUpBM7L/CajLUzAW2BpI7mw9YBK5Q+kz2bNiWwcKfjUdgPnEl+dIaCtzJAt/taMt/USDRx5m8LnMHuIw=;7:bWf4/OE/qsgaVyYljqp6nYeWJAYq0V1pQstdTDDCVnrer9mbg81ep3CTKADAWW9aVrKEhj8uHSiHyrJf0tvp2lV2HW/jZPUexT1se58BiqbFYploPTSxPNw9JvFLKEjj9X6Ka7G9b2UPYMS+pOcyjADd1UN+LEOfrbaPE67CrBu3OjK3ltm+T6ay1nZAt//s63XksQyJgdUYm7jw5yWXFeWBC8JnQtqCvOI/H4iaTYKWHY+gEz69PeRH6szLDRBp SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2018 22:39:24.8285 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c0018962-f7ab-4c70-e92d-08d5f73677aa 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 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 22:39:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10551499 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 3ACE813BB for ; Tue, 31 Jul 2018 22:39:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B70E2B323 for ; Tue, 31 Jul 2018 22:39:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 200582B329; Tue, 31 Jul 2018 22:39:34 +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 994A42B323 for ; Tue, 31 Jul 2018 22:39:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732716AbeHAAWD (ORCPT ); Tue, 31 Jul 2018 20:22:03 -0400 Received: from mail-eopbgr20068.outbound.protection.outlook.com ([40.107.2.68]:13680 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732123AbeHAAWD (ORCPT ); Tue, 31 Jul 2018 20:22:03 -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=ibpPmFVp5aWRZp6Y1UnvXwHzqQcZJHifKciAwcAG1ysLX8R4PwbQzi+sQTetg+UEZ2GczkX8UNfH0nM/IbuRwEqlP7iFOykOlVZkmsKanPWoElU1HtgJ2baBB3b+GCwdRA63bO4N17uUjy9IuuPl8BP43L6/pOzydq9QM6Rb/t0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (89.176.83.59) by VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.21; Tue, 31 Jul 2018 22:39:28 +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 v2 6/7] selftests: forwarding: Move DSCP capture to lib.sh In-Reply-To: References: Message-Id: Date: Wed, 01 Aug 2018 00:39:25 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [89.176.83.59] X-ClientProxiedBy: AM4PR0101CA0071.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::39) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 12c3aabb-c278-418e-b1c5-08d5f7367a49 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:EG5UpHCX38bncR32p/uaLbouFxg1zMTyQkyyaKAmNE2/tr8mG+Qx5AW1DuBG+/WbKK5iUAOkj6opgAtk7B9MeGwNO6JIFWbzPkNNb2TJb4Wbxri+/gD3J43tD9ja9RLwvBuCRy77fIB3oM1bQoc/FsL1V4GYNVQN9pM51Sz1brYNrTLoGY5EghJjwyqJ7ohxamu1axfNtnOdMULqkdmcKzkwk82IrdBvpsVYbhy9I4VwxP1MEep1K1/htDc/47yY;25:ABn66G6F2u7GWkgj1AcGAjD9MFiRPkPmX3Sp4KxxJ9bMzOCyUw1TEszIs1z8XvpQ2pCDgjeHeXPaR9F01cEbgDxIaatTT7WRCAUFeholBZKVnsb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5u9DzYu0x/PHqQmMjr4wWmgtG2jNWF7+TZRfbKLu49Fety8URMgu1CGkbNUs1Z6kP5y1e6nDzJw0rJDmKySse4RC1sFf/C7ECI4hL9mXHDwoWSnkVYhIaW6zlw8jYH+ZnIdPIcJn7OhniK3BfZ0OaCbYEwPv5onUNPWsNDwQ2/pqBBdGCy49BOdFXxC9xDncvnR2cp0sidO41rLKXvS6DPBtYufEPDBDq3vJ/1AXGiAD290NdsJO//MLbHLWLuz2YxGAc7mYInbkeaqAU7NA== 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)(366004)(346002)(376002)(136003)(396003)(39860400002)(189003)(199004)(36756003)(2906002)(956004)(81166006)(486006)(81156014)(476003)(2616005)(8676002)(39060400002)(305945005)(8936002)(4326008)(6666003)(25786009)(50466002)(48376002)(118296001)(5660300001)(14444005)(7416002)(66066001)(446003)(52116002)(51416003)(478600001)(3846002)(16586007)(26005)(86362001)(6496006)(47776003)(52396003)(186003)(58126008)(6116002)(11346002)(6486002)(16526019)(53936002)(7736002)(76176011)(68736007)(105586002)(106356001)(97736004)(316002)(386003);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-Micros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5:jTMs+h2UQ0E5x3S0KieAZGjLCaeiz8yUdzo83RCapoe/PIl7ctRRLgl2+acZEFi2zewesSEtZNZKgUjkxMR39NQCHZKNNLQjgBGvHQ+WMxJ76l19/h+L2aYr26x2MtyXdNy5q/t6lJ4SFIh41YDijiXVm7HveJHoSfuhZc0CXUQ=;7:QWoJsH1j9M+WkBP+i5exj5oV4CGw5lCaLfFpP2+zNvuNsDkD1wGesUr2Oye/DnFJawYrgy7nVNYNxdkrmErOkhtRukyx1L2w5gN42j0SpiAPoL+MvWvo5ZDigLTW8c0lGdifkxqgLMp9tflV7Dclk5eOT5vE5gs0WY17AaqZttCJqjhWENQewB9GdRsGFfasSlh32KEZ5dhwyEhPTXFk5orVonNwiUSSJP29oToMya9Doh/Uys9lpKPPCWOndwzD SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2018 22:39:28.6171 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 12c3aabb-c278-418e-b1c5-08d5f7367a49 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 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 22:39:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10551501 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 827B013BB for ; Tue, 31 Jul 2018 22:39:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 719282B323 for ; Tue, 31 Jul 2018 22:39:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64FBA2B329; Tue, 31 Jul 2018 22:39:43 +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 AEDE32B323 for ; Tue, 31 Jul 2018 22:39:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732728AbeHAAWK (ORCPT ); Tue, 31 Jul 2018 20:22:10 -0400 Received: from mail-eopbgr20073.outbound.protection.outlook.com ([40.107.2.73]:18880 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732123AbeHAAWK (ORCPT ); Tue, 31 Jul 2018 20:22:10 -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=O+CauxXwvlFl2oObWMaZxbtBYxk5bRZt93cemYq1iXJBMCkI05hSWFmYBjvBJ+uRTE6bPvUDzhgZ5IL07xvERjYlgzoNOEMpa4YarRJJnZ0Rl5NWxyx2eS2i0DG7lvpbBfwWSMxDudVOgNpNY/H7UTVOREszQeNFfQ9XYuGqV5s= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (89.176.83.59) by VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.21; Tue, 31 Jul 2018 22:39: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 v2 7/7] selftests: mlxsw: Add test for ip_forward_update_priority In-Reply-To: References: Message-Id: Date: Wed, 01 Aug 2018 00:39:29 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [89.176.83.59] X-ClientProxiedBy: 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: b668f25c-df39-4e0f-7407-08d5f7367dad 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:3JUfTcJlvTKOY1csV0qyVgZz5G0ljKG+u0joH/uqDTVsR4nayF0RuqS8PEaaf3OykEZdWi/eBL+Rfs2etORBVzHgpdoS9ZROl5cj3g9JxL9uGasf412G28R+ndhUpUoOE+J0nfRxfKVPsEfD09k5Z4foK8mrs7Q1QB9z5kAdWyp4bNPDqcNbZzYeEmNYcKiF3kRlrg6etQ4NVUiIcqDunUiYVTMsL8H/oGooVJ6O8TvxYA0vknaVd1lqB1/Qdn5G;25:xcG8X7LpM14nGvizfYjuYq0czBgDI59nwlg+IYdUxXu/F/oAUbZMMUZ2vw2KhHEcL6mLI/L1d81LOKNm4DS+KQODTWrYdgfoYixL1OR1ss+fmFkdlkz2pSzexgBxVahaFNTNIeav9PNPaRq1jvqYRJMG4t4uF21fE1yXIzeB/tovmCuVpq2hbT7oXnhBEfeKTiuoMSaeYclT5bnwS0PbDd4obDz+1D1T5kj+DZjcht3oxIoobvazFBnlnrn/7JPGwgG/7FDjCw6nllaQiTX6aeS0EElhur+3+kmSLtnjs3lp3J8R0bk0wD2ZBPURSPIc9GOvaSj2aKXgC5k3gbv/vw==;31:v/IFi8hl0Q2dn/4ZlB3qpCS8BvUtePlkndBTqW7CyQXhkQWlkmn5KbBYPGacNeh7LP6VebPpDRjZFD0Pli0eiknY/kYnvmgVLgA3ERUnLSXComoq5CwyFdRn8myLzhPdOhbSEJu3Mw6AnlN9w4M/XX5Anamiw6/Foqw61ySyAhT/cm3S5ipEot1raQdTyliqeqB9TeuG+Y6UDFT/nVk4NMxc7AiGH7UK7uc4uS4EMtI= X-MS-TrafficTypeDiagnostic: VI1PR05MB4191: X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB4191;20:uQVB52LkCQePEbL9KvaIw47nuTYx1wRqVFnCkdNC5sQE+gB1XkPrAJ1gmMwYg93cHvQEkrr5p595ReMMEVuJHCPXXn02XgoDL1TgaaeQcnD5Jkkee564Yz27Nu8yH3DCWNV8R2uvW5VtNc0SNA5B0gujgnYAcWvG0SYX8kYXSXH51nNwwOiVC+MZjmh02LR0z59WhL9XQpbXefsAZi0Ss41R7bhuhKTssO7qRVf37LnuSgbEjG16yH3z6xBLWGIWrTE1s5dls3iwdJfJxfp1EjBDV5XCcFw9t752xp4ta02GL4XDQwcEGoL+4N19+ePEAoapAIkTA2jdlQ4lfTGgjOwUk+CAGJxlmShIBmKchuZwxyceMe3EY3MV1yqAQFrYK1px7ic+r7a1k8BcPuJDJK1ID5+A+hPn1tBLLpeG5uORmJ1oTEd1fkh+bZoXOJyMTuAl3KjUETCGl+LsLx2Xg/1dtgXQQWPB2bPuJqO6MnYfQGA3iGW5d65e8xaA3524;4:PFWOpnhwzL0ejQBPCKUWWA8pcd8tMOBUi7UOsLeVuQ96ljZc9tvQOkAlhmngenS0b0WpbR//kd4CNvTbnsSfZVxllkYItDEjXl9Fy09iSJjAj9/A+Fy9ll78hV17r0frWAEeuvfmpgWtBXsmUOwTHx2cyiRhiCQDPkh3v+D1AppRGvoe/KZUmSZWmmUut3WTfP3KWclO8wwRfzOfZQATWY1IlMSXfVGYUi2+ubGbjd/aRC1uEaVykpMSYU3Xht1aabsOJUKsQ9/4WsPS8SmBUQ== 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)(366004)(346002)(376002)(136003)(396003)(39860400002)(189003)(199004)(36756003)(2906002)(956004)(81166006)(486006)(81156014)(476003)(2616005)(8676002)(39060400002)(305945005)(8936002)(4326008)(6666003)(25786009)(50466002)(48376002)(118296001)(5660300001)(14444005)(7416002)(66066001)(446003)(52116002)(51416003)(478600001)(3846002)(16586007)(26005)(86362001)(575784001)(6496006)(47776003)(52396003)(186003)(58126008)(6116002)(11346002)(6486002)(16526019)(53936002)(7736002)(76176011)(68736007)(105586002)(106356001)(97736004)(316002)(386003);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: 1;VI1PR05MB4191;23:d8zy2tl/brU+xNV/oLleIPRDi3z6h2aDZJEeCA0XCA6ij6ylIK15EllgT5JpIdwA4Z4QL5ODBvQ2WjbYYkY9ER5o9LfFSxKcmDxlTyhYd2mFAxliFF3YusHbZpk0y7WmbQM1TrRLTQlFrUVpP2DTXUAunCQiGdNv3lBvoLQB2seoTUQDgGhBJn/kAmf8uB7F8NkKURW0jB1cizjCtH1LmSwyfaVRglXxppd00ddcZAhjfhgyckw4PVXDeK3RSuZ24PBJvNN7F/Crm3K6oG2oujlRT9pT5g9loRUwQCI/ATxcWbgTwxYJXPZMCEmUaw/kj2YEXRDsn05DBU2Nq0oHCoxRMwpEk1HK5Yy2/z86DWNzmwKrE+VRZDAOpl3vAgKa++uhrBMGXDwrUNNLzSHXpi/w0EMwGdfE/ekgLdjK0zn2bucia8JnzYH23yhpdEjlH4lhnkZse0Zs9+ULGD1hQRW/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SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2018 22:39:33.6436 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b668f25c-df39-4e0f-7407-08d5f7367dad 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 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