Change zone set/get options related to notify

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.
This commit is contained in:
Matthijs Mekking 2025-12-16 17:31:24 +01:00
parent 2118fa0b62
commit 7fd1eccb6e
5 changed files with 76 additions and 69 deletions

View 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);

View 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;
};

View 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

View 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);

View 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;
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_getnotifysrc4(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.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;
UNLOCK_ZONE(zone);
}
void
dns_zone_getnotifysrc6(dns_zone_t *zone, 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);
}