diff options
Diffstat (limited to 'net/netfilter/xt_limit.c')
| -rw-r--r-- | net/netfilter/xt_limit.c | 14 | 
1 files changed, 7 insertions, 7 deletions
diff --git a/net/netfilter/xt_limit.c b/net/netfilter/xt_limit.c index 32b7a579a03..bef85059655 100644 --- a/net/netfilter/xt_limit.c +++ b/net/netfilter/xt_limit.c @@ -1,5 +1,6 @@  /* (C) 1999 Jérôme de Vivie <devivie@info.enserb.u-bordeaux.fr>   * (C) 1999 Hervé Eychenne <eychenne@info.enserb.u-bordeaux.fr> + * (C) 2006-2012 Patrick McHardy <kaber@trash.net>   *   * This program is free software; you can redistribute it and/or modify   * it under the terms of the GNU General Public License version 2 as @@ -88,8 +89,7 @@ limit_mt(const struct sk_buff *skb, struct xt_action_param *par)  }  /* Precision saver. */ -static u_int32_t -user2credits(u_int32_t user) +static u32 user2credits(u32 user)  {  	/* If multiplying would overflow... */  	if (user > 0xFFFFFFFF / (HZ*CREDITS_PER_JIFFY)) @@ -118,12 +118,12 @@ static int limit_mt_check(const struct xt_mtchk_param *par)  	/* For SMP, we only want to use one set of state. */  	r->master = priv; +	/* User avg in seconds * XT_LIMIT_SCALE: convert to jiffies * +	   128. */ +	priv->prev = jiffies; +	priv->credit = user2credits(r->avg * r->burst); /* Credits full. */  	if (r->cost == 0) { -		/* User avg in seconds * XT_LIMIT_SCALE: convert to jiffies * -		   128. */ -		priv->prev = jiffies; -		priv->credit = user2credits(r->avg * r->burst); /* Credits full. */ -		r->credit_cap = user2credits(r->avg * r->burst); /* Credits full. */ +		r->credit_cap = priv->credit; /* Credits full. */  		r->cost = user2credits(r->avg);  	}  	return 0;  | 
