![]() |
Kea 3.1.8
|
An allocator maintaining a shared queue of free leases. More...
#include <sflq_allocator.h>
Public Member Functions | |
| SharedFlqAllocator (Lease::Type type, const WeakSubnetPtr &subnet) | |
| Constructor. | |
| SubnetSflqAllocationStatePtr | getSubnetState () const |
| Returns the allocation state for the subnet pool_type;. | |
| virtual std::string | getType () const |
| Returns the allocator type string. | |
| Public Member Functions inherited from isc::dhcp::Allocator | |
| Allocator (Lease::Type type, const WeakSubnetPtr &subnet) | |
| Constructor. | |
| virtual | ~Allocator () |
| Virtual destructor. | |
| virtual double | getOccupancyRate (const asiolink::IOAddress &addr, const ClientClasses &client_classes) |
| Returns the occupancy rate (v4 addresses). | |
| virtual double | getOccupancyRate (const asiolink::IOAddress &pref, const uint8_t plen, const ClientClasses &client_classes) |
| Returns the occupancy rate (v6 prefixes). | |
| void | initAfterConfigure () |
| Performs allocator initialization after server's reconfiguration. | |
| virtual isc::asiolink::IOAddress | pickAddress (const ClientClasses &client_classes, const IdentifierBaseTypePtr &duid, const asiolink::IOAddress &hint) |
| Picks an address. | |
| virtual isc::asiolink::IOAddress | pickPrefix (const ClientClasses &client_classes, Pool6Ptr &pool, const IdentifierBaseTypePtr &duid, PrefixLenMatchType prefix_length_match, const asiolink::IOAddress &hint, uint8_t hint_prefix_length) |
| Picks a delegated prefix. | |
Static Public Member Functions | |
| static bool | inUse () |
| Returns the global in-use flag. | |
| static void | sanityChecksSflqAllocator4 (Subnet4Ptr subnet) |
| Sanity checks the subnet and pool configuration for use with SFLQ. | |
| static void | sanityChecksSflqAllocator6 (Subnet6Ptr subnet) |
| Sanity checks the subnet and pool configuration for use with SFLQ. | |
| static void | setInUse (bool in_use) |
| Sets the global in-use flag. | |
| Static Public Member Functions inherited from isc::dhcp::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. | |
Static Public Attributes | |
| static constexpr size_t | MAX_V4_POOL_SIZE = 16777216 |
| Maximum capacity of a V4 pool supported by SFLQ. | |
| static constexpr size_t | MAX_V6_POOL_SIZE = 16777216 |
| Maximum capacity of a V6 pool supported by SFLQ. | |
Additional Inherited Members | |
| Public Types inherited from isc::dhcp::Allocator | |
| enum | PrefixLenMatchType { PREFIX_LEN_EQUAL , PREFIX_LEN_LOWER , PREFIX_LEN_HIGHER } |
| Type of preferred PD-pool prefix length selection criteria. More... | |
| Protected Attributes inherited from isc::dhcp::Allocator | |
| bool | inited_ |
| Indicates if the allocator has been initialized. | |
| std::mutex | mutex_ |
| The mutex to protect the allocated lease. | |
| Lease::Type | pool_type_ |
| Defines pool type allocation. | |
| WeakSubnetPtr | subnet_ |
| Weak pointer to the subnet owning the allocator. | |
| SubnetID | subnet_id_ |
| ID of a subnet to which the allocator belongs. | |
An allocator maintaining a shared queue of free leases.
This allocator is part of the Shared Free Lease Queue (SFLQ) Allocation scheme. The concept is similar to FLQ Allocation but rather than the creating and maintaining free lease data locally, it is created and maintained in the lease back end (MySql and PosgreSQL only) where it can be shared by other servers.
Th allocator relies on stored procedures in the lease back end to return free leases for a given IP address range (i.e. pool). This can greatly reduces the number of queries made to lease back end as only addresses that are actually free are returned. The allocation engine must still check for HR conflicts but generally, the maximum number of queries for a client request is one query per client-qualified pool rather than one query * the total number of addresses in the pools.
The SLFQ data tracks the last address picked for each SFLQ pool such that consecutive queries for the same pool will return a different free address. This should minimize conflicts with other servers until the number of free addresses approaches zero.
This allocator should only be used for reasonably small pools due to the overhead to populate the free leases. A reasonably small pool is an IPv4 pool (including /8) and the prefix delegation pools with similar capacity. This allocator is not suitable for a typical IPv6 address pool (e.g., /64). An attempt to populate free leases for such a giant pool would freeze the server and likely exhaust the database server's storage.
As opposed to FLQ, free leases are populated in sequential order.
Definition at line 48 of file sflq_allocator.h.
| isc::dhcp::SharedFlqAllocator::SharedFlqAllocator | ( | Lease::Type | type, |
| const WeakSubnetPtr & | subnet ) |
Constructor.
| type | specifies the type of allocated leases. |
| subnet | weak pointer to the subnet owning the allocator. |
Definition at line 41 of file sflq_allocator.cc.
References isc::dhcp::Allocator::Allocator().
| SubnetSflqAllocationStatePtr isc::dhcp::SharedFlqAllocator::getSubnetState | ( | ) | const |
Returns the allocation state for the subnet pool_type;.
Definition at line 215 of file sflq_allocator.cc.
References isc_throw, isc::dhcp::Allocator::pool_type_, isc::dhcp::Allocator::subnet_, and isc::dhcp::Lease::TYPE_V4.
|
inlinevirtual |
Returns the allocator type string.
Implements isc::dhcp::Allocator.
Definition at line 60 of file sflq_allocator.h.
|
static |
Returns the global in-use flag.
Definition at line 37 of file sflq_allocator.cc.
References isc::sflq_in_use_.
Referenced by isc::dhcp::LeaseMgr::useSharedFlqStatement(), and isc::dhcp::LeaseMgr::useSharedFlqStatement().
|
static |
Sanity checks the subnet and pool configuration for use with SFLQ.
| subnet | Subnet to check |
| BadValue | if the capacity exceeds limit. |
Definition at line 233 of file sflq_allocator.cc.
References isc_throw, MAX_V4_POOL_SIZE, and isc::dhcp::Lease::TYPE_V4.
Referenced by isc::dhcp::SrvConfig::sanityChecksSflqAllocator().
|
static |
Sanity checks the subnet and pool configuration for use with SFLQ.
| subnet | Subnet to check |
| BadValue | if the capacity exceeds limit. |
Definition at line 246 of file sflq_allocator.cc.
References isc_throw, MAX_V6_POOL_SIZE, isc::dhcp::Lease::TYPE_NA, and isc::dhcp::Lease::TYPE_PD.
Referenced by isc::dhcp::SrvConfig::sanityChecksSflqAllocator().
|
static |
Sets the global in-use flag.
| in_use | new value to assign to the in-use flag. |
Definition at line 32 of file sflq_allocator.cc.
References isc::sflq_in_use_.
Referenced by isc::dhcp::CfgSubnets4::initAllocatorsAfterConfigure(), and isc::dhcp::CfgSubnets6::initAllocatorsAfterConfigure().
|
staticconstexpr |
Maximum capacity of a V4 pool supported by SFLQ.
Definition at line 97 of file sflq_allocator.h.
Referenced by sanityChecksSflqAllocator4().
|
staticconstexpr |
Maximum capacity of a V6 pool supported by SFLQ.
Definition at line 100 of file sflq_allocator.h.
Referenced by sanityChecksSflqAllocator6().