From: Aram Sargsyan Date: Tue, 19 Aug 2025 09:10:06 +0000 (+0000) Subject: Implement '-T slowrpz' named testing option X-Git-Tag: v9.21.12~29^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e718dd220ff7f49361b4b78d5b4dc17287d1941;p=thirdparty%2Fbind9.git Implement '-T slowrpz' named testing option When used, named processes RPZ zones slowly. Useful for system tests. --- diff --git a/bin/named/main.c b/bin/named/main.c index 7a848284295..3ec1c2f0e12 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -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); } diff --git a/bin/named/server.c b/bin/named/server.c index 30a115cfa05..b10d015f82d 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -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)) { diff --git a/lib/dns/include/dns/rpz.h b/lib/dns/include/dns/rpz.h index 9406f691400..8dac8746877 100644 --- a/lib/dns/include/dns/rpz.h +++ b/lib/dns/include/dns/rpz.h @@ -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; }; diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index b59c560acaa..a2f34528683 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -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) { diff --git a/lib/ns/include/ns/server.h b/lib/ns/include/ns/server.h index 822ec81399c..32f4e1d66bc 100644 --- a/lib/ns/include/ns/server.h +++ b/lib/ns/include/ns/server.h @@ -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.