diff options
author | Thomas Gschwantner <tharre3@gmail.com> | 2019-09-29 21:00:45 +0200 |
---|---|---|
committer | Thomas Gschwantner <tharre3@gmail.com> | 2019-09-29 21:00:45 +0200 |
commit | f73da8f4118142ad06e1fbd0d711fadc9c8c1975 (patch) | |
tree | d7c867ea023de3c29b4d965e0b550d54c0b32aff | |
parent | Rename struct ip_pool to be more descriptive (diff) | |
download | wg-dynamic-f73da8f4118142ad06e1fbd0d711fadc9c8c1975.tar.xz wg-dynamic-f73da8f4118142ad06e1fbd0d711fadc9c8c1975.zip |
radix-trie: allow full use of the v4 address space
Diffstat (limited to '')
-rw-r--r-- | lease.c | 2 | ||||
-rw-r--r-- | radix-trie.c | 4 | ||||
-rw-r--r-- | radix-trie.h | 4 |
3 files changed, 5 insertions, 5 deletions
@@ -115,7 +115,7 @@ struct wg_dynamic_lease *new_lease(wg_key pubkey, uint32_t leasetime, if (wants_ipv4) { if (!ipv4) { index = random_bounded(ipns.total_ipv4); - debug("new_lease(v4): %u of %u\n", index, + debug("new_lease(v4): %u of %ju\n", index, ipns.total_ipv4); ipp_addnth_v4(&ipns, &lease->ipv4, index); diff --git a/radix-trie.c b/radix-trie.c index f8ff629..3557063 100644 --- a/radix-trie.c +++ b/radix-trie.c @@ -380,7 +380,7 @@ static int remove_node(struct radix_node *trie, const uint8_t *key, static void totalip_inc(struct ipns *ns, uint8_t bits, uint8_t val) { if (bits == 32) { - BUG_ON(val >= 32); + BUG_ON(val > 32); ns->total_ipv4 += 1ULL << val; } else if (bits == 128) { uint64_t tmp = ns->totall_ipv6; @@ -394,7 +394,7 @@ static void totalip_inc(struct ipns *ns, uint8_t bits, uint8_t val) static void totalip_dec(struct ipns *ns, uint8_t bits, uint8_t val) { if (bits == 32) { - BUG_ON(val >= 32); + BUG_ON(val > 32); ns->total_ipv4 -= 1ULL << val; } else if (bits == 128) { uint64_t tmp = ns->totall_ipv6; diff --git a/radix-trie.h b/radix-trie.h index 4fa909b..d3599dc 100644 --- a/radix-trie.h +++ b/radix-trie.h @@ -12,8 +12,8 @@ struct ipns { /* Total amount of available addresses over all pools */ - uint64_t totall_ipv6; - uint32_t totalh_ipv6, total_ipv4; + uint64_t totall_ipv6, total_ipv4; + uint32_t totalh_ipv6; struct radix_node *ip4_root, *ip6_root; struct radix_pool *ip4_pools, *ip6_pools; |