From patchwork Wed Sep 6 19:57:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 111836 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp1291027ybm; Wed, 6 Sep 2017 12:59:00 -0700 (PDT) X-Google-Smtp-Source: ADKCNb6ni40gh3oSUTYs5ECkJtflLyXQAsHb7prWIeJO0FDX51Zzme35BGqCtCuzonH1gqqpQRSZ X-Received: by 10.101.65.133 with SMTP id a5mr317718pgq.144.1504727940806; Wed, 06 Sep 2017 12:59:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504727940; cv=none; d=google.com; s=arc-20160816; b=DSg30jXKV7k75hKEgG7zYVtR8EKqNnXUbYaNktHgMJPAUwXxjHfAjBZCP9gJSjyZj7 rL9wagIbJ/mcfYUrr1CVIm9818R9ygIAr5SbC8yDi3i15QgcFHOOMyioxa9IzzNYfFAg TF0dx3uN3bsN/UTHGtp2p+/qddDM/o6Sq3wJ44Jwd2OsmF7HHnbiSjQ/X/sNJu9KQnY/ gC/bhW7zwLCAK1xWd9cesBgpQeUk8h9un0S3BzQhgJ5XON/RaNKkqQ/uYVz8//yXTDO3 q2Rh/k4jwtlWhF12Zc1K28f/Y5z2d57pd9DUAPTLShS3GLZP9gFXyh+PZd322ffLxmW7 i2OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=dcX+U4myXAIHy7YM3ApANlAdTlKBVR11gcPjsBwkvoA=; b=tZ9JQnnxiY+lRhDAf/Io1o0TZGuW/YSCnamWbQtPwW8QabgbZ56MjUw/N2hvOp1H8J gYj2QIgfyFI/bvd3Eh8HtBKKa41VmMh8ZjDS4+SfJcyzjmZ4RQOQ55147x+ZKxp4goD0 U/CbB70k9XAzY6OZomvGazsXAXS8lXFuzyE2oHS/pmIOWdTkVnrjZfaemGjXRY4QESW3 NzhlscePjOxk4MKfbgL6w8zvNxbj+jnKK32BAkKeBg+PpFaUibmXuPWy5UKX6fyPrZm4 xHrlqx9yaJdLujxwGzk/NqRJjEwxpt2y3vlB2eLGekkXVYIV8iLChPSVzsM3Zd8Ubefp hiBg== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e18si472450pfl.468.2017.09.06.12.59.00; Wed, 06 Sep 2017 12:59:00 -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 S1752751AbdIFT66 (ORCPT + 26 others); 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 Received: from wuerfel.lan ([95.208.190.237]) by mrelayeu.kundenserver.de (mreue004 [212.227.15.129]) with ESMTPA (Nemesis) id 0Lb6lR-1dALEM22FF-00kd1d; Wed, 06 Sep 2017 21:58:31 +0200 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.9.0 Acked-by: Geert Uytterhoeven 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; }