]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use notify type in logging and for getting context
authorMatthijs Mekking <matthijs@isc.org>
Tue, 25 Nov 2025 08:12:58 +0000 (09:12 +0100)
committerMatthijs Mekking <matthijs@isc.org>
Fri, 19 Dec 2025 13:08:15 +0000 (14:08 +0100)
Add the notify type to the log messages for clarity, and use it to
retrieve the right notify context.

lib/dns/notify.c
lib/dns/zone.c
lib/dns/zone_p.h

index 07b71b7242235fdeb0ca2f4f43b63f146371015b..98619c11157b039d2957c4c8805f59965b1afb89 100644 (file)
@@ -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(&notify->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(&notify->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(&notify->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(&notify->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(&notify->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;
index db5f59b2b3e8295278accb966771838b80542ce2..ee632cef0a77900d569382342e4ace0c500d999c 100644 (file)
@@ -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
index 9a7d3481fa584d5808cbd94e4a83f39890f6a92f..158ee0d8a8e57e9373a9b45834fdc5c1435a106f 100644 (file)
@@ -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.
  *