* [NETFILTER 2.6.18 3/3]: hashlimit match: fix random initialization
@ 2006-06-08 7:12 Patrick McHardy
0 siblings, 0 replies; only message in thread
From: Patrick McHardy @ 2006-06-08 7:12 UTC (permalink / raw)
To: David S. Miller; +Cc: Netfilter Development Mailinglist
[-- Attachment #1: 03.diff --]
[-- Type: text/plain, Size: 1758 bytes --]
[NETFILTER]: hashlimit match: fix random initialization
hashlimit does:
if (!ht->rnd)
get_random_bytes(&ht->rnd, 4);
ignoring that 0 is also a valid random number.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit f42a39846047e78d30c913270125bed2e0c5a0da
tree a875d2fb478ecaa405810a020ee4af61fa5c42f1
parent b010cc3184ce7cb65a9865ae52ec2ce6f3fe4c9d
author Patrick McHardy <kaber@trash.net> Thu, 01 Jun 2006 20:43:40 +0200
committer Patrick McHardy <kaber@trash.net> Thu, 01 Jun 2006 20:43:40 +0200
net/ipv4/netfilter/ipt_hashlimit.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/netfilter/ipt_hashlimit.c b/net/ipv4/netfilter/ipt_hashlimit.c
index 85edfb7..92980ab 100644
--- a/net/ipv4/netfilter/ipt_hashlimit.c
+++ b/net/ipv4/netfilter/ipt_hashlimit.c
@@ -80,6 +80,7 @@ struct ipt_hashlimit_htable {
/* used internally */
spinlock_t lock; /* lock for list_head */
u_int32_t rnd; /* random seed for hash */
+ int rnd_initialized;
struct timer_list timer; /* timer for gc */
atomic_t count; /* number entries in table */
@@ -134,8 +135,10 @@ __dsthash_alloc_init(struct ipt_hashlimi
/* initialize hash with random val at the time we allocate
* the first hashtable entry */
- if (!ht->rnd)
+ if (!ht->rnd_initialized) {
get_random_bytes(&ht->rnd, 4);
+ ht->rnd_initialized = 1;
+ }
if (ht->cfg.max &&
atomic_read(&ht->count) >= ht->cfg.max) {
@@ -214,7 +217,7 @@ static int htable_create(struct ipt_hash
atomic_set(&hinfo->count, 0);
atomic_set(&hinfo->use, 1);
- hinfo->rnd = 0;
+ hinfo->rnd_initialized = 0;
spin_lock_init(&hinfo->lock);
hinfo->pde = create_proc_entry(minfo->name, 0, hashlimit_procdir);
if (!hinfo->pde) {
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2006-06-08 7:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-08 7:12 [NETFILTER 2.6.18 3/3]: hashlimit match: fix random initialization Patrick McHardy
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.