2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 05:27:55 +00:00

[#1958] addressed review comments

This commit is contained in:
Razvan Becheriu 2023-01-17 17:26:21 +02:00
parent 3478e51fd5
commit b6f0aaa01e
9 changed files with 231 additions and 162 deletions

View File

@ -669,12 +669,12 @@ AllocEngine::allocateUnreservedLeases6(ClientContext6& ctx) {
hint_prefix_length = 0;
}
if (!hint_prefix_length) {
prefix_length_match = Allocator::PREFIX_LEN_GREATER;
prefix_length_match = Allocator::PREFIX_LEN_HIGHER;
}
}
// Try the first allocation using PREFIX_LEN_EQUAL (or in case of PDs,
// PREFIX_LEN_GREATER when there is no valid delegated prefix length in the
// PREFIX_LEN_HIGHER when there is no valid delegated prefix length in the
// provided hint)
Lease6Ptr lease = allocateBestMatch(ctx, hint_lease, search_hint_lease,
hint, hint_prefix_length, subnet,
@ -683,12 +683,12 @@ AllocEngine::allocateUnreservedLeases6(ClientContext6& ctx) {
subnets_with_unavail_pools,
callout_status, prefix_length_match);
// Try the second allocation using PREFIX_LEN_SMALLER only for PDs if the
// Try the second allocation using PREFIX_LEN_LOWER only for PDs if the
// first allocation using PREFIX_LEN_EQUAL failed (there was a specific
// delegated prefix length hint requested).
if (!lease && ctx.currentIA().type_ == Lease::TYPE_PD &&
prefix_length_match == Allocator::PREFIX_LEN_EQUAL) {
prefix_length_match = Allocator::PREFIX_LEN_SMALLER;
prefix_length_match = Allocator::PREFIX_LEN_LOWER;
lease = allocateBestMatch(ctx, hint_lease, search_hint_lease, hint,
hint_prefix_length, subnet, network,
total_attempts, subnets_with_unavail_leases,
@ -696,12 +696,12 @@ AllocEngine::allocateUnreservedLeases6(ClientContext6& ctx) {
prefix_length_match);
}
// Try the third allocation using PREFIX_LEN_GREATER only for PDs if the
// second allocation using PREFIX_LEN_SMALLER failed (there was a specific
// Try the third allocation using PREFIX_LEN_HIGHER only for PDs if the
// second allocation using PREFIX_LEN_LOWER failed (there was a specific
// delegated prefix length hint requested).
if (!lease && ctx.currentIA().type_ == Lease::TYPE_PD &&
prefix_length_match == Allocator::PREFIX_LEN_SMALLER) {
prefix_length_match = Allocator::PREFIX_LEN_GREATER;
prefix_length_match == Allocator::PREFIX_LEN_LOWER) {
prefix_length_match = Allocator::PREFIX_LEN_HIGHER;
lease = allocateBestMatch(ctx, hint_lease, search_hint_lease, hint,
hint_prefix_length, subnet, network,
total_attempts, subnets_with_unavail_leases,
@ -845,10 +845,6 @@ AllocEngine::allocateBestMatch(ClientContext6& ctx,
search_hint_lease = false;
hint_lease = LeaseMgrFactory::instance().getLease6(ctx.currentIA().type_, hint);
usable_hint_lease = hint_lease;
if (prefix_length_match == Allocator::PREFIX_LEN_EQUAL && hint_lease &&
hint_lease->prefixlen_ != hint_prefix_length) {
usable_hint_lease.reset();
}
}
if (!usable_hint_lease) {
@ -868,6 +864,7 @@ AllocEngine::allocateBestMatch(ClientContext6& ctx,
}
if (hosts.empty()) {
// If the in-pool reservations are disabled, or there is no
// reservation for a given hint, we're good to go.
@ -1626,7 +1623,6 @@ AllocEngine::removeNonreservedLeases6(ClientContext6& ctx,
// If there's only one lease left, break the loop.
break;
}
}
// Remove all elements that we previously marked for deletion (those that
@ -2229,7 +2225,6 @@ AllocEngine::extendLease6(ClientContext6& ctx, Lease6Ptr lease) {
setLeaseReusable(lease, current_preferred_lft, ctx);
}
// Now that the lease has been reclaimed, we can go ahead and update it
// in the lease database.
if (lease->reuseable_valid_lft_ == 0) {

View File

@ -19,17 +19,21 @@ bool Allocator::isValidPrefixPool(Allocator::PrefixLenMatchType prefix_length_ma
return (false);
}
if (!hint_prefix_length) {
return (true);
}
if (prefix_length_match == Allocator::PREFIX_LEN_EQUAL &&
pool6->getLength() != hint_prefix_length) {
return (false);
}
if (prefix_length_match == Allocator::PREFIX_LEN_SMALLER &&
if (prefix_length_match == Allocator::PREFIX_LEN_LOWER &&
pool6->getLength() >= hint_prefix_length) {
return (false);
}
if (prefix_length_match == Allocator::PREFIX_LEN_GREATER &&
if (prefix_length_match == Allocator::PREFIX_LEN_HIGHER &&
pool6->getLength() <= hint_prefix_length) {
return (false);
}

View File

@ -59,8 +59,8 @@ public:
/// @brief Type of preferred PD-pool prefix length selection criteria
enum PrefixLenMatchType {
PREFIX_LEN_EQUAL, // select PD-pools with specific prefix length
PREFIX_LEN_SMALLER, // select PD-pools with smaller prefix length
PREFIX_LEN_GREATER // select PD-pools with greater prefix length
PREFIX_LEN_LOWER, // select PD-pools with lower prefix length
PREFIX_LEN_HIGHER // select PD-pools with higher prefix length
};
/// @brief Constructor
@ -88,9 +88,9 @@ public:
///
/// Pools which are not allowed for client classes are skipped.
///
/// @param client_classes list of classes client belongs to
/// @param duid Client's DUID
/// @param hint Client's hint
/// @param client_classes list of classes client belongs to.
/// @param duid Client's DUID.
/// @param hint Client's hint.
///
/// @return the next address.
virtual isc::asiolink::IOAddress
@ -111,14 +111,15 @@ public:
///
/// Pools which are not allowed for client classes are skipped.
///
/// @param client_classes list of classes client belongs to
/// @param client_classes list of classes client belongs to.
/// @param pool the selected pool satisfying all required conditions.
/// @param duid Client's DUID
/// @param duid Client's DUID.
/// @param prefix_length_match type which indicates the selection criteria
/// for the pools relative to the provided hint prefix length
/// @param hint Client's hint
/// for the pools relative to the provided hint prefix length.
/// @param hint Client's hint.
/// @param hint_prefix_length the hint prefix length that the client
/// provided
/// provided. The 0 value means that there is no hint and that any
/// pool will suffice.
///
/// @return the next prefix.
virtual isc::asiolink::IOAddress
@ -142,7 +143,8 @@ public:
/// @param pool the pool checked for restricted delegated prefix length
/// value.
/// @param hint_prefix_length The hint prefix length that the client
/// provided.
/// provided. The 0 value means that there is no hint and that any
/// pool will suffice.
static bool isValidPrefixPool(Allocator::PrefixLenMatchType prefix_length_match,
PoolPtr pool, uint8_t hint_prefix_length);
@ -170,14 +172,15 @@ private:
/// Derived classes must provide their specific implementations of
/// this function.
///
/// @param client_classes list of classes client belongs to
/// @param client_classes list of classes client belongs to.
/// @param pool the selected pool satisfying all required conditions.
/// @param duid Client's DUID
/// @param duid Client's DUID.
/// @param prefix_length_match type which indicates the selection criteria
/// for the pools relative to the provided hint prefix length
/// @param hint Client's hint
/// for the pools relative to the provided hint prefix length.
/// @param hint Client's hint.
/// @param hint_prefix_length the hint prefix length that the client
/// provided
/// provided. The 0 value means that there is no hint and that any
/// pool will suffice.
///
/// @return the next prefix.
virtual isc::asiolink::IOAddress

View File

@ -50,14 +50,15 @@ private:
///
/// Internal thread-unsafe implementation of the @c pickPrefix.
///
/// @param client_classes list of classes client belongs to
/// @param client_classes list of classes client belongs to.
/// @param pool the selected pool satisfying all required conditions.
/// @param duid Client's DUID
/// @param duid Client's DUID.
/// @param prefix_length_match type which indicates the selection criteria
/// for the pools relative to the provided hint prefix length
/// @param hint Client's hint
/// for the pools relative to the provided hint prefix length.
/// @param hint Client's hint.
/// @param hint_prefix_length the hint prefix length that the client
/// provided
/// provided. The 0 value means that there is no hint and that any
/// pool will suffice.
///
/// @return the next prefix.
virtual isc::asiolink::IOAddress

View File

@ -55,14 +55,15 @@ private:
///
/// Internal thread-unsafe implementation of the @c pickPrefix.
///
/// @param client_classes list of classes client belongs to
/// @param client_classes list of classes client belongs to.
/// @param pool the selected pool satisfying all required conditions.
/// @param duid Client's DUID
/// @param duid Client's DUID.
/// @param prefix_length_match type which indicates the selection criteria
/// for the pools relative to the provided hint prefix length
/// @param hint Client's hint
/// for the pools relative to the provided hint prefix length
/// @param hint Client's hint.
/// @param hint_prefix_length the hint prefix length that the client
/// provided
/// provided. The 0 value means that there is no hint and that any
/// pool will suffice.
///
/// @return the next prefix.
virtual isc::asiolink::IOAddress

View File

@ -393,6 +393,8 @@ protected:
/// @brief Returns a sum of possible leases in all pools allowing classes
/// and matching selection criteria relative to provided hint prefix length.
///
/// @note This function should be called only for PD pools.
///
/// @param pools list of pools
/// @param client_classes list of classes
/// @param prefix_length_match type which indicates the selection criteria

View File

@ -2114,8 +2114,7 @@ TEST_F(AllocEngine6Test, largePdPool) {
}
// This test checks that the allocation engine can pick a pool which has smaller
// delegated prefix length than the hint. The already present lease in the
// database is ignored because it does not match hint delegated length.
// delegated prefix length than the hint.
TEST_F(AllocEngine6Test, largePdPoolPreferrSmaller) {
AllocEngine engine(0);
@ -2130,23 +2129,44 @@ TEST_F(AllocEngine6Test, largePdPoolPreferrSmaller) {
Pool6Ptr pool2(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1:3::"), 72, 80));
subnet_->addPool(pool2);
// Let's create a lease and put it in the LeaseMgr
// Even if the lease is owned by the client, the non-matching prefix length
// in the hint should force allocation of other lease.
time_t now = time(NULL);
Lease6Ptr used(new Lease6(Lease::TYPE_PD, IOAddress("2001:db8:1:2::"),
duid_, 1, 2, now, subnet_->getID(), HWAddrPtr(), 96));
ASSERT_TRUE(LeaseMgrFactory::instance().addLease(used));
// We should have got exactly one lease.
Lease6Collection leases = allocateTest(engine, pool2, IOAddress("2001:db8:1:2::"),
false, true, 92);
ASSERT_EQ(1, leases.size());
}
// This test checks that the allocation engine can pick a pool which has smaller
// delegated prefix length than the hint. However the already present lease in
// the database is used and the hint delegated length is ignored.
TEST_F(AllocEngine6Test, largePdPoolPreferrExistingLeaseInsteadOfSmaller) {
AllocEngine engine(0);
// Remove the default PD pool.
subnet_->delPools(Lease::TYPE_PD);
// Configure the PD pool with the prefix length of /80 and the delegated
// length /96.
Pool6Ptr pool(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1:2::"), 80, 96));
subnet_->addPool(pool);
Pool6Ptr pool2(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1:3::"), 72, 80));
subnet_->addPool(pool2);
// Let's create a lease and put it in the LeaseMgr
// Even if the the prefix length in the hint does not match, the allocation
// engine should use the existing lease.
Lease6Ptr used(new Lease6(Lease::TYPE_PD, IOAddress("2001:db8:1:2::"),
duid_, iaid_, 501, 502, subnet_->getID(), HWAddrPtr(), 96));
ASSERT_TRUE(LeaseMgrFactory::instance().addLease(used));
// We should have got exactly one lease.
Lease6Collection leases = allocateTest(engine, pool, IOAddress("2001:db8:1:2::"),
false, true, 92);
ASSERT_EQ(1, leases.size());
}
// This test checks that the allocation engine can pick a pool which has exact
// delegated prefix length as the hint. The already present lease in the
// database is ignored because it does not match hint delegated length.
// delegated prefix length as the hint.
TEST_F(AllocEngine6Test, largePdPoolPreferrEqual) {
AllocEngine engine(0);
@ -2161,23 +2181,44 @@ TEST_F(AllocEngine6Test, largePdPoolPreferrEqual) {
Pool6Ptr pool2(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1:3::"), 72, 80));
subnet_->addPool(pool2);
// Let's create a lease and put it in the LeaseMgr
// Even if the lease is owned by the client, the non-matching prefix length
// in the hint should force allocation of other lease.
time_t now = time(NULL);
Lease6Ptr used(new Lease6(Lease::TYPE_PD, IOAddress("2001:db8:1:2::"),
duid_, 1, 2, now, subnet_->getID(), HWAddrPtr(), 96));
ASSERT_TRUE(LeaseMgrFactory::instance().addLease(used));
// We should have got exactly one lease.
Lease6Collection leases = allocateTest(engine, pool2, IOAddress("2001:db8:1:2::"),
false, true, 80);
ASSERT_EQ(1, leases.size());
}
// This test checks that the allocation engine can pick a pool which has exact
// delegated prefix length as the hint. However the already present lease in
// the database is used and the hint delegated length is ignored.
TEST_F(AllocEngine6Test, largePdPoolPreferrExistingLeaseInsteadOfEqual) {
AllocEngine engine(0);
// Remove the default PD pool.
subnet_->delPools(Lease::TYPE_PD);
// Configure the PD pool with the prefix length of /80 and the delegated
// length /96.
Pool6Ptr pool(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1:2::"), 80, 96));
subnet_->addPool(pool);
Pool6Ptr pool2(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1:3::"), 72, 80));
subnet_->addPool(pool2);
// Let's create a lease and put it in the LeaseMgr
// Even if the the prefix length in the hint does not match, the allocation
// engine should use the existing lease.
Lease6Ptr used(new Lease6(Lease::TYPE_PD, IOAddress("2001:db8:1:2::"),
duid_, iaid_, 501, 502, subnet_->getID(), HWAddrPtr(), 96));
ASSERT_TRUE(LeaseMgrFactory::instance().addLease(used));
// We should have got exactly one lease.
Lease6Collection leases = allocateTest(engine, pool, IOAddress("2001:db8:1:2::"),
false, true, 80);
ASSERT_EQ(1, leases.size());
}
// This test checks that the allocation engine can pick a pool which has greater
// delegated prefix length than the hint. The already present lease in the
// database is ignored because it does not match hint delegated length.
// delegated prefix length than the hint.
TEST_F(AllocEngine6Test, largePdPoolPreferrGreater) {
AllocEngine engine(0);
@ -2192,16 +2233,38 @@ TEST_F(AllocEngine6Test, largePdPoolPreferrGreater) {
Pool6Ptr pool2(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1:3::"), 72, 80));
subnet_->addPool(pool2);
// We should have got exactly one lease.
Lease6Collection leases = allocateTest(engine, pool, IOAddress("2001:db8:1:3::"),
false, true, 64);
ASSERT_EQ(1, leases.size());
}
// This test checks that the allocation engine can pick a pool which has greater
// delegated prefix length than the hint. However the already present lease in
// the database is used and the hint delegated length is ignored.
TEST_F(AllocEngine6Test, largePdPoolPreferrExistingLeaseInsteadOfGreater) {
AllocEngine engine(0);
// Remove the default PD pool.
subnet_->delPools(Lease::TYPE_PD);
// Configure the PD pool with the prefix length of /80 and the delegated
// length /96.
Pool6Ptr pool(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1:2::"), 80, 96));
subnet_->addPool(pool);
Pool6Ptr pool2(new Pool6(Lease::TYPE_PD, IOAddress("2001:db8:1:3::"), 72, 80));
subnet_->addPool(pool2);
// Let's create a lease and put it in the LeaseMgr
// Even if the lease is owned by the client, the non-matching prefix length
// in the hint should force allocation of other lease.
time_t now = time(NULL);
Lease6Ptr used(new Lease6(Lease::TYPE_PD, IOAddress("2001:db8:1:3::"),
duid_, 1, 2, now, subnet_->getID(), HWAddrPtr(), 80));
duid_, iaid_, 5001, 502, subnet_->getID(), HWAddrPtr(), 80));
ASSERT_TRUE(LeaseMgrFactory::instance().addLease(used));
// We should have got exactly one lease.
Lease6Collection leases = allocateTest(engine, pool, IOAddress("2001:db8:1:3::"),
Lease6Collection leases = allocateTest(engine, pool2, IOAddress("2001:db8:1:3::"),
false, true, 64);
ASSERT_EQ(1, leases.size());
}

View File

@ -56,7 +56,7 @@ TEST_F(IterativeAllocatorTest4, clientClass) {
// This test verifies that the iterative allocator really walks over all addresses
// in all pools in specified subnet. It also must not pick the same address twice
// unless it runs out of pool space and must start over.
// unless it runs out of pool space.
TEST_F(IterativeAllocatorTest4, manyPools) {
IterativeAllocator alloc(Lease::TYPE_V4, subnet_);
@ -145,8 +145,8 @@ TEST_F(IterativeAllocatorTest6, clientClass) {
}
// This test verifies that the iterative allocator really walks over all addresses
// in all pools in specified subnet. It also must not pick the same address twice
// unless it runs out of pool space and must start over.
// in all pools in specified subnet. It also must not pick the same address twice.
// unless it runs out of pool space.
TEST_F(IterativeAllocatorTest6, manyPools) {
NakedIterativeAllocator alloc(Lease::TYPE_NA, subnet_);
@ -367,62 +367,62 @@ TEST_F(IterativeAllocatorTest6, prefixStep) {
// First pool check (Let's check over all 16 leases)
EXPECT_EQ("2001:db8::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:10::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:20::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:30::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:40::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:50::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:60::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:70::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:80::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:90::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:a0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:b0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:c0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:d0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:e0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:f0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
// Second pool (just one lease here)
EXPECT_EQ("2001:db8:1::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
// Third pool (256 leases, let's check first and last explicitly and the
// rest over in a pool
EXPECT_EQ("2001:db8:2::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
for (int i = 1; i < 255; i++) {
stringstream exp;
exp << "2001:db8:2:" << hex << i << dec << "::";
EXPECT_EQ(exp.str(),
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
}
EXPECT_EQ("2001:db8:2:ff::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
// Ok, we've iterated over all prefixes in all pools. We now wrap around.
// We're looping over now (iterating over first pool again)
EXPECT_EQ("2001:db8::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:10::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
}
// This test verifies that the allocator picks delegated prefixes from several
@ -448,48 +448,48 @@ TEST_F(IterativeAllocatorTest6, prefixStepPreferrSmaller) {
// First pool check (Let's check over all 16 leases)
EXPECT_EQ("2001:db8::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:10::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:20::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:30::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:40::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:50::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:60::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:70::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:80::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:90::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:a0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:b0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:c0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:d0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:e0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:f0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
// Second pool (just one lease here)
EXPECT_EQ("2001:db8:1::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
// Ok, we've iterated over all prefixes in all pools. We now wrap around.
// We're looping over now (iterating over first pool again)
EXPECT_EQ("2001:db8::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
EXPECT_EQ("2001:db8:0:10::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 64).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 64).toText());
}
// This test verifies that the allocator picks delegated prefixes from several
@ -547,21 +547,21 @@ TEST_F(IterativeAllocatorTest6, prefixStepPreferrGreater) {
// Third pool (256 leases, let's check first and last explicitly and the
// rest over in a pool
EXPECT_EQ("2001:db8:2::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 60).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 60).toText());
for (int i = 1; i < 255; i++) {
stringstream exp;
exp << "2001:db8:2:" << hex << i << dec << "::";
EXPECT_EQ(exp.str(),
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 60).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 60).toText());
}
EXPECT_EQ("2001:db8:2:ff::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 60).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 60).toText());
// Ok, we've iterated over all prefixes in all pools. We now wrap around.
// We're looping over now (iterating over third pool again)
EXPECT_EQ("2001:db8:2::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 60).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 60).toText());
}
// This test verifies that the allocator picks delegated prefixes from the pools
@ -593,62 +593,62 @@ TEST_F(IterativeAllocatorTest6, prefixStepInClass) {
// First pool check (Let's check over all 16 leases)
EXPECT_EQ("2001:db8::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:10::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:20::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:30::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:40::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:50::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:60::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:70::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:80::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:90::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:a0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:b0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:c0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:d0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:e0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:f0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
// Second pool (just one lease here)
EXPECT_EQ("2001:db8:1::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
// Third pool (256 leases, let's check first and last explicitly and the
// rest over in a pool
EXPECT_EQ("2001:db8:2::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
for (int i = 1; i < 255; i++) {
stringstream exp;
exp << "2001:db8:2:" << hex << i << dec << "::";
EXPECT_EQ(exp.str(),
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
}
EXPECT_EQ("2001:db8:2:ff::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
// Ok, we've iterated over all prefixes in all pools. We now wrap around.
// We're looping over now (iterating over first pool again)
EXPECT_EQ("2001:db8::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:10::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
}
// This test verifies that the allocator omits pools with non-matching client classes.
@ -675,60 +675,60 @@ TEST_F(IterativeAllocatorTest6, prefixStepOutClass) {
// First pool check (Let's check over all 16 leases)
EXPECT_EQ("2001:db8::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:10::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:20::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:30::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:40::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:50::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:60::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:70::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:80::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:90::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:a0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:b0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:c0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:d0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:e0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:f0::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
// The second pool is skipped
// Third pool (256 leases, let's check first and last explicitly and the
// rest over in a pool
EXPECT_EQ("2001:db8:2::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
for (int i = 1; i < 255; i++) {
stringstream exp;
exp << "2001:db8:2:" << hex << i << dec << "::";
EXPECT_EQ(exp.str(),
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
}
EXPECT_EQ("2001:db8:2:ff::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
// Ok, we've iterated over all prefixes in all pools. We now wrap around.
// We're looping over now (iterating over first pool again)
EXPECT_EQ("2001:db8::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
EXPECT_EQ("2001:db8:0:10::",
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0).toText());
alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0).toText());
}
// This test verifies that the iterative allocator can step over addresses.

View File

@ -332,7 +332,7 @@ TEST_F(RandomAllocatorTest6, singlePdPool) {
// are returned.
std::set<IOAddress> prefixes;
for (auto i = 0; i < 66000; ++i) {
IOAddress candidate = alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0);
IOAddress candidate = alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0);
prefixes.insert(candidate);
EXPECT_TRUE(subnet_->inPool(Lease::TYPE_PD, candidate));
EXPECT_TRUE(subnet_->inPool(Lease::TYPE_PD, candidate, cc_));
@ -362,7 +362,7 @@ TEST_F(RandomAllocatorTest6, manyPdPools) {
for (auto j = 0; j < 2; ++j) {
std::set<IOAddress> prefixes;
for (auto i = 0; i < total; ++i) {
IOAddress candidate = alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 0);
IOAddress candidate = alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 0);
prefixes.insert(candidate);
EXPECT_TRUE(subnet_->inPool(Lease::TYPE_PD, candidate));
EXPECT_TRUE(subnet_->inPool(Lease::TYPE_PD, candidate, cc_));
@ -393,7 +393,7 @@ TEST_F(RandomAllocatorTest6, manyPdPoolsPreferrSmaller) {
for (auto j = 0; j < 2; ++j) {
std::set<IOAddress> prefixes;
for (auto i = 0; i < total; ++i) {
IOAddress candidate = alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_SMALLER, IOAddress("::"), 120);
IOAddress candidate = alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_LOWER, IOAddress("::"), 120);
prefixes.insert(candidate);
EXPECT_TRUE(subnet_->inPool(Lease::TYPE_PD, candidate));
EXPECT_TRUE(subnet_->inPool(Lease::TYPE_PD, candidate, cc_));
@ -455,7 +455,7 @@ TEST_F(RandomAllocatorTest6, manyPdPoolsPreferrGreater) {
for (auto j = 0; j < 2; ++j) {
std::set<IOAddress> prefixes;
for (auto i = 0; i < total; ++i) {
IOAddress candidate = alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_GREATER, IOAddress("::"), 64);
IOAddress candidate = alloc.pickPrefix(cc_, pool, duid_, Allocator::PREFIX_LEN_HIGHER, IOAddress("::"), 64);
prefixes.insert(candidate);
EXPECT_TRUE(subnet_->inPool(Lease::TYPE_PD, candidate));
EXPECT_TRUE(subnet_->inPool(Lease::TYPE_PD, candidate, cc_));