#define DNS_DEFAULT_IDLEOUT 3600 /*%< 1 hour */
#define MAX_XFER_TIME (2 * 3600) /*%< Documented default is 2 hours */
#define RESIGN_DELAY 3600 /*%< 1 hour */
-#define UDP_REQUEST_TIMEOUT 5 /*%< 5 seconds */
-#define UDP_REQUEST_RETRIES 2
-#define TCP_REQUEST_TIMEOUT \
- (UDP_REQUEST_TIMEOUT * (UDP_REQUEST_RETRIES + 1) + 1)
#ifndef DNS_MAX_EXPIRE
#define DNS_MAX_EXPIRE 14515200 /*%< 24 weeks */
static void
setnsec3param(void *arg);
-static void
-zmgr_tlsctx_attach(dns_zonemgr_t *zmgr, isc_tlsctx_cache_t **ptlsctx_cache);
-/*%<
- * Attach to TLS client context cache used for zone transfers via
- * encrypted transports (e.g. XoT).
- *
- * The obtained reference needs to be detached by a call to
- * 'isc_tlsctx_cache_detach()' when not needed anymore.
- *
- * Requires:
- *\li 'zmgr' is a valid zone manager.
- *\li 'ptlsctx_cache' is not 'NULL' and points to 'NULL'.
- */
-
#define ENTER zone_debuglog(zone, __func__, 1, "enter")
static const unsigned int dbargc_default = 1;
ISC_REFCOUNT_IMPL(dns_zone, zone_destroy);
#endif
-void
-dns_zone_iattach(dns_zone_t *source, dns_zone_t **target) {
- REQUIRE(DNS_ZONE_VALID(source));
-
- LOCK_ZONE(source);
- zone_iattach(source, target);
- UNLOCK_ZONE(source);
-}
-
static void
zone_iattach(dns_zone_t *source, dns_zone_t **target) {
REQUIRE(DNS_ZONE_VALID(source));
*target = source;
}
+void
+dns__zone_iattach_locked(dns_zone_t *source, dns_zone_t **target) {
+ zone_iattach(source, target);
+}
+
+void
+dns_zone_iattach(dns_zone_t *source, dns_zone_t **target) {
+ REQUIRE(DNS_ZONE_VALID(source));
+
+ LOCK_ZONE(source);
+ zone_iattach(source, target);
+ UNLOCK_ZONE(source);
+}
+
static void
zone_idetach(dns_zone_t **zonep) {
dns_zone_t *zone;
0);
}
+void
+dns__zone_idetach_locked(dns_zone_t **zonep) {
+ zone_idetach(zonep);
+}
+
void
dns_zone_idetach(dns_zone_t **zonep) {
dns_zone_t *zone;
if (!locked) {
UNLOCK_ZONE(notify->zone);
}
- if (locked) {
- zone_idetach(¬ify->zone);
- } else {
- dns_zone_idetach(¬ify->zone);
- }
+ dns_zone_idetach(¬ify->zone, locked);
}
if (notify->find != NULL) {
dns_adb_destroyfind(¬ify->find);
options |= DNS_REQUESTOPT_TCP;
}
- zmgr_tlsctx_attach(notify->zone->zmgr, &zmgr_tlsctx_cache);
+ dns_zonemgr_tlsctx_attach(notify->zone->zmgr, &zmgr_tlsctx_cache);
const unsigned int connect_timeout = isc_nm_getinitialtimeout() /
MS_PER_SEC;
return &zone->origin;
}
+dns_rdataclass_t
+dns_zone_getrdclass(dns_zone_t *zone) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+
+ return zone->rdclass;
+}
+
+dns_notifyctx_t *
+dns__zone_getnotifyctx(dns_zone_t *zone) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+
+ return &zone->notifyctx;
+}
+
void
dns_zone_setidlein(dns_zone_t *zone, uint32_t idlein) {
REQUIRE(DNS_ZONE_VALID(zone));
return zone->idleout;
}
+void
+dns__zone_stats_increment(dns_zone_t *zone, isc_statscounter_t counter) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+ REQUIRE(LOCKED_ZONE(zone));
+ inc_stats(zone, counter);
+}
+
+void
+dns__zone_lock(dns_zone_t *zone) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+ LOCK_ZONE(zone);
+}
+
+void
+dns__zone_unlock(dns_zone_t *zone) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+ UNLOCK_ZONE(zone);
+}
+
+bool
+dns__zone_locked(dns_zone_t *zone) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+ return LOCKED_ZONE(zone);
+}
+
+bool
+dns__zone_loaded(dns_zone_t *zone) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+ return DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED) != 0;
+}
+
+bool
+dns__zone_exiting(dns_zone_t *zone) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+ return DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING) != 0;
+}
+
static void
notify_done(void *arg) {
dns_request_t *request = (dns_request_t *)arg;
INSIST(isc_sockaddr_pf(&primaryaddr) == isc_sockaddr_pf(&sourceaddr));
- zmgr_tlsctx_attach(zone->zmgr, &zmgr_tlsctx_cache);
+ dns__zonemgr_tlsctx_attach(zone->zmgr, &zmgr_tlsctx_cache);
dns_xfrin_create(zone, xfrtype, ixfr_maxdiffs, &primaryaddr,
&sourceaddr, zone->tsigkey, soa_transport_type,
}
}
- zmgr_tlsctx_attach(zone->zmgr, &zmgr_tlsctx_cache);
+ dns__zonemgr_tlsctx_attach(zone->zmgr, &zmgr_tlsctx_cache);
const unsigned int connect_timeout = isc_nm_getprimariestimeout() /
MS_PER_SEC;
result = dns_request_createraw(
return zmgr->notifyrate;
}
+void
+dns__zonemgr_getnotifyrl(dns_zonemgr_t *zmgr, isc_ratelimiter_t **prl) {
+ REQUIRE(DNS_ZONEMGR_VALID(zmgr));
+
+ *prl = zmgr->notifyrl;
+}
+
unsigned int
dns_zonemgr_getstartupnotifyrate(dns_zonemgr_t *zmgr) {
REQUIRE(DNS_ZONEMGR_VALID(zmgr));
return zmgr->startupnotifyrate;
}
+void
+dns__zonemgr_getstartupnotifyrl(dns_zonemgr_t *zmgr, isc_ratelimiter_t **prl) {
+ REQUIRE(DNS_ZONEMGR_VALID(zmgr));
+
+ *prl = zmgr->startupnotifyrl;
+}
+
unsigned int
dns_zonemgr_getserialqueryrate(dns_zonemgr_t *zmgr) {
REQUIRE(DNS_ZONEMGR_VALID(zmgr));
UNLOCK_ZONE(zone);
}
+void
+dns__zone_getisself(dns_zone_t *zone, dns_isselffunc_t *isself, void **arg) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+ REQUIRE(isself != NULL);
+ REQUIRE(arg != NULL && *arg == NULL);
+
+ *isself = zone->isself;
+ *arg = zone->isselfarg;
+}
+
void
dns_zone_setnotifydefer(dns_zone_t *zone, uint32_t defer) {
REQUIRE(DNS_ZONE_VALID(zone));
RWUNLOCK(&zmgr->tlsctx_cache_rwlock, isc_rwlocktype_write);
}
-static void
-zmgr_tlsctx_attach(dns_zonemgr_t *zmgr, isc_tlsctx_cache_t **ptlsctx_cache) {
+void
+dns__zonemgr_tlsctx_attach(dns_zonemgr_t *zmgr,
+ isc_tlsctx_cache_t **ptlsctx_cache) {
REQUIRE(DNS_ZONEMGR_VALID(zmgr));
REQUIRE(ptlsctx_cache != NULL && *ptlsctx_cache == NULL);
* associated unit tests.
*/
+#define UDP_REQUEST_TIMEOUT 5 /*%< 5 seconds */
+#define UDP_REQUEST_RETRIES 2
+#define TCP_REQUEST_TIMEOUT \
+ (UDP_REQUEST_TIMEOUT * (UDP_REQUEST_RETRIES + 1) + 1)
+
typedef struct {
dns_diff_t *diff;
bool offline;
dns__zone_lookup_nsec3param(dns_zone_t *zone, dns_rdata_nsec3param_t *lookup,
dns_rdata_nsec3param_t *param,
unsigned char saltbuf[255], bool resalt);
+
+void
+dns__zone_lock(dns_zone_t *zone);
+/*%<
+ * Locks the zone.
+ *
+ * Requires:
+ *\li 'zone' to be a valid zone.
+ */
+
+void
+dns__zone_unlock(dns_zone_t *zone);
+/*%<
+ * Unlocks the zone.
+ *
+ * Requires:
+ *\li 'zone' to be a valid zone.
+ */
+
+bool
+dns__zone_locked(dns_zone_t *zone);
+/*%<
+ * Checks if the zone is locked.
+ *
+ * Requires:
+ *\li 'zone' to be a valid zone.
+ *
+ * Returns:
+ *\li true if the zone is locked, false otherwise.
+ */
+
+bool
+dns__zone_loaded(dns_zone_t *zone);
+/*%<
+ * Checks if the zone is loaded.
+ *
+ * Requires:
+ *\li 'zone' to be a valid zone.
+ *
+ * Returns:
+ *\li true if the zone is loaded, false otherwise.
+ */
+
+bool
+dns__zone_exiting(dns_zone_t *zone);
+/*%<
+ * Checks if the zone is exiting.
+ *
+ * Requires:
+ *\li 'zone' to be a valid zone.
+ *
+ * Returns:
+ *\li true if the zone is exiting, false otherwise.
+ */
+
+void
+dns__zone_stats_increment(dns_zone_t *zone, isc_statscounter_t counter);
+/*%
+ * Increment resolver-related statistics counters
+ *
+ * Requires:
+ *\li 'zone' to be a valid zone, and locked.
+ */
+
+dns_notifyctx_t *
+dns__zone_getnotifyctx(dns_zone_t *zone);
+/*%<
+ * Returns the notify context.
+ *
+ * Require:
+ *\li 'zone' to be a valid zone.
+ */
+
+void
+dns__zonemgr_getnotifyrl(dns_zonemgr_t *zmgr, isc_ratelimiter_t **prl);
+/*%<
+ * Get the NOTIFY requests rate limiter
+ *
+ * Requires:
+ *\li 'zmgr' to be a valid zone manager
+ */
+
+void
+dns__zonemgr_getstartupnotifyrl(dns_zonemgr_t *zmgr, isc_ratelimiter_t **prl);
+/*%<
+ * Get the startup NOTIFY requests rate limiter
+ *
+ * Requires:
+ *\li 'zmgr' to be a valid zone manager
+ */
+
+void
+dns__zonemgr_tlsctx_attach(dns_zonemgr_t *zmgr,
+ isc_tlsctx_cache_t **ptlsctx_cache);
+/*%<
+ * Attach to TLS client context cache used for zone transfers via
+ * encrypted transports (e.g. XoT).
+ *
+ * The obtained reference needs to be detached by a call to
+ * 'isc_tlsctx_cache_detach()' when not needed anymore.
+ *
+ * Requires:
+ *\li 'zmgr' is a valid zone manager.
+ *\li 'ptlsctx_cache' is not 'NULL' and points to 'NULL'.
+ */
+
+void
+dns__zone_getisself(dns_zone_t *zone, dns_isselffunc_t *isself, void **arg);
+/*%<
+ * Returns the isself callback function and argument.
+ *
+ * Require:
+ *\li 'zone' to be a valid zone.
+ *\li 'isself' is not NULL.
+ *\li 'arg' is not NULL and '*arg' is NULL.
+ */
+
+void
+dns__zone_iattach_locked(dns_zone_t *source, dns_zone_t **target);
+/*%<
+ * Attach '*target' to 'source' incrementing its internal
+ * reference count. This is intended for use by operations
+ * such as zone transfers that need to prevent the zone
+ * object from being freed but not from shutting down.
+ *
+ * Require:
+ *\li The caller is running in the context of the zone's loop.
+ *\li 'zone' to be a valid zone, already locked.
+ *\li 'target' to be non NULL and '*target' to be NULL.
+ */
+
+void
+dns__zone_idetach_locked(dns_zone_t **zonep);
+/*%<
+ * Detach from a zone decrementing its internal reference count.
+ * If there are no more internal or external references to the
+ * zone, it will be freed.
+ *
+ * Require:
+ *\li The caller is running in the context of the zone's loop.
+ *\li 'zonep' to point to a valid zone, already locked.
+ */