summaryrefslogtreecommitdiffstats
path: root/kernel/ip_set_hash_ipportip.c
diff options
context:
space:
mode:
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2010-10-30 18:52:53 +0200
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2010-10-30 18:52:53 +0200
commit3f8f60c2115992ecf6678fb6ce24d46dbb09e5f8 (patch)
treeb7bf4a865ac507037e034ddd3df3d8ededb12a9b /kernel/ip_set_hash_ipportip.c
parenta9bfa58f6b893d14cd4ffff7ef14084fcdc0ebe9 (diff)
Resizing converted to run under read-locking of the set
With restricting resizing so that it can be triggered by an add from userspace only, we can modify it so that it uses read-locking instead of write-locking. Thus the matching in the set can run parallel with resizing.
Diffstat (limited to 'kernel/ip_set_hash_ipportip.c')
-rw-r--r--kernel/ip_set_hash_ipportip.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/kernel/ip_set_hash_ipportip.c b/kernel/ip_set_hash_ipportip.c
index a20f1ef..0e46268 100644
--- a/kernel/ip_set_hash_ipportip.c
+++ b/kernel/ip_set_hash_ipportip.c
@@ -437,6 +437,7 @@ hash_ipportip_create(struct ip_set *set, struct nlattr *head,
struct nlattr *tb[IPSET_ATTR_CREATE_MAX+1];
struct chash *h;
u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM;
+ u8 hbits;
if (!(set->family == AF_INET || set->family == AF_INET6))
return -IPSET_ERR_INVALID_FAMILY;
@@ -459,19 +460,21 @@ hash_ipportip_create(struct ip_set *set, struct nlattr *head,
return -ENOMEM;
h->maxelem = maxelem;
- h->htable_bits = htable_bits(hashsize);
h->array_size = CHASH_DEFAULT_ARRAY_SIZE;
h->chain_limit = CHASH_DEFAULT_CHAIN_LIMIT;
get_random_bytes(&h->initval, sizeof(h->initval));
h->timeout = IPSET_NO_TIMEOUT;
- h->htable = ip_set_alloc(
- jhash_size(h->htable_bits) * sizeof(struct slist),
+ hbits = htable_bits(hashsize);
+ h->table = ip_set_alloc(
+ sizeof(struct htable)
+ + jhash_size(hbits) * sizeof(struct slist),
GFP_KERNEL);
- if (!h->htable) {
+ if (!h->table) {
kfree(h);
return -ENOMEM;
}
+ h->table->htable_bits = hbits;
set->data = h;
@@ -491,8 +494,8 @@ hash_ipportip_create(struct ip_set *set, struct nlattr *head,
}
pr_debug("create %s hashsize %u (%u) maxelem %u: %p(%p)",
- set->name, jhash_size(h->htable_bits),
- h->htable_bits, h->maxelem, set->data, h->htable);
+ set->name, jhash_size(h->table->htable_bits),
+ h->table->htable_bits, h->maxelem, set->data, h->table);
return 0;
}