From b6f0aaa01edf72c917289020e2654de23dd61f2c Mon Sep 17 00:00:00 2001 From: Razvan Becheriu Date: Tue, 17 Jan 2023 17:26:21 +0200 Subject: [PATCH] [#1958] addressed review comments --- src/lib/dhcpsrv/alloc_engine.cc | 23 +-- src/lib/dhcpsrv/allocator.cc | 8 +- src/lib/dhcpsrv/allocator.h | 35 ++-- src/lib/dhcpsrv/iterative_allocator.h | 11 +- src/lib/dhcpsrv/random_allocator.h | 11 +- src/lib/dhcpsrv/subnet.h | 2 + .../dhcpsrv/tests/alloc_engine6_unittest.cc | 113 ++++++++--- .../tests/iterative_allocator_unittest.cc | 182 +++++++++--------- .../tests/random_allocator_unittest.cc | 8 +- 9 files changed, 231 insertions(+), 162 deletions(-) diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc index b8f15e918b..d65ae8313b 100644 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@ -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) { diff --git a/src/lib/dhcpsrv/allocator.cc b/src/lib/dhcpsrv/allocator.cc index 40a99bc1c8..eead3af770 100644 --- a/src/lib/dhcpsrv/allocator.cc +++ b/src/lib/dhcpsrv/allocator.cc @@ -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); } diff --git a/src/lib/dhcpsrv/allocator.h b/src/lib/dhcpsrv/allocator.h index 67e52dc427..3dd5cf96c0 100644 --- a/src/lib/dhcpsrv/allocator.h +++ b/src/lib/dhcpsrv/allocator.h @@ -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 diff --git a/src/lib/dhcpsrv/iterative_allocator.h b/src/lib/dhcpsrv/iterative_allocator.h index 356676d1cc..9d572e4b8c 100644 --- a/src/lib/dhcpsrv/iterative_allocator.h +++ b/src/lib/dhcpsrv/iterative_allocator.h @@ -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 diff --git a/src/lib/dhcpsrv/random_allocator.h b/src/lib/dhcpsrv/random_allocator.h index 29791f1abb..d40f1616ff 100644 --- a/src/lib/dhcpsrv/random_allocator.h +++ b/src/lib/dhcpsrv/random_allocator.h @@ -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 diff --git a/src/lib/dhcpsrv/subnet.h b/src/lib/dhcpsrv/subnet.h index e36d3124d4..ad15e97bad 100644 --- a/src/lib/dhcpsrv/subnet.h +++ b/src/lib/dhcpsrv/subnet.h @@ -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 diff --git a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc index 6f9b6a7b1f..c8e6a91a7e 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc @@ -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()); } diff --git a/src/lib/dhcpsrv/tests/iterative_allocator_unittest.cc b/src/lib/dhcpsrv/tests/iterative_allocator_unittest.cc index 1579f4768f..fb90e9a034 100644 --- a/src/lib/dhcpsrv/tests/iterative_allocator_unittest.cc +++ b/src/lib/dhcpsrv/tests/iterative_allocator_unittest.cc @@ -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. diff --git a/src/lib/dhcpsrv/tests/random_allocator_unittest.cc b/src/lib/dhcpsrv/tests/random_allocator_unittest.cc index 03cac06c80..2858eb141c 100644 --- a/src/lib/dhcpsrv/tests/random_allocator_unittest.cc +++ b/src/lib/dhcpsrv/tests/random_allocator_unittest.cc @@ -332,7 +332,7 @@ TEST_F(RandomAllocatorTest6, singlePdPool) { // are returned. std::set 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 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 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 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_));