netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v3] netfilter: xt_hashlimit: Fix link error in 32bit arch because of 64bit division
@ 2016-09-29 17:39 Vishwanath Pai
  2016-09-30  1:53 ` Maciej Żenczykowski
  2016-09-30 17:46 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 4+ messages in thread
From: Vishwanath Pai @ 2016-09-29 17:39 UTC (permalink / raw)
  To: pablo
  Cc: johunt, netfilter-devel, coreteam, netdev, pai.vishwain, kaber,
	kadlec, zlpnobody, hannes, maze, eric.dumazet, akpm

v2:
Remove unnecessary div64_u64 around constants

v3:
remove backslashes

--

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 <vpai@akamai.com>
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);
 	}
 }
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v3] netfilter: xt_hashlimit: Fix link error in 32bit arch because of 64bit division
  2016-09-29 17:39 [PATCH net-next v3] netfilter: xt_hashlimit: Fix link error in 32bit arch because of 64bit division Vishwanath Pai
@ 2016-09-30  1:53 ` Maciej Żenczykowski
  2016-09-30 17:46 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 4+ messages in thread
From: Maciej Żenczykowski @ 2016-09-30  1:53 UTC (permalink / raw)
  To: Vishwanath Pai
  Cc: Pablo Neira Ayuso, johunt, netfilter-devel, coreteam,
	Linux NetDev, Vishwanath Pai, Patrick McHardy, kadlec, zlpnobody,
	Hannes Frederic Sowa, Eric Dumazet, akpm

> +               return div64_u64((user * HZ * CREDITS_PER_JIFFY_v1),
> +                                XT_HASHLIMIT_SCALE);

spurious ()

> +               return div64_u64((user * HZ * CREDITS_PER_JIFFY),
> +                                XT_HASHLIMIT_SCALE_v2);

spurious ()

but:

Acked-by: Maciej Żenczykowski

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v3] netfilter: xt_hashlimit: Fix link error in 32bit arch because of 64bit division
  2016-09-29 17:39 [PATCH net-next v3] netfilter: xt_hashlimit: Fix link error in 32bit arch because of 64bit division Vishwanath Pai
  2016-09-30  1:53 ` Maciej Żenczykowski
@ 2016-09-30 17:46 ` Pablo Neira Ayuso
  2016-09-30 17:58   ` Vishwanath Pai
  1 sibling, 1 reply; 4+ messages in thread
From: Pablo Neira Ayuso @ 2016-09-30 17:46 UTC (permalink / raw)
  To: Vishwanath Pai
  Cc: johunt, netfilter-devel, coreteam, netdev, pai.vishwain, kaber,
	kadlec, zlpnobody, hannes, maze, eric.dumazet, akpm

On Thu, Sep 29, 2016 at 01:39:50PM -0400, Vishwanath Pai wrote:
> v2:
> Remove unnecessary div64_u64 around constants
> 
> v3:
> remove backslashes
> 
> --
> 
> 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

Applied, thanks Pai.

> Signed-off-by: Vishwanath Pai <vpai@akamai.com>
> Fixes: 11d5f15723c9 ("netfilter: xt_hashlimit: Create revision 2 to ...")
> 
> ---

Please, next time place the versioning information here, otherwise git
am takes the wrong description here.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v3] netfilter: xt_hashlimit: Fix link error in 32bit arch because of 64bit division
  2016-09-30 17:46 ` Pablo Neira Ayuso
@ 2016-09-30 17:58   ` Vishwanath Pai
  0 siblings, 0 replies; 4+ messages in thread
From: Vishwanath Pai @ 2016-09-30 17:58 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: johunt, netfilter-devel, coreteam, netdev, pai.vishwain, kaber,
	kadlec, zlpnobody, hannes, maze, eric.dumazet, akpm

On 09/30/2016 01:46 PM, Pablo Neira Ayuso wrote:
> On Thu, Sep 29, 2016 at 01:39:50PM -0400, Vishwanath Pai wrote:
>> v2:
>> Remove unnecessary div64_u64 around constants
>>
>> v3:
>> remove backslashes
>>
>> --
>>
>> 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
> 
> Applied, thanks Pai.
> 
>> Signed-off-by: Vishwanath Pai <vpai@akamai.com>
>> Fixes: 11d5f15723c9 ("netfilter: xt_hashlimit: Create revision 2 to ...")
>>
>> ---
> 
> Please, next time place the versioning information here, otherwise git
> am takes the wrong description here.
> 

Thank you. And sorry about, I did not realize git am would put that into
the description.

-Vishwanath

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-09-30 17:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-29 17:39 [PATCH net-next v3] netfilter: xt_hashlimit: Fix link error in 32bit arch because of 64bit division Vishwanath Pai
2016-09-30  1:53 ` Maciej Żenczykowski
2016-09-30 17:46 ` Pablo Neira Ayuso
2016-09-30 17:58   ` Vishwanath Pai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).