2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-22 09:57:41 +00:00

[#3582] Update kea-dhcp6 parsing and UTs

/doc/examples/kea4/all-keys.json
/doc/examples/kea4/classify.json
/doc/examples/kea4/classify2.json
/doc/examples/kea4/ha-load-balancing-server1-mt-with-tls.json
/doc/examples/kea4/ha-load-balancing-server1-mt-with-tls.json
/doc/examples/kea4/ha-load-balancing-server2-mt.json
/doc/examples/kea4/ha-load-balancing-server2-mt.json
/doc/examples/kea4/hooks-radius.json
/doc/examples/kea6/all-keys.json

/src/bin/dhcp4/tests/config_parser_unittest.cc
    TEST_F(Dhcp4ParserTest, deprecatedClientClassesCheck) - new test

/src/bin/dhcp4/tests/get_config_unittest.cc
    updated

/src/bin/dhcp6/dhcp6_lexer.ll
/src/bin/dhcp6/dhcp6_parser.yy
    added support for client-classes

/src/bin/dhcp6/tests/config_parser_unittest.cc
    updated
    TEST_F(Dhcp6ParserTest, sharedNetworksDeriveClientClass) - removed obsolete test
    TEST_F(Dhcp6ParserTest, deprecatedClientClassesCheck) - new test

/src/bin/dhcp6/tests/get_config_unittest.cc
/src/bin/dhcp6/tests/host_unittest.cc
/src/bin/dhcp6/tests/shared_network_unittest.cc
    updated

src/lib/dhcpsrv/parsers/simple_parser6.cc
    Corrected globals
This commit is contained in:
Thomas Markwalder 2024-10-31 14:37:19 -04:00
parent 24a2bbe164
commit b4ca3bdd20
20 changed files with 2956 additions and 2217 deletions

View File

@ -859,9 +859,9 @@
"boot-file-name": "/dev/null",
// Restricts this shared network to allow only clients
// that belong to a particular client class. If an
// empty string is provided, no restriction is applied.
"client-class": "",
// that belong to at least one class in this list. If omitted
// or an empty list is provided, no restriction is applied.
"client-classes": [],
// Shared-network level value. See description at the global level.
"ddns-generated-prefix": "myhost",
@ -998,10 +998,10 @@
// Subnet-level bootfile name, set in 'file' field.
"boot-file-name": "",
// Restricts this subnet to allow only clients that belong
// to a particular client class. If an empty string is
// provided, no restriction is applied.
"client-class": "",
// Restricts this subnet to allow only clients
// that belong to at least one class in this list. If omitted
// or an empty list is provided, no restriction is applied.
"client-classes": [],
// Subnet-level value. See description at the global level.
"ddns-generated-prefix": "myhost",
@ -1076,7 +1076,7 @@
// option will be applied. If the list is empty or is
// omitted this option will be applied regardless of class
// membership.
"client-classes": [ ],
"client-classes": [],
// Option code.
"code": 3,
@ -1105,9 +1105,10 @@
// List of IP address pools belonging to the subnet.
"pools": [
{
// Restricts this pool to only be used for client
// requests belonging to a particular client class.
"client-class": "phones_server1",
// Restricts this pool to allow only clients
// that belong to at least one class in this list. If omitted
// or an empty list is provided, no restriction is applied.
"client-classes": [ "phones_server1" ],
// Pool-level list of DHCP options.
"option-data": [],
@ -1120,9 +1121,10 @@
"evaluate-additional-classes": [ "late" ]
},
{
// Restricts this pool to only be used for client
// requests belonging to a particular client class.
"client-class": "phones_server2",
// Restricts this pool to allow only clients
// that belong to at least one class in this list. If omitted
// or an empty list is provided, no restriction is applied.
"client-classes": [ "phones_server2" ],
// Pool-level list of DHCP options.
"option-data": [],

View File

@ -83,7 +83,7 @@
"pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ],
"id": 1,
"subnet": "192.0.2.0/24",
"client-class": "VoIP",
"client-classes": [ "VoIP" ],
"interface": "eth0"
},
@ -113,7 +113,7 @@
// This one is for VoIP devices only.
{
"pool": "192.0.4.1 - 192.0.4.200",
"client-class": "VoIP"
"client-classes": [ "VoIP" ]
},
// This one doesn't have any client-class specified,

View File

@ -92,7 +92,7 @@
"pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ],
"id": 1,
"subnet": "192.0.2.0/24",
"client-class": "VoIP",
"client-classes": [ "VoIP" ],
"interface": "eth0"
},
// This one doesn't have any client-class specified, so everyone
@ -122,7 +122,7 @@
{
// This one is for VoIP devices only.
"pool": "192.0.4.1 - 192.0.4.200",
"client-class": "VoIP"
"client-classes": [ "VoIP" ]
},
// This one doesn't have any client-class specified, so everyone
// is allowed in.
@ -144,11 +144,11 @@
"pools": [
{
"pool": "192.0.8.100 - 192.0.8.200",
"client-class": "UNKNOWN"
"client-classes": [ "UNKNOWN" ]
},
{
"pool": "192.0.9.100 - 192.0.9.200",
"client-class": "KNOWN"
"client-classes": [ "KNOWN" ]
}
],
"id": 4,

View File

@ -214,19 +214,19 @@
"pools": [
{
"pool": "192.0.3.100 - 192.0.3.125",
"client-class": "phones_server1"
"client-classes": [ "phones_server1" ]
},
{
"pool": "192.0.3.126 - 192.0.3.150",
"client-class": "laptops_server1"
"client-classes": [ "laptops_server1" ]
},
{
"pool": "192.0.3.200 - 192.0.3.225",
"client-class": "phones_server2"
"client-classes": [ "phones_server2" ]
},
{
"pool": "192.0.3.226 - 192.0.3.250",
"client-class": "laptops_server2"
"client-classes": [ "laptops_server2" ]
}
],

View File

@ -197,19 +197,19 @@
"pools": [
{
"pool": "192.0.3.100 - 192.0.3.125",
"client-class": "phones_server1"
"client-classes": [ "phones_server1" ]
},
{
"pool": "192.0.3.126 - 192.0.3.150",
"client-class": "laptops_server1"
"client-classes": [ "laptops_server1" ]
},
{
"pool": "192.0.3.200 - 192.0.3.225",
"client-class": "phones_server2"
"client-classes": [ "phones_server2" ]
},
{
"pool": "192.0.3.226 - 192.0.3.250",
"client-class": "laptops_server2"
"client-classes": [ "laptops_server2" ]
}
],

View File

@ -106,12 +106,12 @@
{
// Red pool (10-19 are for reservations)
"pool": "192.0.2.20-192.0.2.99",
"client-class": "red"
"client-classes": [ "red" ]
},
{
// White pool (110-119 are for reservations)
"pool": "192.0.2.120-192.0.2.199",
"client-class": "white"
"client-classes": [ "white" ]
}
// Note there are not pools available to anyone. This is

View File

@ -802,9 +802,9 @@
"pd-allocator": "iterative",
// Restricts this shared network to allow only clients
// that belong to a particular client class. If an
// empty string is provided, no restriction is applied.
"client-class": "",
// that belong to at least one class in this list. If omitted
// or an empty list is provided, no restriction is applied.
"client-classes": [],
// Shared-network level value. See description at the global level.
"ddns-generated-prefix": "myhost",
@ -933,10 +933,10 @@
// for the subnet.
"pd-allocator": "iterative",
// Restricts this subnet to allow only clients that belong
// to a particular client class. If an empty string is
// provided, no restriction is applied.
"client-class": "",
// Restricts this subnet to allow only clients
// that belong to at least one class in this list. If omitted
// or an empty list is provided, no restriction is applied.
"client-classes": [],
// Subnet-level value. See description at the global level.
"ddns-generated-prefix": "myhost",
@ -1004,7 +1004,7 @@
// option will be applied. If the list is empty or is
// omitted this option will be applied regardless of class
// membership.
"client-classes": [ ],
"client-classes": [],
// Option code.
"code": 7,
@ -1034,9 +1034,10 @@
// clients.
"pd-pools": [
{
// Restricts this prefix pool to be used only for the client
// requests belonging to a particular client class.
"client-class": "phones_server1",
// Restricts this prefix pool subnet to allow only clients
// that belong to at least one class in this list. If omitted
// or an empty list is provided, no restriction is applied.
"client-classes": [ "phones_server1" ],
// Length of prefixes delegated to clients.
"delegated-len": 64,
@ -1083,9 +1084,10 @@
// List of IP address pools belonging to the subnet.
"pools": [
{
// Restricts this pool to only be used for client
// requests belonging to a particular client class.
"client-class": "phones_server1",
// Restricts this pool subnet to allow only clients
// that belong to at least one class in this list. If omitted
// or an empty list is provided, no restriction is applied.
"client-classes": [ "phones_server1" ],
// Pool-level list of DHCP options.
"option-data": [],
@ -1098,9 +1100,10 @@
"evaluate-additional-classes": [ "late" ]
},
{
// Restricts this pool to only be used for client
// requests belonging to a particular client class.
"client-class": "phones_server2",
// Restricts this pool subnet to allow only clients
// that belong to at least one class in this list. If omitted
// or an empty list is provided, no restriction is applied.
"client-classes": [ "phones_server2" ],
// Pool-level list of DHCP options.
"option-data": [],

View File

@ -8187,4 +8187,87 @@ TEST_F(Dhcp4ParserTest, deprecatedOnlyIfRequiredCheck) {
" 'only-in-additional-list'. Use only the latter.");
}
// This test verifies that deprecated client-class
// gets handled properly.
TEST_F(Dhcp4ParserTest, deprecatedClientClassesCheck) {
// Verify that require-client-classes gets translated
// to evaluate-additional-classes.
std::string config = "{ " + genIfaceConfig() + ","
R"^(
"rebind-timer": 2000,
"renew-timer": 1000,
"shared-networks":[{
"name": "net1",
"client-class": "one",
"subnet4": [{
"client-class": "two",
"pools": [{
"pool": "192.0.2.0/28",
"client-class": "three"
}],
"id": 1,
"subnet": "192.0.2.0/24"
}],
}],
"valid-lifetime": 400
})^";
ConstElementPtr json;
ASSERT_NO_THROW(json = parseDHCP4(config));
extractConfig(config);
ConstElementPtr status;
ASSERT_NO_THROW(status = configureDhcp4Server(*srv_, json));
checkResult(status, 0);
SharedNetwork4Ptr network = CfgMgr::instance().getStagingCfg()->
getCfgSharedNetworks4()->getByName("net1");
ASSERT_TRUE(network);
auto& net_class_list = network->getClientClasses();
ASSERT_EQ(1, net_class_list.size());
auto cclasses = net_class_list.begin();
EXPECT_EQ(*cclasses, "one");
auto subnet = CfgMgr::instance().getStagingCfg()->
getCfgSubnets4()->getBySubnetId(1);
ASSERT_TRUE(subnet);
auto& sub_class_list = subnet->getClientClasses();
ASSERT_EQ(1, sub_class_list.size());
cclasses = sub_class_list.begin();
EXPECT_EQ(*cclasses, "two");
PoolPtr pool = subnet->getPool(Lease::TYPE_V4, IOAddress("192.0.2.0"), false);
ASSERT_TRUE(pool);
auto& pool_class_list = pool->getClientClasses();
ASSERT_EQ(1, pool_class_list.size());
cclasses = pool_class_list.begin();
EXPECT_EQ(*cclasses, "three");
// Now verify that users cannot specify both. We don't check all scopes
// as they all use the same function.
config = "{ " + genIfaceConfig() + ","
R"^(
"rebind-timer": 2000,
"renew-timer": 1000,
"subnet4": [{
"client-class": "foo",
"client-classes": [ "bar" ],
"pools": [{ "pool": "192.0.2.0/28" }],
"id": 1,
"subnet": "192.0.2.0/24"
}],
"valid-lifetime": 400
})^";
ASSERT_NO_THROW(json = parseDHCP4(config));
ASSERT_NO_THROW(status = configureDhcp4Server(*srv_, json));
checkResult(status, 1,
"subnet configuration failed: cannot specify both 'client-class'"
" and 'client-classes'. Use only the latter.");
}
} // namespace

View File

@ -2622,6 +2622,35 @@ const char* EXTRACTED_CONFIGS[] = {
" \"renew-timer\": 1000,\n"
" \"subnet4\": [ ],\n"
" \"valid-lifetime\": 400\n"
" }\n",
// CONFIGURATION 82
"{\n"
" \"interfaces-config\": {\n"
" \"interfaces\": [ \"*\" ],\n"
" \"re-detect\": false\n"
" },\n"
" \"rebind-timer\": 2000,\n"
" \"renew-timer\": 1000,\n"
" \"shared-networks\": [\n"
" {\n"
" \"client-class\": \"one\",\n"
" \"name\": \"net1\",\n"
" \"subnet4\": [\n"
" {\n"
" \"client-class\": \"two\",\n"
" \"id\": 1,\n"
" \"pools\": [\n"
" {\n"
" \"client-class\": \"three\",\n"
" \"pool\": \"192.0.2.0/28\"\n"
" }\n"
" ],\n"
" \"subnet\": \"192.0.2.0/24\"\n"
" }\n"
" ]\n"
" }\n"
" ],\n"
" \"valid-lifetime\": 400\n"
" }\n"
};
@ -13381,6 +13410,142 @@ const char* UNPARSED_CONFIGS[] = {
" \"t1-percent\": 0.5,\n"
" \"t2-percent\": 0.875,\n"
" \"valid-lifetime\": 400\n"
" }\n",
// CONFIGURATION 82
"{\n"
" \"allocator\": \"iterative\",\n"
" \"authoritative\": false,\n"
" \"boot-file-name\": \"\",\n"
" \"calculate-tee-times\": false,\n"
" \"ddns-conflict-resolution-mode\": \"check-with-dhcid\",\n"
" \"ddns-generated-prefix\": \"myhost\",\n"
" \"ddns-override-client-update\": false,\n"
" \"ddns-override-no-update\": false,\n"
" \"ddns-qualifying-suffix\": \"\",\n"
" \"ddns-replace-client-name\": \"never\",\n"
" \"ddns-send-updates\": true,\n"
" \"ddns-update-on-renew\": false,\n"
" \"decline-probation-period\": 86400,\n"
" \"dhcp-ddns\": {\n"
" \"enable-updates\": false,\n"
" \"max-queue-size\": 1024,\n"
" \"ncr-format\": \"JSON\",\n"
" \"ncr-protocol\": \"UDP\",\n"
" \"sender-ip\": \"0.0.0.0\",\n"
" \"sender-port\": 0,\n"
" \"server-ip\": \"127.0.0.1\",\n"
" \"server-port\": 53001\n"
" },\n"
" \"dhcp-queue-control\": {\n"
" \"capacity\": 64,\n"
" \"enable-queue\": false,\n"
" \"queue-type\": \"kea-ring4\"\n"
" },\n"
" \"dhcp4o6-port\": 0,\n"
" \"early-global-reservations-lookup\": false,\n"
" \"echo-client-id\": true,\n"
" \"expired-leases-processing\": {\n"
" \"flush-reclaimed-timer-wait-time\": 25,\n"
" \"hold-reclaimed-time\": 3600,\n"
" \"max-reclaim-leases\": 100,\n"
" \"max-reclaim-time\": 250,\n"
" \"reclaim-timer-wait-time\": 10,\n"
" \"unwarned-reclaim-cycles\": 5\n"
" },\n"
" \"hooks-libraries\": [ ],\n"
" \"host-reservation-identifiers\": [ \"hw-address\", \"duid\", \"circuit-id\", \"client-id\" ],\n"
" \"hostname-char-replacement\": \"\",\n"
" \"hostname-char-set\": \"[^A-Za-z0-9.-]\",\n"
" \"interfaces-config\": {\n"
" \"interfaces\": [ \"*\" ],\n"
" \"re-detect\": false\n"
" },\n"
" \"ip-reservations-unique\": true,\n"
" \"lease-database\": {\n"
" \"type\": \"memfile\"\n"
" },\n"
" \"match-client-id\": true,\n"
" \"multi-threading\": {\n"
" \"enable-multi-threading\": true,\n"
" \"packet-queue-size\": 64,\n"
" \"thread-pool-size\": 0\n"
" },\n"
" \"next-server\": \"0.0.0.0\",\n"
" \"option-data\": [ ],\n"
" \"option-def\": [ ],\n"
" \"parked-packet-limit\": 256,\n"
" \"rebind-timer\": 2000,\n"
" \"renew-timer\": 1000,\n"
" \"reservations-global\": false,\n"
" \"reservations-in-subnet\": true,\n"
" \"reservations-lookup-first\": false,\n"
" \"reservations-out-of-pool\": false,\n"
" \"sanity-checks\": {\n"
" \"extended-info-checks\": \"fix\",\n"
" \"lease-checks\": \"warn\"\n"
" },\n"
" \"server-hostname\": \"\",\n"
" \"server-tag\": \"\",\n"
" \"shared-networks\": [\n"
" {\n"
" \"allocator\": \"iterative\",\n"
" \"calculate-tee-times\": false,\n"
" \"client-classes\": [ \"one\" ],\n"
" \"max-valid-lifetime\": 400,\n"
" \"min-valid-lifetime\": 400,\n"
" \"name\": \"net1\",\n"
" \"option-data\": [ ],\n"
" \"rebind-timer\": 2000,\n"
" \"relay\": {\n"
" \"ip-addresses\": [ ]\n"
" },\n"
" \"renew-timer\": 1000,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [\n"
" {\n"
" \"4o6-interface\": \"\",\n"
" \"4o6-interface-id\": \"\",\n"
" \"4o6-subnet\": \"\",\n"
" \"allocator\": \"iterative\",\n"
" \"calculate-tee-times\": false,\n"
" \"client-classes\": [ \"two\" ],\n"
" \"id\": 1,\n"
" \"max-valid-lifetime\": 400,\n"
" \"min-valid-lifetime\": 400,\n"
" \"option-data\": [ ],\n"
" \"pools\": [\n"
" {\n"
" \"client-classes\": [ \"three\" ],\n"
" \"option-data\": [ ],\n"
" \"pool\": \"192.0.2.0/28\"\n"
" }\n"
" ],\n"
" \"rebind-timer\": 2000,\n"
" \"relay\": {\n"
" \"ip-addresses\": [ ]\n"
" },\n"
" \"renew-timer\": 1000,\n"
" \"reservations\": [ ],\n"
" \"store-extended-info\": false,\n"
" \"subnet\": \"192.0.2.0/24\",\n"
" \"t1-percent\": 0.5,\n"
" \"t2-percent\": 0.875,\n"
" \"valid-lifetime\": 400\n"
" }\n"
" ],\n"
" \"t1-percent\": 0.5,\n"
" \"t2-percent\": 0.875,\n"
" \"valid-lifetime\": 400\n"
" }\n"
" ],\n"
" \"stash-agent-options\": false,\n"
" \"statistic-default-sample-age\": 0,\n"
" \"statistic-default-sample-count\": 20,\n"
" \"store-extended-info\": false,\n"
" \"subnet4\": [ ],\n"
" \"t1-percent\": 0.5,\n"
" \"t2-percent\": 0.875,\n"
" \"valid-lifetime\": 400\n"
" }\n"
};

File diff suppressed because it is too large Load Diff

View File

@ -1605,6 +1605,10 @@ ControlCharacterFill [^"\\]|\\["\\/bfnrtu]
case isc::dhcp::Parser6Context::DHCP6:
case isc::dhcp::Parser6Context::RESERVATIONS:
case isc::dhcp::Parser6Context::OPTION_DATA:
case isc::dhcp::Parser6Context::SHARED_NETWORK:
case isc::dhcp::Parser6Context::SUBNET6:
case isc::dhcp::Parser6Context::POOLS:
case isc::dhcp::Parser6Context::PD_POOLS:
return isc::dhcp::Dhcp6Parser::make_CLIENT_CLASSES(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("client-classes", driver.loc_);

File diff suppressed because it is too large Load Diff

View File

@ -1202,281 +1202,283 @@ namespace isc { namespace dhcp {
S_450_66 = 450, // $@66
S_client_class = 451, // client_class
S_452_67 = 452, // $@67
S_require_client_classes = 453, // require_client_classes
S_network_client_classes = 453, // network_client_classes
S_454_68 = 454, // $@68
S_evaluate_additional_classes = 455, // evaluate_additional_classes
S_require_client_classes = 455, // require_client_classes
S_456_69 = 456, // $@69
S_reservations_global = 457, // reservations_global
S_reservations_in_subnet = 458, // reservations_in_subnet
S_reservations_out_of_pool = 459, // reservations_out_of_pool
S_id = 460, // id
S_rapid_commit = 461, // rapid_commit
S_shared_networks = 462, // shared_networks
S_463_70 = 463, // $@70
S_shared_networks_content = 464, // shared_networks_content
S_shared_networks_list = 465, // shared_networks_list
S_shared_network = 466, // shared_network
S_467_71 = 467, // $@71
S_shared_network_params = 468, // shared_network_params
S_shared_network_param = 469, // shared_network_param
S_option_def_list = 470, // option_def_list
S_471_72 = 471, // $@72
S_sub_option_def_list = 472, // sub_option_def_list
S_evaluate_additional_classes = 457, // evaluate_additional_classes
S_458_70 = 458, // $@70
S_reservations_global = 459, // reservations_global
S_reservations_in_subnet = 460, // reservations_in_subnet
S_reservations_out_of_pool = 461, // reservations_out_of_pool
S_id = 462, // id
S_rapid_commit = 463, // rapid_commit
S_shared_networks = 464, // shared_networks
S_465_71 = 465, // $@71
S_shared_networks_content = 466, // shared_networks_content
S_shared_networks_list = 467, // shared_networks_list
S_shared_network = 468, // shared_network
S_469_72 = 469, // $@72
S_shared_network_params = 470, // shared_network_params
S_shared_network_param = 471, // shared_network_param
S_option_def_list = 472, // option_def_list
S_473_73 = 473, // $@73
S_option_def_list_content = 474, // option_def_list_content
S_not_empty_option_def_list = 475, // not_empty_option_def_list
S_option_def_entry = 476, // option_def_entry
S_477_74 = 477, // $@74
S_sub_option_def = 478, // sub_option_def
S_sub_option_def_list = 474, // sub_option_def_list
S_475_74 = 475, // $@74
S_option_def_list_content = 476, // option_def_list_content
S_not_empty_option_def_list = 477, // not_empty_option_def_list
S_option_def_entry = 478, // option_def_entry
S_479_75 = 479, // $@75
S_option_def_params = 480, // option_def_params
S_not_empty_option_def_params = 481, // not_empty_option_def_params
S_option_def_param = 482, // option_def_param
S_option_def_name = 483, // option_def_name
S_code = 484, // code
S_option_def_code = 485, // option_def_code
S_option_def_type = 486, // option_def_type
S_487_76 = 487, // $@76
S_option_def_record_types = 488, // option_def_record_types
S_sub_option_def = 480, // sub_option_def
S_481_76 = 481, // $@76
S_option_def_params = 482, // option_def_params
S_not_empty_option_def_params = 483, // not_empty_option_def_params
S_option_def_param = 484, // option_def_param
S_option_def_name = 485, // option_def_name
S_code = 486, // code
S_option_def_code = 487, // option_def_code
S_option_def_type = 488, // option_def_type
S_489_77 = 489, // $@77
S_space = 490, // space
S_option_def_record_types = 490, // option_def_record_types
S_491_78 = 491, // $@78
S_option_def_space = 492, // option_def_space
S_option_def_encapsulate = 493, // option_def_encapsulate
S_494_79 = 494, // $@79
S_option_def_array = 495, // option_def_array
S_option_data_list = 496, // option_data_list
S_497_80 = 497, // $@80
S_option_data_list_content = 498, // option_data_list_content
S_not_empty_option_data_list = 499, // not_empty_option_data_list
S_option_data_entry = 500, // option_data_entry
S_501_81 = 501, // $@81
S_sub_option_data = 502, // sub_option_data
S_space = 492, // space
S_493_79 = 493, // $@79
S_option_def_space = 494, // option_def_space
S_option_def_encapsulate = 495, // option_def_encapsulate
S_496_80 = 496, // $@80
S_option_def_array = 497, // option_def_array
S_option_data_list = 498, // option_data_list
S_499_81 = 499, // $@81
S_option_data_list_content = 500, // option_data_list_content
S_not_empty_option_data_list = 501, // not_empty_option_data_list
S_option_data_entry = 502, // option_data_entry
S_503_82 = 503, // $@82
S_option_data_params = 504, // option_data_params
S_not_empty_option_data_params = 505, // not_empty_option_data_params
S_option_data_param = 506, // option_data_param
S_option_data_name = 507, // option_data_name
S_option_data_data = 508, // option_data_data
S_509_83 = 509, // $@83
S_option_data_code = 510, // option_data_code
S_option_data_space = 511, // option_data_space
S_option_data_csv_format = 512, // option_data_csv_format
S_option_data_always_send = 513, // option_data_always_send
S_option_data_never_send = 514, // option_data_never_send
S_option_data_client_classes = 515, // option_data_client_classes
S_516_84 = 516, // $@84
S_pools_list = 517, // pools_list
S_sub_option_data = 504, // sub_option_data
S_505_83 = 505, // $@83
S_option_data_params = 506, // option_data_params
S_not_empty_option_data_params = 507, // not_empty_option_data_params
S_option_data_param = 508, // option_data_param
S_option_data_name = 509, // option_data_name
S_option_data_data = 510, // option_data_data
S_511_84 = 511, // $@84
S_option_data_code = 512, // option_data_code
S_option_data_space = 513, // option_data_space
S_option_data_csv_format = 514, // option_data_csv_format
S_option_data_always_send = 515, // option_data_always_send
S_option_data_never_send = 516, // option_data_never_send
S_option_data_client_classes = 517, // option_data_client_classes
S_518_85 = 518, // $@85
S_pools_list_content = 519, // pools_list_content
S_not_empty_pools_list = 520, // not_empty_pools_list
S_pool_list_entry = 521, // pool_list_entry
S_522_86 = 522, // $@86
S_sub_pool6 = 523, // sub_pool6
S_pools_list = 519, // pools_list
S_520_86 = 520, // $@86
S_pools_list_content = 521, // pools_list_content
S_not_empty_pools_list = 522, // not_empty_pools_list
S_pool_list_entry = 523, // pool_list_entry
S_524_87 = 524, // $@87
S_pool_params = 525, // pool_params
S_pool_param = 526, // pool_param
S_pool_entry = 527, // pool_entry
S_528_88 = 528, // $@88
S_pool_id = 529, // pool_id
S_user_context = 530, // user_context
S_531_89 = 531, // $@89
S_comment = 532, // comment
S_sub_pool6 = 525, // sub_pool6
S_526_88 = 526, // $@88
S_pool_params = 527, // pool_params
S_pool_param = 528, // pool_param
S_pool_entry = 529, // pool_entry
S_530_89 = 530, // $@89
S_pool_id = 531, // pool_id
S_user_context = 532, // user_context
S_533_90 = 533, // $@90
S_pd_pools_list = 534, // pd_pools_list
S_comment = 534, // comment
S_535_91 = 535, // $@91
S_pd_pools_list_content = 536, // pd_pools_list_content
S_not_empty_pd_pools_list = 537, // not_empty_pd_pools_list
S_pd_pool_entry = 538, // pd_pool_entry
S_539_92 = 539, // $@92
S_sub_pd_pool = 540, // sub_pd_pool
S_pd_pools_list = 536, // pd_pools_list
S_537_92 = 537, // $@92
S_pd_pools_list_content = 538, // pd_pools_list_content
S_not_empty_pd_pools_list = 539, // not_empty_pd_pools_list
S_pd_pool_entry = 540, // pd_pool_entry
S_541_93 = 541, // $@93
S_pd_pool_params = 542, // pd_pool_params
S_pd_pool_param = 543, // pd_pool_param
S_pd_prefix = 544, // pd_prefix
S_545_94 = 545, // $@94
S_pd_prefix_len = 546, // pd_prefix_len
S_excluded_prefix = 547, // excluded_prefix
S_548_95 = 548, // $@95
S_excluded_prefix_len = 549, // excluded_prefix_len
S_pd_delegated_len = 550, // pd_delegated_len
S_reservations = 551, // reservations
S_552_96 = 552, // $@96
S_reservations_list = 553, // reservations_list
S_not_empty_reservations_list = 554, // not_empty_reservations_list
S_reservation = 555, // reservation
S_556_97 = 556, // $@97
S_sub_reservation = 557, // sub_reservation
S_sub_pd_pool = 542, // sub_pd_pool
S_543_94 = 543, // $@94
S_pd_pool_params = 544, // pd_pool_params
S_pd_pool_param = 545, // pd_pool_param
S_pd_prefix = 546, // pd_prefix
S_547_95 = 547, // $@95
S_pd_prefix_len = 548, // pd_prefix_len
S_excluded_prefix = 549, // excluded_prefix
S_550_96 = 550, // $@96
S_excluded_prefix_len = 551, // excluded_prefix_len
S_pd_delegated_len = 552, // pd_delegated_len
S_reservations = 553, // reservations
S_554_97 = 554, // $@97
S_reservations_list = 555, // reservations_list
S_not_empty_reservations_list = 556, // not_empty_reservations_list
S_reservation = 557, // reservation
S_558_98 = 558, // $@98
S_reservation_params = 559, // reservation_params
S_not_empty_reservation_params = 560, // not_empty_reservation_params
S_reservation_param = 561, // reservation_param
S_ip_addresses = 562, // ip_addresses
S_563_99 = 563, // $@99
S_prefixes = 564, // prefixes
S_sub_reservation = 559, // sub_reservation
S_560_99 = 560, // $@99
S_reservation_params = 561, // reservation_params
S_not_empty_reservation_params = 562, // not_empty_reservation_params
S_reservation_param = 563, // reservation_param
S_ip_addresses = 564, // ip_addresses
S_565_100 = 565, // $@100
S_excluded_prefixes = 566, // excluded_prefixes
S_prefixes = 566, // prefixes
S_567_101 = 567, // $@101
S_duid = 568, // duid
S_excluded_prefixes = 568, // excluded_prefixes
S_569_102 = 569, // $@102
S_hw_address = 570, // hw_address
S_duid = 570, // duid
S_571_103 = 571, // $@103
S_hostname = 572, // hostname
S_hw_address = 572, // hw_address
S_573_104 = 573, // $@104
S_flex_id_value = 574, // flex_id_value
S_hostname = 574, // hostname
S_575_105 = 575, // $@105
S_reservation_client_classes = 576, // reservation_client_classes
S_flex_id_value = 576, // flex_id_value
S_577_106 = 577, // $@106
S_relay = 578, // relay
S_reservation_client_classes = 578, // reservation_client_classes
S_579_107 = 579, // $@107
S_relay_map = 580, // relay_map
S_client_classes = 581, // client_classes
S_582_108 = 582, // $@108
S_client_classes_list = 583, // client_classes_list
S_client_class_entry = 584, // client_class_entry
S_585_109 = 585, // $@109
S_client_class_params = 586, // client_class_params
S_not_empty_client_class_params = 587, // not_empty_client_class_params
S_client_class_param = 588, // client_class_param
S_client_class_name = 589, // client_class_name
S_client_class_test = 590, // client_class_test
S_591_110 = 591, // $@110
S_client_class_template_test = 592, // client_class_template_test
S_relay = 580, // relay
S_581_108 = 581, // $@108
S_relay_map = 582, // relay_map
S_client_classes = 583, // client_classes
S_584_109 = 584, // $@109
S_client_classes_list = 585, // client_classes_list
S_client_class_entry = 586, // client_class_entry
S_587_110 = 587, // $@110
S_client_class_params = 588, // client_class_params
S_not_empty_client_class_params = 589, // not_empty_client_class_params
S_client_class_param = 590, // client_class_param
S_client_class_name = 591, // client_class_name
S_client_class_test = 592, // client_class_test
S_593_111 = 593, // $@111
S_only_if_required = 594, // only_if_required
S_only_in_additional_list = 595, // only_in_additional_list
S_server_id = 596, // server_id
S_597_112 = 597, // $@112
S_server_id_params = 598, // server_id_params
S_server_id_param = 599, // server_id_param
S_server_id_type = 600, // server_id_type
S_601_113 = 601, // $@113
S_duid_type = 602, // duid_type
S_htype = 603, // htype
S_identifier = 604, // identifier
S_605_114 = 605, // $@114
S_time = 606, // time
S_enterprise_id = 607, // enterprise_id
S_dhcp4o6_port = 608, // dhcp4o6_port
S_control_socket = 609, // control_socket
S_610_115 = 610, // $@115
S_control_sockets = 611, // control_sockets
S_client_class_template_test = 594, // client_class_template_test
S_595_112 = 595, // $@112
S_only_if_required = 596, // only_if_required
S_only_in_additional_list = 597, // only_in_additional_list
S_server_id = 598, // server_id
S_599_113 = 599, // $@113
S_server_id_params = 600, // server_id_params
S_server_id_param = 601, // server_id_param
S_server_id_type = 602, // server_id_type
S_603_114 = 603, // $@114
S_duid_type = 604, // duid_type
S_htype = 605, // htype
S_identifier = 606, // identifier
S_607_115 = 607, // $@115
S_time = 608, // time
S_enterprise_id = 609, // enterprise_id
S_dhcp4o6_port = 610, // dhcp4o6_port
S_control_socket = 611, // control_socket
S_612_116 = 612, // $@116
S_control_socket_list = 613, // control_socket_list
S_not_empty_control_socket_list = 614, // not_empty_control_socket_list
S_control_socket_entry = 615, // control_socket_entry
S_616_117 = 616, // $@117
S_control_socket_params = 617, // control_socket_params
S_control_socket_param = 618, // control_socket_param
S_control_socket_type = 619, // control_socket_type
S_620_118 = 620, // $@118
S_control_socket_type_value = 621, // control_socket_type_value
S_control_socket_name = 622, // control_socket_name
S_623_119 = 623, // $@119
S_control_socket_address = 624, // control_socket_address
S_control_sockets = 613, // control_sockets
S_614_117 = 614, // $@117
S_control_socket_list = 615, // control_socket_list
S_not_empty_control_socket_list = 616, // not_empty_control_socket_list
S_control_socket_entry = 617, // control_socket_entry
S_618_118 = 618, // $@118
S_control_socket_params = 619, // control_socket_params
S_control_socket_param = 620, // control_socket_param
S_control_socket_type = 621, // control_socket_type
S_622_119 = 622, // $@119
S_control_socket_type_value = 623, // control_socket_type_value
S_control_socket_name = 624, // control_socket_name
S_625_120 = 625, // $@120
S_control_socket_port = 626, // control_socket_port
S_cert_required = 627, // cert_required
S_http_headers = 628, // http_headers
S_629_121 = 629, // $@121
S_http_header_list = 630, // http_header_list
S_not_empty_http_header_list = 631, // not_empty_http_header_list
S_http_header = 632, // http_header
S_633_122 = 633, // $@122
S_http_header_params = 634, // http_header_params
S_http_header_param = 635, // http_header_param
S_header_value = 636, // header_value
S_637_123 = 637, // $@123
S_authentication = 638, // authentication
S_control_socket_address = 626, // control_socket_address
S_627_121 = 627, // $@121
S_control_socket_port = 628, // control_socket_port
S_cert_required = 629, // cert_required
S_http_headers = 630, // http_headers
S_631_122 = 631, // $@122
S_http_header_list = 632, // http_header_list
S_not_empty_http_header_list = 633, // not_empty_http_header_list
S_http_header = 634, // http_header
S_635_123 = 635, // $@123
S_http_header_params = 636, // http_header_params
S_http_header_param = 637, // http_header_param
S_header_value = 638, // header_value
S_639_124 = 639, // $@124
S_auth_params = 640, // auth_params
S_auth_param = 641, // auth_param
S_auth_type = 642, // auth_type
S_643_125 = 643, // $@125
S_auth_type_value = 644, // auth_type_value
S_realm = 645, // realm
S_646_126 = 646, // $@126
S_directory = 647, // directory
S_authentication = 640, // authentication
S_641_125 = 641, // $@125
S_auth_params = 642, // auth_params
S_auth_param = 643, // auth_param
S_auth_type = 644, // auth_type
S_645_126 = 645, // $@126
S_auth_type_value = 646, // auth_type_value
S_realm = 647, // realm
S_648_127 = 648, // $@127
S_clients = 649, // clients
S_directory = 649, // directory
S_650_128 = 650, // $@128
S_clients_list = 651, // clients_list
S_not_empty_clients_list = 652, // not_empty_clients_list
S_basic_auth = 653, // basic_auth
S_654_129 = 654, // $@129
S_clients_params = 655, // clients_params
S_clients_param = 656, // clients_param
S_user_file = 657, // user_file
S_658_130 = 658, // $@130
S_password_file = 659, // password_file
S_clients = 651, // clients
S_652_129 = 652, // $@129
S_clients_list = 653, // clients_list
S_not_empty_clients_list = 654, // not_empty_clients_list
S_basic_auth = 655, // basic_auth
S_656_130 = 656, // $@130
S_clients_params = 657, // clients_params
S_clients_param = 658, // clients_param
S_user_file = 659, // user_file
S_660_131 = 660, // $@131
S_dhcp_queue_control = 661, // dhcp_queue_control
S_password_file = 661, // password_file
S_662_132 = 662, // $@132
S_queue_control_params = 663, // queue_control_params
S_queue_control_param = 664, // queue_control_param
S_enable_queue = 665, // enable_queue
S_queue_type = 666, // queue_type
S_667_133 = 667, // $@133
S_capacity = 668, // capacity
S_arbitrary_map_entry = 669, // arbitrary_map_entry
S_670_134 = 670, // $@134
S_dhcp_ddns = 671, // dhcp_ddns
S_dhcp_queue_control = 663, // dhcp_queue_control
S_664_133 = 664, // $@133
S_queue_control_params = 665, // queue_control_params
S_queue_control_param = 666, // queue_control_param
S_enable_queue = 667, // enable_queue
S_queue_type = 668, // queue_type
S_669_134 = 669, // $@134
S_capacity = 670, // capacity
S_arbitrary_map_entry = 671, // arbitrary_map_entry
S_672_135 = 672, // $@135
S_sub_dhcp_ddns = 673, // sub_dhcp_ddns
S_dhcp_ddns = 673, // dhcp_ddns
S_674_136 = 674, // $@136
S_dhcp_ddns_params = 675, // dhcp_ddns_params
S_dhcp_ddns_param = 676, // dhcp_ddns_param
S_enable_updates = 677, // enable_updates
S_server_ip = 678, // server_ip
S_679_137 = 679, // $@137
S_server_port = 680, // server_port
S_sender_ip = 681, // sender_ip
S_682_138 = 682, // $@138
S_sender_port = 683, // sender_port
S_max_queue_size = 684, // max_queue_size
S_ncr_protocol = 685, // ncr_protocol
S_686_139 = 686, // $@139
S_ncr_protocol_value = 687, // ncr_protocol_value
S_ncr_format = 688, // ncr_format
S_689_140 = 689, // $@140
S_config_control = 690, // config_control
S_sub_dhcp_ddns = 675, // sub_dhcp_ddns
S_676_137 = 676, // $@137
S_dhcp_ddns_params = 677, // dhcp_ddns_params
S_dhcp_ddns_param = 678, // dhcp_ddns_param
S_enable_updates = 679, // enable_updates
S_server_ip = 680, // server_ip
S_681_138 = 681, // $@138
S_server_port = 682, // server_port
S_sender_ip = 683, // sender_ip
S_684_139 = 684, // $@139
S_sender_port = 685, // sender_port
S_max_queue_size = 686, // max_queue_size
S_ncr_protocol = 687, // ncr_protocol
S_688_140 = 688, // $@140
S_ncr_protocol_value = 689, // ncr_protocol_value
S_ncr_format = 690, // ncr_format
S_691_141 = 691, // $@141
S_sub_config_control = 692, // sub_config_control
S_config_control = 692, // config_control
S_693_142 = 693, // $@142
S_config_control_params = 694, // config_control_params
S_config_control_param = 695, // config_control_param
S_config_databases = 696, // config_databases
S_697_143 = 697, // $@143
S_config_fetch_wait_time = 698, // config_fetch_wait_time
S_loggers = 699, // loggers
S_700_144 = 700, // $@144
S_loggers_entries = 701, // loggers_entries
S_logger_entry = 702, // logger_entry
S_703_145 = 703, // $@145
S_logger_params = 704, // logger_params
S_logger_param = 705, // logger_param
S_debuglevel = 706, // debuglevel
S_severity = 707, // severity
S_708_146 = 708, // $@146
S_output_options_list = 709, // output_options_list
S_sub_config_control = 694, // sub_config_control
S_695_143 = 695, // $@143
S_config_control_params = 696, // config_control_params
S_config_control_param = 697, // config_control_param
S_config_databases = 698, // config_databases
S_699_144 = 699, // $@144
S_config_fetch_wait_time = 700, // config_fetch_wait_time
S_loggers = 701, // loggers
S_702_145 = 702, // $@145
S_loggers_entries = 703, // loggers_entries
S_logger_entry = 704, // logger_entry
S_705_146 = 705, // $@146
S_logger_params = 706, // logger_params
S_logger_param = 707, // logger_param
S_debuglevel = 708, // debuglevel
S_severity = 709, // severity
S_710_147 = 710, // $@147
S_output_options_list_content = 711, // output_options_list_content
S_output_entry = 712, // output_entry
S_713_148 = 713, // $@148
S_output_params_list = 714, // output_params_list
S_output_params = 715, // output_params
S_output = 716, // output
S_717_149 = 717, // $@149
S_flush = 718, // flush
S_maxsize = 719, // maxsize
S_maxver = 720, // maxver
S_pattern = 721, // pattern
S_722_150 = 722, // $@150
S_compatibility = 723, // compatibility
S_output_options_list = 711, // output_options_list
S_712_148 = 712, // $@148
S_output_options_list_content = 713, // output_options_list_content
S_output_entry = 714, // output_entry
S_715_149 = 715, // $@149
S_output_params_list = 716, // output_params_list
S_output_params = 717, // output_params
S_output = 718, // output
S_719_150 = 719, // $@150
S_flush = 720, // flush
S_maxsize = 721, // maxsize
S_maxver = 722, // maxver
S_pattern = 723, // pattern
S_724_151 = 724, // $@151
S_compatibility_params = 725, // compatibility_params
S_compatibility_param = 726, // compatibility_param
S_lenient_option_parsing = 727 // lenient_option_parsing
S_compatibility = 725, // compatibility
S_726_152 = 726, // $@152
S_compatibility_params = 727, // compatibility_params
S_compatibility_param = 728, // compatibility_param
S_lenient_option_parsing = 729 // lenient_option_parsing
};
};
@ -5738,8 +5740,8 @@ switch (yykind)
/// Constants.
enum
{
yylast_ = 1599, ///< Last index in yytable_.
yynnts_ = 493, ///< Number of nonterminal symbols.
yylast_ = 1722, ///< Last index in yytable_.
yynnts_ = 495, ///< Number of nonterminal symbols.
yyfinal_ = 30 ///< Termination state number.
};
@ -5983,7 +5985,7 @@ switch (yykind)
#line 14 "dhcp6_parser.yy"
} } // isc::dhcp
#line 5987 "dhcp6_parser.h"
#line 5989 "dhcp6_parser.h"

View File

@ -1619,6 +1619,7 @@ subnet6_param: preferred_lifetime
| id
| rapid_commit
| client_class
| network_client_classes
| require_client_classes
| evaluate_additional_classes
| reservations
@ -1687,6 +1688,18 @@ client_class: CLIENT_CLASS {
ctx.leave();
};
// Used by shared-network,subnet, pool, and pd_pool
network_client_classes: CLIENT_CLASSES {
ctx.unique("client-classes", ctx.loc2pos(@1));
ElementPtr c(new ListElement(ctx.loc2pos(@1)));
ctx.stack_.back()->set("client-classes", c);
ctx.stack_.push_back(c);
ctx.enter(ctx.NO_KEYWORD);
} COLON list_strings {
ctx.stack_.pop_back();
ctx.leave();
};
// Deprecated.
require_client_classes: REQUIRE_CLIENT_CLASSES {
ctx.unique("require-client-classes", ctx.loc2pos(@1));
@ -1793,6 +1806,7 @@ shared_network_param: name
| reservations_in_subnet
| reservations_out_of_pool
| client_class
| network_client_classes
| require_client_classes
| evaluate_additional_classes
| preferred_lifetime
@ -2159,6 +2173,7 @@ pool_param: pool_entry
| pool_id
| option_data_list
| client_class
| network_client_classes
| require_client_classes
| evaluate_additional_classes
| user_context
@ -2297,6 +2312,7 @@ pd_pool_param: pd_prefix
| pool_id
| option_data_list
| client_class
| network_client_classes
| require_client_classes
| evaluate_additional_classes
| excluded_prefix

View File

@ -1,4 +1,3 @@
// Generated 202411151018
// A Bison parser, made by GNU Bison 3.8.2.
// Locations for Bison parsers in C++

View File

@ -5165,19 +5165,19 @@ TEST_F(Dhcp6ParserTest, classifySubnets) {
" \"id\": 1,"
" \"pools\": [ { \"pool\": \"2001:db8:1::/80\" } ],"
" \"subnet\": \"2001:db8:1::/64\", "
" \"client-class\": \"alpha\" "
" \"client-classes\": [ \"alpha\" ] "
" },"
" {"
" \"id\": 2,"
" \"pools\": [ { \"pool\": \"2001:db8:2::/80\" } ],"
" \"subnet\": \"2001:db8:2::/64\", "
" \"client-class\": \"beta\" "
" \"client-classes\": [ \"beta\" ] "
" },"
" {"
" \"id\": 3,"
" \"pools\": [ { \"pool\": \"2001:db8:3::/80\" } ],"
" \"subnet\": \"2001:db8:3::/64\", "
" \"client-class\": \"gamma\" "
" \"client-classes\": [ \"gamma\" ] "
" },"
" {"
" \"id\": 4,"
@ -5262,15 +5262,15 @@ TEST_F(Dhcp6ParserTest, classifyPools) {
" \"id\": 1,"
" \"pools\": [ { "
" \"pool\": \"2001:db8:1::/80\", "
" \"client-class\": \"alpha\" "
" \"client-classes\": [ \"alpha\" ] "
" },"
" {"
" \"pool\": \"2001:db8:2::/80\", "
" \"client-class\": \"beta\" "
" \"client-classes\": [ \"beta\" ] "
" },"
" {"
" \"pool\": \"2001:db8:3::/80\", "
" \"client-class\": \"gamma\" "
" \"client-classes\": [ \"gamma\" ] "
" },"
" {"
" \"pool\": \"2001:db8:4::/80\" "
@ -5355,19 +5355,19 @@ TEST_F(Dhcp6ParserTest, classifyPdPools) {
" \"prefix-len\": 48, "
" \"delegated-len\": 64, "
" \"prefix\": \"2001:db8:1::\", "
" \"client-class\": \"alpha\" "
" \"client-classes\": [ \"alpha\" ] "
" },"
" {"
" \"prefix-len\": 48, "
" \"delegated-len\": 64, "
" \"prefix\": \"2001:db8:2::\", "
" \"client-class\": \"beta\" "
" \"client-classes\": [ \"beta\" ] "
" },"
" {"
" \"prefix-len\": 48, "
" \"delegated-len\": 64, "
" \"prefix\": \"2001:db8:3::\", "
" \"client-class\": \"gamma\" "
" \"client-classes\": [ \"gamma\" ] "
" },"
" {"
" \"prefix-len\": 48, "
@ -7577,98 +7577,6 @@ TEST_F(Dhcp6ParserTest, sharedNetworksInterfacesMixed) {
"or the shared-network itself used eth0");
}
#if 0
// This test checks if client-class is derived properly.
TEST_F(Dhcp6ParserTest, sharedNetworksDeriveClientClass) {
// This config is structured in a way that the first shared network has
// client-class defined. This should in general be inherited by subnets, but
// it's also possible to override the values on subnet level.
string config = "{\n"
"\"renew-timer\": 1, \n" // global values here
"\"rebind-timer\": 2, \n"
"\"preferred-lifetime\": 3,\n"
"\"valid-lifetime\": 4, \n"
"\"shared-networks\": [ {\n"
" \"name\": \"foo\"\n," // shared network values here
" \"client-class\": \"alpha\",\n"
" \"subnet6\": [\n"
" { \n"
" \"id\": 1,\n"
" \"subnet\": \"2001:db1::/48\",\n"
" \"pools\": [ { \"pool\": \"2001:db1::/64\" } ]\n"
" },\n"
" { \n"
" \"id\": 2,\n"
" \"subnet\": \"2001:db2::/48\",\n"
" \"pools\": [ { \"pool\": \"2001:db2::/64\" } ],\n"
" \"client-class\": \"beta\"\n"
" }\n"
" ]\n"
" },\n"
"{ // second shared-network starts here\n"
" \"name\": \"bar\",\n"
" \"subnet6\": [\n"
" {\n"
" \"id\": 3,\n"
" \"subnet\": \"2001:db3::/48\",\n"
" \"pools\": [ { \"pool\": \"2001:db3::/64\" } ]\n"
" }\n"
" ]\n"
" } ]\n"
"} \n";
configure(config, CONTROL_RESULT_SUCCESS, "");
// Now verify that the shared network was indeed configured.
CfgSharedNetworks6Ptr cfg_net = CfgMgr::instance().getStagingCfg()
->getCfgSharedNetworks6();
// Two shared networks are expected.
ASSERT_TRUE(cfg_net);
const SharedNetwork6Collection* nets = cfg_net->getAll();
ASSERT_TRUE(nets);
ASSERT_EQ(2, nets->size());
// Let's check the first one.
SharedNetwork6Ptr net = nets->at(0);
ASSERT_TRUE(net);
EXPECT_EQ("alpha", net->getClientClass().get());
// The first shared network has two subnets.
const Subnet6SimpleCollection* subs = net->getAllSubnets();
ASSERT_TRUE(subs);
EXPECT_EQ(2, subs->size());
// For the first subnet, the client-class should be inherited from
// shared-network level.
Subnet6Ptr s = checkSubnet(*subs, "2001:db1::/48", 1, 2, 3, 4);
ASSERT_TRUE(s);
EXPECT_EQ("alpha", s->getClientClass().get());
// For the second subnet, the values are overridden on subnet level.
// The value should not be inherited.
s = checkSubnet(*subs, "2001:db2::/48", 1, 2, 3, 4);
ASSERT_TRUE(s);
EXPECT_EQ("beta", s->getClientClass().get()); // beta defined on subnet level
// Ok, now check the second shared network. It doesn't have
// anything defined on shared-network or subnet level, so
// everything should have default values.
net = nets->at(1);
ASSERT_TRUE(net);
subs = net->getAllSubnets();
ASSERT_TRUE(subs);
EXPECT_EQ(1, subs->size());
// This subnet should derive its renew-timer from global scope.
s = checkSubnet(*subs, "2001:db3::/48", 1, 2, 3, 4);
EXPECT_TRUE(s->getClientClass().empty());
}
#endif
// Tests if rapid-commit is derived properly.
TEST_F(Dhcp6ParserTest, sharedNetworksRapidCommit) {
@ -7686,7 +7594,7 @@ TEST_F(Dhcp6ParserTest, sharedNetworksRapidCommit) {
" \"id\": 2, \n"
" \"subnet\": \"2001:db2::/48\",\n"
" \"pools\": [ { \"pool\": \"2001:db2::/64\" } ],\n"
" \"client-class\": \"beta\"\n"
" \"client-classes\": [ \"beta\" ]\n"
" }\n"
" ]\n"
" },\n"
@ -7760,7 +7668,7 @@ TEST_F(Dhcp6ParserTest, sharedNetworksRapidCommitMix) {
" \"subnet\": \"2001:db2::/48\",\n"
" \"rapid-commit\": false,\n"
" \"pools\": [ { \"pool\": \"2001:db2::/64\" } ],\n"
" \"client-class\": \"beta\"\n"
" \"client-classes\": [ \"beta\" ]\n"
" }\n"
" ]\n"
" } ]\n"
@ -9282,4 +9190,99 @@ TEST_F(Dhcp6ParserTest, deprecatedOnlyIfRequiredCheck) {
" 'only-in-additional-list'. Use only the latter.");
}
// This test verifies that deprecated client-class
// gets handled properly.
TEST_F(Dhcp6ParserTest, deprecatedClientClassesCheck) {
// Verify that require-client-classes gets translated
// to evaluate-additional-classes.
std::string config = "{ " + genIfaceConfig() + ","
R"^(
"rebind-timer": 2000,
"renew-timer": 1000,
"shared-networks":[{
"name": "net1",
"client-class": "one",
"subnet6": [{
"client-class": "two",
"pools": [{
"pool": "2001:db8::/64",
"client-class": "three",
}],
"pd-pools": [{
"prefix": "3001:db8::",
"prefix-len": 56,
"delegated-len": 64,
"client-class": "four",
}],
"id": 1,
"subnet": "2001:db8::/64"
}],
}],
"valid-lifetime": 400
})^";
ConstElementPtr json;
ASSERT_NO_THROW(json = parseDHCP6(config));
extractConfig(config);
ConstElementPtr status;
ASSERT_NO_THROW(status = configureDhcp6Server(srv_, json));
checkResult(status, 0);
SharedNetwork6Ptr network = CfgMgr::instance().getStagingCfg()->
getCfgSharedNetworks6()->getByName("net1");
ASSERT_TRUE(network);
auto& net_class_list = network->getClientClasses();
ASSERT_EQ(1, net_class_list.size());
auto cclasses = net_class_list.begin();
EXPECT_EQ(*cclasses, "one");
auto subnet = CfgMgr::instance().getStagingCfg()->getCfgSubnets6()->getBySubnetId(1);
ASSERT_TRUE(subnet);
auto& sub_class_list = subnet->getClientClasses();
ASSERT_EQ(1, sub_class_list.size());
cclasses = sub_class_list.begin();
EXPECT_EQ(*cclasses, "two");
PoolPtr pool = subnet->getPool(Lease::TYPE_NA, IOAddress("2001:db8::"), false);
ASSERT_TRUE(pool);
auto& pool_class_list = pool->getClientClasses();
ASSERT_EQ(1, pool_class_list.size());
cclasses = pool_class_list.begin();
EXPECT_EQ(*cclasses, "three");
pool = subnet->getPool(Lease::TYPE_PD, IOAddress("3001:db8::"), false);
ASSERT_TRUE(pool);
auto& pd_pool_class_list = pool->getClientClasses();
ASSERT_EQ(1, pd_pool_class_list.size());
cclasses = pd_pool_class_list.begin();
EXPECT_EQ(*cclasses, "four");
// Now verify that users cannot specify both.
config = "{ " + genIfaceConfig() + ","
R"^(
"rebind-timer": 2000,
"renew-timer": 1000,
"subnet6": [{
"client-class": "foo",
"client-classes": [ "bar" ],
"pools": [{ "pool": "2001:db8::/64" }],
"id": 1,
"subnet": "2001:db8::/64"
}],
"valid-lifetime": 400
})^";
ASSERT_NO_THROW(json = parseDHCP6(config));
ASSERT_NO_THROW(status = configureDhcp6Server(srv_, json));
checkResult(status, 1,
"subnet configuration failed: cannot specify both 'client-class'"
" and 'client-classes'. Use only the latter.");
}
} // namespace

View File

@ -1157,7 +1157,7 @@ const char* EXTRACTED_CONFIGS[] = {
" \"renew-timer\": 1000,\n"
" \"subnet6\": [\n"
" {\n"
" \"client-class\": \"alpha\",\n"
" \"client-classes\": [ \"alpha\" ],\n"
" \"id\": 1,\n"
" \"pools\": [\n"
" {\n"
@ -1167,7 +1167,7 @@ const char* EXTRACTED_CONFIGS[] = {
" \"subnet\": \"2001:db8:1::/64\"\n"
" },\n"
" {\n"
" \"client-class\": \"beta\",\n"
" \"client-classes\": [ \"beta\" ],\n"
" \"id\": 2,\n"
" \"pools\": [\n"
" {\n"
@ -1177,7 +1177,7 @@ const char* EXTRACTED_CONFIGS[] = {
" \"subnet\": \"2001:db8:2::/64\"\n"
" },\n"
" {\n"
" \"client-class\": \"gamma\",\n"
" \"client-classes\": [ \"gamma\" ],\n"
" \"id\": 3,\n"
" \"pools\": [\n"
" {\n"
@ -1212,15 +1212,15 @@ const char* EXTRACTED_CONFIGS[] = {
" \"id\": 1,\n"
" \"pools\": [\n"
" {\n"
" \"client-class\": \"alpha\",\n"
" \"client-classes\": [ \"alpha\" ],\n"
" \"pool\": \"2001:db8:1::/80\"\n"
" },\n"
" {\n"
" \"client-class\": \"beta\",\n"
" \"client-classes\": [ \"beta\" ],\n"
" \"pool\": \"2001:db8:2::/80\"\n"
" },\n"
" {\n"
" \"client-class\": \"gamma\",\n"
" \"client-classes\": [ \"gamma\" ],\n"
" \"pool\": \"2001:db8:3::/80\"\n"
" },\n"
" {\n"
@ -1246,19 +1246,19 @@ const char* EXTRACTED_CONFIGS[] = {
" \"id\": 1,\n"
" \"pd-pools\": [\n"
" {\n"
" \"client-class\": \"alpha\",\n"
" \"client-classes\": [ \"alpha\" ],\n"
" \"delegated-len\": 64,\n"
" \"prefix\": \"2001:db8:1::\",\n"
" \"prefix-len\": 48\n"
" },\n"
" {\n"
" \"client-class\": \"beta\",\n"
" \"client-classes\": [ \"beta\" ],\n"
" \"delegated-len\": 64,\n"
" \"prefix\": \"2001:db8:2::\",\n"
" \"prefix-len\": 48\n"
" },\n"
" {\n"
" \"client-class\": \"gamma\",\n"
" \"client-classes\": [ \"gamma\" ],\n"
" \"delegated-len\": 64,\n"
" \"prefix\": \"2001:db8:3::\",\n"
" \"prefix-len\": 48\n"
@ -7670,7 +7670,7 @@ const char* UNPARSED_CONFIGS[] = {
" {\n"
" \"allocator\": \"iterative\",\n"
" \"calculate-tee-times\": true,\n"
" \"client-class\": \"alpha\",\n"
" \"client-classes\": [ \"alpha\" ],\n"
" \"id\": 1,\n"
" \"max-preferred-lifetime\": 3000,\n"
" \"max-valid-lifetime\": 4000,\n"
@ -7702,7 +7702,7 @@ const char* UNPARSED_CONFIGS[] = {
" {\n"
" \"allocator\": \"iterative\",\n"
" \"calculate-tee-times\": true,\n"
" \"client-class\": \"beta\",\n"
" \"client-classes\": [ \"beta\" ],\n"
" \"id\": 2,\n"
" \"max-preferred-lifetime\": 3000,\n"
" \"max-valid-lifetime\": 4000,\n"
@ -7734,7 +7734,7 @@ const char* UNPARSED_CONFIGS[] = {
" {\n"
" \"allocator\": \"iterative\",\n"
" \"calculate-tee-times\": true,\n"
" \"client-class\": \"gamma\",\n"
" \"client-classes\": [ \"gamma\" ],\n"
" \"id\": 3,\n"
" \"max-preferred-lifetime\": 3000,\n"
" \"max-valid-lifetime\": 4000,\n"
@ -7898,17 +7898,17 @@ const char* UNPARSED_CONFIGS[] = {
" \"pd-pools\": [ ],\n"
" \"pools\": [\n"
" {\n"
" \"client-class\": \"alpha\",\n"
" \"client-classes\": [ \"alpha\" ],\n"
" \"option-data\": [ ],\n"
" \"pool\": \"2001:db8:1::/80\"\n"
" },\n"
" {\n"
" \"client-class\": \"beta\",\n"
" \"client-classes\": [ \"beta\" ],\n"
" \"option-data\": [ ],\n"
" \"pool\": \"2001:db8:2::/80\"\n"
" },\n"
" {\n"
" \"client-class\": \"gamma\",\n"
" \"client-classes\": [ \"gamma\" ],\n"
" \"option-data\": [ ],\n"
" \"pool\": \"2001:db8:3::/80\"\n"
" },\n"
@ -8034,21 +8034,21 @@ const char* UNPARSED_CONFIGS[] = {
" \"pd-allocator\": \"iterative\",\n"
" \"pd-pools\": [\n"
" {\n"
" \"client-class\": \"alpha\",\n"
" \"client-classes\": [ \"alpha\" ],\n"
" \"delegated-len\": 64,\n"
" \"option-data\": [ ],\n"
" \"prefix\": \"2001:db8:1::\",\n"
" \"prefix-len\": 48\n"
" },\n"
" {\n"
" \"client-class\": \"beta\",\n"
" \"client-classes\": [ \"beta\" ],\n"
" \"delegated-len\": 64,\n"
" \"option-data\": [ ],\n"
" \"prefix\": \"2001:db8:2::\",\n"
" \"prefix-len\": 48\n"
" },\n"
" {\n"
" \"client-class\": \"gamma\",\n"
" \"client-classes\": [ \"gamma\" ],\n"
" \"delegated-len\": 64,\n"
" \"option-data\": [ ],\n"
" \"prefix\": \"2001:db8:3::\",\n"

View File

@ -473,7 +473,7 @@ const char* CONFIGS[] = {
" \"pools\": ["
" {"
" \"pool\": \"2001:db8:1::10-2001:db8:1::11\","
" \"client-class\": \"reserved_class\""
" \"client-classes\": [ \"reserved_class\" ]"
" }"
" ],\n"
" \"interface\": \"eth0\"\n"
@ -484,7 +484,7 @@ const char* CONFIGS[] = {
" \"pools\": ["
" {"
" \"pool\": \"2001:db8:2::10-2001:db8:2::11\","
" \"client-class\": \"unreserved_class\""
" \"client-classes\": [ \"unreserved_class\" ]"
" }"
" ],\n"
" \"interface\": \"eth0\"\n"
@ -522,7 +522,7 @@ const char* CONFIGS[] = {
" \"subnet6\": [\n"
" {\n"
" \"subnet\": \"2001:db8:1::/64\", \n"
" \"client-class\": \"reserved_class\","
" \"client-classes\": [ \"reserved_class\" ],"
" \"id\": 10,"
" \"pools\": ["
" {"
@ -533,7 +533,7 @@ const char* CONFIGS[] = {
" },\n"
" {\n"
" \"subnet\": \"2001:db8:2::/64\", \n"
" \"client-class\": \"unreserved_class\","
" \"client-classes\": [ \"unreserved_class\" ],"
" \"id\": 11,"
" \"pools\": ["
" {"
@ -571,11 +571,11 @@ const char* CONFIGS[] = {
" \"pools\": ["
" {"
" \"pool\": \"2001:db8:1::10-2001:db8:1::11\","
" \"client-class\": \"reserved_class\""
" \"client-classes\": [ \"reserved_class\" ]"
" },"
" {"
" \"pool\": \"2001:db8:1::20-2001:db8:1::21\","
" \"client-class\": \"unreserved_class\""
" \"client-classes\": [ \"unreserved_class\" ]"
" }"
" ],\n"
" \"interface\": \"eth0\"\n"

View File

@ -158,7 +158,7 @@ const char* NETWORKS_CONFIG[] = {
" \"pool\": \"2001:db8:1::20 - 2001:db8:1::20\""
" }"
" ],"
" \"client-class\": \"a-devices\""
" \"client-classes\": [ \"a-devices\" ]"
" },"
" {"
" \"subnet\": \"2001:db8:2::/64\","
@ -201,7 +201,7 @@ const char* NETWORKS_CONFIG[] = {
" \"pool\": \"2001:db8:1::20 - 2001:db8:1::20\""
" }"
" ],"
" \"client-class\": \"a-devices\""
" \"client-classes\": [ \"a-devices\" ]"
" },"
" {"
" \"subnet\": \"2001:db8:2::/64\","
@ -211,7 +211,7 @@ const char* NETWORKS_CONFIG[] = {
" \"pool\": \"2001:db8:2::20 - 2001:db8:2::20\""
" }"
" ],"
" \"client-class\": \"b-devices\""
" \"client-classes\": [ \"b-devices\" ]"
" }"
" ]"
" }"
@ -346,7 +346,7 @@ const char* NETWORKS_CONFIG[] = {
" \"pool\": \"2001:db8:1::1 - 2001:db8:1::64\""
" }"
" ],"
" \"client-class\": \"a-devices\","
" \"client-classes\": [ \"a-devices\" ],"
" \"reservations\": ["
" {"
" \"duid\": \"00:03:00:01:aa:bb:cc:dd:ee:ff\","
@ -633,7 +633,7 @@ const char* NETWORKS_CONFIG[] = {
" {"
" \"name\": \"frog\","
" \"interface\": \"eth1\","
" \"client-class\": \"a-devices\","
" \"client-classes\": [ \"a-devices\" ],"
" \"subnet6\": ["
" {"
" \"subnet\": \"2001:db8:1::/64\","
@ -649,7 +649,7 @@ const char* NETWORKS_CONFIG[] = {
" {"
" \"name\": \"dog\","
" \"interface\": \"eth1\","
" \"client-class\": \"b-devices\","
" \"client-classes\": [ \"b-devices\" ],"
" \"subnet6\": ["
" {"
" \"subnet\": \"2001:db8:2::/64\","
@ -697,7 +697,7 @@ const char* NETWORKS_CONFIG[] = {
" \"pool\": \"2001:db8:2::20 - 2001:db8:2::20\""
" }"
" ],"
" \"client-class\": \"b-devices\""
" \"client-classes\": [ \"b-devices\" ]"
" }"
" ]"
" }"
@ -985,7 +985,7 @@ const char* NETWORKS_CONFIG[] = {
" \"pools\": ["
" {"
" \"pool\": \"2001:db8:1::20 - 2001:db8:1::20\","
" \"client-class\": \"a-devices\""
" \"client-classes\": [ \"a-devices\" ]"
" },"
" {"
" \"pool\": \"2001:db8:1::50 - 2001:db8:1::50\""
@ -1022,11 +1022,11 @@ const char* NETWORKS_CONFIG[] = {
" \"pools\": ["
" {"
" \"pool\": \"2001:db8:1::20 - 2001:db8:1::20\","
" \"client-class\": \"a-devices\""
" \"client-classes\": [ \"a-devices\" ]"
" },"
" {"
" \"pool\": \"2001:db8:1::50 - 2001:db8:1::50\","
" \"client-class\": \"b-devices\""
" \"client-classes\": [ \"b-devices\" ]"
" }"
" ]"
" }"
@ -1056,7 +1056,7 @@ const char* NETWORKS_CONFIG[] = {
" \"pools\": ["
" {"
" \"pool\": \"2001:db8:1::20 - 2001:db8:1::20\","
" \"client-class\": \"a-devices\""
" \"client-classes\": [ \"a-devices\" ]"
" },"
" {"
" \"pool\": \"2001:db8:1::50 - 2001:db8:1::50\""
@ -1090,11 +1090,11 @@ const char* NETWORKS_CONFIG[] = {
" \"pools\": ["
" {"
" \"pool\": \"2001:db8:1::20 - 2001:db8:1::20\","
" \"client-class\": \"a-devices\""
" \"client-classes\": [ \"a-devices\" ]"
" },"
" {"
" \"pool\": \"2001:db8:1::50 - 2001:db8:1::50\","
" \"client-class\": \"b-devices\""
" \"client-classes\": [ \"b-devices\" ]"
" }"
" ]"
" }"

View File

@ -53,8 +53,7 @@ const SimpleKeywords SimpleParser6::GLOBAL6_PARAMETERS = {
{ "mac-sources", Element::list },
{ "relay-supplied-options", Element::list },
{ "host-reservation-identifiers", Element::list },
{ "client-class", Element::string },
{ "client-classes", Element::string },
{ "client-classes", Element::list },
{ "option-def", Element::list },
{ "option-data", Element::list },
{ "hooks-libraries", Element::list },