Lines Matching refs:sq
94 struct subnet_qstate *sq = (struct subnet_qstate*)regional_alloc(
96 if(!sq)
98 qstate->minfo[id] = sq;
99 memset(sq, 0, sizeof(*sq));
100 sq->started_no_cache_store = qstate->no_cache_store;
101 sq->started_no_cache_lookup = qstate->no_cache_lookup;
150 struct subnet_qstate *sq;
153 if(!(sq=(struct subnet_qstate*)qstate->minfo[id]))
157 if(sq->is_subquery_nonsubnet) {
158 if(sq->is_subquery_scopezero) {
175 && sq->ecs_client_in.subnet_validdata) {
179 sq->subnet_sent_no_subnet = 0;
180 if(sq->ecs_server_out.subnet_validdata && ((sq->subnet_downstream &&
193 if(sq->ecs_server_out.subnet_source_mask == 0) {
194 sq->subnet_sent_no_subnet = 1;
195 sq->subnet_sent = 0;
198 subnet_ecs_opt_list_append(&sq->ecs_server_out,
201 sq->subnet_sent = 1;
211 sq->subnet_sent = 0;
380 struct subnet_qstate *sq = (struct subnet_qstate*)qstate->minfo[id];
382 struct ecs_data *edns = &sq->ecs_client_in;
452 edns->subnet_source_mask, sq->max_scope, rep,
468 lookup_and_reply(struct module_qstate *qstate, int id, struct subnet_qstate *sq, int prefetch)
475 struct ecs_data *ecs = &sq->ecs_client_in;
480 memset(&sq->ecs_client_out, 0, sizeof(sq->ecs_client_out));
482 if (sq) {
483 sq->qinfo_hash = h; /* Might be useful on cache miss */
484 sq->qinfo_hash_calculated = 1;
512 if (sq->subnet_downstream) { /* relay to interested client */
513 sq->ecs_client_out.subnet_scope_mask = scope;
514 sq->ecs_client_out.subnet_addr_fam = ecs->subnet_addr_fam;
515 sq->ecs_client_out.subnet_source_mask = ecs->subnet_source_mask;
516 memcpy(&sq->ecs_client_out.subnet_addr, &ecs->subnet_addr,
518 sq->ecs_client_out.subnet_validdata = 1;
546 * @param sq: subnet qstate
550 generate_sub_request(struct module_qstate *qstate, int id, struct subnet_qstate* sq)
587 if(sq->ecs_client_in.subnet_source_mask == 0 &&
601 * @param sq: subnet qstate
606 struct subnet_qstate* sq)
609 if(!generate_sub_request(qstate, id, sq)) {
615 sq->wait_subquery = 1;
620 eval_response(struct module_qstate *qstate, int id, struct subnet_qstate *sq)
624 struct ecs_data *c_in = &sq->ecs_client_in; /* rcvd from client */
625 struct ecs_data *c_out = &sq->ecs_client_out;/* will send to client */
626 struct ecs_data *s_in = &sq->ecs_server_in; /* rcvd from auth */
627 struct ecs_data *s_out = &sq->ecs_server_out;/* sent to auth */
639 if (!sq->subnet_sent && !sq->subnet_sent_no_subnet) {
642 if (sq->subnet_downstream) /* Copy back to client */
648 if (!s_in->subnet_validdata && !sq->subnet_sent_no_subnet) {
654 return generate_lookup_without_subnet(qstate, id, sq);
660 if(sq->subnet_sent_no_subnet && !s_in->subnet_validdata) {
684 sq->subnet_sent = 0;
685 sq->subnet_sent_no_subnet = 0;
686 return generate_lookup_without_subnet(qstate, id, sq);
690 if(!sq->started_no_cache_store) {
710 if (sq->subnet_downstream) {
716 c_out->subnet_scope_mask = sq->max_scope;
809 struct subnet_qstate *sq;
811 if(!response || !(sq=(struct subnet_qstate*)qstate->minfo[id]))
814 if(sq->subnet_sent &&
819 sq->subnet_sent = 0;
820 sq->subnet_sent_no_subnet = 0;
821 memset(&sq->ecs_server_out, 0, sizeof(sq->ecs_server_out));
822 } else if (!sq->track_max_scope &&
833 sq->track_max_scope = 1;
861 struct subnet_qstate *sq;
864 if(!(sq=(struct subnet_qstate*)qstate->minfo[id]))
869 parse_subnet_option(ecs_opt, &sq->ecs_server_in) &&
870 sq->subnet_sent && sq->ecs_server_in.subnet_validdata) {
878 if(!sq->track_max_scope || (sq->track_max_scope &&
879 sq->ecs_server_in.subnet_scope_mask >
880 sq->max_scope))
881 sq->max_scope = sq->ecs_server_in.subnet_scope_mask;
882 } else if(sq->subnet_sent_no_subnet) {
885 } else if(sq->subnet_sent) {
898 struct subnet_qstate *sq = (struct subnet_qstate*)qstate->minfo[id];
905 if(sq && sq->wait_subquery_done) {
907 if(sq->ecs_client_in.subnet_source_mask == 0 &&
910 if(!sq->started_no_cache_store &&
916 if (sq->subnet_downstream)
917 cp_edns_bad_response(&sq->ecs_client_out,
918 &sq->ecs_client_in);
921 subnet_ecs_opt_list_append(&sq->ecs_client_out,
925 sq->wait_subquery_done = 0;
927 qstate->no_cache_store = sq->started_no_cache_store;
928 qstate->no_cache_lookup = sq->started_no_cache_lookup;
932 sq == NULL) {
940 sq = (struct subnet_qstate*)qstate->minfo[id];
941 if(sq->wait_subquery)
947 if(!parse_subnet_option(ecs_opt, &sq->ecs_client_in)) {
955 sq->subnet_downstream = 1;
960 &sq->ecs_client_in, qstate->env->cfg);
965 &sq->ecs_client_in, qstate->env->cfg);
968 if(sq->ecs_client_in.subnet_validdata == 0) {
971 sq->ecs_server_out.subnet_validdata = 0;
977 qstate, id, sq);
986 if(sq->ecs_client_in.subnet_source_mask != 0 && (
987 (sq->ecs_client_in.subnet_addr_fam == EDNSSUBNET_ADDRFAM_IP4 &&
988 sq->ecs_client_in.subnet_source_mask < qstate->env->cfg->min_client_subnet_ipv4) ||
989 (sq->ecs_client_in.subnet_addr_fam == EDNSSUBNET_ADDRFAM_IP6 &&
990 sq->ecs_client_in.subnet_source_mask < qstate->env->cfg->min_client_subnet_ipv6))) {
996 if(!sq->started_no_cache_lookup && !qstate->blacklist) {
999 lookup_and_reply(qstate, id, sq,
1006 subnet_ecs_opt_list_append(&sq->ecs_client_out,
1020 if(sq->ecs_client_in.subnet_source_mask == 0 &&
1025 qstate, id, sq);
1029 sq->ecs_server_out.subnet_addr_fam =
1030 sq->ecs_client_in.subnet_addr_fam;
1031 sq->ecs_server_out.subnet_source_mask =
1032 sq->ecs_client_in.subnet_source_mask;
1034 if(sq->ecs_server_out.subnet_addr_fam == EDNSSUBNET_ADDRFAM_IP4
1035 && sq->ecs_server_out.subnet_source_mask >
1037 sq->ecs_server_out.subnet_source_mask =
1039 else if(sq->ecs_server_out.subnet_addr_fam == EDNSSUBNET_ADDRFAM_IP6
1040 && sq->ecs_server_out.subnet_source_mask >
1042 sq->ecs_server_out.subnet_source_mask =
1047 memcpy(&sq->ecs_server_out.subnet_addr,
1048 sq->ecs_client_in.subnet_addr, INET6_SIZE);
1049 sq->ecs_server_out.subnet_scope_mask = 0;
1050 sq->ecs_server_out.subnet_validdata = 1;
1051 if(sq->ecs_server_out.subnet_source_mask != 0 &&
1053 sq->subnet_downstream)
1064 if(sq && sq->wait_subquery)
1067 if(sq && event == module_event_moddone) {
1068 qstate->ext_state[id] = eval_response(qstate, id, sq);
1071 subnet_ecs_opt_list_append(&sq->ecs_client_out,
1082 qstate->no_cache_store = sq->started_no_cache_store;
1083 qstate->no_cache_lookup = sq->started_no_cache_lookup;
1086 if(sq && outbound) {
1096 if(!sq && (event == module_event_moddone)) {