|
@@ -55,8 +55,10 @@ public:
|
|
/// @brief the sole constructor
|
|
/// @brief the sole constructor
|
|
/// @param engine_type specifies engine type (e.g. iterative)
|
|
/// @param engine_type specifies engine type (e.g. iterative)
|
|
/// @param attempts number of lease selection attempts before giving up
|
|
/// @param attempts number of lease selection attempts before giving up
|
|
- NakedAllocEngine(AllocEngine::AllocType engine_type, unsigned int attempts)
|
|
+ /// @param ipv6 specifies if the engine is IPv6 or IPv4
|
|
- :AllocEngine(engine_type, attempts) {
|
|
+ NakedAllocEngine(AllocEngine::AllocType engine_type,
|
|
|
|
+ unsigned int attempts, bool ipv6 = true)
|
|
|
|
+ :AllocEngine(engine_type, attempts, ipv6) {
|
|
}
|
|
}
|
|
|
|
|
|
// Expose internal classes for testing purposes
|
|
// Expose internal classes for testing purposes
|
|
@@ -399,7 +401,7 @@ TEST_F(AllocEngine6Test, allocateAddress6Nulls) {
|
|
// pool
|
|
// pool
|
|
TEST_F(AllocEngine6Test, IterativeAllocator) {
|
|
TEST_F(AllocEngine6Test, IterativeAllocator) {
|
|
boost::scoped_ptr<NakedAllocEngine::Allocator>
|
|
boost::scoped_ptr<NakedAllocEngine::Allocator>
|
|
- alloc(new NakedAllocEngine::IterativeAllocator());
|
|
+ alloc(new NakedAllocEngine::IterativeAllocator(Pool6::TYPE_IA));
|
|
|
|
|
|
for (int i = 0; i < 1000; ++i) {
|
|
for (int i = 0; i < 1000; ++i) {
|
|
IOAddress candidate = alloc->pickAddress(subnet_, duid_, IOAddress("::"));
|
|
IOAddress candidate = alloc->pickAddress(subnet_, duid_, IOAddress("::"));
|
|
@@ -412,7 +414,7 @@ TEST_F(AllocEngine6Test, IterativeAllocator) {
|
|
// in all pools in specified subnet. It also must not pick the same address twice
|
|
// 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 and must start over.
|
|
TEST_F(AllocEngine6Test, IterativeAllocator_manyPools6) {
|
|
TEST_F(AllocEngine6Test, IterativeAllocator_manyPools6) {
|
|
- NakedAllocEngine::IterativeAllocator alloc;
|
|
+ NakedAllocEngine::IterativeAllocator alloc(Pool6::TYPE_IA);
|
|
|
|
|
|
// let's start from 2, as there is 2001:db8:1::10 - 2001:db8:1::20 pool already.
|
|
// let's start from 2, as there is 2001:db8:1::10 - 2001:db8:1::20 pool already.
|
|
for (int i = 2; i < 10; ++i) {
|
|
for (int i = 2; i < 10; ++i) {
|
|
@@ -632,7 +634,8 @@ TEST_F(AllocEngine6Test, requestReuseExpiredLease6) {
|
|
// This test checks if the simple IPv4 allocation can succeed
|
|
// This test checks if the simple IPv4 allocation can succeed
|
|
TEST_F(AllocEngine4Test, simpleAlloc4) {
|
|
TEST_F(AllocEngine4Test, simpleAlloc4) {
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
- ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
|
|
+ ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE,
|
|
|
|
+ 100, false)));
|
|
ASSERT_TRUE(engine);
|
|
ASSERT_TRUE(engine);
|
|
|
|
|
|
Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
|
|
Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
|
|
@@ -661,7 +664,8 @@ TEST_F(AllocEngine4Test, simpleAlloc4) {
|
|
// This test checks if the fake allocation (for DISCOVER) can succeed
|
|
// This test checks if the fake allocation (for DISCOVER) can succeed
|
|
TEST_F(AllocEngine4Test, fakeAlloc4) {
|
|
TEST_F(AllocEngine4Test, fakeAlloc4) {
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
- ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
|
|
+ ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE,
|
|
|
|
+ 100, false)));
|
|
ASSERT_TRUE(engine);
|
|
ASSERT_TRUE(engine);
|
|
|
|
|
|
Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
|
|
Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
|
|
@@ -689,7 +693,8 @@ TEST_F(AllocEngine4Test, fakeAlloc4) {
|
|
// in pool and free) can succeed
|
|
// in pool and free) can succeed
|
|
TEST_F(AllocEngine4Test, allocWithValidHint4) {
|
|
TEST_F(AllocEngine4Test, allocWithValidHint4) {
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
- ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
|
|
+ ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE,
|
|
|
|
+ 100, false)));
|
|
ASSERT_TRUE(engine);
|
|
ASSERT_TRUE(engine);
|
|
|
|
|
|
Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
|
|
Lease4Ptr lease = engine->allocateAddress4(subnet_, clientid_, hwaddr_,
|
|
@@ -722,7 +727,8 @@ TEST_F(AllocEngine4Test, allocWithValidHint4) {
|
|
// in pool, but is currently used) can succeed
|
|
// in pool, but is currently used) can succeed
|
|
TEST_F(AllocEngine4Test, allocWithUsedHint4) {
|
|
TEST_F(AllocEngine4Test, allocWithUsedHint4) {
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
- ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
|
|
+ ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE,
|
|
|
|
+ 100, false)));
|
|
ASSERT_TRUE(engine);
|
|
ASSERT_TRUE(engine);
|
|
|
|
|
|
// Let's create a lease and put it in the LeaseMgr
|
|
// Let's create a lease and put it in the LeaseMgr
|
|
@@ -770,7 +776,8 @@ TEST_F(AllocEngine4Test, allocWithUsedHint4) {
|
|
// can succeed. The invalid hint should be ignored completely.
|
|
// can succeed. The invalid hint should be ignored completely.
|
|
TEST_F(AllocEngine4Test, allocBogusHint4) {
|
|
TEST_F(AllocEngine4Test, allocBogusHint4) {
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
- ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
|
|
+ ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE,
|
|
|
|
+ 100, false)));
|
|
ASSERT_TRUE(engine);
|
|
ASSERT_TRUE(engine);
|
|
|
|
|
|
// Client would like to get a 3000::abc lease, which does not belong to any
|
|
// Client would like to get a 3000::abc lease, which does not belong to any
|
|
@@ -805,7 +812,8 @@ TEST_F(AllocEngine4Test, allocBogusHint4) {
|
|
// This test checks that NULL values are handled properly
|
|
// This test checks that NULL values are handled properly
|
|
TEST_F(AllocEngine4Test, allocateAddress4Nulls) {
|
|
TEST_F(AllocEngine4Test, allocateAddress4Nulls) {
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
- ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
|
|
+ ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE,
|
|
|
|
+ 100, false)));
|
|
ASSERT_TRUE(engine);
|
|
ASSERT_TRUE(engine);
|
|
|
|
|
|
// Allocations without subnet are not allowed
|
|
// Allocations without subnet are not allowed
|
|
@@ -854,7 +862,7 @@ TEST_F(AllocEngine4Test, allocateAddress4Nulls) {
|
|
// pool
|
|
// pool
|
|
TEST_F(AllocEngine4Test, IterativeAllocator) {
|
|
TEST_F(AllocEngine4Test, IterativeAllocator) {
|
|
boost::scoped_ptr<NakedAllocEngine::Allocator>
|
|
boost::scoped_ptr<NakedAllocEngine::Allocator>
|
|
- alloc(new NakedAllocEngine::IterativeAllocator());
|
|
+ alloc(new NakedAllocEngine::IterativeAllocator(Pool6::TYPE_V4));
|
|
|
|
|
|
for (int i = 0; i < 1000; ++i) {
|
|
for (int i = 0; i < 1000; ++i) {
|
|
IOAddress candidate = alloc->pickAddress(subnet_, clientid_,
|
|
IOAddress candidate = alloc->pickAddress(subnet_, clientid_,
|
|
@@ -868,7 +876,7 @@ TEST_F(AllocEngine4Test, IterativeAllocator) {
|
|
// in all pools in specified subnet. It also must not pick the same address twice
|
|
// 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 and must start over.
|
|
TEST_F(AllocEngine4Test, IterativeAllocator_manyPools4) {
|
|
TEST_F(AllocEngine4Test, IterativeAllocator_manyPools4) {
|
|
- NakedAllocEngine::IterativeAllocator alloc;
|
|
+ NakedAllocEngine::IterativeAllocator alloc(Pool6::TYPE_V4);
|
|
|
|
|
|
// Let's start from 2, as there is 2001:db8:1::10 - 2001:db8:1::20 pool already.
|
|
// Let's start from 2, as there is 2001:db8:1::10 - 2001:db8:1::20 pool already.
|
|
for (int i = 2; i < 10; ++i) {
|
|
for (int i = 2; i < 10; ++i) {
|
|
@@ -923,7 +931,8 @@ TEST_F(AllocEngine4Test, IterativeAllocator_manyPools4) {
|
|
// This test checks if really small pools are working
|
|
// This test checks if really small pools are working
|
|
TEST_F(AllocEngine4Test, smallPool4) {
|
|
TEST_F(AllocEngine4Test, smallPool4) {
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
- ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
|
|
+ ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE,
|
|
|
|
+ 100, false)));
|
|
ASSERT_TRUE(engine);
|
|
ASSERT_TRUE(engine);
|
|
|
|
|
|
IOAddress addr("192.0.2.17");
|
|
IOAddress addr("192.0.2.17");
|
|
@@ -965,7 +974,8 @@ TEST_F(AllocEngine4Test, smallPool4) {
|
|
// to find out a new lease fails.
|
|
// to find out a new lease fails.
|
|
TEST_F(AllocEngine4Test, outOfAddresses4) {
|
|
TEST_F(AllocEngine4Test, outOfAddresses4) {
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
- ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
|
|
+ ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE,
|
|
|
|
+ 100, false)));
|
|
ASSERT_TRUE(engine);
|
|
ASSERT_TRUE(engine);
|
|
|
|
|
|
IOAddress addr("192.0.2.17");
|
|
IOAddress addr("192.0.2.17");
|
|
@@ -1003,7 +1013,8 @@ TEST_F(AllocEngine4Test, outOfAddresses4) {
|
|
// This test checks if an expired lease can be reused in DISCOVER (fake allocation)
|
|
// This test checks if an expired lease can be reused in DISCOVER (fake allocation)
|
|
TEST_F(AllocEngine4Test, discoverReuseExpiredLease4) {
|
|
TEST_F(AllocEngine4Test, discoverReuseExpiredLease4) {
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
- ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
|
|
+ ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE,
|
|
|
|
+ 100, false)));
|
|
ASSERT_TRUE(engine);
|
|
ASSERT_TRUE(engine);
|
|
|
|
|
|
IOAddress addr("192.0.2.15");
|
|
IOAddress addr("192.0.2.15");
|
|
@@ -1070,7 +1081,8 @@ TEST_F(AllocEngine4Test, discoverReuseExpiredLease4) {
|
|
// This test checks if an expired lease can be reused in REQUEST (actual allocation)
|
|
// This test checks if an expired lease can be reused in REQUEST (actual allocation)
|
|
TEST_F(AllocEngine4Test, requestReuseExpiredLease4) {
|
|
TEST_F(AllocEngine4Test, requestReuseExpiredLease4) {
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
- ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
|
|
+ ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE,
|
|
|
|
+ 100, false)));
|
|
ASSERT_TRUE(engine);
|
|
ASSERT_TRUE(engine);
|
|
|
|
|
|
IOAddress addr("192.0.2.105");
|
|
IOAddress addr("192.0.2.105");
|
|
@@ -1123,7 +1135,8 @@ TEST_F(AllocEngine4Test, renewLease4) {
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
CalloutHandlePtr callout_handle = HooksManager::createCalloutHandle();
|
|
CalloutHandlePtr callout_handle = HooksManager::createCalloutHandle();
|
|
|
|
|
|
- ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
|
|
+ ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE,
|
|
|
|
+ 100, false)));
|
|
ASSERT_TRUE(engine);
|
|
ASSERT_TRUE(engine);
|
|
|
|
|
|
IOAddress addr("192.0.2.102");
|
|
IOAddress addr("192.0.2.102");
|
|
@@ -1500,7 +1513,8 @@ TEST_F(HookAllocEngine4Test, lease4_select) {
|
|
|
|
|
|
// Create allocation engine (hook names are registered in its ctor)
|
|
// Create allocation engine (hook names are registered in its ctor)
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
- ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
|
|
+ ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE,
|
|
|
|
+ 100, false)));
|
|
ASSERT_TRUE(engine);
|
|
ASSERT_TRUE(engine);
|
|
|
|
|
|
// Initialize Hooks Manager
|
|
// Initialize Hooks Manager
|
|
@@ -1563,7 +1577,8 @@ TEST_F(HookAllocEngine4Test, change_lease4_select) {
|
|
|
|
|
|
// Create allocation engine (hook names are registered in its ctor)
|
|
// Create allocation engine (hook names are registered in its ctor)
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
boost::scoped_ptr<AllocEngine> engine;
|
|
- ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100)));
|
|
+ ASSERT_NO_THROW(engine.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE,
|
|
|
|
+ 100, false)));
|
|
ASSERT_TRUE(engine);
|
|
ASSERT_TRUE(engine);
|
|
|
|
|
|
// Initialize Hooks Manager
|
|
// Initialize Hooks Manager
|