diff --git a/doc/sphinx/arm/dhcp4-srv.rst b/doc/sphinx/arm/dhcp4-srv.rst index bddc73566b..70faecbe55 100644 --- a/doc/sphinx/arm/dhcp4-srv.rst +++ b/doc/sphinx/arm/dhcp4-srv.rst @@ -7818,6 +7818,8 @@ operating system, i.e. the size of the ``sun_path`` field in the different operating systems, between 91 and 107 characters. Typical values are 107 on Linux and 103 on FreeBSD. +Kea supports only one ``unix`` control socket in the "control-sockets" list. + Communication over the control channel is conducted using JSON structures. See the `Control Channel section in the Kea Developer's Guide @@ -7914,6 +7916,9 @@ password, these values can be read from files. The syntax is extended by: - The ``user-file`` client parameter, which, with the ``directory`` parameter, specifies the path of a file where the user ID can be read. +Since Kea-2.7.6 Kea supports multiple HTTP/HTTPS connections. +Both IPv4 and IPv6 addresses can be used. + When files are used, they are read when the configuration is loaded, to detect configuration errors as soon as possible. @@ -7944,6 +7949,11 @@ to detect configuration errors as soon as possible. "password": "1234" } ] } + }, + { + "socket-type": "http", + "socket-address": "2010:30:40::50", + "socket-port": 8004 } ], diff --git a/doc/sphinx/arm/dhcp6-srv.rst b/doc/sphinx/arm/dhcp6-srv.rst index 7c1b557a68..d28409a864 100644 --- a/doc/sphinx/arm/dhcp6-srv.rst +++ b/doc/sphinx/arm/dhcp6-srv.rst @@ -7618,6 +7618,8 @@ operating system, i.e. the size of the ``sun_path`` field in the different operating systems, between 91 and 107 characters. Typical values are 107 on Linux and 103 on FreeBSD. +Kea supports only one ``unix`` control socket in the "control-sockets" list. + Communication over the control channel is conducted using JSON structures. See the `Control Channel section in the Kea Developer's Guide @@ -7714,6 +7716,9 @@ password, these values can be read from files. The syntax is extended by: - The ``user-file`` client parameter, which, with the ``directory`` parameter, specifies the path of a file where the user ID can be read. +Since Kea-2.7.6 Kea supports multiple HTTP/HTTPS connections. +Both IPv4 and IPv6 addresses can be used. + When files are used, they are read when the configuration is loaded, to detect configuration errors as soon as possible. @@ -7744,6 +7749,11 @@ to detect configuration errors as soon as possible. "password": "1234" } ] } + }, + { + "socket-type": "http", + "socket-address": "10.20.30.40", + "socket-port": 8005 } ], diff --git a/src/bin/agent/ca_process.cc b/src/bin/agent/ca_process.cc index 3496bdd899..cec22a0e83 100644 --- a/src/bin/agent/ca_process.cc +++ b/src/bin/agent/ca_process.cc @@ -136,6 +136,7 @@ CtrlAgentProcess::configure(isc::data::ConstElementPtr config_set, uint16_t server_port = ctx->getHttpPort(); + // Search for the specific connection and reuse the existing one if found. auto it = sockets_.find(std::make_pair(server_address, server_port)); if (it != sockets_.end()) { auto listener = getHttpListener(); @@ -155,6 +156,8 @@ CtrlAgentProcess::configure(isc::data::ConstElementPtr config_set, return; } + // Connection not found so it needs to be created. + // When TLS is enabled configure it. bool use_https = false; TlsContextPtr tls_context; if (!ctx->getCertFile().empty()) { diff --git a/src/bin/agent/ca_process.h b/src/bin/agent/ca_process.h index 434b1c69e4..d96f236dd2 100644 --- a/src/bin/agent/ca_process.h +++ b/src/bin/agent/ca_process.h @@ -15,6 +15,8 @@ namespace isc { namespace agent { +/// @brief Structure used to store HTTP/HTTPS connection data. +/// (configuration, listener, etc.) struct HttpSocketInfo { /// @brief Flag which indicates if socket can be reused. bool usable_; @@ -143,7 +145,7 @@ public: /// @return true if the process is listening. bool isListening() const; - /// @brief Close http control socket. + /// @brief Close http control sockets. void closeCommandSockets(); private: @@ -154,7 +156,7 @@ private: /// @return Number of executed handlers. size_t runIO(); - /// @brief The HTTP/HTTPS socket configurations. + /// @brief The HTTP/HTTPS socket data (configuration, listener, etc.). std::map, HttpSocketInfoPtr> sockets_; }; diff --git a/src/lib/config/config_messages.mes b/src/lib/config/config_messages.mes index 185bc73419..06248d7c97 100644 --- a/src/lib/config/config_messages.mes +++ b/src/lib/config/config_messages.mes @@ -164,13 +164,14 @@ This informational message indicates that the server has started HTTP/HTTPS service on the specified address and port for receiving control commands. -% HTTP_COMMAND_MGR_SERVICE_STOPPING stopping %1 service %2 +% HTTP_COMMAND_MGR_SERVICE_STOPPING Server is stopping %1 service %2 This informational message indicates that the server has stopped HTTP/HTTPS service. When known the address and port are displayed. -% HTTP_COMMAND_MGR_SERVICE_STOPPING_NO_DATA stopping %1 service %2 -This informational message indicates that the server has stopped -HTTP/HTTPS service. When known the address and port are displayed. +% HTTP_COMMAND_MGR_SERVICE_STOPPING_NO_DATA Server is stopping all services including %1 service %2 +This informational message indicates that the server is stopping all +HTTP/HTTPS services. When known the address and port are displayed for +each service. % HTTP_COMMAND_MGR_SERVICE_STOPPING_ALL stopping %1 service %2 This informational message indicates that the server has stopped diff --git a/src/lib/config/http_command_config.h b/src/lib/config/http_command_config.h index ef036f8c92..b6e9c46f0a 100644 --- a/src/lib/config/http_command_config.h +++ b/src/lib/config/http_command_config.h @@ -232,6 +232,8 @@ private: /// @brief Pointer to a HttpCommandConfig object. typedef boost::shared_ptr HttpCommandConfigPtr; +/// @brief Structure used to store HTTP/HTTPS connection data. +/// (configuration, listener, etc.) struct HttpSocketInfo { /// @brief Flag which indicates if socket can be reused. bool usable_; diff --git a/src/lib/config/http_command_mgr.cc b/src/lib/config/http_command_mgr.cc index fd79308ada..a125eca54e 100644 --- a/src/lib/config/http_command_mgr.cc +++ b/src/lib/config/http_command_mgr.cc @@ -38,16 +38,19 @@ public: use_external_(true) { } - /// @brief Configure control socket from configuration. + /// @brief Open http control sockets using configuration. /// - /// @param config Configuration of the control socket. - void openCommandSocket(const isc::data::ConstElementPtr config); - - /// @brief Configure control socket from configuration. - /// - /// @param config Configuration of the control socket. + /// @param config Configuration information for the http control sockets. void openCommandSockets(const isc::data::ConstElementPtr config); + /// @brief Open http control socket using configuration. + /// + /// Creates http/https listener, or reuses the existing one reapplying + /// changes. + /// + /// @param config Configuration information for the http control socket. + void openCommandSocket(const isc::data::ConstElementPtr config); + /// @brief Close control socket. /// /// @param info Configuration information for the http control socket. @@ -74,7 +77,7 @@ public: /// @brief Idle connection timeout. long idle_timeout_; - /// @brief The HTTP/HTTPS socket configurations. + /// @brief The HTTP/HTTPS socket data (configuration, listener, etc.). std::map, HttpSocketInfoPtr> sockets_; /// @brief Use external sockets flag. @@ -117,6 +120,7 @@ HttpCommandMgrImpl::openCommandSocket(const isc::data::ConstElementPtr config) { IOAddress server_address = cmd_config->getSocketAddress(); uint16_t server_port = cmd_config->getSocketPort(); + // Search for the specific connection and reuse the existing one if found. auto it = sockets_.find(std::make_pair(server_address, server_port)); if (it != sockets_.end()) { if ((cmd_config->getTrustAnchor() != it->second->config_->getTrustAnchor()) || @@ -133,6 +137,8 @@ HttpCommandMgrImpl::openCommandSocket(const isc::data::ConstElementPtr config) { return; } + // Connection not found so it needs to be created. + // When TLS is enabled configure it. bool use_https = false; TlsContextPtr tls_context; if (!cmd_config->getCertFile().empty()) { diff --git a/src/lib/config/http_command_mgr.h b/src/lib/config/http_command_mgr.h index 70e8dcf859..8458810348 100644 --- a/src/lib/config/http_command_mgr.h +++ b/src/lib/config/http_command_mgr.h @@ -54,12 +54,15 @@ public: /// @param use_external True (default) add external sockets. void addExternalSockets(bool use_external = true); - /// @brief Configure http control socket from configuration. + /// @brief Open http control sockets using configuration. /// - /// @param config Configuration information for the http control socket. + /// @param config Configuration information for the http control sockets. void openCommandSockets(const isc::data::ConstElementPtr config); - /// @brief Configure http control socket from configuration. + /// @brief Open http control socket using configuration. + /// + /// Creates http/https listener, or reuses the existing one reapplying + /// changes. /// /// @param config Configuration information for the http control socket. void openCommandSocket(const isc::data::ConstElementPtr config); @@ -70,7 +73,7 @@ public: /// @param remove When true remove the listeners immediately. void closeCommandSocket(HttpSocketInfoPtr info = HttpSocketInfoPtr(), bool remove = true); - /// @brief Close http control socket. + /// @brief Close http control sockets. void closeCommandSockets(); /// @brief Returns a const pointer to the HTTP listener. diff --git a/src/lib/config/tests/unix_command_config_unittests.cc b/src/lib/config/tests/unix_command_config_unittests.cc index 53401e7a99..d69eac78b2 100644 --- a/src/lib/config/tests/unix_command_config_unittests.cc +++ b/src/lib/config/tests/unix_command_config_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2024 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2024-2025 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/lib/config/unix_command_mgr.cc b/src/lib/config/unix_command_mgr.cc index 6df9da1afb..560f4c39e0 100644 --- a/src/lib/config/unix_command_mgr.cc +++ b/src/lib/config/unix_command_mgr.cc @@ -510,6 +510,8 @@ public: /// @brief Opens acceptor service allowing the control clients to connect. /// + /// Creates acceptor, or reuses the existing one. + /// /// @param config Configuration information for the control socket. /// @throw BadSocketInfo When socket configuration is invalid. /// @throw SocketError When socket operation fails. @@ -544,7 +546,7 @@ public: /// @brief Pool of connections. ConnectionPool connection_pool_; - /// @brief The UNIX sockets. + /// @brief The UNIX socket data (configuration, acceptor, etc.). std::map sockets_; /// @brief Connection timeout. @@ -587,12 +589,14 @@ UnixCommandMgrImpl::openCommandSocket(const isc::data::ConstElementPtr config) { UnixCommandConfigPtr cmd_config(new UnixCommandConfig(config)); + // Search for the specific connection and reuse the existing one if found. auto it = sockets_.find(cmd_config->getSocketName()); if (it != sockets_.end()) { it->second->usable_ = true; return; } + // Connection not found so it needs to be created. // First let's open lock file. std::string lock_name = cmd_config->getLockName(); int lock_fd = open(lock_name.c_str(), O_RDONLY | O_CREAT, 0600); diff --git a/src/lib/config/unix_command_mgr.h b/src/lib/config/unix_command_mgr.h index 1e6b67538b..89f40f0032 100644 --- a/src/lib/config/unix_command_mgr.h +++ b/src/lib/config/unix_command_mgr.h @@ -71,6 +71,8 @@ public: /// @brief Opens unix control socket with parameters specified in socket_info /// (required parameters: socket-type: unix, socket-name:/unix/path). /// + /// Creates acceptor, or reuses the existing one. + /// /// @throw BadSocketInfo When socket configuration is invalid. /// @throw SocketError When socket operation fails. ///