Browse Source

Merge branch 'trac3997'

Thomas Markwalder 9 years ago
parent
commit
ce91bdd78f

+ 6 - 0
src/bin/dhcp4/dhcp4_messages.mes

@@ -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
 has failed.  As a result, the server will exit.  The reason for the
 failure is given within the message.
 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
 % DHCP4_STARTED Kea DHCPv4 server version %1 started
 This informational message indicates that the DHCPv4 server has
 This informational message indicates that the DHCPv4 server has
 processed all configuration information and is ready to process
 processed all configuration information and is ready to process

+ 16 - 0
src/bin/dhcp4/dhcp4_srv.cc

@@ -263,6 +263,13 @@ Dhcpv4Srv::Dhcpv4Srv(uint16_t port, const bool use_bcast,
 }
 }
 
 
 Dhcpv4Srv::~Dhcpv4Srv() {
 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();
     IfaceMgr::instance().closeSockets();
 }
 }
 
 
@@ -2259,6 +2266,15 @@ Dhcpv4Srv::startD2() {
 }
 }
 
 
 void
 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
 Dhcpv4Srv::d2ClientErrorHandler(const
                                 dhcp_ddns::NameChangeSender::Result result,
                                 dhcp_ddns::NameChangeSender::Result result,
                                 dhcp_ddns::NameChangeRequestPtr& ncr) {
                                 dhcp_ddns::NameChangeRequestPtr& ncr) {

+ 9 - 2
src/bin/dhcp4/dhcp4_srv.h

@@ -234,11 +234,18 @@ public:
 
 
     /// @brief Starts DHCP_DDNS client IO if DDNS updates are enabled.
     /// @brief Starts DHCP_DDNS client IO if DDNS updates are enabled.
     ///
     ///
-    /// If updates are enabled, it Instructs the D2ClientMgr singleton to
+    /// If updates are enabled, it instructs the D2ClientMgr singleton to
     /// enter send mode.  If D2ClientMgr encounters errors it may throw
     /// enter send mode.  If D2ClientMgr encounters errors it may throw
-    /// D2ClientErrors. This method does not catch exceptions.
+    /// D2ClientError. This method does not catch exceptions.
     void startD2();
     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
+    /// D2ClientError. This method does not catch exceptions.
+    void stopD2();
+
     /// @brief Implements the error handler for DHCP_DDNS IO errors
     /// @brief Implements the error handler for DHCP_DDNS IO errors
     ///
     ///
     /// Invoked when a NameChangeRequest send to kea-dhcp-ddns completes with
     /// Invoked when a NameChangeRequest send to kea-dhcp-ddns completes with

+ 5 - 1
src/bin/dhcp4/tests/dhcp4_process_tests.sh.in

@@ -37,7 +37,11 @@ CONFIG="{
         {
         {
             \"subnet\": \"10.0.0.0/8\",
             \"subnet\": \"10.0.0.0/8\",
             \"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ]
             \"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ]
-        } ]
+        } ],
+       \"dhcp-ddns\": {
+            \"enable-updates\": true,
+            \"qualifying-suffix\": \"\"
+        }
     },
     },
 
 
     \"Logging\":
     \"Logging\":

+ 6 - 0
src/bin/dhcp6/dhcp6_messages.mes

@@ -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
 has failed.  As a result, the server will exit.  The reason for the
 failure is given within the message.
 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
 % DHCP6_STANDALONE skipping message queue, running standalone
 This is a debug message indicating that the IPv6 server is running in
 This is a debug message indicating that the IPv6 server is running in
 standalone mode, not connected to the message queue.  Standalone mode
 standalone mode, not connected to the message queue.  Standalone mode

+ 16 - 0
src/bin/dhcp6/dhcp6_srv.cc

@@ -229,6 +229,13 @@ Dhcpv6Srv::Dhcpv6Srv(uint16_t port)
 }
 }
 
 
 Dhcpv6Srv::~Dhcpv6Srv() {
 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();
     IfaceMgr::instance().closeSockets();
 
 
     LeaseMgrFactory::destroy();
     LeaseMgrFactory::destroy();
@@ -2873,6 +2880,15 @@ Dhcpv6Srv::startD2() {
 }
 }
 
 
 void
 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
 Dhcpv6Srv::d2ClientErrorHandler(const
                                 dhcp_ddns::NameChangeSender::Result result,
                                 dhcp_ddns::NameChangeSender::Result result,
                                 dhcp_ddns::NameChangeRequestPtr& ncr) {
                                 dhcp_ddns::NameChangeRequestPtr& ncr) {

+ 9 - 2
src/bin/dhcp6/dhcp6_srv.h

@@ -119,11 +119,18 @@ public:
 
 
     /// @brief Starts DHCP_DDNS client IO if DDNS updates are enabled.
     /// @brief Starts DHCP_DDNS client IO if DDNS updates are enabled.
     ///
     ///
-    /// If updates are enabled, it Instructs the D2ClientMgr singleton to
+    /// If updates are enabled, it instructs the D2ClientMgr singleton to
     /// enter send mode.  If D2ClientMgr encounters errors it may throw
     /// enter send mode.  If D2ClientMgr encounters errors it may throw
-    /// D2ClientErrors. This method does not catch exceptions.
+    /// D2ClientError. This method does not catch exceptions.
     void startD2();
     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
+    /// D2ClientError. This method does not catch exceptions.
+    void stopD2();
+
     /// @brief Implements the error handler for DHCP_DDNS IO errors
     /// @brief Implements the error handler for DHCP_DDNS IO errors
     ///
     ///
     /// Invoked when a NameChangeRequest send to kea-dhcp-ddns completes with
     /// Invoked when a NameChangeRequest send to kea-dhcp-ddns completes with

+ 5 - 1
src/bin/dhcp6/tests/dhcp6_process_tests.sh.in

@@ -37,7 +37,11 @@ CONFIG="{
         {
         {
             \"subnet\": \"2001:db8:1::/64\",
             \"subnet\": \"2001:db8:1::/64\",
             \"pools\": [ { \"pool\": \"2001:db8:1::10-2001:db8:1::100\" } ]
             \"pools\": [ { \"pool\": \"2001:db8:1::10-2001:db8:1::100\" } ]
-        } ]
+        } ],
+        \"dhcp-ddns\": {
+            \"enable-updates\": true,
+            \"qualifying-suffix\": \"\"
+        }
     },
     },
 
 
     \"Logging\":
     \"Logging\":