]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Gracefully handle list of integers in YAML
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 6 Jun 2025 09:01:10 +0000 (11:01 +0200)
committerOliver Chen <oliver.chen@nokia-sbell.com>
Wed, 11 Jun 2025 00:11:19 +0000 (00:11 +0000)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsdistdist/dnsdist-configuration-yaml.cc
pdns/dnsdistdist/dnsdist-rust-lib/dnsdist-settings-generator.py
pdns/dnsdistdist/dnsdist-settings-definitions.yml
pdns/dnsdistdist/docs/reference/yaml-settings.rst

index cb0b2d719acdb3f1254039cc51ec72055975cec8..87180fb859d8341fc0ca6b6df58957ab46928bde 100644 (file)
@@ -1096,8 +1096,7 @@ bool loadConfigurationFromFile(const std::string& fileName, [[maybe_unused]] boo
       if (cache.maximum_entry_size >= sizeof(dnsheader)) {
         settings.d_maximumEntrySize = cache.maximum_entry_size;
       }
-      for (const auto& rankstr : cache.payload_ranks) {
-        auto rank = pdns::checked_stoi<uint16_t>(std::string(rankstr));
+      for (const auto& rank : cache.payload_ranks) {
         if (rank < 512 || rank > settings.d_maximumEntrySize) {
           continue;
         }
index 5ab4362af33233db841e76e0af55f814d19140a4..15c3a1e50081d57c456e95d6420bb7f3fa69d2e0 100644 (file)
@@ -77,7 +77,9 @@ def is_value_rust_default(rust_type, value):
     if rust_type == 'String':
         return value == ''
     if rust_type == 'Vec<String>':
-        return value == ''
+        return value == '' or value == '[]'
+    if is_vector_of(rust_type):
+        return value == '[]'
     return False
 
 def get_rust_field_name(name):
index ca6d047b8d0ce9badc52696678a3b141ac8abd72..7a60899eeebea3927047abdf6cd6bac42edbc1ac 100644 (file)
@@ -1937,8 +1937,8 @@ packet_cache:
       default: ""
       description: "Extra list of EDNS option codes to skip when hashing the packet (if ``cookie_hashing`` above is false, EDNS cookie option number will be added to this list internally)"
     - name: "payload_ranks"
-      type: "Vec<String>"
-      default: ""
+      type: "Vec<u16>"
+      default: "[]"
       description: "List of payload size used when hashing the packet. The list will be sorted in ascend order and searched to find a lower bound value for the payload size in the packet. If found then it will be used for packet hashing. Values less than 512 or greater than ``maximum_entry_size`` above will be discarded. This option is to enable cache entry sharing between clients using different payload sizes when needed"
 
 proxy_protocol:
index f6be755cbc84cca2a75fc7b693ec8f1d19f3b679..7b39250dc60430735b46c644a255a67915f5dad2 100644 (file)
@@ -744,6 +744,7 @@ Packet-cache settings
 - **cookie_hashing**: Boolean ``(false)`` - If true, EDNS Cookie values will be hashed, resulting in separate entries for different cookies in the packet cache. This is required if the backend is sending answers with EDNS Cookies, otherwise a client might receive an answer with the wrong cookie
 - **maximum_entry_size**: Unsigned integer ``(4096)`` - The maximum size, in bytes, of a DNS packet that can be inserted into the packet cache
 - **options_to_skip**: Sequence of String ``("")`` - Extra list of EDNS option codes to skip when hashing the packet (if ``cookie_hashing`` above is false, EDNS cookie option number will be added to this list internally)
+- **payload_ranks**: Sequence of Unsigned integer ``([])`` - List of payload size used when hashing the packet. The list will be sorted in ascend order and searched to find a lower bound value for the payload size in the packet. If found then it will be used for packet hashing. Values less than 512 or greater than ``maximum_entry_size`` above will be discarded. This option is to enable cache entry sharing between clients using different payload sizes when needed
 
 
 .. _yaml-settings-PoolConfiguration: