aboutsummaryrefslogtreecommitdiffstats
path: root/net/netfilter
diff options
context:
space:
mode:
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2015-11-07 05:24:51 -0500
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2015-11-07 05:28:49 -0500
commit0aae24eb409fc429f54ca3809f904f1b91e295e0 (patch)
treeca66562d0bf42b04097f5f52b83cc9d9867acc2b /net/netfilter
parente9dfdc052d018268926ab769d5b7598226713d5a (diff)
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: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Diffstat (limited to 'net/netfilter')
-rw-r--r--net/netfilter/ipset/ip_set_hash_gen.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index fa4f6374bb73..e5336ab36d67 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -476,7 +476,7 @@ static void
476mtype_expire(struct ip_set *set, struct htype *h, u8 nets_length, size_t dsize) 476mtype_expire(struct ip_set *set, struct htype *h, u8 nets_length, size_t dsize)
477{ 477{
478 struct htable *t; 478 struct htable *t;
479 struct hbucket *n; 479 struct hbucket *n, *tmp;
480 struct mtype_elem *data; 480 struct mtype_elem *data;
481 u32 i, j, d; 481 u32 i, j, d;
482#ifdef IP_SET_HASH_WITH_NETS 482#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 } 511 }
512 } 512 }
513 if (d >= AHASH_INIT_SIZE) { 513 if (d >= AHASH_INIT_SIZE) {
514 struct hbucket *tmp = kzalloc(sizeof(*tmp) + 514 if (d >= n->size) {
515 (n->size - AHASH_INIT_SIZE) * dsize, 515 rcu_assign_pointer(hbucket(t, i), NULL);
516 GFP_ATOMIC); 516 kfree_rcu(n, rcu);
517 continue;
518 }
519 tmp = kzalloc(sizeof(*tmp) +
520 (n->size - AHASH_INIT_SIZE) * dsize,
521 GFP_ATOMIC);
517 if (!tmp) 522 if (!tmp)
518 /* Still try to delete expired elements */ 523 /* Still try to delete expired elements */
519 continue; 524 continue;