summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorRazvan Becheriu <razvan@isc.org>2024-05-10 22:48:32 +0200
committerRazvan Becheriu <razvan@isc.org>2024-05-22 18:04:53 +0200
commitd149028d61849a724f3f24c15a00d94303010672 (patch)
treea516953f528c36dcfbfd6146ffddb026b47ebb55 /src/lib
parent[#3021] Add link to the code-signing keys (diff)
downloadkea-d149028d61849a724f3f24c15a00d94303010672.tar.xz
kea-d149028d61849a724f3f24c15a00d94303010672.zip
[#2958] removed deprecated dhcp-ddns parameters
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/dhcpsrv/d2_client_cfg.cc1
-rw-r--r--src/lib/dhcpsrv/d2_client_mgr.h31
-rw-r--r--src/lib/dhcpsrv/srv_config.cc50
-rw-r--r--src/lib/dhcpsrv/srv_config.h25
-rw-r--r--src/lib/dhcpsrv/tests/d2_client_unittest.cc8
-rw-r--r--src/lib/dhcpsrv/tests/srv_config_unittest.cc144
6 files changed, 20 insertions, 239 deletions
diff --git a/src/lib/dhcpsrv/d2_client_cfg.cc b/src/lib/dhcpsrv/d2_client_cfg.cc
index 78d7ffd75c..b26ebc5f2a 100644
--- a/src/lib/dhcpsrv/d2_client_cfg.cc
+++ b/src/lib/dhcpsrv/d2_client_cfg.cc
@@ -208,7 +208,6 @@ D2ClientConfig::toElement() const {
result->set("ncr-protocol", Element::create(dhcp_ddns::ncrProtocolToString(ncr_protocol_)));
// Set ncr-format
result->set("ncr-format", Element::create(dhcp_ddns::ncrFormatToString(ncr_format_)));
- // Set override-no-update
return (result);
}
diff --git a/src/lib/dhcpsrv/d2_client_mgr.h b/src/lib/dhcpsrv/d2_client_mgr.h
index ecd755fcbd..c9f44c98c7 100644
--- a/src/lib/dhcpsrv/d2_client_mgr.h
+++ b/src/lib/dhcpsrv/d2_client_mgr.h
@@ -108,9 +108,9 @@ public:
/// @brief Determines server flags based on configuration and client flags.
///
/// This method uses input values for the client's FQDN S and N flags, in
- /// conjunction with the configuration parameters updates-enabled, override-
- /// no-updates, and override-client-updates to determine the values that
- /// should be used for the server's FQDN S and N flags.
+ /// conjunction with the configuration parameters updates-enabled,
+ /// ddns-override-no-updates, and ddns-override-client-updates to determine
+ /// the values that should be used for the server's FQDN S and N flags.
/// The logic in this method is based upon RFCs 4702 and 4704, and is
/// shown in the following truth table:
///
@@ -158,12 +158,13 @@ public:
/// @brief Builds a FQDN based on the configuration and given IP address.
///
- /// Using the current values for generated-prefix, qualifying-suffix and
- /// an IP address, this method constructs a fully qualified domain name.
+ /// Using the current values for ddns-generated-prefix,
+ /// ddns-qualifying-suffix and an IP address, this method constructs a fully
+ /// qualified domain name.
/// It supports both IPv4 and IPv6 addresses. The format of the name
/// is as follows:
///
- /// <generated-prefix>-<ip address>.<qualifying-suffix>.
+ /// <ddns-generated-prefix>-<ip address>.<ddns-qualifying-suffix>.
///
/// <ip-address> is the result of IOAddress.toText() with the delimiters
/// ('.' for IPv4 or ':' for IPv6) replaced with a hyphen, '-'.
@@ -180,10 +181,10 @@ public:
/// @brief Adds a qualifying suffix to a given domain name
///
- /// Constructs a FQDN based on the configured qualifying-suffix and
+ /// Constructs a FQDN based on the configured ddns-qualifying-suffix and
/// a partial domain name as follows:
///
- /// <partial_name>.<qualifying-suffix>.
+ /// <partial_name>.<ddns-qualifying-suffix>.
///
/// Note that the qualifying suffix will only be appended if the
/// input name does not already end with that suffix.
@@ -202,7 +203,7 @@ public:
/// @brief Set server FQDN flags based on configuration and a given FQDN
///
- /// Templated wrapper around the analyzeFqdn() allowing that method to
+ /// Template wrapper around the analyzeFqdn() allowing that method to
/// be used for either IPv4 or IPv6 processing. This methods resets all
/// of the flags in the response to zero and then sets the S,N, and O
/// flags. Any other flags are the responsibility of the invoking layer.
@@ -218,7 +219,7 @@ public:
/// @brief Get directional update flags based on server FQDN flags
///
- /// Templated convenience method which determines whether forward and
+ /// Template convenience method which determines whether forward and
/// reverse updates should be performed based on a server response version
/// of the FQDN flags. The logic is straight forward and currently not
/// dependent upon configuration specific values:
@@ -238,18 +239,18 @@ public:
/// @brief Set server FQDN name based on configuration and a given FQDN
///
- /// Templated method which adjusts the domain name value and type in
+ /// Template method which adjusts the domain name value and type in
/// a server FQDN from a client (inbound) FQDN and the current
/// configuration. The logic is as follows:
///
- /// If replace-client-name is true or the supplied name is empty, the
+ /// If ddns-replace-client-name is true or the supplied name is empty, the
/// server FQDN is set to ""/PARTIAL.
///
- /// If replace-client-name is false and the supplied name is a partial
+ /// If ddns-replace-client-name is false and the supplied name is a partial
/// name the server FQDN is set to the supplied name qualified by
- /// appending the qualifying-suffix.
+ /// appending the ddns-qualifying-suffix.
///
- /// If replace-client-name is false and the supplied name is a fully
+ /// If ddns-replace-client-name is false and the supplied name is a fully
/// qualified name, set the server FQDN to the supplied name.
///
/// If hostname-char-set is not empty, the inbound name will be
diff --git a/src/lib/dhcpsrv/srv_config.cc b/src/lib/dhcpsrv/srv_config.cc
index 30a6ad8124..3979dc467b 100644
--- a/src/lib/dhcpsrv/srv_config.cc
+++ b/src/lib/dhcpsrv/srv_config.cc
@@ -964,56 +964,6 @@ SrvConfig::getDdnsParams(const Subnet6Ptr& subnet) const {
}
void
-SrvConfig::moveDdnsParams(isc::data::ElementPtr srv_elem) {
- if (!srv_elem || (srv_elem->getType() != Element::map)) {
- isc_throw(BadValue, "moveDdnsParams server config must be given a map element");
- }
-
- if (!srv_elem->contains("dhcp-ddns")) {
- /* nothing to do */
- return;
- }
-
- ElementPtr d2_elem = boost::const_pointer_cast<Element>(srv_elem->get("dhcp-ddns"));
- if (!d2_elem || (d2_elem->getType() != Element::map)) {
- isc_throw(BadValue, "moveDdnsParams dhcp-ddns is not a map");
- }
-
- struct Param {
- std::string from_name;
- std::string to_name;
- };
-
- std::vector<Param> params {
- { "override-no-update", "ddns-override-no-update" },
- { "override-client-update", "ddns-override-client-update" },
- { "replace-client-name", "ddns-replace-client-name" },
- { "generated-prefix", "ddns-generated-prefix" },
- { "qualifying-suffix", "ddns-qualifying-suffix" },
- { "hostname-char-set", "hostname-char-set" },
- { "hostname-char-replacement", "hostname-char-replacement" }
- };
-
- for (auto const& param : params) {
- if (d2_elem->contains(param.from_name)) {
- if (!srv_elem->contains(param.to_name)) {
- // No global value for it already, so let's add it.
- srv_elem->set(param.to_name, d2_elem->get(param.from_name));
- LOG_INFO(dhcpsrv_logger, DHCPSRV_CFGMGR_DDNS_PARAMETER_MOVED)
- .arg(param.from_name).arg(param.to_name);
- } else {
- // Already a global value, we'll use it and ignore this one.
- LOG_INFO(dhcpsrv_logger, DHCPSRV_CFGMGR_DDNS_PARAMETER_IGNORED)
- .arg(param.from_name).arg(param.to_name);
- }
-
- // Now remove it from d2_data, so D2ClientCfg won't complain.
- d2_elem->remove(param.from_name);
- }
- }
-}
-
-void
SrvConfig::setIPReservationsUnique(const bool unique) {
if (!getCfgDbAccess()->getIPReservationsUnique() && unique) {
LOG_WARN(dhcpsrv_logger, DHCPSRV_CFGMGR_IP_RESERVATIONS_UNIQUE_DUPLICATES_POSSIBLE);
diff --git a/src/lib/dhcpsrv/srv_config.h b/src/lib/dhcpsrv/srv_config.h
index c329eb6421..69c6cb9318 100644
--- a/src/lib/dhcpsrv/srv_config.h
+++ b/src/lib/dhcpsrv/srv_config.h
@@ -935,31 +935,6 @@ public:
void sanityChecksLifetime(const SrvConfig& target_config,
const std::string& name) const;
- /// @brief Moves deprecated parameters from dhcp-ddns element to global element
- ///
- /// Given a server configuration element map, the following parameters are moved
- /// from dhcp-ddns to top-level (i.e. global) element if they do not already
- /// exist there:
- ///
- /// @code
- /// From dhcp-ddns: To (global):
- /// ------------------------------------------------------
- /// override-no-update ddns-override-no-update
- /// override-client-update ddns-override-client-update
- /// replace-client-name ddns-replace-client-name
- /// generated-prefix ddns-generated-prefix
- /// qualifying-suffix ddns-qualifying-suffix
- /// hostname-char-set hostname-char-set
- /// hostname-char-replacement hostname-char-replacement
- /// @endcode
- ///
- /// Note that the whether or not the deprecated parameters are added
- /// to the global element, they are always removed from the dhcp-ddns
- /// element.
- ///
- /// @param srv_elem server top level map to alter
- static void moveDdnsParams(isc::data::ElementPtr srv_elem);
-
/// @brief Configures the server to allow or disallow specifying multiple
/// hosts with the same IP address/subnet.
///
diff --git a/src/lib/dhcpsrv/tests/d2_client_unittest.cc b/src/lib/dhcpsrv/tests/d2_client_unittest.cc
index 8dff72a7c0..3ca6b7eeeb 100644
--- a/src/lib/dhcpsrv/tests/d2_client_unittest.cc
+++ b/src/lib/dhcpsrv/tests/d2_client_unittest.cc
@@ -425,13 +425,13 @@ TEST_F(D2ClientMgrParamsTest, analyzeFqdnEnabledNoOverrides) {
}
/// @brief Tests that analyzeFqdn generates correct server S and N flags when
-/// updates are enabled and override-no-update is on.
+/// updates are enabled and ddns-override-no-update is on.
TEST_F(D2ClientMgrParamsTest, analyzeFqdnEnabledOverrideNoUpdate) {
D2ClientMgr mgr;
bool server_s = false;
bool server_n = false;
- // Create enabled configuration with override-no-update true.
+ // Create enabled configuration with ddns-override-no-update true.
subnet_->setDdnsSendUpdates(true);
subnet_->setDdnsOverrideNoUpdate(true);
subnet_->setDdnsOverrideClientUpdate(false);
@@ -464,13 +464,13 @@ TEST_F(D2ClientMgrParamsTest, analyzeFqdnEnabledOverrideNoUpdate) {
}
/// @brief Tests that analyzeFqdn generates correct server S and N flags when
-/// updates are enabled and override-client-update is on.
+/// updates are enabled and ddns-override-client-update is on.
TEST_F(D2ClientMgrParamsTest, analyzeFqdnEnabledOverrideClientUpdate) {
D2ClientMgr mgr;
bool server_s = false;
bool server_n = false;
- // Create enabled configuration with override-client-update true.
+ // Create enabled configuration with ddns-override-client-update true.
subnet_->setDdnsSendUpdates(true);
subnet_->setDdnsOverrideNoUpdate(false);
subnet_->setDdnsOverrideClientUpdate(true);
diff --git a/src/lib/dhcpsrv/tests/srv_config_unittest.cc b/src/lib/dhcpsrv/tests/srv_config_unittest.cc
index c53bd2a863..f3d6bb1107 100644
--- a/src/lib/dhcpsrv/tests/srv_config_unittest.cc
+++ b/src/lib/dhcpsrv/tests/srv_config_unittest.cc
@@ -1315,150 +1315,6 @@ TEST_F(SrvConfigTest, mergeEmptyClientClasses) {
EXPECT_TRUE(cfg_to.getClientClassDictionary()->findClass("bar"));
}
-// Validates SrvConfig::moveDdnsParams by ensuring that deprecated dhcp-ddns
-// parameters are:
-// 1. Translated to their global counterparts if they do not exist globally
-// 2. Removed from the dhcp-ddns element
-TEST_F(SrvConfigTest, moveDdnsParamsTest) {
- DdnsParamsPtr params;
-
- CfgMgr::instance().setFamily(AF_INET);
-
- struct Scenario {
- std::string description;
- std::string input_cfg;
- std::string exp_cfg;
- };
-
- std::vector<Scenario> scenarios {
- {
- "scenario 1, move with no global conflicts",
- // input_cfg
- "{\n"
- " \"dhcp-ddns\": {\n"
- " \"enable-updates\": true, \n"
- " \"server-ip\" : \"192.0.2.0\",\n"
- " \"server-port\" : 3432,\n"
- " \"sender-ip\" : \"192.0.2.1\",\n"
- " \"sender-port\" : 3433,\n"
- " \"max-queue-size\" : 2048,\n"
- " \"ncr-protocol\" : \"UDP\",\n"
- " \"ncr-format\" : \"JSON\",\n"
- " \"user-context\": { \"foo\": \"bar\" },\n"
- " \"override-no-update\": true,\n"
- " \"override-client-update\": false,\n"
- " \"replace-client-name\": \"always\",\n"
- " \"generated-prefix\": \"prefix\",\n"
- " \"qualifying-suffix\": \"suffix.com.\",\n"
- " \"hostname-char-set\": \"[^A-Z]\",\n"
- " \"hostname-char-replacement\": \"x\"\n"
- " }\n"
- "}\n",
- // exp_cfg
- "{\n"
- " \"dhcp-ddns\": {\n"
- " \"enable-updates\": true, \n"
- " \"server-ip\" : \"192.0.2.0\",\n"
- " \"server-port\" : 3432,\n"
- " \"sender-ip\" : \"192.0.2.1\",\n"
- " \"sender-port\" : 3433,\n"
- " \"max-queue-size\" : 2048,\n"
- " \"ncr-protocol\" : \"UDP\",\n"
- " \"ncr-format\" : \"JSON\",\n"
- " \"user-context\": { \"foo\": \"bar\" }\n"
- " },\n"
- " \"ddns-override-no-update\": true,\n"
- " \"ddns-override-client-update\": false,\n"
- " \"ddns-replace-client-name\": \"always\",\n"
- " \"ddns-generated-prefix\": \"prefix\",\n"
- " \"ddns-qualifying-suffix\": \"suffix.com.\",\n"
- " \"hostname-char-set\": \"[^A-Z]\",\n"
- " \"hostname-char-replacement\": \"x\"\n"
- "}\n"
- },
- {
- "scenario 2, globals already exist for all movable params",
- // input_cfg
- "{\n"
- " \"dhcp-ddns\" : {\n"
- " \"enable-updates\": true, \n"
- " \"override-no-update\": true,\n"
- " \"override-client-update\": true,\n"
- " \"replace-client-name\": \"always\",\n"
- " \"generated-prefix\": \"prefix\",\n"
- " \"qualifying-suffix\": \"suffix.com.\",\n"
- " \"hostname-char-set\": \"[^A-Z]\",\n"
- " \"hostname-char-replacement\": \"x\"\n"
- " },\n"
- " \"ddns-override-no-update\": false,\n"
- " \"ddns-override-client-update\": false,\n"
- " \"ddns-replace-client-name\": \"when-present\",\n"
- " \"ddns-generated-prefix\": \"org_prefix\",\n"
- " \"ddns-qualifying-suffix\": \"org_suffix.com.\",\n"
- " \"hostname-char-set\": \"[^a-z]\",\n"
- " \"hostname-char-replacement\": \"y\"\n"
- "}\n",
- // exp_cfg
- "{\n"
- " \"dhcp-ddns\" : {\n"
- " \"enable-updates\": true\n"
- " },\n"
- " \"ddns-override-no-update\": false,\n"
- " \"ddns-override-client-update\": false,\n"
- " \"ddns-replace-client-name\": \"when-present\",\n"
- " \"ddns-generated-prefix\": \"org_prefix\",\n"
- " \"ddns-qualifying-suffix\": \"org_suffix.com.\",\n"
- " \"hostname-char-set\": \"[^a-z]\",\n"
- " \"hostname-char-replacement\": \"y\"\n"
- "}\n"
- },
- {
- "scenario 3, nothing to move",
- // input_cfg
- "{\n"
- " \"dhcp-ddns\" : {\n"
- " \"enable-updates\": true, \n"
- " \"server-ip\" : \"192.0.2.0\",\n"
- " \"server-port\" : 3432,\n"
- " \"sender-ip\" : \"192.0.2.1\"\n"
- " }\n"
- "}\n",
- // exp_output
- "{\n"
- " \"dhcp-ddns\" : {\n"
- " \"enable-updates\": true, \n"
- " \"server-ip\" : \"192.0.2.0\",\n"
- " \"server-port\" : 3432,\n"
- " \"sender-ip\" : \"192.0.2.1\"\n"
- " }\n"
- "}\n"
- }
- };
-
- for (auto const& scenario : scenarios) {
- SrvConfig conf(32);
- ElementPtr input_cfg;
- ConstElementPtr exp_cfg;
- {
- SCOPED_TRACE(scenario.description);
- // Parse the input cfg into a mutable Element map.
- ASSERT_NO_THROW(input_cfg = boost::const_pointer_cast<Element>
- (Element::fromJSON(scenario.input_cfg)))
- << "input_cfg didn't parse, test is broken";
-
- // Parse the expected cfg into an Element map.
- ASSERT_NO_THROW(exp_cfg = Element::fromJSON(scenario.exp_cfg))
- << "exp_cfg didn't parse, test is broken";
-
- // Now call moveDdnsParams.
- ASSERT_NO_THROW(SrvConfig::moveDdnsParams(input_cfg));
-
- // Make sure the resultant configuration is as expected.
- EXPECT_TRUE(input_cfg->equals(*exp_cfg));
- }
- }
-}
-
// Verifies that the scoped values for DDNS parameters can be fetched
// for a given Subnet4.
TEST_F(SrvConfigTest, getDdnsParamsTest4) {