From: Razvan Becheriu Date: Mon, 29 May 2023 16:57:19 +0000 (+0300) Subject: [#2893] lease commands hook library parse pool-id X-Git-Tag: Kea-2.3.8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4ecd49481e578ea8b2250f8ec2d0984611d559a;p=thirdparty%2Fkea.git [#2893] lease commands hook library parse pool-id --- diff --git a/src/hooks/dhcp/lease_cmds/lease_parser.cc b/src/hooks/dhcp/lease_cmds/lease_parser.cc index 9cef198af2..2871c1cd94 100644 --- a/src/hooks/dhcp/lease_cmds/lease_parser.cc +++ b/src/hooks/dhcp/lease_cmds/lease_parser.cc @@ -49,6 +49,12 @@ Lease4Parser::parse(ConstSrvConfigPtr& cfg, if (lease_info->contains("subnet-id")) { subnet_id = getUint32(lease_info, "subnet-id"); } + + uint32_t pool_id = 0; + if (lease_info->contains("pool-id")) { + pool_id = getUint32(lease_info, "pool-id"); + } + ConstSubnet4Ptr subnet; if (subnet_id) { // If subnet-id is specified, it has to match. @@ -170,6 +176,7 @@ Lease4Parser::parse(ConstSrvConfigPtr& cfg, fqdn_fwd, fqdn_rev, hostname)); l->state_ = state; l->setContext(ctx); + l->pool_id_ = pool_id; // Sanitize extended info. if (ctx) { @@ -232,6 +239,11 @@ Lease6Parser::parse(ConstSrvConfigPtr& cfg, subnet_id = getUint32(lease_info, "subnet-id"); } + uint32_t pool_id = 0; + if (lease_info->contains("pool-id")) { + pool_id = getUint32(lease_info, "pool-id"); + } + // Check if the subnet-id specified is sane. ConstSubnet6Ptr subnet; if (subnet_id) { @@ -377,6 +389,7 @@ Lease6Parser::parse(ConstSrvConfigPtr& cfg, l->cltt_ = cltt; l->state_ = state; l->setContext(ctx); + l->pool_id_ = pool_id; // Sanitize extended info. if (ctx) { diff --git a/src/lib/dhcpsrv/flq_allocator.cc b/src/lib/dhcpsrv/flq_allocator.cc index 682df3265d..e361c3b906 100644 --- a/src/lib/dhcpsrv/flq_allocator.cc +++ b/src/lib/dhcpsrv/flq_allocator.cc @@ -39,7 +39,7 @@ FreeLeaseQueueAllocator::pickAddressInternal(const ClientClasses& client_classes const IdentifierBaseTypePtr&, const IOAddress&) { auto subnet = subnet_.lock(); - auto pools = subnet->getPools(pool_type_); + auto const& pools = subnet->getPools(pool_type_); if (pools.empty()) { // No pools, no allocation. return (pool_type_ == Lease::TYPE_V4 ? IOAddress::IPV4_ZERO_ADDRESS() : IOAddress::IPV6_ZERO_ADDRESS()); @@ -86,7 +86,7 @@ FreeLeaseQueueAllocator::pickPrefixInternal(const ClientClasses& client_classes, const IOAddress&, uint8_t hint_prefix_length) { auto subnet = subnet_.lock(); - auto pools = subnet->getPools(pool_type_); + auto const& pools = subnet->getPools(pool_type_); if (pools.empty()) { // No pool, no allocation. return (IOAddress::IPV6_ZERO_ADDRESS()); @@ -137,7 +137,7 @@ FreeLeaseQueueAllocator::pickPrefixInternal(const ClientClasses& client_classes, void FreeLeaseQueueAllocator::initAfterConfigureInternal() { auto subnet = subnet_.lock(); - auto pools = subnet->getPools(pool_type_); + auto const& pools = subnet->getPools(pool_type_); if (pools.empty()) { // If there are no pools there is nothing to do. return;