mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
Schedule a zonefetch
Scheduling and rescheduling a zonefetch is also similar. Refactor into zonefetch functions. This also increments and decrements the zone's internal reference counter in the same module, which may be less confusing when reading the code.
This commit is contained in:
parent
77418fedce
commit
868ede012c
3 changed files with 67 additions and 21 deletions
|
|
@ -106,6 +106,32 @@ dns_zonefetch_done(void *arg);
|
|||
* the fetch type.
|
||||
*/
|
||||
|
||||
void
|
||||
dns_zonefetch_schedule(dns_zonefetch_t *fetch, dns_name_t *name);
|
||||
/*%<
|
||||
* Schedule a zone fetch, starting at 'name'. Initializes the rdata sets,
|
||||
* and sets the starting name to 'name'. Note that the query type is
|
||||
* determined by the type of zone fetch. This function also increments the
|
||||
* corresponding zone's ireferences (to be decremented in
|
||||
* dns_zonefetch_done()).
|
||||
*
|
||||
* Requires:
|
||||
* 'fetch' is not NULL.
|
||||
* 'name' is not NULL.
|
||||
*/
|
||||
|
||||
void
|
||||
dns_zonefetch_reschedule(dns_zonefetch_t *fetch);
|
||||
/*%<
|
||||
* Reschedule a zone fetch. Initializes the rdata sets and increments the
|
||||
* corresponding zone's ireferences (to be decremented in
|
||||
* dns_zonefetch_done()).
|
||||
*
|
||||
* Requires:
|
||||
* 'fetch' is not NULL.
|
||||
* 'name' is not NULL.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
dns_zonefetch_verify(dns_zonefetch_t *fetch, isc_result_t eresult,
|
||||
dns_trust_t trust);
|
||||
|
|
|
|||
|
|
@ -11332,7 +11332,7 @@ zone_refreshkeys(dns_zone_t *zone) {
|
|||
result = dns_rriterator_nextrrset(&rrit))
|
||||
{
|
||||
isc_stdtime_t timer = 0xffffffff;
|
||||
dns_name_t *name = NULL, *kname = NULL;
|
||||
dns_name_t *name = NULL;
|
||||
dns_rdataset_t *kdset = NULL;
|
||||
uint32_t ttl;
|
||||
|
||||
|
|
@ -11411,28 +11411,22 @@ zone_refreshkeys(dns_zone_t *zone) {
|
|||
isc_mem_attach(zone->mctx, &fetch->mctx);
|
||||
|
||||
zone->fetchcount[ZONEFETCHTYPE_KEY]++;
|
||||
isc_refcount_increment0(&zone->irefs);
|
||||
kname = dns_fixedname_initname(&fetch->name);
|
||||
dns_name_dup(name, zone->mctx, kname);
|
||||
dns_rdataset_init(&fetch->rrset);
|
||||
dns_rdataset_init(&fetch->sigset);
|
||||
|
||||
kfetch = &fetch->fetchdata.keyfetch;
|
||||
dns_rdataset_init(&kfetch->keydataset);
|
||||
dns_rdataset_clone(kdset, &kfetch->keydataset);
|
||||
dns_db_attach(db, &kfetch->db);
|
||||
|
||||
dns_zonefetch_schedule(fetch, name);
|
||||
|
||||
if (isc_log_wouldlog(ISC_LOG_DEBUG(3))) {
|
||||
char namebuf[DNS_NAME_FORMATSIZE];
|
||||
dns_name_format(kname, namebuf,
|
||||
sizeof(namebuf));
|
||||
dns_name_format(name, namebuf, sizeof(namebuf));
|
||||
dnssec_log(zone, ISC_LOG_DEBUG(3),
|
||||
"Creating key fetch in "
|
||||
"zone_refreshkeys() for '%s'",
|
||||
namebuf);
|
||||
}
|
||||
|
||||
isc_async_run(zone->loop, dns_zonefetch_run, fetch);
|
||||
fetching = true;
|
||||
#ifdef ENABLE_AFL
|
||||
}
|
||||
|
|
@ -21112,16 +21106,14 @@ nsfetch_continue(dns_zonefetch_t *fetch) {
|
|||
#endif /* ifdef ENABLE_AFL */
|
||||
LOCK_ZONE(zone);
|
||||
zone->fetchcount[ZONEFETCHTYPE_NS]++;
|
||||
isc_refcount_increment0(&zone->irefs);
|
||||
|
||||
dns_rdataset_init(&fetch->rrset);
|
||||
dns_rdataset_init(&fetch->sigset);
|
||||
dns_zonefetch_reschedule(fetch);
|
||||
|
||||
if (isc_log_wouldlog(ISC_LOG_DEBUG(3))) {
|
||||
dnssec_log(zone, ISC_LOG_DEBUG(3),
|
||||
"Creating parent NS fetch in "
|
||||
"nsfetch_continue()");
|
||||
}
|
||||
isc_async_run(zone->loop, dns_zonefetch_run, fetch);
|
||||
UNLOCK_ZONE(zone);
|
||||
#ifdef ENABLE_AFL
|
||||
}
|
||||
|
|
@ -21303,7 +21295,6 @@ zone_checkds(dns_zone_t *zone) {
|
|||
#endif /* ifdef ENABLE_AFL */
|
||||
dns_zonefetch_t *fetch = NULL;
|
||||
dns_nsfetch_t *nsfetch = NULL;
|
||||
dns_name_t *name = NULL;
|
||||
|
||||
fetch = isc_mem_get(zone->mctx, sizeof(dns_zonefetch_t));
|
||||
*fetch = (dns_zonefetch_t){
|
||||
|
|
@ -21324,22 +21315,18 @@ zone_checkds(dns_zone_t *zone) {
|
|||
|
||||
LOCK_ZONE(zone);
|
||||
zone->fetchcount[ZONEFETCHTYPE_NS]++;
|
||||
isc_refcount_increment0(&zone->irefs);
|
||||
name = dns_fixedname_initname(&fetch->name);
|
||||
dns_name_dup(&zone->origin, zone->mctx, name);
|
||||
dns_rdataset_init(&fetch->rrset);
|
||||
dns_rdataset_init(&fetch->sigset);
|
||||
|
||||
nsfetch = &fetch->fetchdata.nsfetch;
|
||||
dns_name_init(&nsfetch->pname);
|
||||
dns_name_clone(&zone->origin, &nsfetch->pname);
|
||||
|
||||
dns_zonefetch_schedule(fetch, &zone->origin);
|
||||
|
||||
if (isc_log_wouldlog(ISC_LOG_DEBUG(3))) {
|
||||
dnssec_log(
|
||||
zone, ISC_LOG_DEBUG(3),
|
||||
"Creating parent NS fetch in zone_checkds()");
|
||||
}
|
||||
isc_async_run(zone->loop, dns_zonefetch_run, fetch);
|
||||
UNLOCK_ZONE(zone);
|
||||
#ifdef ENABLE_AFL
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
/*! \file */
|
||||
|
||||
#include <isc/async.h>
|
||||
#include <isc/loop.h>
|
||||
|
||||
#include <dns/resolver.h>
|
||||
|
|
@ -188,6 +189,38 @@ cleanup:
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
zonefetch_schedule(dns_zonefetch_t *fetch, dns_name_t *name) {
|
||||
dns_zone_t *zone = fetch->zone;
|
||||
|
||||
isc_refcount_increment0(dns__zone_irefs(zone));
|
||||
|
||||
if (name != NULL) {
|
||||
dns_name_t *fname = dns_fixedname_initname(&fetch->name);
|
||||
dns_name_dup(name, fetch->mctx, fname);
|
||||
}
|
||||
|
||||
dns_rdataset_init(&fetch->rrset);
|
||||
dns_rdataset_init(&fetch->sigset);
|
||||
|
||||
isc_async_run(dns_zone_getloop(zone), dns_zonefetch_run, fetch);
|
||||
}
|
||||
|
||||
void
|
||||
dns_zonefetch_schedule(dns_zonefetch_t *fetch, dns_name_t *name) {
|
||||
REQUIRE(fetch != NULL);
|
||||
REQUIRE(name != NULL);
|
||||
|
||||
zonefetch_schedule(fetch, name);
|
||||
}
|
||||
|
||||
void
|
||||
dns_zonefetch_reschedule(dns_zonefetch_t *fetch) {
|
||||
REQUIRE(fetch != NULL);
|
||||
|
||||
zonefetch_schedule(fetch, NULL);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_zonefetch_verify(dns_zonefetch_t *fetch, isc_result_t eresult,
|
||||
dns_trust_t trust) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue