From: Colin Vidal Date: Fri, 31 Oct 2025 11:12:20 +0000 (+0100) Subject: add dns_zone_isexpired API X-Git-Tag: v9.21.15~10^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68832829296eb01fa49a4c7271e7dff1f95a7ce8;p=thirdparty%2Fbind9.git add dns_zone_isexpired API Introduce the `dns_zone_isexpired()` API which returns `true` when a secondary, mirror, etc. zone is expired. This internally use the `DNS_ZONEFLG_EXPIRED` which was already set when the zone gets expired, but never used. The flag `DNS_ZONEFLG_EXPIRED` is also now cleared when the expiration time of the zone is updated and in the future. --- diff --git a/lib/dns/include/dns/zone.h b/lib/dns/include/dns/zone.h index b45c842c9a6..70b79471a4a 100644 --- a/lib/dns/include/dns/zone.h +++ b/lib/dns/include/dns/zone.h @@ -2792,6 +2792,15 @@ dns_zone_getcfg(dns_zone_t *zone); * \li 'zone' to be a valid zone. */ +bool +dns_zone_isexpired(dns_zone_t *zone); +/*%< + * Return true if a (secondary, mirror, etc.) zone is expired + * + * Requires: + * \li 'zone\ to be a valid zone. + */ + #if DNS_ZONE_TRACE #define dns_zone_ref(ptr) dns_zone__ref(ptr, __func__, __FILE__, __LINE__) #define dns_zone_unref(ptr) dns_zone__unref(ptr, __func__, __FILE__, __LINE__) diff --git a/lib/dns/zone.c b/lib/dns/zone.c index d0bc8b65c4b..a196d5b96cb 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -17617,6 +17617,7 @@ again: isc_time_compare(&expiretime, &zone->expiretime) > 0) { zone->expiretime = expiretime; + DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_EXPIRED); } /* @@ -24249,3 +24250,10 @@ dns_zone_getcfg(dns_zone_t *zone) { return zone->cfg; } + +bool +dns_zone_isexpired(dns_zone_t *zone) { + REQUIRE(DNS_ZONE_VALID(zone)); + + return DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXPIRED); +}