diff options
author | Thomas Markwalder <tmark@isc.org> | 2019-03-26 20:12:06 +0100 |
---|---|---|
committer | Thomas Markwalder <tmark@isc.org> | 2019-03-26 20:12:06 +0100 |
commit | f5fe96c6ee044017583bdb2b64e98ebd49a785cc (patch) | |
tree | 204793b1258143b36e2fca8a61e620701e75691f /src/lib | |
parent | [#103,!277] Regenerated bison files. (diff) | |
download | kea-f5fe96c6ee044017583bdb2b64e98ebd49a785cc.tar.xz kea-f5fe96c6ee044017583bdb2b64e98ebd49a785cc.zip |
[#104,!290] kea-dhcpv6 now supports fetching config from backends
Infrastructure has been added to kea-dhcp6 such that it can
now be configured to fetch full and then periodic updates
from config backends.
Merging the actual fetched content will be done under subsequent
issues.
src/bin/dhcp6
ctrl_dhcp6_srv.*
- ControlledDhcpv6Srv::processConfig() - added logic to schedule CB update timer
- ControlledDhcpv6Srv::cbFetchUpdates() - new callback function for CB updates
dhcp6_lexer.ll
dhcp6_parser.yy
- Added config-fetch-wait-time
dhcp6_messages.mes
- New log messages
dhcp6_srv.*
- Dhcpv6Srv::cb_control_ - new member for config backend access
- Dhcpv6Srv::inTestMode() - new function to test for unit test mode
json_config_parser.cc
- configureDhcp6Server() - invokes full fetch from config backend
src/bin/dhcp6/tests
config_backend_unittest.cc - new file/tests for config backend testing
config_parser_unittest.cc - updated
get_config_unittest.cc - rebuild tests
kea_controller_unittest.cc - added CB control/timer tests
src/lib/dhcpsrv/
dhcpsrv_messages.mes - added log message
cb_ctl_dhcp6.* - new files that provide v6 impl of config backend controller
doc/examples/kea6/all-keys-current.json - added config-fetch-wait-time
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/dhcpsrv/Makefile.am | 1 | ||||
-rw-r--r-- | src/lib/dhcpsrv/cb_ctl_dhcp6.cc | 85 | ||||
-rw-r--r-- | src/lib/dhcpsrv/cb_ctl_dhcp6.h | 50 | ||||
-rw-r--r-- | src/lib/dhcpsrv/dhcpsrv_messages.cc | 4 | ||||
-rw-r--r-- | src/lib/dhcpsrv/dhcpsrv_messages.h | 3 | ||||
-rw-r--r-- | src/lib/dhcpsrv/dhcpsrv_messages.mes | 5 |
6 files changed, 146 insertions, 2 deletions
diff --git a/src/lib/dhcpsrv/Makefile.am b/src/lib/dhcpsrv/Makefile.am index 4c862958ff..ab5b800333 100644 --- a/src/lib/dhcpsrv/Makefile.am +++ b/src/lib/dhcpsrv/Makefile.am @@ -68,6 +68,7 @@ libkea_dhcpsrv_la_SOURCES += cache_host_data_source.h libkea_dhcpsrv_la_SOURCES += callout_handle_store.h libkea_dhcpsrv_la_SOURCES += cb_ctl_dhcp.h libkea_dhcpsrv_la_SOURCES += cb_ctl_dhcp4.cc cb_ctl_dhcp4.h +libkea_dhcpsrv_la_SOURCES += cb_ctl_dhcp6.cc cb_ctl_dhcp6.h libkea_dhcpsrv_la_SOURCES += cfg_4o6.cc cfg_4o6.h libkea_dhcpsrv_la_SOURCES += cfg_consistency.cc cfg_consistency.h libkea_dhcpsrv_la_SOURCES += cfg_db_access.cc cfg_db_access.h diff --git a/src/lib/dhcpsrv/cb_ctl_dhcp6.cc b/src/lib/dhcpsrv/cb_ctl_dhcp6.cc new file mode 100644 index 0000000000..b379e80e18 --- /dev/null +++ b/src/lib/dhcpsrv/cb_ctl_dhcp6.cc @@ -0,0 +1,85 @@ +// Copyright (C) 2019 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 +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include <config.h> +#include <dhcpsrv/cb_ctl_dhcp6.h> +#include <dhcpsrv/cfgmgr.h> +#include <dhcpsrv/dhcpsrv_log.h> + +using namespace isc::data; +using namespace isc::process; + +namespace isc { +namespace dhcp { + +void +CBControlDHCPv6::databaseConfigApply(const db::BackendSelector& backend_selector, + const db::ServerSelector& server_selector, + const boost::posix_time::ptime& lb_modification_time, + const db::AuditEntryCollection& audit_entries) { + // Create the external config into which we'll fetch backend config data. + SrvConfigPtr external_cfg = CfgMgr::instance().createExternalCfg(); + + // First let's fetch the globals and add them to external config. + if (fetchConfigElement(audit_entries, "dhcp6_global_parameter")) { + data::StampedValueCollection globals; + globals = getMgr().getPool()->getModifiedGlobalParameters6(backend_selector, server_selector, + lb_modification_time); + addGlobalsToConfig(external_cfg, globals); + } + + // Now we fetch the option definitions and add them. + if (fetchConfigElement(audit_entries, "dhcp6_option_def")) { + OptionDefContainer option_defs = + getMgr().getPool()->getModifiedOptionDefs6(backend_selector, server_selector, + lb_modification_time); + for (auto option_def = option_defs.begin(); option_def != option_defs.end(); ++option_def) { + external_cfg->getCfgOptionDef()->add((*option_def), (*option_def)->getOptionSpaceName()); + } + } + + // Next fetch the options. They are returned as a container of OptionDescriptors. + if (fetchConfigElement(audit_entries, "dhcp6_options")) { + OptionContainer options = getMgr().getPool()->getModifiedOptions6(backend_selector, + server_selector, + lb_modification_time); + for (auto option = options.begin(); option != options.end(); ++option) { + external_cfg->getCfgOption()->add((*option), (*option).space_name_); + } + } + + // Now fetch the shared networks. + if (fetchConfigElement(audit_entries, "dhcp6_shared_network")) { + SharedNetwork6Collection networks = + getMgr().getPool()->getModifiedSharedNetworks6(backend_selector, server_selector, + lb_modification_time); + for (auto network = networks.begin(); network != networks.end(); ++network) { + external_cfg->getCfgSharedNetworks6()->add((*network)); + } + } + + // Next we fetch subnets. + if (fetchConfigElement(audit_entries, "dhcp6_subnet")) { + Subnet6Collection subnets = getMgr().getPool()->getModifiedSubnets6(backend_selector, + server_selector, + lb_modification_time); + for (auto subnet = subnets.begin(); subnet != subnets.end(); ++subnet) { + external_cfg->getCfgSubnets6()->add((*subnet)); + } + } + + if (audit_entries.empty()) { + CfgMgr::instance().mergeIntoStagingCfg(external_cfg->getSequence()); + + } else { + CfgMgr::instance().mergeIntoCurrentCfg(external_cfg->getSequence()); + } + LOG_INFO(dhcpsrv_logger, DHCPSRV_CFGMGR_CONFIG6_MERGED); +} + + +} // end of namespace isc::dhcp +} // end of namespace isc diff --git a/src/lib/dhcpsrv/cb_ctl_dhcp6.h b/src/lib/dhcpsrv/cb_ctl_dhcp6.h new file mode 100644 index 0000000000..4817556540 --- /dev/null +++ b/src/lib/dhcpsrv/cb_ctl_dhcp6.h @@ -0,0 +1,50 @@ +// Copyright (C) 2019 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 +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef CB_CTL_DHCP6_H +#define CB_CTL_DHCP6_H + +#include <dhcpsrv/cb_ctl_dhcp.h> +#include <dhcpsrv/config_backend_dhcp6_mgr.h> +#include <dhcpsrv/srv_config.h> + +namespace isc { +namespace dhcp { + +/// @brief Implementation of the mechanisms to control the use of +/// the Configuration Backends by the DHCPv6 server. +/// +/// It implements fetching and merging DHCPv6 server configuration from +/// the database into the staging or current configuration. +/// +/// @tparam ConfigBackendMgrType Type of the Config Backend Manager used +/// by the server implementing this class. For example, for the DHCPv6 +/// server it will be @c ConfigBackendDHCPv6Mgr. +class CBControlDHCPv6 : public CBControlDHCP<ConfigBackendDHCPv6Mgr> { +protected: + + /// @brief DHCPv6 server specific method to fetch and apply back end + /// configuration into the local configuration. + /// + /// @param backend_selector Backend selector. + /// @param server_selector Server selector. + /// @param lb_modification_time Lower bound modification time for the + /// configuration elements to be fetched. + /// @param audit_entries Audit entries fetched from the database since + /// the last configuration update. This collection is empty if there + /// were no updates. + virtual void databaseConfigApply(const db::BackendSelector& backend_selector, + const db::ServerSelector& server_selector, + const boost::posix_time::ptime& lb_modification_time, + const db::AuditEntryCollection& audit_entries); +}; + +typedef boost::shared_ptr<CBControlDHCPv6> CBControlDHCPv6Ptr; + +} // end of namespace isc::dhcp +} // end of namespace isc + +#endif // CB_CTL_DHCP6_H diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.cc b/src/lib/dhcpsrv/dhcpsrv_messages.cc index 0b33bf120e..a45a3b988e 100644 --- a/src/lib/dhcpsrv/dhcpsrv_messages.cc +++ b/src/lib/dhcpsrv/dhcpsrv_messages.cc @@ -1,4 +1,4 @@ -// File created from ../../../src/lib/dhcpsrv/dhcpsrv_messages.mes on Tue Mar 19 2019 10:19 +// File created from ../../../src/lib/dhcpsrv/dhcpsrv_messages.mes on Tue Mar 26 2019 13:08 #include <cstddef> #include <log/message_types.h> @@ -14,6 +14,7 @@ extern const isc::log::MessageID DHCPSRV_CFGMGR_ALL_IFACES_ACTIVE = "DHCPSRV_CFG extern const isc::log::MessageID DHCPSRV_CFGMGR_CFG_DHCP_DDNS = "DHCPSRV_CFGMGR_CFG_DHCP_DDNS"; extern const isc::log::MessageID DHCPSRV_CFGMGR_CLEAR_ACTIVE_IFACES = "DHCPSRV_CFGMGR_CLEAR_ACTIVE_IFACES"; extern const isc::log::MessageID DHCPSRV_CFGMGR_CONFIG4_MERGED = "DHCPSRV_CFGMGR_CONFIG4_MERGED"; +extern const isc::log::MessageID DHCPSRV_CFGMGR_CONFIG6_MERGED = "DHCPSRV_CFGMGR_CONFIG6_MERGED"; extern const isc::log::MessageID DHCPSRV_CFGMGR_CONFIGURE_SERVERID = "DHCPSRV_CFGMGR_CONFIGURE_SERVERID"; extern const isc::log::MessageID DHCPSRV_CFGMGR_DEL_SUBNET4 = "DHCPSRV_CFGMGR_DEL_SUBNET4"; extern const isc::log::MessageID DHCPSRV_CFGMGR_DEL_SUBNET6 = "DHCPSRV_CFGMGR_DEL_SUBNET6"; @@ -245,6 +246,7 @@ const char* values[] = { "DHCPSRV_CFGMGR_CFG_DHCP_DDNS", "Setting DHCP-DDNS configuration to: %1", "DHCPSRV_CFGMGR_CLEAR_ACTIVE_IFACES", "stop listening on all interfaces", "DHCPSRV_CFGMGR_CONFIG4_MERGED", "Configuration backend data has been merged.", + "DHCPSRV_CFGMGR_CONFIG6_MERGED", "Configuration backend data has been merged.", "DHCPSRV_CFGMGR_CONFIGURE_SERVERID", "server configuration includes specification of a server identifier", "DHCPSRV_CFGMGR_DEL_SUBNET4", "IPv4 subnet %1 removed", "DHCPSRV_CFGMGR_DEL_SUBNET6", "IPv6 subnet %1 removed", diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.h b/src/lib/dhcpsrv/dhcpsrv_messages.h index b9bc955029..3a421e3dd1 100644 --- a/src/lib/dhcpsrv/dhcpsrv_messages.h +++ b/src/lib/dhcpsrv/dhcpsrv_messages.h @@ -1,4 +1,4 @@ -// File created from ../../../src/lib/dhcpsrv/dhcpsrv_messages.mes on Tue Mar 19 2019 10:19 +// File created from ../../../src/lib/dhcpsrv/dhcpsrv_messages.mes on Tue Mar 26 2019 13:08 #ifndef DHCPSRV_MESSAGES_H #define DHCPSRV_MESSAGES_H @@ -15,6 +15,7 @@ extern const isc::log::MessageID DHCPSRV_CFGMGR_ALL_IFACES_ACTIVE; extern const isc::log::MessageID DHCPSRV_CFGMGR_CFG_DHCP_DDNS; extern const isc::log::MessageID DHCPSRV_CFGMGR_CLEAR_ACTIVE_IFACES; extern const isc::log::MessageID DHCPSRV_CFGMGR_CONFIG4_MERGED; +extern const isc::log::MessageID DHCPSRV_CFGMGR_CONFIG6_MERGED; extern const isc::log::MessageID DHCPSRV_CFGMGR_CONFIGURE_SERVERID; extern const isc::log::MessageID DHCPSRV_CFGMGR_DEL_SUBNET4; extern const isc::log::MessageID DHCPSRV_CFGMGR_DEL_SUBNET6; diff --git a/src/lib/dhcpsrv/dhcpsrv_messages.mes b/src/lib/dhcpsrv/dhcpsrv_messages.mes index 56a500a5a7..810d695f21 100644 --- a/src/lib/dhcpsrv/dhcpsrv_messages.mes +++ b/src/lib/dhcpsrv/dhcpsrv_messages.mes @@ -36,6 +36,11 @@ This is an informational message emitted when the DHCPv4 server has successfully merged configuration data retrieved from its configuration backends into the current configuration. +% DHCPSRV_CFGMGR_CONFIG6_MERGED Configuration backend data has been merged. +This is an informational message emitted when the DHCPv6 server has +successfully merged configuration data retrieved from its configuration +backends into the current configuration. + % 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 |