From patchwork Tue Sep 27 07:42:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishwanath Pai X-Patchwork-Id: 675421 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 3sjt8N29rhz9s4n for ; Tue, 27 Sep 2016 17:42:12 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=akamai.com header.i=@akamai.com header.b=X1+woM2H; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753981AbcI0HmH (ORCPT ); Tue, 27 Sep 2016 03:42:07 -0400 Received: from prod-mail-xrelay05.akamai.com ([23.79.238.179]:23500 "EHLO prod-mail-xrelay05.akamai.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751468AbcI0HmF (ORCPT ); Tue, 27 Sep 2016 03:42:05 -0400 Received: from prod-mail-xrelay05.akamai.com (localhost.localdomain [127.0.0.1]) by postfix.imss70 (Postfix) with ESMTP id E1846423749; Tue, 27 Sep 2016 07:42:03 +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 CA02E423709; Tue, 27 Sep 2016 07:42:03 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; s=a1; t=1474962123; bh=cAXcZlNpfuB+W7fgOV6P1E0A3Ib0/awqSIueXmBFezA=; l=1515; h=Date:From:To:Cc:From; b=X1+woM2HbSUkToc+lJg6D1GuCKkqR+ftASp0PgzXMleDbxEexg/fczjYrOYiNgudX pdlIAi4pg9sYARTgBG5B7OMZEcWm2dho2ekqmRN4PaSvCJ2cDtkiMv3BUM8RDkCEIP KeBCt/HHMDHNfwbS8RlNbUO62VbP1aAcj+L0tty8= 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 C52701FC94; Tue, 27 Sep 2016 07:42:03 +0000 (GMT) Received: from vpai by bos-lpqrs.kendall.corp.akamai.com with local (Exim 4.82) (envelope-from ) id 1bon1f-000169-OM; Tue, 27 Sep 2016 03:42:03 -0400 Date: Tue, 27 Sep 2016 03:42:03 -0400 From: Vishwanath Pai To: pablo@netfilter.org Cc: kaber@trash.net, kadlec@blackhole.kfki.hu, johunt@akamai.com, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, pai.vishwain@gmail.com, zlpnobody@gmail.com Subject: [PATCH] Fix link error in 32bit arch because of 64bit division Message-ID: <20160927074203.GA3968@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 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 | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c index 44a095e..7fc694e 100644 --- a/net/netfilter/xt_hashlimit.c +++ b/net/netfilter/xt_hashlimit.c @@ -465,19 +465,20 @@ static u64 user2credits(u64 user, int revision) { if (revision == 1) { /* If multiplying would overflow... */ - if (user > 0xFFFFFFFF / (HZ*CREDITS_PER_JIFFY_v1)) + if (user > div64_u64(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) *\ + if (user > div64_u64(0xFFFFFFFFFFFFFFFF, (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); } }