]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Implement 'max-query-count'
authorMatthijs Mekking <matthijs@isc.org>
Thu, 7 Nov 2024 09:52:19 +0000 (10:52 +0100)
committerMatthijs Mekking <matthijs@isc.org>
Thu, 5 Dec 2024 13:01:57 +0000 (14:01 +0100)
Add another option to configure how many outgoing queries per
client request is allowed. The existing 'max-recursion-queries' is
per restart, this one is a global limit.

bin/named/config.c
bin/named/server.c
bin/tests/system/checkconf/good.conf.in
doc/arm/reference.rst
doc/misc/options
lib/dns/include/dns/view.h
lib/dns/resolver.c
lib/dns/view.c
lib/isccfg/namedconf.c

index 975ea4938a3be7a6bb958622c138f5dc6b789c2a..636b3393c28ce358ca42acc0a36fe68ceb4bbc72 100644 (file)
@@ -169,6 +169,7 @@ options {\n\
        max-ncache-ttl 10800; /* 3 hours */\n\
        max-recursion-depth 7;\n\
        max-recursion-queries 32;\n\
+       max-query-count 200;\n\
        max-query-restarts 11;\n\
        max-stale-ttl 86400; /* 1 day */\n\
        message-compression yes;\n\
index de1a4ba6e157f615ec6537c3e4db7016b9c32e30..085d0baea2c94f54317d96d73b9d8842f06949cb 100644 (file)
@@ -5292,6 +5292,11 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
        INSIST(result == ISC_R_SUCCESS);
        dns_view_setmaxrestarts(view, cfg_obj_asuint32(obj));
 
+       obj = NULL;
+       result = named_config_get(maps, "max-query-count", &obj);
+       INSIST(result == ISC_R_SUCCESS);
+       dns_view_setmaxqueries(view, cfg_obj_asuint32(obj));
+
        obj = NULL;
        result = named_config_get(maps, "max-validations-per-fetch", &obj);
        if (result == ISC_R_SUCCESS) {
index be3b462b5eb9ce8da6c952d36bcc0106e573dec0..18b35c9efbf0cc11ba5667aa241aa6e5f24d3796 100644 (file)
@@ -74,6 +74,7 @@ options {
        check-names primary warn;
        check-names secondary ignore;
        max-cache-size 20000000000000;
+       max-query-count 100;
        max-query-restarts 10;
        nta-lifetime 604800;
        nta-recheck 604800;
index 8851c842c01ceffbe833ad5ccb66d700b3bc14e4..bd3133e1422d00c8ba6d16dc8f8bd20b7a50d8be 100644 (file)
@@ -4472,6 +4472,15 @@ Tuning
    format is more human-readable, and is thus suitable when a zone is to
    be edited by hand. The default is ``relative``.
 
+.. namedconf:statement:: max-query-count
+   :tags: server, query
+   :short: Sets the maximum number of iterative queries while servicing a recursive query.
+
+   This sets the maximum number of iterative queries that may be sent
+   by a resolver while looking up a single name. If more queries than this
+   need to be sent before an answer is reached, then recursion is terminated
+   and a SERVFAIL response is returned to the client. The default is ``200``.
+
 .. namedconf:statement:: max-recursion-depth
    :tags: server
    :short: Sets the maximum number of levels of recursion permitted at any one time while servicing a recursive query.
index b6d4e062e3d848a86094aa26d1a50e8efb4b2a08..71486800fff58c96aeda69e47d1c1fa9390b9e0f 100644 (file)
@@ -179,6 +179,7 @@ options {
        max-ixfr-ratio ( unlimited | <percentage> );
        max-journal-size ( default | unlimited | <sizeval> );
        max-ncache-ttl <duration>;
+       max-query-count <integer>;
        max-query-restarts <integer>;
        max-records <integer>;
        max-records-per-type <integer>;
@@ -470,6 +471,7 @@ view <string> [ <class> ] {
        max-ixfr-ratio ( unlimited | <percentage> );
        max-journal-size ( default | unlimited | <sizeval> );
        max-ncache-ttl <duration>;
+       max-query-count <integer>;
        max-query-restarts <integer>;
        max-records <integer>;
        max-records-per-type <integer>;
index c82708ca528c3d032e24e333ee6ba0042ebea288..a82d860d98a2c4392c7f7aa8894e6615b581f340 100644 (file)
@@ -185,6 +185,7 @@ struct dns_view {
        unsigned int          udpsize;
        uint32_t              maxrrperset;
        uint32_t              maxtypepername;
+       uint16_t              max_queries;
        uint8_t               max_restarts;
 
        /*
@@ -1335,4 +1336,17 @@ dns_view_setmaxrestarts(dns_view_t *view, uint8_t max_restarts);
  *\li  'max_restarts' is greater than 0.
  */
 
+void
+dns_view_setmaxqueries(dns_view_t *view, uint16_t max_queries);
+/*%
+ * Set the number of permissible outgoing queries before we give up.
+ * This defaults to 200.
+ *
+ * Requires:
+ *
+ *\li  'view' is valid;
+ *\li  'max_queries' is greater than 0.
+ */
+
+
 ISC_LANG_ENDDECLS
index e6f69c0fda41efa72b9b2f7cae7f4e8931564413..5d5b0947432f4b1a4ad9da593daa567d3b7815c9 100644 (file)
@@ -566,6 +566,7 @@ struct dns_resolver {
        unsigned int query_timeout;
        unsigned int maxdepth;
        unsigned int maxqueries;
+       unsigned int maxquerycount;
        isc_result_t quotaresp[2];
        isc_stats_t *stats;
        dns_stats_t *querystats;
index 5251f7a4051293b5abc96f53d2d3c8f30867e620..f5dd2126c741d7d8ab50cf49069f8e82f44f4c0f 100644 (file)
@@ -2447,3 +2447,11 @@ dns_view_setmaxrestarts(dns_view_t *view, uint8_t max_restarts) {
 
        view->max_restarts = max_restarts;
 }
+
+void
+dns_view_setmaxqueries(dns_view_t *view, uint16_t max_queries) {
+       REQUIRE(DNS_VIEW_VALID(view));
+       REQUIRE(max_queries > 0);
+
+       view->max_queries = max_queries;
+}
index 9c29016c8ba1d94dd53a8ae49116cb9a1ba188f7..84367fc2f333d70e6c96098bc8af3c4c43ec9cba 100644 (file)
@@ -2108,6 +2108,7 @@ static cfg_clausedef_t view_clauses[] = {
        { "max-ncache-ttl", &cfg_type_duration, 0 },
        { "max-recursion-depth", &cfg_type_uint32, 0 },
        { "max-recursion-queries", &cfg_type_uint32, 0 },
+       { "max-query-count", &cfg_type_uint32, 0 },
        { "max-query-restarts", &cfg_type_uint32, 0 },
        { "max-stale-ttl", &cfg_type_duration, 0 },
        { "max-udp-size", &cfg_type_uint32, 0 },