unbound: iterator/iter_utils.h File Reference

unbound 0.1

Macros | Functions
iter_utils.h File Reference

This file contains functions to assist the iterator module. More...

`#include "iterator/iter_resptype.h"`

## Macros
#define | ITERATOR_NAME_CACHELOOKUP_MAX 3
#define | ITERATOR_NAME_CACHELOOKUP_MAX_PSIDE 5

## Functions
int | iter_apply_cfg (struct iter_env *iter_env, struct config_file *cfg)
| Process config options and set iterator module state.
struct delegpt_addr * | iter_server_selection (struct iter_env *iter_env, struct module_env *env, struct delegpt *dp, uint8_t *name, size_t namelen, uint16_t qtype, int *dnssec_lame, int *chase_to_rd, int open_target, struct sock_list *blacklist, time_t prefetch)
| Select a valid, nice target to send query to.
struct dns_msg * | dns_alloc_msg (struct sldns_buffer *pkt, struct msg_parse *msg, struct regional *regional)
| Allocate dns_msg from parsed msg, in regional.
struct dns_msg * | dns_copy_msg (struct dns_msg *from, struct regional *regional)
| Copy a dns_msg to this regional.
void | iter_dns_store (struct module_env *env, struct query_info *qinf, struct reply_info *rep, int is_referral, time_t leeway, int pside, struct regional *region, uint16_t flags, time_t qstarttime, int is_valrec)
| Allocate a dns_msg with malloc/alloc structure and store in dns cache.
int | iter_ns_probability (struct ub_randstate *rnd, int n, int m)
| Select randomly with n/m probability.
void | iter_mark_cycle_targets (struct module_qstate *qstate, struct delegpt *dp)
| Mark targets that result in a dependency cycle as done, so they will not get selected as targets.
void | iter_mark_pside_cycle_targets (struct module_qstate *qstate, struct delegpt *dp)
| Mark targets that result in a dependency cycle as done, so they will not get selected as targets.
int | iter_dp_is_useless (struct query_info *qinfo, uint16_t qflags, struct delegpt *dp, int supports_ipv4, int supports_ipv6, int use_nat64)
| See if delegation is useful or offers immediately no targets for further recursion.
int | iter_qname_indicates_dnssec (struct module_env *env, struct query_info *qinfo)
| See if qname has DNSSEC needs.
int | iter_indicates_dnssec (struct module_env *env, struct delegpt *dp, struct dns_msg *msg, uint16_t dclass)
| See if delegation is expected to have DNSSEC information (RRSIGs) in its answers, or not.
int | iter_msg_has_dnssec (struct dns_msg *msg)
| See if a message contains DNSSEC.
int | iter_msg_from_zone (struct dns_msg *msg, struct delegpt *dp, enum response_type type, uint16_t dclass)
| See if a message is known to be from a certain zone.
int | reply_equal (struct reply_info *p, struct reply_info *q, struct regional *region)
| Check if two replies are equal For fallback procedures.
void | caps_strip_reply (struct reply_info *rep)
| Remove unused bits from the reply if possible.
int | caps_failed_rcode (struct reply_info *rep)
| see if reply has a 'useful' rcode for capsforid comparison, so not SERVFAIL or REFUSED, and thus NOERROR or NXDOMAIN.
void | iter_store_parentside_rrset (struct module_env *env, struct ub_packed_rrset_key *rrset)
| Store parent-side rrset in separate rrset cache entries for later last-resort * lookups in case the child-side versions of this information fails.
void | iter_store_parentside_NS (struct module_env *env, struct reply_info *rep)
| Store parent-side NS records from a referral message.
void | iter_store_parentside_neg (struct module_env *env, struct query_info *qinfo, struct reply_info *rep)
| Store parent-side negative element, the parentside rrset does not exist, creates an rrset with empty rdata in the rrset cache with PARENTSIDE flag.
int | iter_lookup_parent_NS_from_cache (struct module_env *env, struct delegpt *dp, struct regional *region, struct query_info *qinfo)
| Add parent NS record if that exists in the cache.
int | iter_lookup_parent_glue_from_cache (struct module_env *env, struct delegpt *dp, struct regional *region, struct query_info *qinfo)
| Add parent-side glue if that exists in the cache.
int | iter_get_next_root (struct iter_hints *hints, struct iter_forwards *fwd, uint16_t *c)
| Lookup next root-hint or root-forward entry.
void | iter_scrub_ds (struct dns_msg *msg, struct ub_packed_rrset_key *ns, uint8_t *z)
| Remove DS records that are inappropriate before they are cached.
void | iter_scrub_nxdomain (struct dns_msg *msg)
| Prepare an NXDOMAIN message to be used for a subdomain answer by removing all RRs from the ANSWER section.
void | iter_dec_attempts (struct delegpt *dp, int d, int outbound_msg_retry)
| Remove query attempts from all available ips.
void | iter_merge_retry_counts (struct delegpt *dp, struct delegpt *old, int outbound_msg_retry)
| Add retry counts from older delegpt to newer delegpt.
int | iter_ds_toolow (struct dns_msg *msg, struct delegpt *dp)
| See if a DS response (type ANSWER) is too low: a nodata answer with a SOA record in the authority section at-or-below the qchase.qname.
int | iter_dp_cangodown (struct query_info *qinfo, struct delegpt *dp)
| See if delegpt can go down a step to the qname or not.
int | iter_stub_fwd_no_cache (struct module_qstate *qstate, struct query_info *qinf, uint8_t **retdpname, size_t *retdpnamelen, uint8_t *dpname_storage, size_t dpname_storage_len)
| Lookup if no_cache is set in stub or fwd.
void | iterator_set_ip46_support (struct module_stack *mods, struct module_env *env, struct outside_network *outnet)
| Set support for IP4 and IP6 depending on outgoing interfaces in the outside network.
int | read_fetch_policy (int **target_fetch_policy, int *max_dependency_depth, const char *str)
| Read config string that represents the target fetch policy.
struct rbtree_type * | caps_white_create (void)
| Create caps exempt data structure.
void | caps_white_delete (struct rbtree_type *caps_white)
| Delete caps exempt data structure.
int | caps_white_apply_cfg (struct rbtree_type *ntree, struct config_file *cfg)
| Apply config caps whitelist items to name tree.
int | nat64_apply_cfg (struct iter_nat64 *nat64, struct config_file *cfg)
| Apply config for nat64.
void | limit_nsec_ttl (struct dns_msg *msg)
| Limit NSEC and NSEC3 TTL in response, RFC9077.
void | iter_make_minimal (struct reply_info *rep)
| Make the response minimal.

## Detailed Description

This file contains functions to assist the iterator module.

Configuration options. Forward zones.

## Function Documentation

## ◆ iter_apply_cfg()

int iter_apply_cfg | ( | struct iter_env * | iter_env,
|  | struct config_file * | cfg )

Process config options and set iterator module state.

Sets default values if no config is found.

Parameters

  iter_env | iterator module state.
  cfg | config options.

Returns
  0 on error.

References iter_env::caps_white, caps_white_apply_cfg(), caps_white_create(), config_file::caps_whitelist, config_file::do_ip4, config_file::do_ip6, iter_env::donotq, donotq_apply_cfg(), donotq_create(), log_err(), iter_env::max_dependency_depth, config_file::max_query_restarts, iter_env::max_query_restarts, config_file::max_sent_count, iter_env::max_sent_count, iter_env::nat64, nat64_apply_cfg(), config_file::outbound_msg_retry, iter_env::outbound_msg_retry, iter_env::priv, priv_apply_cfg(), priv_create(), read_fetch_policy(), iter_env::supports_ipv4, iter_env::supports_ipv6, config_file::target_fetch_policy, iter_env::target_fetch_policy, VERB_QUERY, and verbose().

Referenced by iter_init().

## ◆ iter_server_selection()

struct delegpt_addr * iter_server_selection | ( | struct iter_env * | iter_env,
|  | struct module_env * | env,
|  | struct delegpt * | dp,
|  | uint8_t * | name,
|  | size_t | namelen,
|  | uint16_t | qtype,
|  | int * | dnssec_lame,
|  | int * | chase_to_rd,
|  | int | open_target,
|  | struct sock_list * | blacklist,
|  | time_t | prefetch )

Select a valid, nice target to send query to.

Sorting and removing unsuitable targets is combined. Adds records to the infra cache if not already there.

Parameters

  iter_env | iterator module global state, with ip6 enabled and do-not-query-addresses.
  env | environment with infra cache (lameness, rtt info).
  dp | delegation point with result list.
  name | zone name (for lameness check).
  namelen | length of name.
  qtype | query type that we want to send.
  dnssec_lame | set to 1, if a known dnssec-lame server is selected these are not preferred, but are used as a last resort.
  chase_to_rd | set to 1 if a known recursion lame server is selected these are not preferred, but are used as a last resort.
  open_target | number of currently outstanding target queries. If we wait for these, perhaps more server addresses become available.
  blacklist | the IP blacklist to use.
  prefetch | if not 0, prefetch is in use for this query. This means the query can have different timing, because prefetch is not waited upon by the downstream client, and thus a good time to perform exploration of other targets.

Returns
  best target or NULL if no target. if not null, that target is removed from the result list in the dp.

References delegpt_addr::attempts, BLACKLIST_PENALTY, iter_filter_order(), log_assert, delegpt_addr::next_result, module_env::now, iter_env::outbound_msg_retry, delegpt::result_list, module_env::rnd, ub_random_max(), USEFUL_SERVER_TOP_TIMEOUT, VERB_ALGO, and verbose().

Referenced by processQueryTargets().

## ◆ dns_alloc_msg()

struct dns_msg * dns_alloc_msg | ( | struct sldns_buffer * | pkt,
|  | struct msg_parse * | msg,
|  | struct regional * | regional )

Allocate dns_msg from parsed msg, in regional.

Parameters

  pkt | packet.
  msg | parsed message (cleaned and ready for regional allocation).
  regional | regional to use for allocation.

Returns
  newly allocated dns_msg, or NULL on memory error.

References log_err(), parse_create_msg(), dns_msg::qinfo, regional_alloc(), and dns_msg::rep.

Referenced by process_response().

## ◆ dns_copy_msg()

struct dns_msg * dns_copy_msg | ( | struct dns_msg * | from,
|  | struct regional * | regional )

Copy a dns_msg to this regional.

Parameters

  from | dns message, also in regional.
  regional | regional to use for allocation.

Returns
  newly allocated dns_msg, or NULL on memory error.

References dns_msg::qinfo, query_info::qname, query_info::qname_len, regional_alloc(), regional_alloc_init(), dns_msg::rep, and reply_info_copy().

Referenced by prime_supers(), and processClassResponse().

## ◆ iter_dns_store()

void iter_dns_store | ( | struct module_env * | env,
|  | struct query_info * | qinf,
|  | struct reply_info * | rep,
|  | int | is_referral,
|  | time_t | leeway,
|  | int | pside,
|  | struct regional * | region,
|  | uint16_t | flags,
|  | time_t | qstarttime,
|  | int | is_valrec )

Allocate a dns_msg with malloc/alloc structure and store in dns cache.

Parameters

  env | environment, with alloc structure and dns cache.
  qinf | query info, the query for which answer is stored.
  rep | reply in dns_msg from dns_alloc_msg for example.
  is_referral | If true, then the given message to be stored is a referral. The cache implementation may use this as a hint.
  leeway | prefetch TTL leeway to expire old rrsets quicker.
  pside | true if dp is parentside, thus message is 'fresh' and NS can be prefetch-updates.
  region | to copy modified (cache is better) rrs back to.
  flags | with BIT_CD for dns64 AAAA translated queries.
  qstarttime | time of query start.
  is_valrec | if the query is validation recursion and does not get return void, because we are not interested in alloc errors, the iterator and validator can operate on the results in their scratch space (the qstate.region) and are not dependent on the cache. It is useful to log the alloc failure (for the server operator), but the query resolution can continue without cache storage.

References dns_cache_store(), and log_err().

Referenced by error_response_cache(), processFinished(), and processQueryResponse().

## ◆ iter_ns_probability()

int iter_ns_probability | ( | struct ub_randstate * | rnd,
|  | int | n,
|  | int | m )

Select randomly with n/m probability.

For shuffle NS records for address fetching.

Parameters

  rnd | random table
  n | probability.
  m | divisor for probability.

Returns
  true with n/m probability.

References ub_random_max().

Referenced by query_for_targets().

## ◆ iter_mark_cycle_targets()

void iter_mark_cycle_targets | ( | struct module_qstate * | qstate,
|  | struct delegpt * | dp )

Mark targets that result in a dependency cycle as done, so they will not get selected as targets.

Parameters

  qstate | query state.
  dp | delegpt to mark ns in.

References causes_cycle(), LDNS_RR_TYPE_A, LDNS_RR_TYPE_AAAA, log_nametypeclass(), delegpt_ns::name, delegpt_ns::namelen, delegpt_ns::next, delegpt::nslist, query_info::qclass, module_qstate::qinfo, delegpt_ns::resolved, and VERB_QUERY.

Referenced by query_for_targets().

## ◆ iter_mark_pside_cycle_targets()

void iter_mark_pside_cycle_targets | ( | struct module_qstate * | qstate,
|  | struct delegpt * | dp )

Mark targets that result in a dependency cycle as done, so they will not get selected as targets.

For the parent-side lookups.

Parameters

  qstate | query state.
  dp | delegpt to mark ns in.

References causes_cycle(), delegpt_ns::done_pside4, delegpt_ns::done_pside6, LDNS_RR_TYPE_A, LDNS_RR_TYPE_AAAA, log_nametypeclass(), delegpt_ns::name, delegpt_ns::namelen, delegpt_ns::next, delegpt::nslist, query_info::qclass, module_qstate::qinfo, and VERB_QUERY.

Referenced by processLastResort().

## ◆ iter_dp_is_useless()

int iter_dp_is_useless | ( | struct query_info * | qinfo,
|  | uint16_t | qflags,
|  | struct delegpt * | dp,
|  | int | supports_ipv4,
|  | int | supports_ipv6,
|  | int | use_nat64 )

See if delegation is useful or offers immediately no targets for further recursion.

Parameters

  qinfo | query name and type
  qflags | query flags with RD flag
  dp | delegpt to check.
  supports_ipv4 | if we support ipv4 for lookups to the target. if not, then the IPv4 addresses are useless.
  supports_ipv6 | if we support ipv6 for lookups to the target. if not, then the IPv6 addresses are useless.
  use_nat64 | if we support NAT64 for lookups to the target. if yes, IPv4 addresses are useful even if we don't support IPv4.

Returns
  true if dp is useless.

References delegpt_addr::addr, addr_is_ip6(), delegpt_addr::addrlen, BIT_RD, delegpt_find_ns(), dname_subdomain_c(), LDNS_RR_TYPE_A, LDNS_RR_TYPE_AAAA, delegpt::name, delegpt_ns::name, delegpt_ns::next, delegpt_addr::next_result, delegpt_addr::next_usable, delegpt::nslist, query_info::qname, query_info::qname_len, query_info::qtype, delegpt_ns::resolved, delegpt::result_list, and delegpt::usable_list.

Referenced by processInitRequest().

## ◆ iter_qname_indicates_dnssec()

int iter_qname_indicates_dnssec | ( | struct module_env * | env,
|  | struct query_info * | qinfo )

See if qname has DNSSEC needs.

This is true if there is a trust anchor above it. Whether there is an insecure delegation to the data is unknown.

Parameters

  env | environment with anchors.
  qinfo | query name and class.

Returns
  true if trust anchor above qname, false if no anchor or insecure point above qname.

References module_env::anchors, anchors_lookup(), trust_anchor::lock, trust_anchor::numDNSKEY, trust_anchor::numDS, query_info::qclass, query_info::qname, and query_info::qname_len.

Referenced by processInitRequest(), and processQueryTargets().

## ◆ iter_indicates_dnssec()

int iter_indicates_dnssec | ( | struct module_env * | env,
|  | struct delegpt * | dp,
|  | struct dns_msg * | msg,
|  | uint16_t | dclass )

See if delegation is expected to have DNSSEC information (RRSIGs) in its answers, or not.

Inspects delegation point (name), trust anchors, and delegation message (DS RRset) to determine this.

Parameters

  env | module env with trust anchors.
  dp | delegation point.
  msg | delegation message, with DS if a secure referral.
  dclass | class of query.

Returns
  1 if dnssec is expected, 0 if not or insecure point above qname.

References anchor_find(), module_env::anchors, trust_anchor::dclass, module_env::key_cache, key_cache_obtain(), key_entry_isbad(), key_entry_isgood(), key_entry_isnull(), LDNS_RR_TYPE_DS, trust_anchor::lock, delegpt::name, key_entry_key::name, delegpt::namelabs, delegpt::namelen, module_env::now, trust_anchor::numDNSKEY, trust_anchor::numDS, query_dname_compare(), regional_free_all(), dns_msg::rep, reply_find_rrset_section_ns(), and module_env::scratch.

Referenced by generate_parentside_target_query(), prime_root(), prime_stub(), processInitRequest3(), and processQueryResponse().

## ◆ iter_msg_has_dnssec()

int iter_msg_has_dnssec | ( | struct dns_msg * | msg | ) |

See if a message contains DNSSEC.

This is examined by looking for RRSIGs. With DNSSEC a valid answer, nxdomain, nodata, referral or cname reply has RRSIGs in answer or auth sections, sigs on answer data, SOA, DS, or NSEC/NSEC3 records.

Parameters

  msg | message to examine.

Returns
  true if DNSSEC information was found.

References reply_info::an_numrrsets, reply_info::ns_numrrsets, dns_msg::rep, and reply_info::rrsets.

Referenced by processQueryResponse().

## ◆ iter_msg_from_zone()

int iter_msg_from_zone | ( | struct dns_msg * | msg,
|  | struct delegpt * | dp,
|  | enum response_type | type,
|  | uint16_t | dclass )

See if a message is known to be from a certain zone.

This looks for SOA or NS rrsets, for answers. For referrals, when one label is delegated, the zone is detected. Does not look at signatures.

Parameters

  msg | the message to inspect.
  dp | delegation point with zone name to look for.
  type | type of message.
  dclass | class of query.

Returns
  true if message is certain to be from zone in dp->name. false if not sure (empty msg), or not from the zone.

References reply_info::an_numrrsets, packed_rrset_key::dname, dname_count_labels(), dname_strict_subdomain(), LDNS_RR_TYPE_NS, LDNS_RR_TYPE_SOA, log_assert, delegpt::name, delegpt::namelabs, delegpt::namelen, reply_info::ns_numrrsets, dns_msg::rep, reply_find_rrset_section_an(), reply_find_rrset_section_ns(), RESPONSE_TYPE_ANSWER, RESPONSE_TYPE_CNAME, RESPONSE_TYPE_REFERRAL, ub_packed_rrset_key::rk, packed_rrset_key::rrset_class, reply_info::rrsets, and packed_rrset_key::type.

Referenced by processQueryResponse().

## ◆ reply_equal()

int reply_equal | ( | struct reply_info * | p,
|  | struct reply_info * | q,
|  | struct regional * | region )

Check if two replies are equal For fallback procedures.

Parameters

  p | reply one. The reply has rrset data pointers in region. Does not check rrset-IDs
  q | reply two
  region | scratch buffer.

Returns
  if one and two are equal.

References reply_info::an_numrrsets, reply_info::ar_numrrsets, reply_info::flags, log_assert, reply_info::ns_numrrsets, reply_info::qdcount, regional_alloc_init(), regional_free_all(), rrset_canonical_equal(), rrset_canonical_sort_cmp(), reply_info::rrset_count, rrset_equal(), reply_info::rrsets, and reply_info::security.

Referenced by process_response().

## ◆ caps_strip_reply()

void caps_strip_reply | ( | struct reply_info * | rep | ) |

Remove unused bits from the reply if possible.

So that caps-for-id (0x20) fallback is more likely to be successful. This removes like, the additional section, and NS record in the authority section if those records are gratuitous (not for a referral).

Parameters

  rep | the reply to strip stuff out of.

References reply_info::an_numrrsets, reply_info::ar_numrrsets, BIT_AA, reply_info::flags, LDNS_RR_TYPE_NS, reply_info::ns_numrrsets, ub_packed_rrset_key::rk, reply_info::rrset_count, reply_info::rrsets, packed_rrset_key::type, VERB_ALGO, and verbose().

Referenced by process_response().

## ◆ caps_failed_rcode()

int caps_failed_rcode | ( | struct reply_info * | rep | ) |

see if reply has a 'useful' rcode for capsforid comparison, so not SERVFAIL or REFUSED, and thus NOERROR or NXDOMAIN.

Parameters

  rep | reply to check.

Returns
  true if the rcode is a bad type of message.

References reply_info::flags, and FLAGS_GET_RCODE.

Referenced by process_response().

## ◆ iter_store_parentside_rrset()

void iter_store_parentside_rrset | ( | struct module_env * | env,
|  | struct ub_packed_rrset_key * | rrset )

Store parent-side rrset in separate rrset cache entries for later last-resort * lookups in case the child-side versions of this information fails.

Parameters

  env | environment with cache, time, ...
  rrset | the rrset to store (copied). Failure to store is logged, but otherwise ignored.

References module_env::alloc, ub_packed_rrset_key::entry, packed_rrset_key::flags, lruhash_entry::hash, rrset_ref::id, ub_packed_rrset_key::id, rrset_ref::key, log_err(), module_env::now, packed_rrset_copy_alloc(), PACKED_RRSET_PARENT_SIDE, ub_packed_rrset_key::rk, module_env::rrset_cache, rrset_cache_update(), and rrset_key_hash().

Referenced by iter_store_parentside_neg(), iter_store_parentside_NS(), and processQueryResponse().

## ◆ iter_store_parentside_NS()

void iter_store_parentside_NS | ( | struct module_env * | env,
|  | struct reply_info * | rep )

Store parent-side NS records from a referral message.

Parameters

  env | environment with cache, time, ...
  rep | response with NS rrset. Failure to store is logged, but otherwise ignored.

References iter_store_parentside_rrset(), log_rrset_key(), reply_get_NS_rrset(), and VERB_ALGO.

Referenced by processQueryResponse().

## ◆ iter_store_parentside_neg()

void iter_store_parentside_neg | ( | struct module_env * | env,
|  | struct query_info * | qinfo,
|  | struct reply_info * | rep )

Store parent-side negative element, the parentside rrset does not exist, creates an rrset with empty rdata in the rrset cache with PARENTSIDE flag.

Parameters

  env | environment with cache, time, ...
  qinfo | the identity of the rrset that is missing.
  rep | delegation response or answer response, to glean TTL from. (malloc) failure is logged but otherwise ignored.

References packed_rrset_data::count, lruhash_entry::data, packed_rrset_key::dname, packed_rrset_key::dname_len, ub_packed_rrset_key::entry, packed_rrset_key::flags, lruhash_entry::hash, iter_store_parentside_rrset(), lruhash_entry::key, log_err(), log_rrset_key(), NORR_TTL, packed_rrset_ptr_fixup(), query_info::qclass, query_info::qname, query_info::qname_len, query_info::qtype, regional_alloc(), regional_alloc_init(), regional_alloc_zero(), reply_get_NS_rrset(), ub_packed_rrset_key::rk, packed_rrset_data::rr_data, packed_rrset_data::rr_len, packed_rrset_data::rr_ttl, packed_rrset_key::rrset_class, reply_info::rrset_count, rrset_key_hash(), rrset_trust_ans_noAA, reply_info::rrsets, packed_rrset_data::rrsig_count, module_env::scratch, packed_rrset_data::trust, packed_rrset_data::ttl, packed_rrset_key::type, ub_packed_rrset_ttl(), and VERB_ALGO.

Referenced by processFinished(), and processLastResort().

## ◆ iter_lookup_parent_NS_from_cache()

int iter_lookup_parent_NS_from_cache | ( | struct module_env * | env,
|  | struct delegpt * | dp,
|  | struct regional * | region,
|  | struct query_info * | qinfo )

Add parent NS record if that exists in the cache.

This is both new information and acts like a timeout throttle on retries.

Parameters

  env | query env with rrset cache and time.
  dp | delegation point to store result in. Also this dp is used to see which NS name is needed.
  region | region to alloc result in.
  qinfo | pertinent information, the qclass.

Returns
  false on malloc failure. if true, the routine worked and if such cached information existed dp->has_parent_side_NS is set true.

References delegpt_rrset_add_ns(), ub_packed_rrset_key::entry, delegpt::has_parent_side_NS, LDNS_RR_TYPE_NS, lruhash_entry::lock, log_rrset_key(), delegpt::name, delegpt::namelen, module_env::now, PACKED_RRSET_PARENT_SIDE, query_info::qclass, module_env::rrset_cache, rrset_cache_lookup(), and VERB_ALGO.

Referenced by processLastResort().

## ◆ iter_lookup_parent_glue_from_cache()

int iter_lookup_parent_glue_from_cache | ( | struct module_env * | env,
|  | struct delegpt * | dp,
|  | struct regional * | region,
|  | struct query_info * | qinfo )

Add parent-side glue if that exists in the cache.

This is both new information and acts like a timeout throttle on retries to fetch them.

Parameters

  env | query env with rrset cache and time.
  dp | delegation point to store result in. Also this dp is used to see which NS name is needed.
  region | region to alloc result in.
  qinfo | pertinent information, the qclass.

Returns
  : true, it worked, no malloc failures, and new addresses (lame) have been added, giving extra options as query targets.

References delegpt_ns::cache_lookup_count, delegpt_add_rrset_A(), delegpt_add_rrset_AAAA(), delegpt_count_targets(), delegpt_ns::done_pside4, delegpt_ns::done_pside6, ub_packed_rrset_key::entry, LDNS_RR_TYPE_A, LDNS_RR_TYPE_AAAA, lruhash_entry::lock, log_err(), log_rrset_key(), delegpt_ns::name, delegpt_ns::namelen, delegpt_ns::next, module_env::now, delegpt::nslist, PACKED_RRSET_PARENT_SIDE, query_info::qclass, module_env::rrset_cache, rrset_cache_lookup(), and VERB_ALGO.

Referenced by processLastResort().

## ◆ iter_get_next_root()

int iter_get_next_root | ( | struct iter_hints * | hints,
|  | struct iter_forwards * | fwd,
|  | uint16_t * | c )

Lookup next root-hint or root-forward entry.

Parameters

  hints | the hints.
  fwd | the forwards.
  c | the class to start searching at. 0 means find first one.

Returns
  false if no classes found, true if found and returned in c.

References forwards_next_root(), hints_next_root(), iter_forwards::lock, and iter_hints::lock.

Referenced by processCollectClass().

## ◆ iter_scrub_ds()

void iter_scrub_ds | ( | struct dns_msg * | msg,
|  | struct ub_packed_rrset_key * | ns,
|  | uint8_t * | z )

Remove DS records that are inappropriate before they are cached.

Parameters

  msg | the response to scrub.
  ns | RRSET that is the NS record for the referral. if NULL, then all DS records are removed from the authority section.
  z | zone name that the response is from.

References reply_info::an_numrrsets, packed_rrset_key::dname, dname_subdomain_c(), LDNS_RR_TYPE_DS, log_nametypeclass(), reply_info::ns_numrrsets, query_dname_compare(), dns_msg::rep, ub_packed_rrset_key::rk, packed_rrset_key::rrset_class, reply_info::rrset_count, reply_info::rrsets, packed_rrset_key::type, and VERB_ALGO.

Referenced by processQueryResponse().

## ◆ iter_scrub_nxdomain()

void iter_scrub_nxdomain | ( | struct dns_msg * | msg | ) |

Prepare an NXDOMAIN message to be used for a subdomain answer by removing all RRs from the ANSWER section.

Parameters

  msg | the response to scrub.

References reply_info::an_numrrsets, dns_msg::rep, reply_info::rrset_count, and reply_info::rrsets.

Referenced by dns_cache_lookup(), and processQueryResponse().

## ◆ iter_dec_attempts()

void iter_dec_attempts | ( | struct delegpt * | dp,
|  | int | d,
|  | int | outbound_msg_retry )

Remove query attempts from all available ips.

For 0x20.

Parameters

  dp | delegpt.
  d | decrease.
  outbound_msg_retry | number of retries of outgoing queries

References delegpt_addr::attempts, delegpt_add_to_result_list(), delegpt_addr::next_target, and delegpt::target_list.

Referenced by process_response(), and processQueryTargets().

## ◆ iter_merge_retry_counts()

void iter_merge_retry_counts | ( | struct delegpt * | dp,
|  | struct delegpt * | old,
|  | int | outbound_msg_retry )

Add retry counts from older delegpt to newer delegpt.

Does not waste time on timeout'd (or other failing) addresses.

Parameters

  dp | new delegationpoint.
  old | old delegationpoint.
  outbound_msg_retry | number of retries of outgoing queries

References delegpt_addr::addr, delegpt_addr::addrlen, delegpt_addr::attempts, delegpt_find_addr(), log_addr(), delegpt_addr::next_target, delegpt_addr::next_usable, delegpt::target_list, delegpt::usable_list, and VERB_ALGO.

Referenced by processQueryResponse().

## ◆ iter_ds_toolow()

int iter_ds_toolow | ( | struct dns_msg * | msg,
|  | struct delegpt * | dp )

See if a DS response (type ANSWER) is too low: a nodata answer with a SOA record in the authority section at-or-below the qchase.qname.

Also returns true if we are not sure (i.e. empty message, CNAME nosig).

Parameters

  msg | the response.
  dp | the dp name is used to check if the RRSIG gives a clue that it was originated from the correct nameserver.

Returns
  true if too low.

References reply_info::an_numrrsets, packed_rrset_key::dname, dname_subdomain_c(), LDNS_RR_TYPE_CNAME, LDNS_RR_TYPE_DNAME, LDNS_RR_TYPE_DS, LDNS_RR_TYPE_SOA, delegpt::name, reply_info::ns_numrrsets, dns_msg::qinfo, query_info::qname, query_dname_compare(), dns_msg::rep, ub_packed_rrset_key::rk, reply_info::rrsets, packed_rrset_key::type, and val_find_rrset_signer().

Referenced by processQueryResponse().

## ◆ iter_dp_cangodown()

int iter_dp_cangodown | ( | struct query_info * | qinfo,
|  | struct delegpt * | dp )

See if delegpt can go down a step to the qname or not.

Parameters

  qinfo | the query name looked up.
  dp | checked if the name can go lower to the qname

Returns
  true if can go down, false if that would not be possible. the current response seems to be the one and only, best possible, response.

References dname_count_labels(), delegpt::name, delegpt::namelabs, query_info::qname, and query_dname_compare().

Referenced by processQueryResponse().

## ◆ iter_stub_fwd_no_cache()

int iter_stub_fwd_no_cache | ( | struct module_qstate * | qstate,
|  | struct query_info * | qinf,
|  | uint8_t ** | retdpname,
|  | size_t * | retdpnamelen,
|  | uint8_t * | dpname_storage,
|  | size_t | dpname_storage_len )

Lookup if no_cache is set in stub or fwd.

Parameters

  qstate | query state with env with hints and fwds.
  qinf | query name to lookup for.
  retdpname | returns NULL or the deepest enclosing name of fwd or stub. This is the name under which the closest lookup is going to happen. Used for NXDOMAIN checks, above that it is an nxdomain from a different server and zone. You can pass NULL to not get it.
  retdpnamelen | returns the length of the dpname.
  dpname_storage | this is where the dpname buf is stored, if any. So that caller can manage the buffer.
  dpname_storage_len | size of dpname_storage buffer.

Returns
  true if no_cache is set in stub or fwd.

References dname_str(), dname_strict_subdomain(), iter_hints_stub::dp, module_qstate::env, forwards_lookup(), module_env::fwds, module_env::hints, hints_lookup_stub(), LDNS_MAX_DOMAINLEN, iter_forwards::lock, iter_hints::lock, log_assert, delegpt::name, delegpt::namelabs, delegpt::namelen, query_info::qclass, query_info::qname, VERB_ALGO, verbose(), and verbosity.

Referenced by processInitRequest().

## ◆ iterator_set_ip46_support()

void iterator_set_ip46_support | ( | struct module_stack * | mods,
|  | struct module_env * | env,
|  | struct outside_network * | outnet )

Set support for IP4 and IP6 depending on outgoing interfaces in the outside network.

If none, no support, so no use to lookup the AAAA and then attempt to use it if there is no outgoing-interface for it.

Parameters

  mods | modstack to find iterator module in.
  env | module env, find iterator module (if one) in there.
  outnet | outside network structure.

References module_env::modinfo, modstack_find(), outside_network::num_ip4, outside_network::num_ip6, outside_network::pending, iter_env::supports_ipv4, and iter_env::supports_ipv6.

Referenced by worker_init().

## ◆ read_fetch_policy()

int read_fetch_policy | ( | int ** | target_fetch_policy,
|  | int * | max_dependency_depth,
|  | const char * | str )

Read config string that represents the target fetch policy.

Parameters

  target_fetch_policy | alloced on return.
  max_dependency_depth | set on return.
  str | the config string

Returns
  false on failure.

References cfg_count_numbers(), fetch_fill(), and log_err().

Referenced by fr_construct_from_config(), and iter_apply_cfg().

## ◆ caps_white_create()

struct rbtree_type * caps_white_create | ( | void |  | ) |

Create caps exempt data structure.

Returns
  NULL on failure.

References log_err(), name_tree_compare(), and rbtree_create().

Referenced by fr_construct_from_config(), and iter_apply_cfg().

## ◆ caps_white_delete()

void caps_white_delete | ( | struct rbtree_type * | caps_white | ) |

Delete caps exempt data structure.

Parameters

  caps_white | caps exempt tree.

References caps_free(), and traverse_postorder().

Referenced by fr_construct_clear(), and iter_deinit().

## ◆ caps_white_apply_cfg()

int caps_white_apply_cfg | ( | struct rbtree_type * | ntree,
|  | struct config_file * | cfg )

Apply config caps whitelist items to name tree.

Parameters

  ntree | caps exempt tree.
  cfg | config with options.

References config_file::caps_whitelist, name_tree_node::dclass, dname_count_labels(), rbnode_type::key, name_tree_node::labs, LDNS_RR_CLASS_IN, name_tree_node::len, log_err(), name_tree_node::name, name_tree_init_parents(), name_tree_insert(), config_strlist::next, name_tree_node::node, sldns_str2wire_dname(), and config_strlist::str.

Referenced by fr_construct_from_config(), and iter_apply_cfg().

## ◆ nat64_apply_cfg()

int nat64_apply_cfg | ( | struct iter_nat64 * | nat64,
|  | struct config_file * | cfg )

Apply config for nat64.

Parameters

  nat64 | the nat64 state.
  cfg | config with options.

Returns
  false on failure.

References addr_is_ip6(), DEFAULT_NAT64_PREFIX, config_file::do_nat64, log_err(), iter_nat64::nat64_prefix_addr, iter_nat64::nat64_prefix_addrlen, iter_nat64::nat64_prefix_net, netblockstrtoaddr(), prefixnet_is_nat64(), and iter_nat64::use_nat64.

Referenced by fr_construct_from_config(), and iter_apply_cfg().

## ◆ limit_nsec_ttl()

void limit_nsec_ttl | ( | struct dns_msg * | msg | ) |

Limit NSEC and NSEC3 TTL in response, RFC9077.

Parameters

  msg | dns message, the SOA record ttl is used to restrict ttls of NSEC and NSEC3 RRsets. If no SOA record, nothing happens.

References lruhash_entry::data, packed_rrset_key::dname, ub_packed_rrset_key::entry, LDNS_RR_TYPE_SOA, log_nametypeclass(), dns_msg::rep, ub_packed_rrset_key::rk, packed_rrset_key::rrset_class, reply_info::rrset_count, reply_info::rrsets, packed_rrset_data::ttl, packed_rrset_key::type, VERB_ALGO, and verbosity.

Referenced by process_response().

## ◆ iter_make_minimal()

void iter_make_minimal | ( | struct reply_info * | rep | ) |

Make the response minimal.

Removed authority and additional section, that works when there is an answer in the answer section.

Parameters

  rep | reply to modify.

References reply_info::ar_numrrsets, reply_info::ns_numrrsets, and reply_info::rrset_count.

Referenced by processQueryResponse().