From patchwork Tue Sep 27 13:57:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishwanath Pai X-Patchwork-Id: 675634 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 3sk2fV69Fbz9sC4 for ; Wed, 28 Sep 2016 00:05:22 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=akamai.com header.i=@akamai.com header.b=eGbYEMtq; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933226AbcI0OFF (ORCPT ); Tue, 27 Sep 2016 10:05:05 -0400 Received: from prod-mail-xrelay07.akamai.com ([23.79.238.175]:26498 "EHLO prod-mail-xrelay07.akamai.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933019AbcI0OFD (ORCPT ); Tue, 27 Sep 2016 10:05:03 -0400 X-Greylist: delayed 463 seconds by postgrey-1.27 at vger.kernel.org; Tue, 27 Sep 2016 10:05:02 EDT Received: from prod-mail-xrelay07.akamai.com (localhost.localdomain [127.0.0.1]) by postfix.imss70 (Postfix) with ESMTP id CBF9D433435; Tue, 27 Sep 2016 13:57:18 +0000 (GMT) Received: from prod-mail-relay11.akamai.com (prod-mail-relay11.akamai.com [172.27.118.250]) by prod-mail-xrelay07.akamai.com (Postfix) with ESMTP id B4337433419; Tue, 27 Sep 2016 13:57:18 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; s=a1; t=1474984638; bh=p1drTOB51mMO5CrYBWUfwpSR39TMoJRouTgxxiK7sf0=; l=1409; h=Date:From:To:Cc:From; b=eGbYEMtqZAXIeZI6STeGIov+ARwpjwT53W5Ersqj6p7U7lxiLED8AZmVPeFfnbKMD lcRHOTU1ethcp/0gdHiPreY1/7Fe2wRrImdKQzHXyFQADM9ZkATkQyMfQ8J/fo5gaU JsgQAuhpoAG7Xs5c3OLx0M2oVyGFddQRaPkxAfO0= Received: from bos-lpqrs.kendall.corp.akamai.com (bos-lpqrs.kendall.corp.akamai.com [172.28.13.81]) by prod-mail-relay11.akamai.com (Postfix) with ESMTP id AF3711FC90; Tue, 27 Sep 2016 13:57:18 +0000 (GMT) Received: from vpai by bos-lpqrs.kendall.corp.akamai.com with local (Exim 4.82) (envelope-from ) id 1bosso-0008Bj-L3; Tue, 27 Sep 2016 09:57:18 -0400 Date: Tue, 27 Sep 2016 09:57:18 -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 Subject: [PATCH v2] netfilter: xt_hashlimit: Fix link error in 32bit arch because of 64bit division Message-ID: <20160927135718.GA31297@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 --- 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 --- net/netfilter/xt_hashlimit.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c index 44a095e..200a9d8 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) *\ + 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) *\ + 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); } }