Lines Matching defs:qstate

91 subnet_new_qstate(struct module_qstate *qstate, int id)
94 qstate->region, sizeof(struct subnet_qstate));
97 qstate->minfo[id] = sq;
99 sq->started_no_cache_store = qstate->no_cache_store;
100 sq->started_no_cache_lookup = qstate->no_cache_lookup;
107 struct module_qstate *qstate, struct regional *region)
110 sldns_buffer* buf = qstate->env->scratch_buffer;
137 qstate->env->cfg->client_subnet_opcode,
144 uint16_t ATTR_UNUSED(flags), struct module_qstate* qstate,
152 if(!(sq=(struct subnet_qstate*)qstate->minfo[id]))
154 sn_env = (struct subnet_env*)qstate->env->modinfo[id];
158 if(!iter_stub_fwd_no_cache(qstate, &qstate->qinfo, NULL, NULL, NULL, 0)) {
159 qstate->no_cache_store = 0;
164 qstate->env->cfg->client_subnet_always_forward) ||
171 if(!edns_opt_list_find(qstate->edns_opts_back_out,
172 qstate->env->cfg->client_subnet_opcode)) {
182 &qstate->edns_opts_back_out, qstate, region);
189 if(edns_opt_list_find(qstate->edns_opts_back_out,
190 qstate->env->cfg->client_subnet_opcode)) {
191 edns_opt_list_remove(&qstate->edns_opts_back_out,
192 qstate->env->cfg->client_subnet_opcode);
356 update_cache(struct module_qstate *qstate, int id)
362 struct subnet_env *sne = qstate->env->modinfo[id];
363 struct subnet_qstate *sq = (struct subnet_qstate*)qstate->minfo[id];
371 hashvalue_type h = qstate->minfo[id] &&
372 ((struct subnet_qstate*)qstate->minfo[id])->qinfo_hash_calculated?
373 ((struct subnet_qstate*)qstate->minfo[id])->qinfo_hash :
374 query_info_hash(&qstate->qinfo, qstate->query_flags);
377 &qstate->qinfo, 1);
386 qinf = qstate->qinfo;
387 qinf.qname = memdup(qstate->qinfo.qname,
388 qstate->qinfo.qname_len);
407 if (!(tree = get_tree(lru_entry->data, edns, sne, qstate->env->cfg))) {
413 rep = reply_info_copy(qstate->return_msg->rep, &sne->alloc, NULL);
426 reply_info_set_ttls(rep, *qstate->env->now);
436 rep->ttl, *qstate->env->now, only_match_scope_zero);
451 lookup_and_reply(struct module_qstate *qstate, int id, struct subnet_qstate *sq, int prefetch)
454 struct module_env *env = qstate->env;
456 hashvalue_type h = query_info_hash(&qstate->qinfo, qstate->query_flags);
469 e = slabhash_lookup(sne->subnet_msg_cache, h, &qstate->qinfo, 1);
485 qstate->return_msg = tomsg(NULL, &qstate->qinfo,
486 (struct reply_info *)node->elem, qstate->region, *env->now, 0,
491 if (!qstate->return_msg) { /* Failed allocation or expired TTL */
504 if (prefetch && *qstate->env->now >= ((struct reply_info *)node->elem)->prefetch_ttl) {
505 qstate->need_refetch = 1;
526 eval_response(struct module_qstate *qstate, int id, struct subnet_qstate *sq)
528 struct subnet_env *sne = qstate->env->modinfo[id];
537 if (!qstate->return_msg) {
562 update_cache(qstate, id);
595 (void)edns_opt_list_remove(&qstate->edns_opts_back_out,
596 qstate->env->cfg->client_subnet_opcode);
604 update_cache(qstate, id);
613 if(qstate->env->cfg->serve_expired) {
614 msg_cache_remove(qstate->env, qstate->qinfo.qname,
615 qstate->qinfo.qname_len, qstate->qinfo.qtype,
616 qstate->qinfo.qclass, 0);
618 if(qstate->env->cachedb_enabled)
619 cachedb_msg_remove(qstate);
633 qstate->env->cfg->max_client_subnet_ipv4) {
635 qstate->env->cfg->max_client_subnet_ipv4;
639 qstate->env->cfg->max_client_subnet_ipv6) {
641 qstate->env->cfg->max_client_subnet_ipv6;
719 ecs_query_response(struct module_qstate* qstate, struct dns_msg* response,
724 if(!response || !(sq=(struct subnet_qstate*)qstate->minfo[id]))
730 edns_opt_list_remove(&qstate->edns_opts_back_out,
731 qstate->env->cfg->client_subnet_opcode);
741 query_dname_compare(qstate->qinfo.qname,
745 * qstate. */
771 ecs_edns_back_parsed(struct module_qstate* qstate, int id,
777 if(!(sq=(struct subnet_qstate*)qstate->minfo[id]))
780 qstate->edns_opts_back_in,
781 qstate->env->cfg->client_subnet_opcode)) &&
790 qstate->no_cache_store = 1;
797 qstate->no_cache_store = 1;
804 subnetmod_operate(struct module_qstate *qstate, enum module_ev event,
807 struct subnet_env *sne = qstate->env->modinfo[id];
808 struct subnet_qstate *sq = (struct subnet_qstate*)qstate->minfo[id];
811 "event:%s", id, strextstate(qstate->ext_state[id]),
813 log_query_info(VERB_QUERY, "subnetcache operate: query", &qstate->qinfo);
818 if(!subnet_new_qstate(qstate, id)) {
819 qstate->return_msg = NULL;
820 qstate->ext_state[id] = module_finished;
824 sq = (struct subnet_qstate*)qstate->minfo[id];
827 qstate->edns_opts_front_in,
828 qstate->env->cfg->client_subnet_opcode))) {
832 qstate->return_rcode = LDNS_RCODE_FORMERR;
833 qstate->ext_state[id] = module_finished;
839 else if(qstate->mesh_info->reply_list) {
841 &qstate->mesh_info->reply_list->query_reply.client_addr,
842 &sq->ecs_client_in, qstate->env->cfg);
844 else if(qstate->client_addr.ss_family != AF_UNSPEC) {
846 &qstate->client_addr,
847 &sq->ecs_client_in, qstate->env->cfg);
855 qstate->ext_state[id] = module_wait_module;
862 sq->ecs_client_in.subnet_source_mask < qstate->env->cfg->min_client_subnet_ipv4) ||
864 sq->ecs_client_in.subnet_source_mask < qstate->env->cfg->min_client_subnet_ipv6))) {
865 qstate->return_rcode = LDNS_RCODE_REFUSED;
866 qstate->ext_state[id] = module_finished;
870 if(!sq->started_no_cache_lookup && !qstate->blacklist) {
872 if(qstate->mesh_info->reply_list &&
873 lookup_and_reply(qstate, id, sq,
874 qstate->env->cfg->prefetch)) {
878 qstate->ext_state[id] = module_finished;
881 &qstate->edns_opts_front_out, qstate,
882 qstate->region);
886 qstate->edns_opts_front_out,
887 qstate->env->cfg->
902 qstate->env->cfg->max_client_subnet_ipv4)
904 qstate->env->cfg->max_client_subnet_ipv4;
907 qstate->env->cfg->max_client_subnet_ipv6)
909 qstate->env->cfg->max_client_subnet_ipv6;
918 qstate->env->cfg->client_subnet_always_forward &&
922 qstate->no_cache_lookup = 1;
927 qstate->ext_state[id] = module_wait_module;
932 qstate->ext_state[id] = eval_response(qstate, id, sq);
933 if(qstate->ext_state[id] == module_finished &&
934 qstate->return_msg) {
936 &qstate->edns_opts_front_out, qstate,
937 qstate->region);
941 qstate->edns_opts_front_out,
942 qstate->env->cfg->
946 qstate->no_cache_store = sq->started_no_cache_store;
947 qstate->no_cache_lookup = sq->started_no_cache_lookup;
957 qstate->ext_state[id] = module_wait_module;
962 qstate->ext_state[id] = module_finished;
966 qstate->ext_state[id] = module_error;
971 subnetmod_clear(struct module_qstate *ATTR_UNUSED(qstate),
974 /* qstate has no data outside region */
978 subnetmod_inform_super(struct module_qstate *ATTR_UNUSED(qstate),