From patchwork Fri Sep 30 16:05:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101729 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp372666qgf; Fri, 30 Sep 2016 09:06:37 -0700 (PDT) X-Received: by 10.66.83.132 with SMTP id q4mr13018780pay.22.1475251597411; Fri, 30 Sep 2016 09:06:37 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id af8si20690928pad.16.2016.09.30.09.06.36; Fri, 30 Sep 2016 09:06:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933857AbcI3QGe (ORCPT + 27 others); Fri, 30 Sep 2016 12:06:34 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:53410 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933562AbcI3QGc (ORCPT ); Fri, 30 Sep 2016 12:06:32 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue101) with ESMTPA (Nemesis) id 0MCIPR-1bhVrh1t5N-009C0k; Fri, 30 Sep 2016 18:06:12 +0200 From: Arnd Bergmann To: Pablo Neira Ayuso Cc: Arnd Bergmann , Patrick McHardy , Jozsef Kadlecsik , "David S. Miller" , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] netfilter: nf_tables: avoid uninitialized variable warning Date: Fri, 30 Sep 2016 18:05:34 +0200 Message-Id: <20160930160559.4102745-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:kdHzkWShraDq5QmTuELwTcHgjtvjvCld92BUz223aIsODRWk4c1 xI2YPFEjRbuE2c1MtDWkgIUlYj0S253lIFdwrb5ssY5Kwp6LRMITmDdIWArv53+c7VX4Rhl 0NPWxlyKGn8JKLxKyhAjgna6X7rXrK8a14RAA00Ly6zeLYFUgPXnTdJhDxYA6jkd6SKukKC HrhHPWdY5f3RM2IOKxx1Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:uz+RqLdnOTY=:q8TV60SS2RDxxdWW9RwQ72 CLxToGX8a3bZmgmQQPLqOC3MNMso1OFq1jrd64rb7lsI4YxThVf1eBXvnbmZNXTJ+E+uhAYMJ JJonGVn7Evp+qdvX/8RpxoANel5BJcVlqmWz4LUgeVQttOS7XMEJi+pP+oPp1F6GTK2bJY76v gtDHIRSQ5GhsY+tjnGrcAJ3nHhYe61qYeUqul85QboeOJRr5F+iCqg177fRMMSb+5g68WbBvG Hv54xp5mDj24u6iSac7MXsUAW6pYieHUnreJrFNcUS5SQDUdhBczIseFEEeWxb/MCDfpUQ2+1 aQPrufJ0l6v238KQBJ/pg+JdQ7KB5eJhY3Fw4A05/RSTta8YekJnXhCnwQzaIITKBtbwkoMHx lhXNUfDbUVcqzmpTrn13evsakMANojA1z1YkizfVE8l9fqR4Y74j2eB/SgPLojQMuiUCJNo65 6QNMvjY2q+v5l7JwSz7JgLgoVyJlz+hhwtXn6GW8wvg7QvEBvAyBKs0c0BYFP2LsYj4aXUgDp DQKESnFgwSyBqpaM5Cavok7HHR5FICRcgO+mny0BJ63zp6O7eoc4wlFCMjAjIatoQaOnhYrRo 7OenVfCTt6BC306/rI3MSUDmi8/I3VrZ3wHy6xvFzSXo4cLHzMoVjj0hpxCeRrLJym925UDfY knja5PpgKau9OVwWBs0nU5kU0/es/pDww44nfB+jnKq4zkcYKvJpGw2u9jKQdDMepI+8= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The newly added nft_range_eval() function handles the two possible nft range operations, but as the compiler warning points out, any unexpected value would lead to the 'mismatch' variable being used without being initialized: net/netfilter/nft_range.c: In function 'nft_range_eval': net/netfilter/nft_range.c:45:5: error: 'mismatch' may be used uninitialized in this function [-Werror=maybe-uninitialized] This can be trivially avoided by added a 'default:' clause. Fixes: 0f3cd9b36977 ("netfilter: nf_tables: add range expression") Signed-off-by: Arnd Bergmann --- net/netfilter/nft_range.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.9.0 diff --git a/net/netfilter/nft_range.c b/net/netfilter/nft_range.c index c6d5358482d1..72dff5bffca8 100644 --- a/net/netfilter/nft_range.c +++ b/net/netfilter/nft_range.c @@ -40,6 +40,8 @@ static void nft_range_eval(const struct nft_expr *expr, case NFT_RANGE_NEQ: mismatch = (d1 >= 0 && d2 <= 0); break; + default: + mismatch = 0; } if (mismatch) From patchwork Fri Sep 30 16:05:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101728 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp373196qgf; Fri, 30 Sep 2016 09:07:29 -0700 (PDT) X-Received: by 10.98.97.7 with SMTP id v7mr12877833pfb.140.1475251649813; Fri, 30 Sep 2016 09:07:29 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gm8si20616399pac.186.2016.09.30.09.07.29; Fri, 30 Sep 2016 09:07:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933940AbcI3QH1 (ORCPT + 27 others); Fri, 30 Sep 2016 12:07:27 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:60148 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933296AbcI3QHX (ORCPT ); Fri, 30 Sep 2016 12:07:23 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue101) with ESMTPA (Nemesis) id 0LlWhL-1bFI4e2kr9-00bL28; Fri, 30 Sep 2016 18:07:03 +0200 From: Arnd Bergmann To: Pablo Neira Ayuso Cc: Arnd Bergmann , Patrick McHardy , Jozsef Kadlecsik , "David S. Miller" , Aaron Conole , Florian Westphal , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] netfilter: hide reference to nf_hooks_ingress Date: Fri, 30 Sep 2016 18:05:35 +0200 Message-Id: <20160930160559.4102745-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160930160559.4102745-1-arnd@arndb.de> References: <20160930160559.4102745-1-arnd@arndb.de> X-Provags-ID: V03:K0:Ees/Vnz4KTKvroWZ6eBrp6bINShBfh6I90417coshJ5wtbfnP7l zn9exTTZSd12B5YIyPGQGPendcil09M0GBLXXxvySmqMiX1xMzVcUbmvovAZ5yW6QxBHcqi ENmuzHHyep3V0DMUDgDX2NFbGHARzOhylCNC1qReh8nMP7+Bqubwn3K6Im+8i+4poF4ZInV Uzg12NgqxaYev0KcR8/SA== X-UI-Out-Filterresults: notjunk:1; V01:K0:RO+fnMb3wqw=:8ObCJf2MGzC8E+Rf9G3JkJ dKXv/INxGfPNfeLvlIco1Jiglq8NH/zMfAu4JZfHBSbregXLuNU5KPEWZqSyxnXKs4hFwkJRT sIgAmRKl/j6QG/WmYgAxlnZ+cyd+fG2SwhVr2QhWzmHGFBCMhHdahEmwVCVrQvXLMDoy0CCBR IvcS3IJWGhBr0WHPz0EZe7Ze1GyM1YnLMdPa+0agO/v46+axD7C0RnMY0LJPtMW1Gyf3YpbNg s9T9OMiOkmy6onWQcRVDX3gG9vNMtakkdt02Er1Ih7KA1HejwnBjolmDCYcfutqEbcr5usuuh JaoiR8ev6BgIVh0SBr2TSdo5vdZbi+Ww2plrBeBz+seyo1NxLnjB3OLzy0ZkydZJf9JDmUMlM 3gzxqNwLK0E6cC732ZHG/oxaKWeLgexuaiXh6zetwaElTMB7bIq51WqngQc6aDlb8k9RQ7YD3 RaRBvM6PWcqxUI+oUAEt7bDXvRex7ryS5SLn0BxNuchLZahaGE0Ls4LzmnB89VyZL0A1TsQ02 Gv6NpwX+fUmXdiQR5fYZx/9FdA0OrN5lLq04dFH+SDEQkzxKz8gIgnAMZMp1jlUOECPtEARLx 6g4FfXKEiooJhdDf1hihwkVQ//rU4g5nzjo4XDaHfbCGMdrLZTKWxbzc9sn3iad/iB4lem6Ik QsC8ZN8Uu9fswpfQMxIeY/Pa6qAefvfKeKYMHR2w3Edpd2FDxJxkf/3/cDYtBJUzOgiY= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A recent cleanup added an unconditional reference to the nf_hooks_ingress pointer, but that fails when CONFIG_NETFILTER_INGRESS is disabled and that member is not present in net_device: net/netfilter/core.c: In function 'nf_set_hooks_head': net/netfilter/core.c:96:30: error: 'struct net_device' has no member named 'nf_hooks_ingress' This avoids the build error by simply enclosing the assignment in an #ifdef, which may or may not be the correct fix. Fixes: e3b37f11e6e4 ("netfilter: replace list_head with single linked list") Signed-off-by: Arnd Bergmann --- net/netfilter/core.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.9.0 diff --git a/net/netfilter/core.c b/net/netfilter/core.c index 576a9c0406a9..5ccff1d9f209 100644 --- a/net/netfilter/core.c +++ b/net/netfilter/core.c @@ -90,10 +90,12 @@ static void nf_set_hooks_head(struct net *net, const struct nf_hook_ops *reg, { switch (reg->pf) { case NFPROTO_NETDEV: +#ifdef CONFIG_NETFILTER_INGRESS /* We already checked in nf_register_net_hook() that this is * used from ingress. */ rcu_assign_pointer(reg->dev->nf_hooks_ingress, entry); +#endif break; default: rcu_assign_pointer(net->nf.hooks[reg->pf][reg->hooknum], From patchwork Fri Sep 30 16:05:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101727 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp373672qgf; Fri, 30 Sep 2016 09:08:19 -0700 (PDT) X-Received: by 10.66.158.200 with SMTP id ww8mr6742021pab.116.1475251699236; Fri, 30 Sep 2016 09:08:19 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u23si20660931pfa.234.2016.09.30.09.08.18; Fri, 30 Sep 2016 09:08:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933842AbcI3QIR (ORCPT + 27 others); Fri, 30 Sep 2016 12:08:17 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:62006 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933296AbcI3QIH (ORCPT ); Fri, 30 Sep 2016 12:08:07 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue101) with ESMTPA (Nemesis) id 0MYNd3-1bUOrv0KTR-00V8ju; Fri, 30 Sep 2016 18:07:58 +0200 From: Arnd Bergmann To: Pablo Neira Ayuso Cc: Arnd Bergmann , Patrick McHardy , Jozsef Kadlecsik , "David S. Miller" , Joshua Hunt , Vishwanath Pai , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] netfilter: xt_hashlimit: uses div_u64 for division Date: Fri, 30 Sep 2016 18:05:36 +0200 Message-Id: <20160930160559.4102745-3-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160930160559.4102745-1-arnd@arndb.de> References: <20160930160559.4102745-1-arnd@arndb.de> X-Provags-ID: V03:K0:sWtNZd45SMsy4L1SQe8Oz85YdCuM5iQNChR4S9s4CPGseDhFQ7a MS9ljvmzxuRolFoaRN5C+ZBBSe4Mz95Sjx4y4g2E3yToiImgbRtpMRo8k6rI1vSHfIKN3bz 2NYsmPl/1ZJOTFA1bMqA3pI1UjMM8LEXPT+hpkMYvG8lByMQ6E1c6C+ljWKMuC6hP3UdAso 6pO8jjefXtd3ugPat5CYw== X-UI-Out-Filterresults: notjunk:1; V01:K0:9JZzylGP5hE=:WUXCMFmAQA19cUMKTE+R1p rq/2OY36o4ZOCzRl3gznjVdkdR1DcJUUbZcfTBmjFKarnyTMIDfeeS8aG7YkaOnrDH9ubsQnv PVnS4PwdA01aM2nt5MBjh2AffmQQtm/gjKxC5C3tBewnyPyZJpzi1wjDMY8abgm9hvuKx2w49 chp8HyHEEuKVO7Jd6JPZFJmCTh3KCLqzJAFZcuTscavnMZUHvgZI4S4ancjGzc5BMFNlwkGVl B924sfUhbhkywWhXS6KKXiSBHV02GyWbaHiAUXeXCDrr7YuIxJwW/2gibNdDEFKoWQ55BGGcd MHg6gE0Q2TbqSb1wWtwHrYdbnBk1oozpngcilmq0r4Ra+8SetNoNhfb47pO7ejCXk6uNaDLLg j3BgJ1ZAKINQOtHSeoXz7KibTPkWr/dvACEvaGUAjGsw+zjZxwqtPmgHtAxdK5XMSMZPqIeL6 liA2uiyM8fij/u4+JrfXImyHkHLOa6lbbzxd2Zc8NqCcsnIE4PQDY1vHU7kCzTHZ70aaQIpix 6FhCf1/3QwuguMUVmzWRszcrmOzT8EgBv4+KciJF/dnEkWxDISxzGiVU8DAS4K0Zak8eVzPaw VsJhzMe5W0kjTRyCVXFyPXExccljwBzBXql3d+3jYu8qT77nru6Lk0a5Fh+nkrHhl2jEL8Teb D3bln24pWB/St99JJU7sI667TeX7ioXpEGitLSALtjRGO5bNK8fLQRD6qzFAqVXwrOeA= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The newly added support for high-resolution pps rates introduced multiple 64-bit division operations in one function, which fails on all 32-bit architectures: net/netfilter/xt_hashlimit.o: In function `user2credits': xt_hashlimit.c:(.text.user2credits+0x3c): undefined reference to `__aeabi_uldivmod' xt_hashlimit.c:(.text.user2credits+0x68): undefined reference to `__aeabi_uldivmod' xt_hashlimit.c:(.text.user2credits+0x88): undefined reference to `__aeabi_uldivmod' This replaces the division with an explicit call to div_u64 for version 2 to documents that this is a slow operation, and reverts back to 32-bit arguments for the version 1 data to restore the original faster 32-bit division. With both changes combined, we no longer get a link error. Fixes: 11d5f15723c9 ("netfilter: xt_hashlimit: Create revision 2 to support higher pps rates") Signed-off-by: Arnd Bergmann --- Vishwanath Pai already sent a patch for this, and I did my version independently. The difference is that his version also the more expensive division for the version 1 variant that doesn't need it. See also http://patchwork.ozlabs.org/patch/676713/ --- net/netfilter/xt_hashlimit.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) -- 2.9.0 diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c index 44a095ecc7b7..3d5525df6eb3 100644 --- a/net/netfilter/xt_hashlimit.c +++ b/net/netfilter/xt_hashlimit.c @@ -464,20 +464,23 @@ static u32 xt_hashlimit_len_to_chunks(u32 len) static u64 user2credits(u64 user, int revision) { if (revision == 1) { + u32 user32 = user; /* use 32-bit division */ + /* If multiplying would overflow... */ - if (user > 0xFFFFFFFF / (HZ*CREDITS_PER_JIFFY_v1)) + if (user32 > 0xFFFFFFFF / (HZ*CREDITS_PER_JIFFY_v1)) /* Divide first. */ - return (user / XT_HASHLIMIT_SCALE) *\ + return (user32 / XT_HASHLIMIT_SCALE) * HZ * CREDITS_PER_JIFFY_v1; - return (user * HZ * CREDITS_PER_JIFFY_v1) \ - / XT_HASHLIMIT_SCALE; + return (user32 * HZ * CREDITS_PER_JIFFY_v1) / + XT_HASHLIMIT_SCALE; } else { if (user > 0xFFFFFFFFFFFFFFFF / (HZ*CREDITS_PER_JIFFY)) - return (user / XT_HASHLIMIT_SCALE_v2) *\ - HZ * CREDITS_PER_JIFFY; + return div_u64_u64(user, XT_HASHLIMIT_SCALE_v2) * + HZ * CREDITS_PER_JIFFY; - return (user * HZ * CREDITS_PER_JIFFY) / XT_HASHLIMIT_SCALE_v2; + return div_u64_u64(user * HZ * CREDITS_PER_JIFFY, + XT_HASHLIMIT_SCALE_v2); } }