query.c revision 64a840af4969584d44d69e69b11f5da925981b43
/*
* 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/fixedname.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdatasetiter.h>
#include <dns/resolver.h>
NS_QUERYATTR_PARTIALANSWER) != 0)
NS_QUERYATTR_CACHEOK) != 0)
NS_QUERYATTR_RECURSIONOK) != 0)
NS_QUERYATTR_RECURSING) != 0)
static isc_result_t
static inline void
static void
static inline void
/*
* client->query.qname was dynamically allocated.
*/
}
}
static inline void
unsigned int i;
/*
* Reset the query state of a client to its default state.
*/
/*
* Cancel the fetch if it's running.
*/
}
/*
* Cleanup any active versions.
*/
dbversion = dbversion_next) {
}
/*
* Clean up free versions.
*/
dbversion = dbversion_next, i++) {
/*
* If we're not freeing everything, we keep the first three
* dbversions structures around.
*/
if (i > 3 || everything) {
link);
sizeof *dbversion);
}
}
}
}
}
static void
(void)result;
}
void
}
static inline isc_result_t
/*
* Allocate a name buffer.
*/
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_SUCCESS);
}
static inline isc_buffer_t *
isc_region_t r;
/*
* Return a name buffer with space for a maximal name, allocating
* a new one if necessary.
*/
if (result != ISC_R_SUCCESS)
return (NULL);
}
isc_buffer_available(dbuf, &r);
if (r.length < 255) {
if (result != ISC_R_SUCCESS)
return (NULL);
isc_buffer_available(dbuf, &r);
}
return (dbuf);
}
static inline void
isc_region_t r;
/*
* 'name' is using space in 'dbuf', but 'dbuf' has not yet been
* adjusted to take account of that. We do the adjustment.
*/
dns_name_toregion(name, &r);
}
static inline void
/*
* 'name' is no longer needed. Return it to our pool of temporary
* names. If it is using a name buffer, relinquish its exclusive
* rights on the buffer.
*/
if (dns_name_hasbuffer(name)) {
!= 0);
}
}
static inline dns_name_t *
{
isc_region_t r;
if (result != ISC_R_SUCCESS)
return (NULL);
isc_buffer_available(dbuf, &r);
return (name);
}
static inline dns_rdataset_t *
if (result != ISC_R_SUCCESS)
return (NULL);
return (rdataset);
}
static inline void
}
}
static inline isc_result_t
unsigned int i;
for (i = 0; i < n; i++) {
link);
} else {
/*
* We only return ISC_R_NOMEMORY if we couldn't
* allocate anything.
*/
if (i == 0)
return (ISC_R_NOMEMORY);
else
return (ISC_R_SUCCESS);
}
}
return (ISC_R_SUCCESS);
}
static inline ns_dbversion_t *
if (result != ISC_R_SUCCESS)
return (NULL);
}
return (dbversion);
}
if (result != ISC_R_SUCCESS)
return (result);
return (query_newnamebuf(client));
}
static inline dns_dbversion_t *
/*
* We may already have done a query related to this
* database. If so, we must be sure to make subsequent
* queries from the same version.
*/
break;
}
/*
* This is a new zone for this query. Add it to
* the active list.
*/
return (NULL);
}
}
static isc_result_t
{
unsigned int dboptions;
/*
* Find a database to answer the query.
*/
else if (result != DNS_R_SUCCESS)
goto cleanup;
/*
* Get the current version of this database.
*/
if (is_zone) {
goto cleanup;
}
/*
* Now look for an answer in the database.
*/
if (result == DNS_R_DELEGATION ||
result == DNS_R_NOTFOUND ||
result == DNS_R_NXGLUE) {
if (is_zone) {
/*
* Either the answer is in the cache, or we
* don't know it.
*/
dns_db_detach(&db);
goto db_find;
}
} else {
/*
* We don't have the data in the cache. If we've got
* glue from the zone, use it.
*/
goto cleanup;
}
}
/*
* We don't know the answer.
*/
} else if (result == DNS_R_GLUE) {
/*
* We found an answer, but the cache may be better.
* Remember what we've got and go look in the cache.
*/
}
dns_db_detach(&db);
goto db_find;
}
/*
* Otherwise, the glue is the best answer.
*/
} else if (result != ISC_R_SUCCESS)
}
dns_db_detach(&db);
return (result);
}
static inline isc_boolean_t
{
for (section = DNS_SECTION_ANSWER;
section++) {
if (result == ISC_R_SUCCESS) {
/*
* We've already got this RRset in the response.
*/
return (ISC_TRUE);
} else if (result == DNS_R_NXRDATASET) {
/*
* The name exists, but the rdataset does not.
*/
if (section == DNS_SECTION_ADDITIONAL)
break;
} else
}
/*
* If the dns_name_t we're lookup up is already in the message,
* we don't want to trigger the caller's name replacement logic.
*/
return (ISC_FALSE);
}
static isc_result_t
isc_buffer_t b;
unsigned int dboptions;
/* XXXRTH Other requirements. */
/*
* Initialization.
*/
sigrdataset = NULL;
zsigrdataset = NULL;
a6rdataset = NULL;
/*
* Find a database to answer the query.
*/
else if (result != DNS_R_SUCCESS)
goto cleanup;
/*
* Get the current version of this database.
*/
if (is_zone) {
goto cleanup;
}
/*
* Get some resources...
*/
goto cleanup;
goto cleanup;
/*
* Now look for an answer in the database.
*/
if (is_zone) {
/*
* Either the answer is in the cache, or we
* don't know it. Go look in the cache.
*/
dns_db_detach(&db);
goto db_find;
} else {
/*
* We don't know the answer.
*/
goto cleanup;
}
} else {
/*
* We don't have the data in the cache. If we've
* got glue from the zone, use it.
*/
dns_db_detach(&db);
} else {
/*
* We don't know the answer.
*/
goto cleanup;
}
}
/*
* We found an answer, but the cache may be
* better. Remember what we've got and go look in
* the cache.
*/
goto db_find;
}
} else if (result != DNS_R_SUCCESS)
goto cleanup;
} else
/*
* Note: we only add SIGs if we've added the type they cover,
* so we do not need to check if the SIG rdataset is already
* in the response.
*/
sigrdataset = NULL;
}
}
if (type == dns_rdatatype_a) {
/*
* We treat type A additional section processing as if it
* were "any address type" additional section processing.
*
* We now go looking for A6 and AAAA records, along with
* their signatures.
*
* XXXRTH This code could be more efficient.
*/
} else {
goto addname;
}
if (sigrdataset != NULL) {
} else {
if (sigrdataset == NULL)
goto addname;
}
dns_rdatatype_a6, 0,
/*
* The cache doesn't have an A6, but we may have
* one in the zone's glue.
*/
dns_rdatatype_a6, 0,
}
if (result == ISC_R_SUCCESS) {
dns_rdatatype_a6, &mname)) {
} else
sigrdataset, link);
}
goto addname;
} else
}
/*
* The cache doesn't have an AAAA, but we may have
* one in the zone's glue.
*/
}
if (result == ISC_R_SUCCESS) {
dns_rdatatype_aaaa, &mname)) {
} else
sigrdataset, link);
sigrdataset = NULL;
}
}
}
}
/*
* If we haven't added anything, then we're done.
*/
if (!added_something)
goto cleanup;
/*
* We may have added our rdatasets to an existing name, if so, then
* need_addname will be ISC_FALSE. Whether we used an existing name
* or a new one, we must set fname to NULL to prevent cleanup.
*/
if (need_addname)
/*
* In a few cases, we want to add additional data for additional
* data. It's simpler to just deal with special cases here than
* to try to create a general purpose mechanism and allow the
* rdata implementations to do it themselves.
*
* This involves recursion, but the depth is limited. The
* most complex case is adding a SRV rdataset, which involves
* recursing to add address records, which in turn can cause
* recursion to add KEYs.
*/
/*
* RFC 2535 section 3.5 says that when A or AAAA records are
* retrieved as additional data, any KEY RRs for the owner name
* should be added to the additional data section. Note: we
* do NOT include A6 in the list of types with such treatment
* in additional data because we'd have to do it for each A6
* in the A6 chain.
*
* XXXRTH We should lower the priority here. Alternatively,
* we could raise the priority of glue records.
*/
} else if (type == dns_rdatatype_srv) {
/*
* If we're adding SRV records to the additional data
* section, it's helpful if we add the SRV additional data
* as well.
*/
client);
}
/*
* If we added an A6 rdataset, we should also add everything we
* know about the A6 chains. We wait until now to do this so that
* they'll come after any additional data added above.
*/
if (a6rdataset != NULL) {
}
dns_db_detach(&db);
dns_db_detach(&zdb);
}
return (eresult);
}
static void
{
isc_buffer_t b, *dbuf;
/*
* Add an rrset to the additional data section.
*/
/*
* Get some resources...
*/
csigrdataset = NULL;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
} else {
}
/*
* Note: we only add SIGs if we've added the type they cover, so
* we do not need to check if the SIG rdataset is already in the
* response.
*/
csigrdataset = NULL;
}
/*
* In spite of RFC 2535 section 3.5, we don't currently try to add
* KEY RRs for the A6 records. It's just too much work.
*/
}
static inline void
{
/*
* Add additional data.
*
* We don't care if dns_a6_foreach or dns_rdataset_additionaldata()
* fail.
*/
if (type == dns_rdatatype_a6) {
} else
/*
* RFC 2535 section 3.5 says that when NS, SOA, A, or AAAA records
* are retrieved, any KEY RRs for the owner name should be added
* to the additional data section. We treat A6 records the same way.
*
* We don't care if query_additional() fails.
*/
type == dns_rdatatype_a6) {
/*
* XXXRTH We should lower the priority here. Alternatively,
* we could raise the priority of glue records.
*/
}
}
static void
{
if (sigrdatasetp != NULL)
else
sigrdataset = NULL;
if (result == ISC_R_SUCCESS) {
/*
* We've already got an RRset of the given name and type.
* There's nothing else to do;
*/
return;
} else if (result == DNS_R_NXDOMAIN) {
/*
* The name doesn't exist.
*/
} else
/*
* Note: we only add SIGs if we've added the type they cover, so
* we do not need to check if the SIG rdataset is already in the
* response.
*/
/*
* We have a signature. Add it to the response.
*/
*sigrdatasetp = NULL;
}
}
static inline isc_result_t
/*
* Initialization.
*/
/*
* Get resources and make 'name' be the database origin.
*/
if (result != ISC_R_SUCCESS)
return (result);
goto cleanup;
}
/*
* Find the SOA.
*/
if (result != ISC_R_SUCCESS) {
/*
* This is bad. We tried to get the SOA RR at the zone top
* and it didn't work!
*/
} else {
}
return (eresult);
}
static inline isc_result_t
/*
* Initialization.
*/
/*
* Get resources and make 'name' be the database origin.
*/
if (result != ISC_R_SUCCESS)
return (result);
goto cleanup;
}
/*
* Find the NS rdataset.
*/
if (result != ISC_R_SUCCESS) {
/*
* This is bad. We tried to get the NS rdataset at the zone
* top and it didn't work!
*/
} else {
}
return (eresult);
}
static inline isc_result_t
{
isc_region_t r;
/*
* We assume the name data referred to by qname and tname won't
* go away.
*/
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS)
return (result);
dns_name_toregion(tname, &r);
}
return (ISC_R_SUCCESS);
}
static void
isc_buffer_t b;
sigrdataset = NULL;
zsigrdataset = NULL;
/*
* Find the right database.
*/
if (result == ISC_R_NOTFOUND) {
/*
* We're not directly authoritative for this query name, nor
* is it a subdomain of any zone for which we're
* authoritative.
*/
goto cleanup;
} else if (result != ISC_R_SUCCESS) {
/*
* Something is broken.
*/
goto cleanup;
}
if (is_zone) {
goto cleanup;
} else
/*
* We'll need some resources...
*/
goto cleanup;
goto cleanup;
/*
* Now look for the zonecut.
*/
if (is_zone) {
dns_rdatatype_ns, 0,
if (result != DNS_R_DELEGATION)
goto cleanup;
goto db_find;
}
} else {
if (result == ISC_R_SUCCESS) {
/*
* We found a zonecut in the cache, but our
* zone delegation is better.
*/
}
/*
* We didn't find anything in the cache, but we
* have a zone delegation, so use it.
*/
} else
goto cleanup;
}
if (use_zone) {
/*
* We've already done query_keepname() on
* zfname, so we must set dbuf to NULL to
* prevent query_addrrset() from trying to
* call query_keepname() again.
*/
zsigrdataset = NULL;
}
dns_db_detach(&db);
dns_db_detach(&zdb);
}
}
static inline isc_result_t
/*
* XXXRTH OPT still needs to be added.
* Should get help with this from rdata.c
*/
switch (type) {
case dns_rdatatype_tkey:
return (DNS_R_NOTIMP);
case dns_rdatatype_tsig:
return (DNS_R_FORMERR);
case dns_rdatatype_ixfr:
case dns_rdatatype_axfr:
case dns_rdatatype_mailb:
case dns_rdatatype_maila:
return (DNS_R_REFUSED);
default:
break;
}
return (ISC_R_SUCCESS);
}
static void
/*
* Resume a query after recursion.
*/
/*
* This is the fetch we've been waiting for.
*/
} else {
/*
* This is a fetch completion event for a cancelled fetch.
* Clean up and don't resume the find.
*/
}
/*
* XXXRTH If this client is shutting down, or this transaction
* has timed out, do not resume the find.
*
* We should probably have a "unwait" function that
* decrements waiting and tells us whether we should continue,
* do nothing, or reset the client (resetting would cause the
* client to continue with shutdown if it was in shutdown
* mode).
*/
if (want_find)
}
static isc_result_t
{
/*
* Invoke the resolver.
*/
return (ISC_R_NOMEMORY);
return (ISC_R_NOMEMORY);
}
if (result == ISC_R_SUCCESS) {
/*
* Record that we're waiting for an event. A client which
* is shutting down will not be destroyed until all the
* events have been received.
*/
} else {
}
return (result);
}
#define MAX_RESTARTS 16
#define QUERY_ERROR(r) \
do { \
eresult = r; \
want_restart = ISC_FALSE; \
} while (0)
static void
int order;
isc_region_t r;
isc_buffer_t b;
/*
* One-time initialization.
*
* It's especially important to initialize anything that the cleanup
* code might cleanup.
*/
sigrdataset = NULL;
zsigrdataset = NULL;
/*
* We're returning from recursion. Restore the query context
* and resume.
*/
if (qtype == dns_rdatatype_sig)
else
/*
* We'll need some resources...
*/
goto cleanup;
}
goto cleanup;
}
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
goto resume;
} else
/*
* First we must find the right database.
*/
if (result == ISC_R_NOTFOUND) {
/*
* We're not directly authoritative for this query name, nor
* is it a subdomain of any zone for which we're
* authoritative.
*/
/*
* If we can't use the cache, either because we
* don't have one or because its use has been
* disallowed, there's no more progress we can make
* on this query.
*/
goto cleanup;
}
} else if (result != ISC_R_SUCCESS) {
/*
* Something is broken.
*/
goto cleanup;
}
if (is_zone) {
/*
* Get the current version of this database.
*/
goto cleanup;
}
} else
/*
* Find the first unanswered type in the question section.
*/
qtype = 0;
qcount = 0;
}
qcount++;
}
}
/*
* We had better have found something!
*/
/*
* If there's more than one question, we'll eventually retrieve the
* node and iterate it, trying to find answers. For now, we simply
* refuse requests with more than one question.
*/
if (qcount == 1)
else {
goto cleanup;
}
/*
* See if the type is OK.
*/
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
/*
* If it's a SIG query, we'll iterate the node.
*/
if (qtype == dns_rdatatype_sig)
/*
* We'll need some resources...
*/
goto cleanup;
}
goto cleanup;
}
/*
* Now look for an answer in the database.
*/
switch (result) {
case DNS_R_SUCCESS:
/*
* This case is handled in the main line below.
*/
break;
case DNS_R_GLUE:
case DNS_R_ZONECUT:
/*
* These cases are handled in the main line below.
*/
break;
case DNS_R_NOTFOUND:
/*
* The cache doesn't even have the root NS. Get them from
* the hints DB.
*/
dns_db_detach(&db);
if (result != ISC_R_SUCCESS) {
/*
* We can't even find the hints for the root
* nameservers!
*/
goto cleanup;
}
/*
* XXXRTH We should trigger root server priming here.
*/
/* FALLTHROUGH */
case DNS_R_DELEGATION:
if (is_zone) {
/*
* We're authoritative for an ancestor of QNAME.
*/
/*
* We don't have a cache, so this is the best
* answer.
*
* We enable the retrieval of glue for this
* database by setting client->query.gluedb.
*/
&sigrdataset, dbuf,
} else {
/*
* We might have a better answer or delegation
* in the cache. We'll remember the current
* values of fname, rdataset, and sigrdataset.
* We'll then go looking for QNAME in the
* cache. If we find something better, we'll
* use it instead.
*/
goto db_find;
}
} else {
/*
* We've already got a delegation from
* authoritative data, and it is better
* than what we found in the cache. Use
* it instead of the cache delegation.
*/
/*
* We've already done query_keepname() on
* zfname, so we must set dbuf to NULL to
* prevent query_addrrset() from trying to
* call query_keepname() again.
*/
zsigrdataset = NULL;
/*
* We don't clean up zdb here because we
* may still need it. It will get cleaned
* up by the main cleanup code.
*/
}
if (RECURSIONOK(client)) {
/*
* Recurse!
*/
rdataset);
if (result == ISC_R_SUCCESS)
else
} else {
/*
* This is the best answer.
*/
&rdataset, &sigrdataset,
}
}
goto cleanup;
case DNS_R_NXRDATASET:
if (dns_rdataset_isassociated(rdataset)) {
/*
* If we've got a NXT record, we need to save the
* name now because we're going call query_addsoa()
* below, and it needs to use the name buffer.
*/
/*
* We don't want the cleanup code to try to release
* fname if we fail below, so we set it to NULL.
*/
} else {
/*
* We're not going to use fname, and need to release
* our hold on the name buffer so query_addsoa()
* may use it.
*/
}
/*
* Add SOA.
*/
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
/*
* Add NXT record if we found one.
*/
goto cleanup;
case DNS_R_NXDOMAIN:
/*
* We hit a dead end following a CNAME or DNAME.
*/
goto cleanup;
}
if (dns_rdataset_isassociated(rdataset)) {
/*
* If we've got a NXT record, we need to save the
* name now because we're going call query_addsoa()
* below, and it needs to use the name buffer.
*/
/*
* We don't want the cleanup code to try to release
* fname if we fail below, so we set it to NULL.
*/
} else {
/*
* We're not going to use fname, and need to release
* our hold on the name buffer so query_addsoa()
* may use it.
*/
}
/*
* Add SOA.
*/
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
/*
* Add NXT record if we found one.
*/
/*
* Set message rcode.
*/
goto cleanup;
case DNS_R_NCACHENXDOMAIN:
case DNS_R_NCACHENXRRSET:
/*
* Set message rcode, if required.
*/
if (result == DNS_R_NCACHENXDOMAIN)
/*
* We don't call query_addrrset() because we don't need any
* of its extra features (and things would probably break!).
*/
goto cleanup;
case DNS_R_CNAME:
/*
* Keep a copy of the rdataset. We have to do this because
* query_addrrset may clear 'rdataset' (to prevent the
* cleanup code from cleaning it up).
*/
/*
* Add the CNAME to the answer section.
*/
/*
* We set the PARTIALANSWER attribute so that if anything goes
* wrong later on, we'll return what we've got so far.
*/
/*
* Reset qname to be the target name of the CNAME and restart
* the query.
*/
if (result != ISC_R_SUCCESS)
goto cleanup;
if (result != ISC_R_SUCCESS)
goto cleanup;
dns_name_fromregion(tname, &r);
goto addauth;
case DNS_R_DNAME:
/*
* Compare the current qname to the found name. We need
* to know how many labels and bits are in common because
* we're going to have to split qname later on.
*/
/*
* Keep a copy of the rdataset. We have to do this because
* query_addrrset may clear 'rdataset' (to prevent the
* cleanup code from cleaning it up).
*/
/*
* Add the DNAME to the answer section.
*/
/*
* We set the PARTIALANSWER attribute so that if anything goes
* wrong later on, we'll return what we've got so far.
*/
/*
* Get the target name of the DNAME.
*/
if (result != ISC_R_SUCCESS)
goto cleanup;
if (result != ISC_R_SUCCESS)
goto cleanup;
dns_name_fromregion(tname, &r);
/*
* Construct the new qname.
*/
if (result != ISC_R_SUCCESS)
goto cleanup;
goto cleanup;
goto cleanup;
if (result != ISC_R_SUCCESS) {
if (result == ISC_R_NOSPACE) {
/*
* RFC 2672, section 4.1, subsection 3c says
* we should return YXDOMAIN if the constructed
* name would be too long.
*/
}
goto cleanup;
}
/*
* Synthesize a CNAME for this DNAME.
*
* We want to synthesize a CNAME since if we don't
* then older software that doesn't understand DNAME
* will not chain like it should.
*
* We do not try to synthesize a signature because we hope
* that security aware servers will understand DNAME. Also,
* even if we had an online key, making a signature
* on-the-fly is costly, and not really legitimate anyway
* since the synthesized CNAME is NOT in the zone.
*/
/*
* Switch to the new qname and restart.
*/
goto addauth;
default:
/*
* Something has gone wrong.
*/
goto cleanup;
}
if (type == dns_rdatatype_any) {
/*
* XXXRTH Need to handle zonecuts with special case
* code.
*/
n = 0;
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
while (result == ISC_R_SUCCESS) {
if ((qtype == dns_rdatatype_any ||
n++;
/*
* We set dbuf to NULL because we only
* want the query_keepname() call in
* query_addrrset() to be called once.
*/
}
/*
* We shouldn't ever fail to add 'rdataset'
* because it's already in the answer.
*/
break;
} else {
/*
* We're not interested in this rdataset.
*/
}
}
if (n > 0) {
if (clear_fname)
} else {
/*
* We didn't match any rdatasets.
*/
if (qtype == dns_rdatatype_sig &&
result == DNS_R_NOMORE) {
/*
* XXXRTH If this is a secure zone and we
* didn't find any SIGs, we should generate
* an error unless we were searching for
* glue. Ugh.
*/
/*
* We were searching for SIG records in
* a nonsecure zone. Send a "no error,
* no data" response.
*
* First we must release fname.
*/
/*
* Add SOA.
*/
if (result == ISC_R_SUCCESS)
} else {
/*
* Something went wrong.
*/
}
}
if (result != DNS_R_NOMORE) {
goto cleanup;
}
} else {
/*
* This is the "normal" case -- an ordinary question to which
* we know the answer.
*/
/*
* We shouldn't ever fail to add 'rdataset'
* because it's already in the answer.
*/
/*
* Remember that we've answered this question.
*/
if (clear_fname)
}
/*
* Add NS records to the authority section (if we haven't already
* added them to the answer section).
*/
if (!want_restart) {
if (is_zone) {
if (!(qtype == dns_rdatatype_ns &&
dns_db_origin(db))))
} else if (qtype != dns_rdatatype_ns) {
}
}
/*
* General cleanup.
*/
dns_db_detach(&db);
dns_db_detach(&zdb);
}
/*
* AA bit.
*/
/*
* We're not authoritative, so we must ensure the AA bit
* isn't set.
*/
}
/*
* Restart the query?
*/
goto restart;
}
}
/*
* XXXRTH Problem areas.
*
* If we're authoritative for both a parent and a child, the
* child is non-secure, and we are asked for the KEY of the
* nonsecure child, we need to get it from the parent.
* If we're not auth for the parent, then we have to go
* looking for it in the cache. How do we even know who
* the parent is? We probably won't find this KEY when doing
* additional data KEY retrievals, but that's probably OK,
* since it's a SHOULD not a MUST. We don't want to be doing
* tons of work just to fill out additional data.
*
* Similar problems occur with NXT queries, since there can
* be NXT records at a delegation point in both the parent
* and the child. RFC 2535 section 5.5 says that on explicit
* query we should return both, if available. That seems
* to imply we shouldn't recurse to get the missing one
* if only one is available. Is that right?
*/
void
/*
* Ensure that appropriate cleanups occur.
*/
/*
* We don't have a cache. Turn off cache support and
* recursion.
*/
/*
* If the client doesn't want recursion, or we don't have
* a resolver, turn recursion off.
*/
}
/*
* XXXRTH Deal with allow-query and allow-recursion here.
*/
/*
* RA flag.
*/
if (set_ra)
/*
* Get the question name.
*/
if (result != ISC_R_SUCCESS) {
return;
}
if (result != ISC_R_NOMORE) {
if (result == ISC_R_SUCCESS) {
/*
* There's more than one QNAME in the question
* section.
*/
} else
return;
}
/*
* Check for illegal meta-classes and meta-types in
* multiple question queries (edns1 section 5.1).
*/
return;
}
return;
}
}
}
/*
* Check for meta-queries like IXFR and AXFR.
*/
case dns_rdatatype_any:
break; /* Let query_find handle it. */
case dns_rdatatype_ixfr:
case dns_rdatatype_axfr:
return;
case dns_rdatatype_maila:
case dns_rdatatype_mailb:
return;
default: /* TSIG, etc. */
return;
}
}
}
/* This is an ordinary query. */
if (result != ISC_R_SUCCESS) {
return;
}
/*
* Assume authoritative response until it is known to be
* otherwise.
*/
/*
* Set AD. We need only clear it if we add "pending" data to
* a response.
*
* Note: as currently written, the server does not return "pending"
* data even if a client says it's OK to do so.
*/
}