Lines Matching refs:search
2902 rbtdb_search_t *search = arg;
2914 if (search->zonecut != NULL) {
2920 onode = search->rbtdb->origin_node;
2922 NODE_LOCK(&(search->rbtdb->node_locks[node->locknum].lock),
2938 if (header->serial <= search->serial &&
2961 IS_STUB(search->rbtdb))
2980 if (!IS_CACHE(search->rbtdb) && !IS_STUB(search->rbtdb) &&
2988 search->zonecut_sigrdataset = NULL;
2991 search->zonecut_sigrdataset = sigdname_header;
2994 search->zonecut_sigrdataset = NULL;
3000 * search->zonecut_rdataset will still be valid later.
3002 new_reference(search->rbtdb, node, isc_rwlocktype_read);
3003 search->zonecut = node;
3004 search->zonecut_rdataset = found;
3005 search->need_cleanup = true;
3009 * may clear search->wild.
3011 search->wild = false;
3012 if ((search->options & DNS_DBFIND_GLUEOK) == 0) {
3015 * this is the best answer and the search should
3023 * The search will continue beneath the zone cut.
3027 zcname = dns_fixedname_name(&search->zonecut_name);
3029 search->copy_name = true;
3041 if (node->wild && (search->options & DNS_DBFIND_NOWILD) == 0) {
3042 search->wild = true;
3046 NODE_UNLOCK(&(search->rbtdb->node_locks[node->locknum].lock),
3176 setup_delegation(rbtdb_search_t *search, dns_dbnode_t **nodep,
3183 REQUIRE(search != NULL);
3184 REQUIRE(search->zonecut != NULL);
3185 REQUIRE(search->zonecut_rdataset != NULL);
3191 node = search->zonecut;
3192 type = search->zonecut_rdataset->type;
3201 if (foundname != NULL && search->copy_name) {
3202 zcname = dns_fixedname_name(&search->zonecut_name);
3209 * already have in the search block.
3212 search->need_cleanup = false;
3215 NODE_LOCK(&(search->rbtdb->node_locks[node->locknum].lock),
3217 bind_rdataset(search->rbtdb, node, search->zonecut_rdataset,
3218 search->now, isc_rwlocktype_read, rdataset);
3219 if (sigrdataset != NULL && search->zonecut_sigrdataset != NULL)
3221 bind_rdataset(search->rbtdb, node,
3222 search->zonecut_sigrdataset, search->now,
3225 NODE_UNLOCK(&(search->rbtdb->node_locks[node->locknum].lock),
3236 valid_glue(rbtdb_search_t *search, dns_name_t *name, rbtdb_rdatatype_t type,
3255 if (node != search->zonecut) {
3264 header = search->zonecut_rdataset;
3292 activeempty(rbtdb_search_t *search, dns_rbtnodechain_t *chain,
3305 rbtdb = search->rbtdb;
3323 if (header->serial <= search->serial &&
3346 activeemptynode(rbtdb_search_t *search, const dns_name_t *qname,
3367 rbtdb = search->rbtdb;
3381 chain = search->chain;
3392 if (header->serial <= search->serial &&
3423 if (header->serial <= search->serial &&
3468 find_wildcard(rbtdb_search_t *search, dns_rbtnode_t **nodep,
3489 * search for it. If the wildcard node exists, and is active in
3493 * continue the search.
3496 rbtdb = search->rbtdb;
3497 i = search->chain.level_matches;
3506 * the search's version. We do this now, even though we
3512 if (header->serial <= search->serial &&
3546 level_node = search->chain.levels[j];
3566 * is active in the search's version, we're
3574 if (header->serial <= search->serial &&
3583 activeempty(search, &wchain, wname))
3585 if (activeemptynode(search, qname,
3621 node = search->chain.levels[i];
3631 matchparams(rdatasetheader_t *header, rbtdb_search_t *search) {
3650 dns_rdata_fromregion(&rdata, search->rbtdb->common.rdclass,
3655 if (nsec3.hash == search->rbtversion->hash &&
3656 nsec3.iterations == search->rbtversion->iterations &&
3657 nsec3.salt_length == search->rbtversion->salt_length &&
3658 memcmp(nsec3.salt, search->rbtversion->salt,
3672 previous_closest_nsec(dns_rdatatype_t type, rbtdb_search_t *search,
3685 result = dns_rbtnodechain_prev(&search->chain, NULL, NULL);
3689 result = dns_rbtnodechain_current(&search->chain, name, origin,
3711 search->rbtdb->nsec, target, NULL, &nsecnode,
3761 result = dns_rbt_findnode(search->rbtdb->tree, target, NULL,
3762 nodep, &search->chain,
3785 * search chain. For NSEC3 records only NSEC3 records that match the
3789 find_closest_nsec(rbtdb_search_t *search, dns_dbnode_t **nodep,
3806 if (tree == search->rbtdb->nsec3) {
3825 result = dns_rbtnodechain_current(&search->chain, name, origin, &node);
3830 NODE_LOCK(&(search->rbtdb->node_locks[node->locknum].lock),
3842 if (header->serial <= search->serial &&
3877 if (found != NULL && search->rbtversion->havensec3 &&
3879 !matchparams(found, search))
3885 type, search, name, origin, &prevnode,
3904 search->rbtdb, node,
3908 bind_rdataset(search->rbtdb, node,
3909 found, search->now,
3914 search->rbtdb, node,
3915 foundsig, search->now,
3925 * relevant for our search. Treat the
3930 type, search, name, origin, &prevnode,
3945 result = previous_closest_nsec(type, search, name,
3949 NODE_UNLOCK(&(search->rbtdb->node_locks[node->locknum].lock),
3960 result = dns_rbtnodechain_last(&search->chain, tree, NULL,
3987 rbtdb_search_t search;
4001 search.rbtdb = (dns_rbtdb_t *)db;
4003 REQUIRE(VALID_RBTDB(search.rbtdb));
4021 search.rbtversion = version;
4022 search.serial = search.rbtversion->serial;
4023 search.options = options;
4024 search.copy_name = false;
4025 search.need_cleanup = false;
4026 search.wild = false;
4027 search.zonecut = NULL;
4028 dns_fixedname_init(&search.zonecut_name);
4029 dns_rbtnodechain_init(&search.chain);
4030 search.now = 0;
4037 RWLOCK(&search.rbtdb->tree_lock, isc_rwlocktype_read);
4041 * encounter a callback node, zone_zonecut_callback() will search the
4044 tree = (options & DNS_DBFIND_FORCENSEC3) != 0 ? search.rbtdb->nsec3
4045 : search.rbtdb->tree;
4046 result = dns_rbt_findnode(tree, name, foundname, &node, &search.chain,
4048 &search);
4052 if (search.zonecut != NULL) {
4053 result = setup_delegation(&search, nodep, foundname,
4058 if (search.wild) {
4060 * At least one of the levels in the search chain
4065 result = find_wildcard(&search, &node, name);
4081 dns_rbtnodechain_t chain = search.chain;
4082 active = activeempty(&search, &chain, name);
4089 if ((search.rbtversion->secure == dns_db_secure &&
4090 !search.rbtversion->havensec3) ||
4091 (search.options & DNS_DBFIND_FORCENSEC) != 0 ||
4092 (search.options & DNS_DBFIND_FORCENSEC3) != 0)
4094 result = find_closest_nsec(&search, nodep, foundname,
4096 search.rbtversion->secure);
4115 if (search.zonecut != NULL) {
4133 ((node != search.rbtdb->origin_node &&
4135 IS_STUB(search.rbtdb)))
4156 lock = &search.rbtdb->node_locks[node->locknum].lock;
4172 if (header->serial <= search.serial && !IGNORE(header))
4199 * ensure that search->zonecut_rdataset will
4202 new_reference(search.rbtdb, node,
4204 search.zonecut = node;
4205 search.zonecut_rdataset = header;
4206 search.zonecut_sigrdataset = NULL;
4207 search.need_cleanup = true;
4216 if ((search.options & DNS_DBFIND_GLUEOK) == 0 &&
4238 !matchparams(header, &search))
4273 * If we've got all we need, end the search.
4285 * If we've got all we need, end the search.
4291 !search.rbtversion->havensec3)
4300 !search.rbtversion->havensec3)
4336 if (search.zonecut != NULL) {
4344 result = setup_delegation(&search, nodep, foundname,
4352 if (search.rbtversion->secure == dns_db_secure &&
4353 !search.rbtversion->havensec3 &&
4366 result = find_closest_nsec(&search, nodep, foundname,
4368 search.rbtdb->tree,
4369 search.rbtversion->secure);
4375 if ((search.options & DNS_DBFIND_FORCENSEC) != 0 &&
4386 new_reference(search.rbtdb, node, isc_rwlocktype_read);
4389 if ((search.rbtversion->secure == dns_db_secure &&
4390 !search.rbtversion->havensec3) ||
4391 (search.options & DNS_DBFIND_FORCENSEC) != 0)
4393 bind_rdataset(search.rbtdb, node, nsecheader, 0,
4396 bind_rdataset(search.rbtdb, node, nsecsig, 0,
4419 } else if (search.zonecut != NULL) {
4425 if (search.zonecut == node) {
4453 (search.options & DNS_DBFIND_VALIDATEGLUE) != 0 &&
4454 !valid_glue(&search, foundname, type, node))
4457 result = setup_delegation(&search, nodep, foundname,
4470 new_reference(search.rbtdb, node, isc_rwlocktype_read);
4472 search.need_cleanup = false;
4478 bind_rdataset(search.rbtdb, node, found, 0, isc_rwlocktype_read,
4481 bind_rdataset(search.rbtdb, node, foundsig, 0,
4494 RWUNLOCK(&search.rbtdb->tree_lock, isc_rwlocktype_read);
4500 if (search.need_cleanup) {
4501 node = search.zonecut;
4503 lock = &(search.rbtdb->node_locks[node->locknum].lock);
4506 decrement_reference(search.rbtdb, node, 0, isc_rwlocktype_read,
4515 dns_rbtnodechain_reset(&search.chain);
4544 rbtdb_search_t *search, rdatasetheader_t **header_prev) {
4545 if (!ACTIVE(header, search->now)) {
4547 STALE_TTL(header, search->rbtdb);
4556 if (!ZEROTTL(header) && KEEPSTALE(search->rbtdb) &&
4557 stale > search->now)
4559 mark_header_stale(search->rbtdb, header);
4567 if ((search->options & DNS_DBFIND_STALESTART) != 0) {
4570 search->now);
4571 } else if ((search->options &
4573 search->now <
4576 search->rbtdb->serve_stale_refresh))
4587 } else if ((search->options &
4596 return ((search->options & DNS_DBFIND_STALEOK) == 0);
4605 if ((header->rdh_ttl < search->now - RBTDB_VIRTUAL) &&
4630 mctx = search->rbtdb->common.mctx;
4631 clean_stale_headers(search->rbtdb, mctx,
4638 free_rdataset(search->rbtdb, mctx, header);
4640 mark_header_ancient(search->rbtdb, header);
4653 rbtdb_search_t *search = arg;
4662 REQUIRE(search->zonecut == NULL);
4669 lock = &(search->rbtdb->node_locks[node->locknum].lock);
4681 if (check_stale_header(node, header, &locktype, lock, search,
4702 (search->options & DNS_DBFIND_PENDINGOK) != 0))
4706 * search->zonecut_rdataset will still be valid later.
4708 new_reference(search->rbtdb, node, locktype);
4709 search->zonecut = node;
4710 search->zonecut_rdataset = dname_header;
4711 search->zonecut_sigrdataset = sigdname_header;
4712 search->need_cleanup = true;
4724 find_deepest_zonecut(rbtdb_search_t *search, dns_rbtnode_t *node,
4742 rbtdb = search->rbtdb;
4743 i = search->chain.level_matches;
4760 search, &header_prev))
4802 level_node = search->chain.levels[i];
4818 new_reference(search->rbtdb, node, locktype);
4821 bind_rdataset(search->rbtdb, node, found, search->now,
4824 bind_rdataset(search->rbtdb, node, foundsig,
4825 search->now, locktype,
4828 if (need_headerupdate(found, search->now) ||
4830 need_headerupdate(foundsig, search->now)))
4838 if (need_headerupdate(found, search->now)) {
4839 update_header(search->rbtdb, found,
4840 search->now);
4843 need_headerupdate(foundsig, search->now))
4845 update_header(search->rbtdb, foundsig,
4846 search->now);
4856 node = search->chain.levels[i];
4873 find_coveringnsec(rbtdb_search_t *search, const dns_name_t *name,
4895 result = dns_rbt_findnode(search->rbtdb->nsec, name, target, &node,
4930 result = dns_rbt_findnode(search->rbtdb->tree, target, fname, &node,
4936 lock = &(search->rbtdb->node_locks[node->locknum].lock);
4940 if (check_stale_header(node, header, &locktype, lock, search,
4965 bind_rdataset(search->rbtdb, node, found, now, locktype,
4968 bind_rdataset(search->rbtdb, node, foundsig, now,
4971 new_reference(search->rbtdb, node, locktype);
4991 rbtdb_search_t search;
5007 search.rbtdb = (dns_rbtdb_t *)db;
5009 REQUIRE(VALID_RBTDB(search.rbtdb));
5016 search.rbtversion = NULL;
5017 search.serial = 1;
5018 search.options = options;
5019 search.copy_name = false;
5020 search.need_cleanup = false;
5021 search.wild = false;
5022 search.zonecut = NULL;
5023 search.zonecut_rdataset = NULL;
5024 search.zonecut_sigrdataset = NULL;
5025 dns_fixedname_init(&search.zonecut_name);
5026 dns_rbtnodechain_init(&search.chain);
5027 search.now = now;
5031 RWLOCK(&search.rbtdb->tree_lock, isc_rwlocktype_read);
5035 * encounter a callback node, cache_zonecut_callback() will search the
5038 result = dns_rbt_findnode(search.rbtdb->tree, name, foundname, &node,
5039 &search.chain, DNS_RBTFIND_EMPTYDATA,
5040 cache_zonecut_callback, &search);
5047 if ((search.options & DNS_DBFIND_COVERINGNSEC) != 0 &&
5048 (search.zonecut_rdataset == NULL ||
5049 search.zonecut_rdataset->type != dns_rdatatype_dname))
5051 result = find_coveringnsec(&search, name, nodep, now,
5058 if (search.zonecut != NULL) {
5059 result = setup_delegation(&search, nodep, foundname,
5064 result = find_deepest_zonecut(&search, node, nodep,
5088 lock = &(search.rbtdb->node_locks[node->locknum].lock);
5105 if (check_stale_header(node, header, &locktype, lock, &search,
5198 if ((search.options & DNS_DBFIND_COVERINGNSEC) != 0) {
5199 result = find_coveringnsec(&search, name, nodep, now,
5223 if ((search.options & DNS_DBFIND_COVERINGNSEC) != 0 &&
5227 new_reference(search.rbtdb, node, locktype);
5230 bind_rdataset(search.rbtdb, node, nsecheader,
5231 search.now, locktype, rdataset);
5232 if (need_headerupdate(nsecheader, search.now)) {
5236 bind_rdataset(search.rbtdb, node, nsecsig,
5237 search.now, locktype,
5239 if (need_headerupdate(nsecsig, search.now)) {
5251 (search.options & DNS_DBFIND_COVERINGNSEC) != 0)
5254 result = find_coveringnsec(&search, name, nodep, now,
5269 new_reference(search.rbtdb, node, locktype);
5272 bind_rdataset(search.rbtdb, node, nsheader, search.now,
5274 if (need_headerupdate(nsheader, search.now)) {
5278 bind_rdataset(search.rbtdb, node, nssig,
5279 search.now, locktype,
5281 if (need_headerupdate(nssig, search.now)) {
5301 new_reference(search.rbtdb, node, locktype);
5333 bind_rdataset(search.rbtdb, node, found, search.now, locktype,
5335 if (need_headerupdate(found, search.now)) {
5339 bind_rdataset(search.rbtdb, node, foundsig, search.now,
5341 if (need_headerupdate(foundsig, search.now)) {
5356 if (update != NULL && need_headerupdate(update, search.now)) {
5357 update_header(search.rbtdb, update, search.now);
5359 if (updatesig != NULL && need_headerupdate(updatesig, search.now)) {
5360 update_header(search.rbtdb, updatesig, search.now);
5366 RWUNLOCK(&search.rbtdb->tree_lock, isc_rwlocktype_read);
5372 if (search.need_cleanup) {
5373 node = search.zonecut;
5375 lock = &(search.rbtdb->node_locks[node->locknum].lock);
5378 decrement_reference(search.rbtdb, node, 0, isc_rwlocktype_read,
5383 dns_rbtnodechain_reset(&search.chain);
5385 update_cachestats(search.rbtdb, result);
5397 rbtdb_search_t search;
5404 search.rbtdb = (dns_rbtdb_t *)db;
5406 REQUIRE(VALID_RBTDB(search.rbtdb));
5412 search.rbtversion = NULL;
5413 search.serial = 1;
5414 search.options = options;
5415 search.copy_name = false;
5416 search.need_cleanup = false;
5417 search.wild = false;
5418 search.zonecut = NULL;
5419 dns_fixedname_init(&search.zonecut_name);
5420 dns_rbtnodechain_init(&search.chain);
5421 search.now = now;
5431 RWLOCK(&search.rbtdb->tree_lock, isc_rwlocktype_read);
5436 result = dns_rbt_findnode(search.rbtdb->tree, name, dcname, &node,
5437 &search.chain, rbtoptions, NULL, &search);
5440 result = find_deepest_zonecut(&search, node, nodep, foundname,
5453 lock = &(search.rbtdb->node_locks[node->locknum].lock);
5462 if (check_stale_header(node, header, &locktype, lock, &search,
5476 result = find_deepest_zonecut(&search, node, nodep,
5511 result = find_deepest_zonecut(&search, node, nodep, foundname,
5517 new_reference(search.rbtdb, node, locktype);
5521 bind_rdataset(search.rbtdb, node, found, search.now, locktype,
5524 bind_rdataset(search.rbtdb, node, foundsig, search.now,
5528 if (need_headerupdate(found, search.now) ||
5529 (foundsig != NULL && need_headerupdate(foundsig, search.now)))
5537 if (need_headerupdate(found, search.now)) {
5538 update_header(search.rbtdb, found, search.now);
5540 if (foundsig != NULL && need_headerupdate(foundsig, search.now))
5542 update_header(search.rbtdb, foundsig, search.now);
5549 RWUNLOCK(&search.rbtdb->tree_lock, isc_rwlocktype_read);
5551 INSIST(!search.need_cleanup);
5553 dns_rbtnodechain_reset(&search.chain);