From b1c8a57047592b9fd751f67f18185a5b16268b31 Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Mon, 7 Jun 2021 23:26:26 +0200 Subject: [PATCH] ip-pool: Make host address valid even if prefix_len != 24 At the end of ip_pool_select_addr4() we'd check if the selected address is equal to the subnet address and increment it by 1 to produce a valid host address for the AP. That check was always correct only with 24-bit prefix, extend it to actually use the prefix-dependent mask instead of 0xff. Fixes a testAP failure triggered 50% of the times because the netmask is 28 bit long there. --- src/ip-pool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ip-pool.c b/src/ip-pool.c index 509bbeb7..efc4fd18 100644 --- a/src/ip-pool.c +++ b/src/ip-pool.c @@ -237,7 +237,7 @@ check_avail: selected -= count; } - if ((host_addr & 0xff) == 0) + if ((host_addr & host_mask) == 0) host_addr += 1; done: