Commit 0e17fb09a4 for bind

commit 0e17fb09a41cbe0bb1b647c19f3ac8f1b672b302
Author: Matthijs Mekking <matthijs@isc.org>
Date:   Mon Nov 16 11:50:01 2026 +0100

    When zone_verifykeys fails, set result correctly

    When zone_verifykeys fails it logs an error message and jumps to the
    cleanup part of the function, without setting result. As a result,
    the refreshkeysinterval is not set, stays the same and this will
    trigger excessive retries.

    This commit sets the result to the return value of zone_verifykeys, and
    in case of an error triggers a zone_rekey failure log, and backing off
    the refreshkeysinterval with 10 minutes.

diff --git a/lib/dns/zone.c b/lib/dns/zone.c
index 70fe8a8281..297b14b8c0 100644
--- a/lib/dns/zone.c
+++ b/lib/dns/zone.c
@@ -18877,9 +18877,9 @@ zone_rekey(dns_zone_t *zone) {

 	if (kasp != NULL && !offlineksk) {
 		/* Verify new keys. */
-		isc_result_t ret = zone_verifykeys(
-			zone, &keys, dns_kasp_purgekeys(kasp), now);
-		if (ret != ISC_R_SUCCESS) {
+		result = zone_verifykeys(zone, &keys, dns_kasp_purgekeys(kasp),
+					 now);
+		if (result != ISC_R_SUCCESS) {
 			dnssec_log(zone, ISC_LOG_ERROR,
 				   "zone_rekey:zone_verifykeys failed: "
 				   "some key files are missing");
@@ -18896,8 +18896,8 @@ zone_rekey(dns_zone_t *zone) {
 		ISC_LIST_INIT(zone->checkds_ok);
 		UNLOCK_ZONE(zone);

-		ret = dns_zone_getdnsseckeys(zone, db, ver, now,
-					     &zone->checkds_ok);
+		isc_result_t ret = dns_zone_getdnsseckeys(zone, db, ver, now,
+							  &zone->checkds_ok);
 		if (ret == ISC_R_SUCCESS) {
 			zone_checkds(zone);
 		} else {
@@ -18910,27 +18910,24 @@ zone_rekey(dns_zone_t *zone) {
 		}

 		/* Run keymgr. */
-		if (result == ISC_R_SUCCESS || result == ISC_R_NOTFOUND) {
-			dns_zone_lock_keyfiles(zone);
-			result = dns_keymgr_run(&zone->origin, zone->rdclass,
-						mctx, &keys, &dnskeys, dir,
-						kasp, options, now, &nexttime);
-			dns_zone_unlock_keyfiles(zone);
+		dns_zone_lock_keyfiles(zone);
+		result = dns_keymgr_run(&zone->origin, zone->rdclass, mctx,
+					&keys, &dnskeys, dir, kasp, options,
+					now, &nexttime);
+		dns_zone_unlock_keyfiles(zone);

-			if (result == ISC_R_SUCCESS) {
-				kasp_change = true;
-				keymgr_done = true;
-			} else if (result == DNS_R_UNCHANGED) {
-				result = ISC_R_SUCCESS;
-				keymgr_done = true;
-			} else {
-				dnssec_log(zone, ISC_LOG_ERROR,
-					   "zone_rekey:dns_keymgr_run "
-					   "failed: %s",
-					   isc_result_totext(result));
-				KASP_UNLOCK(kasp);
-				goto cleanup;
-			}
+		if (result == ISC_R_SUCCESS) {
+			kasp_change = true;
+			keymgr_done = true;
+		} else if (result == DNS_R_UNCHANGED) {
+			result = ISC_R_SUCCESS;
+			keymgr_done = true;
+		} else {
+			dnssec_log(zone, ISC_LOG_ERROR,
+				   "zone_rekey:dns_keymgr_run failed: %s",
+				   isc_result_totext(result));
+			KASP_UNLOCK(kasp);
+			goto cleanup;
 		}
 	} else if (offlineksk) {
 		/*