Commit 28b3a427 authored by Florian Westphal's avatar Florian Westphal Committed by Pablo Neira Ayuso

netfilter: hashlimit: do not use indirect calls during gc

no need, just use a simple boolean to indicate we want to reap all
entries.
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent f698fe40
...@@ -357,21 +357,7 @@ static int htable_create(struct net *net, struct hashlimit_cfg3 *cfg, ...@@ -357,21 +357,7 @@ static int htable_create(struct net *net, struct hashlimit_cfg3 *cfg,
return 0; return 0;
} }
static bool select_all(const struct xt_hashlimit_htable *ht, static void htable_selective_cleanup(struct xt_hashlimit_htable *ht, bool select_all)
const struct dsthash_ent *he)
{
return true;
}
static bool select_gc(const struct xt_hashlimit_htable *ht,
const struct dsthash_ent *he)
{
return time_after_eq(jiffies, he->expires);
}
static void htable_selective_cleanup(struct xt_hashlimit_htable *ht,
bool (*select)(const struct xt_hashlimit_htable *ht,
const struct dsthash_ent *he))
{ {
unsigned int i; unsigned int i;
...@@ -381,7 +367,7 @@ static void htable_selective_cleanup(struct xt_hashlimit_htable *ht, ...@@ -381,7 +367,7 @@ static void htable_selective_cleanup(struct xt_hashlimit_htable *ht,
spin_lock_bh(&ht->lock); spin_lock_bh(&ht->lock);
hlist_for_each_entry_safe(dh, n, &ht->hash[i], node) { hlist_for_each_entry_safe(dh, n, &ht->hash[i], node) {
if ((*select)(ht, dh)) if (time_after_eq(jiffies, dh->expires) || select_all)
dsthash_free(ht, dh); dsthash_free(ht, dh);
} }
spin_unlock_bh(&ht->lock); spin_unlock_bh(&ht->lock);
...@@ -395,7 +381,7 @@ static void htable_gc(struct work_struct *work) ...@@ -395,7 +381,7 @@ static void htable_gc(struct work_struct *work)
ht = container_of(work, struct xt_hashlimit_htable, gc_work.work); ht = container_of(work, struct xt_hashlimit_htable, gc_work.work);
htable_selective_cleanup(ht, select_gc); htable_selective_cleanup(ht, false);
queue_delayed_work(system_power_efficient_wq, queue_delayed_work(system_power_efficient_wq,
&ht->gc_work, msecs_to_jiffies(ht->cfg.gc_interval)); &ht->gc_work, msecs_to_jiffies(ht->cfg.gc_interval));
...@@ -419,7 +405,7 @@ static void htable_destroy(struct xt_hashlimit_htable *hinfo) ...@@ -419,7 +405,7 @@ static void htable_destroy(struct xt_hashlimit_htable *hinfo)
{ {
cancel_delayed_work_sync(&hinfo->gc_work); cancel_delayed_work_sync(&hinfo->gc_work);
htable_remove_proc_entry(hinfo); htable_remove_proc_entry(hinfo);
htable_selective_cleanup(hinfo, select_all); htable_selective_cleanup(hinfo, true);
kfree(hinfo->name); kfree(hinfo->name);
vfree(hinfo); vfree(hinfo);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment