]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1621] fixed disable network state for connections
authorRazvan Becheriu <razvan@isc.org>
Thu, 4 Mar 2021 06:40:31 +0000 (08:40 +0200)
committerRazvan Becheriu <razvan@isc.org>
Mon, 29 Mar 2021 18:10:52 +0000 (21:10 +0300)
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp6/ctrl_dhcp6_srv.cc

index 1f99921633d8df83eaae9be9e7a9c11a5092fdf5..77519831db78250c536061415433dcd993ccf305 100644 (file)
@@ -1236,17 +1236,19 @@ ControlledDhcpv4Srv::deleteExpiredReclaimedLeases(const uint32_t secs) {
 
 bool
 ControlledDhcpv4Srv::dbLostCallback(ReconnectCtlPtr db_reconnect_ctl) {
-    // Disable service until the connection is recovered.
-    network_state_->disableService(NetworkState::Origin::DB_CONNECTION);
-
-    LOG_INFO(dhcp4_logger, DHCP4_DB_RECONNECT_LOST_CONNECTION);
-
     if (!db_reconnect_ctl) {
         // This should never happen
         LOG_ERROR(dhcp4_logger, DHCP4_DB_RECONNECT_NO_DB_CTL);
         return (false);
     }
 
+    // Disable service until the connection is recovered.
+    if (db_reconnect_ctl->retriesLeft() == db_reconnect_ctl->maxRetries()) {
+        network_state_->disableService(NetworkState::Origin::DB_CONNECTION);
+    }
+
+    LOG_INFO(dhcp4_logger, DHCP4_DB_RECONNECT_LOST_CONNECTION);
+
     // If reconnect isn't enabled log it, initiate a shutdown and return false.
     if (!db_reconnect_ctl->retriesLeft() ||
         !db_reconnect_ctl->retryInterval()) {
index 1afbbc63e38c4e58cbfee88718f4b6b9b4d22351..15bf8f3c356d75172afba398869632731c7b4f53 100644 (file)
@@ -1255,17 +1255,19 @@ ControlledDhcpv6Srv::deleteExpiredReclaimedLeases(const uint32_t secs) {
 
 bool
 ControlledDhcpv6Srv::dbLostCallback(ReconnectCtlPtr db_reconnect_ctl) {
-    // Disable service until the connection is recovered.
-    network_state_->disableService(NetworkState::Origin::DB_CONNECTION);
-
-    LOG_INFO(dhcp6_logger, DHCP6_DB_RECONNECT_LOST_CONNECTION);
-
     if (!db_reconnect_ctl) {
         // This should never happen
         LOG_ERROR(dhcp6_logger, DHCP6_DB_RECONNECT_NO_DB_CTL);
         return (false);
     }
 
+    // Disable service until the connection is recovered.
+    if (db_reconnect_ctl->retriesLeft() == db_reconnect_ctl->maxRetries()) {
+        network_state_->disableService(NetworkState::Origin::DB_CONNECTION);
+    }
+
+    LOG_INFO(dhcp6_logger, DHCP6_DB_RECONNECT_LOST_CONNECTION);
+
     // If reconnect isn't enabled log it, initiate a shutdown and return false.
     if (!db_reconnect_ctl->retriesLeft() ||
         !db_reconnect_ctl->retryInterval()) {