Commit 1f827f51 authored by Vishwanath Pai's avatar Vishwanath Pai Committed by Pablo Neira Ayuso

netfilter: xt_hashlimit: 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: 11d5f157 ("netfilter: xt_hashlimit: Create revision 2 to ...")
Signed-off-by: default avatarVishwanath Pai <vpai@akamai.com>
Acked-by: default avatarMaciej Żenczykowski <maze@google.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 7816ec56
...@@ -467,17 +467,18 @@ static u64 user2credits(u64 user, int revision) ...@@ -467,17 +467,18 @@ static u64 user2credits(u64 user, int revision)
/* If multiplying would overflow... */ /* If multiplying would overflow... */
if (user > 0xFFFFFFFF / (HZ*CREDITS_PER_JIFFY_v1)) if (user > 0xFFFFFFFF / (HZ*CREDITS_PER_JIFFY_v1))
/* Divide first. */ /* Divide first. */
return (user / XT_HASHLIMIT_SCALE) *\ return div64_u64(user, XT_HASHLIMIT_SCALE)
HZ * CREDITS_PER_JIFFY_v1; * HZ * CREDITS_PER_JIFFY_v1;
return (user * HZ * CREDITS_PER_JIFFY_v1) \ return div64_u64(user * HZ * CREDITS_PER_JIFFY_v1,
/ XT_HASHLIMIT_SCALE; XT_HASHLIMIT_SCALE);
} else { } else {
if (user > 0xFFFFFFFFFFFFFFFF / (HZ*CREDITS_PER_JIFFY)) 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; * 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);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment