2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

Expose 'first refresh' zone flag in stats channel

Add a new zone flag to indicate that a secondary type zone is
not yet fully ready, and a first time refresh is pending or is
in progress.

Expose this new flag in the statistics channel's "Incoming Zone
Transfers" section.
This commit is contained in:
Aram Sargsyan
2023-11-10 11:06:08 +00:00
parent 87942ee0b4
commit 0a1f05987f
4 changed files with 41 additions and 13 deletions

View File

@@ -919,6 +919,7 @@
<th>Local Serial</th>
<th>Remote Serial</th>
<th>IXFR</th>
<th>First Refresh</th>
<th>State</th>
<th>Additional Refresh Queued</th>
<th>Local Address</th>
@@ -946,6 +947,7 @@
<td><xsl:value-of select="serial"/></td>
<td><xsl:value-of select="remoteserial"/></td>
<td><xsl:value-of select="ixfr"/></td>
<td><xsl:value-of select="firstrefresh"/></td>
<td><xsl:value-of select="state"/></td>
<td><xsl:value-of select="refreshqueued"/></td>
<td><xsl:value-of select="localaddr"/></td>

View File

@@ -1470,7 +1470,7 @@ xfrin_xmlrender(dns_zone_t *zone, void *arg) {
dns_zonestat_level_t statlevel;
int xmlrc;
dns_xfrin_t *xfr = NULL;
bool is_running, is_deferred, is_presoa, is_pending;
bool is_firstrefresh, is_running, is_deferred, is_presoa, is_pending;
bool needs_refresh;
bool is_first_data_received, is_ixfr;
unsigned int nmsg = 0;
@@ -1482,8 +1482,9 @@ xfrin_xmlrender(dns_zone_t *zone, void *arg) {
return (ISC_R_SUCCESS);
}
if (dns_zone_getxfr(zone, &xfr, &is_running, &is_deferred, &is_presoa,
&is_pending, &needs_refresh) != ISC_R_SUCCESS)
if (dns_zone_getxfr(zone, &xfr, &is_firstrefresh, &is_running,
&is_deferred, &is_presoa, &is_pending,
&needs_refresh) != ISC_R_SUCCESS)
{
/*
* Failed to get information about the zone's incoming transfer
@@ -1550,6 +1551,11 @@ xfrin_xmlrender(dns_zone_t *zone, void *arg) {
}
TRY0(xmlTextWriterEndElement(writer));
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "firstrefresh"));
TRY0(xmlTextWriterWriteString(
writer, ISC_XMLCHAR(is_firstrefresh ? "Yes" : "No")));
TRY0(xmlTextWriterEndElement(writer));
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "state"));
if (is_running) {
const char *xfr_state = NULL;
@@ -2538,7 +2544,7 @@ xfrin_jsonrender(dns_zone_t *zone, void *arg) {
dns_transport_type_t transport_type;
dns_zonestat_level_t statlevel;
dns_xfrin_t *xfr = NULL;
bool is_running, is_deferred, is_presoa, is_pending;
bool is_firstrefresh, is_running, is_deferred, is_presoa, is_pending;
bool needs_refresh;
bool is_first_data_received, is_ixfr;
unsigned int nmsg = 0;
@@ -2570,8 +2576,9 @@ xfrin_jsonrender(dns_zone_t *zone, void *arg) {
goto cleanup;
}
result = dns_zone_getxfr(zone, &xfr, &is_running, &is_deferred,
&is_presoa, &is_pending, &needs_refresh);
result = dns_zone_getxfr(zone, &xfr, &is_firstrefresh, &is_running,
&is_deferred, &is_presoa, &is_pending,
&needs_refresh);
if (result != ISC_R_SUCCESS) {
result = ISC_R_SUCCESS;
goto cleanup;
@@ -2597,6 +2604,10 @@ xfrin_jsonrender(dns_zone_t *zone, void *arg) {
}
}
json_object_object_add(
xfrinobj, "firstrefresh",
json_object_new_string(is_firstrefresh ? "Yes" : "No"));
if (is_running) {
const char *xfr_state = NULL;

View File

@@ -1880,9 +1880,9 @@ dns_zonemgr_getcount(dns_zonemgr_t *zmgr, int state);
*/
isc_result_t
dns_zone_getxfr(dns_zone_t *zone, dns_xfrin_t **xfrp, bool *is_running,
bool *is_deferred, bool *is_presoa, bool *is_pending,
bool *needs_refresh);
dns_zone_getxfr(dns_zone_t *zone, dns_xfrin_t **xfrp, bool *is_firstrefresh,
bool *is_running, bool *is_deferred, bool *is_presoa,
bool *is_pending, bool *needs_refresh);
/*%<
* Returns the xfrin associated with the zone (if any) with the current
* transfer states (as booleans). When no longer needed, the returned xfrin
@@ -1891,6 +1891,7 @@ dns_zone_getxfr(dns_zone_t *zone, dns_xfrin_t **xfrp, bool *is_running,
* Requires:
*\li 'zone' to be a valid zone.
*\li 'xfrp' to be non NULL and '*xfrp' to be NULL.
*\li 'is_firstrefresh' to be non NULL.
*\li 'is_running' to be non NULL.
*\li 'is_deferred' to be non NULL.
*\li 'is_presoa' to be non NULL.

View File

@@ -554,6 +554,7 @@ typedef enum {
* notify due to the zone
* just being loaded for
* the first time. */
DNS_ZONEFLG_FIRSTREFRESH = 0x100000000U, /*%< First refresh pending */
DNS_ZONEFLG___MAX = UINT64_MAX, /* trick to make the ENUM 64-bit wide */
} dns_zoneflg_t;
@@ -2272,6 +2273,8 @@ zone_load(dns_zone_t *zone, unsigned int flags, bool locked) {
dns_remote_addresses(&zone->primaries) != NULL)) &&
rbt)
{
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_FIRSTREFRESH);
if (zone->stream == NULL &&
(zone->masterfile == NULL ||
!isc_file_exists(zone->masterfile)))
@@ -5091,7 +5094,13 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
if (isc_time_compare(&zone->refreshtime,
&zone->expiretime) >= 0)
{
DNS_ZONE_SETFLAG(zone,
DNS_ZONEFLG_FIRSTREFRESH);
zone->refreshtime = now;
} else {
/* The zone is up to date. */
DNS_ZONE_CLRFLAG(zone,
DNS_ZONEFLG_FIRSTREFRESH);
}
}
@@ -5270,6 +5279,8 @@ cleanup:
(zone->type == dns_zone_redirect &&
dns_remote_addresses(&zone->primaries) != NULL))
{
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_FIRSTREFRESH);
if (result != ISC_R_NOMEMORY) {
if (zone->journal != NULL) {
zone_saveunique(zone, zone->journal,
@@ -17591,7 +17602,8 @@ again:
DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NEEDNOTIFY);
FALLTHROUGH;
case DNS_R_UPTODATE:
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_FORCEXFER);
DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_FORCEXFER |
DNS_ZONEFLG_FIRSTREFRESH);
/*
* Has the zone expired underneath us?
*/
@@ -19724,9 +19736,9 @@ dns_zonemgr_getcount(dns_zonemgr_t *zmgr, int state) {
}
isc_result_t
dns_zone_getxfr(dns_zone_t *zone, dns_xfrin_t **xfrp, bool *is_running,
bool *is_deferred, bool *is_presoa, bool *is_pending,
bool *needs_refresh) {
dns_zone_getxfr(dns_zone_t *zone, dns_xfrin_t **xfrp, bool *is_firstrefresh,
bool *is_running, bool *is_deferred, bool *is_presoa,
bool *is_pending, bool *needs_refresh) {
REQUIRE(DNS_ZONE_VALID(zone));
REQUIRE(xfrp != NULL && *xfrp == NULL);
@@ -19735,6 +19747,7 @@ dns_zone_getxfr(dns_zone_t *zone, dns_xfrin_t **xfrp, bool *is_running,
}
/* Reset. */
*is_firstrefresh = false;
*is_running = false;
*is_deferred = false;
*is_presoa = false;
@@ -19743,6 +19756,7 @@ dns_zone_getxfr(dns_zone_t *zone, dns_xfrin_t **xfrp, bool *is_running,
RWLOCK(&zone->zmgr->rwlock, isc_rwlocktype_read);
LOCK_ZONE(zone);
*is_firstrefresh = DNS_ZONE_FLAG(zone, DNS_ZONEFLG_FIRSTREFRESH);
if (zone->xfr != NULL) {
dns_xfrin_attach(zone->xfr, xfrp);
}