Commit 80571a9e authored by Jozsef Kadlecsik's avatar Jozsef Kadlecsik

netfilter: ipset: Fix hash resizing with comments

The destroy function must take into account that resizing doesn't
create new extensions so those cannot be destroyed at resize.
Signed-off-by: default avatarJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
parent fda75c6d
...@@ -393,7 +393,7 @@ mtype_flush(struct ip_set *set) ...@@ -393,7 +393,7 @@ mtype_flush(struct ip_set *set)
/* Destroy the hashtable part of the set */ /* Destroy the hashtable part of the set */
static void static void
mtype_ahash_destroy(struct ip_set *set, struct htable *t) mtype_ahash_destroy(struct ip_set *set, struct htable *t, bool ext_destroy)
{ {
struct hbucket *n; struct hbucket *n;
u32 i; u32 i;
...@@ -401,7 +401,7 @@ mtype_ahash_destroy(struct ip_set *set, struct htable *t) ...@@ -401,7 +401,7 @@ mtype_ahash_destroy(struct ip_set *set, struct htable *t)
for (i = 0; i < jhash_size(t->htable_bits); i++) { for (i = 0; i < jhash_size(t->htable_bits); i++) {
n = hbucket(t, i); n = hbucket(t, i);
if (n->size) { if (n->size) {
if (set->extensions & IPSET_EXT_DESTROY) if (set->extensions & IPSET_EXT_DESTROY && ext_destroy)
mtype_ext_cleanup(set, n); mtype_ext_cleanup(set, n);
/* FIXME: use slab cache */ /* FIXME: use slab cache */
kfree(n->value); kfree(n->value);
...@@ -420,7 +420,7 @@ mtype_destroy(struct ip_set *set) ...@@ -420,7 +420,7 @@ mtype_destroy(struct ip_set *set)
if (set->extensions & IPSET_EXT_TIMEOUT) if (set->extensions & IPSET_EXT_TIMEOUT)
del_timer_sync(&h->gc); del_timer_sync(&h->gc);
mtype_ahash_destroy(set, rcu_dereference_bh_nfnl(h->table)); mtype_ahash_destroy(set, rcu_dereference_bh_nfnl(h->table), true);
#ifdef IP_SET_HASH_WITH_RBTREE #ifdef IP_SET_HASH_WITH_RBTREE
rbtree_destroy(&h->rbtree); rbtree_destroy(&h->rbtree);
#endif #endif
...@@ -586,7 +586,7 @@ mtype_resize(struct ip_set *set, bool retried) ...@@ -586,7 +586,7 @@ mtype_resize(struct ip_set *set, bool retried)
mtype_data_reset_flags(data, &flags); mtype_data_reset_flags(data, &flags);
#endif #endif
read_unlock_bh(&set->lock); read_unlock_bh(&set->lock);
mtype_ahash_destroy(set, t); mtype_ahash_destroy(set, t, false);
if (ret == -EAGAIN) if (ret == -EAGAIN)
goto retry; goto retry;
return ret; return ret;
...@@ -607,7 +607,7 @@ mtype_resize(struct ip_set *set, bool retried) ...@@ -607,7 +607,7 @@ mtype_resize(struct ip_set *set, bool retried)
pr_debug("set %s resized from %u (%p) to %u (%p)\n", set->name, pr_debug("set %s resized from %u (%p) to %u (%p)\n", set->name,
orig->htable_bits, orig, t->htable_bits, t); orig->htable_bits, orig, t->htable_bits, t);
mtype_ahash_destroy(set, orig); mtype_ahash_destroy(set, orig, false);
return 0; return 0;
} }
......
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