]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
fix "response-padding" configuration and remove optionmaps
authorEvan Hunt <each@isc.org>
Wed, 29 Oct 2025 04:33:03 +0000 (21:33 -0700)
committerEvan Hunt <each@isc.org>
Wed, 29 Oct 2025 18:31:38 +0000 (11:31 -0700)
Add a default "response-padding" option in the global defaults,
to disable the option, and simplify the configuration code so that
looks at the global defaults if the option is not set in named.conf.

This enables us to remove the 'optionmaps' variable in configure_view(),
which was used for options that only look in named.conf.

(cherry picked from commit cf409e814f13c932d92fae5d85ddd16ac7ebfdc0)

bin/named/config.c
bin/named/server.c

index b11f63efbb73e13ea7004ce8910de0fbf63177a1..06fbc78ac9c6e536827507fbc4046300549b2acf 100644 (file)
@@ -188,6 +188,7 @@ options {\n\
        parental-source *;\n\
        parental-source-v6 *;\n\
        provide-ixfr true;\n\
+       response-padding { none; } block-size 0;\n\
        qname-minimization relaxed;\n\
        query-source address *;\n\
        query-source-v6 address *;\n\
index d176f3432628b1b3d5c18470fa7aed087f6f8c7f..973c15fc3ab9984a4c119973766d84c11b133b07 100644 (file)
@@ -4166,7 +4166,6 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
               bool first_time) {
        const cfg_obj_t *maps[4];
        const cfg_obj_t *cfgmaps[3];
-       const cfg_obj_t *optionmaps[3];
        const cfg_obj_t *options = NULL;
        const cfg_obj_t *voptions = NULL;
        const cfg_obj_t *forwardtype;
@@ -4225,6 +4224,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
        const char *qminmode = NULL;
        dns_adb_t *adb = NULL;
        bool oldcache = false;
+       uint32_t padding;
 
        REQUIRE(DNS_VIEW_VALID(view));
 
@@ -4234,27 +4234,24 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
 
        /*
         * maps: view options, options, defaults
-        * cfgmaps: view options, config
-        * optionmaps: view options, options
+        * cfgmaps: view options, top-level config
         */
        if (vconfig != NULL) {
                voptions = cfg_tuple_get(vconfig, "options");
                maps[i++] = voptions;
-               optionmaps[j++] = voptions;
                cfgmaps[k++] = voptions;
        }
        if (options != NULL) {
                maps[i++] = options;
-               optionmaps[j++] = options;
        }
 
        maps[i++] = named_g_defaults;
        maps[i] = NULL;
-       optionmaps[j] = NULL;
+
        if (config != NULL) {
-               cfgmaps[k++] = config;
+               cfgmaps[j++] = config;
        }
-       cfgmaps[k] = NULL;
+       cfgmaps[j] = NULL;
 
        /*
         * Set the view's port number for outgoing queries.
@@ -5617,22 +5614,19 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
        if (view->pad_acl != NULL) {
                dns_acl_detach(&view->pad_acl);
        }
-       result = named_config_get(optionmaps, "response-padding", &obj);
-       if (result == ISC_R_SUCCESS) {
-               const cfg_obj_t *padobj = cfg_tuple_get(obj, "block-size");
-               const cfg_obj_t *aclobj = cfg_tuple_get(obj, "acl");
-               uint32_t padding = cfg_obj_asuint32(padobj);
-
-               if (padding > 512U) {
-                       cfg_obj_log(obj, named_g_lctx, ISC_LOG_WARNING,
-                                   "response-padding block-size cannot "
-                                   "exceed 512: lowering");
-                       padding = 512U;
-               }
-               view->padding = (uint16_t)padding;
-               CHECK(cfg_acl_fromconfig(aclobj, config, named_g_lctx, actx,
-                                        named_g_mctx, 0, &view->pad_acl));
-       }
+       result = named_config_get(maps, "response-padding", &obj);
+       INSIST(result == ISC_R_SUCCESS);
+       padding = cfg_obj_asuint32(cfg_tuple_get(obj, "block-size"));
+       if (padding > 512U) {
+               cfg_obj_log(obj, named_g_lctx, ISC_LOG_WARNING,
+                           "response-padding block-size cannot "
+                           "exceed 512: lowering");
+               padding = 512U;
+       }
+       view->padding = (uint16_t)padding;
+       CHECK(cfg_acl_fromconfig(cfg_tuple_get(obj, "acl"), config,
+                                named_g_lctx, actx, named_g_mctx, 0,
+                                &view->pad_acl));
 
        obj = NULL;
        result = named_config_get(maps, "require-server-cookie", &obj);