Skip to content

Commit

Permalink
netfilter: xt_hashlimit: Fix link error in 32bit arch because of 64bi…
Browse files Browse the repository at this point in the history
…t division

Division of 64bit integers will cause linker error undefined reference
to `__udivdi3'. Fix this by replacing divisions with div64_64

Fixes: 11d5f15 ("netfilter: xt_hashlimit: Create revision 2 to ...")
Signed-off-by: Vishwanath Pai <vpai@akamai.com>
Acked-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Vishwanath Pai authored and Pablo Neira Ayuso committed Sep 30, 2016
1 parent 7816ec5 commit 1f827f5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions net/netfilter/xt_hashlimit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 1f827f5

Please sign in to comment.