]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2893] lease commands hook library parse pool-id Kea-2.3.8
authorRazvan Becheriu <razvan@isc.org>
Mon, 29 May 2023 16:57:19 +0000 (19:57 +0300)
committerRazvan Becheriu <razvan@isc.org>
Mon, 29 May 2023 19:46:17 +0000 (22:46 +0300)
src/hooks/dhcp/lease_cmds/lease_parser.cc
src/lib/dhcpsrv/flq_allocator.cc

index 9cef198af2696c5fb5ce676e2f831310d54ca22e..2871c1cd94fb43c766d5bce793f228490a672e1d 100644 (file)
@@ -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) {
index 682df3265df896f902e6ddbe8c9dea0c40149089..e361c3b906b405f47ea4e4a17395c9976a78c985 100644 (file)
@@ -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;