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>
Signed-off-by: David S. Miller <davem@davemloft.net>
/* used internally */
spinlock_t lock; /* lock for list_head */
u_int32_t rnd; /* random seed for hash */
/* used internally */
spinlock_t lock; /* lock for list_head */
u_int32_t rnd; /* random seed for hash */
struct timer_list timer; /* timer for gc */
atomic_t count; /* number entries in table */
struct timer_list timer; /* timer for gc */
atomic_t count; /* number entries in table */
/* initialize hash with random val at the time we allocate
* the first hashtable entry */
/* initialize hash with random val at the time we allocate
* the first hashtable entry */
+ if (!ht->rnd_initialized) {
get_random_bytes(&ht->rnd, 4);
get_random_bytes(&ht->rnd, 4);
+ ht->rnd_initialized = 1;
+ }
if (ht->cfg.max &&
atomic_read(&ht->count) >= ht->cfg.max) {
if (ht->cfg.max &&
atomic_read(&ht->count) >= ht->cfg.max) {
atomic_set(&hinfo->count, 0);
atomic_set(&hinfo->use, 1);
atomic_set(&hinfo->count, 0);
atomic_set(&hinfo->use, 1);
+ hinfo->rnd_initialized = 0;
spin_lock_init(&hinfo->lock);
hinfo->pde = create_proc_entry(minfo->name, 0, hashlimit_procdir);
if (!hinfo->pde) {
spin_lock_init(&hinfo->lock);
hinfo->pde = create_proc_entry(minfo->name, 0, hashlimit_procdir);
if (!hinfo->pde) {