]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Implement '-T slowrpz' named testing option
authorAram Sargsyan <aram@isc.org>
Tue, 19 Aug 2025 09:10:06 +0000 (09:10 +0000)
committerArаm Sаrgsyаn <aram@isc.org>
Fri, 22 Aug 2025 16:31:17 +0000 (16:31 +0000)
When used, named processes RPZ zones slowly. Useful for system tests.

bin/named/main.c
bin/named/server.c
lib/dns/include/dns/rpz.h
lib/dns/rpz.c
lib/ns/include/ns/server.h

index 7a8482842953d7ac42ae4e0d6c685eb2179d72f0..3ec1c2f0e12ac21905a86d65bd8ddaf9bd36f05c 100644 (file)
@@ -139,6 +139,7 @@ static bool noedns = false;
 static bool nonearest = false;
 static bool nosoa = false;
 static bool notcp = false;
+static bool rpzslow = false;
 static bool sigvalinsecs = false;
 static bool transferinsecs = false;
 static bool transferslowly = false;
@@ -724,6 +725,8 @@ parse_T_opt(char *option) {
                if (dns_zone_mkey_month < dns_zone_mkey_day) {
                        named_main_earlyfatal("bad mkeytimer");
                }
+       } else if (!strcmp(option, "rpzslow")) {
+               rpzslow = true;
        } else if (!strcmp(option, "sigvalinsecs")) {
                sigvalinsecs = true;
        } else if (!strcmp(option, "transferinsecs")) {
@@ -1273,6 +1276,9 @@ setup(void) {
        if (notcp) {
                ns_server_setoption(sctx, NS_SERVER_NOTCP, true);
        }
+       if (rpzslow) {
+               ns_server_setoption(sctx, NS_SERVER_RPZSLOW, true);
+       }
        if (sigvalinsecs) {
                ns_server_setoption(sctx, NS_SERVER_SIGVALINSECS, true);
        }
index 30a115cfa05e93720b1fec135b396981432d9e15..b10d015f82d864eaa432ff0ad9d5917f5af0ca3d 100644 (file)
@@ -2181,6 +2181,8 @@ configure_rpz(dns_view_t *view, dns_view_t *pview, const cfg_obj_t *rpz_obj,
 
        zones->p.nsip_on = nsip_on;
        zones->p.nsdname_on = nsdname_on;
+       zones->p.slow_mode = ns_server_getoption(named_g_server->sctx,
+                                                NS_SERVER_RPZSLOW);
 
        sub_obj = cfg_tuple_get(rpz_obj, "recursive-only");
        if (!cfg_obj_isvoid(sub_obj) && !cfg_obj_asboolean(sub_obj)) {
index 9406f691400515ff3fdaf53e55d191590e334a6f..8dac8746877db94f262e9301633161dd38154a4e 100644 (file)
@@ -205,6 +205,7 @@ struct dns_rpz_popt {
        bool            nsip_wait_recurse;
        bool            nsdname_wait_recurse;
        bool            servfail_until_ready;
+       bool            slow_mode; /* Used for system tests with '-T rpzslow' */
        unsigned int    min_ns_labels;
        dns_rpz_num_t   num_zones;
 };
index b59c560acaaaa5bcc356b322db11586034b0a966..a2f34528683b622fc40acc2c93df28c9ec37fe20 100644 (file)
@@ -32,6 +32,7 @@
 #include <isc/rwlock.h>
 #include <isc/string.h>
 #include <isc/util.h>
+#include <isc/uv.h>
 #include <isc/work.h>
 
 #include <dns/db.h>
@@ -1705,6 +1706,7 @@ update_nodes(dns_rpz_zone_t *rpz, isc_ht_t *newnodes) {
        dns_name_t *name = NULL;
        dns_fixedname_t fixname;
        char domain[DNS_NAME_FORMATSIZE];
+       bool slow_mode;
 
        dns_name_format(&rpz->origin, domain, DNS_NAME_FORMATSIZE);
 
@@ -1728,6 +1730,10 @@ update_nodes(dns_rpz_zone_t *rpz, isc_ht_t *newnodes) {
                goto cleanup;
        }
 
+       LOCK(&rpz->rpzs->maint_lock);
+       slow_mode = rpz->rpzs->p.slow_mode;
+       UNLOCK(&rpz->rpzs->maint_lock);
+
        while (result == ISC_R_SUCCESS) {
                char namebuf[DNS_NAME_FORMATSIZE];
                dns_rdatasetiter_t *rdsiter = NULL;
@@ -1828,6 +1834,10 @@ update_nodes(dns_rpz_zone_t *rpz, isc_ht_t *newnodes) {
 
        next:
                result = dns_dbiterator_next(updbit);
+
+               if (slow_mode) {
+                       uv_sleep(100);
+               }
        }
        INSIST(result != ISC_R_SUCCESS);
        if (result == ISC_R_NOMORE) {
index 822ec81399c6f28fa06b2f33c98d116c25ac3825..32f4e1d66bc8b87b541739e401821c111408edf2 100644 (file)
@@ -51,6 +51,7 @@
 #define NS_SERVER_TRANSFERSTUCK            0x00020000U /*%< -T transferstuck */
 #define NS_SERVER_LOGRESPONSES     0x00040000U /*%< log responses */
 #define NS_SERVER_COOKIEALWAYSVALID 0x00080000U /*%< -T cookiealwaysvalid */
+#define NS_SERVER_RPZSLOW          0x00100000U /*%< -T rpzslow */
 
 /*%
  * Type for callback function to get hostname.