]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Move setresign to rdataset.c and rename it
authorAlessio Podda <alessio@isc.org>
Tue, 7 Oct 2025 04:00:17 +0000 (06:00 +0200)
committerAlessio Podda <alessio@isc.org>
Thu, 29 Jan 2026 08:13:02 +0000 (09:13 +0100)
The setresign method is not diff specific, it only returns the minimum
resign time of an rdataset. Move it to rdataset.c to simplify late
refactoring.

(cherry picked from commit 6f726ae3db00e98f063302363b39fa41a5a7a8d3)

lib/dns/diff.c
lib/dns/include/dns/rdataset.h
lib/dns/rdataset.c

index d3885c7311a0c8aaf9e7a1e36feac46f221c3eb8..88333abc0fe121d20728cc8fb05218b61a451ce6 100644 (file)
@@ -211,41 +211,6 @@ dns_diff_appendminimal(dns_diff_t *diff, dns_difftuple_t **tuplep) {
        }
 }
 
-static isc_stdtime_t
-setresign(dns_rdataset_t *modified) {
-       dns_rdata_t rdata = DNS_RDATA_INIT;
-       dns_rdata_rrsig_t sig;
-       int64_t when;
-       isc_result_t result;
-
-       result = dns_rdataset_first(modified);
-       INSIST(result == ISC_R_SUCCESS);
-       dns_rdataset_current(modified, &rdata);
-       (void)dns_rdata_tostruct(&rdata, &sig, NULL);
-       if ((rdata.flags & DNS_RDATA_OFFLINE) != 0) {
-               when = 0;
-       } else {
-               when = dns_time64_from32(sig.timeexpire);
-       }
-       dns_rdata_reset(&rdata);
-
-       result = dns_rdataset_next(modified);
-       while (result == ISC_R_SUCCESS) {
-               dns_rdataset_current(modified, &rdata);
-               (void)dns_rdata_tostruct(&rdata, &sig, NULL);
-               if ((rdata.flags & DNS_RDATA_OFFLINE) != 0) {
-                       goto next_rr;
-               }
-               if (when == 0 || dns_time64_from32(sig.timeexpire) < when) {
-                       when = dns_time64_from32(sig.timeexpire);
-               }
-       next_rr:
-               dns_rdata_reset(&rdata);
-               result = dns_rdataset_next(modified);
-       }
-       INSIST(result == ISC_R_NOMORE);
-       return (isc_stdtime_t)when;
-}
 
 static void
 getownercase(dns_rdataset_t *rdataset, dns_name_t *name) {
@@ -420,7 +385,7 @@ diff_apply(const dns_diff_t *diff, dns_db_t *db, dns_dbversion_t *ver,
                                     op == DNS_DIFFOP_ADDRESIGN))
                                {
                                        isc_stdtime_t resign;
-                                       resign = setresign(&ardataset);
+                                       resign = dns_rdataset_minresign(&ardataset);
                                        dns_db_setsigningtime(db, &ardataset,
                                                              resign);
                                }
index 0dc54cf58e3d10aa4df55ccd50b4323b9b753e45..c52ff87dff488dbb4b344742bd0c1f6f6e198988 100644 (file)
@@ -691,4 +691,17 @@ dns_trust_totext(dns_trust_t trust);
  * Display trust in textual form.
  */
 
+isc_stdtime_t
+dns_rdataset_minresign(dns_rdataset_t *rdataset);
+/*%<
+ * Return the minimum resign time from an RRSIG rdataset.
+ *
+ * This function iterates through all RRSIG records in the rdataset
+ * and returns the earliest expiration time, which indicates when
+ * the signatures should be resigned.
+ *
+ * Requires:
+ * \li 'rdataset' is a valid rdataset.
+ */
+
 ISC_LANG_ENDDECLS
index b6043ba7ea8f96b953f9716971f7f1fd4d83003f..dadb1aeca5a0c1eda4a665185b4f6bd10ab4ed85 100644 (file)
@@ -29,6 +29,8 @@
 #include <dns/ncache.h>
 #include <dns/rdata.h>
 #include <dns/rdataset.h>
+#include <dns/time.h>
+#include <dns/types.h>
 
 static const char *trustnames[] = {
        "none",           "pending-additional",
@@ -676,3 +678,41 @@ dns_rdataset_trimttl(dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset,
        rdataset->ttl = ttl;
        sigrdataset->ttl = ttl;
 }
+
+isc_stdtime_t
+dns_rdataset_minresign(dns_rdataset_t *rdataset) {
+       dns_rdata_t rdata = DNS_RDATA_INIT;
+       dns_rdata_rrsig_t sig;
+       int64_t when;
+       isc_result_t result;
+
+       REQUIRE(DNS_RDATASET_VALID(rdataset));
+
+       result = dns_rdataset_first(rdataset);
+       INSIST(result == ISC_R_SUCCESS);
+       dns_rdataset_current(rdataset, &rdata);
+       (void)dns_rdata_tostruct(&rdata, &sig, NULL);
+       if ((rdata.flags & DNS_RDATA_OFFLINE) != 0) {
+               when = 0;
+       } else {
+               when = dns_time64_from32(sig.timeexpire);
+       }
+       dns_rdata_reset(&rdata);
+
+       result = dns_rdataset_next(rdataset);
+       while (result == ISC_R_SUCCESS) {
+               dns_rdataset_current(rdataset, &rdata);
+               (void)dns_rdata_tostruct(&rdata, &sig, NULL);
+               if ((rdata.flags & DNS_RDATA_OFFLINE) != 0) {
+                       goto next_rr;
+               }
+               if (when == 0 || dns_time64_from32(sig.timeexpire) < when) {
+                       when = dns_time64_from32(sig.timeexpire);
+               }
+       next_rr:
+               dns_rdata_reset(&rdata);
+               result = dns_rdataset_next(rdataset);
+       }
+       INSIST(result == ISC_R_NOMORE);
+       return (isc_stdtime_t)when;
+}