]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3477] Checkpoint: updating servers
authorFrancis Dupont <fdupont@isc.org>
Mon, 8 Jul 2024 18:13:56 +0000 (20:13 +0200)
committerFrancis Dupont <fdupont@isc.org>
Thu, 1 Aug 2024 07:23:53 +0000 (09:23 +0200)
src/bin/d2/d2_controller.cc
src/bin/d2/d2_process.cc
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/json_config_parser.cc
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/json_config_parser.cc

index 2bfe5083cdf2ef5d704fa1b28422c5a797bb2739..9534d0b9bff26ad16119ed23297ab144ec5f953a 100644 (file)
@@ -7,6 +7,7 @@
 #include <config.h>
 
 #include <config/command_mgr.h>
+#include <config/http_command_mgr.h>
 #include <d2/d2_controller.h>
 #include <d2/d2_process.h>
 #include <d2/parser_context.h>
@@ -103,8 +104,9 @@ D2Controller::registerCommands() {
 void
 D2Controller::deregisterCommands() {
     try {
-        // Close the command socket (if it exists).
+        // Close command sockets.
         CommandMgr::instance().closeCommandSocket();
+        HttpCommandMgr::instance().close();
 
         // Deregister any registered commands (please keep in alphabetic order)
         CommandMgr::instance().deregisterCommand(BUILD_REPORT_COMMAND);
index 75d0704551ab892881f915ee6b0ab01d713ad62d..9e3128887ae90cbaa961b3b60714e05edf77414b 100644 (file)
@@ -9,6 +9,7 @@
 #include <asiolink/io_service_mgr.h>
 #include <cc/command_interpreter.h>
 #include <config/command_mgr.h>
+#include <config/http_command_mgr.h>
 #include <d2/d2_controller.h>
 #include <d2/d2_process.h>
 #include <d2srv/d2_cfg_mgr.h>
@@ -74,8 +75,9 @@ D2Process::D2Process(const char* name, const asiolink::IOServicePtr& io_service)
 
 void
 D2Process::init() {
-    // CommandMgr uses IO service to run asynchronous socket operations.
+    // CommandMgrs use IO service to run asynchronous socket operations.
     isc::config::CommandMgr::instance().setIOService(getIOService());
+    isc::config::HttpCommandMgr::instance().setIOService(getIOService());
 };
 
 void
@@ -152,6 +154,7 @@ D2Process::runIO() {
         // service is stopped it will return immediately with a cnt of zero.
         cnt = getIOService()->runOne();
     }
+    config::HttpCommandMgr::instance().garbageCollectListeners();
     return (cnt);
 }
 
@@ -517,6 +520,13 @@ D2Process::reconfigureCommandChannel() {
 
     // Commit the new socket configuration.
     current_control_socket_ = sock_cfg;
+
+    // HTTP control socket is simpler: just (re)configure it.
+
+    // Get new config.
+    HttpCommandConfigPtr http_config =
+        getD2CfgMgr()->getHttpControlSocketInfo();
+    HttpCommandMgr::instance().configure(http_config);
 }
 
 } // namespace isc::d2
index 198f8ac409147c2ddd85ac73437bbb08f94cf9fa..8090ce58dd48f69531a4b5b9a4489487669ccd69 100644 (file)
@@ -11,6 +11,7 @@
 #include <cc/command_interpreter.h>
 #include <cc/data.h>
 #include <config/command_mgr.h>
+#include <config/http_command_mgr.h>
 #include <cryptolink/crypto_hash.h>
 #include <dhcp/libdhcp++.h>
 #include <dhcp4/ctrl_dhcp4_srv.h>
@@ -1080,8 +1081,9 @@ ControlledDhcpv4Srv::ControlledDhcpv4Srv(uint16_t server_port /*= DHCP4_SERVER_P
     // TimerMgr uses IO service to run asynchronous timers.
     TimerMgr::instance()->setIOService(getIOService());
 
-    // CommandMgr uses IO service to run asynchronous socket operations.
+    // CommandMgr's use IO service to run asynchronous socket operations.
     CommandMgr::instance().setIOService(getIOService());
+    HttpCommandMgr::instance().setIOService(getIOService());
 
     // DatabaseConnection uses IO service to run asynchronous timers.
     DatabaseConnection::setIOService(getIOService());
@@ -1187,8 +1189,9 @@ ControlledDhcpv4Srv::~ControlledDhcpv4Srv() {
 
         cleanup();
 
-        // Close the command socket (if it exists).
+        // Close command sockets.
         CommandMgr::instance().closeCommandSocket();
+        HttpCommandMgr::instance().close();
 
         // Deregister any registered commands (please keep in alphabetic order)
         CommandMgr::instance().deregisterCommand("build-report");
index 88a928d1eb857cacf0543eaa87967416048cd649..43a60bb8a0369a7e60f10bdab264dcd8cb296b05 100644 (file)
@@ -8,6 +8,7 @@
 #include <kea_version.h>
 
 #include <asiolink/io_service_mgr.h>
+#include <config/http_command_mgr.h>
 #include <dhcp/dhcp4.h>
 #include <dhcp/duid.h>
 #include <dhcp/hwaddr.h>
@@ -1142,6 +1143,7 @@ Dhcpv4Srv::run() {
             // Handle events registered by hooks using external IOService objects.
             IOServiceMgr::instance().pollIOServices();
             getIOService()->poll();
+            config::HttpCommandMgr::instance().garbageCollectListeners();
         } catch (const std::exception& e) {
             // General catch-all exception that are not caught by more specific
             // catches. This one is for exceptions derived from std::exception.
index 9b8a22d6d59299c35157082ac9209c37cff3c025..a07ae52f60de5864627b061d704e815f3d89d103 100644 (file)
@@ -9,6 +9,7 @@
 #include <asiolink/io_service_mgr.h>
 #include <cc/command_interpreter.h>
 #include <config/command_mgr.h>
+#include <config/http_command_mgr.h>
 #include <database/dbaccess_parser.h>
 #include <database/backend_selector.h>
 #include <database/server_selector.h>
 #include <netinet/in.h>
 #include <vector>
 
-using namespace std;
-using namespace isc;
+using namespace isc::asiolink;
+using namespace isc::config;
 using namespace isc::data;
 using namespace isc::dhcp;
-using namespace isc::asiolink;
 using namespace isc::hooks;
 using namespace isc::process;
-using namespace isc::config;
 using namespace isc::util;
+using namespace isc;
+using namespace std;
 
 namespace {
 
@@ -309,16 +310,23 @@ void configureCommandChannel() {
     // receive the configuration result.
     if (!sock_cfg || !current_sock_cfg || sock_changed) {
         // Close the existing socket (if any).
-        isc::config::CommandMgr::instance().closeCommandSocket();
+        CommandMgr::instance().closeCommandSocket();
 
         if (sock_cfg) {
             // This will create a control socket and install the external
             // socket in IfaceMgr. That socket will be monitored when
             // Dhcp4Srv::receivePacket() calls IfaceMgr::receive4() and
             // callback in CommandMgr will be called, if necessary.
-            isc::config::CommandMgr::instance().openCommandSocket(sock_cfg);
+            CommandMgr::instance().openCommandSocket(sock_cfg);
         }
     }
+
+    // HTTP control socket is simpler: just (re)configure it.
+
+    // Get new config.
+    HttpCommandConfigPtr http_config =
+        CfgMgr::instance().getStagingCfg()->getHttpControlSocketInfo();
+    HttpCommandMgr::instance().configure(http_config);
 }
 
 /// @brief Process a DHCPv4 confguration and return an answer stating if the
index 511b3c7f013e90c1ab3d80dfafb2ef13740dd763..b581e411dd4380a290edd5c59ac5d6fdeeeca886 100644 (file)
@@ -11,6 +11,7 @@
 #include <cc/command_interpreter.h>
 #include <cc/data.h>
 #include <config/command_mgr.h>
+#include <config/http_command_mgr.h>
 #include <cryptolink/crypto_hash.h>
 #include <dhcp/libdhcp++.h>
 #include <dhcp6/ctrl_dhcp6_srv.h>
@@ -1104,8 +1105,9 @@ ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t server_port /*= DHCP6_SERVER_P
     // TimerMgr uses IO service to run asynchronous timers.
     TimerMgr::instance()->setIOService(getIOService());
 
-    // CommandMgr uses IO service to run asynchronous socket operations.
+    // CommandMgr's use IO service to run asynchronous socket operations.
     CommandMgr::instance().setIOService(getIOService());
+    HttpCommandMgr::instance().setIOService(getIOService());
 
     // DatabaseConnection uses IO service to run asynchronous timers.
     DatabaseConnection::setIOService(getIOService());
@@ -1211,8 +1213,9 @@ ControlledDhcpv6Srv::~ControlledDhcpv6Srv() {
 
         cleanup();
 
-        // Close the command socket (if it exists).
+        // Close command sockets.
         CommandMgr::instance().closeCommandSocket();
+        HttpCommandMgr::instance().close();
 
         // Deregister any registered commands (please keep in alphabetic order)
         CommandMgr::instance().deregisterCommand("build-report");
index 381536ed21c5b2566607fec7e545e46263df8a69..72ec04ee824fc82f412fd173a2401bb49c06c001 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <asiolink/io_address.h>
 #include <asiolink/io_service_mgr.h>
+#include <config/http_command_mgr.h>
 #include <dhcp_ddns/ncr_msg.h>
 #include <dhcp/dhcp6.h>
 #include <dhcp/docsis3_option_defs.h>
@@ -614,6 +615,7 @@ Dhcpv6Srv::run() {
             // Handle events registered by hooks using external IOService objects.
             IOServiceMgr::instance().pollIOServices();
             getIOService()->poll();
+            config::HttpCommandMgr::instance().garbageCollectListeners();
         } catch (const std::exception& e) {
             // General catch-all standard exceptions that are not caught by more
             // specific catches.
index 7eb9c48d16649bd03dc70dc2593e660deecfbbf8..9b05170d4b409fea7a525cd5607d34e1b94d5554 100644 (file)
@@ -11,6 +11,7 @@
 #include <cc/data.h>
 #include <cc/command_interpreter.h>
 #include <config/command_mgr.h>
+#include <config/http_command_mgr.h>
 #include <database/dbaccess_parser.h>
 #include <dhcp6/ctrl_dhcp6_srv.h>
 #include <dhcp6/dhcp6_log.h>
 
 #include <stdint.h>
 
-using namespace std;
-using namespace isc;
+using namespace isc::asiolink;
+using namespace isc::config;
 using namespace isc::data;
 using namespace isc::dhcp;
-using namespace isc::asiolink;
 using namespace isc::hooks;
 using namespace isc::process;
-using namespace isc::config;
 using namespace isc::util;
+using namespace isc;
+using namespace std;
 
 namespace {
 
@@ -411,16 +412,23 @@ void configureCommandChannel() {
     // receive the configuration result.
     if (!sock_cfg || !current_sock_cfg || sock_changed) {
         // Close the existing socket (if any).
-        isc::config::CommandMgr::instance().closeCommandSocket();
+        CommandMgr::instance().closeCommandSocket();
 
         if (sock_cfg) {
             // This will create a control socket and install the external
             // socket in IfaceMgr. That socket will be monitored when
             // Dhcp6Srv::receivePacket() calls IfaceMgr::receive6() and
             // callback in CommandMgr will be called, if necessary.
-            isc::config::CommandMgr::instance().openCommandSocket(sock_cfg);
+            CommandMgr::instance().openCommandSocket(sock_cfg);
         }
     }
+
+    // HTTP control socket is simpler: just (re)configure it.
+
+    // Get new config.
+    HttpCommandConfigPtr http_config =
+        CfgMgr::instance().getStagingCfg()->getHttpControlSocketInfo();
+    HttpCommandMgr::instance().configure(http_config);
 }
 
 /// @brief Process a DHCPv6 confguration and return an answer stating if the