diff --git a/src/lib/dhcpsrv/allocator.h b/src/lib/dhcpsrv/allocator.h index 94e89a4fe3..44a5309a82 100644 --- a/src/lib/dhcpsrv/allocator.h +++ b/src/lib/dhcpsrv/allocator.h @@ -150,11 +150,9 @@ public: /// /// @param addr the address. /// @param client_classes list of classes client belongs to. - /// @param count_me the address is still marked as free. virtual double getOccupancyRate(const asiolink::IOAddress& addr, - const ClientClasses& client_classes, - const bool count_me) const { + const ClientClasses& client_classes) const { return (0.); } @@ -169,12 +167,10 @@ public: /// @param pref the prefix. /// @param plen the prefix length. /// @param client_classes list of classes client belongs to. - /// @param count_me the prefix is still marked as free. virtual double getOccupancyRate(const asiolink::IOAddress& pref, const uint8_t plen, - const ClientClasses& client_classes, - const bool count_me) const { + const ClientClasses& client_classes) const { return (0.); } diff --git a/src/lib/dhcpsrv/flq_allocation_state.cc b/src/lib/dhcpsrv/flq_allocation_state.cc index 816759afbb..f73afa4766 100644 --- a/src/lib/dhcpsrv/flq_allocation_state.cc +++ b/src/lib/dhcpsrv/flq_allocation_state.cc @@ -53,6 +53,17 @@ PoolFreeLeaseQueueAllocationState::deleteFreeLease(const asiolink::IOAddress& ad } } +bool +PoolFreeLeaseQueueAllocationState::isFreeLease(const asiolink::IOAddress& address) const { + if (free_lease4_queue_) { + auto const& idx = free_lease4_queue_->get<1>(); + return (idx.count(address.toUint32()) > 0); + } else { + auto const& idx = free_lease6_queue_->get<1>(); + return (idx.count(address) > 0); + } +} + IOAddress PoolFreeLeaseQueueAllocationState::offerFreeLease() { if (free_lease4_queue_) { @@ -84,4 +95,3 @@ PoolFreeLeaseQueueAllocationState::getFreeLeaseCount() const { } // end of namespace isc::dhcp } // end of namespace isc - diff --git a/src/lib/dhcpsrv/flq_allocation_state.h b/src/lib/dhcpsrv/flq_allocation_state.h index 194edcfc7b..9962046a7d 100644 --- a/src/lib/dhcpsrv/flq_allocation_state.h +++ b/src/lib/dhcpsrv/flq_allocation_state.h @@ -55,6 +55,11 @@ public: /// @param address lease address. void deleteFreeLease(const asiolink::IOAddress& address); + /// @brief Check if a lease is in the queue. + /// + /// @param address lease address. + bool isFreeLease(const asiolink::IOAddress& address) const; + /// @brief Returns next available lease. /// /// @return next free lease address or IPv4/IPv6 zero address when diff --git a/src/lib/dhcpsrv/flq_allocator.cc b/src/lib/dhcpsrv/flq_allocator.cc index d6c0ba4f56..e560f108d6 100644 --- a/src/lib/dhcpsrv/flq_allocator.cc +++ b/src/lib/dhcpsrv/flq_allocator.cc @@ -137,8 +137,7 @@ FreeLeaseQueueAllocator::pickPrefixInternal(const ClientClasses& client_classes, double FreeLeaseQueueAllocator::getOccupancyRate(const IOAddress& addr, - const ClientClasses& client_classes, - const bool count_me) const { + const ClientClasses& client_classes) const { // Sanity. if (!addr.isV4()) { return (0.); @@ -164,7 +163,7 @@ FreeLeaseQueueAllocator::getOccupancyRate(const IOAddress& addr, uint128_t free_cnt = pool_state->getFreeLeaseCount(); if (!found && pool->inRange(addr)) { found = true; - if (count_me && (free_cnt > 0)) { + if ((free_cnt > 0) && pool_state->isFreeLease(addr)) { --free_cnt; } } @@ -186,8 +185,7 @@ FreeLeaseQueueAllocator::getOccupancyRate(const IOAddress& addr, double FreeLeaseQueueAllocator::getOccupancyRate(const IOAddress& pref, const uint8_t plen, - const ClientClasses& client_classes, - const bool count_me) const { + const ClientClasses& client_classes) const { // Sanity. if (!pref.isV6()) { return (0.); @@ -217,7 +215,7 @@ FreeLeaseQueueAllocator::getOccupancyRate(const IOAddress& pref, uint128_t free_cnt = pool_state->getFreeLeaseCount(); if (!found && pool->inRange(pref)) { found = true; - if (count_me && (free_cnt > 0)) { + if ((free_cnt > 0) && pool_state->isFreeLease(pref)) { --free_cnt; } } diff --git a/src/lib/dhcpsrv/flq_allocator.h b/src/lib/dhcpsrv/flq_allocator.h index dbe8d6d48c..e2e772aa25 100644 --- a/src/lib/dhcpsrv/flq_allocator.h +++ b/src/lib/dhcpsrv/flq_allocator.h @@ -61,11 +61,9 @@ public: /// /// @param addr the address. /// @param client_classes list of classes client belongs to. - /// @param count_me the address is still marked as free. virtual double getOccupancyRate(const asiolink::IOAddress& addr, - const ClientClasses& client_classes, - const bool count_me) const; + const ClientClasses& client_classes) const; /// @brief Returns the occupancy rate (v6 prefixes). /// @@ -78,12 +76,10 @@ public: /// @param pref the prefix. /// @param plen the prefix length. /// @param client_classes list of classes client belongs to. - /// @param count_me the prefix is still marked as free. virtual double getOccupancyRate(const asiolink::IOAddress& pref, const uint8_t plen, - const ClientClasses& client_classes, - const bool count_me) const; + const ClientClasses& client_classes) const; private: diff --git a/src/lib/dhcpsrv/tests/flq_allocation_state_unittest.cc b/src/lib/dhcpsrv/tests/flq_allocation_state_unittest.cc index 23b4d56071..b3c61f03b2 100644 --- a/src/lib/dhcpsrv/tests/flq_allocation_state_unittest.cc +++ b/src/lib/dhcpsrv/tests/flq_allocation_state_unittest.cc @@ -39,12 +39,15 @@ TEST(PoolFreeLeaseAllocationState, addDeleteFreeLeaseV4) { // Add the first free lease. The pool should now have one free lease // that is always offered. + EXPECT_FALSE(state->isFreeLease(IOAddress("192.0.2.1"))); state->addFreeLease(IOAddress("192.0.2.1")); EXPECT_FALSE(state->exhausted()); EXPECT_EQ(1, state->getFreeLeaseCount()); + EXPECT_TRUE(state->isFreeLease(IOAddress("192.0.2.1"))); // The same lease is always offered. EXPECT_EQ("192.0.2.1", state->offerFreeLease().toText()); EXPECT_EQ("192.0.2.1", state->offerFreeLease().toText()); + EXPECT_TRUE(state->isFreeLease(IOAddress("192.0.2.1"))); // Add another free lease. We should now have two free leases. state->addFreeLease(IOAddress("192.0.2.3")); @@ -55,9 +58,12 @@ TEST(PoolFreeLeaseAllocationState, addDeleteFreeLeaseV4) { EXPECT_EQ("192.0.2.1", state->offerFreeLease().toText()); // Now, the second lease should be offered. EXPECT_EQ("192.0.2.3", state->offerFreeLease().toText()); + EXPECT_TRUE(state->isFreeLease(IOAddress("192.0.2.1"))); + EXPECT_TRUE(state->isFreeLease(IOAddress("192.0.2.3"))); // Try to delete a non-existing lease. It should not affect the // existing leases. + EXPECT_FALSE(state->isFreeLease(IOAddress("192.0.2.2"))); state->deleteFreeLease(IOAddress("192.0.2.2")); EXPECT_FALSE(state->exhausted()); EXPECT_EQ(2, state->getFreeLeaseCount()); @@ -126,12 +132,15 @@ TEST(PoolFreeLeaseAllocationState, addDeleteFreeLeaseNA) { // Add the first free lease. The pool should now have one free lease // that is always offered. + EXPECT_FALSE(state->isFreeLease(IOAddress("2001:db8:1::1"))); state->addFreeLease(IOAddress("2001:db8:1::1")); EXPECT_FALSE(state->exhausted()); EXPECT_EQ(1, state->getFreeLeaseCount()); + EXPECT_TRUE(state->isFreeLease(IOAddress("2001:db8:1::1"))); // The same lease is always offered. EXPECT_EQ("2001:db8:1::1", state->offerFreeLease().toText()); EXPECT_EQ("2001:db8:1::1", state->offerFreeLease().toText()); + EXPECT_TRUE(state->isFreeLease(IOAddress("2001:db8:1::1"))); // Add another free lease. We should now have two free leases. state->addFreeLease(IOAddress("2001:db8:1::3")); @@ -142,9 +151,12 @@ TEST(PoolFreeLeaseAllocationState, addDeleteFreeLeaseNA) { EXPECT_EQ("2001:db8:1::1", state->offerFreeLease().toText()); // Now, the second lease should be offered. EXPECT_EQ("2001:db8:1::3", state->offerFreeLease().toText()); + EXPECT_TRUE(state->isFreeLease(IOAddress("2001:db8:1::1"))); + EXPECT_TRUE(state->isFreeLease(IOAddress("2001:db8:1::3"))); // Try to delete a non-existing lease. It should not affect the // existing leases. + EXPECT_FALSE(state->isFreeLease(IOAddress("2001:db8:1::2"))); state->deleteFreeLease(IOAddress("2001:db8:1::2")); EXPECT_FALSE(state->exhausted()); EXPECT_EQ(2, state->getFreeLeaseCount()); @@ -211,11 +223,15 @@ TEST(PoolFreeLeaseAllocationState, addDeleteFreeLeasePD) { // Add the first free lease. The pool should now have one free lease // that is always offered. + EXPECT_FALSE(state->isFreeLease(IOAddress("3000::5600"))); state->addFreeLease(IOAddress("3000::5600")); EXPECT_FALSE(state->exhausted()); EXPECT_EQ(1, state->getFreeLeaseCount()); + EXPECT_TRUE(state->isFreeLease(IOAddress("3000::5600"))); // The same lease is always offered. EXPECT_EQ("3000::5600", state->offerFreeLease().toText()); + EXPECT_EQ("3000::5600", state->offerFreeLease().toText()); + EXPECT_TRUE(state->isFreeLease(IOAddress("3000::5600"))); // Add another free lease. We should now have two free leases. state->addFreeLease(IOAddress("3000::7800")); @@ -226,9 +242,12 @@ TEST(PoolFreeLeaseAllocationState, addDeleteFreeLeasePD) { EXPECT_EQ("3000::5600", state->offerFreeLease().toText()); // Now, the second lease should be offered. EXPECT_EQ("3000::7800", state->offerFreeLease().toText()); + EXPECT_TRUE(state->isFreeLease(IOAddress("3000::5600"))); + EXPECT_TRUE(state->isFreeLease(IOAddress("3000::7800"))); // Try to delete a non-existing lease. It should not affect the // existing leases. + EXPECT_FALSE(state->isFreeLease(IOAddress("3000::6400"))); state->deleteFreeLease(IOAddress("3000::6400")); EXPECT_FALSE(state->exhausted()); EXPECT_EQ(2, state->getFreeLeaseCount()); @@ -274,5 +293,4 @@ TEST(PoolFreeLeaseAllocationState, addFreeLeasPDSeveralTimes) { EXPECT_TRUE(state->exhausted()); } - } // end of anonymous namespace diff --git a/src/lib/dhcpsrv/tests/flq_allocator_unittest.cc b/src/lib/dhcpsrv/tests/flq_allocator_unittest.cc index 36f5f68564..bed7284b0d 100644 --- a/src/lib/dhcpsrv/tests/flq_allocator_unittest.cc +++ b/src/lib/dhcpsrv/tests/flq_allocator_unittest.cc @@ -65,11 +65,9 @@ TEST_F(FreeLeaseQueueAllocatorTest4, populateFreeAddressLeases) { ASSERT_TRUE(pool_state); EXPECT_FALSE(pool_state->exhausted()); - double r = alloc.getOccupancyRate(IOAddress("192.0.2.101"), cc_, false); - EXPECT_EQ(.5, r); - r = alloc.getOccupancyRate(IOAddress("192.0.2.101"), cc_, true); + double r = alloc.getOccupancyRate(IOAddress("192.0.2.101"), cc_); EXPECT_EQ(.6, r); - r = alloc.getOccupancyRate(IOAddress("192.0.2.1"), cc_, false); + r = alloc.getOccupancyRate(IOAddress("192.0.2.1"), cc_); EXPECT_EQ(0., r); std::set addresses; @@ -131,7 +129,7 @@ TEST_F(FreeLeaseQueueAllocatorTest4, singlePoolWithAllocations) { IOAddress candidate = alloc.pickAddress(cc_, clientid_, IOAddress("0.0.0.0")); EXPECT_TRUE(candidate.isV4Zero()); - double r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_, false); + double r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_); EXPECT_EQ(1., r); auto i = 0; @@ -142,7 +140,7 @@ TEST_F(FreeLeaseQueueAllocatorTest4, singlePoolWithAllocations) { ++i; } - r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_, false); + r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_); EXPECT_EQ(.5, r); for (auto j = 0; j < 5; ++j) { @@ -156,7 +154,7 @@ TEST_F(FreeLeaseQueueAllocatorTest4, singlePoolWithAllocations) { candidate = alloc.pickAddress(cc_, clientid_, IOAddress("0.0.0.0")); EXPECT_TRUE(candidate.isV4Zero()); - r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_, false); + r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_); EXPECT_EQ(1., r); } @@ -186,7 +184,7 @@ TEST_F(FreeLeaseQueueAllocatorTest4, singlePoolWithReclamations) { IOAddress candidate = alloc.pickAddress(cc_, clientid_, IOAddress("0.0.0.0")); EXPECT_TRUE(candidate.isV4Zero()); - double r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_, false); + double r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_); EXPECT_EQ(1., r); auto i = 0; @@ -198,7 +196,7 @@ TEST_F(FreeLeaseQueueAllocatorTest4, singlePoolWithReclamations) { } ++i; } - r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_, false); + r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_); EXPECT_EQ(.5, r); for (auto j = 0; j < 5; ++j) { @@ -212,7 +210,7 @@ TEST_F(FreeLeaseQueueAllocatorTest4, singlePoolWithReclamations) { candidate = alloc.pickAddress(cc_, clientid_, IOAddress("0.0.0.0")); EXPECT_TRUE(candidate.isV4Zero()); - r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_, false); + r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_); EXPECT_EQ(1., r); } @@ -237,8 +235,9 @@ TEST_F(FreeLeaseQueueAllocatorTest4, manyPools) { auto& lease_mgr = LeaseMgrFactory::instance(); - double r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_, false); - EXPECT_EQ(0., r); + double r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_); + // 1/100 + EXPECT_EQ(.01, r); std::set addresses_set; std::vector addresses_vector; @@ -259,7 +258,7 @@ TEST_F(FreeLeaseQueueAllocatorTest4, manyPools) { // Make sure that unique addresses have been returned. EXPECT_EQ(total, addresses_set.size()); - r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_, false); + r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_); EXPECT_EQ(1., r); // Verify that the addresses are returned in the random order. @@ -301,7 +300,7 @@ TEST_F(FreeLeaseQueueAllocatorTest4, noPools) { EXPECT_TRUE(candidate.isV4Zero()); // rate is 0. because of the address can't be found, not from 0./0.... - double r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_, false); + double r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_); EXPECT_EQ(0., r); } @@ -338,8 +337,9 @@ TEST_F(FreeLeaseQueueAllocatorTest4, clientClasses) { // Simulate client's request belonging to the class bar. cc_.insert("bar"); - double r = alloc.getOccupancyRate(IOAddress("192.0.2.120"), cc_, false); - EXPECT_EQ(0., r); + double r = alloc.getOccupancyRate(IOAddress("192.0.2.120"), cc_); + // 1/20 + EXPECT_EQ(.05, r); for (auto i = 0; i < 20; ++i) { // Allocate random addresses and make sure they belong to the // pools associated with the class bar. @@ -351,7 +351,7 @@ TEST_F(FreeLeaseQueueAllocatorTest4, clientClasses) { } EXPECT_EQ(20, addresses_set.size()); - r = alloc.getOccupancyRate(IOAddress("192.0.2.120"), cc_, false); + r = alloc.getOccupancyRate(IOAddress("192.0.2.120"), cc_); EXPECT_EQ(1., r); addresses_set.clear(); @@ -359,8 +359,9 @@ TEST_F(FreeLeaseQueueAllocatorTest4, clientClasses) { // Simulate the case that the client also belongs to the class foo. // All pools should now be available. cc_.insert("foo"); - r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_, false); - EXPECT_EQ(.5, r); + r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_); + // 21/40 + EXPECT_EQ(.525, r); for (auto i = 0; i < 20; ++i) { IOAddress candidate = alloc.pickAddress(cc_, clientid_, IOAddress("0.0.0.0")); addresses_set.insert(candidate); @@ -368,7 +369,7 @@ TEST_F(FreeLeaseQueueAllocatorTest4, clientClasses) { EXPECT_TRUE(subnet_->inRange(candidate)); } EXPECT_EQ(20, addresses_set.size()); - r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_, false); + r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_); EXPECT_EQ(1., r); // When the client does not belong to any client class the allocator @@ -376,7 +377,7 @@ TEST_F(FreeLeaseQueueAllocatorTest4, clientClasses) { cc_.clear(); IOAddress candidate = alloc.pickAddress(cc_, clientid_, IOAddress("0.0.0.0")); EXPECT_TRUE(candidate.isV4Zero()); - r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_, false); + r = alloc.getOccupancyRate(IOAddress("192.0.2.100"), cc_); EXPECT_EQ(0., r); } @@ -428,7 +429,7 @@ TEST_F(FreeLeaseQueueAllocatorTest6, populateFreeAddressLeases) { EXPECT_NO_THROW(alloc.initAfterConfigure()); // Address getOccupancyRate is for IPv4 only. - double r = alloc.getOccupancyRate(IOAddress("2001:db8:1::10"), cc_, false); + double r = alloc.getOccupancyRate(IOAddress("2001:db8:1::10"), cc_); EXPECT_EQ(0., r); auto pool_state = boost::dynamic_pointer_cast(pool_->getAllocationState()); @@ -735,8 +736,7 @@ TEST_F(FreeLeaseQueueAllocatorTest6, populateFreePrefixDelegationLeases) { ASSERT_TRUE(pool_state); EXPECT_FALSE(pool_state->exhausted()); - double r = alloc.getOccupancyRate(IOAddress("2001:db8:2::"), - 128, cc_, false); + double r = alloc.getOccupancyRate(IOAddress("2001:db8:2::"), 128, cc_); EXPECT_EQ(5. / 256., r); std::set addresses; @@ -775,8 +775,7 @@ TEST_F(FreeLeaseQueueAllocatorTest6, singlePdPool) { // The pool comprises 65536 prefixes. All should be returned. EXPECT_EQ(65536, prefixes.size()); - double r = alloc.getOccupancyRate(IOAddress("2001:db8:1:2::"), - 128, cc_, false); + double r = alloc.getOccupancyRate(IOAddress("2001:db8:1:2::"), 128, cc_); EXPECT_EQ(1., r); } @@ -814,7 +813,7 @@ TEST_F(FreeLeaseQueueAllocatorTest6, singlePdPoolWithAllocations) { IOAddress candidate = alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0); EXPECT_TRUE(candidate.isV6Zero()); - double r = alloc.getOccupancyRate(IOAddress("3000::"), 128, cc_, false); + double r = alloc.getOccupancyRate(IOAddress("3000::"), 128, cc_); EXPECT_EQ(1., r); auto i = 0; @@ -824,10 +823,8 @@ TEST_F(FreeLeaseQueueAllocatorTest6, singlePdPoolWithAllocations) { } ++i; } - r = alloc.getOccupancyRate(IOAddress("3000::"), 128, cc_, false); + r = alloc.getOccupancyRate(IOAddress("3000::"), 128, cc_); EXPECT_EQ(.5, r); - r = alloc.getOccupancyRate(IOAddress("3000::"), 128, cc_, true); - EXPECT_EQ(129. / 256., r); for (auto j = 0; j < 128; ++j) { candidate = alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0); @@ -840,7 +837,7 @@ TEST_F(FreeLeaseQueueAllocatorTest6, singlePdPoolWithAllocations) { candidate = alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0); EXPECT_TRUE(candidate.isV6Zero()); - r = alloc.getOccupancyRate(IOAddress("3000::"), 128, cc_, false); + r = alloc.getOccupancyRate(IOAddress("3000::"), 128, cc_); EXPECT_EQ(1., r); } @@ -878,7 +875,7 @@ TEST_F(FreeLeaseQueueAllocatorTest6, singlePdPoolWithReclamations) { IOAddress candidate = alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0); EXPECT_TRUE(candidate.isV6Zero()); - double r = alloc.getOccupancyRate(IOAddress("3000::"), 128, cc_, false); + double r = alloc.getOccupancyRate(IOAddress("3000::"), 128, cc_); EXPECT_EQ(1., r); auto i = 0; @@ -890,7 +887,7 @@ TEST_F(FreeLeaseQueueAllocatorTest6, singlePdPoolWithReclamations) { } ++i; } - r = alloc.getOccupancyRate(IOAddress("3000::"), 128, cc_, false); + r = alloc.getOccupancyRate(IOAddress("3000::"), 128, cc_); EXPECT_EQ(.5, r); for (auto j = 0; j < 128; ++j) { @@ -905,7 +902,7 @@ TEST_F(FreeLeaseQueueAllocatorTest6, singlePdPoolWithReclamations) { candidate = alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0); EXPECT_TRUE(candidate.isV6Zero()); - r = alloc.getOccupancyRate(IOAddress("3000::"), 128, cc_, false); + r = alloc.getOccupancyRate(IOAddress("3000::"), 128, cc_); EXPECT_EQ(1., r); } @@ -942,7 +939,7 @@ TEST_F(FreeLeaseQueueAllocatorTest6, manyPdPools) { // Make sure that unique prefixes have been returned. EXPECT_EQ(total, prefixes.size()); - double r = alloc.getOccupancyRate(IOAddress("3001::"), 128, cc_, false); + double r = alloc.getOccupancyRate(IOAddress("3001::"), 128, cc_); EXPECT_EQ(1., r); } @@ -979,12 +976,11 @@ TEST_F(FreeLeaseQueueAllocatorTest6, manyPdPoolsPreferLower) { // Make sure that unique prefixes have been returned. EXPECT_EQ(total, prefixes.size()); - double r = alloc.getOccupancyRate(IOAddress("2001:db8:1:2::"), - 120, cc_, false); + double r = alloc.getOccupancyRate(IOAddress("2001:db8:1:2::"), 120, cc_); EXPECT_EQ(1., r); - r = alloc.getOccupancyRate(IOAddress("2001:db8:1:2::"), 128, cc_, false); + r = alloc.getOccupancyRate(IOAddress("2001:db8:1:2::"), 128, cc_); EXPECT_EQ(65536. / 68096., r); - r = alloc.getOccupancyRate(IOAddress("2001:db8:1:2::"), 64, cc_, false); + r = alloc.getOccupancyRate(IOAddress("2001:db8:1:2::"), 64, cc_); EXPECT_EQ(0., r); } @@ -1020,7 +1016,7 @@ TEST_F(FreeLeaseQueueAllocatorTest6, manyPdPoolsPreferEqual) { } // Make sure that unique prefixes have been returned. EXPECT_EQ(total, prefixes.size()); - double r = alloc.getOccupancyRate(IOAddress("3001::"), 128, cc_, false); + double r = alloc.getOccupancyRate(IOAddress("3001::"), 128, cc_); EXPECT_EQ(2560. / 68096., r); } @@ -1056,7 +1052,7 @@ TEST_F(FreeLeaseQueueAllocatorTest6, manyPdPoolsPreferHigher) { } // Make sure that unique prefixes have been returned. EXPECT_EQ(total, prefixes.size()); - double r = alloc.getOccupancyRate(IOAddress("3001::"), 128, cc_, false); + double r = alloc.getOccupancyRate(IOAddress("3001::"), 128, cc_); EXPECT_EQ(2560. / 68096., r); } @@ -1095,13 +1091,13 @@ TEST_F(FreeLeaseQueueAllocatorTest6, pdPoolsClientClasses) { candidate = alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 64); EXPECT_TRUE(candidate.isV6Zero()); - double r = alloc.getOccupancyRate(IOAddress("3000:1::"), 128, cc_, false); + double r = alloc.getOccupancyRate(IOAddress("3000:1::"), 128, cc_); EXPECT_EQ(1., r); cc_.insert("foo"); - r = alloc.getOccupancyRate(IOAddress("3000:1::"), 128, cc_, false); + r = alloc.getOccupancyRate(IOAddress("3000:1::"), 128, cc_); EXPECT_EQ(256. / 65792., r); cc_.clear(); - r = alloc.getOccupancyRate(IOAddress("3000:1::"), 128, cc_, false); + r = alloc.getOccupancyRate(IOAddress("3000:1::"), 128, cc_); EXPECT_EQ(0., r); }