From patchwork Thu Sep 29 17:39:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vishwanath Pai X-Patchwork-Id: 676712 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3slMK92VRjz9sBX for ; Fri, 30 Sep 2016 03:39:57 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=akamai.com header.i=@akamai.com header.b=C/NjGu5i; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934465AbcI2Rjw (ORCPT ); Thu, 29 Sep 2016 13:39:52 -0400 Received: from prod-mail-xrelay05.akamai.com ([23.79.238.179]:54589 "EHLO prod-mail-xrelay05.akamai.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934123AbcI2Rjv (ORCPT ); Thu, 29 Sep 2016 13:39:51 -0400 Received: from prod-mail-xrelay05.akamai.com (localhost.localdomain [127.0.0.1]) by postfix.imss70 (Postfix) with ESMTP id 83210423702; Thu, 29 Sep 2016 17:39:50 +0000 (GMT) Received: from prod-mail-relay10.akamai.com (prod-mail-relay10.akamai.com [172.27.118.251]) by prod-mail-xrelay05.akamai.com (Postfix) with ESMTP id 6C24A423701; Thu, 29 Sep 2016 17:39:50 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; s=a1; t=1475170790; bh=lUW9iKCkqDocFu77AVhEWI3eEPKg6oXHu3r/R97mWPQ=; l=1572; h=Date:From:To:Cc:From; b=C/NjGu5i1RvIjPBXGVJjJIHOxJu5u4I9rDT3vkpdwKsKfhBHMzmUqGvlhmL1Q00U8 FDg4d2nOLM0M6DZZsa2rGk42P3UW2EyOe0ddSPPUAUThpYSygq4CuxcpowkWBD2FFi fI1qQSee0oOyqMNic12UHRo9nU6ErKjIFpISyxTY= Received: from bos-lpqrs.kendall.corp.akamai.com (bos-lpqrs.kendall.corp.akamai.com [172.28.13.81]) by prod-mail-relay10.akamai.com (Postfix) with ESMTP id 678141FC8D; Thu, 29 Sep 2016 17:39:50 +0000 (GMT) Received: from vpai by bos-lpqrs.kendall.corp.akamai.com with local (Exim 4.82) (envelope-from ) id 1bpfJG-0007N3-As; Thu, 29 Sep 2016 13:39:50 -0400 Date: Thu, 29 Sep 2016 13:39:50 -0400 From: Vishwanath Pai To: pablo@netfilter.org Cc: johunt@akamai.com, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, pai.vishwain@gmail.com, kaber@trash.net, kadlec@blackhole.kfki.hu, zlpnobody@gmail.com, hannes@stressinduktion.org, maze@google.com, eric.dumazet@gmail.com, akpm@linux-foundation.org Subject: [PATCH net-next v3] netfilter: xt_hashlimit: Fix link error in 32bit arch because of 64bit division Message-ID: <20160929173950.GA27689@akamai.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org v2: Remove unnecessary div64_u64 around constants v3: remove backslashes Acked-by: Maciej Żenczykowski --- Fix link error in 32bit arch because of 64bit division Division of 64bit integers will cause linker error undefined reference to `__udivdi3'. Fix this by replacing divisions with div64_64 Signed-off-by: Vishwanath Pai Fixes: 11d5f15723c9 ("netfilter: xt_hashlimit: Create revision 2 to ...") --- net/netfilter/xt_hashlimit.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c index 44a095e..faf65f1 100644 --- a/net/netfilter/xt_hashlimit.c +++ b/net/netfilter/xt_hashlimit.c @@ -467,17 +467,18 @@ static u64 user2credits(u64 user, int revision) /* If multiplying would overflow... */ if (user > 0xFFFFFFFF / (HZ*CREDITS_PER_JIFFY_v1)) /* Divide first. */ - return (user / XT_HASHLIMIT_SCALE) *\ - HZ * CREDITS_PER_JIFFY_v1; + return div64_u64(user, XT_HASHLIMIT_SCALE) + * HZ * CREDITS_PER_JIFFY_v1; - return (user * HZ * CREDITS_PER_JIFFY_v1) \ - / XT_HASHLIMIT_SCALE; + return div64_u64((user * 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 div64_u64(user, XT_HASHLIMIT_SCALE_v2) + * HZ * CREDITS_PER_JIFFY; - return (user * HZ * CREDITS_PER_JIFFY) / XT_HASHLIMIT_SCALE_v2; + return div64_u64((user * HZ * CREDITS_PER_JIFFY), + XT_HASHLIMIT_SCALE_v2); } }