44 generator_.seed(rd());
50 auto const& pools = subnet->getPools(
pool_type_);
59 for (
const auto& pool : pools) {
63 pool->getLastAddress(),
64 subnet->getID(),
false);
68 pool->getLastAddress(),
70 subnet->getID(),
false);
73 auto pdpool = boost::dynamic_pointer_cast<Pool6>(pool);
75 pool->getLastAddress(),
77 subnet->getID(),
false);
87SharedFlqAllocator::pickAddressInternal(
const ClientClasses& client_classes,
93 auto const& pools = subnet->getPools(
pool_type_);
94 std::vector<PoolPtr> available;
95 for (
auto const& pool : pools) {
97 if (pool->clientSupported(client_classes)) {
98 available.push_back(pool);
103 while (available.size()) {
105 auto offset = getRandomNumber(available.size() - 1);
106 PoolPtr const pool = available[offset];
112 pool->getLastAddress());
113 if (!free_lease.isV4Zero()) {
124 pool->getLastAddress());
125 if (!free_lease.isV6Zero()) {
133 isc_throw(Unexpected,
"pickAddressInternal called for Lease::TYPE_PD");
138 available.erase(available.begin() + offset);
147SharedFlqAllocator::pickPrefixInternal(
const ClientClasses& client_classes,
150 PrefixLenMatchType prefix_length_match,
152 uint8_t hint_prefix_length) {
156 auto const& pools = subnet->getPools(
pool_type_);
157 std::vector<PoolPtr> available;
158 for (
auto const& pool : pools) {
160 if (pool->clientSupported(client_classes)) {
162 hint_prefix_length)) {
166 available.push_back(pool);
171 while (available.size()) {
173 auto offset = getRandomNumber(available.size() - 1);
174 PoolPtr const pool = available[offset];
177 isc_throw(Unexpected,
"pickAddressInternal called for Lease::TYPE_V4");
181 isc_throw(Unexpected,
"pickAddressInternal called for Lease::TYPE_NA");
187 pool->getLastAddress());
188 if (!free_lease.isV6Zero()) {
197 available.erase(available.begin() + offset);
205SharedFlqAllocator::getRandomNumber(uint64_t limit) {
210 std::uniform_int_distribution<uint64_t> dist(0, limit);
211 return (dist(generator_));
217 if (!subnet->getAllocationState(
pool_type_)) {
219 boost::make_shared<SubnetSflqAllocationState>());
223 state = boost::dynamic_pointer_cast<SubnetSflqAllocationState>
235 auto const& capacity(pool->getCapacity());
239 <<
" for shared-flq allocator on V4 pool "
247 if (subnet->getAllocatorType() ==
"shared-flq") {
249 auto const& capacity(pool->getCapacity());
253 <<
" for shared-flq allocator on V6 pool "
259 if (subnet->getPdAllocatorType() ==
"shared-flq") {
261 auto const& capacity(pool->getCapacity());
265 <<
" for shared-flq allocator on V6 pool "
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
A generic exception that is thrown when an unexpected error condition occurs.
The IOAddress class represents an IP addresses (version agnostic)
static const IOAddress & IPV4_ZERO_ADDRESS()
Returns an address set to all zeros.
static const IOAddress & IPV6_ZERO_ADDRESS()
Returns an IPv6 zero address.
virtual void initAfterConfigureInternal()
Allocator-specific initialization function.
Lease::Type pool_type_
Defines pool type allocation.
Allocator(Lease::Type type, const WeakSubnetPtr &subnet)
Constructor.
WeakSubnetPtr subnet_
Weak pointer to the subnet owning the allocator.
static bool isValidPrefixPool(Allocator::PrefixLenMatchType prefix_length_match, PoolPtr pool, uint8_t hint_prefix_length)
Check if the pool matches the selection criteria relative to the provided hint prefix length.
Container for storing client class names.
static TrackingLeaseMgr & instance()
Return current lease manager.
virtual asiolink::IOAddress sflqPickFreeLease4(asiolink::IOAddress start_address, asiolink::IOAddress end_address)
Finds a free V4 address within the given pool range.
virtual bool sflqCreateFlqPool4(asiolink::IOAddress start_address, asiolink::IOAddress end_address, SubnetID subnet_id, bool recreate=false)
Creates a v4 SFLQ Pool.
virtual asiolink::IOAddress sflqPickFreeLease6(asiolink::IOAddress start_address, asiolink::IOAddress end_address)
Finds a free V6 address/prefix within the given pool range.
virtual bool sflqCreateFlqPool6(asiolink::IOAddress start_address, asiolink::IOAddress end_address, Lease::Type lease_type, uint8_t delegated_len, SubnetID subnet_id, bool recreate=false)
Calls stored procedure to create an SFLQ pool for v6.
static void setInUse(bool in_use)
Sets the global in-use flag.
static bool inUse()
Returns the global in-use flag.
static void sanityChecksSflqAllocator6(Subnet6Ptr subnet)
Sanity checks the subnet and pool configuration for use with SFLQ.
static void sanityChecksSflqAllocator4(Subnet4Ptr subnet)
Sanity checks the subnet and pool configuration for use with SFLQ.
SubnetSflqAllocationStatePtr getSubnetState() const
Returns the allocation state for the subnet pool_type;.
static constexpr size_t MAX_V6_POOL_SIZE
Maximum capacity of a V6 pool supported by SFLQ.
SharedFlqAllocator(Lease::Type type, const WeakSubnetPtr &subnet)
Constructor.
static constexpr size_t MAX_V4_POOL_SIZE
Maximum capacity of a V4 pool supported by SFLQ.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< Subnet4 > Subnet4Ptr
A pointer to a Subnet4 object.
boost::weak_ptr< Subnet > WeakSubnetPtr
Weak pointer to the Subnet.
boost::shared_ptr< Subnet6 > Subnet6Ptr
A pointer to a Subnet6 object.
boost::shared_ptr< IdentifierBaseType > IdentifierBaseTypePtr
Shared pointer to a IdentifierType.
boost::shared_ptr< Pool > PoolPtr
a pointer to either IPv4 or IPv6 Pool
boost::shared_ptr< SubnetSflqAllocationState > SubnetSflqAllocationStatePtr
Type of the pointer to the SubnetSflqAllocationState.
boost::shared_ptr< Pool6 > Pool6Ptr
a pointer an IPv6 Pool
Defines the logger used by the top-level component of kea-lfc.
Type
Type of lease or pool.
@ TYPE_TA
the lease contains temporary IPv6 address
@ TYPE_PD
the lease contains IPv6 prefix (for prefix delegation)
@ TYPE_NA
the lease contains non-temporary IPv6 address