// Allocator selection at the global level can affect subnets and shared networks
// for which the allocator hasn't been specified explicitly. Let's see if the
// allocator has been specified at the global level.
- std::string default_allocator;
+ std::string global_allocator;
auto allocator = external_cfg->getConfiguredGlobal(CfgGlobals::ALLOCATOR);
if (allocator && (allocator->getType() == Element::string)) {
- default_allocator = allocator->stringValue();
+ global_allocator = allocator->stringValue();
}
// If we're fetching the changes from the config backend we also want
// We're only affected by the allocator change if this is the update from
// the configuration backend.
if (cb_update) {
- std::string current_default_allocator;
auto allocator = CfgMgr::instance().getCurrentCfg()->getConfiguredGlobal(CfgGlobals::ALLOCATOR);
if (allocator && (allocator->getType() == Element::string)) {
- allocator_changed = (default_allocator != allocator->stringValue());
+ allocator_changed = (global_allocator != allocator->stringValue());
}
}
(*network)->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
});
- (*network)->setDefaultAllocatorType(default_allocator);
+ (*network)->setDefaultAllocatorType(global_allocator);
external_cfg->getCfgSharedNetworks4()->add((*network));
}
Subnet4Collection subnets;
if (allocator_changed || reconfig) {
// A change of the allocator or the server reconfiguration can affect all
- // shared networks. Get all subnets.
+ // subnets. Get all subnets.
subnets = getMgr().getPool()->getAllSubnets4(backend_selector, server_selector);
} else if (!updated_entries.empty()) {
(*subnet)->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
});
- (*subnet)->setDefaultAllocatorType(default_allocator);
+ (*subnet)->setDefaultAllocatorType(global_allocator);
external_cfg->getCfgSubnets4()->add((*subnet));
}
// Allocator selection at the global level can affect subnets and shared networks
// for which the allocator hasn't been specified explicitly. Let's see if the
// allocator has been specified at the global level.
- std::string default_allocator;
+ std::string global_allocator;
auto allocator = external_cfg->getConfiguredGlobal(CfgGlobals::ALLOCATOR);
if (allocator && (allocator->getType() == Element::string)) {
- default_allocator = allocator->stringValue();
+ global_allocator = allocator->stringValue();
}
// Also, get the PD allocator.
- std::string default_pd_allocator;
+ std::string global_pd_allocator;
allocator = external_cfg->getConfiguredGlobal(CfgGlobals::PD_ALLOCATOR);
if (allocator && (allocator->getType() == Element::string)) {
- default_pd_allocator = allocator->stringValue();
+ global_pd_allocator = allocator->stringValue();
}
// If we're fetching the changes from the config backend we also want
if (cb_update) {
auto allocator = CfgMgr::instance().getCurrentCfg()->getConfiguredGlobal(CfgGlobals::ALLOCATOR);
if (allocator && (allocator->getType() == Element::string)) {
- allocator_changed = (default_allocator != allocator->stringValue());
+ allocator_changed = (global_allocator != allocator->stringValue());
}
// The address allocator hasn't changed. So, let's check if the PD allocator
if (!allocator_changed) {
auto allocator = CfgMgr::instance().getCurrentCfg()->getConfiguredGlobal(CfgGlobals::PD_ALLOCATOR);
if (allocator && (allocator->getType() == Element::string)) {
- allocator_changed = (default_pd_allocator != allocator->stringValue());
+ allocator_changed = (global_pd_allocator != allocator->stringValue());
}
}
}
(*network)->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
});
- (*network)->setDefaultAllocatorType(default_allocator);
- (*network)->setDefaultPdAllocatorType(default_pd_allocator);
+ (*network)->setDefaultAllocatorType(global_allocator);
+ (*network)->setDefaultPdAllocatorType(global_pd_allocator);
external_cfg->getCfgSharedNetworks6()->add((*network));
}
Subnet6Collection subnets;
if (allocator_changed || reconfig) {
// A change of the allocator or the server reconfiguration can affect all
- // shared networks. Get all subnets.
+ // subnets. Get all subnets.
subnets = getMgr().getPool()->getAllSubnets6(backend_selector, server_selector);
} else if (!updated_entries.empty()) {
(*subnet)->setFetchGlobalsFn([] () -> ConstCfgGlobalsPtr {
return (CfgMgr::instance().getCurrentCfg()->getConfiguredGlobals());
});
- (*subnet)->setDefaultAllocatorType(default_allocator);
- (*subnet)->setDefaultPdAllocatorType(default_pd_allocator);
+ (*subnet)->setDefaultAllocatorType(global_allocator);
+ (*subnet)->setDefaultPdAllocatorType(global_pd_allocator);
external_cfg->getCfgSubnets6()->add((*subnet));
}
util::Optional<std::string> allocator_type_;
/// @brief Default allocator type.
+ ///
+ /// This value is not configurable by the user. It is used by the configuration
+ /// backend internally.
util::Optional<std::string> default_allocator_type_;
/// @brief Pointer to another network that this network belongs to.
// Test that the allocator returns the correct type.
TEST_F(FreeLeaseQueueAllocatorTest6, getType) {
- FreeLeaseQueueAllocator alloc(Lease::TYPE_NA, subnet_);
- EXPECT_EQ("flq", alloc.getType());
+ FreeLeaseQueueAllocator allocNA(Lease::TYPE_NA, subnet_);
+ EXPECT_EQ("flq", allocNA.getType());
+
+ FreeLeaseQueueAllocator allocPD(Lease::TYPE_PD, subnet_);
+ EXPECT_EQ("flq", allocPD.getType());
}
// Test populating free DHCPv6 address leases to the queue.
// Test that the allocator returns the correct type.
TEST_F(IterativeAllocatorTest6, getType) {
- IterativeAllocator alloc(Lease::TYPE_NA, subnet_);
- EXPECT_EQ("iterative", alloc.getType());
+ IterativeAllocator allocNA(Lease::TYPE_NA, subnet_);
+ EXPECT_EQ("iterative", allocNA.getType());
+
+ IterativeAllocator allocPD(Lease::TYPE_PD, subnet_);
+ EXPECT_EQ("iterative", allocPD.getType());
}
// This test verifies that the allocator picks addresses that belong to the
// Test that the allocator returns the correct type.
TEST_F(RandomAllocatorTest6, getType) {
- RandomAllocator alloc(Lease::TYPE_NA, subnet_);
- EXPECT_EQ("random", alloc.getType());
+ RandomAllocator allocNA(Lease::TYPE_NA, subnet_);
+ EXPECT_EQ("random", allocNA.getType());
+
+ RandomAllocator allocPD(Lease::TYPE_PD, subnet_);
+ EXPECT_EQ("random", allocPD.getType());
}
// Test allocating IPv6 addresses when a subnet has a single pool.