summaryrefslogtreecommitdiffstats
path: root/src/bin/dhcp6/ctrl_dhcp6_srv.cc
diff options
context:
space:
mode:
authorMarcin Siodelski <marcin@isc.org>2015-11-17 20:04:46 +0100
committerMarcin Siodelski <marcin@isc.org>2015-11-17 20:31:51 +0100
commit45d78a3d844ac8d15d9bfdd5ee6ff98c0e8d5106 (patch)
treee6363121fbdc0de04117bbb1fe1b7eeda5f0e308 /src/bin/dhcp6/ctrl_dhcp6_srv.cc
parent[3874] Reuse existing DUID if not explicitly specified. (diff)
downloadkea-45d78a3d844ac8d15d9bfdd5ee6ff98c0e8d5106.tar.xz
kea-45d78a3d844ac8d15d9bfdd5ee6ff98c0e8d5106.zip
[3874] Use generated server identifier in the server.
Diffstat (limited to 'src/bin/dhcp6/ctrl_dhcp6_srv.cc')
-rw-r--r--src/bin/dhcp6/ctrl_dhcp6_srv.cc25
1 files changed, 25 insertions, 0 deletions
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();