diff options
author | Marcin Siodelski <marcin@isc.org> | 2022-11-21 17:30:31 +0100 |
---|---|---|
committer | Marcin Siodelski <marcin@isc.org> | 2023-01-07 11:45:06 +0100 |
commit | 927ac35562c9ca3f2001438928f6a6e894118466 (patch) | |
tree | 342581c03e5bfaf90517a599789d199c1fb2a065 /src | |
parent | [#969] DHCPv6 allocators configurable (diff) | |
download | kea-927ac35562c9ca3f2001438928f6a6e894118466.tar.xz kea-927ac35562c9ca3f2001438928f6a6e894118466.zip |
[#969] Improve allocator parsing code
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/dhcp4/tests/get_config_unittest.cc | 2 | ||||
-rw-r--r-- | src/bin/dhcp6/tests/get_config_unittest.cc | 2 | ||||
-rw-r--r-- | src/lib/dhcpsrv/network.h | 5 | ||||
-rw-r--r-- | src/lib/dhcpsrv/parsers/base_network_parser.cc | 26 | ||||
-rw-r--r-- | src/lib/dhcpsrv/parsers/base_network_parser.h | 27 | ||||
-rw-r--r-- | src/lib/dhcpsrv/parsers/dhcp_parsers.cc | 67 | ||||
-rw-r--r-- | src/lib/dhcpsrv/parsers/shared_network_parser.cc | 12 | ||||
-rw-r--r-- | src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc | 175 | ||||
-rw-r--r-- | src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc | 19 |
9 files changed, 286 insertions, 49 deletions
diff --git a/src/bin/dhcp4/tests/get_config_unittest.cc b/src/bin/dhcp4/tests/get_config_unittest.cc index 019968acdb..76fdecce3d 100644 --- a/src/bin/dhcp4/tests/get_config_unittest.cc +++ b/src/bin/dhcp4/tests/get_config_unittest.cc @@ -11174,6 +11174,7 @@ const char* UNPARSED_CONFIGS[] = { " \"server-tag\": \"\",\n" " \"shared-networks\": [\n" " {\n" +" \"allocator\": \"iterative\",\n" " \"calculate-tee-times\": false,\n" " \"max-valid-lifetime\": 7200,\n" " \"min-valid-lifetime\": 7200,\n" @@ -11532,6 +11533,7 @@ const char* UNPARSED_CONFIGS[] = { " \"server-tag\": \"\",\n" " \"shared-networks\": [\n" " {\n" +" \"allocator\": \"iterative\",\n" " \"calculate-tee-times\": true,\n" " \"max-valid-lifetime\": 4000,\n" " \"min-valid-lifetime\": 4000,\n" diff --git a/src/bin/dhcp6/tests/get_config_unittest.cc b/src/bin/dhcp6/tests/get_config_unittest.cc index d15d92c466..89c9f650d7 100644 --- a/src/bin/dhcp6/tests/get_config_unittest.cc +++ b/src/bin/dhcp6/tests/get_config_unittest.cc @@ -10023,6 +10023,7 @@ const char* UNPARSED_CONFIGS[] = { " \"server-tag\": \"\",\n" " \"shared-networks\": [\n" " {\n" +" \"allocator\": \"iterative\",\n" " \"calculate-tee-times\": true,\n" " \"max-preferred-lifetime\": 3600,\n" " \"max-valid-lifetime\": 7200,\n" @@ -10030,6 +10031,7 @@ const char* UNPARSED_CONFIGS[] = { " \"min-valid-lifetime\": 7200,\n" " \"name\": \"foo\",\n" " \"option-data\": [ ],\n" +" \"pd-allocator\": \"iterative\",\n" " \"preferred-lifetime\": 3600,\n" " \"rapid-commit\": false,\n" " \"relay\": {\n" diff --git a/src/lib/dhcpsrv/network.h b/src/lib/dhcpsrv/network.h index adb799e88b..d379fb8453 100644 --- a/src/lib/dhcpsrv/network.h +++ b/src/lib/dhcpsrv/network.h @@ -1333,6 +1333,11 @@ private: util::Optional<std::string> filename_; }; +class Network6; + +/// @brief Pointer to the @ref Network6 object. +typedef boost::shared_ptr<Network6> Network6Ptr; + /// @brief Specialization of the @ref Network object for DHCPv6 case. class Network6 : public virtual Network { public: diff --git a/src/lib/dhcpsrv/parsers/base_network_parser.cc b/src/lib/dhcpsrv/parsers/base_network_parser.cc index 9af4919bd8..be994acd11 100644 --- a/src/lib/dhcpsrv/parsers/base_network_parser.cc +++ b/src/lib/dhcpsrv/parsers/base_network_parser.cc @@ -267,5 +267,31 @@ BaseNetworkParser::parseDdnsParams(const data::ConstElementPtr& network_data, } } +void +BaseNetworkParser::parseAllocatorParams(const data::ConstElementPtr& network_data, + NetworkPtr& network) { + if (network_data->contains("allocator")) { + auto allocator_type = getString(network_data, "allocator"); + if ((allocator_type != "iterative") && (allocator_type != "random")) { + // Unsupported allocator type used. + isc_throw(DhcpConfigError, "supported allocators are: iterative and random"); + } + network->setAllocatorType(allocator_type); + } +} + +void +BaseNetworkParser::parsePdAllocatorParams(const data::ConstElementPtr& network_data, + Network6Ptr& network) { + if (network_data->contains("pd-allocator")) { + auto allocator_type = getString(network_data, "pd-allocator"); + if ((allocator_type != "iterative") && (allocator_type != "random")) { + // Unsupported allocator type used. + isc_throw(DhcpConfigError, "supported allocators are: iterative and random"); + } + network->setPdAllocatorType(allocator_type); + } +} + } // end of namespace isc::dhcp } // end of namespace isc diff --git a/src/lib/dhcpsrv/parsers/base_network_parser.h b/src/lib/dhcpsrv/parsers/base_network_parser.h index ee4bef373e..97065b7a5a 100644 --- a/src/lib/dhcpsrv/parsers/base_network_parser.h +++ b/src/lib/dhcpsrv/parsers/base_network_parser.h @@ -87,7 +87,7 @@ protected: /// @throw DhcpConfigError if configuration of these parameters is /// invalid. void parseCacheParams(const data::ConstElementPtr& network_data, - NetworkPtr& network); + NetworkPtr& network); /// @brief Parses parameters pertaining to DDNS behavior. /// @@ -105,6 +105,31 @@ protected: /// to be stored. void parseDdnsParams(const data::ConstElementPtr& network_data, NetworkPtr& network); + + /// @brief Parses parameters pertaining to allocator selection. + /// + /// The parsed parameters are: + /// - allocator + /// + /// @param network_data Data element holding shared network + /// configuration to be parsed. + /// @param [out] network Pointer to a network in which parsed data is + /// to be stored. + void parseAllocatorParams(const data::ConstElementPtr& network_data, + NetworkPtr& network); + + /// @brief Parses parameters pertaining to prefix delegation allocator + /// selection. + /// + /// The parsed parameters are: + /// - pd-allocator + /// + /// @param network_data Data element holding shared network + /// configuration to be parsed. + /// @param [out] network Pointer to a network in which parsed data is + /// to be stored. + void parsePdAllocatorParams(const data::ConstElementPtr& network_data, + Network6Ptr& network); }; } // end of namespace isc::dhcp diff --git a/src/lib/dhcpsrv/parsers/dhcp_parsers.cc b/src/lib/dhcpsrv/parsers/dhcp_parsers.cc index 3b92002494..de27db3449 100644 --- a/src/lib/dhcpsrv/parsers/dhcp_parsers.cc +++ b/src/lib/dhcpsrv/parsers/dhcp_parsers.cc @@ -633,17 +633,6 @@ SubnetConfigParser::createSubnet(ConstElementPtr params) { // Call the subclass's method to instantiate the subnet initSubnet(params, addr, len); - std::string allocator_type = "iterative"; - if (params->contains("allocator")) { - allocator_type = getString(params, "allocator"); - if ((allocator_type != "iterative") && (allocator_type != "random")) { - ConstElementPtr error = params->get("allocator"); - isc_throw(DhcpConfigError, "supported allocators are: iterative and random (" - << error->getPosition() << ")"); - } - } - subnet_->setAllocatorType(allocator_type); - // Add pools to it. for (PoolStorage::iterator it = pools_->begin(); it != pools_->end(); ++it) { @@ -732,26 +721,24 @@ Subnet4ConfigParser::parse(ConstElementPtr subnet) { } } - if (subnet_->getAllocatorType() == "random") { - subnet_->setAllocator(Lease::TYPE_V4, + // Parse allocator specification. + auto network4 = boost::dynamic_pointer_cast<Network>(sn4ptr); + parseAllocatorParams(subnet, network4); + + if (sn4ptr->getAllocatorType() == "random") { + sn4ptr->setAllocator(Lease::TYPE_V4, boost::make_shared<RandomAllocator> - (Lease::TYPE_V4, subnet_)); - subnet_->setAllocationState(Lease::TYPE_V4, SubnetAllocationStatePtr()); + (Lease::TYPE_V4, sn4ptr)); + sn4ptr->setAllocationState(Lease::TYPE_V4, SubnetAllocationStatePtr()); for (auto pool : *pools_) { pool->setAllocationState(PoolRandomAllocationState::create(pool)); } - } else if (subnet_->getAllocatorType() == "iterative") { - subnet_->setAllocator(Lease::TYPE_V4, - boost::make_shared<IterativeAllocator> - (Lease::TYPE_V4, subnet_)); - subnet_->setAllocationState(Lease::TYPE_V4, SubnetIterativeAllocationState::create(subnet_)); - + } else { for (auto pool : *pools_) { pool->setAllocationState(PoolIterativeAllocationState::create(pool)); } - } return (sn4ptr); @@ -1261,17 +1248,17 @@ Subnet6ConfigParser::parse(ConstElementPtr subnet) { } } - std::string allocator_type = "iterative"; - if (subnet->contains("pd-allocator")) { - allocator_type = getString(subnet, "pd-allocator"); - if ((allocator_type != "iterative") && (allocator_type != "random")) { - ConstElementPtr error = subnet->get("pd-allocator"); - isc_throw(DhcpConfigError, "supported allocators are: iterative and random (" - << error->getPosition() << ")"); - } - } - sn6ptr->setPdAllocatorType(allocator_type); + // Parse allocator specification. + auto network = boost::dynamic_pointer_cast<Network>(sn6ptr); + parseAllocatorParams(subnet, network); + + // Parse pd-allocator specification. + auto network6 = boost::dynamic_pointer_cast<Network6>(sn6ptr); + parsePdAllocatorParams(subnet, network6); + // If we use the random allocator we need to create its instance and + // the state instance for it. There is no need to do it for the iterative + // allocator because it is configured by default. if (sn6ptr->getAllocatorType() == "random") { sn6ptr->setAllocator(Lease::TYPE_NA, boost::make_shared<RandomAllocator> @@ -1282,30 +1269,18 @@ Subnet6ConfigParser::parse(ConstElementPtr subnet) { sn6ptr->setAllocationState(Lease::TYPE_NA, SubnetAllocationStatePtr()); sn6ptr->setAllocationState(Lease::TYPE_TA, SubnetAllocationStatePtr()); - } else { - sn6ptr->setAllocator(Lease::TYPE_NA, - boost::make_shared<IterativeAllocator> - (Lease::TYPE_NA, sn6ptr)); - sn6ptr->setAllocator(Lease::TYPE_TA, - boost::make_shared<IterativeAllocator> - (Lease::TYPE_TA, sn6ptr)); - sn6ptr->setAllocationState(Lease::TYPE_NA, SubnetIterativeAllocationState::create(sn6ptr)); - sn6ptr->setAllocationState(Lease::TYPE_TA, SubnetIterativeAllocationState::create(sn6ptr)); } + // Repeat the same for the delegated prefix allocator. if (sn6ptr->getPdAllocatorType() == "random") { sn6ptr->setAllocator(Lease::TYPE_PD, boost::make_shared<RandomAllocator> (Lease::TYPE_PD, sn6ptr)); sn6ptr->setAllocationState(Lease::TYPE_PD, SubnetAllocationStatePtr()); - } else { - sn6ptr->setAllocator(Lease::TYPE_PD, - boost::make_shared<IterativeAllocator> - (Lease::TYPE_PD, sn6ptr)); - sn6ptr->setAllocationState(Lease::TYPE_PD, SubnetIterativeAllocationState::create(sn6ptr)); } + // Create states for the pools. for (auto pool : *pools_) { switch (pool->getType()) { case Lease::TYPE_V4: diff --git a/src/lib/dhcpsrv/parsers/shared_network_parser.cc b/src/lib/dhcpsrv/parsers/shared_network_parser.cc index c063fa6ec6..9136ca60bd 100644 --- a/src/lib/dhcpsrv/parsers/shared_network_parser.cc +++ b/src/lib/dhcpsrv/parsers/shared_network_parser.cc @@ -197,6 +197,10 @@ SharedNetwork4Parser::parse(const data::ConstElementPtr& shared_network_data) { // Parse lease cache parameters parseCacheParams(shared_network_data, network); + + // Parse allocator params. + parseAllocatorParams(shared_network_data, network); + } catch (const DhcpConfigError&) { // Position was already added throw; @@ -377,6 +381,14 @@ SharedNetwork6Parser::parse(const data::ConstElementPtr& shared_network_data) { // Parse lease cache parameters parseCacheParams(shared_network_data, network); + + // Parse allocator params. + parseAllocatorParams(shared_network_data, network); + + // Parse prefix delegation allocator params. + auto network6 = boost::dynamic_pointer_cast<Network6>(shared_network); + parsePdAllocatorParams(shared_network_data, network6); + } catch (const std::exception& ex) { isc_throw(DhcpConfigError, ex.what() << " (" << shared_network_data->getPosition() << ")"); diff --git a/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc b/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc index b0e8a178ec..3bfa842787 100644 --- a/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc +++ b/src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc @@ -19,10 +19,13 @@ #include <dhcpsrv/subnet.h> #include <dhcpsrv/cfg_mac_source.h> #include <dhcpsrv/iterative_allocator.h> +#include <dhcpsrv/iterative_allocation_state.h> #include <dhcpsrv/parsers/dhcp_parsers.h> #include <dhcpsrv/parsers/option_data_parser.h> #include <dhcpsrv/parsers/shared_network_parser.h> #include <dhcpsrv/parsers/shared_networks_list_parser.h> +#include <dhcpsrv/random_allocator.h> +#include <dhcpsrv/random_allocation_state.h> #include <dhcpsrv/tests/test_libraries.h> #include <dhcpsrv/testutils/config_result_check.h> #include <exceptions/exceptions.h> @@ -3198,6 +3201,178 @@ TEST_F(ParseConfigTest, reservedSubnetId6) { EXPECT_EQ(expected, comment->stringValue()); } +// This test verifies that random allocator can be selected for +// a subnet. +TEST_F(ParseConfigTest, randomSubnetAllocator4) { + std::string config = + "{" + " \"subnet4\": [ {" + " \"subnet\": \"192.0.2.0/24\"," + " \"id\": 1," + " \"allocator\": \"random\"" + " } ]" + "}"; + + ElementPtr json = Element::fromJSON(config); + EXPECT_TRUE(json); + ConstElementPtr status = parseElementSet(json, false); + int rcode = 0; + ConstElementPtr comment = parseAnswer(rcode, status); + ASSERT_EQ(0, rcode); + + auto subnet = CfgMgr::instance().getStagingCfg()->getCfgSubnets4()->getBySubnetId(1); + ASSERT_TRUE(subnet); + + EXPECT_EQ("random", subnet->getAllocatorType().get()); + auto allocator = subnet->getAllocator(Lease::TYPE_V4); + ASSERT_TRUE(allocator); + EXPECT_TRUE(boost::dynamic_pointer_cast<RandomAllocator>(allocator)); +} + +// This test verifies that unknown allocator is rejected. +TEST_F(ParseConfigTest, invalidSubnetAllocator4) { + std::string config = + "{" + " \"subnet4\": [ {" + " \"subnet\": \"192.0.2.0/24\"," + " \"id\": 1," + " \"allocator\": \"unsupported\"" + " } ]" + "}"; + + ElementPtr json = Element::fromJSON(config); + EXPECT_TRUE(json); + ConstElementPtr status = parseElementSet(json, false); + int rcode = 0; + ConstElementPtr comment = parseAnswer(rcode, status); + ASSERT_TRUE(comment); + ASSERT_EQ(comment->getType(), Element::string); + EXPECT_EQ(1, rcode); + std::string expected = "Configuration parsing failed: "; + expected += "supported allocators are: iterative and random"; + EXPECT_EQ(expected, comment->stringValue()); +} + +// This test verifies that random allocator can be selected for +// a subnet. +TEST_F(ParseConfigTest, randomSubnetAllocator6) { + std::string config = + "{" + " \"subnet6\": [ {" + " \"subnet\": \"2001:db8:1::/64\"," + " \"id\": 1," + " \"allocator\": \"random\"" + " } ]" + "}"; + + ElementPtr json = Element::fromJSON(config); + EXPECT_TRUE(json); + ConstElementPtr status = parseElementSet(json, false); + int rcode = 0; + ConstElementPtr comment = parseAnswer(rcode, status); + ASSERT_EQ(0, rcode); + + auto subnet = CfgMgr::instance().getStagingCfg()->getCfgSubnets6()->getBySubnetId(1); + ASSERT_TRUE(subnet); + + EXPECT_EQ("random", subnet->getAllocatorType().get()); + auto allocator = subnet->getAllocator(Lease::TYPE_NA); + ASSERT_TRUE(allocator); + EXPECT_TRUE(boost::dynamic_pointer_cast<RandomAllocator>(allocator)); + allocator = subnet->getAllocator(Lease::TYPE_TA); + ASSERT_TRUE(allocator); + EXPECT_TRUE(boost::dynamic_pointer_cast<RandomAllocator>(allocator)); + // PD allocator should be iterative. + allocator = subnet->getAllocator(Lease::TYPE_PD); + ASSERT_TRUE(allocator); + EXPECT_TRUE(boost::dynamic_pointer_cast<IterativeAllocator>(allocator)); +} + +// This test verifies that unknown allocator is rejected. +TEST_F(ParseConfigTest, invalidSubnetAllocator6) { + std::string config = + "{" + " \"subnet6\": [ {" + " \"subnet\": \"2001:db8:1::/64\"," + " \"id\": 1," + " \"allocator\": \"unsupported\"" + " } ]" + "}"; + + ElementPtr json = Element::fromJSON(config); + EXPECT_TRUE(json); + ConstElementPtr status = parseElementSet(json, false); + int rcode = 0; + ConstElementPtr comment = parseAnswer(rcode, status); + ASSERT_TRUE(comment); + ASSERT_EQ(comment->getType(), Element::string); + EXPECT_EQ(1, rcode); + std::string expected = "Configuration parsing failed: "; + expected += "supported allocators are: iterative and random"; + EXPECT_EQ(expected, comment->stringValue()); +} + +// This test verifies that random allocator can be selected for +// a subnet. +TEST_F(ParseConfigTest, randomSubnetPdAllocator6) { + std::string config = + "{" + " \"subnet6\": [ {" + " \"subnet\": \"2001:db8:1::/64\"," + " \"id\": 1," + " \"pd-allocator\": \"random\"" + " } ]" + "}"; + + ElementPtr json = Element::fromJSON(config); + EXPECT_TRUE(json); + ConstElementPtr status = parseElementSet(json, false); + int rcode = 0; + ConstElementPtr comment = parseAnswer(rcode, status); + ASSERT_EQ(0, rcode); + + auto subnet = CfgMgr::instance().getStagingCfg()->getCfgSubnets6()->getBySubnetId(1); + ASSERT_TRUE(subnet); + + EXPECT_EQ("random", subnet->getPdAllocatorType().get()); + + // Address allocators should be iterative. + auto allocator = subnet->getAllocator(Lease::TYPE_NA); + ASSERT_TRUE(allocator); + EXPECT_TRUE(boost::dynamic_pointer_cast<IterativeAllocator>(allocator)); + allocator = subnet->getAllocator(Lease::TYPE_TA); + ASSERT_TRUE(allocator); + EXPECT_TRUE(boost::dynamic_pointer_cast<IterativeAllocator>(allocator)); + // PD allocator should be random. + allocator = subnet->getAllocator(Lease::TYPE_PD); + ASSERT_TRUE(allocator); + EXPECT_TRUE(boost::dynamic_pointer_cast<RandomAllocator>(allocator)); +} + +// This test verifies that unknown prefix delegation allocator is rejected. +TEST_F(ParseConfigTest, invalidSubnetPdAllocator6) { + std::string config = + "{" + " \"subnet6\": [ {" + " \"subnet\": \"2001:db8:1::/64\"," + " \"id\": 1," + " \"pd-allocator\": \"unsupported\"" + " } ]" + "}"; + + ElementPtr json = Element::fromJSON(config); + EXPECT_TRUE(json); + ConstElementPtr status = parseElementSet(json, false); + int rcode = 0; + ConstElementPtr comment = parseAnswer(rcode, status); + ASSERT_TRUE(comment); + ASSERT_EQ(comment->getType(), Element::string); + EXPECT_EQ(1, rcode); + std::string expected = "Configuration parsing failed: "; + expected += "supported allocators are: iterative and random"; + EXPECT_EQ(expected, comment->stringValue()); +} + // There's no test for ControlSocketParser, as it is tested in the DHCPv4 code // (see CtrlDhcpv4SrvTest.commandSocketBasic in // src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc). diff --git a/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc b/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc index fc35dde10c..873e150a8d 100644 --- a/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc +++ b/src/lib/dhcpsrv/tests/shared_network_parser_unittest.cc @@ -118,6 +118,7 @@ public: /// @return Valid shared network configuration. virtual std::string getWorkingConfig() const { std::string config = "{" + " \"allocator\": \"iterative\"," " \"authoritative\": true," " \"boot-file-name\": \"/dev/null\"," " \"client-class\": \"srv1\"," @@ -186,7 +187,8 @@ public: " \"t2-percent\": .65," " \"hostname-char-set\": \"\"," " \"cache-threshold\": .20," - " \"cache-max-age\": 50" + " \"cache-max-age\": 50," + " \"allocator\": \"random\"" " }," " {" " \"id\": 2," @@ -280,6 +282,7 @@ TEST_F(SharedNetwork4ParserTest, parse) { EXPECT_EQ(0.123, network->getCacheThreshold()); EXPECT_EQ(123, network->getCacheMaxAge().get()); EXPECT_TRUE(network->getDdnsUpdateOnRenew().get()); + EXPECT_EQ("iterative", network->getAllocatorType().get()); // Relay information. auto relay_info = network->getRelayInfo(); @@ -305,6 +308,7 @@ TEST_F(SharedNetwork4ParserTest, parse) { EXPECT_EQ(400, subnet->getValid().getMax()); EXPECT_FALSE(subnet->getHostnameCharSet().unspecified()); EXPECT_EQ("", subnet->getHostnameCharSet().get()); + EXPECT_EQ("random", subnet->getAllocatorType().get()); // Subnet with id 2 subnet = network->getSubnet(SubnetID(2)); @@ -315,6 +319,7 @@ TEST_F(SharedNetwork4ParserTest, parse) { EXPECT_EQ(30, subnet->getValid().getMax()); EXPECT_EQ("[^A-Z]", subnet->getHostnameCharSet().get()); EXPECT_EQ("x", subnet->getHostnameCharReplacement().get()); + EXPECT_EQ("iterative", subnet->getAllocatorType().get()); // DHCP options ConstCfgOptionPtr cfg_option = network->getCfgOption(); @@ -577,6 +582,8 @@ public: " \"cache-threshold\": 0.123," " \"cache-max-age\": 123," " \"ddns-update-on-renew\": true," + " \"allocator\": \"random\"," + " \"pd-allocator\": \"iterative\"," " \"option-data\": [" " {" " \"name\": \"dns-servers\"," @@ -603,7 +610,9 @@ public: " \"reservations-in-subnet\": true," " \"reservations-out-of-pool\": false," " \"rapid-commit\": false," - " \"hostname-char-set\": \"\"" + " \"hostname-char-set\": \"\"," + " \"allocator\": \"iterative\"," + " \"pd-allocator\": \"random\"" " }," " {" " \"id\": 2," @@ -688,6 +697,8 @@ TEST_F(SharedNetwork6ParserTest, parse) { EXPECT_EQ(0.123, network->getCacheThreshold()); EXPECT_EQ(123, network->getCacheMaxAge().get()); EXPECT_TRUE(network->getDdnsUpdateOnRenew().get()); + EXPECT_EQ("random", network->getAllocatorType().get()); + EXPECT_EQ("iterative", network->getPdAllocatorType().get()); // Relay information. auto relay_info = network->getRelayInfo(); @@ -716,6 +727,8 @@ TEST_F(SharedNetwork6ParserTest, parse) { EXPECT_EQ(500, subnet->getValid().getMax()); EXPECT_FALSE(subnet->getHostnameCharSet().unspecified()); EXPECT_EQ("", subnet->getHostnameCharSet().get()); + EXPECT_EQ("iterative", subnet->getAllocatorType().get()); + EXPECT_EQ("random", subnet->getPdAllocatorType().get()); // Subnet with id 2 subnet = network->getSubnet(SubnetID(2)); @@ -729,6 +742,8 @@ TEST_F(SharedNetwork6ParserTest, parse) { EXPECT_EQ(40, subnet->getValid().getMax()); EXPECT_EQ("[^A-Z]", subnet->getHostnameCharSet().get()); EXPECT_EQ("x", subnet->getHostnameCharReplacement().get()); + EXPECT_EQ("random", subnet->getAllocatorType().get()); + EXPECT_EQ("iterative", subnet->getPdAllocatorType().get()); // DHCP options ConstCfgOptionPtr cfg_option = network->getCfgOption(); |