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.
This commit is contained in:
Colin Vidal 2025-10-31 12:12:20 +01:00
parent 069bfab5b3
commit 6883282929
2 changed files with 17 additions and 0 deletions

View file

@ -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__)

View file

@ -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);
}