From: Matthijs Mekking Date: Tue, 25 Nov 2025 08:12:58 +0000 (+0100) Subject: Use notify type in logging and for getting context X-Git-Tag: v9.21.17~21^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97b245c24c9c3f4992290800cbf5869119b2a0bb;p=thirdparty%2Fbind9.git Use notify type in logging and for getting context Add the notify type to the log messages for clarity, and use it to retrieve the right notify context. --- diff --git a/lib/dns/notify.c b/lib/dns/notify.c index 07b71b72422..98619c11157 100644 --- a/lib/dns/notify.c +++ b/lib/dns/notify.c @@ -87,7 +87,7 @@ dns_notify_destroy(dns_notify_t *notify, bool locked) { dns__zone_lock(notify->zone); } REQUIRE(dns__zone_locked(notify->zone)); - nctx = dns__zone_getnotifyctx(notify->zone); + nctx = dns__zone_getnotifyctx(notify->zone, notify->type); if (ISC_LINK_LINKED(notify, link)) { ISC_LIST_UNLINK(nctx->notifies, notify, link); } @@ -129,11 +129,15 @@ notify_done(void *arg) { isc_buffer_t buf; char rcode[128]; char addrbuf[ISC_SOCKADDR_FORMATSIZE]; + char typebuf[DNS_RDATATYPE_FORMATSIZE]; REQUIRE(DNS_NOTIFY_VALID(notify)); isc_buffer_init(&buf, rcode, sizeof(rcode)); isc_sockaddr_format(¬ify->dst, addrbuf, sizeof(addrbuf)); + + dns_rdatatype_format(notify->type, typebuf, sizeof(typebuf)); + /* WMM: This is changing the mctx from zone to notify. */ dns_message_create(notify->mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE, &message); @@ -152,32 +156,33 @@ notify_done(void *arg) { result = dns_rcode_totext(message->rcode, &buf); if (result == ISC_R_SUCCESS) { notify_log(notify, ISC_LOG_DEBUG(3), - "notify response from %s: %.*s", addrbuf, - (int)buf.used, rcode); + "notify(%s) response from %s: %.*s", typebuf, + addrbuf, (int)buf.used, rcode); } fail: dns_message_detach(&message); if (result == ISC_R_SUCCESS) { - notify_log(notify, ISC_LOG_DEBUG(1), "notify to %s successful", - addrbuf); + notify_log(notify, ISC_LOG_DEBUG(1), + "notify(%s) to %s successful", typebuf, addrbuf); } else if (result == ISC_R_SHUTTINGDOWN || result == ISC_R_CANCELED) { /* just destroy the notify */ } else if ((notify->flags & DNS_NOTIFY_TCP) == 0) { notify_log(notify, ISC_LOG_NOTICE, - "notify to %s failed: %s: retrying over TCP", - addrbuf, isc_result_totext(result)); + "notify(%s) to %s failed: %s: retrying over TCP", + typebuf, addrbuf, isc_result_totext(result)); notify->flags |= DNS_NOTIFY_TCP; dns_request_destroy(¬ify->request); dns_notify_queue(notify, notify->flags & DNS_NOTIFY_STARTUP); return; } else if (result == ISC_R_TIMEDOUT) { notify_log(notify, ISC_LOG_WARNING, - "notify to %s failed: %s: retries exceeded", addrbuf, - isc_result_totext(result)); + "notify(%s) to %s failed: %s: retries exceeded", + typebuf, addrbuf, isc_result_totext(result)); } else { - notify_log(notify, ISC_LOG_WARNING, "notify to %s failed: %s", - addrbuf, isc_result_totext(result)); + notify_log(notify, ISC_LOG_WARNING, + "notify(%s) to %s failed: %s", typebuf, addrbuf, + isc_result_totext(result)); } dns_notify_destroy(notify, false); } @@ -324,6 +329,7 @@ notify_send_toaddr(void *arg) { isc_netaddr_t dstip; dns_tsigkey_t *key = NULL; char addrbuf[ISC_SOCKADDR_FORMATSIZE]; + char typebuf[DNS_RDATATYPE_FORMATSIZE]; isc_sockaddr_t src; unsigned int options; bool have_notifysource = false; @@ -333,13 +339,16 @@ notify_send_toaddr(void *arg) { dns__zone_lock(notify->zone); - notifyctx = dns__zone_getnotifyctx(notify->zone); + notifyctx = dns__zone_getnotifyctx(notify->zone, notify->type); zmgr = dns_zone_getmgr(notify->zone); view = dns_zone_getview(notify->zone); loop = dns_zone_getloop(notify->zone); result = dns_zone_getdb(notify->zone, &zonedb); + isc_sockaddr_format(¬ify->dst, addrbuf, sizeof(addrbuf)); + dns_rdatatype_format(notify->type, typebuf, sizeof(typebuf)); + if (!dns__zone_loaded(notify->zone) || notify->rlevent->canceled || dns__zone_exiting(notify->zone) || zmgr == NULL || view == NULL || view->requestmgr == NULL || loop == NULL || zonedb == NULL || @@ -357,8 +366,8 @@ notify_send_toaddr(void *arg) { IN6_IS_ADDR_V4MAPPED(¬ify->dst.type.sin6.sin6_addr)) { notify_log(notify, ISC_LOG_DEBUG(3), - "notify: ignoring IPv6 mapped IPV4 address: %s", - addrbuf); + "notify(%s): ignoring IPv6 mapped IPV4 address: %s", + typebuf, addrbuf); result = ISC_R_CANCELED; goto cleanup; } @@ -374,9 +383,9 @@ notify_send_toaddr(void *arg) { result = dns_view_getpeertsig(view, &dstip, &key); if (result != ISC_R_SUCCESS && result != ISC_R_NOTFOUND) { notify_log(notify, ISC_LOG_ERROR, - "NOTIFY to %s not sent. " + "NOTIFY(%s) to %s not sent. " "Peer TSIG key lookup failure.", - addrbuf); + typebuf, addrbuf); goto cleanup_message; } } @@ -386,11 +395,11 @@ notify_send_toaddr(void *arg) { dns_name_format(key->name, namebuf, sizeof(namebuf)); notify_log(notify, ISC_LOG_INFO, - "sending notify to %s : TSIG (%s)", addrbuf, - namebuf); + "sending notify(%s) to %s : TSIG (%s)", typebuf, + addrbuf, namebuf); } else { - notify_log(notify, ISC_LOG_INFO, "sending notify to %s", - addrbuf); + notify_log(notify, ISC_LOG_INFO, "sending notify(%s) to %s", + typebuf, addrbuf); } options = 0; if (view->peers != NULL) { @@ -466,8 +475,8 @@ again: goto cleanup_key; } else if ((notify->flags & DNS_NOTIFY_TCP) == 0) { notify_log(notify, ISC_LOG_NOTICE, - "notify to %s failed: %s: retrying over TCP", - addrbuf, isc_result_totext(result)); + "notify(%s) to %s failed: %s: retrying over TCP", + typebuf, addrbuf, isc_result_totext(result)); notify->flags |= DNS_NOTIFY_TCP; goto again; } @@ -491,8 +500,9 @@ cleanup: if (result != ISC_R_SUCCESS) { isc_sockaddr_format(¬ify->dst, addrbuf, sizeof(addrbuf)); - notify_log(notify, ISC_LOG_WARNING, "notify to %s failed: %s", - addrbuf, isc_result_totext(result)); + notify_log(notify, ISC_LOG_WARNING, + "notify(%s) to %s failed: %s", typebuf, addrbuf, + isc_result_totext(result)); dns_notify_destroy(notify, false); } } @@ -591,7 +601,7 @@ notify_isself(dns_notify_t *notify, isc_sockaddr_t *dst) { dns_isselffunc_t isselffunc; void *isselfarg = NULL; - notifyctx = dns__zone_getnotifyctx(notify->zone); + notifyctx = dns__zone_getnotifyctx(notify->zone, notify->type); view = dns_zone_getview(notify->zone); dns__zone_getisself(notify->zone, &isselffunc, &isselfarg); if (view == NULL || isselffunc == NULL) { @@ -649,7 +659,7 @@ notify_send(dns_notify_t *notify) { if (dns__zone_exiting(notify->zone)) { return; } - notifyctx = dns__zone_getnotifyctx(notify->zone); + notifyctx = dns__zone_getnotifyctx(notify->zone, notify->type); ISC_LIST_FOREACH(notify->find->list, ai, publink) { dst = ai->sockaddr; diff --git a/lib/dns/zone.c b/lib/dns/zone.c index db5f59b2b3e..ee632cef0a7 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -15687,10 +15687,18 @@ dns_zone_getrdclass(dns_zone_t *zone) { } dns_notifyctx_t * -dns__zone_getnotifyctx(dns_zone_t *zone) { +dns__zone_getnotifyctx(dns_zone_t *zone, dns_rdatatype_t type) { REQUIRE(DNS_ZONE_VALID(zone)); - return &zone->notifysoa; + switch (type) { + case dns_rdatatype_soa: + return &zone->notifysoa; + case dns_rdatatype_cds: + return &zone->notifycds; + default: + UNREACHABLE(); + } + return NULL; } void diff --git a/lib/dns/zone_p.h b/lib/dns/zone_p.h index 9a7d3481fa5..158ee0d8a8e 100644 --- a/lib/dns/zone_p.h +++ b/lib/dns/zone_p.h @@ -108,7 +108,7 @@ dns__zone_stats_increment(dns_zone_t *zone, isc_statscounter_t counter); */ dns_notifyctx_t * -dns__zone_getnotifyctx(dns_zone_t *zone); +dns__zone_getnotifyctx(dns_zone_t *zone, dns_rdatatype_t type); /*%< * Returns the notify context. *