]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3874] Use generated server identifier in the server.
authorMarcin Siodelski <marcin@isc.org>
Tue, 17 Nov 2015 19:04:46 +0000 (20:04 +0100)
committerMarcin Siodelski <marcin@isc.org>
Tue, 17 Nov 2015 19:31:51 +0000 (20:31 +0100)
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/dhcp6_srv.h
src/lib/dhcpsrv/dhcpsrv_messages.mes
src/lib/dhcpsrv/parsers/duid_config_parser.cc

index e02f7be2cb970f813ace5fe91573bdbf9cea6206..90c6362c5f5cfab475d6a1b2e941b11685c4c246 100644 (file)
@@ -28,6 +28,13 @@ using namespace isc::hooks;
 using namespace isc::stats;
 using namespace std;
 
+namespace {
+
+// Name of the file holding server identifier.
+static const char* SERVER_DUID_FILE = "kea-dhcp6-serverid";
+
+}
+
 namespace isc {
 namespace dhcp {
 
@@ -173,6 +180,24 @@ ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) {
                                           + string(ex.what())));
     }
 
+    // Regenerate server identifier if needed.
+    try {
+        const std::string duid_file = CfgMgr::instance().getDataDir() + "/" +
+            std::string(SERVER_DUID_FILE);
+        DuidPtr duid = CfgMgr::instance().getStagingCfg()->getCfgDUID()->create(duid_file);
+        server_->serverid_.reset(new Option(Option::V6, D6O_SERVERID, duid->getDuid()));
+        if (duid) {
+            LOG_INFO(dhcp6_logger, DHCP6_USING_SERVERID)
+                .arg(duid->toText())
+                .arg(duid_file);
+        }
+
+    } catch (const std::exception& ex) {
+        std::ostringstream err;
+        err << "unable to configure server identifier: " << ex.what();
+        return (isc::config::createAnswer(1, err.str()));
+    }
+
     // Server will start DDNS communications if its enabled.
     try {
         srv->startD2();
index ace7821b1761cf290f1850a3c32fc19766a17275..4a38cfb05e3f938c473565d53f801e160a1822dc 100644 (file)
@@ -184,7 +184,7 @@ const std::string Dhcpv6Srv::VENDOR_CLASS_PREFIX("VENDOR_CLASS_");
 static const char* SERVER_DUID_FILE = "kea-dhcp6-serverid";
 
 Dhcpv6Srv::Dhcpv6Srv(uint16_t port)
-    : serverid_(), port_(port), shutdown_(true), alloc_engine_()
+    : port_(port), serverid_(), shutdown_(true), alloc_engine_()
 {
 
     LOG_DEBUG(dhcp6_logger, DBG_DHCP6_START, DHCP6_OPEN_SOCKET).arg(port);
@@ -203,9 +203,6 @@ Dhcpv6Srv::Dhcpv6Srv(uint16_t port)
         DUIDFactory duid_factory(duid_file);
         DuidPtr duid = duid_factory.get();
         serverid_.reset(new Option(Option::V6, D6O_SERVERID, duid->getDuid()));
-        LOG_INFO(dhcp6_logger, DHCP6_USING_SERVERID)
-            .arg(duidToString(getServerID()))
-            .arg(duid_file);
 
         // Instantiate allocation engine. The number of allocation attempts equal
         // to zero indicates that the allocation engine will use the number of
index b744f757efe0b7a1797a84ab11bfe780c65b5606..98a9da909cd9b59fe19df37a1b3ea5c8628c66ae 100644 (file)
@@ -760,14 +760,14 @@ private:
     /// @param query packet transmitted
     static void processStatsSent(const Pkt6Ptr& response);
 
-    /// Server DUID (to be sent in server-identifier option)
-    OptionPtr serverid_;
-
     /// UDP port number on which server listens.
     uint16_t port_;
 
 protected:
 
+    /// Server DUID (to be sent in server-identifier option)
+    OptionPtr serverid_;
+
     /// Indicates if shutdown is in progress. Setting it to true will
     /// initiate server shutdown procedure.
     volatile bool shutdown_;
index de012ff1a39d3aca97cc623ccd0f6970f95e5b30..25ee4524f6f756a1fe9674200dfb11352491da2b 100644 (file)
@@ -39,6 +39,19 @@ of active interfaces. This doesn't prevent the server from listening to
 the DHCP traffic through open sockets, but will rather be used by Interface
 Manager to select active interfaces when sockets are re-opened.
 
+% DHCPSRV_CFGMGR_CONFIGURE_SERVERID server configuration includes specification of a server identifier
+This warning message is issued when the server specified configuration of
+a server identifier. If this new configuration overrides an existing
+server identifier, this will affect existing bindings of the clients.
+Clients will use old server identifier when they renew their bindings.
+The server will not respond to those renews, and the clients will
+eventually transition to rebinding state. The server should reassign
+existing bindings and the clients will subsequently use new server
+identifier. It is recommended to not modify the server identifier, unless
+there is a good reason for it, to avoid increased number of renewals and
+a need for rebinding (increase of multicast traffic, which may be received
+by multiple servers).
+
 % DHCPSRV_CFGMGR_NO_SUBNET4 no suitable subnet is defined for address hint %1
 This debug message is output when the DHCP configuration manager has received
 a request for an IPv4 subnet for the specified address, but no such
index 5afb9bf605e956c3b2025e5da4016f2b18a48d2f..ed7c5054f8cf5a114219fbd11efc7dc92ddcfad2 100644 (file)
@@ -17,6 +17,7 @@
 #include <dhcp/duid.h>
 #include <dhcpsrv/cfg_duid.h>
 #include <dhcpsrv/cfgmgr.h>
+#include <dhcpsrv/dhcpsrv_log.h>
 #include <dhcpsrv/parsers/duid_config_parser.h>
 #include <exceptions/exceptions.h>
 #include <boost/foreach.hpp>
@@ -66,6 +67,8 @@ DUIDConfigParser::build(isc::data::ConstElementPtr duid_configuration) {
                   " for the DUID configuration ("
                   << duid_configuration->getPosition() << ")");
     }
+
+    LOG_WARN(dhcpsrv_logger, DHCPSRV_CFGMGR_CONFIGURE_SERVERID);
 }
 
 void