]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4176] Initial review comments
authorThomas Markwalder <tmark@isc.org>
Tue, 16 Dec 2025 15:47:45 +0000 (10:47 -0500)
committerThomas Markwalder <tmark@isc.org>
Fri, 19 Dec 2025 14:03:38 +0000 (14:03 +0000)
modified:   src/hooks/dhcp/lease_cmds/lease_cmds.cc
modified:   src/hooks/dhcp/lease_cmds/libloadtests/lease_cmds6_unittest.cc
modified:   src/lib/dhcpsrv/lease_mgr.cc
modified:   src/lib/dhcpsrv/lease_mgr.h

src/hooks/dhcp/lease_cmds/lease_cmds.cc
src/hooks/dhcp/lease_cmds/libloadtests/lease_cmds6_unittest.cc
src/lib/dhcpsrv/lease_mgr.cc
src/lib/dhcpsrv/lease_mgr.h

index ab9efddc9f97d2068e5b96d3b0745a6c49883850..12bae7b089dbca50860c16747b501905a607c430 100644 (file)
@@ -576,7 +576,6 @@ LeaseCmdsImpl::addOrUpdate6(Lease6Ptr lease, bool force_create) {
                   "retry might succeed");
     }
 
-    std::cout << "TKM, OK we're here" << std::endl;
     LeaseMgr::updateStatsOnUpdate(existing, lease);
     return (false);
 }
index 61fdbe097db2092dbd619a72c842a4d7312ff7e1..5919790f92391cd2160ff47304be21f1d6e8c008 100644 (file)
@@ -2368,10 +2368,10 @@ void Lease6CmdsTest::testLease6GetByStateFind2() {
     // Let's check if the response makes any sense.
     ConstElementPtr lease = leases->get(0);
     ASSERT_TRUE(lease);
-    checkLease6(lease, "2001:db8:1::1", 0, 66, "42:42:42:42:42:42:42:42");
+    checkLease6(__LINE__, lease, "2001:db8:1::1", 0, 66, "42:42:42:42:42:42:42:42");
     lease = leases->get(2);
     ASSERT_TRUE(lease);
-    checkLease6(lease, "2001:db8:2::1", 0, 99, "42:42:42:42:42:42:42:42");
+    checkLease6(__LINE__, lease, "2001:db8:2::1", 0, 99, "42:42:42:42:42:42:42:42");
 }
 
 void Lease6CmdsTest::testLease6GetByStateFindN() {
index a66e56a4d852a27271217d693e86b95f3ad8e430..26de00a7d0594e27d7de0cba9e291b2a819e55f9 100644 (file)
@@ -1412,15 +1412,8 @@ LeaseMgr::updateStatsOnAdd(const Lease6Ptr& lease) {
     }
 }
 
-/// @brief Helper function that adds a value to an address stat's global,
-/// subnet, and pool level values.
-///
-/// @param stat base name of the statistic e.g. "assigned-addresses", "assigned-nas"
-/// @param subnet_id id of desired subnet
-/// @param pool pointer to the pool (if one) within the subnet, if empty
-/// pool level is skipped.
-/// @param value signed value to add to the statistic
-void bumpStat(const std::string& stat, SubnetID& subnet_id, PoolPtr pool, int value) {
+void 
+LeaseMgr::bumpStat(const std::string& stat, SubnetID& subnet_id, PoolPtr pool, int value) {
     StatsMgr::instance().addValue(stat, static_cast<int64_t>(value));
     StatsMgr::instance().addValue(StatsMgr::generateName("subnet", subnet_id, stat),
                                   static_cast<int64_t>(value));
@@ -1431,21 +1424,14 @@ void bumpStat(const std::string& stat, SubnetID& subnet_id, PoolPtr pool, int va
     }
 }
 
-/// @brief Helper function that adds a value to a PD stat's global,
-/// subnet, and pool level values.
-///
-/// @param stat base name of the statistic e.g. "assigned-pds"
-/// @param subnet_id id of desired subnet
-/// @param pool pointer to the pool (if one) within the subnet, if empty
-/// pool level is skipped.
-/// @param value signed value to add to the statistic
-void bumpStatPDPool(const std::string& stat, SubnetID& subnet_id, PoolPtr pool, int value) {
+void 
+LeaseMgr::bumpStatPrefixPool(const std::string& stat, SubnetID& subnet_id, PoolPtr pool, int value) {
     StatsMgr::instance().addValue(stat, static_cast<int64_t>(value));
     StatsMgr::instance().addValue(StatsMgr::generateName("subnet", subnet_id, stat),
                                   static_cast<int64_t>(value));
     if (pool) {
         StatsMgr::instance().addValue(StatsMgr::generateName("subnet", subnet_id,
-                                       StatsMgr::generateName("pd-pool", pool->getID(), stat)),
+                                      StatsMgr::generateName("pd-pool", pool->getID(), stat)),
                                       static_cast<int64_t>(value));
     }
 }
@@ -1682,7 +1668,7 @@ LeaseMgr::updateStatsOnUpdate(const Lease6Ptr& existing,
             if (existing->type_ == Lease::TYPE_NA) {
                 bumpStat("assigned-nas", existing->subnet_id_, pool, 1);
             } else {
-                bumpStatPDPool("assigned-pds", existing->subnet_id_, pool, 1);
+                bumpStatPrefixPool("assigned-pds", existing->subnet_id_, pool, 1);
             }
             break;
 
@@ -1711,7 +1697,7 @@ LeaseMgr::updateStatsOnUpdate(const Lease6Ptr& existing,
             if (existing->type_ == Lease::TYPE_NA) {
                 bumpStat("assigned-nas", existing->subnet_id_, pool, -1);
             } else {
-                bumpStatPDPool("assigned-pds", existing->subnet_id_, pool, -1);
+                bumpStatPrefixPool("assigned-pds", existing->subnet_id_, pool, -1);
             }
             break;
 
@@ -1774,8 +1760,8 @@ LeaseMgr::updateStatsOnUpdate(const Lease6Ptr& existing,
             bumpStat("assigned-nas", existing->subnet_id_, existing_pool, -1);
             bumpStat("assigned-nas", lease->subnet_id_, new_pool, 1);
         } else {
-            bumpStatPDPool("assigned-pds", existing->subnet_id_, existing_pool, -1);
-            bumpStatPDPool("assigned-pds", lease->subnet_id_, new_pool, 1);
+            bumpStatPrefixPool("assigned-pds", existing->subnet_id_, existing_pool, -1);
+            bumpStatPrefixPool("assigned-pds", lease->subnet_id_, new_pool, 1);
         }
         break;
 
@@ -1790,7 +1776,7 @@ LeaseMgr::updateStatsOnUpdate(const Lease6Ptr& existing,
         if (lease->type_ == Lease::TYPE_NA) {
             bumpStat("assigned-nas", lease->subnet_id_, new_pool, 1);
         } else {
-            bumpStatPDPool("assigned-pds", lease->subnet_id_, new_pool, 1);
+            bumpStatPrefixPool("assigned-pds", lease->subnet_id_, new_pool, 1);
         }
         break;
 
@@ -1829,7 +1815,7 @@ LeaseMgr::updateStatsOnUpdate(const Lease6Ptr& existing,
         if (lease->type_ == Lease::TYPE_NA) {
             bumpStat("assigned-nas", existing->subnet_id_, existing_pool, -1);
         } else {
-            bumpStatPDPool("assigned-pds", existing->subnet_id_, existing_pool, -1);
+            bumpStatPrefixPool("assigned-pds", existing->subnet_id_, existing_pool, -1);
         }
         break;
 
index 720b6144522de2839fc2cb8d4b2728ec9930ec03..d7a55e220e371b38f4950ae68dd22b8bc6eb47cd 100644 (file)
@@ -1132,6 +1132,27 @@ public:
     /// @param lease Deleted lease.
     static void updateStatsOnDelete(const Lease6Ptr& lease);
 
+    /// @brief Helper function that adds a value to an address stat's global,
+    /// subnet, and pool level values.
+    ///
+    /// @param stat base name of the statistic e.g. "assigned-addresses", "assigned-nas"
+    /// @param subnet_id id of desired subnet
+    /// @param pool pointer to the pool (if one) within the subnet, if empty
+    /// pool level is skipped.
+    /// @param value signed value to add to the statistic
+    static void bumpStat(const std::string& stat, SubnetID& subnet_id,
+                         PoolPtr pool, int value);
+
+    /// @brief Helper function that adds a value to a prefix stat's global,
+    /// subnet, and pool level values.
+    ///
+    /// @param stat base name of the statistic e.g. "assigned-pds"
+    /// @param subnet_id id of desired subnet
+    /// @param pool pointer to the pool (if one) within the subnet, if empty
+    /// pool level is skipped.
+    /// @param value signed value to add to the statistic
+    static void bumpStatPrefixPool(const std::string& stat, SubnetID&
+                                   subnet_id, PoolPtr pool, int value);
 protected:
 
     /// Extended information / Bulk Lease Query shared interface.