]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
add syntax and setter/getter functions to configure max-ixfr-ratio
authorEvan Hunt <each@isc.org>
Fri, 21 Feb 2020 18:53:08 +0000 (10:53 -0800)
committerOndřej Surý <ondrej@sury.org>
Tue, 26 Jan 2021 11:38:32 +0000 (12:38 +0100)
21 files changed:
bin/named/config.c
bin/named/zoneconf.c
bin/tests/system/checkconf/bad-maxratio1.conf [new file with mode: 0644]
bin/tests/system/checkconf/bad-maxratio2.conf [new file with mode: 0644]
bin/tests/system/checkconf/good-maxratio1.conf [new file with mode: 0644]
bin/tests/system/checkconf/good-maxratio2.conf [new file with mode: 0644]
bin/tests/system/checkconf/good.conf
bin/tests/system/checkconf/tests.sh
bin/tests/system/checkconf/warn-maxratio1.conf [new file with mode: 0644]
bin/tests/system/ixfr/ns4/named.conf.in
bin/tests/system/run.sh [changed mode: 0644->0755]
doc/misc/master.zoneopt
doc/misc/mirror.zoneopt
doc/misc/options
doc/misc/options.active
doc/misc/slave.zoneopt
lib/bind9/check.c
lib/dns/include/dns/zone.h
lib/dns/win32/libdns.def.in
lib/dns/zone.c
lib/isccfg/namedconf.c

index 210ac8bde670738480ba6a9d0d173c3ef47595c6..9c3e8ca7995f6cf0a90b62696bb038aebeb05227 100644 (file)
@@ -81,6 +81,7 @@ options {\n\
        listen-on-v6 {any;};\n\
 #      lock-file \"" NAMED_LOCALSTATEDIR "/run/named/named.lock\";\n\
        match-mapped-addresses no;\n\
+       max-ixfr-ratio 100%;\n\
        max-rsa-exponent-size 0; /* no limit */\n\
        max-udp-size 1232;\n\
        memstatistics-file \"named.memstats\";\n\
index b2bb3731fb290dfb31549ba622b6fbd9d1e97285..32b6aedb7f159b156520d1973e1782a4f710b969 100644 (file)
@@ -1398,6 +1398,15 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
                                           ixfrdiff);
                }
 
+               obj = NULL;
+               result = named_config_get(maps, "max-ixfr-ratio", &obj);
+               INSIST(result == ISC_R_SUCCESS && obj != NULL);
+               if (cfg_obj_isstring(obj)) {
+                       dns_zone_setixfrratio(zone, 0);
+               } else {
+                       dns_zone_setixfrratio(zone, cfg_obj_aspercentage(obj));
+               }
+
                obj = NULL;
                result = named_config_get(maps, "request-expire", &obj);
                INSIST(result == ISC_R_SUCCESS);
diff --git a/bin/tests/system/checkconf/bad-maxratio1.conf b/bin/tests/system/checkconf/bad-maxratio1.conf
new file mode 100644 (file)
index 0000000..f0d06be
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+zone example {
+       type master;
+       masterfile-format map;
+       file "example.db";
+       max-ixfr-ratio 0.9;
+};
diff --git a/bin/tests/system/checkconf/bad-maxratio2.conf b/bin/tests/system/checkconf/bad-maxratio2.conf
new file mode 100644 (file)
index 0000000..902c334
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+zone example {
+       type master;
+       masterfile-format map;
+       file "example.db";
+       max-ixfr-ratio 0%;
+};
diff --git a/bin/tests/system/checkconf/good-maxratio1.conf b/bin/tests/system/checkconf/good-maxratio1.conf
new file mode 100644 (file)
index 0000000..80ff113
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+zone example {
+       type master;
+       masterfile-format map;
+       file "example.db";
+       max-ixfr-ratio 50%;
+};
diff --git a/bin/tests/system/checkconf/good-maxratio2.conf b/bin/tests/system/checkconf/good-maxratio2.conf
new file mode 100644 (file)
index 0000000..e057dfe
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+zone example {
+       type master;
+       masterfile-format map;
+       file "example.db";
+       max-ixfr-ratio unlimited;
+};
index 117143ad2933f5d191f095f73acd3c5a9f560e98..e23fd25060fa8101899c2be09c6b2594751c20a9 100644 (file)
@@ -81,6 +81,7 @@ options {
                "corp";
        };
        dnssec-policy "test";
+       max-ixfr-ratio 90%;
        transfer-source 0.0.0.0 dscp 63;
        zone-statistics none;
 };
@@ -92,11 +93,13 @@ view "first" {
                type master;
                file "xxx";
                update-policy local;
+               max-ixfr-ratio 20%;
                notify-source 10.10.10.10 port 53 dscp 55;
        };
        zone "clone" {
                type master;
                file "yyy";
+               max-ixfr-ratio unlimited;
        };
        dnssec-validation auto;
        zone-statistics terse;
index 61e3b8fa4a58f448c7cc7cbc86af50e6c754b8b0..19baf1c19be38bad80815361c3d9df2bc66e5c38 100644 (file)
@@ -559,9 +559,16 @@ awk 'BEGIN { ok = 0; } /cut here/ { ok = 1; getline } ok == 1 { print }' good-ka
 [ -s good-kasp.conf.in ] || ret=1
 $CHECKCONF -p good-kasp.conf.in | grep -v '^good-kasp.conf.in:' > good-kasp.conf.out 2>&1 || ret=1
 cmp good-kasp.conf.in good-kasp.conf.out || ret=1
-
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
 
+n=`expr $n + 1`
+echo_i "check that max-ixfr-ratio 100% generates a warning ($n)"
+ret=0
+$CHECKCONF warn-maxratio1.conf > checkconf.out$n 2>/dev/null || ret=1
+grep "exceeds 100%" < checkconf.out$n > /dev/null || ret=1
+if [ $ret != 0 ]; then echo_i "failed"; ret=1; fi
+status=`expr $status + $ret`
+
 echo_i "exit status: $status"
 [ $status -eq 0 ] || exit 1
diff --git a/bin/tests/system/checkconf/warn-maxratio1.conf b/bin/tests/system/checkconf/warn-maxratio1.conf
new file mode 100644 (file)
index 0000000..519dcc4
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+zone example {
+       type master;
+       masterfile-format map;
+       file "example.db";
+       max-ixfr-ratio 101%;
+};
index be96c1191d561949e38303bfb5da569811b2bbb8..ef70229ad94f7d61461e5c8f6a2ada058ca16f87 100644 (file)
@@ -37,6 +37,7 @@ view "primary" {
                type secondary;
                file "mytest.db";
                primaries { 10.53.0.3; };
+               max-ixfr-ratio unlimited;
        };
        zone "sub.test" IN {
                type secondary;
old mode 100644 (file)
new mode 100755 (executable)
index bb3d6281bd30a0b90c9879b26ac94bbb69ee2f00..f9903b34e818546a4dd020fe571c162036b7b301 100644 (file)
@@ -35,6 +35,7 @@ zone <string> [ <class> ] {
        key-directory <quoted_string>;
        masterfile-format ( map | raw | text );
        masterfile-style ( full | relative );
+       max-ixfr-ratio ( unlimited | <percentage> );
        max-journal-size ( default | unlimited | <sizeval> );
        max-records <integer>;
        max-transfer-idle-out <integer>;
index d403bfd1b872bf2564b46cd15c066b81e3655c14..c142586fe21510935ce26a616b11f59cdc938daf 100644 (file)
@@ -16,6 +16,7 @@ zone <string> [ <class> ] {
        masterfile-format ( map | raw | text );
        masterfile-style ( full | relative );
        masters [ port <integer> ] [ dscp <integer> ] { ( <primaries> | <ipv4_address> [ port <integer> ] | <ipv6_address> [ port <integer> ] ) [ key <string> ]; ... };
+       max-ixfr-ratio ( unlimited | <percentage> );
        max-journal-size ( default | unlimited | <sizeval> );
        max-records <integer>;
        max-refresh-time <integer>;
index f98abd8e78c14a48270c8f5b74bce62fac044683..27b047fba8bbfde846172f5769a4b8336887977a 100644 (file)
@@ -241,6 +241,7 @@ options {
         max-cache-ttl <duration>;
         max-clients-per-query <integer>;
         max-ixfr-log-size ( default | unlimited | <sizeval> ); // ancient
+        max-ixfr-ratio ( unlimited | <percentage> );
         max-journal-size ( default | unlimited | <sizeval> );
         max-ncache-ttl <duration>;
         max-records <integer>;
@@ -608,6 +609,7 @@ view <string> [ <class> ] {
         max-cache-ttl <duration>;
         max-clients-per-query <integer>;
         max-ixfr-log-size ( default | unlimited | <sizeval> ); // ancient
+        max-ixfr-ratio ( unlimited | <percentage> );
         max-journal-size ( default | unlimited | <sizeval> );
         max-ncache-ttl <duration>;
         max-records <integer>;
@@ -835,6 +837,7 @@ view <string> [ <class> ] {
                     ... };
                 max-ixfr-log-size ( default | unlimited |
                     <sizeval> ); // ancient
+                max-ixfr-ratio ( unlimited | <percentage> );
                 max-journal-size ( default | unlimited | <sizeval> );
                 max-records <integer>;
                 max-refresh-time <integer>;
@@ -943,6 +946,7 @@ zone <string> [ <class> ] {
             <ipv4_address> [ port <integer> ] | <ipv6_address> [ port
             <integer> ] ) [ key <string> ]; ... };
         max-ixfr-log-size ( default | unlimited | <sizeval> ); // ancient
+        max-ixfr-ratio ( unlimited | <percentage> );
         max-journal-size ( default | unlimited | <sizeval> );
         max-records <integer>;
         max-refresh-time <integer>;
index 85421169121312e6c70215fd44e69240ce0394b0..8e778f135fbd77cd12a623b2dadfc6cc1cf23a44 100644 (file)
@@ -215,6 +215,7 @@ options {
         max-cache-size ( default | unlimited | <sizeval> | <percentage> );
         max-cache-ttl <duration>;
         max-clients-per-query <integer>;
+        max-ixfr-ratio ( unlimited | <percentage> );
         max-journal-size ( default | unlimited | <sizeval> );
         max-ncache-ttl <duration>;
         max-records <integer>;
@@ -545,6 +546,7 @@ view <string> [ <class> ] {
         max-cache-size ( default | unlimited | <sizeval> | <percentage> );
         max-cache-ttl <duration>;
         max-clients-per-query <integer>;
+        max-ixfr-ratio ( unlimited | <percentage> );
         max-journal-size ( default | unlimited | <sizeval> );
         max-ncache-ttl <duration>;
         max-records <integer>;
@@ -755,6 +757,7 @@ view <string> [ <class> ] {
                     <primaries> | <ipv4_address> [ port <integer> ] |
                     <ipv6_address> [ port <integer> ] ) [ key <string> ];
                     ... };
+                max-ixfr-ratio ( unlimited | <percentage> );
                 max-journal-size ( default | unlimited | <sizeval> );
                 max-records <integer>;
                 max-refresh-time <integer>;
@@ -856,6 +859,7 @@ zone <string> [ <class> ] {
         masters [ port <integer> ] [ dscp <integer> ] { ( <primaries> |
             <ipv4_address> [ port <integer> ] | <ipv6_address> [ port
             <integer> ] ) [ key <string> ]; ... };
+        max-ixfr-ratio ( unlimited | <percentage> );
         max-journal-size ( default | unlimited | <sizeval> );
         max-records <integer>;
         max-refresh-time <integer>;
index 7bc7f3594686e5a0d0d419e351c912a91478adc0..040f2d5b69a2dd16900826b79c560d55ee0ced04 100644 (file)
@@ -28,6 +28,7 @@ zone <string> [ <class> ] {
        masterfile-format ( map | raw | text );
        masterfile-style ( full | relative );
        masters [ port <integer> ] [ dscp <integer> ] { ( <primaries> | <ipv4_address> [ port <integer> ] | <ipv6_address> [ port <integer> ] ) [ key <string> ]; ... };
+       max-ixfr-ratio ( unlimited | <percentage> );
        max-journal-size ( default | unlimited | <sizeval> );
        max-records <integer>;
        max-refresh-time <integer>;
index 64d7aaeedfe529675db3c8a17823bc86f5f327f4..f8e937d6d3568a381a7afbf69f6faa964a8896e2 100644 (file)
@@ -1567,6 +1567,24 @@ check_options(const cfg_obj_t *options, isc_log_t *logctx, isc_mem_t *mctx,
                }
        }
 
+       obj = NULL;
+       (void)cfg_map_get(options, "max-ixfr-ratio", &obj);
+       if (obj != NULL && cfg_obj_ispercentage(obj)) {
+               uint32_t percent = cfg_obj_aspercentage(obj);
+               if (percent == 0) {
+                       cfg_obj_log(obj, logctx, ISC_LOG_ERROR,
+                                   "'ixfr-max-ratio' must be a nonzero "
+                                   "percentage or 'unlimited')");
+                       if (result == ISC_R_SUCCESS) {
+                               result = ISC_R_RANGE;
+                       }
+               } else if (percent > 100) {
+                       cfg_obj_log(obj, logctx, ISC_LOG_WARNING,
+                                   "'ixfr-max-ratio %d%%' exceeds 100%%",
+                                   percent);
+               }
+       }
+
        obj = NULL;
        (void)cfg_map_get(options, "check-names", &obj);
        if (obj != NULL && !cfg_obj_islist(obj)) {
index d61322bc9c69764fc78d285f900452a90618f6ea..412ed3744c077842639532fffbeec988c10d2144 100644 (file)
@@ -2338,6 +2338,25 @@ dns_zone_setrequestixfr(dns_zone_t *zone, bool flag);
  * \li 'zone' to be valid.
  */
 
+uint32_t
+dns_zone_getixfrratio(dns_zone_t *zone);
+/*%
+ * Returns the zone's current IXFR ratio.
+ *
+ * Requires:
+ * \li 'zone' to be valid.
+ */
+
+void
+dns_zone_setixfrratio(dns_zone_t *zone, uint32_t ratio);
+/*%
+ * Sets the ratio of IXFR size to zone size above which we use an AXFR
+ * response, expressed as a percentage. Cannot exceed 100.
+ *
+ * Requires:
+ * \li 'zone' to be valid.
+ */
+
 void
 dns_zone_setserialupdatemethod(dns_zone_t *zone, dns_updatemethod_t method);
 /*%
index 040e8d128075c78c4daa0a25e23801f8962542f3..88aaa682ef02eaec32a0663e116f6c5205d78e26 100644 (file)
@@ -1221,6 +1221,7 @@ dns_zone_getgluecachestats
 dns_zone_getidlein
 dns_zone_getidleout
 dns_zone_getincludes
+dns_zone_getixfrratio
 dns_zone_getjournal
 dns_zone_getjournalsize
 dns_zone_getkasp
@@ -1323,6 +1324,7 @@ dns_zone_setforwardacl
 dns_zone_setidlein
 dns_zone_setidleout
 dns_zone_setisself
+dns_zone_setixfrratio
 dns_zone_setjournal
 dns_zone_setjournalsize
 dns_zone_setkasp
index 029311c52e90aff15a3bbcd45d2a9c97baceccc8..94c9365f9cd6c5f52bcff6fcbfbb47d99d5e2ee5 100644 (file)
@@ -407,6 +407,7 @@ struct dns_zone {
         * whether ixfr is requested
         */
        bool requestixfr;
+       uint32_t ixfr_ratio;
 
        /*%
         * whether EDNS EXPIRE is requested
@@ -1128,6 +1129,7 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx) {
        zone->sourceserial = 0;
        zone->sourceserialset = false;
        zone->requestixfr = true;
+       zone->ixfr_ratio = 100;
        zone->requestexpire = true;
        ISC_LIST_INIT(zone->rss_events);
        ISC_LIST_INIT(zone->rss_post);
@@ -20561,6 +20563,18 @@ dns_zone_getrequestixfr(dns_zone_t *zone) {
        return (zone->requestixfr);
 }
 
+void
+dns_zone_setixfrratio(dns_zone_t *zone, uint32_t ratio) {
+       REQUIRE(DNS_ZONE_VALID(zone));
+       zone->ixfr_ratio = ratio;
+}
+
+uint32_t
+dns_zone_getixfrratio(dns_zone_t *zone) {
+       REQUIRE(DNS_ZONE_VALID(zone));
+       return (zone->ixfr_ratio);
+}
+
 void
 dns_zone_setrequestexpire(dns_zone_t *zone, bool flag) {
        REQUIRE(DNS_ZONE_VALID(zone));
index 28dbde65ff9c3f7ce3fdc581d333f4358fcbed38..d7853a3443d64d437b46924353e3b67fe6a7e7fb 100644 (file)
@@ -92,6 +92,7 @@ static cfg_type_t cfg_type_dnstapoutput;
 static cfg_type_t cfg_type_dyndb;
 static cfg_type_t cfg_type_plugin;
 static cfg_type_t cfg_type_ixfrdifftype;
+static cfg_type_t cfg_type_ixfrratio;
 static cfg_type_t cfg_type_key;
 static cfg_type_t cfg_type_logfile;
 static cfg_type_t cfg_type_logging;
@@ -2203,6 +2204,8 @@ static cfg_clausedef_t zone_clauses[] = {
          CFG_ZONE_MASTER | CFG_ZONE_SLAVE | CFG_ZONE_MIRROR | CFG_ZONE_STUB |
                  CFG_ZONE_REDIRECT },
        { "max-ixfr-log-size", &cfg_type_size, CFG_CLAUSEFLAG_ANCIENT },
+       { "max-ixfr-ratio", &cfg_type_ixfrratio,
+         CFG_ZONE_MASTER | CFG_ZONE_SLAVE | CFG_ZONE_MIRROR },
        { "max-journal-size", &cfg_type_size,
          CFG_ZONE_MASTER | CFG_ZONE_SLAVE | CFG_ZONE_MIRROR },
        { "max-records", &cfg_type_uint32,
@@ -2740,6 +2743,28 @@ static cfg_type_t cfg_type_sizeorpercent = {
        doc_parse_size_or_percent, &cfg_rep_string,       sizeorpercent_enums
 };
 
+/*%
+ * An IXFR size ratio: percentage, or "unlimited".
+ */
+
+static isc_result_t
+parse_ixfrratio(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
+       return (cfg_parse_enum_or_other(pctx, type, &cfg_type_percentage, ret));
+}
+
+static void
+doc_ixfrratio(cfg_printer_t *pctx, const cfg_type_t *type) {
+       UNUSED(type);
+       cfg_print_cstr(pctx, "( unlimited | ");
+       cfg_doc_terminal(pctx, &cfg_type_percentage);
+       cfg_print_cstr(pctx, " )");
+}
+
+static const char *ixfrratio_enums[] = { "unlimited", NULL };
+static cfg_type_t cfg_type_ixfrratio = { "ixfr_ratio", parse_ixfrratio,
+                                        NULL,         doc_ixfrratio,
+                                        NULL,         ixfrratio_enums };
+
 /*%
  * optional_keyvalue
  */