Lines Matching refs:view
79 dns_view_t *view;
84 * Create a view.
90 view = isc_mem_get(mctx, sizeof(*view));
91 if (view == NULL)
94 view->nta_file = NULL;
95 view->mctx = NULL;
96 isc_mem_attach(mctx, &view->mctx);
97 view->name = isc_mem_strdup(mctx, name);
98 if (view->name == NULL) {
103 result = isc_file_sanitize(NULL, view->name, "nta",
107 view->nta_file = isc_mem_strdup(mctx, buffer);
108 if (view->nta_file == NULL) {
113 result = isc_mutex_init(&view->lock);
117 view->zonetable = NULL;
119 result = dns_zt_create(mctx, rdclass, &view->zonetable);
128 view->secroots_priv = NULL;
129 view->ntatable_priv = NULL;
130 view->fwdtable = NULL;
131 result = dns_fwdtable_create(mctx, &view->fwdtable);
140 view->acache = NULL;
141 view->cache = NULL;
142 view->cachedb = NULL;
143 ISC_LIST_INIT(view->dlz_searched);
144 ISC_LIST_INIT(view->dlz_unsearched);
145 view->hints = NULL;
146 view->resolver = NULL;
147 view->adb = NULL;
148 view->requestmgr = NULL;
149 view->rdclass = rdclass;
150 view->frozen = ISC_FALSE;
151 view->task = NULL;
152 result = isc_refcount_init(&view->references, 1);
155 view->weakrefs = 0;
156 view->attributes = (DNS_VIEWATTR_RESSHUTDOWN|DNS_VIEWATTR_ADBSHUTDOWN|
158 view->statickeys = NULL;
159 view->dynamickeys = NULL;
160 view->matchclients = NULL;
161 view->matchdestinations = NULL;
162 view->matchrecursiveonly = ISC_FALSE;
163 result = dns_tsigkeyring_create(view->mctx, &view->dynamickeys);
166 view->peers = NULL;
167 view->order = NULL;
168 view->delonly = NULL;
169 view->rootdelonly = ISC_FALSE;
170 view->rootexclude = NULL;
171 view->adbstats = NULL;
172 view->resstats = NULL;
173 view->resquerystats = NULL;
174 view->cacheshared = ISC_FALSE;
175 ISC_LIST_INIT(view->dns64);
176 view->dns64cnt = 0;
181 view->recursion = ISC_TRUE;
182 view->auth_nxdomain = ISC_FALSE; /* Was true in BIND 8 */
183 view->additionalfromcache = ISC_TRUE;
184 view->additionalfromauth = ISC_TRUE;
185 view->enablednssec = ISC_TRUE;
186 view->enablevalidation = ISC_TRUE;
187 view->acceptexpired = ISC_FALSE;
188 view->minimal_any = ISC_FALSE;
189 view->minimalresponses = dns_minimal_no;
190 view->transfer_format = dns_one_answer;
191 view->cacheacl = NULL;
192 view->cacheonacl = NULL;
193 view->queryacl = NULL;
194 view->queryonacl = NULL;
195 view->recursionacl = NULL;
196 view->recursiononacl = NULL;
197 view->sortlist = NULL;
198 view->transferacl = NULL;
199 view->notifyacl = NULL;
200 view->updateacl = NULL;
201 view->upfwdacl = NULL;
202 view->denyansweracl = NULL;
203 view->nocasecompress = NULL;
204 view->msgcompression = ISC_TRUE;
205 view->answeracl_exclude = NULL;
206 view->denyanswernames = NULL;
207 view->answernames_exclude = NULL;
208 view->rrl = NULL;
209 view->provideixfr = ISC_TRUE;
210 view->maxcachettl = 7 * 24 * 3600;
211 view->maxncachettl = 3 * 3600;
212 view->nta_lifetime = 0;
213 view->nta_recheck = 0;
214 view->prefetch_eligible = 0;
215 view->prefetch_trigger = 0;
216 view->dstport = 53;
217 view->preferred_glue = 0;
218 view->flush = ISC_FALSE;
219 view->dlv = NULL;
220 view->maxudp = 0;
221 view->nocookieudp = 0;
222 view->maxbits = 0;
223 view->v4_aaaa = dns_aaaa_ok;
224 view->v6_aaaa = dns_aaaa_ok;
225 view->aaaa_acl = NULL;
226 view->rpzs = NULL;
227 view->catzs = NULL;
228 dns_fixedname_init(&view->dlv_fixed);
229 view->managed_keys = NULL;
230 view->redirect = NULL;
231 view->redirectzone = NULL;
232 dns_fixedname_init(&view->redirectfixed);
233 view->requestnsid = ISC_FALSE;
234 view->sendcookie = ISC_TRUE;
235 view->requireservercookie = ISC_FALSE;
236 view->trust_anchor_telemetry = ISC_TRUE;
237 view->new_zone_file = NULL;
238 view->new_zone_db = NULL;
239 view->new_zone_dbenv = NULL;
240 view->new_zone_mapsize = 0ULL;
241 view->new_zone_config = NULL;
242 view->cfg_destroy = NULL;
243 view->fail_ttl = 0;
244 view->failcache = NULL;
245 (void)dns_badcache_init(view->mctx, DNS_VIEW_FAILCACHESIZE,
246 &view->failcache);
247 view->v6bias = 0;
248 view->dtenv = NULL;
249 view->dttypes = 0;
251 result = isc_mutex_init(&view->new_zone_lock);
256 result = dns_order_create(view->mctx, &view->order);
261 result = dns_peerlist_new(view->mctx, &view->peers);
265 result = dns_aclenv_init(view->mctx, &view->aclenv);
269 ISC_LINK_INIT(view, link);
270 ISC_EVENT_INIT(&view->resevent, sizeof(view->resevent), 0, NULL,
272 view, NULL, NULL, NULL);
273 ISC_EVENT_INIT(&view->adbevent, sizeof(view->adbevent), 0, NULL,
275 view, NULL, NULL, NULL);
276 ISC_EVENT_INIT(&view->reqevent, sizeof(view->reqevent), 0, NULL,
278 view, NULL, NULL, NULL);
279 view->viewlist = NULL;
280 view->magic = DNS_VIEW_MAGIC;
282 *viewp = view;
287 if (view->peers != NULL)
288 dns_peerlist_detach(&view->peers);
291 if (view->order != NULL)
292 dns_order_detach(&view->order);
295 DESTROYLOCK(&view->new_zone_lock);
298 if (view->dynamickeys != NULL)
299 dns_tsigkeyring_detach(&view->dynamickeys);
302 isc_refcount_destroy(&view->references);
305 if (view->fwdtable != NULL)
306 dns_fwdtable_destroy(&view->fwdtable);
309 if (view->zonetable != NULL)
310 dns_zt_detach(&view->zonetable);
313 DESTROYLOCK(&view->lock);
315 if (view->nta_file != NULL)
316 isc_mem_free(mctx, view->nta_file);
319 isc_mem_free(mctx, view->name);
322 isc_mem_putanddetach(&view->mctx, view, sizeof(*view));
328 destroy(dns_view_t *view) {
332 REQUIRE(!ISC_LINK_LINKED(view, link));
333 REQUIRE(isc_refcount_current(&view->references) == 0);
334 REQUIRE(view->weakrefs == 0);
335 REQUIRE(RESSHUTDOWN(view));
336 REQUIRE(ADBSHUTDOWN(view));
337 REQUIRE(REQSHUTDOWN(view));
339 if (view->order != NULL)
340 dns_order_detach(&view->order);
341 if (view->peers != NULL)
342 dns_peerlist_detach(&view->peers);
344 if (view->dynamickeys != NULL) {
352 view->name);
360 dns_tsigkeyring_detach(&view->dynamickeys);
363 &view->dynamickeys, fp);
376 if (view->statickeys != NULL)
377 dns_tsigkeyring_detach(&view->statickeys);
378 if (view->adb != NULL)
379 dns_adb_detach(&view->adb);
380 if (view->resolver != NULL)
381 dns_resolver_detach(&view->resolver);
382 if (view->acache != NULL) {
383 if (view->cachedb != NULL)
384 dns_acache_putdb(view->acache, view->cachedb);
385 dns_acache_detach(&view->acache);
387 dns_rrl_view_destroy(view);
388 if (view->rpzs != NULL)
389 dns_rpz_detach_rpzs(&view->rpzs);
390 if (view->catzs != NULL)
391 dns_catz_catzs_detach(&view->catzs);
392 for (dlzdb = ISC_LIST_HEAD(view->dlz_searched);
394 dlzdb = ISC_LIST_HEAD(view->dlz_searched)) {
395 ISC_LIST_UNLINK(view->dlz_searched, dlzdb, link);
398 for (dlzdb = ISC_LIST_HEAD(view->dlz_unsearched);
400 dlzdb = ISC_LIST_HEAD(view->dlz_unsearched)) {
401 ISC_LIST_UNLINK(view->dlz_unsearched, dlzdb, link);
404 if (view->requestmgr != NULL)
405 dns_requestmgr_detach(&view->requestmgr);
406 if (view->task != NULL)
407 isc_task_detach(&view->task);
408 if (view->hints != NULL)
409 dns_db_detach(&view->hints);
410 if (view->cachedb != NULL)
411 dns_db_detach(&view->cachedb);
412 if (view->cache != NULL)
413 dns_cache_detach(&view->cache);
414 if (view->nocasecompress != NULL)
415 dns_acl_detach(&view->nocasecompress);
416 if (view->matchclients != NULL)
417 dns_acl_detach(&view->matchclients);
418 if (view->matchdestinations != NULL)
419 dns_acl_detach(&view->matchdestinations);
420 if (view->cacheacl != NULL)
421 dns_acl_detach(&view->cacheacl);
422 if (view->cacheonacl != NULL)
423 dns_acl_detach(&view->cacheonacl);
424 if (view->queryacl != NULL)
425 dns_acl_detach(&view->queryacl);
426 if (view->queryonacl != NULL)
427 dns_acl_detach(&view->queryonacl);
428 if (view->recursionacl != NULL)
429 dns_acl_detach(&view->recursionacl);
430 if (view->recursiononacl != NULL)
431 dns_acl_detach(&view->recursiononacl);
432 if (view->sortlist != NULL)
433 dns_acl_detach(&view->sortlist);
434 if (view->transferacl != NULL)
435 dns_acl_detach(&view->transferacl);
436 if (view->notifyacl != NULL)
437 dns_acl_detach(&view->notifyacl);
438 if (view->updateacl != NULL)
439 dns_acl_detach(&view->updateacl);
440 if (view->upfwdacl != NULL)
441 dns_acl_detach(&view->upfwdacl);
442 if (view->denyansweracl != NULL)
443 dns_acl_detach(&view->denyansweracl);
444 if (view->aaaa_acl != NULL)
445 dns_acl_detach(&view->aaaa_acl);
446 if (view->answeracl_exclude != NULL)
447 dns_rbt_destroy(&view->answeracl_exclude);
448 if (view->denyanswernames != NULL)
449 dns_rbt_destroy(&view->denyanswernames);
450 if (view->answernames_exclude != NULL)
451 dns_rbt_destroy(&view->answernames_exclude);
452 if (view->delonly != NULL) {
457 name = ISC_LIST_HEAD(view->delonly[i]);
459 ISC_LIST_UNLINK(view->delonly[i], name, link);
460 dns_name_free(name, view->mctx);
461 isc_mem_put(view->mctx, name, sizeof(*name));
462 name = ISC_LIST_HEAD(view->delonly[i]);
465 isc_mem_put(view->mctx, view->delonly, sizeof(dns_namelist_t) *
467 view->delonly = NULL;
469 if (view->rootexclude != NULL) {
474 name = ISC_LIST_HEAD(view->rootexclude[i]);
476 ISC_LIST_UNLINK(view->rootexclude[i],
478 dns_name_free(name, view->mctx);
479 isc_mem_put(view->mctx, name, sizeof(*name));
480 name = ISC_LIST_HEAD(view->rootexclude[i]);
483 isc_mem_put(view->mctx, view->rootexclude,
485 view->rootexclude = NULL;
487 if (view->adbstats != NULL)
488 isc_stats_detach(&view->adbstats);
489 if (view->resstats != NULL)
490 isc_stats_detach(&view->resstats);
491 if (view->resquerystats != NULL)
492 dns_stats_detach(&view->resquerystats);
493 if (view->secroots_priv != NULL)
494 dns_keytable_detach(&view->secroots_priv);
495 if (view->ntatable_priv != NULL)
496 dns_ntatable_detach(&view->ntatable_priv);
497 for (dns64 = ISC_LIST_HEAD(view->dns64);
499 dns64 = ISC_LIST_HEAD(view->dns64)) {
500 dns_dns64_unlink(&view->dns64, dns64);
503 if (view->managed_keys != NULL)
504 dns_zone_detach(&view->managed_keys);
505 if (view->redirect != NULL)
506 dns_zone_detach(&view->redirect);
508 if (view->dtenv != NULL)
509 dns_dt_detach(&view->dtenv);
511 dns_view_setnewzones(view, ISC_FALSE, NULL, NULL, 0ULL);
512 if (view->new_zone_file != NULL) {
513 isc_mem_free(view->mctx, view->new_zone_file);
514 view->new_zone_file = NULL;
517 if (view->new_zone_dbenv != NULL) {
518 mdb_env_close((MDB_env *) view->new_zone_dbenv);
519 view->new_zone_dbenv = NULL;
521 if (view->new_zone_db != NULL) {
522 isc_mem_free(view->mctx, view->new_zone_db);
523 view->new_zone_db = NULL;
526 dns_fwdtable_destroy(&view->fwdtable);
527 dns_aclenv_destroy(&view->aclenv);
528 if (view->failcache != NULL)
529 dns_badcache_destroy(&view->failcache);
530 DESTROYLOCK(&view->new_zone_lock);
531 DESTROYLOCK(&view->lock);
532 isc_refcount_destroy(&view->references);
533 isc_mem_free(view->mctx, view->nta_file);
534 isc_mem_free(view->mctx, view->name);
535 isc_mem_putanddetach(&view->mctx, view, sizeof(*view));
539 * Return true iff 'view' may be freed.
540 * The caller must be holding the view lock.
543 all_done(dns_view_t *view) {
545 if (isc_refcount_current(&view->references) == 0 &&
546 view->weakrefs == 0 &&
547 RESSHUTDOWN(view) && ADBSHUTDOWN(view) && REQSHUTDOWN(view))
566 dns_view_t *view;
571 view = *viewp;
572 REQUIRE(DNS_VIEW_VALID(view));
575 view->flush = ISC_TRUE;
576 isc_refcount_decrement(&view->references, &refs);
580 LOCK(&view->lock);
581 if (!RESSHUTDOWN(view))
582 dns_resolver_shutdown(view->resolver);
583 if (!ADBSHUTDOWN(view))
584 dns_adb_shutdown(view->adb);
585 if (!REQSHUTDOWN(view))
586 dns_requestmgr_shutdown(view->requestmgr);
587 if (view->acache != NULL)
588 dns_acache_shutdown(view->acache);
589 if (view->zonetable != NULL) {
590 if (view->flush)
591 dns_zt_flushanddetach(&view->zonetable);
593 dns_zt_detach(&view->zonetable);
595 if (view->managed_keys != NULL) {
596 mkzone = view->managed_keys;
597 view->managed_keys = NULL;
598 if (view->flush)
601 if (view->redirect != NULL) {
602 rdzone = view->redirect;
603 view->redirect = NULL;
604 if (view->flush)
607 if (view->catzs != NULL) {
608 dns_catz_catzs_detach(&view->catzs);
610 done = all_done(view);
611 UNLOCK(&view->lock);
613 /* Need to detach zones outside view lock */
624 destroy(view);
645 dns_view_dialup(dns_view_t *view) {
646 REQUIRE(DNS_VIEW_VALID(view));
647 REQUIRE(view->zonetable != NULL);
649 (void)dns_zt_apply(view->zonetable, ISC_FALSE, dialup, NULL);
667 dns_view_t *view;
671 view = *viewp;
672 REQUIRE(DNS_VIEW_VALID(view));
674 LOCK(&view->lock);
676 INSIST(view->weakrefs > 0);
677 view->weakrefs--;
678 done = all_done(view);
680 UNLOCK(&view->lock);
685 destroy(view);
690 dns_view_t *view = event->ev_arg;
694 REQUIRE(DNS_VIEW_VALID(view));
695 REQUIRE(view->task == task);
701 LOCK(&view->lock);
703 view->attributes |= DNS_VIEWATTR_RESSHUTDOWN;
704 done = all_done(view);
706 UNLOCK(&view->lock);
709 destroy(view);
714 dns_view_t *view = event->ev_arg;
718 REQUIRE(DNS_VIEW_VALID(view));
719 REQUIRE(view->task == task);
725 LOCK(&view->lock);
727 view->attributes |= DNS_VIEWATTR_ADBSHUTDOWN;
728 done = all_done(view);
730 UNLOCK(&view->lock);
733 destroy(view);
738 dns_view_t *view = event->ev_arg;
742 REQUIRE(DNS_VIEW_VALID(view));
743 REQUIRE(view->task == task);
749 LOCK(&view->lock);
751 view->attributes |= DNS_VIEWATTR_REQSHUTDOWN;
752 done = all_done(view);
754 UNLOCK(&view->lock);
757 destroy(view);
761 dns_view_createzonetable(dns_view_t *view) {
763 REQUIRE(DNS_VIEW_VALID(view));
764 REQUIRE(!view->frozen);
765 REQUIRE(view->zonetable == NULL);
767 return (dns_zt_create(view->mctx, view->rdclass, &view->zonetable));
771 dns_view_createresolver(dns_view_t *view,
786 REQUIRE(DNS_VIEW_VALID(view));
787 REQUIRE(!view->frozen);
788 REQUIRE(view->resolver == NULL);
790 result = isc_task_create(taskmgr, 0, &view->task);
793 isc_task_setname(view->task, "view", view);
795 result = dns_resolver_create(view, taskmgr, ntasks, ndisp, socketmgr,
798 &view->resolver);
800 isc_task_detach(&view->task);
803 event = &view->resevent;
804 dns_resolver_whenshutdown(view->resolver, view->task, &event);
805 view->attributes &= ~DNS_VIEWATTR_RESSHUTDOWN;
809 dns_resolver_shutdown(view->resolver);
813 result = dns_adb_create(mctx, view, timermgr, taskmgr, &view->adb);
817 dns_resolver_shutdown(view->resolver);
820 event = &view->adbevent;
821 dns_adb_whenshutdown(view->adb, view->task, &event);
822 view->attributes &= ~DNS_VIEWATTR_ADBSHUTDOWN;
824 result = dns_requestmgr_create(view->mctx, timermgr, socketmgr,
825 dns_resolver_taskmgr(view->resolver),
826 dns_resolver_dispatchmgr(view->resolver),
828 &view->requestmgr);
830 dns_adb_shutdown(view->adb);
831 dns_resolver_shutdown(view->resolver);
834 event = &view->reqevent;
835 dns_requestmgr_whenshutdown(view->requestmgr, view->task, &event);
836 view->attributes &= ~DNS_VIEWATTR_REQSHUTDOWN;
842 dns_view_setcache(dns_view_t *view, dns_cache_t *cache) {
843 dns_view_setcache2(view, cache, ISC_FALSE);
847 dns_view_setcache2(dns_view_t *view, dns_cache_t *cache, isc_boolean_t shared) {
848 REQUIRE(DNS_VIEW_VALID(view));
849 REQUIRE(!view->frozen);
851 view->cacheshared = shared;
852 if (view->cache != NULL) {
853 if (view->acache != NULL)
854 dns_acache_putdb(view->acache, view->cachedb);
855 dns_db_detach(&view->cachedb);
856 dns_cache_detach(&view->cache);
858 dns_cache_attach(cache, &view->cache);
859 dns_cache_attachdb(cache, &view->cachedb);
860 INSIST(DNS_DB_VALID(view->cachedb));
862 if (view->acache != NULL)
863 dns_acache_setdb(view->acache, view->cachedb);
867 dns_view_iscacheshared(dns_view_t *view) {
868 REQUIRE(DNS_VIEW_VALID(view));
870 return (view->cacheshared);
874 dns_view_sethints(dns_view_t *view, dns_db_t *hints) {
875 REQUIRE(DNS_VIEW_VALID(view));
876 REQUIRE(!view->frozen);
877 REQUIRE(view->hints == NULL);
880 dns_db_attach(hints, &view->hints);
884 dns_view_setkeyring(dns_view_t *view, dns_tsig_keyring_t *ring) {
885 REQUIRE(DNS_VIEW_VALID(view));
887 if (view->statickeys != NULL)
888 dns_tsigkeyring_detach(&view->statickeys);
889 dns_tsigkeyring_attach(ring, &view->statickeys);
893 dns_view_setdynamickeyring(dns_view_t *view, dns_tsig_keyring_t *ring) {
894 REQUIRE(DNS_VIEW_VALID(view));
896 if (view->dynamickeys != NULL)
897 dns_tsigkeyring_detach(&view->dynamickeys);
898 dns_tsigkeyring_attach(ring, &view->dynamickeys);
902 dns_view_getdynamickeyring(dns_view_t *view, dns_tsig_keyring_t **ringp) {
903 REQUIRE(DNS_VIEW_VALID(view));
905 if (view->dynamickeys != NULL)
906 dns_tsigkeyring_attach(view->dynamickeys, ringp);
910 dns_view_restorekeyring(dns_view_t *view) {
915 REQUIRE(DNS_VIEW_VALID(view));
917 if (view->dynamickeys != NULL) {
919 view->name);
923 dns_keyring_restore(view->dynamickeys, fp);
931 dns_view_setdstport(dns_view_t *view, in_port_t dstport) {
932 REQUIRE(DNS_VIEW_VALID(view));
933 view->dstport = dstport;
937 dns_view_freeze(dns_view_t *view) {
938 REQUIRE(DNS_VIEW_VALID(view));
939 REQUIRE(!view->frozen);
941 if (view->resolver != NULL) {
942 INSIST(view->cachedb != NULL);
943 dns_resolver_freeze(view->resolver);
945 view->frozen = ISC_TRUE;
949 dns_view_thaw(dns_view_t *view) {
950 REQUIRE(DNS_VIEW_VALID(view));
951 REQUIRE(view->frozen);
953 view->frozen = ISC_FALSE;
957 dns_view_addzone(dns_view_t *view, dns_zone_t *zone) {
960 REQUIRE(DNS_VIEW_VALID(view));
961 REQUIRE(!view->frozen);
962 REQUIRE(view->zonetable != NULL);
964 result = dns_zt_mount(view->zonetable, zone);
970 dns_view_findzone(dns_view_t *view, dns_name_t *name, dns_zone_t **zonep) {
973 REQUIRE(DNS_VIEW_VALID(view));
975 LOCK(&view->lock);
976 if (view->zonetable != NULL) {
977 result = dns_zt_find(view->zonetable, name, 0, NULL, zonep);
984 UNLOCK(&view->lock);
990 dns_view_find(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
994 return (dns_view_find2(view, name, type, now, options, use_hints,
1000 dns_view_find2(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
1018 REQUIRE(DNS_VIEW_VALID(view));
1019 REQUIRE(view->frozen);
1039 LOCK(&view->lock);
1040 if (view->zonetable != NULL)
1041 result = dns_zt_find(view->zonetable, name, 0, NULL, &zone);
1044 UNLOCK(&view->lock);
1050 if (result != ISC_R_SUCCESS && view->cachedb != NULL)
1051 dns_db_attach(view->cachedb, &db);
1058 } else if (result == ISC_R_NOTFOUND && view->cachedb != NULL)
1059 dns_db_attach(view->cachedb, &db);
1082 if (view->cachedb != NULL && !is_staticstub_zone) {
1088 * (see the function description in view.h).
1091 dns_db_attach(view->cachedb, &db);
1118 if (view->cachedb != NULL && !is_staticstub_zone) {
1135 dns_db_attach(view->cachedb, &db);
1144 if (result == ISC_R_NOTFOUND && use_hints && view->hints != NULL) {
1155 result = dns_db_find(view->hints, name, NULL, type, options,
1163 dns_resolver_prime(view->resolver);
1164 dns_db_attach(view->hints, &db);
1167 dns_db_attach(view->hints, &db);
1176 dns_db_detachnode(view->hints, &node);
1213 dns_view_simplefind(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
1222 result = dns_view_find(view, name, type, now, options, use_hints,
1257 dns_view_findzonecut(dns_view_t *view, dns_name_t *name, dns_name_t *fname,
1262 return(dns_view_findzonecut2(view, name, fname, now, options,
1268 dns_view_findzonecut2(dns_view_t *view, dns_name_t *name, dns_name_t *fname,
1282 REQUIRE(DNS_VIEW_VALID(view));
1283 REQUIRE(view->frozen);
1301 LOCK(&view->lock);
1302 if (view->zonetable != NULL) {
1305 result = dns_zt_find(view->zonetable, name, ztoptions,
1309 UNLOCK(&view->lock);
1318 if (use_cache && view->cachedb != NULL) {
1322 dns_db_attach(view->cachedb, &db);
1349 if (use_cache && view->cachedb != NULL && db != view->hints) {
1365 dns_db_attach(view->cachedb, &db);
1419 } else if (try_hints && use_hints && view->hints != NULL) {
1423 result = dns_db_find(view->hints, dns_rootname, NULL,
1455 dns_view_t *view;
1459 for (view = ISC_LIST_HEAD(*list);
1460 view != NULL;
1461 view = ISC_LIST_NEXT(view, link)) {
1462 if (strcmp(view->name, name) == 0 && view->rdclass == rdclass)
1465 if (view == NULL)
1468 dns_view_attach(view, viewp);
1478 dns_view_t *view;
1486 for (view = ISC_LIST_HEAD(*list);
1487 view != NULL;
1488 view = ISC_LIST_NEXT(view, link)) {
1489 if (allclasses == ISC_FALSE && view->rdclass != rdclass)
1493 * If the zone is defined in more than one view,
1497 LOCK(&view->lock);
1498 if (view->zonetable != NULL)
1499 result = dns_zt_find(view->zonetable, name, 0,
1503 UNLOCK(&view->lock);
1532 dns_view_load(dns_view_t *view, isc_boolean_t stop) {
1534 REQUIRE(DNS_VIEW_VALID(view));
1535 REQUIRE(view->zonetable != NULL);
1537 return (dns_zt_load(view->zonetable, stop));
1541 dns_view_loadnew(dns_view_t *view, isc_boolean_t stop) {
1543 REQUIRE(DNS_VIEW_VALID(view));
1544 REQUIRE(view->zonetable != NULL);
1546 return (dns_zt_loadnew(view->zonetable, stop));
1550 dns_view_asyncload(dns_view_t *view, dns_zt_allloaded_t callback, void *arg) {
1551 REQUIRE(DNS_VIEW_VALID(view));
1552 REQUIRE(view->zonetable != NULL);
1554 return (dns_zt_asyncload(view->zonetable, callback, arg));
1558 dns_view_gettsig(dns_view_t *view, dns_name_t *keyname, dns_tsigkey_t **keyp)
1564 view->statickeys);
1567 view->dynamickeys);
1572 dns_view_getpeertsig(dns_view_t *view, isc_netaddr_t *peeraddr,
1579 result = dns_peerlist_peerbyaddr(view->peers, peeraddr, &peer);
1587 result = dns_view_gettsig(view, keyname, keyp);
1592 dns_view_checksig(dns_view_t *view, isc_buffer_t *source, dns_message_t *msg) {
1593 REQUIRE(DNS_VIEW_VALID(view));
1596 return (dns_tsig_verify(source, msg, view->statickeys,
1597 view->dynamickeys));
1601 dns_view_dumpdbtostream(dns_view_t *view, FILE *fp) {
1604 REQUIRE(DNS_VIEW_VALID(view));
1606 (void)fprintf(fp, ";\n; Cache dump of view '%s'\n;\n", view->name);
1607 result = dns_master_dumptostream(view->mctx, view->cachedb, NULL,
1611 dns_adb_dump(view->adb, fp);
1612 dns_resolver_printbadcache(view->resolver, fp);
1613 dns_badcache_print(view->failcache, "SERVFAIL cache", fp);
1618 dns_view_flushcache(dns_view_t *view) {
1619 return (dns_view_flushcache2(view, ISC_FALSE));
1623 dns_view_flushcache2(dns_view_t *view, isc_boolean_t fixuponly) {
1626 REQUIRE(DNS_VIEW_VALID(view));
1628 if (view->cachedb == NULL)
1631 result = dns_cache_flush(view->cache);
1635 if (view->acache != NULL)
1636 dns_acache_putdb(view->acache, view->cachedb);
1637 dns_db_detach(&view->cachedb);
1638 dns_cache_attachdb(view->cache, &view->cachedb);
1639 if (view->acache != NULL)
1640 dns_acache_setdb(view->acache, view->cachedb);
1641 if (view->resolver != NULL)
1642 dns_resolver_flushbadcache(view->resolver, NULL);
1643 if (view->failcache != NULL)
1644 dns_badcache_flush(view->failcache);
1646 dns_adb_flush(view->adb);
1651 dns_view_flushname(dns_view_t *view, dns_name_t *name) {
1652 return (dns_view_flushnode(view, name, ISC_FALSE));
1656 dns_view_flushnode(dns_view_t *view, dns_name_t *name, isc_boolean_t tree) {
1659 REQUIRE(DNS_VIEW_VALID(view));
1662 if (view->adb != NULL)
1663 dns_adb_flushnames(view->adb, name);
1664 if (view->resolver != NULL)
1665 dns_resolver_flushbadnames(view->resolver, name);
1666 if (view->failcache != NULL)
1667 dns_badcache_flushtree(view->failcache, name);
1669 if (view->adb != NULL)
1670 dns_adb_flushname(view->adb, name);
1671 if (view->resolver != NULL)
1672 dns_resolver_flushbadcache(view->resolver, name);
1673 if (view->failcache != NULL)
1674 dns_badcache_flushname(view->failcache, name);
1677 if (view->cache != NULL)
1678 result = dns_cache_flushnode(view->cache, name, tree);
1684 dns_view_adddelegationonly(dns_view_t *view, dns_name_t *name) {
1689 REQUIRE(DNS_VIEW_VALID(view));
1691 if (view->delonly == NULL) {
1692 view->delonly = isc_mem_get(view->mctx,
1695 if (view->delonly == NULL)
1698 ISC_LIST_INIT(view->delonly[hash]);
1701 item = ISC_LIST_HEAD(view->delonly[hash]);
1706 item = isc_mem_get(view->mctx, sizeof(*item));
1710 result = dns_name_dup(name, view->mctx, item);
1712 ISC_LIST_APPEND(view->delonly[hash], item, link);
1714 isc_mem_put(view->mctx, item, sizeof(*item));
1719 dns_view_excludedelegationonly(dns_view_t *view, dns_name_t *name) {
1724 REQUIRE(DNS_VIEW_VALID(view));
1726 if (view->rootexclude == NULL) {
1727 view->rootexclude = isc_mem_get(view->mctx,
1730 if (view->rootexclude == NULL)
1733 ISC_LIST_INIT(view->rootexclude[hash]);
1736 item = ISC_LIST_HEAD(view->rootexclude[hash]);
1741 item = isc_mem_get(view->mctx, sizeof(*item));
1745 result = dns_name_dup(name, view->mctx, item);
1747 ISC_LIST_APPEND(view->rootexclude[hash], item, link);
1749 isc_mem_put(view->mctx, item, sizeof(*item));
1754 dns_view_isdelegationonly(dns_view_t *view, dns_name_t *name) {
1758 REQUIRE(DNS_VIEW_VALID(view));
1760 if (!view->rootdelonly && view->delonly == NULL)
1764 if (view->rootdelonly && dns_name_countlabels(name) <= 2) {
1765 if (view->rootexclude == NULL)
1767 item = ISC_LIST_HEAD(view->rootexclude[hash]);
1774 if (view->delonly == NULL)
1777 item = ISC_LIST_HEAD(view->delonly[hash]);
1786 dns_view_setrootdelonly(dns_view_t *view, isc_boolean_t value) {
1787 REQUIRE(DNS_VIEW_VALID(view));
1788 view->rootdelonly = value;
1792 dns_view_getrootdelonly(dns_view_t *view) {
1793 REQUIRE(DNS_VIEW_VALID(view));
1794 return (view->rootdelonly);
1798 dns_view_freezezones(dns_view_t *view, isc_boolean_t value) {
1800 REQUIRE(DNS_VIEW_VALID(view));
1801 REQUIRE(view->zonetable != NULL);
1803 return (dns_zt_freezezones(view->zonetable, value));
1807 dns_view_setadbstats(dns_view_t *view, isc_stats_t *stats) {
1808 REQUIRE(DNS_VIEW_VALID(view));
1809 REQUIRE(!view->frozen);
1810 REQUIRE(view->adbstats == NULL);
1812 isc_stats_attach(stats, &view->adbstats);
1816 dns_view_getadbstats(dns_view_t *view, isc_stats_t **statsp) {
1817 REQUIRE(DNS_VIEW_VALID(view));
1820 if (view->adbstats != NULL)
1821 isc_stats_attach(view->adbstats, statsp);
1825 dns_view_setresstats(dns_view_t *view, isc_stats_t *stats) {
1827 REQUIRE(DNS_VIEW_VALID(view));
1828 REQUIRE(!view->frozen);
1829 REQUIRE(view->resstats == NULL);
1831 isc_stats_attach(stats, &view->resstats);
1835 dns_view_getresstats(dns_view_t *view, isc_stats_t **statsp) {
1836 REQUIRE(DNS_VIEW_VALID(view));
1839 if (view->resstats != NULL)
1840 isc_stats_attach(view->resstats, statsp);
1844 dns_view_setresquerystats(dns_view_t *view, dns_stats_t *stats) {
1845 REQUIRE(DNS_VIEW_VALID(view));
1846 REQUIRE(!view->frozen);
1847 REQUIRE(view->resquerystats == NULL);
1849 dns_stats_attach(stats, &view->resquerystats);
1853 dns_view_getresquerystats(dns_view_t *view, dns_stats_t **statsp) {
1854 REQUIRE(DNS_VIEW_VALID(view));
1857 if (view->resquerystats != NULL)
1858 dns_stats_attach(view->resquerystats, statsp);
1862 dns_view_initntatable(dns_view_t *view,
1865 REQUIRE(DNS_VIEW_VALID(view));
1866 if (view->ntatable_priv != NULL)
1867 dns_ntatable_detach(&view->ntatable_priv);
1868 return (dns_ntatable_create(view, taskmgr, timermgr,
1869 &view->ntatable_priv));
1873 dns_view_getntatable(dns_view_t *view, dns_ntatable_t **ntp) {
1874 REQUIRE(DNS_VIEW_VALID(view));
1876 if (view->ntatable_priv == NULL)
1878 dns_ntatable_attach(view->ntatable_priv, ntp);
1883 dns_view_initsecroots(dns_view_t *view, isc_mem_t *mctx) {
1884 REQUIRE(DNS_VIEW_VALID(view));
1885 if (view->secroots_priv != NULL)
1886 dns_keytable_detach(&view->secroots_priv);
1887 return (dns_keytable_create(mctx, &view->secroots_priv));
1891 dns_view_getsecroots(dns_view_t *view, dns_keytable_t **ktp) {
1892 REQUIRE(DNS_VIEW_VALID(view));
1894 if (view->secroots_priv == NULL)
1896 dns_keytable_attach(view->secroots_priv, ktp);
1901 dns_view_ntacovers(dns_view_t *view, isc_stdtime_t now,
1904 REQUIRE(DNS_VIEW_VALID(view));
1906 if (view->ntatable_priv == NULL)
1909 return (dns_ntatable_covered(view->ntatable_priv, now, name, anchor));
1913 dns_view_issecuredomain(dns_view_t *view, dns_name_t *name,
1922 REQUIRE(DNS_VIEW_VALID(view));
1924 if (view->secroots_priv == NULL)
1930 result = dns_keytable_issecuredomain(view->secroots_priv, name,
1935 if (checknta && secure && view->ntatable_priv != NULL &&
1936 dns_ntatable_covered(view->ntatable_priv, now, name, anchor))
1944 dns_view_untrust(dns_view_t *view, dns_name_t *keyname,
1969 result = dns_view_getsecroots(view, &sr);
1991 dns_view_setnewzones(dns_view_t *view, isc_boolean_t allow, void *cfgctx,
2005 REQUIRE(DNS_VIEW_VALID(view));
2008 if (view->new_zone_file != NULL) {
2009 isc_mem_free(view->mctx, view->new_zone_file);
2010 view->new_zone_file = NULL;
2014 if (view->new_zone_dbenv != NULL) {
2015 mdb_env_close((MDB_env *) view->new_zone_dbenv);
2016 view->new_zone_dbenv = NULL;
2019 if (view->new_zone_db != NULL) {
2020 isc_mem_free(view->mctx, view->new_zone_db);
2021 view->new_zone_db = NULL;
2025 if (view->new_zone_config != NULL) {
2026 view->cfg_destroy(&view->new_zone_config);
2027 view->cfg_destroy = NULL;
2033 CHECK(isc_file_sanitize(NULL, view->name, "nzf",
2036 view->new_zone_file = isc_mem_strdup(view->mctx, buffer);
2037 if (view->new_zone_file == NULL) {
2042 CHECK(isc_file_sanitize(NULL, view->name, "nzd",
2045 view->new_zone_db = isc_mem_strdup(view->mctx, buffer);
2046 if (view->new_zone_db == NULL) {
2068 view->new_zone_mapsize = mapsize;
2071 status = mdb_env_open(env, view->new_zone_db, DNS_LMDB_FLAGS, 0600);
2076 view->new_zone_db, mdb_strerror(status));
2080 view->new_zone_dbenv = env;
2084 view->new_zone_config = cfgctx;
2085 view->cfg_destroy = cfg_destroy;
2089 if (view->new_zone_file != NULL) {
2090 isc_mem_free(view->mctx, view->new_zone_file);
2091 view->new_zone_file = NULL;
2095 if (view->new_zone_db != NULL) {
2096 isc_mem_free(view->mctx, view->new_zone_db);
2097 view->new_zone_db = NULL;
2103 view->new_zone_config = NULL;
2104 view->cfg_destroy = NULL;
2111 dns_view_searchdlz(dns_view_t *view, dns_name_t *name, unsigned int minlabels,
2128 REQUIRE(DNS_VIEW_VALID(view));
2139 for (dlzdb = ISC_LIST_HEAD(view->dlz_searched);
2168 view->rdclass, zonename,
2199 dns_view_getfailttl(dns_view_t *view) {
2200 REQUIRE(DNS_VIEW_VALID(view));
2201 return (view->fail_ttl);
2205 dns_view_setfailttl(dns_view_t *view, isc_uint32_t fail_ttl) {
2206 REQUIRE(DNS_VIEW_VALID(view));
2207 view->fail_ttl = fail_ttl;
2211 dns_view_saventa(dns_view_t *view) {
2217 REQUIRE(DNS_VIEW_VALID(view));
2219 if (view->nta_lifetime == 0)
2223 CHECK(isc_stdio_open(view->nta_file, "w", &fp));
2225 result = dns_view_getntatable(view, &ntatable);
2251 (void) isc_file_remove(view->nta_file);
2260 dns_view_loadnta(dns_view_t *view) {
2267 REQUIRE(DNS_VIEW_VALID(view));
2269 if (view->nta_lifetime == 0)
2272 CHECK(isc_lex_create(view->mctx, 1025, &lex));
2273 CHECK(isc_lex_openfile(lex, view->nta_file));
2274 CHECK(dns_view_getntatable(view, &ntatable));
2358 dns_view_setviewcommit(dns_view_t *view) {
2359 REQUIRE(DNS_VIEW_VALID(view));
2361 LOCK(&view->lock);
2363 if (view->redirect != NULL) {
2364 dns_zone_setviewcommit(view->redirect);
2366 if (view->managed_keys != NULL) {
2367 dns_zone_setviewcommit(view->managed_keys);
2369 if (view->zonetable != NULL) {
2370 dns_zt_setviewcommit(view->zonetable);
2373 UNLOCK(&view->lock);
2377 dns_view_setviewrevert(dns_view_t *view) {
2380 REQUIRE(DNS_VIEW_VALID(view));
2383 * dns_zt_setviewrevert() attempts to lock this view, so we must
2386 LOCK(&view->lock);
2387 if (view->redirect != NULL) {
2388 dns_zone_setviewrevert(view->redirect);
2390 if (view->managed_keys != NULL) {
2391 dns_zone_setviewrevert(view->managed_keys);
2393 zonetable = view->zonetable;
2394 UNLOCK(&view->lock);