view.c revision 113b8ef9731a0c4fb47f3ad41cb9d07d97e022a8
ca41b452ede6feaa9d8739ec3cae19389a7b0d03Bob Halley * Copyright (C) 1999, 2000 Internet Software Consortium.
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * Permission to use, copy, modify, and distribute this software for any
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * purpose with or without fee is hereby granted, provided that the above
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * copyright notice and this permission notice appear in all copies.
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff/* $Id: view.c,v 1.87 2000/12/15 21:11:35 gson Exp $ */
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff#include <isc/string.h> /* Required for HP/UX (and others?) */
efa4ebbff3c9f6f38ab8b55540fb696243c1172cAndreas Gustafsson#define RESSHUTDOWN(v) (((v)->attributes & DNS_VIEWATTR_RESSHUTDOWN) != 0)
efa4ebbff3c9f6f38ab8b55540fb696243c1172cAndreas Gustafsson#define ADBSHUTDOWN(v) (((v)->attributes & DNS_VIEWATTR_ADBSHUTDOWN) != 0)
c90f5e8d1edbd5c277f2ee320167a12a30ba7c7bMichael Graff#define REQSHUTDOWN(v) (((v)->attributes & DNS_VIEWATTR_REQSHUTDOWN) != 0)
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graffstatic void resolver_shutdown(isc_task_t *task, isc_event_t *event);
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graffstatic void adb_shutdown(isc_task_t *task, isc_event_t *event);
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graffstatic void req_shutdown(isc_task_t *task, isc_event_t *event);
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graffdns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff * Create a view.
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff "isc_mutex_init() failed: %s",
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff result = isc_rwlock_init(&view->conflock, 1, 1);
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff "isc_rwlock_init() failed: %s",
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff result = dns_zt_create(mctx, rdclass, &view->zonetable);
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff "dns_zt_create() failed: %s",
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff result = dns_keytable_create(mctx, &view->secroots);
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff "dns_keytable_create() failed: %s",
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff result = dns_keytable_create(mctx, &view->trustedkeys);
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff "dns_keytable_create() failed: %s",
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff result = dns_fwdtable_create(mctx, &view->fwdtable);
c803787146cadcb2d7e10cbf4491f3be513dfa1aMichael Graff "dns_fwdtable_create() failed: %s",
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graff view->attributes = (DNS_VIEWATTR_RESSHUTDOWN|DNS_VIEWATTR_ADBSHUTDOWN|
86944a4c8002e80ae9b6eb5a5e29b797879be45fMichael Graff result = dns_tsigkeyring_create(view->mctx, &view->dynamickeys);
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff * Initialize configuration data with default values.
c803787146cadcb2d7e10cbf4491f3be513dfa1aMichael Graff view->auth_nxdomain = ISC_FALSE; /* Was true in BIND 8 */
3ac63b472022ff92691d1fe69ac715a729671965Michael Graff result = dns_peerlist_new(view->mctx, &view->peers);
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff ISC_EVENT_INIT(&view->resevent, sizeof view->resevent, 0, NULL,
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff ISC_EVENT_INIT(&view->adbevent, sizeof view->adbevent, 0, NULL,
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graff ISC_EVENT_INIT(&view->reqevent, sizeof view->reqevent, 0, NULL,
36ca83769dbba29a3d8670eef9acd95c7a71a7f6Michael Graffstatic inline void
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff * Return true iff 'view' may be freed.
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graff * The caller must be holding the view lock.
da547174e2b7beb6d6119d58197ad0bc85b91179Michael Graff if (view->references == 0 && view->weakrefs == 0 &&
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff RESSHUTDOWN(view) && ADBSHUTDOWN(view) && REQSHUTDOWN(view))
970cccf46e0f949a1a9edbcd8302dd2a112b43c2Michael Graffdns_view_attach(dns_view_t *source, dns_view_t **targetp) {
e198cb953c1a5bc189ae21dc3f8d622f5a08bc34Bob Halleyview_flushanddetach(dns_view_t **viewp, isc_boolean_t flush) {
f942258b6380ba1f2c2f057a79ffc37bc3436488Michael Graff dns_zt_apply(view->zonetable, ISC_FALSE, dialup, NULL);
1a0e33bc2044e1902493111db14cbf793083ac47Michael Graffdns_view_weakattach(dns_view_t *source, dns_view_t **targetp) {
efc8a09e19dfcfafa92fd2ad113073a4f5295e9bMichael Graffresolver_shutdown(isc_task_t *task, isc_event_t *event) {
910df98b0efcbe8380b952887f4071051cc39a25Michael Graff REQUIRE(event->ev_type == DNS_EVENT_VIEWRESSHUTDOWN);
if (done)
if (done)
if (done)
unsigned int options,
return (result);
return (result);
return (result);
return (result);
return (ISC_R_SUCCESS);
return (result);
return (result);
goto cleanup;
goto cleanup;
if (!is_cache) {
goto db_find;
goto cleanup;
goto db_find;
return (result);
return (result);
goto finish;
goto cleanup;
if (!is_cache) {
goto cleanup;
NULL);
goto cleanup;
goto db_find;
goto cleanup;
if (use_zone) {
goto cleanup;
return (result);
return (ISC_R_NOTFOUND);
return (ISC_R_SUCCESS);
return (result);
return (result);
return (result);
return (ISC_R_IGNORE);
return (result);
return (ISC_R_SUCCESS);