]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
extends named -T so ADB settings can be tweaked
authorColin Vidal <colin@isc.org>
Mon, 2 Feb 2026 12:50:38 +0000 (13:50 +0100)
committerColin Vidal <colin@isc.org>
Wed, 11 Feb 2026 12:56:03 +0000 (13:56 +0100)
ADB entry window and ADB min cache time can be tweaked using `named -T
adbentrywindow=<unsigned int>` and `named -T adbmincache=<unsigned
int>`.

While those values doesn't needs to be exposed to the operator, this can
be needed to be able to system test ADB behaviors without having to wait
as long as those values are by default.

bin/named/main.c
lib/dns/adb.c

index 92d3b2b9b29239cc1d938ba0198b7a82c1af1bde..984c01c85aaf3a587d8cfda33e47de39fdf95a92 100644 (file)
@@ -120,6 +120,9 @@ extern unsigned int dns_zone_mkey_hour;
 extern unsigned int dns_zone_mkey_day;
 extern unsigned int dns_zone_mkey_month;
 
+extern unsigned int dns_adb_entrywindow;
+extern unsigned int dns_adb_cachemin;
+
 static bool want_stats = false;
 static char absolute_conffile[PATH_MAX];
 static char saved_command_line[4096] = { 0 };
@@ -723,6 +726,10 @@ parse_T_opt(char *option) {
                transferstuck = true;
        } else if (!strncmp(option, "tat=", 4)) {
                named_g_tat_interval = atoi(option + 4);
+       } else if (!strncmp(option, "adbentrywindow=", 15)) {
+               dns_adb_entrywindow = atoi(option + 15);
+       } else if (!strncmp(option, "adbcachemin=", 12)) {
+               dns_adb_cachemin = atoi(option + 12);
        } else {
                fprintf(stderr, "unknown -T flag '%s'\n", option);
        }
index 06256be58863fb3c3ff3c52d97d8f395eaf42b80..8721d8f6ff752126ef40b69157ee893f6dba52ca 100644 (file)
 /*!
  * For type 3 negative cache entries, we will remember that the address is
  * broken for this long.  XXXMLG This is also used for actual addresses, too.
- * The intent is to keep us from constantly asking about A/AAAA records
- * if the zone has extremely low TTLs.
  */
-#define ADB_CACHE_MINIMUM 10   /*%< seconds */
 #define ADB_CACHE_MAXIMUM 86400 /*%< seconds (86400 = 24 hours) */
-#define ADB_ENTRY_WINDOW  60   /*%< seconds */
 
 #define ADB_HASH_SIZE (1 << 12)
 
@@ -284,6 +280,12 @@ ISC_REFCOUNT_TRACE_DECL(dns_adbentry);
 ISC_REFCOUNT_DECL(dns_adbentry);
 #endif
 
+/*
+ * ADB settings that can be tweaked with named -T option
+ */
+unsigned int dns_adb_entrywindow = 60;
+unsigned int dns_adb_cachemin = 10;
+
 /*
  * Internal functions (and prototypes).
  */
@@ -457,10 +459,10 @@ enum {
  * Due to the ttlclamp(), the TTL is never 0 unless the trust is ultimate,
  * in which case we need to set the expiration to have immediate effect.
  */
-#define ADJUSTED_EXPIRE(expire, now, ttl)                                      \
-       ((ttl != 0)                                                            \
-                ? ISC_MIN(expire, ISC_MAX(now + ADB_ENTRY_WINDOW, now + ttl)) \
-                : INT_MAX)
+#define ADJUSTED_EXPIRE(expire, now, ttl)                                    \
+       ((ttl != 0) ? ISC_MIN(expire,                                        \
+                             ISC_MAX(now + dns_adb_entrywindow, now + ttl)) \
+                   : INT_MAX)
 
 /*
  * Error states.
@@ -533,8 +535,12 @@ inc_adbstats(dns_adb_t *adb, isc_statscounter_t counter) {
 
 static dns_ttl_t
 ttlclamp(dns_ttl_t ttl) {
-       if (ttl < ADB_CACHE_MINIMUM) {
-               ttl = ADB_CACHE_MINIMUM;
+       if (ttl < dns_adb_cachemin) {
+               /*
+                * Avoid to constantly ask about A/AAAA records if the zone has
+                * extremely low TTLs.
+                */
+               ttl = dns_adb_cachemin;
        }
        if (ttl > ADB_CACHE_MAXIMUM) {
                ttl = ADB_CACHE_MAXIMUM;
@@ -567,7 +573,11 @@ import_rdataset(dns_adbname_t *adbname, dns_rdataset_t *rdataset,
        case dns_trust_additional:
        case dns_trust_pending_answer:
        case dns_trust_pending_additional:
-               rdataset->ttl = ADB_CACHE_MINIMUM;
+               /*
+                * Avoid to constantly ask about A/AAAA records if the zone has
+                * extremely low TTLs.
+                */
+               rdataset->ttl = dns_adb_cachemin;
                break;
        case dns_trust_ultimate:
                rdataset->ttl = 0;
@@ -972,7 +982,7 @@ new_adbentry(dns_adb_t *adb, const isc_sockaddr_t *addr, isc_stdtime_t now) {
                .quota = adb->quota,
                .references = ISC_REFCOUNT_INITIALIZER(1),
                .adb = dns_adb_ref(adb),
-               .expires = now + ADB_ENTRY_WINDOW,
+               .expires = now + dns_adb_entrywindow,
                .loop = isc_loop_ref(isc_loop()),
                .magic = DNS_ADBENTRY_MAGIC,
        };