From: Marcin Siodelski Date: Tue, 17 Nov 2015 19:04:46 +0000 (+0100) Subject: [3874] Use generated server identifier in the server. X-Git-Tag: trac4231_base~39^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=45d78a3d844ac8d15d9bfdd5ee6ff98c0e8d5106;p=thirdparty%2Fkea.git [3874] Use generated server identifier in the server. --- diff --git a/src/bin/dhcp6/ctrl_dhcp6_srv.cc b/src/bin/dhcp6/ctrl_dhcp6_srv.cc index e02f7be2cb..90c6362c5f 100644 --- a/src/bin/dhcp6/ctrl_dhcp6_srv.cc +++ b/src/bin/dhcp6/ctrl_dhcp6_srv.cc @@ -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(); diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index ace7821b17..4a38cfb05e 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -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 diff --git a/src/bin/dhcp6/dhcp6_srv.h b/src/bin/dhcp6/dhcp6_srv.h index b744f757ef..98a9da909c 100644 --- a/src/bin/dhcp6/dhcp6_srv.h +++ b/src/bin/dhcp6/dhcp6_srv.h @@ -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_; diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.mes b/src/lib/dhcpsrv/dhcpsrv_messages.mes index de012ff1a3..25ee4524f6 100644 --- a/src/lib/dhcpsrv/dhcpsrv_messages.mes +++ b/src/lib/dhcpsrv/dhcpsrv_messages.mes @@ -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 diff --git a/src/lib/dhcpsrv/parsers/duid_config_parser.cc b/src/lib/dhcpsrv/parsers/duid_config_parser.cc index 5afb9bf605..ed7c5054f8 100644 --- a/src/lib/dhcpsrv/parsers/duid_config_parser.cc +++ b/src/lib/dhcpsrv/parsers/duid_config_parser.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -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