This file contains a module that performs recusive iterative DNS query processing. More...
#include "config.h"
#include "iterator/iterator.h"
#include "iterator/iter_utils.h"
#include "iterator/iter_hints.h"
#include "iterator/iter_fwd.h"
#include "iterator/iter_donotq.h"
#include "iterator/iter_delegpt.h"
#include "iterator/iter_resptype.h"
#include "iterator/iter_scrub.h"
#include "iterator/iter_priv.h"
#include "validator/val_neg.h"
#include "util/locks.h"
#include "util/rbtree.h"
#include "services/cache/dns.h"
#include "services/cache/infra.h"
#include "util/module.h"
#include "util/netevent.h"
#include "util/net_help.h"
#include "util/regional.h"
#include "util/data/dname.h"
#include "util/data/msgencode.h"
#include "util/fptr_wlist.h"
#include "util/config_file.h"
Functions | |
int | iter_init (struct module_env *env, int id) |
iterator init | |
void | iter_deinit (struct module_env *env, int id) |
iterator deinit | |
static int | iter_new (struct module_qstate *qstate, int id) |
new query for iterator | |
static int | next_state (struct iter_qstate *iq, enum iter_state nextstate) |
Transition to the next state. | |
static int | final_state (struct iter_qstate *iq) |
Transition an event to its final state. | |
static void | error_supers (struct module_qstate *qstate, int id, struct module_qstate *super) |
Callback routine to handle errors in parent query states. | |
static int | error_response (struct module_qstate *qstate, int id, int rcode) |
Return an error to the client. | |
static int | error_response_cache (struct module_qstate *qstate, int id, int rcode) |
Return an error to the client and cache the error code in the message cache (so per qname, qtype, qclass). | |
static int | prepend_is_duplicate (struct ub_packed_rrset_key **sets, size_t to, struct ub_packed_rrset_key *dup) |
check if prepend item is duplicate item | |
static int | iter_prepend (struct iter_qstate *iq, struct dns_msg *msg, struct regional *region) |
prepend the prepend list in the answer and authority section of dns_msg | |
static int | iter_add_prepend_answer (struct module_qstate *qstate, struct iter_qstate *iq, struct ub_packed_rrset_key *rrset) |
Add rrset to ANSWER prepend list. | |
static int | iter_add_prepend_auth (struct module_qstate *qstate, struct iter_qstate *iq, struct ub_packed_rrset_key *rrset) |
Add rrset to AUTHORITY prepend list. | |
static int | handle_cname_response (struct module_qstate *qstate, struct iter_qstate *iq, struct dns_msg *msg, uint8_t **mname, size_t *mname_len) |
Given a CNAME response (defined as a response containing a CNAME or DNAME that does not answer the request), process the response, modifying the state as necessary. | |
static int | generate_sub_request (uint8_t *qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, struct module_qstate *qstate, int id, struct iter_qstate *iq, enum iter_state initial_state, enum iter_state final_state, struct module_qstate **subq_ret, int v) |
Generate a subrequest. | |
static int | prime_root (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie, int id, uint16_t qclass) |
Generate and send a root priming request. | |
static int | prime_stub (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie, int id, struct query_info *q) |
Generate and process a stub priming request. | |
static void | generate_a_aaaa_check (struct module_qstate *qstate, struct iter_qstate *iq, int id) |
Generate A and AAAA checks for glue that is in-zone for the referral we just got to obtain authoritative information on the adresses. | |
static void | generate_ns_check (struct module_qstate *qstate, struct iter_qstate *iq, int id) |
Generate a NS check request to obtain authoritative information on an NS rrset. | |
static void | generate_dnskey_prefetch (struct module_qstate *qstate, struct iter_qstate *iq, int id) |
Generate a DNSKEY prefetch query to get the DNSKEY for the DS record we just got in a referral (where we have dnssec_expected, thus have trust anchors above it). | |
static int | forward_request (struct module_qstate *qstate, struct iter_qstate *iq) |
See if the query needs forwarding. | |
static int | processInitRequest (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie, int id) |
Process the initial part of the request handling. | |
static int | processInitRequest2 (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie, int id) |
Process the second part of the initial request handling. | |
static int | processInitRequest3 (struct module_qstate *qstate, struct iter_qstate *iq, int id) |
Process the third part of the initial request handling. | |
static int | generate_target_query (struct module_qstate *qstate, struct iter_qstate *iq, int id, uint8_t *name, size_t namelen, uint16_t qtype, uint16_t qclass) |
Given a basic query, generate a "target" query. | |
static int | query_for_targets (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie, int id, int maxtargets, int *num) |
Given an event at a certain state, generate zero or more target queries for it's current delegation point. | |
static int | processQueryTargets (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie, int id) |
This is the request event state where the request will be sent to one of its current query targets. | |
static struct ub_packed_rrset_key * | find_NS (struct reply_info *rep, size_t from, size_t to) |
find NS rrset in given list | |
static int | processQueryResponse (struct module_qstate *qstate, struct iter_qstate *iq, int id) |
Process the query response. | |
static void | prime_supers (struct module_qstate *qstate, int id, struct module_qstate *forq) |
Return priming query results to interestes super querystates. | |
static int | processPrimeResponse (struct module_qstate *qstate, int id) |
This handles the response to a priming query. | |
static void | processTargetResponse (struct module_qstate *qstate, int id, struct module_qstate *forq) |
Do final processing on responses to target queries. | |
static void | processClassResponse (struct module_qstate *qstate, int id, struct module_qstate *forq) |
Process response for qclass=ANY queries for a particular class. | |
static int | processCollectClass (struct module_qstate *qstate, int id) |
Collect class ANY responses and make them into one response. | |
static int | processFinished (struct module_qstate *qstate, struct iter_qstate *iq, int id) |
This handles the final state for first-tier responses (i.e., responses to externally generated queries). | |
void | iter_inform_super (struct module_qstate *qstate, int id, struct module_qstate *super) |
Return priming query results to interestes super querystates. | |
static void | iter_handle (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie, int id) |
Handle iterator state. | |
static void | process_request (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie, int id) |
This is the primary entry point for processing request events. | |
static void | process_response (struct module_qstate *qstate, struct iter_qstate *iq, struct iter_env *ie, int id, struct outbound_entry *outbound, enum module_ev event) |
process authoritative server reply | |
void | iter_operate (struct module_qstate *qstate, enum module_ev event, int id, struct outbound_entry *outbound) |
iterator operate on a query | |
void | iter_clear (struct module_qstate *qstate, int id) |
iterator cleanup query state | |
size_t | iter_get_mem (struct module_env *env, int id) |
iterator alloc size routine | |
struct module_func_block * | iter_get_funcblock () |
Get the iterator function block. | |
const char * | iter_state_to_string (enum iter_state state) |
Get iterator state as a string. | |
int | iter_state_is_responsestate (enum iter_state s) |
See if iterator state is a response state. | |
Variables | |
static struct module_func_block | iter_block |
The iterator function block. |
This file contains a module that performs recusive iterative DNS query processing.
static int next_state | ( | struct iter_qstate * | iq, | |
enum iter_state | nextstate | |||
) | [static] |
Transition to the next state.
This can be used to advance a currently processing event. It cannot be used to reactivate a forEvent.
iq,: | iterator query state | |
nextstate | The state to transition to. |
References iter_state_is_responsestate(), log_err(), iter_qstate::response, and iter_qstate::state.
Referenced by final_state(), processInitRequest(), processInitRequest2(), processInitRequest3(), processQueryResponse(), and processQueryTargets().
static int final_state | ( | struct iter_qstate * | iq | ) | [static] |
Transition an event to its final state.
Final states always either return a result up the module chain, or reactivate a dependent event. Which final state to transtion to is set in the module state for the event when it was created, and depends on the original purpose of the event.
The response is stored in the qstate->buf buffer.
iq,: | iterator query state |
References iter_qstate::final_state, and next_state().
Referenced by processInitRequest(), processInitRequest3(), and processQueryResponse().
static void error_supers | ( | struct module_qstate * | qstate, | |
int | id, | |||
struct module_qstate * | super | |||
) | [static] |
Callback routine to handle errors in parent query states.
qstate,: | query state that failed. | |
id,: | module id. | |
super,: | super state. |
References cache_fill_missing(), delegpt_find_ns(), delegpt_log(), iter_qstate::dp, module_qstate::env, log_assert, log_err(), log_query_info(), module_qstate::minfo, iter_qstate::num_target_queries, iter_qstate::qchase, query_info::qclass, module_qstate::qinfo, query_info::qname, query_info::qname_len, query_info::qtype, QUERYTARGETS_STATE, module_qstate::region, delegpt_ns::resolved, iter_qstate::state, VERB_ALGO, and verbose().
Referenced by iter_inform_super().
static int error_response | ( | struct module_qstate * | qstate, | |
int | id, | |||
int | rcode | |||
) | [static] |
Return an error to the client.
qstate,: | our query state | |
id,: | module id | |
rcode,: | error code (DNS errcode). |
References module_qstate::ext_state, module_finished, delegpt_ns::name, module_qstate::return_msg, module_qstate::return_rcode, VERB_QUERY, and verbose().
Referenced by error_response_cache(), iter_operate(), prime_stub(), process_response(), processCollectClass(), processFinished(), processInitRequest(), processQueryResponse(), and processQueryTargets().
static int error_response_cache | ( | struct module_qstate * | qstate, | |
int | id, | |||
int | rcode | |||
) | [static] |
Return an error to the client and cache the error code in the message cache (so per qname, qtype, qclass).
qstate,: | our query state | |
id,: | module id | |
rcode,: | error code (DNS errcode). |
References BIT_QR, BIT_RA, module_qstate::env, error_response(), reply_info::flags, FLAGS_SET_RCODE, iter_dns_store(), log_err(), NORR_TTL, reply_info::prefetch_ttl, PREFETCH_TTL_CALC, reply_info::qdcount, module_qstate::qinfo, sec_status_indeterminate, reply_info::security, reply_info::ttl, VERB_ALGO, and verbose().
Referenced by processQueryTargets().
static int iter_add_prepend_answer | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct ub_packed_rrset_key * | rrset | |||
) | [static] |
Add rrset to ANSWER prepend list.
qstate,: | query state. | |
iq,: | iterator query state. | |
rrset,: | rrset to add. |
References iter_qstate::an_prepend_last, iter_qstate::an_prepend_list, iter_prep_list::next, module_qstate::region, regional_alloc(), and iter_prep_list::rrset.
Referenced by handle_cname_response().
static int iter_add_prepend_auth | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct ub_packed_rrset_key * | rrset | |||
) | [static] |
Add rrset to AUTHORITY prepend list.
qstate,: | query state. | |
iq,: | iterator query state. | |
rrset,: | rrset to add. |
References iter_prep_list::next, iter_qstate::ns_prepend_last, iter_qstate::ns_prepend_list, module_qstate::region, regional_alloc(), and iter_prep_list::rrset.
Referenced by handle_cname_response().
static int handle_cname_response | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct dns_msg * | msg, | |||
uint8_t ** | mname, | |||
size_t * | mname_len | |||
) | [static] |
Given a CNAME response (defined as a response containing a CNAME or DNAME that does not answer the request), process the response, modifying the state as necessary.
This follows the CNAME/DNAME chain and returns the final query name.
sets the new query name, after following the CNAME/DNAME chain.
qstate,: | query state. | |
iq,: | iterator query state. | |
msg,: | the response. | |
mname,: | returned target new query name. | |
mname_len,: | length of mname. |
References reply_info::an_numrrsets, packed_rrset_key::dname, dname_strict_subdomain_c(), get_cname_target(), iter_add_prepend_answer(), iter_add_prepend_auth(), reply_info::ns_numrrsets, iter_qstate::qchase, query_info::qname, query_info::qname_len, query_dname_compare(), dns_msg::rep, ub_packed_rrset_key::rk, reply_info::rrsets, and packed_rrset_key::type.
Referenced by processInitRequest(), and processQueryResponse().
static int generate_sub_request | ( | uint8_t * | qname, | |
size_t | qnamelen, | |||
uint16_t | qtype, | |||
uint16_t | qclass, | |||
struct module_qstate * | qstate, | |||
int | id, | |||
struct iter_qstate * | iq, | |||
enum iter_state | initial_state, | |||
enum iter_state | final_state, | |||
struct module_qstate ** | subq_ret, | |||
int | v | |||
) | [static] |
Generate a subrequest.
Generate a local request event. Local events are tied to this module, and have a correponding (first tier) event that is waiting for this event to resolve to continue.
qname | The query name for this request. | |
qnamelen | length of qname | |
qtype | The query type for this request. | |
qclass | The query class for this request. | |
qstate | The event that is generating this event. | |
id,: | module id. | |
iq,: | The iterator state that is generating this event. | |
initial_state | The initial response state (normally this is QUERY_RESP_STATE, unless it is known that the request won't need iterative processing | |
final_state | The final state for the response to this request. | |
subq_ret,: | if newly allocated, the subquerystate, or NULL if it does not need initialisation. | |
v,: | if true, validation is done on the subquery. |
References module_env::attach_sub, BIT_CD, BIT_RD, iter_qstate::chase_flags, module_qstate::curmod, iter_qstate::depth, module_env::detect_cycle, module_qstate::env, module_qstate::ext_state, iter_qstate::final_state, fptr_ok, fptr_whitelist_modenv_attach_sub(), fptr_whitelist_modenv_detect_cycle(), fptr_whitelist_modenv_kill_sub(), INIT_REQUEST_STATE, module_env::kill_sub, log_err(), log_query_info(), module_qstate::minfo, module_state_initial, iter_qstate::num_current_queries, iter_qstate::num_target_queries, outbound_list_init(), iter_qstate::outlist, PRIME_RESP_STATE, iter_qstate::qchase, query_info::qclass, module_qstate::qinfo, query_info::qname, query_info::qname_len, query_info::qtype, module_qstate::query_flags, iter_qstate::refetch_glue, module_qstate::region, regional_alloc(), iter_qstate::state, and VERB_DETAIL.
Referenced by generate_a_aaaa_check(), generate_dnskey_prefetch(), generate_ns_check(), generate_target_query(), prime_root(), prime_stub(), processCollectClass(), and processPrimeResponse().
static int prime_root | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct iter_env * | ie, | |||
int | id, | |||
uint16_t | qclass | |||
) | [static] |
Generate and send a root priming request.
qstate,: | the qtstate that triggered the need to prime. | |
iq,: | iterator query state. | |
ie,: | iterator global state. | |
id,: | module id. | |
qclass,: | the class to prime. |
References delegpt_copy(), iter_qstate::dnssec_expected, iter_qstate::dp, module_qstate::env, module_qstate::ext_state, fptr_ok, fptr_whitelist_modenv_kill_sub(), generate_sub_request(), iter_env::hints, hints_lookup_root(), iter_indicates_dnssec(), module_env::kill_sub, log_err(), module_qstate::minfo, module_wait_subquery, iter_qstate::num_target_queries, PRIME_RESP_STATE, query_info::qclass, module_qstate::qinfo, QUERYTARGETS_STATE, module_qstate::region, VERB_ALGO, VERB_DETAIL, and verbose().
Referenced by processInitRequest().
static int prime_stub | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct iter_env * | ie, | |||
int | id, | |||
struct query_info * | q | |||
) | [static] |
Generate and process a stub priming request.
This method tests for the need to prime a stub zone, so it is safe to call for every request.
qstate,: | the qtstate that triggered the need to prime. | |
iq,: | iterator query state. | |
ie,: | iterator global state. | |
id,: | module id. | |
q,: | request name. |
References delegpt_copy(), dname_is_root(), dname_remove_label(), iter_qstate::dnssec_expected, iter_hints_stub::dp, iter_qstate::dp, module_qstate::env, error_response(), module_qstate::ext_state, fptr_ok, fptr_whitelist_modenv_kill_sub(), generate_sub_request(), iter_env::hints, hints_lookup_stub(), iter_indicates_dnssec(), module_env::kill_sub, log_err(), log_nametypeclass(), module_qstate::minfo, module_wait_subquery, delegpt::name, delegpt::namelen, iter_hints_stub::noprime, iter_qstate::num_target_queries, PRIME_RESP_STATE, query_info::qclass, module_qstate::qinfo, query_info::qname, query_info::qname_len, query_info::qtype, QUERYTARGETS_STATE, module_qstate::region, VERB_ALGO, VERB_DETAIL, verbose(), and iter_qstate::wait_priming_stub.
Referenced by processInitRequest2().
static void generate_a_aaaa_check | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
int | id | |||
) | [static] |
Generate A and AAAA checks for glue that is in-zone for the referral we just got to obtain authoritative information on the adresses.
qstate,: | the qtstate that triggered the need to prime. | |
iq,: | iterator query state. | |
id,: | module id. |
References reply_info::an_numrrsets, BIT_CD, BIT_RD, packed_rrset_key::dname, packed_rrset_key::dname_len, iter_qstate::dp, FINISHED_STATE, generate_sub_request(), INIT_REQUEST_STATE, log_assert, log_nametypeclass(), reply_info::ns_numrrsets, query_info::qclass, module_qstate::qinfo, query_info::qname, query_info::qtype, query_dname_compare(), module_qstate::query_flags, dns_msg::rep, iter_qstate::response, ub_packed_rrset_key::rk, packed_rrset_key::rrset_class, reply_info::rrsets, packed_rrset_key::type, VERB_ALGO, and verbose().
Referenced by generate_ns_check(), and processPrimeResponse().
static void generate_ns_check | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
int | id | |||
) | [static] |
Generate a NS check request to obtain authoritative information on an NS rrset.
qstate,: | the qtstate that triggered the need to prime. | |
iq,: | iterator query state. | |
id,: | module id. |
References BIT_CD, BIT_RD, delegpt_copy(), iter_qstate::dp, module_qstate::env, FINISHED_STATE, fptr_ok, fptr_whitelist_modenv_kill_sub(), generate_a_aaaa_check(), generate_sub_request(), INIT_REQUEST_STATE, module_env::kill_sub, log_assert, log_err(), log_nametypeclass(), module_qstate::minfo, delegpt::name, delegpt::namelen, iter_qstate::qchase, query_info::qclass, module_qstate::qinfo, query_info::qname, query_info::qtype, query_dname_compare(), module_qstate::query_flags, iter_qstate::refetch_glue, module_qstate::region, VERB_ALGO, and verbose().
Referenced by processQueryResponse().
static void generate_dnskey_prefetch | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
int | id | |||
) | [static] |
Generate a DNSKEY prefetch query to get the DNSKEY for the DS record we just got in a referral (where we have dnssec_expected, thus have trust anchors above it).
Note that right after calling this routine the iterator detached subqueries (because of following the referral), and thus the DNSKEY query becomes detached, its return stored in the cache for later lookup by the validator. This cache lookup by the validator avoids the roundtrip incurred by the DNSKEY query. The DNSKEY query is now performed at about the same time the original query is sent to the domain, thus the two answers are likely to be returned at about the same time, saving a roundtrip from the validated lookup.
qstate,: | the qtstate that triggered the need to prime. | |
iq,: | iterator query state. | |
id,: | module id. |
References BIT_CD, BIT_RD, delegpt_copy(), iter_qstate::dp, FINISHED_STATE, generate_sub_request(), INIT_REQUEST_STATE, log_assert, log_nametypeclass(), module_qstate::minfo, delegpt::name, delegpt::namelen, iter_qstate::qchase, query_info::qclass, module_qstate::qinfo, query_info::qname, query_info::qtype, query_dname_compare(), module_qstate::query_flags, module_qstate::region, VERB_ALGO, and verbose().
Referenced by processInitRequest3(), and processQueryResponse().
static int forward_request | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq | |||
) | [static] |
See if the query needs forwarding.
qstate,: | query state. | |
iq,: | iterator query state. |
References BIT_RD, iter_qstate::chase_flags, delegpt_copy(), dname_is_root(), dname_remove_label(), iter_qstate::dp, module_qstate::env, forwards_lookup(), module_env::fwds, iter_qstate::qchase, query_info::qclass, query_info::qname, query_info::qname_len, query_info::qtype, module_qstate::region, VERB_ALGO, and verbose().
Referenced by processInitRequest().
static int processInitRequest | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct iter_env * | ie, | |||
int | id | |||
) | [static] |
Process the initial part of the request handling.
This state roughly corresponds to resolver algorithms steps 1 (find answer in cache) and 2 (find the best servers to ask).
Note that all requests start here, and query restarts revisit this state.
This state either generates: 1) a response, from cache or error, 2) a priming event, or 3) forwards the request to the next state (init2, generally).
qstate,: | query state. | |
iq,: | iterator query state. | |
ie,: | iterator shared global environment. | |
id,: | module id. |
References module_qstate::blacklist, COLLECT_CLASS_STATE, iter_qstate::deleg_msg, delegpt_copy(), delegpt_log(), iter_qstate::depth, dname_is_root(), dname_remove_label(), dns_cache_find_delegation(), dns_cache_lookup(), iter_qstate::dp, module_qstate::env, error_response(), final_state(), forward_request(), forwards_lookup_root(), module_env::fwds, handle_cname_response(), iter_env::hints, hints_lookup_root(), INIT_REQUEST_2_STATE, INIT_REQUEST_STATE, iter_dp_is_useless(), log_dns_msg(), log_err(), log_query_info(), iter_env::max_dependency_depth, MAX_RESTART_COUNT, delegpt::name, delegpt::namelen, module_env::neg_cache, next_state(), module_env::now, reply_info::prefetch_ttl, prime_root(), iter_qstate::qchase, query_info::qclass, dns_msg::qinfo, module_qstate::qinfo, query_info::qname, query_info::qname_len, query_info::qtype, module_qstate::query_flags, iter_qstate::query_restart_count, QUERYTARGETS_STATE, iter_qstate::refetch_glue, module_qstate::region, dns_msg::rep, module_qstate::reply_origin, iter_qstate::response, RESPONSE_TYPE_CNAME, response_type_from_cache(), module_env::rrset_cache, module_env::scratch, module_env::scratch_buffer, sock_list_insert(), reply_info::ttl, val_neg_getmsg(), VERB_ALGO, VERB_DETAIL, VERB_QUERY, verbose(), and verbosity.
Referenced by iter_handle().
static int processInitRequest2 | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct iter_env * | ie, | |||
int | id | |||
) | [static] |
Process the second part of the initial request handling.
This state basically exists so that queries that generate root priming events have the same init processing as ones that do not. Request events that reach this state must have a valid currentDelegationPoint set.
This part is primarly handling stub zone priming. Events that reach this state must have a current delegation point.
qstate,: | query state. | |
iq,: | iterator query state. | |
ie,: | iterator shared global environment. | |
id,: | module id. |
References INIT_REQUEST_3_STATE, log_query_info(), next_state(), prime_stub(), iter_qstate::qchase, module_qstate::qinfo, and VERB_QUERY.
Referenced by iter_handle().
static int processInitRequest3 | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
int | id | |||
) | [static] |
Process the third part of the initial request handling.
This state exists as a separate state so that queries that generate stub priming events will get the tail end of the init process but not repeat the stub priming check.
qstate,: | query state. | |
iq,: | iterator query state. | |
id,: | module id. |
References BIT_CD, BIT_RD, module_env::cfg, iter_qstate::chase_flags, iter_qstate::deleg_msg, module_env::detach_subs, iter_qstate::dnssec_expected, iter_qstate::dp, module_qstate::env, final_state(), fptr_ok, fptr_whitelist_modenv_detach_subs(), generate_dnskey_prefetch(), iter_indicates_dnssec(), log_dns_msg(), log_query_info(), next_state(), config_file::prefetch_key, iter_qstate::qchase, query_info::qclass, dns_msg::qinfo, module_qstate::qinfo, module_qstate::query_flags, QUERYTARGETS_STATE, module_qstate::region, dns_msg::rep, module_qstate::reply_origin, iter_qstate::response, sock_list_insert(), VERB_ALGO, VERB_QUERY, and verbosity.
Referenced by iter_handle().
static int generate_target_query | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
int | id, | |||
uint8_t * | name, | |||
size_t | namelen, | |||
uint16_t | qtype, | |||
uint16_t | qclass | |||
) | [static] |
Given a basic query, generate a "target" query.
These are subordinate queries for missing delegation point target addresses.
qstate,: | query state. | |
iq,: | iterator query state. | |
id,: | module id. | |
name,: | target qname. | |
namelen,: | target qname length. | |
qtype,: | target qtype (either A or AAAA). | |
qclass,: | target qclass. |
References delegpt_copy(), dname_subdomain_c(), iter_qstate::dnssec_expected, iter_qstate::dp, module_qstate::env, FINISHED_STATE, generate_sub_request(), INIT_REQUEST_STATE, iter_indicates_dnssec(), log_nametypeclass(), module_qstate::minfo, delegpt::name, query_info::qclass, module_qstate::qinfo, iter_qstate::refetch_glue, module_qstate::region, VERB_ALGO, VERB_QUERY, and verbose().
Referenced by query_for_targets().
static int query_for_targets | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct iter_env * | ie, | |||
int | id, | |||
int | maxtargets, | |||
int * | num | |||
) | [static] |
Given an event at a certain state, generate zero or more target queries for it's current delegation point.
qstate,: | query state. | |
iq,: | iterator query state. | |
ie,: | iterator shared global environment. | |
id,: | module id. | |
maxtargets,: | The maximum number of targets to query for. if it is negative, there is no maximum number of targets. | |
num,: | returns the number of queries generated and processed, which may be zero if there were no missing targets. |
References delegpt_count_missing_targets(), iter_qstate::dp, module_qstate::env, module_qstate::ext_state, generate_target_query(), delegpt_ns::got4, delegpt_ns::got6, iter_mark_cycle_targets(), iter_ns_probability(), log_assert, module_wait_subquery, delegpt_ns::name, delegpt_ns::namelen, delegpt_ns::next, delegpt::nslist, iter_qstate::qchase, query_info::qclass, delegpt_ns::resolved, module_env::rnd, and iter_env::supports_ipv6.
Referenced by processQueryTargets().
static int processQueryTargets | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct iter_env * | ie, | |||
int | id | |||
) | [static] |
This is the request event state where the request will be sent to one of its current query targets.
This state also handles issuing target lookup queries for missing target IP addresses. Queries typically iterate on this state, both when they are just trying different targets for a given delegation point, and when they change delegation points. This state roughly corresponds to RFC 1034 algorithm steps 3 and 4.
qstate,: | query state. | |
iq,: | iterator query state. | |
ie,: | iterator shared global environment. | |
id,: | module id. |
References delegpt_addr::addr, delegpt_addr::addrlen, BIT_CD, BIT_RD, module_qstate::blacklist, iter_qstate::caps_fallback, iter_qstate::caps_server, iter_qstate::chase_flags, iter_qstate::chase_to_rd, iter_qstate::deleg_msg, delegpt_add_unused_targets(), delegpt_count_addr(), delegpt_count_missing_targets(), delegpt_log(), delegpt_no_ipv6(), iter_qstate::depth, iter_qstate::dnssec_expected, iter_qstate::dp, EDNS_DO, module_qstate::env, error_response(), error_response_cache(), module_qstate::ext_state, fptr_ok, fptr_whitelist_modenv_send_query(), INIT_REQUEST_STATE, iter_server_selection(), iter_suspect_exists(), log_addr(), log_name_addr(), log_query_info(), iter_env::max_dependency_depth, MAX_REFERRAL_COUNT, module_wait_reply, delegpt::name, delegpt::namelen, next_state(), iter_qstate::num_current_queries, iter_qstate::num_target_queries, outbound_list_insert(), iter_qstate::outlist, iter_qstate::qchase, query_info::qclass, module_qstate::qinfo, query_info::qname, query_info::qname_len, query_info::qtype, query_for_targets(), QUERY_RESP_STATE, iter_qstate::query_restart_count, QUERYTARGETS_STATE, iter_qstate::referral_count, iter_qstate::refetch_glue, module_env::send_query, iter_qstate::state, iter_env::supports_ipv6, iter_env::target_fetch_policy, VERB_ALGO, VERB_DETAIL, VERB_QUERY, and verbose().
Referenced by iter_handle().
static int processQueryResponse | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
int | id | |||
) | [static] |
Process the query response.
All queries end up at this state first. This process generally consists of analyzing the response and routing the event to the next state (either bouncing it back to a request state, or terminating the processing for this event).
qstate,: | query state. | |
iq,: | iterator query state. | |
id,: | module id. |
References comm_reply::addr, comm_reply::addrlen, reply_info::an_numrrsets, BIT_CD, BIT_RD, cache_fill_missing(), module_env::cfg, iter_qstate::chase_flags, iter_qstate::chase_to_rd, iter_qstate::deleg_msg, delegpt_from_message(), delegpt_log(), module_env::detach_subs, packed_rrset_key::dname, dname_strict_subdomain_c(), dname_subdomain_c(), iter_qstate::dnssec_expected, iter_qstate::dp, module_qstate::env, error_response(), final_state(), find_NS(), reply_info::flags, FLAGS_GET_RCODE, fptr_ok, fptr_whitelist_modenv_detach_subs(), generate_dnskey_prefetch(), generate_ns_check(), handle_cname_response(), config_file::harden_referral_path, module_env::infra_cache, infra_set_lame(), INIT_REQUEST_STATE, iter_dns_store(), iter_indicates_dnssec(), iter_msg_from_zone(), iter_msg_has_dnssec(), iter_scrub_ds(), iter_store_inzone_glue(), log_dns_msg(), log_err(), log_warn(), delegpt::name, delegpt::namelen, module_env::neg_cache, next_state(), module_env::now, reply_info::ns_numrrsets, iter_qstate::num_current_queries, iter_qstate::num_target_queries, outbound_list_clear(), iter_qstate::outlist, config_file::prefetch_key, module_qstate::prefetch_leeway, iter_qstate::qchase, query_info::qclass, module_qstate::qinfo, dns_msg::qinfo, query_info::qname, query_info::qname_len, query_info::qtype, module_qstate::query_flags, iter_qstate::query_restart_count, QUERYTARGETS_STATE, iter_qstate::referral_count, module_qstate::region, dns_msg::rep, module_qstate::reply, reply_find_rrset_section_an(), reply_find_rrset_section_ns(), module_qstate::reply_origin, iter_qstate::response, RESPONSE_TYPE_ANSWER, RESPONSE_TYPE_CNAME, response_type_from_server(), RESPONSE_TYPE_LAME, RESPONSE_TYPE_REC_LAME, RESPONSE_TYPE_REFERRAL, RESPONSE_TYPE_THROWAWAY, RESPONSE_TYPE_UNTYPED, ub_packed_rrset_key::rk, sock_list_insert(), val_neg_addreferral(), VERB_ALGO, VERB_DETAIL, verbose(), and verbosity.
Referenced by iter_handle().
static void prime_supers | ( | struct module_qstate * | qstate, | |
int | id, | |||
struct module_qstate * | forq | |||
) | [static] |
Return priming query results to interestes super querystates.
Sets the delegation point and delegation message (not nonRD queries). This is a callback from walk_supers.
qstate,: | priming query state that finished. | |
id,: | module id. | |
forq,: | the qstate for which priming has been done. |
References iter_qstate::deleg_msg, delegpt_from_message(), delegpt_log(), dns_copy_msg(), iter_qstate::dp, INIT_REQUEST_2_STATE, INIT_REQUEST_3_STATE, module_qstate::is_priming, log_assert, log_err(), log_query_info(), module_qstate::minfo, module_qstate::qinfo, QUERYTARGETS_STATE, module_qstate::region, module_qstate::return_msg, module_qstate::return_rcode, iter_qstate::state, VERB_ALGO, VERB_DETAIL, verbose(), and iter_qstate::wait_priming_stub.
Referenced by iter_inform_super().
static int processPrimeResponse | ( | struct module_qstate * | qstate, | |
int | id | |||
) | [static] |
This handles the response to a priming query.
This is used to handle both root and stub priming responses. This is basically the equivalent of the QUERY_RESP_STATE, but will not handle CNAME responses and will treat REFERRALs as ANSWERS. It will also update and reactivate the originating event.
qstate,: | query state. | |
id,: | module id. |
References module_env::cfg, iter_qstate::dp, module_qstate::env, module_qstate::ext_state, FINISHED_STATE, generate_a_aaaa_check(), generate_sub_request(), config_file::harden_referral_path, INIT_REQUEST_STATE, log_nametypeclass(), module_qstate::minfo, module_finished, iter_qstate::qchase, query_info::qclass, module_qstate::qinfo, query_info::qname, query_info::qname_len, query_info::qtype, iter_qstate::response, RESPONSE_TYPE_ANSWER, response_type_from_server(), module_qstate::return_msg, module_qstate::return_rcode, VERB_ALGO, and verbose().
Referenced by iter_handle().
static void processTargetResponse | ( | struct module_qstate * | qstate, | |
int | id, | |||
struct module_qstate * | forq | |||
) | [static] |
Do final processing on responses to target queries.
Events reach this state after the iterative resolution algorithm terminates. This state is responsible for reactiving the original event, and housekeeping related to received target responses (caching, updating the current delegation point, etc). Callback from walk_supers for every super state that is interested in the results from this query.
qstate,: | query state. | |
id,: | module id. | |
forq,: | super query state. |
References delegpt_add_ns(), delegpt_add_rrset(), delegpt_find_ns(), delegpt_log(), packed_rrset_key::dname, packed_rrset_key::dname_len, module_qstate::env, iter_lookup_inzone_glue(), log_assert, log_err(), log_query_info(), module_qstate::minfo, iter_qstate::qchase, module_qstate::qinfo, query_info::qname, query_info::qname_len, QUERYTARGETS_STATE, module_qstate::region, dns_msg::rep, reply_find_answer_rrset(), delegpt_ns::resolved, module_qstate::return_msg, module_qstate::return_rcode, ub_packed_rrset_key::rk, VERB_ALGO, and verbose().
Referenced by iter_inform_super().
static void processClassResponse | ( | struct module_qstate * | qstate, | |
int | id, | |||
struct module_qstate * | forq | |||
) | [static] |
Process response for qclass=ANY queries for a particular class.
Append to result or error-exit.
qstate,: | query state. | |
id,: | module id. | |
forq,: | super query state. |
References reply_info::an_numrrsets, reply_info::ar_numrrsets, reply_info::authoritative, dns_copy_msg(), FINISHED_STATE, reply_info::flags, log_err(), log_query_info(), module_qstate::minfo, reply_info::ns_numrrsets, iter_qstate::num_current_queries, reply_info::prefetch_ttl, query_info::qclass, reply_info::qdcount, dns_msg::qinfo, module_qstate::qinfo, module_qstate::region, regional_alloc(), dns_msg::rep, iter_qstate::response, module_qstate::return_msg, module_qstate::return_rcode, reply_info::rrset_count, reply_info::rrsets, reply_info::security, iter_qstate::state, reply_info::ttl, and VERB_ALGO.
Referenced by iter_inform_super().
static int processCollectClass | ( | struct module_qstate * | qstate, | |
int | id | |||
) | [static] |
Collect class ANY responses and make them into one response.
This state is started and it creates queries for all classes (that have root hints). The answers are then collected.
qstate,: | query state. | |
id,: | module id. |
References BIT_CD, module_qstate::env, error_response(), FINISHED_STATE, module_env::fwds, generate_sub_request(), INIT_REQUEST_STATE, iter_get_next_root(), log_nametypeclass(), module_qstate::minfo, module_env::modinfo, iter_qstate::num_current_queries, iter_qstate::qchase, query_info::qclass, module_qstate::qinfo, query_info::qname, query_info::qname_len, query_info::qtype, module_qstate::query_flags, VERB_ALGO, and verbose().
Referenced by iter_handle().
static int processFinished | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
int | id | |||
) | [static] |
This handles the final state for first-tier responses (i.e., responses to externally generated queries).
qstate,: | query state. | |
iq,: | iterator query state. | |
id,: | module id. |
References iter_qstate::an_prepend_list, BIT_AA, BIT_QR, BIT_RA, BIT_RD, module_qstate::env, error_response(), module_qstate::ext_state, reply_info::flags, iter_dns_store(), iter_prepend(), log_err(), log_query_info(), module_finished, iter_qstate::ns_prepend_list, module_qstate::prefetch_leeway, dns_msg::qinfo, module_qstate::qinfo, module_qstate::query_flags, module_qstate::region, dns_msg::rep, iter_qstate::response, module_qstate::return_msg, module_qstate::return_rcode, VERB_ALGO, VERB_QUERY, and verbose().
Referenced by iter_handle().
void iter_inform_super | ( | struct module_qstate * | qstate, | |
int | id, | |||
struct module_qstate * | super | |||
) |
Return priming query results to interestes super querystates.
Sets the delegation point and delegation message (not nonRD queries). This is a callback from walk_supers.
qstate,: | query state that finished. | |
id,: | module id. | |
super,: | the qstate to inform. |
References error_supers(), module_qstate::is_priming, prime_supers(), processClassResponse(), processTargetResponse(), query_info::qclass, module_qstate::qinfo, and module_qstate::return_rcode.
Referenced by fptr_whitelist_mod_inform_super().
static void iter_handle | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct iter_env * | ie, | |||
int | id | |||
) | [static] |
Handle iterator state.
Handle events. This is the real processing loop for events, responsible for moving events through the various states. If a processing method returns true, then it will be advanced to the next state. If false, then processing will stop.
qstate,: | query state. | |
ie,: | iterator shared global environment. | |
iq,: | iterator query state. | |
id,: | module id. |
References COLLECT_CLASS_STATE, FINISHED_STATE, INIT_REQUEST_2_STATE, INIT_REQUEST_3_STATE, INIT_REQUEST_STATE, iter_state_to_string(), log_warn(), PRIME_RESP_STATE, processCollectClass(), processFinished(), processInitRequest(), processInitRequest2(), processInitRequest3(), processPrimeResponse(), processQueryResponse(), processQueryTargets(), QUERY_RESP_STATE, QUERYTARGETS_STATE, iter_qstate::state, VERB_ALGO, and verbose().
Referenced by iter_operate(), process_request(), and process_response().
static void process_request | ( | struct module_qstate * | qstate, | |
struct iter_qstate * | iq, | |||
struct iter_env * | ie, | |||
int | id | |||
) | [static] |
This is the primary entry point for processing request events.
Note that this method should only be used by external modules.
qstate,: | query state. | |
ie,: | iterator shared global environment. | |
iq,: | iterator query state. | |
id,: | module id. |
References iter_qstate::final_state, FINISHED_STATE, INIT_REQUEST_STATE, iter_handle(), iter_qstate::state, VERB_ALGO, and verbose().
Referenced by iter_operate().
struct module_func_block* iter_get_funcblock | ( | ) | [read] |
Get the iterator function block.
Referenced by checkconf(), and module_funcs_avail().
const char* iter_state_to_string | ( | enum iter_state | state | ) |
Get iterator state as a string.
state,: | to convert |
References COLLECT_CLASS_STATE, FINISHED_STATE, INIT_REQUEST_2_STATE, INIT_REQUEST_3_STATE, INIT_REQUEST_STATE, PRIME_RESP_STATE, QUERY_RESP_STATE, and QUERYTARGETS_STATE.
Referenced by iter_handle().
int iter_state_is_responsestate | ( | enum iter_state | s | ) |
See if iterator state is a response state.
s,: | to inspect |
References COLLECT_CLASS_STATE, INIT_REQUEST_2_STATE, INIT_REQUEST_3_STATE, INIT_REQUEST_STATE, and QUERYTARGETS_STATE.
Referenced by next_state().
struct module_func_block iter_block [static] |
{ "iterator", &iter_init, &iter_deinit, &iter_operate, &iter_inform_super, &iter_clear, &iter_get_mem }
The iterator function block.