view.c revision 7865ea9545f28f12f046b32d24c989e8441b9812
/*
* Copyright (C) 2004-2012 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
* 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$ */
/*! \file */
#include <config.h>
#include <dns/dispatch.h>
#ifdef BIND9
#endif
#include <dns/keytable.h>
#include <dns/keyvalues.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)
goto cleanup_name;
#ifdef BIND9
if (result != ISC_R_SUCCESS) {
"dns_zt_create() failed: %s",
goto cleanup_mutex;
}
#endif
if (result != ISC_R_SUCCESS) {
"dns_fwdtable_create() failed: %s",
goto cleanup_zt;
}
if (result != ISC_R_SUCCESS)
goto cleanup_fwdtable;
if (result != ISC_R_SUCCESS)
goto cleanup_references;
/*
* Initialize configuration data with default values.
*/
view->preferred_glue = 0;
#ifdef BIND9
if (result != ISC_R_SUCCESS)
goto cleanup_dynkeys;
#endif
if (result != ISC_R_SUCCESS)
goto cleanup_order;
if (result != ISC_R_SUCCESS)
goto cleanup_peerlist;
return (ISC_R_SUCCESS);
#ifdef BIND9
#endif
#ifdef BIND9
#endif
return (result);
}
static inline void
#ifdef BIND9
#endif
#ifdef BIND9
#endif
char template[20];
char keyfile[20];
int n;
sizeof(template));
if (result == ISC_R_SUCCESS)
}
else {
if (result == ISC_R_SUCCESS) {
keyfile);
if (result != ISC_R_SUCCESS)
} else {
}
}
}
#ifdef BIND9
}
#else
#endif
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);
}
#ifdef BIND9
}
#endif
}
/*
* 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))
#ifdef BIND9
else
}
}
#endif
}
if (done)
}
void
}
void
}
#ifdef BIND9
static isc_result_t
return (ISC_R_SUCCESS);
}
void
}
#endif
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
#ifdef BIND9
#endif
}
#ifdef BIND9
#endif
}
return (view->cacheshared);
}
void
}
void
}
void
}
void
}
void
char keyfile[20];
int n;
}
}
}
}
void
}
void
}
}
#ifdef BIND9
void
}
return (result);
}
#endif
#ifdef BIND9
if (result == DNS_R_PARTIALMATCH) {
}
return (result);
}
#endif
sigrdataset));
}
{
#ifndef BIND9
#endif
/*
* Find an rdataset whose owner name is 'name', and whose type is
* 'type'.
*/
/*
* Initialize.
*/
/*
* Find a database to answer the query.
*/
#ifdef BIND9
!use_static_stub) {
}
else if (result != ISC_R_SUCCESS)
goto cleanup;
}
#else
#endif /* BIND9 */
else
goto cleanup;
/*
* Now look for an answer in the database.
*/
if (sigrdataset != NULL &&
if (!is_cache) {
dns_db_detach(&db);
/*
* Either the answer is in the cache, or we
* don't know it.
* Note that if the result comes from a
* static-stub zone we stop the search here
* (see the function description in view.h).
*/
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.
*/
}
#ifdef BIND9
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.
*/
}
#endif /* BIND9 */
if (dns_rdataset_isassociated(&zrdataset)) {
}
dns_db_detach(&zdb);
}
else
}
else
dns_db_detach(&db);
} else
#ifdef BIND9
#endif
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.
*/
#ifdef BIND9
#else
#endif
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);
#ifdef BIND9
#endif
return (result);
}
{
break;
}
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
}
#ifdef BIND9
dns_zone_t **zonep)
{
continue;
/*
* If the zone is defined in more than one view,
* treat it as not found.
*/
result == ISC_R_NOTFOUND ||
result == DNS_R_PARTIALMATCH);
/* Treat a partial match as no match */
if (result == DNS_R_PARTIALMATCH) {
}
return (ISC_R_NOTFOUND);
}
}
return (ISC_R_SUCCESS);
}
return (ISC_R_NOTFOUND);
}
}
}
}
#endif /* BIND9 */
{
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));
}
#ifdef BIND9
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_SUCCESS);
}
#endif
}
return (ISC_R_SUCCESS);
if (!fixuponly) {
if (result != ISC_R_SUCCESS)
return (result);
}
#ifdef BIND9
#endif
#ifdef BIND9
#endif
return (ISC_R_SUCCESS);
}
}
if (!tree) {
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);
}
#ifdef BIND9
}
#endif
void
}
void
}
void
}
void
}
void
}
void
}
}
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
}
return (ISC_R_NOTFOUND);
}
void
{
unsigned char data[4096];
/*
* Clear the revoke bit, if set, so that the key will match what's
* in secroots now.
*/
/* Convert dnskey to DST key. */
if (result != ISC_R_SUCCESS)
return;
if (result == ISC_R_SUCCESS) {
}
dst_key_free(&key);
}
#define NZF ".nzf"
void
void (*cfg_destroy)(void **))
{
#ifdef BIND9
}
}
if (allow) {
/* Truncate the hash at 16 chars; full length is overkill */
}
#else
#endif
}