diff options
author | Patrick McHardy | 2005-08-13 22:57:58 +0200 |
---|---|---|
committer | David S. Miller | 2005-08-30 00:58:11 +0200 |
commit | 8ffde671730df0b392ca478643b88ef7153244c0 (patch) | |
tree | d7c57be003aff2de6068acbe751182264acf3d25 | |
parent | [NETFILTER]: Add new iptables "connbytes" match (diff) | |
download | kernel-qcow2-linux-8ffde671730df0b392ca478643b88ef7153244c0.tar.gz kernel-qcow2-linux-8ffde671730df0b392ca478643b88ef7153244c0.tar.xz kernel-qcow2-linux-8ffde671730df0b392ca478643b88ef7153244c0.zip |
[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.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>"); MODULE_DESCRIPTION("iptables match for matching number of pkts/bytes per connection"); /* 64bit divisor, dividend and result. dynamic precision */ -static u_int64_t div64_64(u_int64_t divisor, u_int64_t dividend) +static u_int64_t div64_64(u_int64_t dividend, u_int64_t divisor) { - u_int64_t result = divisor; - - if (dividend > 0xffffffff) { - int first_bit = find_first_bit((unsigned long *) ÷nd, sizeof(dividend)); - /* calculate number of bits to shift. shift exactly enough - * bits to make dividend fit in 32bits. */ - int num_shift = (64 - 32 - first_bit); - /* first bit has to be < 32, since dividend was > 0xffffffff */ - result = result >> num_shift; - dividend = dividend >> num_shift; - } + u_int32_t d = divisor; + + if (divisor > 0xffffffffULL) { + unsigned int shift = fls(divisor >> 32); - do_div(divisor, dividend); + d = divisor >> shift; + dividend >>= shift; + } - return divisor; + do_div(dividend, d); + return dividend; } static int |