From: Colin Vidal Date: Thu, 16 Oct 2025 15:00:43 +0000 (+0200) Subject: effective config: specific prefetch/trigger case X-Git-Tag: v9.21.15~22^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6643345a5babc2c3b605226d3355c930211a723f;p=thirdparty%2Fbind9.git effective config: specific prefetch/trigger case The prefetch statement can be overriden by the user, but the user might specify the prefetch without the trigger value, which needs to be pulled from the default configuration. Handle this case by directly getting the default value if needed from the default configuration when building the effective configuration tree. Also take care of keeping the values inside their bounds, and simplify the server configuration code which then just have to read effective configuration values. --- diff --git a/bin/named/server.c b/bin/named/server.c index 595043d4665..5aec16d3798 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -5176,27 +5176,8 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config, INSIST(result == ISC_R_SUCCESS); prefetch_trigger = cfg_tuple_get(obj, "trigger"); view->prefetch_trigger = cfg_obj_asuint32(prefetch_trigger); - if (view->prefetch_trigger > 10) { - view->prefetch_trigger = 10; - } prefetch_eligible = cfg_tuple_get(obj, "eligible"); - if (cfg_obj_isvoid(prefetch_eligible)) { - int m; - for (m = 1; maps[m] != NULL; m++) { - obj = NULL; - result = named_config_get(&maps[m], "prefetch", &obj); - INSIST(result == ISC_R_SUCCESS); - prefetch_eligible = cfg_tuple_get(obj, "eligible"); - if (cfg_obj_isuint32(prefetch_eligible)) { - break; - } - } - INSIST(cfg_obj_isuint32(prefetch_eligible)); - } view->prefetch_eligible = cfg_obj_asuint32(prefetch_eligible); - if (view->prefetch_eligible < view->prefetch_trigger + 6) { - view->prefetch_eligible = view->prefetch_trigger + 6; - } /* * For now, there is only one kind of trusted keys, the diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c index ee632a98e88..b302daf5e35 100644 --- a/lib/isccfg/namedconf.c +++ b/lib/isccfg/namedconf.c @@ -2222,6 +2222,34 @@ static cfg_type_t cfg_type_staleanswerclienttimeout = { staleanswerclienttimeout_enums }; +static void +prefetch_merge(cfg_obj_t *effectiveobj, const cfg_obj_t *defaultobj) { + cfg_obj_t *trigger = NULL; + cfg_obj_t *eligible = NULL; + + trigger = (cfg_obj_t *)cfg_tuple_get(effectiveobj, "trigger"); + INSIST(cfg_obj_isuint32(trigger)); + if (cfg_obj_asuint32(trigger) > 10) { + trigger->value.uint32 = 10; + } + + eligible = (cfg_obj_t *)cfg_tuple_get(effectiveobj, "eligible"); + if (cfg_obj_isvoid(eligible)) { + const cfg_obj_t *defaulteligible = NULL; + + defaulteligible = cfg_tuple_get(defaultobj, "eligible"); + INSIST(cfg_obj_isuint32(defaulteligible)); + + eligible->value.uint32 = cfg_obj_asuint32(defaulteligible); + eligible->type = &cfg_type_uint32; + } + + INSIST(cfg_obj_isuint32(eligible)); + if (cfg_obj_asuint32(eligible) < cfg_obj_asuint32(trigger) + 6) { + eligible->value.uint32 = cfg_obj_asuint32(trigger) + 6; + } +} + /*% * Clauses that can be found within the 'view' statement, * with defaults in the 'options' statement. @@ -2324,7 +2352,7 @@ static cfg_clausedef_t view_clauses[] = { { "nta-recheck", &cfg_type_duration, 0 }, { "nxdomain-redirect", &cfg_type_astring, 0 }, { "preferred-glue", &cfg_type_astring, 0 }, - { "prefetch", &cfg_type_prefetch, 0 }, + { "prefetch", &cfg_type_prefetch, 0, prefetch_merge }, { "provide-ixfr", &cfg_type_boolean, 0 }, { "qname-minimization", &cfg_type_qminmethod, 0 }, /*