]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
effective config: specific prefetch/trigger case
authorColin Vidal <colin@isc.org>
Thu, 16 Oct 2025 15:00:43 +0000 (17:00 +0200)
committerEvan Hunt <each@isc.org>
Wed, 29 Oct 2025 20:55:04 +0000 (13:55 -0700)
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.

bin/named/server.c
lib/isccfg/namedconf.c

index 595043d4665a7af6aeb945ed3a5b9da6f7e4160e..5aec16d3798ce911da244135c14157d82e4e64e7 100644 (file)
@@ -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
index ee632a98e8891f2d033d8b882dac63f683c80135..b302daf5e35981c3a52dd5711eb9e14c4f54808b 100644 (file)
@@ -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 },
        /*