From 68832829296eb01fa49a4c7271e7dff1f95a7ce8 Mon Sep 17 00:00:00 2001 From: Colin Vidal Date: Fri, 31 Oct 2025 12:12:20 +0100 Subject: [PATCH] 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. --- lib/dns/include/dns/zone.h | 9 +++++++++ lib/dns/zone.c | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/dns/include/dns/zone.h b/lib/dns/include/dns/zone.h index b45c842c9a..70b79471a4 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 d0bc8b65c4..a196d5b96c 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); +}