view.c revision dafcb997e390efa4423883dafd100c975c4095d6
/*
* Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 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 ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC 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.
*/
/* $Id: view.c,v 1.125 2004/03/05 05:09:26 marka Exp $ */
#include <config.h>
#include <dns/keytable.h>
#include <dns/masterdump.h>
#include <dns/rdataset.h>
#include <dns/resolver.h>
#define DNS_VIEW_DELONLYHASH 111
{
/*
* Create a view.
*/
return (ISC_R_NOMEMORY);
goto cleanup_view;
}
if (result != ISC_R_SUCCESS) {
"isc_mutex_init() failed: %s",
goto cleanup_name;
}
if (result != ISC_R_SUCCESS) {
"dns_zt_create() failed: %s",
goto cleanup_mutex;
}
if (result != ISC_R_SUCCESS) {
"dns_keytable_create() failed: %s",
goto cleanup_zt;
}
if (result != ISC_R_SUCCESS) {
"dns_keytable_create() failed: %s",
goto cleanup_secroots;
}
if (result != ISC_R_SUCCESS) {
"dns_fwdtable_create() failed: %s",
goto cleanup_trustedkeys;
}
if (result != ISC_R_SUCCESS)
goto cleanup_fwdtable;
/*
* Initialize configuration data with default values.
*/
view->preferred_glue = 0;
if (result != ISC_R_SUCCESS)
goto cleanup_dynkeys;
if (result != ISC_R_SUCCESS)
goto cleanup_order;
if (result != ISC_R_SUCCESS)
goto cleanup_peerlist;
return (ISC_R_SUCCESS);
return (result);
}
static inline void
int i;
for (i = 0; i < DNS_VIEW_DELONLYHASH; i++) {
}
}
}
int i;
for (i = 0; i < DNS_VIEW_DELONLYHASH; i++) {
}
}
sizeof(dns_namelist_t) * DNS_VIEW_DELONLYHASH);
}
}
/*
* Return true iff 'view' may be freed.
* The caller must be holding the view lock.
*/
static isc_boolean_t
return (ISC_TRUE);
return (ISC_FALSE);
}
void
}
static void
unsigned int refs;
if (flush)
if (refs == 0) {
if (!RESSHUTDOWN(view))
if (!ADBSHUTDOWN(view))
if (!REQSHUTDOWN(view))
else
}
if (done)
}
void
}
void
}
static isc_result_t
return (ISC_R_SUCCESS);
}
void
}
void
}
void
if (done)
}
static void
if (done)
}
static void
if (done)
}
static void
if (done)
}
unsigned int options,
{
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS) {
return (result);
}
if (result != ISC_R_SUCCESS) {
return (result);
}
if (result != ISC_R_SUCCESS) {
return (result);
}
&view->requestmgr);
if (result != ISC_R_SUCCESS) {
return (result);
}
return (ISC_R_SUCCESS);
}
void
}
}
void
}
void
}
void
}
return (result);
}
void
}
}
if (result == DNS_R_PARTIALMATCH) {
}
return (result);
}
{
/*
* Find an rdataset whose owner name is 'name', and whose type is
* 'type'.
*/
/*
* Initialize.
*/
/*
* Find a database to answer the query.
*/
else if (result != ISC_R_SUCCESS)
goto cleanup;
else
goto cleanup;
/*
* Now look for an answer in the database.
*/
if (result == DNS_R_DELEGATION ||
result == ISC_R_NOTFOUND) {
if (sigrdataset != NULL &&
if (!is_cache) {
dns_db_detach(&db);
/*
* Either the answer is in the cache, or we
* don't know it.
*/
goto db_find;
}
} else {
/*
* We don't have the data in the cache. If we've got
* glue from the zone, use it.
*/
if (dns_rdataset_isassociated(&zrdataset)) {
if (sigrdataset != NULL &&
result = DNS_R_GLUE;
dns_db_detach(&db);
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.
*/
if (sigrdataset != NULL &&
}
dns_db_detach(&db);
goto db_find;
}
/*
* Otherwise, the glue is the best answer.
*/
}
if (sigrdataset != NULL &&
dns_db_detach(&db);
}
/*
* We just used a hint. Let the resolver know it
* should consider priming.
*/
result = DNS_R_HINT;
} else if (result == DNS_R_NXRRSET) {
} else if (result == DNS_R_NXDOMAIN)
/*
* Cleanup if non-standard hints are used.
*/
}
/*
* We don't care about any DNSSEC proof data in these cases.
*/
if (sigrdataset != NULL &&
}
if (dns_rdataset_isassociated(&zrdataset)) {
}
dns_db_detach(&zdb);
}
else
}
else
dns_db_detach(&db);
} else
return (result);
}
{
if (result == DNS_R_NXDOMAIN) {
/*
* The rdataset and sigrdataset of the relevant NSEC record
* may be returned, but the caller cannot use them because
* foundname is not returned by this simplified API. We
* disassociate them here to prevent any misuse by the caller.
*/
if (sigrdataset != NULL &&
} else if (result != ISC_R_SUCCESS &&
result != DNS_R_GLUE &&
result != DNS_R_HINT &&
result != DNS_R_NCACHENXDOMAIN &&
result != DNS_R_NCACHENXRRSET &&
result != DNS_R_NXRRSET &&
result != DNS_R_HINTNXRRSET &&
result != ISC_R_NOTFOUND) {
if (sigrdataset != NULL &&
}
return (result);
}
{
rdataset, sigrdataset));
}
{
/*
* Initialize.
*/
/*
* 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.
*/
/*
* We have a cache; try it.
*/
} else {
/*
* Maybe we have hints...
*/
goto finish;
}
} else if (result != ISC_R_SUCCESS) {
/*
* Something is broken.
*/
goto cleanup;
}
/*
* Look for the zonecut.
*/
if (!is_cache) {
if (result == DNS_R_DELEGATION)
else if (result != ISC_R_SUCCESS)
goto cleanup;
/*
* We found an answer, but the cache may be better.
*/
if (result != ISC_R_SUCCESS)
goto cleanup;
if (sigrdataset != NULL &&
}
dns_db_detach(&db);
goto db_find;
}
} else {
if (result == ISC_R_SUCCESS) {
/*
* We found a zonecut in the cache, but our
* zone delegation is better.
*/
}
} else if (result == ISC_R_NOTFOUND) {
/*
* We didn't find anything in the cache, but we
* have a zone delegation, so use it.
*/
} else {
/*
* Maybe we have hints...
*/
}
} else {
/*
* Something bad happened.
*/
goto cleanup;
}
}
if (use_zone) {
if (dns_rdataset_isassociated(rdataset)) {
if (sigrdataset != NULL &&
}
if (result != ISC_R_SUCCESS)
goto cleanup;
if (sigrdataset != NULL &&
/*
* We've found nothing so far, but we have hints.
*/
if (result != ISC_R_SUCCESS) {
/*
* We can't even find the hints for the root
* nameservers!
*/
}
}
if (dns_rdataset_isassociated(&zrdataset)) {
}
dns_db_detach(&db);
return (result);
}
{
break;
}
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
}
}
}
{
view->statickeys);
if (result == ISC_R_NOTFOUND)
view->dynamickeys);
return (result);
}
{
if (result != ISC_R_SUCCESS)
return (result);
if (result != ISC_R_SUCCESS)
return (result);
}
view->dynamickeys));
}
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_SUCCESS);
}
return (ISC_R_SUCCESS);
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_SUCCESS);
}
return (ISC_R_SUCCESS);
}
sizeof(dns_namelist_t) *
return (ISC_R_NOMEMORY);
}
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
if (result == ISC_R_SUCCESS)
else
return (result);
}
sizeof(dns_namelist_t) *
return (ISC_R_NOMEMORY);
}
return (ISC_R_SUCCESS);
return (ISC_R_NOMEMORY);
if (result == ISC_R_SUCCESS)
else
return (result);
}
return (ISC_FALSE);
return (ISC_TRUE);
return (ISC_TRUE);
}
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_TRUE);
}
void
}
return (view->rootdelonly);
}