]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2843] Fix in random allocator return values
authorMarcin Siodelski <marcin@isc.org>
Fri, 12 May 2023 12:45:35 +0000 (14:45 +0200)
committerMarcin Siodelski <marcin@isc.org>
Fri, 12 May 2023 12:45:35 +0000 (14:45 +0200)
src/lib/dhcpsrv/random_allocator.cc
src/lib/dhcpsrv/tests/random_allocator_unittest.cc

index f838b8cf3c22beaedc72aefc6ba882ab91f09a55..e06cc54575a833ec73e39a5ef07a39ce27399e67 100644 (file)
@@ -80,7 +80,7 @@ RandomAllocator::pickAddressInternal(const ClientClasses& client_classes,
 
     // No pool available. There are no pools or client classes do
     // not match.
-    return (IOAddress::IPV4_ZERO_ADDRESS());
+    return (pool_type_ == Lease::TYPE_V4 ? IOAddress::IPV4_ZERO_ADDRESS() : IOAddress::IPV6_ZERO_ADDRESS());
 }
 
 IOAddress
index e8009eed3a6ae3a86eadb3809b281c60752f4dee..caf27f4745634fa1a4f22d6a5690e419b89aadbc 100644 (file)
@@ -334,7 +334,7 @@ TEST_F(RandomAllocatorTest6, clientClasses) {
    // can't offer any address to the client.
    cc_.clear();
    IOAddress candidate = alloc.pickAddress(cc_, duid_, IOAddress("0.0.0.0"));
-   EXPECT_TRUE(candidate.isV4Zero());
+   EXPECT_TRUE(candidate.isV6Zero());
 }
 
 // Test allocating delegated prefixes when a subnet has a single pool.