]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3424] fixed missing pool-id in pd-pool
authorRazvan Becheriu <razvan@isc.org>
Wed, 22 May 2024 14:57:14 +0000 (17:57 +0300)
committerRazvan Becheriu <razvan@isc.org>
Fri, 24 May 2024 10:43:20 +0000 (13:43 +0300)
doc/examples/kea6/all-keys-netconf.json
doc/examples/kea6/all-keys.json
src/bin/dhcp6/dhcp6_lexer.ll
src/bin/dhcp6/dhcp6_parser.yy
src/lib/dhcpsrv/parsers/dhcp_parsers.cc
src/lib/yang/translator_pd_pool.cc

index efc8e2523515e2a5ea6d906230a9f7b501eb9926..2466dd123081832cf6abb9c5dcf10367380d6472 100644 (file)
 
                                 // List of client classes which must be evaluated
                                 // when this prefix pool is selected for client assignments.
-                                "require-client-classes": []
+                                "require-client-classes": [],
+
+                                // PD-pool identifier used to enable statistics for this pd-pool.
+                                // The pd-pool ID does not need to be unique within the subnet
+                                // or across subnets.
+                                // If not unconfigured, it defaults to 0. The statistics
+                                // regarding this pd-pool will be combined with the other statistics
+                                // of all other pd-pools with the same pd-pool ID in this subnet.
+                                "pool-id": 1
+                            },
+                            {
+                                // Length of prefixes delegated to clients.
+                                "delegated-len": 64,
+
+                                // Prefix range (address) used for client assignments.
+                                "prefix": "2001:db8:2::",
+
+                                // Prefix range (length) used for client assignments.
+                                "prefix-len": 48
                             }
                         ],
 
index cde5ee61e50b3db76447d0f6d8770e623f0ed7fa..9ccbfc2d84c3e7bf6b66b4a0f10f302c3ab8f59f 100644 (file)
 
                                 // List of client classes which must be evaluated
                                 // when this prefix pool is selected for client assignments.
-                                "require-client-classes": []
+                                "require-client-classes": [],
+
+                                // PD-pool identifier used to enable statistics for this pd-pool.
+                                // The pd-pool ID does not need to be unique within the subnet
+                                // or across subnets.
+                                // If not unconfigured, it defaults to 0. The statistics
+                                // regarding this pd-pool will be combined with the other statistics
+                                // of all other pd-pools with the same pd-pool ID in this subnet.
+                                "pool-id": 1
+                            },
+                            {
+                                // Length of prefixes delegated to clients.
+                                "delegated-len": 64,
+
+                                // Prefix range (address) used for client assignments.
+                                "prefix": "2001:db8:2::",
+
+                                // Prefix range (length) used for client assignments.
+                                "prefix-len": 48
                             }
                         ],
 
index 8ff67365713814d1e88e525396df601c863b4f05..6c13cdfb52c059a568fadd10ab729a25565bb029 100644 (file)
@@ -1301,6 +1301,7 @@ ControlCharacterFill            [^"\\]|\\["\\/bfnrtu]
 \"pool-id\" {
     switch(driver.ctx_) {
     case isc::dhcp::Parser6Context::POOLS:
+    case isc::dhcp::Parser6Context::PD_POOLS:
         return isc::dhcp::Dhcp6Parser::make_POOL_ID(driver.loc_);
     default:
         return isc::dhcp::Dhcp6Parser::make_STRING("pool-id", driver.loc_);
index e4ccde453e5e8d346fa7574f754e191a28707881..834dfbca25c5767990aac909b510a322a4c94e36 100644 (file)
@@ -2254,6 +2254,7 @@ pd_pool_params: pd_pool_param
 pd_pool_param: pd_prefix
              | pd_prefix_len
              | pd_delegated_len
+             | pool_id
              | option_data_list
              | client_class
              | require_client_classes
index 76b7c7f661bee3ba64956d7608b6bcf2fd21bd11..45d9db3a1fab69d5339ba860e9e5fad9c40a7f6b 100644 (file)
@@ -1064,37 +1064,37 @@ PdPoolParser::PdPoolParser() {
 }
 
 void
-PdPoolParser::parse(PoolStoragePtr pools, ConstElementPtr pd_pool_,
+PdPoolParser::parse(PoolStoragePtr pools, ConstElementPtr pd_pool,
                     bool encapsulate_options) {
-    checkKeywords(SimpleParser6::PD_POOL6_PARAMETERS, pd_pool_);
+    checkKeywords(SimpleParser6::PD_POOL6_PARAMETERS, pd_pool);
 
-    std::string addr_str = getString(pd_pool_, "prefix");
+    std::string addr_str = getString(pd_pool, "prefix");
 
-    uint8_t prefix_len = getUint8(pd_pool_, "prefix-len");
+    uint8_t prefix_len = getUint8(pd_pool, "prefix-len");
 
-    uint8_t delegated_len = getUint8(pd_pool_, "delegated-len");
+    uint8_t delegated_len = getUint8(pd_pool, "delegated-len");
 
     std::string excluded_prefix_str = "::";
-    if (pd_pool_->contains("excluded-prefix")) {
-        excluded_prefix_str = getString(pd_pool_, "excluded-prefix");
+    if (pd_pool->contains("excluded-prefix")) {
+        excluded_prefix_str = getString(pd_pool, "excluded-prefix");
     }
 
     uint8_t excluded_prefix_len = 0;
-    if (pd_pool_->contains("excluded-prefix-len")) {
-        excluded_prefix_len = getUint8(pd_pool_, "excluded-prefix-len");
+    if (pd_pool->contains("excluded-prefix-len")) {
+        excluded_prefix_len = getUint8(pd_pool, "excluded-prefix-len");
     }
 
-    ConstElementPtr user_context = pd_pool_->get("user-context");
+    ConstElementPtr user_context = pd_pool->get("user-context");
     if (user_context) {
         user_context_ = user_context;
     }
 
-    ConstElementPtr client_class = pd_pool_->get("client-class");
+    ConstElementPtr client_class = pd_pool->get("client-class");
     if (client_class) {
         client_class_ = client_class;
     }
 
-    ConstElementPtr class_list = pd_pool_->get("require-client-classes");
+    ConstElementPtr class_list = pd_pool->get("require-client-classes");
 
     // Check the pool parameters. It will throw an exception if any
     // of the required parameters are invalid.
@@ -1110,7 +1110,21 @@ PdPoolParser::parse(PoolStoragePtr pools, ConstElementPtr pd_pool_,
         // aware whether they don't exist or are invalid, let's append
         // the position of the pool map element.
         isc_throw(isc::dhcp::DhcpConfigError, ex.what()
-                  << " (" << pd_pool_->getPosition() << ")");
+                  << " (" << pd_pool->getPosition() << ")");
+    }
+
+    // If there is a pool-id, store it.
+    ConstElementPtr pool_id = pd_pool->get("pool-id");
+    if (pool_id) {
+        if (pool_id->intValue() <= 0) {
+            isc_throw(BadValue, "pool-id " << pool_id->intValue() << " is not"
+                      << " a positive integer greater than 0");
+        } else if (pool_id->intValue() > numeric_limits<uint32_t>::max()) {
+            isc_throw(BadValue, "pool-id " << pool_id->intValue() << " is not"
+                      << " a 32 bit unsigned integer");
+        }
+
+        pool_->setID(pool_id->intValue());
     }
 
     // We create subnet first and then parse the options straight into the subnet's
@@ -1119,7 +1133,7 @@ PdPoolParser::parse(PoolStoragePtr pools, ConstElementPtr pd_pool_,
     // it cost performance. Second, copying options reset the isEncapsulated() flag.
     // If the options have been encapsulated we want to preserve the flag to ensure
     // they are not encapsulated several times.
-    ConstElementPtr option_data = pd_pool_->get("option-data");
+    ConstElementPtr option_data = pd_pool->get("option-data");
     if (option_data) {
         auto opts_parser = createOptionDataListParser();
         opts_parser->parse(pool_->getCfgOption(), option_data, encapsulate_options);
index d0f888050e67b99f25f32d8426c8f0b0fae38c98..b284b6ce83fc5e1ebd1c438d5ab8823a9ecd07f2 100644 (file)
@@ -151,6 +151,8 @@ TranslatorPdPool::getPdPoolKea(DataNode const& data_node) {
     checkAndGetLeaf(result, data_node, "delegated-len");
     checkAndGetLeaf(result, data_node, "require-client-classes");
 
+    checkAndGetLeaf(result, data_node, "pool-id");
+
     checkAndGetAndJsonifyLeaf(result, data_node, "user-context");
 
     ConstElementPtr options = getOptionDataList(data_node);
@@ -218,6 +220,8 @@ TranslatorPdPool::setPdPoolKea(string const& xpath, ConstElementPtr elem) {
 
     checkAndSetLeafList(elem, xpath, "require-client-classes", LeafBaseType::String);
 
+    checkAndSetLeaf(elem, xpath, "pool-id", LeafBaseType::Dec64);
+
     checkAndSetUserContext(elem, xpath);
 
     ConstElementPtr xprefix = elem->get("excluded-prefix");