From: Remi Gacogne Date: Fri, 6 Jun 2025 09:01:10 +0000 (+0200) Subject: dnsdist: Gracefully handle list of integers in YAML X-Git-Tag: dnsdist-2.0.0-beta1~36^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ba4d8fb953906974b3f3175f4593b1dfed1049c1;p=thirdparty%2Fpdns.git dnsdist: Gracefully handle list of integers in YAML Signed-off-by: Remi Gacogne --- diff --git a/pdns/dnsdistdist/dnsdist-configuration-yaml.cc b/pdns/dnsdistdist/dnsdist-configuration-yaml.cc index cb0b2d719a..87180fb859 100644 --- a/pdns/dnsdistdist/dnsdist-configuration-yaml.cc +++ b/pdns/dnsdistdist/dnsdist-configuration-yaml.cc @@ -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(std::string(rankstr)); + for (const auto& rank : cache.payload_ranks) { if (rank < 512 || rank > settings.d_maximumEntrySize) { continue; } diff --git a/pdns/dnsdistdist/dnsdist-rust-lib/dnsdist-settings-generator.py b/pdns/dnsdistdist/dnsdist-rust-lib/dnsdist-settings-generator.py index 5ab4362af3..15c3a1e500 100644 --- a/pdns/dnsdistdist/dnsdist-rust-lib/dnsdist-settings-generator.py +++ b/pdns/dnsdistdist/dnsdist-rust-lib/dnsdist-settings-generator.py @@ -77,7 +77,9 @@ def is_value_rust_default(rust_type, value): if rust_type == 'String': return value == '' if rust_type == 'Vec': - return value == '' + return value == '' or value == '[]' + if is_vector_of(rust_type): + return value == '[]' return False def get_rust_field_name(name): diff --git a/pdns/dnsdistdist/dnsdist-settings-definitions.yml b/pdns/dnsdistdist/dnsdist-settings-definitions.yml index ca6d047b8d..7a60899eee 100644 --- a/pdns/dnsdistdist/dnsdist-settings-definitions.yml +++ b/pdns/dnsdistdist/dnsdist-settings-definitions.yml @@ -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" - default: "" + type: "Vec" + 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: diff --git a/pdns/dnsdistdist/docs/reference/yaml-settings.rst b/pdns/dnsdistdist/docs/reference/yaml-settings.rst index f6be755cbc..7b39250dc6 100644 --- a/pdns/dnsdistdist/docs/reference/yaml-settings.rst +++ b/pdns/dnsdistdist/docs/reference/yaml-settings.rst @@ -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: