]> 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>
Fri, 6 Dec 2024 15:17:53 +0000 (15:17 +0000)
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.

(cherry picked from commit bbc16cc8e6e852afd7cd95f1824429f81b7de222)

bin/named/config.c
bin/named/server.c
bin/tests/system/checkconf/good.conf
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 040fde999c5950947700c661a363931576a1c2ee..0f25033cc27b1eeb8158d4b91cd76079e183f3bf 100644 (file)
@@ -175,6 +175,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 d4862bae4beb73992cf135f385e0bfe274b0db1d..68b29d835f1f940b9390c9e71d0e7b782398d5df 100644 (file)
@@ -5678,6 +5678,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, "fetches-per-zone", &obj);
        INSIST(result == ISC_R_SUCCESS);
index da47e8880e364bea4dc89f4dda0df1e8050388ee..c5eeb0b18a4c876f1473221baf9778fcab98c67e 100644 (file)
@@ -77,6 +77,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 b6356343cc4cca63be9da8a8ce5969af92ba264e..3c9f1447850f033bc83a29eb8da69b75c595f68c 100644 (file)
@@ -4675,6 +4675,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 8c01d5723776617111dfb2009c1e1e83f648d205..f8fdec6859271641bcaea9dfb7daf1899e998d8d 100644 (file)
@@ -180,6 +180,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>;
@@ -473,6 +474,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 f5e274ef3d3ddcb9b1b8801b778e8af86861677f..b7a479870345713dfe2f9aead83a7cb21fbf7f03 100644 (file)
@@ -193,6 +193,7 @@ struct dns_view {
        dns_badcache_t   *failcache;
        uint32_t          maxrrperset;
        uint32_t          maxtypepername;
+       uint16_t          max_queries;
        uint8_t           max_restarts;
 
        /*
@@ -1440,4 +1441,16 @@ 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 1c3f0a36ff1b42244873d66f0faf357c9eeac925..b8907b420eeb2ee3a428f870b1933f138b3b0097 100644 (file)
@@ -581,6 +581,7 @@ struct dns_resolver {
        unsigned int query_timeout;
        unsigned int maxdepth;
        unsigned int maxqueries;
+       unsigned int maxquerycount;
        isc_result_t quotaresp[2];
 
        /* Additions for serve-stale feature. */
index 33e229fbeeb546bbfe7b87b87dc48f31294b18f9..8f23d8a1555027c3ba9286ac27c73539a01d00d9 100644 (file)
@@ -2806,3 +2806,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 f5afac4dcd39c3a632cd9c330f067734f4279106..0c8bcb6c202e5e8c909a13387102ca43c40491aa 100644 (file)
@@ -2110,6 +2110,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 },