aboutsummaryrefslogtreecommitdiff
path: root/net/netfilter/xt_RATEEST.c
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@medozas.de>2010-01-04 16:27:25 +0100
committerPatrick McHardy <kaber@trash.net>2010-01-04 16:27:25 +0100
commit5191d50192ec1281e51cbcb5248cb2667ff4d896 (patch)
treeea3b76594fb980d51f135024462658b84f1f78ae /net/netfilter/xt_RATEEST.c
parent89bc7a0f64de7bed2e0bc68a23d75699a610cd37 (diff)
netfilter: xtables: do not grab random bytes at __init
"It is deliberately not done in the init function, since we might not have sufficient random while booting." Signed-off-by: Jan Engelhardt <jengelh@medozas.de> Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'net/netfilter/xt_RATEEST.c')
-rw-r--r--net/netfilter/xt_RATEEST.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/net/netfilter/xt_RATEEST.c b/net/netfilter/xt_RATEEST.c
index d80b8192e0d..87ae97e5516 100644
--- a/net/netfilter/xt_RATEEST.c
+++ b/net/netfilter/xt_RATEEST.c
@@ -23,6 +23,7 @@ static DEFINE_MUTEX(xt_rateest_mutex);
#define RATEEST_HSIZE 16
static struct hlist_head rateest_hash[RATEEST_HSIZE] __read_mostly;
static unsigned int jhash_rnd __read_mostly;
+static bool rnd_inited __read_mostly;
static unsigned int xt_rateest_hash(const char *name)
{
@@ -93,6 +94,11 @@ static bool xt_rateest_tg_checkentry(const struct xt_tgchk_param *par)
struct gnet_estimator est;
} cfg;
+ if (unlikely(!rnd_inited)) {
+ get_random_bytes(&jhash_rnd, sizeof(jhash_rnd));
+ rnd_inited = true;
+ }
+
est = xt_rateest_lookup(info->name);
if (est) {
/*
@@ -164,7 +170,6 @@ static int __init xt_rateest_tg_init(void)
for (i = 0; i < ARRAY_SIZE(rateest_hash); i++)
INIT_HLIST_HEAD(&rateest_hash[i]);
- get_random_bytes(&jhash_rnd, sizeof(jhash_rnd));
return xt_register_target(&xt_rateest_tg_reg);
}