提交 0aae24eb 编写于 作者: J Jozsef Kadlecsik

netfilter: ipset: Fix hash type expire: release empty hash bucket block

When all entries are expired/all slots are empty, release the bucket.
Signed-off-by: NJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
上级 e9dfdc05
...@@ -476,7 +476,7 @@ static void ...@@ -476,7 +476,7 @@ static void
mtype_expire(struct ip_set *set, struct htype *h, u8 nets_length, size_t dsize) mtype_expire(struct ip_set *set, struct htype *h, u8 nets_length, size_t dsize)
{ {
struct htable *t; struct htable *t;
struct hbucket *n; struct hbucket *n, *tmp;
struct mtype_elem *data; struct mtype_elem *data;
u32 i, j, d; u32 i, j, d;
#ifdef IP_SET_HASH_WITH_NETS #ifdef IP_SET_HASH_WITH_NETS
...@@ -511,9 +511,14 @@ mtype_expire(struct ip_set *set, struct htype *h, u8 nets_length, size_t dsize) ...@@ -511,9 +511,14 @@ mtype_expire(struct ip_set *set, struct htype *h, u8 nets_length, size_t dsize)
} }
} }
if (d >= AHASH_INIT_SIZE) { if (d >= AHASH_INIT_SIZE) {
struct hbucket *tmp = kzalloc(sizeof(*tmp) + if (d >= n->size) {
(n->size - AHASH_INIT_SIZE) * dsize, rcu_assign_pointer(hbucket(t, i), NULL);
GFP_ATOMIC); kfree_rcu(n, rcu);
continue;
}
tmp = kzalloc(sizeof(*tmp) +
(n->size - AHASH_INIT_SIZE) * dsize,
GFP_ATOMIC);
if (!tmp) if (!tmp)
/* Still try to delete expired elements */ /* Still try to delete expired elements */
continue; continue;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册