]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Change zone set/get options related to notify
authorMatthijs Mekking <matthijs@isc.org>
Tue, 16 Dec 2025 16:31:24 +0000 (17:31 +0100)
committerMatthijs Mekking <matthijs@isc.org>
Mon, 29 Dec 2025 08:43:04 +0000 (09:43 +0100)
Add a type to all dns_zone_(get|set) functions that apply to sending
notifies, so the options can be set and retrieved separately per type.

This affects dns_zone_setnotifydefer, dns_zone_getnotifydefer,
dns_zone_setnotifydelay, dns_zone_getnotifydelay,
dns_zone_setnotifysrc4, and dns_zone_setnotifysrc6.

The functions dns_zone_getnotifysrc4 and dns_zone_getnotifysrc6 are
unused and can be removed.

bin/named/zoneconf.c
lib/dns/include/dns/notify.h
lib/dns/include/dns/zone.h
lib/dns/notify.c
lib/dns/zone.c

index 1af25b8adc161ef36ba7af2fbdc273702e6f37a3..4498b01fde3e0b3ad10d6882cc7df81c07037faf 100644 (file)
@@ -1258,12 +1258,14 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
                obj = NULL;
                result = named_config_get(maps, "notify-source", &obj);
                INSIST(result == ISC_R_SUCCESS && obj != NULL);
-               dns_zone_setnotifysrc4(zone, cfg_obj_assockaddr(obj));
+               dns_zone_setnotifysrc4(zone, dns_rdatatype_soa,
+                                      cfg_obj_assockaddr(obj));
 
                obj = NULL;
                result = named_config_get(maps, "notify-source-v6", &obj);
                INSIST(result == ISC_R_SUCCESS && obj != NULL);
-               dns_zone_setnotifysrc6(zone, cfg_obj_assockaddr(obj));
+               dns_zone_setnotifysrc6(zone, dns_rdatatype_soa,
+                                      cfg_obj_assockaddr(obj));
 
                obj = NULL;
                result = named_config_get(maps, "notify-to-soa", &obj);
@@ -1396,12 +1398,14 @@ named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
                obj = NULL;
                result = named_config_get(maps, "notify-delay", &obj);
                INSIST(result == ISC_R_SUCCESS && obj != NULL);
-               dns_zone_setnotifydelay(zone, cfg_obj_asuint32(obj));
+               dns_zone_setnotifydelay(zone, dns_rdatatype_soa,
+                                       cfg_obj_asuint32(obj));
 
                obj = NULL;
                result = named_config_get(maps, "notify-defer", &obj);
                INSIST(result == ISC_R_SUCCESS && obj != NULL);
-               dns_zone_setnotifydefer(zone, cfg_obj_asuint32(obj));
+               dns_zone_setnotifydefer(zone, dns_rdatatype_soa,
+                                       cfg_obj_asuint32(obj));
 
                obj = NULL;
                result = named_config_get(maps, "check-sibling", &obj);
index 6755c2831acbf9419f1fea0f39f8476005754bee..5ecdbfa331ed047af9ebee33d6e59a39ef97673c 100644 (file)
@@ -36,6 +36,8 @@ struct dns_notifyctx {
 
        /* Configuration data. */
        dns_notifytype_t notifytype;
+       uint32_t         notifydefer;
+       uint32_t         notifydelay;
        isc_sockaddr_t   notifysrc4;
        isc_sockaddr_t   notifysrc6;
 };
index 11a9daed4ce0575b1bdf8c77548c4cf10f9f5651..5964e69ead451da03eeb83a2ca9d483224406a54 100644 (file)
@@ -900,47 +900,29 @@ dns_zone_getparentalsrc6(dns_zone_t *zone, isc_sockaddr_t *parentalsrc);
  */
 
 void
-dns_zone_setnotifysrc4(dns_zone_t *zone, const isc_sockaddr_t *notifysrc);
+dns_zone_setnotifysrc4(dns_zone_t *zone, dns_rdatatype_t type,
+                      const isc_sockaddr_t *notifysrc);
 /*%<
  *     Set the source address to be used with IPv4 NOTIFY messages.
  *
  * Require:
  *\li  'zone' to be a valid zone.
+ *\li  'type' to be a valid notify RRtype.
  *\li  'notifysrc' to contain the address.
  */
 
 void
-dns_zone_getnotifysrc4(dns_zone_t *zone, isc_sockaddr_t *notifysrc);
-/*%<
- *     Returns the source address set by a previous dns_zone_setnotifysrc4
- *     call, or the default of inaddr_any, port 0.
- *
- * Require:
- *\li  'zone' to be a valid zone.
- *\li  'notifysrc' to be non NULL.
- */
-
-void
-dns_zone_setnotifysrc6(dns_zone_t *zone, const isc_sockaddr_t *notifysrc);
+dns_zone_setnotifysrc6(dns_zone_t *zone, dns_rdatatype_t type,
+                      const isc_sockaddr_t *notifysrc);
 /*%<
  *     Set the source address to be used with IPv6 NOTIFY messages.
  *
  * Require:
  *\li  'zone' to be a valid zone.
+ *\li  'type' to be a valid notify RRtype.
  *\li  'notifysrc' to contain the address.
  */
 
-void
-dns_zone_getnotifysrc6(dns_zone_t *zone, isc_sockaddr_t *notifysrc);
-/*%<
- *     Returns the source address set by a previous dns_zone_setnotifysrc6
- *     call, or the default of in6addr_any, port 0.
- *
- * Require:
- *\li  'zone' to be a valid zone.
- *\li  'notifysrc' to be non NULL.
- */
-
 void
 dns_zone_setnotifyacl(dns_zone_t *zone, dns_acl_t *acl);
 /*%<
@@ -2123,22 +2105,24 @@ dns_zone_setcheckisservedby(dns_zone_t               *zone,
  */
 
 void
-dns_zone_setnotifydefer(dns_zone_t *zone, uint32_t defer);
+dns_zone_setnotifydefer(dns_zone_t *zone, dns_rdatatype_t type, uint32_t defer);
 /*%<
  * Set the wait/defer time (in seconds) before notify messages are sent when
  * they are ready.
  *
  * Requires:
  *     'zone' to be valid.
+ *     'type' to be a valid notify RRtype.
  */
 
 void
-dns_zone_setnotifydelay(dns_zone_t *zone, uint32_t delay);
+dns_zone_setnotifydelay(dns_zone_t *zone, dns_rdatatype_t type, uint32_t delay);
 /*%<
  * Set the minimum delay (in seconds) between sets of notify messages.
  *
  * Requires:
  *     'zone' to be valid.
+ *     'type' to be a valid notify RRtype.
  */
 
 void
index 98619c11157b039d2957c4c8805f59965b1afb89..0ceb5b30d70b618c49612285fa062ef6006bd669 100644 (file)
@@ -44,6 +44,7 @@ dns_notifyctx_init(dns_notifyctx_t *nctx, dns_rdatatype_t type) {
        dns_notifyctx_t ctx = {
                .type = type,
                .notifytype = dns_notifytype_yes,
+               .notifydelay = 5,
                .notifies = ISC_LIST_INITIALIZER,
        };
        isc_sockaddr_any(&ctx.notifysrc4);
index c15f88d6dde12f5f8645dbf5fc44080d80229d52..8a6b5519c30b2446ec961a3d73b183d35b9088c8 100644 (file)
@@ -408,8 +408,6 @@ struct dns_zone {
        isc_stats_t *requeststats;
        dns_stats_t *rcvquerystats;
        dns_stats_t *dnssecsignstats;
-       uint32_t notifydelay;
-       uint32_t notifydefer;
        dns_isselffunc_t isself;
        void *isselfarg;
 
@@ -1068,7 +1066,6 @@ dns_zone_create(dns_zone_t **zonep, isc_mem_t *mctx, isc_tid_t tid) {
                .sigvalidityinterval = 30 * 24 * 3600,
                .sigresigninginterval = 7 * 24 * 3600,
                .statlevel = dns_zonestat_none,
-               .notifydelay = 5,
                .signatures = 10,
                .nodes = 100,
                .privatetype = (dns_rdatatype_t)0xffffU,
@@ -6353,46 +6350,42 @@ dns_zone_getparentalsrc6(dns_zone_t *zone, isc_sockaddr_t *parentalsrc) {
 }
 
 void
-dns_zone_setnotifysrc4(dns_zone_t *zone, const isc_sockaddr_t *notifysrc) {
+dns_zone_setnotifysrc4(dns_zone_t *zone, dns_rdatatype_t type,
+                      const isc_sockaddr_t *notifysrc) {
        REQUIRE(DNS_ZONE_VALID(zone));
        REQUIRE(notifysrc != NULL);
 
        LOCK_ZONE(zone);
-       zone->notifysoa.notifysrc4 = *notifysrc;
-       zone->notifycds.notifysrc4 = *notifysrc;
-       UNLOCK_ZONE(zone);
-}
-
-void
-dns_zone_getnotifysrc4(dns_zone_t *zone, isc_sockaddr_t *notifysrc) {
-       REQUIRE(DNS_ZONE_VALID(zone));
-       REQUIRE(notifysrc != NULL);
-
-       LOCK_ZONE(zone);
-       *notifysrc = zone->notifysoa.notifysrc4;
-       *notifysrc = zone->notifycds.notifysrc4;
-       UNLOCK_ZONE(zone);
-}
-
-void
-dns_zone_setnotifysrc6(dns_zone_t *zone, const isc_sockaddr_t *notifysrc) {
-       REQUIRE(DNS_ZONE_VALID(zone));
-       REQUIRE(notifysrc != NULL);
-
-       LOCK_ZONE(zone);
-       zone->notifysoa.notifysrc6 = *notifysrc;
-       zone->notifycds.notifysrc6 = *notifysrc;
+       switch (type) {
+       case dns_rdatatype_soa:
+               zone->notifysoa.notifysrc4 = *notifysrc;
+               break;
+       case dns_rdatatype_cds:
+               zone->notifycds.notifysrc4 = *notifysrc;
+               break;
+       default:
+               UNREACHABLE();
+       }
        UNLOCK_ZONE(zone);
 }
 
 void
-dns_zone_getnotifysrc6(dns_zone_t *zone, isc_sockaddr_t *notifysrc) {
+dns_zone_setnotifysrc6(dns_zone_t *zone, dns_rdatatype_t type,
+                      const isc_sockaddr_t *notifysrc) {
        REQUIRE(DNS_ZONE_VALID(zone));
        REQUIRE(notifysrc != NULL);
 
        LOCK_ZONE(zone);
-       *notifysrc = zone->notifysoa.notifysrc6;
-       *notifysrc = zone->notifycds.notifysrc6;
+       switch (type) {
+       case dns_rdatatype_soa:
+               zone->notifysoa.notifysrc6 = *notifysrc;
+               break;
+       case dns_rdatatype_cds:
+               zone->notifycds.notifysrc6 = *notifysrc;
+               break;
+       default:
+               UNREACHABLE();
+       }
        UNLOCK_ZONE(zone);
 }
 
@@ -11403,7 +11396,7 @@ zone_maintenance(dns_zone_t *zone) {
         * primaries after.
         */
        LOCK_ZONE(zone);
-       if (zone->notifydefer != 0 &&
+       if (zone->notifysoa.notifydefer != 0 &&
            !DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NOTIFYNODEFER) &&
            !DNS_ZONE_FLAG(zone, DNS_ZONEFLG_NOTIFYDEFERRED))
        {
@@ -11411,7 +11404,8 @@ zone_maintenance(dns_zone_t *zone) {
                        zone->notifytime = now;
                }
                DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NOTIFYDEFERRED);
-               DNS_ZONE_TIME_ADD(&zone->notifytime, zone->notifydefer,
+               DNS_ZONE_TIME_ADD(&zone->notifytime,
+                                 zone->notifysoa.notifydefer,
                                  &zone->notifytime);
        }
        notify = (zone->type == dns_zone_secondary ||
@@ -12408,7 +12402,7 @@ dns_zone_notify(dns_zone_t *zone, bool nodefer) {
                         */
                        DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_NOTIFYDEFERRED);
                        DNS_ZONE_TIME_SUBTRACT(&zone->notifytime,
-                                              zone->notifydefer,
+                                              zone->notifysoa.notifydefer,
                                               &zone->notifytime);
                }
                DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NOTIFYNODEFER);
@@ -12449,7 +12443,7 @@ zone_notify(dns_zone_t *zone, isc_time_t *now) {
                                       DNS_ZONEFLG_NOTIFYNODEFER |
                                       DNS_ZONEFLG_NOTIFYDEFERRED);
        notifytype = zone->notifysoa.notifytype;
-       DNS_ZONE_TIME_ADD(now, zone->notifydelay, &zone->notifytime);
+       DNS_ZONE_TIME_ADD(now, zone->notifysoa.notifydelay, &zone->notifytime);
        UNLOCK_ZONE(zone);
 
        if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING) ||
@@ -19441,20 +19435,42 @@ dns__zone_getisself(dns_zone_t *zone, dns_isselffunc_t *isself, void **arg) {
 }
 
 void
-dns_zone_setnotifydefer(dns_zone_t *zone, uint32_t defer) {
+dns_zone_setnotifydefer(dns_zone_t *zone, dns_rdatatype_t type,
+                       uint32_t defer) {
        REQUIRE(DNS_ZONE_VALID(zone));
 
        LOCK_ZONE(zone);
-       zone->notifydefer = defer;
+       switch (type) {
+       case dns_rdatatype_soa:
+               zone->notifysoa.notifydefer = defer;
+               break;
+       case dns_rdatatype_cds:
+               /* not applicable to NOTIFY(CDS), unused */
+               zone->notifycds.notifydefer = defer;
+               break;
+       default:
+               UNREACHABLE();
+       }
        UNLOCK_ZONE(zone);
 }
 
 void
-dns_zone_setnotifydelay(dns_zone_t *zone, uint32_t delay) {
+dns_zone_setnotifydelay(dns_zone_t *zone, dns_rdatatype_t type,
+                       uint32_t delay) {
        REQUIRE(DNS_ZONE_VALID(zone));
 
        LOCK_ZONE(zone);
-       zone->notifydelay = delay;
+       switch (type) {
+       case dns_rdatatype_soa:
+               zone->notifysoa.notifydelay = delay;
+               break;
+       case dns_rdatatype_cds:
+               /* not applicable to NOTIFY(CDS), unused */
+               zone->notifycds.notifydelay = delay;
+               break;
+       default:
+               UNREACHABLE();
+       }
        UNLOCK_ZONE(zone);
 }