Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752730AbdIFT66 (ORCPT ); Wed, 6 Sep 2017 15:58:58 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:51051 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752327AbdIFT6z (ORCPT ); Wed, 6 Sep 2017 15:58:55 -0400 From: Arnd Bergmann To: Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" Cc: Arnd Bergmann , Vishwanath Pai , Josh Hunt , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] netfilter: xt_hashlimit: avoid 64-bit division Date: Wed, 6 Sep 2017 21:57:30 +0200 Message-Id: <20170906195825.3715290-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:e8QqSXuhDvA9681gi8FMf4r9PFzt3YnXK5CDQ8Wpp/GozUf188K S8jKwh22AKf79PQTZqVlzD/UMml2kT5skx1HiPYyAni89whXdQwkH0yu1gQwwejTBxcdiUI tlHzJVjuFZ4bqw+IGBbe+gulp2x9oEur1HdF7zHbk8fvrT+8V5ktXirvTmiDOCQfx5TJ3qO TOs3Z+WMZbQ9I8MUIkKmA== X-UI-Out-Filterresults: notjunk:1;V01:K0:ohmIjKTHTJA=:sPZMLd8bCvgzWajkALA0v2 L+eF/uyuuRsijh+yspya8ACgA9q2yDSMOO12EhLSh1xCSlhywCTbIPuuhIa7sTk2vUWCL4w0T zMOzxSCXYV1gdBieb1vWO21oXt9BM0yxTWXNFICmS/dVc/EUgW0SSM4nf9/tV5IYyihjNcSJX 3OzdBsvuVTpSwgJtuXbUwdgFbSLmYDKuWeVHLsquUVVkf1Aki+Gg4gPpixpWBzNKicfGSKhYk lKCrofyRCOo/o/dx8mZghMbViUoRLHqW/hOh5bwdhrfLk4PqZBZcq630L9LaI4TK204ZPnTO3 +63PP/9hdAShaGS22NZs0fI2cLuHm/RM1blcRY7JLbMPY1oN88RFINKefvHjM0Lkpo7Ndymue kl+jh8g+AX8GjInFR4awWx1clz6knOLGiwzySkk+4pI0hA+LVywAgCC/92WCjtqONPKGdfHq3 EySQUtJwJyGtvQJ495lG1N8c45VP8YI1WD71374LM4FICx4jOtBVv0SJeQrkgt3qZCq5Uy+VJ RBL4lR0gs6B5l8I2+HFo0lTqtonLYpv1McAb79xmiGT/Gek9TR+uQLn7HHaJtO9wpN68AvRJt GHnUEFNYbGL17bF4SX9lozbWef6KClWNEKqPhg6eVW4p5m/32aK2M0XgQfrhctxU5k/X+3WTD AXRqFYLkq1GT7IFHBBST6qzW+OXHc4xBqCq1L53uEwn38FA0kkKFbZL6GLtye109su+IveOwA r8lWInN4iDiYyfXO1gBViYhODqhwSOBWfAVaEw== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1076 Lines: 34 64-bit division is expensive on 32-bit architectures, and requires a special function call to avoid a link error like: net/netfilter/xt_hashlimit.o: In function `hashlimit_mt_common': xt_hashlimit.c:(.text+0x1328): undefined reference to `__aeabi_uldivmod' In the case of hashlimit_mt_common, we don't actually need a 64-bit operation, we can simply rewrite the function slightly to make that clear to the compiler. Fixes: bea74641e378 ("netfilter: xt_hashlimit: add rate match mode") Signed-off-by: Arnd Bergmann --- net/netfilter/xt_hashlimit.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c index 10d48234f5f4..50b53d86eef5 100644 --- a/net/netfilter/xt_hashlimit.c +++ b/net/netfilter/xt_hashlimit.c @@ -531,7 +531,10 @@ static u64 user2rate_bytes(u64 user) { u64 r; - r = user ? 0xFFFFFFFFULL / user : 0xFFFFFFFFULL; + if (user > 0xFFFFFFFFULL) + return 0; + + r = user ? 0xFFFFFFFFULL / (u32)user : 0xFFFFFFFFULL; r = (r - 1) << 4; return r; } -- 2.9.0