]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Warn if 'stale-refresh-time' < 30 (default)
authorDiego Fronza <diego@isc.org>
Thu, 5 Nov 2020 16:07:47 +0000 (13:07 -0300)
committerDiego Fronza <diego@isc.org>
Wed, 11 Nov 2020 15:53:23 +0000 (12:53 -0300)
RFC 8767 recommends that attempts to refresh to be done no more
frequently than every 30 seconds.

Added check into named-checkconf, which will warn if values below the
default are found in configuration.

BIND will also log the warning during loading of configuration in the
same fashion.

bin/tests/system/checkconf/servestale.stale-refresh-time.0.conf [new file with mode: 0644]
bin/tests/system/checkconf/servestale.stale-refresh-time.29.conf [new file with mode: 0644]
bin/tests/system/checkconf/tests.sh
lib/bind9/check.c

diff --git a/bin/tests/system/checkconf/servestale.stale-refresh-time.0.conf b/bin/tests/system/checkconf/servestale.stale-refresh-time.0.conf
new file mode 100644 (file)
index 0000000..2e58140
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * 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.
+ */
+
+options {
+       stale-refresh-time 0;
+};
diff --git a/bin/tests/system/checkconf/servestale.stale-refresh-time.29.conf b/bin/tests/system/checkconf/servestale.stale-refresh-time.29.conf
new file mode 100644 (file)
index 0000000..92fe8dc
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * 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.
+ */
+
+options {
+       stale-refresh-time 29;
+};
index d8e6db714e55e8c43f2bd6990e6a6203a931e6fa..244c226469c9d77a93c50681c762c4b450ff54a6 100644 (file)
@@ -139,6 +139,19 @@ grep '.*' < checkconf.out$n.2 > /dev/null && ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
 
+n=`expr $n + 1`
+echo_i "checking named-checkconf servestale warnings ($n)"
+ret=0
+$CHECKCONF servestale.stale-refresh-time.0.conf > checkconf.out$n.1 2>&1
+grep "'stale-refresh-time' should either be 0 or otherwise 30 seconds or higher" < checkconf.out$n.1 > /dev/null && ret=1
+if [ $ret != 0 ]; then echo_i "failed"; fi
+status=`expr $status + $ret`
+ret=0
+$CHECKCONF servestale.stale-refresh-time.29.conf > checkconf.out$n.1 2>&1
+grep "'stale-refresh-time' should either be 0 or otherwise 30 seconds or higher" < checkconf.out$n.1 > /dev/null || ret=1
+if [ $ret != 0 ]; then echo_i "failed"; fi
+status=`expr $status + $ret`
+
 n=`expr $n + 1`
 echo_i "range checking fields that do not allow zero ($n)"
 ret=0
index fde3ec12bbb2c6bcdb6f84e6df69aead62f14dd2..e1b986bc14d40c5cdd6eb62eb4a33c4a255b9d6a 100644 (file)
@@ -1662,6 +1662,17 @@ check_options(const cfg_obj_t *options, isc_log_t *logctx, isc_mem_t *mctx,
                }
        }
 
+       obj = NULL;
+       (void)cfg_map_get(options, "stale-refresh-time", &obj);
+       if (obj != NULL) {
+               uint32_t refresh_time = cfg_obj_asduration(obj);
+               if (refresh_time > 0 && refresh_time < 30) {
+                       cfg_obj_log(obj, logctx, ISC_LOG_WARNING,
+                                   "'stale-refresh-time' should either be 0 "
+                                   "or otherwise 30 seconds or higher");
+               }
+       }
+
        return (result);
 }