]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3997] Corrected DHCP6 server crash on exit when DDNS is enabled
authorThomas Markwalder <tmark@isc.org>
Wed, 12 Aug 2015 20:28:55 +0000 (16:28 -0400)
committerThomas Markwalder <tmark@isc.org>
Wed, 12 Aug 2015 20:28:55 +0000 (16:28 -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/dhcp6/dhcp6_messages.mes
    added DHCP6_SRV_D2STOP_ERROR log message

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

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

src/bin/dhcp6/tests/dhcp6_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_srv.cc
src/bin/dhcp6/dhcp6_messages.mes
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/dhcp6_srv.h
src/bin/dhcp6/tests/dhcp6_process_tests.sh.in

index d9bc01fc52dc249ae6a7a0c350a2a1b8abf6f0fe..34559552fa502cfaa9251517ce8585e756c6210b 100644 (file)
@@ -269,6 +269,7 @@ Dhcpv4Srv::~Dhcpv4Srv() {
         // Highly unlikely, but lets Report it but go on
         LOG_ERROR(dhcp4_logger, DHCP4_SRV_D2STOP_ERROR).arg(ex.what());
     }
+
     IfaceMgr::instance().closeSockets();
 }
 
index 5b62bb73bc72118b438ddc26e0fda0c48a93074c..64076fab6cf819104ec44a5149d3cda102860534 100644 (file)
@@ -676,6 +676,12 @@ core component within the IPv6 DHCP server (the Dhcpv6 server object)
 has failed.  As a result, the server will exit.  The reason for the
 failure is given within the message.
 
+% DHCP6_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 DHCPv6 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.
+
 % DHCP6_STANDALONE skipping message queue, running standalone
 This is a debug message indicating that the IPv6 server is running in
 standalone mode, not connected to the message queue.  Standalone mode
index 9f29e9d03ffeebc9ba4cf8d3fd107c7c6d6b83cd..ba14b2196b45d4179d6e4ab7ada66fb3df5233d7 100644 (file)
@@ -229,6 +229,13 @@ Dhcpv6Srv::Dhcpv6Srv(uint16_t port)
 }
 
 Dhcpv6Srv::~Dhcpv6Srv() {
+    try {
+        stopD2();
+    } catch(const std::exception& ex) {
+        // Highly unlikely, but lets Report it but go on
+        LOG_ERROR(dhcp6_logger, DHCP6_SRV_D2STOP_ERROR).arg(ex.what());
+    }
+
     IfaceMgr::instance().closeSockets();
 
     LeaseMgrFactory::destroy();
@@ -2872,6 +2879,15 @@ Dhcpv6Srv::startD2() {
     }
 }
 
+void
+Dhcpv6Srv::stopD2() {
+    D2ClientMgr& d2_mgr = CfgMgr::instance().getD2ClientMgr();
+    if (d2_mgr.ddnsEnabled()) {
+        // Updates are enabled, so lets stop the sender
+        d2_mgr.stopSender();
+    }
+}
+
 void
 Dhcpv6Srv::d2ClientErrorHandler(const
                                 dhcp_ddns::NameChangeSender::Result result,
index 422eff5847a277a3ca31ac3aa0c37870516dc6ad..8705caf2eaee6e93c2a6aacb2126b8cd3282d275 100644 (file)
@@ -124,6 +124,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 e9748b84196383c7cfe68c64075bfd34ee3c105b..62ceda296503176995c48c8356a2ad1d20ad567a 100755 (executable)
@@ -37,7 +37,11 @@ CONFIG="{
         {
             \"subnet\": \"2001:db8:1::/64\",
             \"pools\": [ { \"pool\": \"2001:db8:1::10-2001:db8:1::100\" } ]
-        } ]
+        } ],
+        \"dhcp-ddns\": {
+            \"enable-updates\": true,
+            \"qualifying-suffix\": \"\"
+        }
     },
 
     \"Logging\":