aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2005-08-13 16:57:58 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2005-08-29 18:58:11 -0400
commit8ffde671730df0b392ca478643b88ef7153244c0 (patch)
treed7c57be003aff2de6068acbe751182264acf3d25
parent9d810fd2d28a9d672eca3136476af1a54a380bb2 (diff)
[NETFILTER]: Fix div64_64 in ipt_connbytes
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv4/netfilter/ipt_connbytes.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/net/ipv4/netfilter/ipt_connbytes.c b/net/ipv4/netfilter/ipt_connbytes.c
index 0dfb52c0e808..47128c073d85 100644
--- a/net/ipv4/netfilter/ipt_connbytes.c
+++ b/net/ipv4/netfilter/ipt_connbytes.c
@@ -22,23 +22,19 @@ MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
22MODULE_DESCRIPTION("iptables match for matching number of pkts/bytes per connection"); 22MODULE_DESCRIPTION("iptables match for matching number of pkts/bytes per connection");
23 23
24/* 64bit divisor, dividend and result. dynamic precision */ 24/* 64bit divisor, dividend and result. dynamic precision */
25static u_int64_t div64_64(u_int64_t divisor, u_int64_t dividend) 25static u_int64_t div64_64(u_int64_t dividend, u_int64_t divisor)
26{ 26{
27 u_int64_t result = divisor; 27 u_int32_t d = divisor;
28 28
29 if (dividend > 0xffffffff) { 29 if (divisor > 0xffffffffULL) {
30 int first_bit = find_first_bit((unsigned long *) &dividend, sizeof(dividend)); 30 unsigned int shift = fls(divisor >> 32);
31 /* calculate number of bits to shift. shift exactly enough
32 * bits to make dividend fit in 32bits. */
33 int num_shift = (64 - 32 - first_bit);
34 /* first bit has to be < 32, since dividend was > 0xffffffff */
35 result = result >> num_shift;
36 dividend = dividend >> num_shift;
37 }
38 31
39 do_div(divisor, dividend); 32 d = divisor >> shift;
33 dividend >>= shift;
34 }
40 35
41 return divisor; 36 do_div(dividend, d);
37 return dividend;
42} 38}
43 39
44static int 40static int