From 77366185a8ad25c872c50eb11a8403920cd34fd4 Mon Sep 17 00:00:00 2001 From: Thomas Gschwantner Date: Sun, 29 Sep 2019 21:00:45 +0200 Subject: radix-trie: allow full use of the v4 address space --- lease.c | 2 +- radix-trie.c | 4 ++-- radix-trie.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lease.c b/lease.c index 37396e5..0272140 100644 --- a/lease.c +++ b/lease.c @@ -238,7 +238,7 @@ struct wg_dynamic_lease *set_lease(wg_key pubkey, uint32_t leasetime, memset(&lease->ipv4, 0, sizeof(lease->ipv4)); } else { uint32_t 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; -- cgit v1.2.3-59-g8ed1b