From: Patrick McHardy Date: Wed, 20 Sep 2006 18:59:25 +0000 (-0700) Subject: [NETFILTER]: xt_limit: don't reset state on unrelated rule updates X-Git-Tag: v2.6.19-rc1~1272^2~41 X-Git-Url: http://ftp.safe.ca/?a=commitdiff_plain;h=57dab5d0bfee21663ed20222b4cedeb0655ba1f3;p=safe%2Fjmp%2Flinux-2.6 [NETFILTER]: xt_limit: don't reset state on unrelated rule updates The limit match reinitializes its state whenever the ruleset changes, which means it will forget about previously used credits. Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- diff --git a/net/netfilter/xt_limit.c b/net/netfilter/xt_limit.c index b9c9ff3..8bfcbdf 100644 --- a/net/netfilter/xt_limit.c +++ b/net/netfilter/xt_limit.c @@ -122,16 +122,16 @@ ipt_limit_checkentry(const char *tablename, return 0; } - /* User avg in seconds * XT_LIMIT_SCALE: convert to jiffies * - 128. */ - r->prev = jiffies; - r->credit = user2credits(r->avg * r->burst); /* Credits full. */ - r->credit_cap = user2credits(r->avg * r->burst); /* Credits full. */ - r->cost = user2credits(r->avg); - /* For SMP, we only want to use one set of counters. */ r->master = r; - + if (r->cost == 0) { + /* User avg in seconds * XT_LIMIT_SCALE: convert to jiffies * + 128. */ + r->prev = jiffies; + r->credit = user2credits(r->avg * r->burst); /* Credits full. */ + r->credit_cap = user2credits(r->avg * r->burst); /* Credits full. */ + r->cost = user2credits(r->avg); + } return 1; }