]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
redis: add rebootstrap scheduling
authorDaniel Salzman <daniel.salzman@nic.cz>
Wed, 12 Nov 2025 13:16:07 +0000 (14:16 +0100)
committerDaniel Salzman <daniel.salzman@nic.cz>
Wed, 26 Nov 2025 14:49:47 +0000 (15:49 +0100)
src/knot/events/handlers/load.c
src/knot/events/handlers/refresh.c
src/knot/zone/zone.c
src/knot/zone/zone.h

index b19c443bd1b63f6d742846348e12f31e61191444..634b4c6730efc548422a47278411a90780ff7195 100644 (file)
@@ -171,6 +171,15 @@ int event_load(conf_t *conf, zone_t *zone)
                        if (ret != KNOT_EOK) {
                                log_zone_error(zone->name, "failed to load from database (%s)",
                                               ret == KNOT_ERDB ? err : knot_strerror(ret));
+
+                               time_t next = time(NULL);
+                               const knot_rdataset_t *soa = zone_soa(zone);
+                               if (soa != NULL) {
+                                       next += knot_soa_retry(soa->rdata);
+                               } else {
+                                       next += zone_bootstrap_next(&zone->zonefile.bootstrap_cnt);
+                               }
+                               zone_events_schedule_at(zone, ZONE_EVENT_LOAD, next);
                                goto cleanup;
                        }
                        zone->zonefile.serial = zone_contents_serial(zf_conts); // for logging
@@ -212,6 +221,7 @@ int event_load(conf_t *conf, zone_t *zone)
                zone->zonefile.serial = zone_contents_serial(zf_conts);
                zone->zonefile.exists = (zf_conts != NULL);
                zone->zonefile.mtime = mtime;
+               zone->zonefile.bootstrap_cnt = 0;
 
 zonefile_loaded:
                // If configured, add reverse records to zone contents
index 46f7834564cb1e3d77d8ccfa9bfd6db1922b552c..364a2a47a1bc8cd2efca3855644fb26f5b01b3b9 100644 (file)
@@ -143,21 +143,6 @@ static bool serial_is_current(uint32_t local_serial, uint32_t remote_serial)
        return (serial_compare(local_serial, remote_serial) & SERIAL_MASK_GEQ);
 }
 
-static time_t bootstrap_next(uint8_t *count)
-{
-       // Let the increment gradually grow in a sensible way.
-       time_t increment = 5 * (*count) * (*count);
-
-       if (increment < 7200) { // two hours
-               (*count)++;
-       } else {
-               increment = 7200;
-       }
-
-       // Add a random delay to prevent burst refresh.
-       return increment + dnssec_random_uint16_t() % 30;
-}
-
 static void limit_timer(conf_t *conf, const knot_dname_t *zone, uint32_t *timer,
                         const char *tm_name, const yp_name_t *low, const yp_name_t *upp)
 {
@@ -1500,7 +1485,7 @@ int event_refresh(conf_t *conf, zone_t *zone)
                if (soa) {
                        next = knot_soa_retry(soa->rdata);
                } else {
-                       next = bootstrap_next(&zone->zonefile.bootstrap_cnt);
+                       next = zone_bootstrap_next(&zone->zonefile.bootstrap_cnt);
                }
 
                limit_timer(conf, zone->name, &next, "retry",
index 201459cf1654e2cbc77c9595fc796b347dad8451..b09a5e08fe9f7300f4dc2f84275de1b4359058e1 100644 (file)
@@ -1015,3 +1015,18 @@ int slave_zone_serial(zone_t *zone, conf_t *conf, uint32_t *serial)
 
        return ret;
 }
+
+time_t zone_bootstrap_next(uint8_t *count)
+{
+       // Let the increment gradually grow in a sensible way.
+       time_t increment = 5 * (*count) * (*count);
+
+       if (increment < 7200) { // two hours
+               (*count)++;
+       } else {
+               increment = 7200;
+       }
+
+       // Add a random delay to prevent burst refresh.
+       return increment + dnssec_random_uint16_t() % 30;
+}
index 3b14bebca286fc0f30703310bbe9934a7515ca88..33be90b5f85d3ad9fa77a27444d93afc4aa33449 100644 (file)
@@ -336,3 +336,5 @@ void zone_set_lastsigned_serial(conf_t *conf, zone_t *zone, uint32_t serial);
 int zone_get_lastsigned_serial(zone_t *zone, uint32_t *serial);
 
 int slave_zone_serial(zone_t *zone, conf_t *conf, uint32_t *serial);
+
+time_t zone_bootstrap_next(uint8_t *count);