resolver.c revision 9736378f29ae166c0449af7b8511961547c35117
/*
* Copyright (C) 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#include <config.h>
#include <isc/assertions.h>
#include <dns/dispatch.h>
#include <dns/resolver.h>
#include <dns/rdataset.h>
#define DNS_RESOLVER_TRACE
#ifdef DNS_RESOLVER_TRACE
ISC_LOG_DEBUG(3), \
"res %p: %s", res, (m))
ISC_LOG_DEBUG(3), \
"res %p: %s", (r), (m))
ISC_LOG_DEBUG(3), \
"fctx %p: %s", fctx, (m))
ISC_LOG_DEBUG(3), \
"fetch %p (fctx %p): %s", \
ISC_LOG_DEBUG(3), \
"resquery %p (fctx %p): %s", \
#else
#define RTRACE(m)
#define RRTRACE(r, m)
#define FCTXTRACE(m)
#define FTRACE(m)
#define QTRACE(m)
#endif
typedef struct fetchctx fetchctx_t;
typedef struct query {
/* Not locked. */
unsigned int magic;
fetchctx_t * fctx;
/* Locked by fctx lock. */
unsigned char data[512];
} resquery_t;
typedef enum {
fetchstate_init = 0,
} fetchstate;
struct fetchctx {
/* Not locked. */
unsigned int magic;
unsigned int options;
isc_task_t * task;
unsigned int bucketnum;
/* Locked by lock. */
unsigned int references;
/* Only changable by event actions running in the context's task */
unsigned int attributes;
isc_timer_t * timer;
unsigned int pending;
};
#define FCTX_ATTR_HAVEANSWER 0x01
#define FCTX_ATTR_GLUING 0x02
#define FCTX_ATTR_ADDRWAIT 0x04
#define FCTX_ATTR_SHUTTINGDOWN 0x08
#define FCTX_ATTR_WANTCACHE 0x10
#define FCTX_ATTR_WANTNCACHE 0x20
0)
0)
0)
!= 0)
struct dns_fetch {
unsigned int magic;
void * private;
};
typedef struct fctxbucket {
isc_task_t * task;
} fctxbucket_t;
struct dns_resolver {
/* Unlocked */
unsigned int magic;
dns_view_t * view;
/* Locked by lock. */
unsigned int references;
unsigned int nbuckets;
unsigned int activebuckets;
};
static inline isc_result_t
ISC_FALSE));
}
static inline isc_result_t
ISC_FALSE));
}
static inline void
/*
* We don't return a result if resetting the timer to inactive fails
* since there's nothing to be done about it. Resetting to inactive
* should never fail anyway, since the code as currently written
* cannot fail in that case.
*/
if (result != ISC_R_SUCCESS) {
"isc_timer_reset(): %s",
}
}
static inline void
FCTXTRACE("cancelquery");
deventp);
}
static void
FCTXTRACE("cancelqueries");
query = next_query) {
}
}
static void
}
}
static inline void
FCTXTRACE("stopeverything");
}
static inline void
/*
* Caller must be holding the appropriate bucket lock.
*/
FCTXTRACE("sendevents");
event = next_event) {
if (!HAVE_ANSWER(fctx))
}
}
static void
FCTXTRACE("done");
}
static void
/*
* XXXRTH
*
* Currently we don't wait for the senddone event before retrying
* a query. This means that if we get really behind, we may end
* up doing extra work!
*/
(void)task;
}
static isc_result_t
isc_region_t r;
FCTXTRACE("sendquery");
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS)
goto cleanup_temps;
if (result != ISC_R_SUCCESS)
goto cleanup_temps;
return (ISC_R_NOMEMORY);
/*
* If this is a TCP query, then we need to make a socket and
* a dispatch for it here. Otherwise we use the resolver's
* shared dispatch. We do not attach to the resolver's shared
* dispatch if we use it, so the resolver MUST ensure that no
* fetches are running before changing the shared dispatch.
*/
/* XXXRTH */
goto cleanup_query;
} else {
switch (isc_sockaddr_pf(address)) {
case AF_INET:
break;
case AF_INET6:
break;
default:
goto cleanup_query;
}
/*
* We should always have a valid dispatcher here. If we
* don't support a protocol family, then its dispatcher
* will be NULL, but we shouldn't be finding addresses for
* protocol types we don't support, so the dispatcher
* we found should never be NULL.
*/
}
/*
* Get a query id from the dispatch.
*/
task,
if (result != ISC_R_SUCCESS)
goto cleanup_query;
/*
* Set up question.
*/
/*
* We don't have to set opcode because it defaults to query.
*/
/*
* recipient.
*/
/*
* Convert the question to wire format.
*/
if (result != ISC_R_SUCCESS)
goto cleanup_message;
DNS_SECTION_QUESTION, 0, 0);
if (result != ISC_R_SUCCESS)
goto cleanup_message;
DNS_SECTION_ADDITIONAL, 0, 0);
if (result != ISC_R_SUCCESS)
goto cleanup_message;
if (result != ISC_R_SUCCESS)
goto cleanup_message;
}
/*
* We're now done with the query message.
*/
/*
* Send the query!
*/
&r, task, resquery_senddone,
if (result != ISC_R_SUCCESS)
goto cleanup_message;
/*
* Finally, we've got everything going!
*/
QTRACE("sent");
return (ISC_R_SUCCESS);
/*
* Stop the dispatcher from listening.
*/
NULL);
/*
* XXXRTH will need to cleanup a nonshared dispatch and TCP socket
* here.
*/
return (result);
}
static void
unsigned int bucketnum;
(void)task;
FCTXTRACE("finddone");
/*
* The fetch is waiting for a name to be found.
*/
/*
* We've got nothing else to wait for and don't
* know the answer. There's nothing to do but
* fail the fctx.
*/
}
SHUTTINGDOWN(fctx)) {
}
if (want_try)
else if (want_done)
else if (bucket_empty)
}
static isc_result_t
isc_region_t r;
unsigned int options;
FCTXTRACE("getaddresses");
if (result != ISC_R_SUCCESS)
return (result);
while (result == ISC_R_SUCCESS) {
/*
* Extract the name from the NS record.
*/
dns_rdata_toregion(&rdata, &r);
dns_name_fromregion(&name, &r);
/*
* XXXRTH If this name is the same as QNAME, remember
* skip it, and remember that we did so so we can
* use an ancestor QDOMAIN if we find no addresses.
*/
/*
* See what we know about this address.
*/
&find);
if (result != ISC_R_SUCCESS)
return (result);
/*
* We have at least some of the addresses for the
* name.
*/
/*
* XXXRTH Sort.
*/
} else {
/*
* We don't know any of the addresses for this
* name.
*/
/*
* We're looking for them and will get an
* event about it later.
*/
} else {
/*
* And ADB isn't going to send us any events
* either. This query loses.
*/
}
}
}
if (result != DNS_R_NOMORE)
return (result);
/*
* We're fetching the addresses, but don't have any yet.
* Tell the caller to wait for an answer.
*/
result = DNS_R_WAIT;
/*
* We've lost completely. We don't know any addresses, and
* the ADB has told us it can't get them.
*/
} else {
/*
* We've found some addresses. We might still be looking
* for more addresses.
*/
/*
* XXXRTH Sort.
*/
}
return (result);
}
#define FCTX_ADDRINFO_MARK 0x01
== 0)
static inline dns_adbaddrinfo_t *
int count = 0;
/*
* Return the next untried address, if any.
*/
/*
* Move to the next find.
*/
else {
}
/*
* Find the first unmarked addrinfo.
*/
count++;
break;
}
}
break;
}
return (addrinfo);
}
static void
FCTXTRACE("try");
/*
* XXXRTH We don't try to handle forwarding yet.
*/
/*
* We have no more addresses. Start over.
*/
if (result == DNS_R_WAIT) {
/*
* Sleep waiting for addresses.
*/
FCTXTRACE("addrwait");
return;
} else if (result != ISC_R_SUCCESS) {
/*
* Something bad happened.
*/
return;
}
/*
* fctx_getaddresses() returned success, so at least one
* of the find lists should be nonempty.
*/
}
/*
* XXXRTH This is the place where a try strategy routine would
* be called to send one or more queries. Instead, we
* just send a single query.
*/
if (result != ISC_R_SUCCESS)
}
static isc_boolean_t
unsigned int bucketnum;
/*
* Caller must be holding the bucket lock.
*/
FCTXTRACE("destroy");
}
return (ISC_TRUE);
return (ISC_FALSE);
}
/*
* Fetch event handlers.
*/
static void
(void)task; /* Keep compiler quiet. */
FCTXTRACE("timeout");
} else {
/*
* We could cancel the running queries here, or we could let
* them keep going. Right now we choose the latter...
*/
}
}
static void
unsigned int bucketnum;
(void)task; /* Keep compiler quiet. */
FCTXTRACE("shutdown");
}
if (bucket_empty)
}
static void
unsigned int bucketnum;
(void)task; /* Keep compiler quiet. */
FCTXTRACE("start");
if (fctx->want_shutdown) {
/*
* We haven't started this fctx yet, and we've been requested
* to shut it down.
*
* The events list should be empty, so we INSIST on it.
*/
} else {
/*
* Normal fctx startup.
*/
/*
* Reset the control event for later use in shutting down
* the fctx.
*/
}
if (!done) {
/*
* All is well. Start working on the fetch.
*/
} else if (bucket_empty)
}
/*
* Fetch Creation, Joining, and Cancelation.
*/
static inline isc_result_t
{
FCTXTRACE("join");
/*
* We store the task we're going to send this event to in the
* sender field. We'll make the fetch the sender when we actually
* send the event.
*/
event = (dns_fetchevent_t *)
return (ISC_R_NOMEMORY);
fctx->references++;
return (ISC_R_SUCCESS);
}
static isc_result_t
{
/*
* Caller must be holding the lock for bucket number 'bucketnum'.
*/
return (ISC_R_NOMEMORY);
FCTXTRACE("create");
if (result != ISC_R_SUCCESS)
goto cleanup_fetch;
if (result != ISC_R_SUCCESS)
goto cleanup_name;
}
/*
* Note! We do not attach to the task. We are relying on the
* resolver to ensure that this task doesn't go away while we are
* using it.
*/
fctx->references = 0;
fctx->attributes = 0;
if (result != ISC_R_SUCCESS)
goto cleanup_domain;
if (result != ISC_R_SUCCESS)
goto cleanup_qmessage;
/*
* Compute an expiration time for the entire fetch.
*/
if (iresult != ISC_R_SUCCESS) {
"isc_time_nowplusinterval: %s",
goto cleanup_rmessage;
}
/*
* XXX Retry interval initialization. Should be setup by the
* transmission strategy routine (when we have one).
*/
/*
* Create an inactive timer. It will be made active when the fetch
* is actually started.
*/
if (iresult != ISC_R_SUCCESS) {
"isc_timer_create: %s",
goto cleanup_rmessage;
}
return (ISC_R_SUCCESS);
}
return (result);
}
/*
* Handle Responses
*/
static inline isc_result_t
/*
* Caller must be holding the fctx lock.
*/
/*
* XXXRTH Currently we support only one question.
*/
return (DNS_R_FORMERR);
if (result != ISC_R_SUCCESS)
return (result);
return (DNS_R_FORMERR);
return (ISC_R_SUCCESS);
}
static void
/*
* Set up any other events to have the same data as the first
* event.
*
* Caller must be holding the appropriate lock.
*/
return;
if (result != ISC_R_SUCCESS)
else
event->sigrdataset);
}
}
static inline isc_result_t
void *data;
/*
* The appropriate bucket lock must be held.
*/
/*
* Is DNSSEC validation required for this name?
*/
/*
* This name is at or below one of the view's security roots,
* so DNSSEC validation is required.
*/
} else if (result != ISC_R_NOTFOUND) {
/*
* Something bad happened.
*/
return (result);
}
asigrdataset = NULL;
if (result != ISC_R_SUCCESS)
return (result);
}
}
}
/*
* Find or create the cache node.
*/
&node);
if (result != ISC_R_SUCCESS)
return (result);
/*
* Cache or validate each cacheable rdataset.
*/
continue;
if (need_validation) {
/*
* XXXRTH.
*/
return (DNS_R_NOTIMPLEMENTED);
/*
* It's OK to cache this rdataset now.
*/
else
else {
}
}
if (result == DNS_R_UNCHANGED) {
/*
* The answer in the cache is better
* than the answer we found, and is
* a negative cache entry, so we
* must set eresult appropriately.
*/
eresult =
else
eresult =
}
} else if (result != ISC_R_SUCCESS)
break;
}
}
}
} else
return (result);
}
static inline isc_result_t
FCTXTRACE("cache_message");
for (section = DNS_SECTION_ANSWER;
section++) {
while (result == ISC_R_SUCCESS) {
&name);
if (result != ISC_R_SUCCESS)
break;
}
}
if (result != ISC_R_NOMORE)
break;
}
if (result == ISC_R_NOMORE)
return (result);
}
static inline isc_result_t
void *data;
FCTXTRACE("ncache_message");
/*
* Is DNSSEC validation required for this name?
*/
/*
* This name is at or below one of the view's security roots,
* so DNSSEC validation is required.
*/
} else if (result != ISC_R_NOTFOUND) {
/*
* Something bad happened.
*/
return (result);
}
if (result != ISC_R_SUCCESS)
goto unlock;
}
&node);
if (result != ISC_R_SUCCESS)
goto unlock;
if (result == DNS_R_UNCHANGED) {
/*
* The data in the cache is better than the negative cache
* entry we're trying to add.
*/
/*
* The cache data is also a negative cache
* entry.
*/
else
} else {
/*
* Either we don't care about the nature of the
* cache rdataset (because no fetch is interested
* in the outcome), or the cache rdataset is not
* a negative cache entry. Whichever case it is,
* we can return success. In the latter case,
* 'eresult' is already set correctly.
*/
}
} else if (result == ISC_R_SUCCESS) {
if (covers == dns_rdatatype_any)
else
} else
goto unlock;
}
return (result);
}
static inline void
{
if (gluing)
else
if (external)
#if 0
/*
* XXXRTH TEMPORARY FOR TESTING!!!
*/
#endif
}
static isc_result_t
else
NULL);
if (result == ISC_R_SUCCESS) {
if (type == dns_rdatatype_a) {
else
if (rtype == dns_rdatatype_a ||
rtype == dns_rdatatype_aaaa ||
gluing);
/*
* XXXRTH Need to do a controlled recursion
* on the A6 prefix names to mark
* any additional data related to them.
*
* Ick.
*/
}
} else {
&rdataset);
if (result == ISC_R_SUCCESS) {
/*
* Do we have its SIG too?
*/
if (result == ISC_R_SUCCESS)
gluing);
}
}
/*
* XXXRTH Some other stuff still needs to be marked.
* See query.c.
*/
}
return (ISC_R_SUCCESS);
}
static inline isc_result_t
isc_region_t r;
if (result != ISC_R_SUCCESS)
return (result);
dns_rdata_toregion(&rdata, &r);
dns_name_fromregion(tname, &r);
return (ISC_R_SUCCESS);
}
static inline isc_result_t
{
isc_region_t r;
int order;
/*
* Get the target name of the DNAME.
*/
if (result != ISC_R_SUCCESS)
return (result);
dns_rdata_toregion(&rdata, &r);
dns_name_fromregion(&tname, &r);
/*
* Get the prefix of qname.
*/
&nbits);
if (namereln != dns_namereln_subdomain)
return (DNS_R_FORMERR);
if (result != ISC_R_SUCCESS)
return (result);
}
static isc_result_t
FCTXTRACE("noanswer_response");
/*
* Setup qname.
*/
/*
* We have a normal, non-chained negative response or
* referral.
*/
else
} else {
/*
* We're being invoked by answer_response() after it has
*/
}
/*
* We have to figure out if this is a negative response, or a
* referral.
*/
/*
* Sometimes we can tell if its a negative response by looking at
* the message header.
*/
/*
* Process the authority section.
*/
ns_rdataset = NULL;
if (type == dns_rdatatype_sig)
/*
* NS or SIG NS.
*
* Only one set of NS RRs is allowed.
*/
return (DNS_R_FORMERR);
name->attributes |=
rdataset->attributes |=
/*
* SOA, SIG SOA, NXT, or SIG NXT.
*
* Only one SOA is allowed.
*/
return (DNS_R_FORMERR);
name->attributes |=
rdataset->attributes |=
if (aa)
else
/*
* No additional data needs to be
* marked.
*/
}
}
}
if (result != ISC_R_NOMORE)
return (result);
}
/*
* Did we find anything?
*/
/*
* Nope.
*/
/*
* and haven't found else anything useful here, but
* no error has occurred since we have an answer.
*/
return (ISC_R_SUCCESS);
} else {
/*
* The responder is insane.
*/
return (DNS_R_FORMERR);
}
}
/*
* If we found both NS and SOA, they should be the same name.
*/
return (DNS_R_FORMERR);
/*
* Don't cache the NS RRs.
*/
}
/*
* Do we have a referral? (We only want to follow a referral if
* we're not following a chain.)
*/
/*
* Mark any additional data related to this rdataset.
* It's important that we do this before we change the
* query domain.
*/
fctx);
/*
* Set the current query domain to the referral name.
*/
if (result != ISC_R_SUCCESS)
return (result);
return (DNS_R_DELEGATION);
}
if (negative_response)
return (ISC_R_SUCCESS);
}
static inline isc_result_t
unsigned int aflag;
FCTXTRACE("answer_response");
/*
* Examine the answer section, marking those rdatasets which are
* part of the answer and should be cached.
*/
else
aflag = 0;
type == dns_rdatatype_any) {
/*
* We've found an ordinary answer.
*/
/*
* We've found a signature that
* covers the type we're looking for.
*/
/*
* We're looking for something else,
* but we found a CNAME.
*
* Getting a CNAME response for some
* query types is an error.
*/
if (type == dns_rdatatype_sig ||
type == dns_rdatatype_key ||
return (DNS_R_FORMERR);
&tname);
if (result != ISC_R_SUCCESS)
return (result);
/*
* We're looking for something else,
* but we found a SIG CNAME.
*/
}
if (found) {
/*
* We've found an answer to our
* question.
*/
name->attributes |=
rdataset->attributes |=
if (!chaining) {
/*
* This data is "the" answer
* to our question only if
* we're not chaining (i.e.
* if we haven't followed
* a CNAME or DNAME).
*/
if (aflag ==
else
name->attributes |=
if (aa)
} else if (external) {
/*
* This data is outside of
* our query domain, and
* may only be cached if it
* comes from a secure zone
* and validates.
*/
rdataset->attributes |=
}
/*
* Mark any additional data related
* to this rdataset.
*/
(void)dns_rdataset_additionaldata(
fctx);
/*
* A6 special cases...
*/
}
/*
* CNAME chaining.
*/
if (want_chaining) {
rdataset->attributes |=
}
}
/*
* We could add an "else" clause here and
* log that we're ignoring this rdataset.
*/
}
} else {
/*
* Look for a DNAME (or its SIG). Anything else is
* ignored.
*/
aflag = 0;
/*
* We're looking for something else,
* but we found a DNAME.
*
* If we're not chaining, then the
* DNAME should not be external.
*/
return (DNS_R_FORMERR);
&dname);
if (result == ISC_R_NOSPACE) {
/*
* We can't construct the
* DNAME target. Do not
* try to continue.
*/
} else if (result != ISC_R_SUCCESS)
return (result);
/*
* We've found a signature that
* covers the DNAME.
*/
}
if (found) {
/*
* We've found an answer to our
* question.
*/
name->attributes |=
rdataset->attributes |=
if (!chaining) {
/*
* This data is "the" answer
* to our question only if
* we're not chaining.
*/
name->attributes |=
if (aa)
} else if (external) {
rdataset->attributes |=
}
/*
* DNAME chaining.
*/
if (want_chaining) {
rdataset->attributes |=
&dname);
}
}
}
}
}
if (result != ISC_R_NOMORE)
return (result);
/*
* We should have found an answer.
*/
if (!have_answer)
return (DNS_R_FORMERR);
/*
* This response is now potentially cacheable.
*/
/*
* Did chaining end before we got the final answer?
*/
if (want_chaining) {
/*
* Yes. This may be a negative reply, so hand off
* authority section processing to the noanswer code.
* If it isn't a noanswer response, no harm will be
* done.
*/
}
/*
* We didn't end with an incomplete chain, so the rcode should be
* "no error".
*/
return (DNS_R_FORMERR);
/*
* Examine the authority section (if there is one).
*
* We expect there to be only one owner name for all the rdatasets
* in this section, and we expect that it is not external.
*/
if (!external) {
/*
* We expect to find NS or SIG NS rdatasets, and
* nothing else.
*/
name->attributes |=
rdataset->attributes |=
else
/*
* Mark any additional data related
* to this rdataset.
*/
(void)dns_rdataset_additionaldata(
fctx);
}
}
/*
* Since we've found a non-external name in the
* authority section, we should stop looking, even
* if we didn't find any NS or SIG NS.
*/
}
}
if (result != ISC_R_NOMORE)
return (result);
return (ISC_R_SUCCESS);
}
static void
(void)task;
QTRACE("response");
covers = 0;
if (result != ISC_R_SUCCESS)
goto done;
if (result != ISC_R_SUCCESS) {
switch (result) {
case DNS_R_FORMERR:
case DNS_R_UNEXPECTEDEND:
break;
case DNS_R_MOREDATA:
break;
}
goto done;
}
/*
* INSIST() that the message comes from the place we sent it to,
* since the dispatch code should ensure this.
*
* INSIST() that the message id is correct (this should also be
* ensured by the dispatch code).
*/
/*
* Is it a query response?
*/
/* XXXRTH Log */
goto done;
}
/*
* Is the remote server broken, or does it dislike us?
*/
/*
* XXXRTH If we want to catch a FORMERR caused by an EDNS0
* OPT RR, this is the place to do it.
*
* XXXRTH Need to deal with YXDOMAIN code.
*/
goto done;
}
/*
* Is the question the same as the one we asked?
*/
if (result != ISC_R_SUCCESS) {
/* XXXRTH Log */
if (result == DNS_R_FORMERR)
goto done;
}
/*
* Did we get any answers?
*/
/*
* We've got answers.
*/
if (result != ISC_R_SUCCESS) {
if (result == DNS_R_FORMERR)
goto done;
}
/*
* NXDOMAIN, NXRDATASET, or referral.
*/
if (result == DNS_R_DELEGATION) {
/*
* We don't have the answer, but we know a better
* place to look.
*/
} else if (result != ISC_R_SUCCESS) {
/*
* Something has gone wrong.
*/
if (result == DNS_R_FORMERR)
goto done;
}
} else {
/*
* The server is insane.
*/
/* XXXRTH Log */
goto done;
}
/*
* XXXRTH Explain this.
*/
/*
* Cache the cacheable parts of the message. This may also cause
* work to be queued to the DNSSEC validator.
*/
if (result != ISC_R_SUCCESS)
goto done;
}
/*
* Ncache the negatively cacheable parts of the message. This may
* also cause work to be queued to the DNSSEC validator.
*/
if (WANTNCACHE(fctx)) {
else
/*
* Cache any negative cache entries in the message.
*/
}
done:
/*
* Give the event back to the dispatcher.
*/
/*
* XXXRTH Record round-trip statistics here. Note that 'result'
* MUST NOT be changed by this recording process.
*/
if (keep_trying) {
if (result == DNS_R_FORMERR)
/*
* XXXRTH If we have a broken server at this point, we will
* decrease its 'goodness', possibly add a 'lame'
* entry, and maybe log a message.
*/
if (get_nameservers) {
if (result != ISC_R_SUCCESS) {
return;
}
&fctx->nameservers,
NULL);
if (result != ISC_R_SUCCESS) {
return;
}
/*
* The best nameservers are now above our
* previous QDOMAIN.
*
* XXXRTH What should we do here?
*/
QTRACE("avoiding upward referral");
return;
}
if (result != ISC_R_SUCCESS) {
return;
}
}
/*
* Try again.
*/
/*
* All has gone well so far, but we are waiting for the
* DNSSEC validator to validate the answer.
*/
if (result != ISC_R_SUCCESS)
} else {
/*
* We're done.
*/
}
}
/***
*** Resolver Methods
***/
static void
unsigned int i;
RTRACE("destroy");
}
}
static void
RTRACE("empty_bucket");
res->activebuckets--;
if (res->activebuckets == 0)
if (need_destroy)
}
{
unsigned int i, buckets_created = 0;
return (ISC_R_NOMEMORY);
RTRACE("create");
ntasks * sizeof (fctxbucket_t));
goto cleanup_res;
}
for (i = 0; i < ntasks; i++) {
if (result != ISC_R_SUCCESS)
goto cleanup_buckets;
if (result != ISC_R_SUCCESS) {
goto cleanup_buckets;
}
}
/*
* IPv4 Dispatcher.
*/
} else if (isc_net_probeipv4() == ISC_R_SUCCESS) {
/*
* Create an IPv4 UDP socket and a dispatcher for it.
*/
&res->udpsocket4);
if (result != ISC_R_SUCCESS)
goto cleanup_buckets;
if (result != ISC_R_SUCCESS)
port++;
}
if (result != ISC_R_SUCCESS) {
RTRACE("Could not open UDP port");
goto cleanup_buckets;
}
if (result != ISC_R_SUCCESS)
goto cleanup_udpsocket4;
}
/*
* IPv6 Dispatcher.
*/
if (isc_net_probeipv6() == ISC_R_SUCCESS) {
/*
* Create an IPv6 UDP socket and a dispatcher for it.
*/
&res->udpsocket6);
if (result != ISC_R_SUCCESS)
goto cleanup_dispatch4;
if (result != ISC_R_SUCCESS)
goto cleanup_udpsocket6;
}
if (result != ISC_R_SUCCESS)
goto cleanup_dispatch6;
return (ISC_R_SUCCESS);
for (i = 0; i < buckets_created; i++) {
}
return (result);
}
void
source->references++;
}
void
unsigned int i;
RTRACE("detach");
res->references--;
if (res->references == 0) {
RTRACE("exiting");
/*
* XXXRTH Post shutdown events?
*/
res->activebuckets--;
}
}
if (res->activebuckets == 0)
}
if (need_destroy)
}
static inline isc_boolean_t
unsigned int options)
{
return (ISC_FALSE);
}
static inline void
isc_buffer_t b;
char text[1024];
isc_region_t r;
/*
* XXXRTH Allow this to be turned on and off...
*/
return;
isc_buffer_available(&b, &r);
if (r.length < 1)
return;
*r.base = ' ';
isc_buffer_add(&b, 1);
return;
isc_buffer_used(&b, &r);
/* XXXRTH Give them their own category? */
}
/*
* XXXRTH This routine takes an unconscionable number of arguments!
*
* Maybe caller should allocate an event and pass that in? Something must
* be done!
*/
{
unsigned int bucketnum;
(void)forwarders;
/* XXXRTH */
if ((options & DNS_FETCHOPT_TCP) != 0)
return (DNS_R_NOTIMPLEMENTED);
/*
* XXXRTH use a mempool?
*/
return (ISC_R_NOMEMORY);
goto unlock;
}
if ((options & DNS_FETCHOPT_UNSHARED) == 0) {
break;
}
}
if (result != ISC_R_SUCCESS)
goto unlock;
}
if (new_fctx) {
if (result == ISC_R_SUCCESS) {
/*
* Launch this fctx.
*/
} else {
/*
* We don't care about the result of fctx_destroy()
* since we know we're not exiting.
*/
(void)fctx_destroy(fctx);
}
}
if (result == ISC_R_SUCCESS) {
FTRACE("created");
} else
return (result);
}
void
FTRACE("cancelfetch");
event = next_event) {
link);
break;
}
}
}
}
}
void
FTRACE("destroyfetch");
/*
* Sanity check. The caller should have either gotten its
* fetchevent before trying to destroy the fetch.
*/
event = next_event) {
}
}
fctx->references--;
if (fctx->references == 0) {
/*
* No one cares about the result of this fetch anymore.
* Shut it down.
*/
/*
* Unless we're still initializing (in which case the
* control event is still outstanding), we need to post
* the control event to tell the fetch we want it to
* exit.
*/
&cevent);
}
}
}