summaryrefslogtreecommitdiffstats
path: root/kernel/ip_set_hash_net.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/ip_set_hash_net.c')
-rw-r--r--kernel/ip_set_hash_net.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/kernel/ip_set_hash_net.c b/kernel/ip_set_hash_net.c
index 27191f2..4cb57ac 100644
--- a/kernel/ip_set_hash_net.c
+++ b/kernel/ip_set_hash_net.c
@@ -399,6 +399,7 @@ hash_net_create(struct ip_set *set, struct nlattr *head, int len, u32 flags)
struct nlattr *tb[IPSET_ATTR_CREATE_MAX+1];
u32 hashsize = IPSET_DEFAULT_HASHSIZE, maxelem = IPSET_DEFAULT_MAXELEM;
struct chash *h;
+ u8 hbits;
if (!(set->family == AF_INET || set->family == AF_INET6))
return -IPSET_ERR_INVALID_FAMILY;
@@ -423,19 +424,21 @@ hash_net_create(struct ip_set *set, struct nlattr *head, int len, u32 flags)
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;
@@ -455,8 +458,8 @@ hash_net_create(struct ip_set *set, struct nlattr *head, int len, u32 flags)
}
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;
}