]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3997] Corrected DHCP4 server crash on exit when DDNS is enabled
authorThomas Markwalder <tmark@isc.org>
Wed, 12 Aug 2015 19:50:47 +0000 (15:50 -0400)
committerThomas Markwalder <tmark@isc.org>
Wed, 12 Aug 2015 19:50:47 +0000 (15:50 -0400)
Rather that stopping it explicitly, the server was relying D2ClientMgr
to stop itself during its own destruction.  This was falling over during
process wind-down because the IfaceMgr singletone was being destroyed before
the D2ClientMgr instance.
The server destructor now explicitly stops the D2ClientMgr.

src/bin/dhcp4/dhcp4_messages.mes
    added DHCP4_SRV_D2STOP_ERROR log message

src/bin/dhcp4/dhcp4_srv.cc
    Dhcpv4Srv::stopD2() - new method stops the NCR sender, causing it to
    unregister its WathSocket from IfaceMgr

    Dhcpv4Srv::~Dhcpv4Srv() - added call to Dhcpv4Srv::stopD2()

src/bin/dhcp4/tests/dhcp4_process_tests.sh.in
    Enabled DNS updates in the CONFIG string.  This ensures the D2
    client will be started during system tests

src/bin/dhcp4/dhcp4_messages.mes
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/dhcp4_srv.h
src/bin/dhcp4/tests/dhcp4_process_tests.sh.in

index f8e471bbdb024cfab95ebdde29024cb0b45c1fec..5fd59626250025de619775e21b2a151b70787c6d 100644 (file)
@@ -610,6 +610,12 @@ core component within the DHCPv4 server (the Dhcpv4 server object)
 has failed.  As a result, the server will exit.  The reason for the
 failure is given within the message.
 
+% DHCP4_SRV_D2STOP_ERROR error stopping IO with DHCP_DDNS during shutdown: %1
+This error message indicates that during shutdown, an erro occurred while
+stopping IO between the DHCPv4 server and the DHCP_DDNS server.  This is
+probably due to a programmatic error is not likely to impact either server
+upon restart.  The reason for the failure is given within the message.
+
 % DHCP4_STARTED Kea DHCPv4 server version %1 started
 This informational message indicates that the DHCPv4 server has
 processed all configuration information and is ready to process
index 6ade319bd709f939eb2f85182cd0459469adf771..d9bc01fc52dc249ae6a7a0c350a2a1b8abf6f0fe 100644 (file)
@@ -263,6 +263,12 @@ Dhcpv4Srv::Dhcpv4Srv(uint16_t port, const bool use_bcast,
 }
 
 Dhcpv4Srv::~Dhcpv4Srv() {
+    try {
+        stopD2();
+    } catch(const std::exception& ex) {
+        // Highly unlikely, but lets Report it but go on
+        LOG_ERROR(dhcp4_logger, DHCP4_SRV_D2STOP_ERROR).arg(ex.what());
+    }
     IfaceMgr::instance().closeSockets();
 }
 
@@ -2258,6 +2264,15 @@ Dhcpv4Srv::startD2() {
     }
 }
 
+void
+Dhcpv4Srv::stopD2() {
+    D2ClientMgr& d2_mgr = CfgMgr::instance().getD2ClientMgr();
+    if (d2_mgr.ddnsEnabled()) {
+        // Updates are enabled, so lets stop the sender
+        d2_mgr.stopSender();
+    }
+}
+
 void
 Dhcpv4Srv::d2ClientErrorHandler(const
                                 dhcp_ddns::NameChangeSender::Result result,
index d01c17c4cb3190df34aef4d00e0286e455f1574a..aed155954386e35131e193370231967a34ec7883 100644 (file)
@@ -239,6 +239,13 @@ public:
     /// D2ClientErrors. This method does not catch exceptions.
     void startD2();
 
+    /// @brief Stops DHCP_DDNS client IO if DDNS updates are enabled.
+    ///
+    /// If updates are enabled, it instructs the D2ClientMgr singleton to
+    /// leave send mode.  If D2ClientMgr encounters errors it may throw
+    /// D2ClientErrors. This method does not catch exceptions.
+    void stopD2();
+
     /// @brief Implements the error handler for DHCP_DDNS IO errors
     ///
     /// Invoked when a NameChangeRequest send to kea-dhcp-ddns completes with
index 91bca885389b73541a2728b0e24c852b7b77d036..b799367bdc4a3d66914ca2b78018aa093974b039 100755 (executable)
@@ -37,7 +37,11 @@ CONFIG="{
         {
             \"subnet\": \"10.0.0.0/8\",
             \"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ]
-        } ]
+        } ],
+       \"dhcp-ddns\": {
+            \"enable-updates\": true,
+            \"qualifying-suffix\": \"\"
+        }
     },
 
     \"Logging\":