]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add type parameter to dns_notify_create()
authorMatthijs Mekking <matthijs@isc.org>
Tue, 18 Nov 2025 08:56:34 +0000 (09:56 +0100)
committerMatthijs Mekking <matthijs@isc.org>
Fri, 19 Dec 2025 13:08:15 +0000 (14:08 +0100)
With Generalized DNS Notifications, a zone may need to send different
type of NOTIFY messages for different reasons. When creating a new
notify, allow for specifying the type.

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

index d6c64e5a027bfbe32cc92954f81c1ff48204a6d4..6755c2831acbf9419f1fea0f39f8476005754bee 100644 (file)
@@ -51,6 +51,7 @@ struct dns_notify {
        dns_adbfind_t   *find;
        dns_request_t   *request;
        dns_name_t       ns;
+       dns_rdatatype_t  type;
        in_port_t        port;
        isc_sockaddr_t   src;
        isc_sockaddr_t   dst;
@@ -77,8 +78,8 @@ dns_notifyctx_init(dns_notifyctx_t *nctx, dns_rdatatype_t type);
  */
 
 void
-dns_notify_create(isc_mem_t *mctx, in_port_t port, unsigned int flags,
-                 dns_notify_t **notifyp);
+dns_notify_create(isc_mem_t *mctx, dns_rdatatype_t type, in_port_t port,
+                 unsigned int flags, dns_notify_t **notifyp);
 /*%<
  *     Create a notify structure to maintain state.
  *
@@ -98,14 +99,15 @@ dns_notify_destroy(dns_notify_t *notify, bool zone_locked);
  */
 
 bool
-dns_notify_isqueued(dns_notifyctx_t *nctx, in_port_t port, unsigned int flags,
-                   dns_name_t *name, isc_sockaddr_t *addr, dns_tsigkey_t *key,
-                   dns_transport_t *transport);
+dns_notify_isqueued(dns_notifyctx_t *nctx, dns_rdatatype_t type, in_port_t port,
+                   unsigned int flags, dns_name_t *name, isc_sockaddr_t *addr,
+                   dns_tsigkey_t *key, dns_transport_t *transport);
 /*%<
- *     Check if we already have a notify queued matching name, destination
- *     address and port, TSIG key, and transport. Will requeue on the normal
- *     notify ratelimiter if the notify was enqueued on the startup ratelimiter
- *     and this is not a startup notify.
+ *     Check if we already have a notify queued matching name, type,
+ *     destination address and port, TSIG key, and transport. Will
+ *     requeue on the normal notify ratelimiter if the notify was
+ *     enqueued on the startup ratelimiter and this is not a startup
+ *     notify.
  *
  *      Requires:
  *             'nctx' is not NULL
index 50f0bb6cea45ccdd3e847c8b6d97586085393db6..07b71b7242235fdeb0ca2f4f43b63f146371015b 100644 (file)
@@ -53,8 +53,8 @@ dns_notifyctx_init(dns_notifyctx_t *nctx, dns_rdatatype_t type) {
 }
 
 void
-dns_notify_create(isc_mem_t *mctx, in_port_t port, unsigned int flags,
-                 dns_notify_t **notifyp) {
+dns_notify_create(isc_mem_t *mctx, dns_rdatatype_t type, in_port_t port,
+                 unsigned int flags, dns_notify_t **notifyp) {
        dns_notify_t *notify;
 
        REQUIRE(notifyp != NULL && *notifyp == NULL);
@@ -63,6 +63,7 @@ dns_notify_create(isc_mem_t *mctx, in_port_t port, unsigned int flags,
        *notify = (dns_notify_t){
                .flags = flags,
                .port = port,
+               .type = type,
        };
 
        isc_mem_attach(mctx, &notify->mctx);
@@ -527,9 +528,9 @@ dns_notify_queue(dns_notify_t *notify, bool startup) {
 }
 
 bool
-dns_notify_isqueued(dns_notifyctx_t *nctx, in_port_t port, unsigned int flags,
-                   dns_name_t *name, isc_sockaddr_t *addr, dns_tsigkey_t *key,
-                   dns_transport_t *transport) {
+dns_notify_isqueued(dns_notifyctx_t *nctx, dns_rdatatype_t type, in_port_t port,
+                   unsigned int flags, dns_name_t *name, isc_sockaddr_t *addr,
+                   dns_tsigkey_t *key, dns_transport_t *transport) {
        dns_notify_t *notify = NULL;
        isc_result_t result;
 
@@ -539,6 +540,9 @@ dns_notify_isqueued(dns_notifyctx_t *nctx, in_port_t port, unsigned int flags,
                if (n->request != NULL) {
                        continue;
                }
+               if (n->type != type) {
+                       continue;
+               }
                if ((name != NULL && dns_name_dynamic(&n->ns) &&
                     dns_name_equal(name, &n->ns)) ||
                    (addr != NULL && isc_sockaddr_equal(addr, &n->dst) &&
@@ -649,8 +653,8 @@ notify_send(dns_notify_t *notify) {
 
        ISC_LIST_FOREACH(notify->find->list, ai, publink) {
                dst = ai->sockaddr;
-               if (dns_notify_isqueued(notifyctx, notify->port, notify->flags,
-                                       NULL, &dst, NULL, NULL))
+               if (dns_notify_isqueued(notifyctx, notify->type, notify->port,
+                                       notify->flags, NULL, &dst, NULL, NULL))
                {
                        continue;
                }
@@ -659,8 +663,8 @@ notify_send(dns_notify_t *notify) {
                }
                newnotify = NULL;
                flags = notify->flags & DNS_NOTIFY_NOSOA;
-               dns_notify_create(notify->mctx, notify->port, flags,
-                                 &newnotify);
+               dns_notify_create(notify->mctx, notify->type, notify->port,
+                                 flags, &newnotify);
                dns__zone_iattach_locked(notify->zone, &newnotify->zone);
                ISC_LIST_APPEND(notifyctx->notifies, newnotify, link);
                newnotify->dst = dst;
index cceb56d2c7f8b919ac294f7d8f122cf92ba8b1ae..db5f59b2b3e8295278accb966771838b80542ce2 100644 (file)
@@ -12598,8 +12598,9 @@ zone_notify(dns_zone_t *zone, isc_time_t *now) {
                        goto next;
                }
 
-               if (dns_notify_isqueued(&zone->notifysoa, zone->view->dstport,
-                                       flags, NULL, &dst, key, transport))
+               if (dns_notify_isqueued(&zone->notifysoa, dns_rdatatype_soa,
+                                       zone->view->dstport, flags, NULL, &dst,
+                                       key, transport))
                {
                        if (key != NULL) {
                                dns_tsigkey_detach(&key);
@@ -12610,8 +12611,8 @@ zone_notify(dns_zone_t *zone, isc_time_t *now) {
                        goto next;
                }
 
-               dns_notify_create(zone->mctx, zone->view->dstport, flags,
-                                 &notify);
+               dns_notify_create(zone->mctx, dns_rdatatype_soa,
+                                 zone->view->dstport, flags, &notify);
                zone_iattach(zone, &notify->zone);
                notify->src = src;
                notify->dst = dst;
@@ -12688,15 +12689,15 @@ zone_notify(dns_zone_t *zone, isc_time_t *now) {
                }
 
                LOCK_ZONE(zone);
-               isqueued = dns_notify_isqueued(&zone->notifysoa,
-                                              zone->view->dstport, flags,
-                                              &ns.name, NULL, NULL, NULL);
+               isqueued = dns_notify_isqueued(
+                       &zone->notifysoa, dns_rdatatype_soa,
+                       zone->view->dstport, flags, &ns.name, NULL, NULL, NULL);
                UNLOCK_ZONE(zone);
                if (isqueued) {
                        continue;
                }
-               dns_notify_create(zone->mctx, zone->view->dstport, flags,
-                                 &notify);
+               dns_notify_create(zone->mctx, dns_rdatatype_soa,
+                                 zone->view->dstport, flags, &notify);
                dns_zone_iattach(zone, &notify->zone);
                dns_name_dup(&ns.name, zone->mctx, &notify->ns);
                LOCK_ZONE(zone);