]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4441] Fix mysql loop limit error
authorThomas Markwalder <tmark@isc.org>
Tue, 14 Apr 2026 11:27:32 +0000 (07:27 -0400)
committerThomas Markwalder <tmark@isc.org>
Fri, 17 Apr 2026 17:21:44 +0000 (17:21 +0000)
Also whitespace clean up

modified:   src/bin/admin/tests/mysql_tests.sh.in
modified:   src/hooks/dhcp/mysql/mysql_lease_mgr.cc
modified:   src/hooks/dhcp/mysql/tests/mysql_lease_mgr_unittest.cc
modified:   src/lib/dhcpsrv/sflq_allocation_state.h
modified:   src/lib/dhcpsrv/testutils/generic_lease_mgr_unittest.cc
modified:   src/share/database/scripts/mysql/dhcpdb_create.mysql
modified:   src/share/database/scripts/mysql/upgrade_033_to_034.sh.in

src/bin/admin/tests/mysql_tests.sh.in
src/hooks/dhcp/mysql/mysql_lease_mgr.cc
src/hooks/dhcp/mysql/tests/mysql_lease_mgr_unittest.cc
src/lib/dhcpsrv/sflq_allocation_state.h
src/lib/dhcpsrv/testutils/generic_lease_mgr_unittest.cc
src/share/database/scripts/mysql/dhcpdb_create.mysql
src/share/database/scripts/mysql/upgrade_033_to_034.sh.in

index 8eba6fd9ce34fcf748295f943ce8beefd9ddf2d0..d06dc2620a211ceb7c079ac419006aa85c21cc51 100755 (executable)
@@ -4134,6 +4134,16 @@ mysql_sflqCreateFlqPool4() {
           '127.0.0.6','127.0.0.7','127.0.0.8')"
     run_statement "select free_leases4" "$sql" "7"
 
+    # Create pool large enough to test recursion limit.
+    start_address="inet_aton('10.100.0.0')"
+    end_address="inet_aton('10.100.255.255')"
+    sql="call sflqCreateFlqPool4($start_address, $end_address, 1, false)"
+    run_statement "sflqCreateFlqPool4" "$sql"
+
+    sql="select count(address) from free_lease4 where address >= $start_address and\
+        address <= $end_address"
+    run_statement "sflqCreateFlqPool4" "$sql" "65536"
+
     # Let's wipe the whole database
     mysql_wipe
 
index 054087b6c6adbf44112c5f9706a284ae5aa1bc6b..bd7cb7bb0ffb3080d04b395506eaf77966a1451f 100644 (file)
@@ -4930,7 +4930,7 @@ MySqlLeaseMgr::sflqCreateFlqPool4(IOAddress start_address, IOAddress end_address
     /// @todo 16M? this is arbitrary number for now.
     if (capacity > 16777216 ) {
         isc_throw(BadValue, "MySqlLeasMgr::sflqCreateFlqPool4 "
-                            "- pool capcity " << capacity << " is too large" 
+                            "- pool capcity " << capacity << " is too large"
                             " for shared-flq allocator");
     }
 
@@ -5054,7 +5054,7 @@ MySqlLeaseMgr::sflqCreateFlqPool6(IOAddress start_address, IOAddress end_address
     // @todo 16M? this is arbitrary number for now.
     if (capacity > 16777216 ) {
         isc_throw(BadValue, "MySqlLeasMgr::sflqCreateFlqPool6 "
-                            "- pool capcity " << capacity << " is too large" 
+                            "- pool capcity " << capacity << " is too large"
                             " for shared-flq allocator");
     }
 
index ffbd3d198d917823b357883e64824c979775d4c8..7edfa5e83e0e76d2168cab0d40068094eaf1acfd 100644 (file)
@@ -1418,43 +1418,43 @@ TEST_F(MySqlLeaseMgrTest, bigStats) {
     testBigStats();
 }
 
-TEST_F(MySqlLeaseMgrTest, updateStatsOn4SameSubnet) { 
+TEST_F(MySqlLeaseMgrTest, updateStatsOn4SameSubnet) {
     testUpdateStatsOn4SameSubnet();
 }
 
-TEST_F(MySqlLeaseMgrTest, updateStatsOn4DifferentSubnet) { 
+TEST_F(MySqlLeaseMgrTest, updateStatsOn4DifferentSubnet) {
     testUpdateStatsOn4DifferentSubnet();
 }
 
-TEST_F(MySqlLeaseMgrTest, updateStatsOn6SameSubnet) { 
+TEST_F(MySqlLeaseMgrTest, updateStatsOn6SameSubnet) {
     testUpdateStatsOn6SameSubnet();
 }
 
-TEST_F(MySqlLeaseMgrTest, updateStatsOn6SameSubnetPD) { 
+TEST_F(MySqlLeaseMgrTest, updateStatsOn6SameSubnetPD) {
     testUpdateStatsOn6SameSubnetPD();
 }
 
-TEST_F(MySqlLeaseMgrTest, updateStatsOn6DifferentSubnet) { 
+TEST_F(MySqlLeaseMgrTest, updateStatsOn6DifferentSubnet) {
     testUpdateStatsOn6DifferentSubnet();
 }
 
-TEST_F(MySqlLeaseMgrTest, updateStatsOn6DifferentSubnetPD) { 
+TEST_F(MySqlLeaseMgrTest, updateStatsOn6DifferentSubnetPD) {
     testUpdateStatsOn6DifferentSubnetPD();
 }
 
-TEST_F(MySqlLeaseMgrTest, testSflqCreateAndPick4) { 
+TEST_F(MySqlLeaseMgrTest, testSflqCreateAndPick4) {
     testSflqCreateAndPick4();
 }
 
-TEST_F(MySqlLeaseMgrTest, testSflqLeaseOps4) { 
+TEST_F(MySqlLeaseMgrTest, testSflqLeaseOps4) {
     testSflqLeaseOps4();
 }
 
-TEST_F(MySqlLeaseMgrTest, testSflqCreateAndPick6) { 
+TEST_F(MySqlLeaseMgrTest, testSflqCreateAndPick6) {
     testSflqCreateAndPick6();
 }
 
-TEST_F(MySqlLeaseMgrTest, testSflqLeaseOps6) { 
+TEST_F(MySqlLeaseMgrTest, testSflqLeaseOps6) {
     testSflqLeaseOps6();
 }
 
index 7529ddd2f928a40c16a04b2276248ffd629dfc65..5db5aa6edf16c5f20496dc52309be160034961ab 100644 (file)
@@ -27,7 +27,7 @@ typedef boost::shared_ptr<SubnetSflqAllocationState> SubnetSflqAllocationStatePt
 /// @brief Subnet allocation state used by the shared-flq allocator.
 ///
 /// It exposes the base class mechanism to store the last allocation time
-/// for various lease types. These times are used by the shared networks to 
+/// for various lease types. These times are used by the shared networks to
 /// find the "preferred" subnet (i.e., a subnet from which the latest lease
 /// was assigned).
 class SubnetSflqAllocationState : public SubnetAllocationState {
@@ -43,7 +43,7 @@ public:
     ///
     /// @param last_time time of last allocation. If not specified
     /// it is set to the current time.
-    void setLastAllocatedTime(boost::posix_time::ptime last_time = 
+    void setLastAllocatedTime(boost::posix_time::ptime last_time =
                               boost::posix_time::not_a_date_time);
 };
 
index 9da3fbf2e8b0d923ab92740db60ff616b6fa2908..9156d5df7bc36bcab678550c61d748c3df117d48 100644 (file)
@@ -5833,28 +5833,28 @@ GenericLeaseMgrTest::testSflqLeaseOps4() {
 
     std::list<Scenario> scenarios = {
         // Add the lease
-        {__LINE__, ADD, Lease::STATE_DEFAULT, 
+        {__LINE__, ADD, Lease::STATE_DEFAULT,
          !expired, should_exist, !can_pick },
 
         // Update to declined state.
-        {__LINE__, UPDATE, Lease::STATE_DECLINED, 
+        {__LINE__, UPDATE, Lease::STATE_DECLINED,
          !expired, should_exist, !can_pick },
 
-        // Delete the lease. 
-        {__LINE__, DELETE, Lease::STATE_DEFAULT, 
+        // Delete the lease.
+        {__LINE__, DELETE, Lease::STATE_DEFAULT,
          !expired, !should_exist, can_pick },
 #if 0
-        // @todo This hinges on #4447 
-        // Add an expired lease. 
-        {__LINE__, ADD, Lease::STATE_DEFAULT, 
+        // @todo This hinges on #4447
+        // Add an expired lease.
+        {__LINE__, ADD, Lease::STATE_DEFAULT,
          !expired, should_exist, can_pick },
 #endif
         // Add a reclaimed lease.
-        {__LINE__, ADD, Lease::STATE_EXPIRED_RECLAIMED, 
+        {__LINE__, ADD, Lease::STATE_EXPIRED_RECLAIMED,
          !expired, should_exist, can_pick },
 
         // Update to default.
-        {__LINE__, UPDATE, Lease::STATE_DEFAULT, 
+        {__LINE__, UPDATE, Lease::STATE_DEFAULT,
          !expired, should_exist, !can_pick },
 
         // Update to reclaimed.
@@ -5870,9 +5870,9 @@ GenericLeaseMgrTest::testSflqLeaseOps4() {
         SCOPED_TRACE(os.str());
 
         // Prep the input lease.
-        preop_lease->state_ = scenario.state_;  
+        preop_lease->state_ = scenario.state_;
         time_t current_time = time(NULL);
-        preop_lease->cltt_ = (scenario.expired_ ? 
+        preop_lease->cltt_ = (scenario.expired_ ?
                               current_time - 1000 : current_time + 1000);
 
         // Carry out the lease operation.
@@ -6001,28 +6001,28 @@ GenericLeaseMgrTest::testSflqLeaseOps6() {
 
     std::list<Scenario> scenarios = {
         // Add the lease
-        {__LINE__, ADD, Lease::STATE_DEFAULT, 
+        {__LINE__, ADD, Lease::STATE_DEFAULT,
          !expired, should_exist, !can_pick },
 
         // Update to declined state.
-        {__LINE__, UPDATE, Lease::STATE_DECLINED, 
+        {__LINE__, UPDATE, Lease::STATE_DECLINED,
          !expired, should_exist, !can_pick },
 
-        // Delete the lease. 
-        {__LINE__, DELETE, Lease::STATE_DEFAULT, 
+        // Delete the lease.
+        {__LINE__, DELETE, Lease::STATE_DEFAULT,
          !expired, !should_exist, can_pick },
 #if 0
-        // @todo This hinges on #4447 
-        // Add an expired lease. 
-        {__LINE__, ADD, Lease::STATE_DEFAULT, 
+        // @todo This hinges on #4447
+        // Add an expired lease.
+        {__LINE__, ADD, Lease::STATE_DEFAULT,
          !expired, should_exist, can_pick },
 #endif
         // Add a reclaimed lease.
-        {__LINE__, ADD, Lease::STATE_EXPIRED_RECLAIMED, 
+        {__LINE__, ADD, Lease::STATE_EXPIRED_RECLAIMED,
          !expired, should_exist, can_pick },
 
         // Update to default.
-        {__LINE__, UPDATE, Lease::STATE_DEFAULT, 
+        {__LINE__, UPDATE, Lease::STATE_DEFAULT,
          !expired, should_exist, !can_pick },
 
         // Update to reclaimed.
@@ -6038,9 +6038,9 @@ GenericLeaseMgrTest::testSflqLeaseOps6() {
         SCOPED_TRACE(os.str());
 
         // Prep the input lease.
-        preop_lease->state_ = scenario.state_;  
+        preop_lease->state_ = scenario.state_;
         time_t current_time = time(NULL);
-        preop_lease->cltt_ = (scenario.expired_ ? 
+        preop_lease->cltt_ = (scenario.expired_ ?
                               current_time - 1000 : current_time + 1000);
 
         // Carry out the lease operation.
index 299a40e8b2b5541f6182c5d047594cbfeaa56c73..2a5365bfb76b32fa500e6079e018179b76959944 100644 (file)
@@ -6781,7 +6781,7 @@ BEGIN
     -- duplicate ignore it. MySql limits recursive queries so we iterate
     -- pool address range in chunks.
     CALL setLoopLimit();
-    SET loop_limit = @kea_recursion_limit;
+    SET loop_limit = @kea_recursion_limit - 1;
     SET next_start_address = p_start_address;
     SET next_end_address = p_start_address;
     start_loop: WHILE next_start_address <= p_end_address DO
index 5c9f41a6eeca60330d3af7ee26893b3cf9226e5c..326febe92e5d1c04d9f41234f3428f5095e578a9 100755 (executable)
@@ -361,7 +361,7 @@ BEGIN
     -- duplicate ignore it. MySql limits recursive queries so we iterate
     -- pool address range in chunks.
     CALL setLoopLimit();
-    SET loop_limit = @kea_recursion_limit;
+    SET loop_limit = @kea_recursion_limit - 1;
     SET next_start_address = p_start_address;
     SET next_end_address = p_start_address;
     start_loop: WHILE next_start_address <= p_end_address DO