]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3958] Fixed the allocation from the large PD pool.
authorMarcin Siodelski <marcin@isc.org>
Sun, 19 Jul 2015 08:06:07 +0000 (10:06 +0200)
committerMarcin Siodelski <marcin@isc.org>
Sun, 19 Jul 2015 08:06:07 +0000 (10:06 +0200)
src/lib/dhcpsrv/alloc_engine.cc
src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc

index 1bbf0ca699356a1ff9d86fc425d7333451f584a8..96e5e5af3f4dc87f86055a031f620f47f4724122 100644 (file)
@@ -631,8 +631,8 @@ AllocEngine::allocateUnreservedLeases6(ClientContext6& ctx) {
     /// try that number of times at most. It would be useful to that value if
     /// attempts_, specified by the user could override that value (and keep
     /// dynamic if they're set to 0).
-    uint32_t max_attempts = ctx.subnet_->getPoolCapacity(ctx.type_);
-    for (uint32_t i = 0; i < max_attempts; ++i)
+    uint64_t max_attempts = ctx.subnet_->getPoolCapacity(ctx.type_);
+    for (uint64_t i = 0; i < max_attempts; ++i)
     {
         IOAddress candidate = allocator->pickAddress(ctx.subnet_, ctx.duid_, hint);
 
index b4251a8deb094c677d8052e644e27139b8c33f2b..cf10138f4e03a279cdd4d113b5232c1d3b93d5e2 100644 (file)
@@ -476,6 +476,7 @@ TEST_F(AllocEngine6Test, outOfAddresses6) {
 
 }
 
+
 // This test checks if an expired lease can be reused in SOLICIT (fake allocation)
 TEST_F(AllocEngine6Test, solicitReuseExpiredLease6) {
     boost::scoped_ptr<AllocEngine> engine;
@@ -1563,6 +1564,28 @@ TEST_F(AllocEngine6Test, reservedAddressByMacInPoolRequestValidHint) {
     EXPECT_EQ("2001:db8:1::1c", lease->addr_.toText());
 }
 
+// This test checks that the allocation engine can delegate the long prefix.
+// The pool with prefix of 64 and with long delegated prefix has a very
+// high capacity. The number of attempts that the allocation engine makes
+// to allocate the prefix for high capacity pools is equal to the capacity
+// value. This test verifies that the prefix can be allocated in that
+// case.
+TEST_F(AllocEngine6Test, largePDPool) {
+    AllocEngine engine(AllocEngine::ALLOC_ITERATIVE, 100);
+
+    // Remove the default PD pool.
+    subnet_->delPools(Lease::TYPE_PD);
+
+    // Configure the PD pool with the prefix length of /64 and the delegated
+    // length /96.
+    Pool6Ptr pool(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1::"), 64, 96));
+    subnet_->addPool(pool);
+
+    // We should have got exactly one lease.
+    Lease6Collection leases = allocateTest(engine, pool, IOAddress("::"),
+                                           false, true);
+    ASSERT_EQ(1, leases.size());
+}
 
 }; // namespace test
 }; // namespace dhcp