diff options
author | Patrick McHardy <kaber@trash.net> | 2005-08-13 16:57:58 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2005-08-29 18:58:11 -0400 |
commit | 8ffde671730df0b392ca478643b88ef7153244c0 (patch) | |
tree | d7c57be003aff2de6068acbe751182264acf3d25 /net | |
parent | 9d810fd2d28a9d672eca3136476af1a54a380bb2 (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>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/netfilter/ipt_connbytes.c | 24 |
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>"); | |||
22 | MODULE_DESCRIPTION("iptables match for matching number of pkts/bytes per connection"); | 22 | MODULE_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 */ |
25 | static u_int64_t div64_64(u_int64_t divisor, u_int64_t dividend) | 25 | static 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 *) ÷nd, 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 | ||
44 | static int | 40 | static int |