Skip to contentSkip to conversation

netfilter: xt_hashlimit: Fix link error in 32bit arch because of 64bit division

PATCH Applied Vishwanath Pai 3 participants 4 messages Sep 29, 2016 – Sep 30, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 netfilter: xt_hashlimit: Fix link error in 32bit arch because of 64bit division

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

Fixes 11d5f15723c9 ("netfilter: xt_hashlimit: Create revision 2 to ...")
---
 net/netfilter/xt_hashlimit.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
net/netfilter/xt_hashlimit.c +8 -7
index 44a095e..faf65f1 100644
@@ -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);
 	}
 }
 
Signature · 1 line
1.9.1
Acked-by on v3 1/1
#1 lore raw

net/netfilter/xt_hashlimit.c static u64 user2credits(u64 user, int revision) · line 474

Quoted 2 lines
net/netfilter/xt_hashlimit.c +2 -0
+               return div64_u64((user * HZ * CREDITS_PER_JIFFY_v1),
+                                XT_HASHLIMIT_SCALE);

spurious ()

net/netfilter/xt_hashlimit.c static u64 user2credits(u64 user, int revision) · line 481

Quoted 2 lines
net/netfilter/xt_hashlimit.c +2 -0
+               return div64_u64((user * HZ * CREDITS_PER_JIFFY),
+                                XT_HASHLIMIT_SCALE_v2);

spurious ()

but:

Acked-by Maciej Żenczykowski
maintainer Applied
#2 lore raw
In reply to Vishwanath Pai
Quoted 6 lines · Vishwanath Pai

v2:
Remove unnecessary div64_u64 around constants

v3:
remove backslashes

Quoted 6 lines

--

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.

Quoted 4 lines
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.

#3 lore raw
Quoted 16 lines · Pablo Neira Ayuso
Quoted 6 lines · Vishwanath Pai

v2:
Remove unnecessary div64_u64 around constants

v3:
remove backslashes

Quoted 6 lines

--

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.

Quoted 8 lines
Quoted 4 lines
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