2007-05-11 10:16:42 -04:00
|
|
|
/*
|
|
|
|
|
* iterator/iterator.h - iterative resolver DNS query response module
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2007, NLnet Labs. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* This software is open source.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
|
* are met:
|
|
|
|
|
*
|
|
|
|
|
* Redistributions of source code must retain the above copyright notice,
|
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
|
*
|
|
|
|
|
* Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
|
*
|
|
|
|
|
* Neither the name of the NLNET LABS nor the names of its contributors may
|
|
|
|
|
* be used to endorse or promote products derived from this software without
|
|
|
|
|
* specific prior written permission.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
2014-02-07 08:28:39 -05:00
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
|
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
|
|
|
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2007-05-11 10:16:42 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \file
|
|
|
|
|
*
|
2017-09-15 10:29:28 -04:00
|
|
|
* This file contains a module that performs recursive iterative DNS query
|
2007-05-11 10:16:42 -04:00
|
|
|
* processing.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef ITERATOR_ITERATOR_H
|
|
|
|
|
#define ITERATOR_ITERATOR_H
|
2007-05-22 08:36:02 -04:00
|
|
|
#include "services/outbound_list.h"
|
2007-06-22 09:24:26 -04:00
|
|
|
#include "util/data/msgreply.h"
|
2007-10-05 09:02:50 -04:00
|
|
|
#include "util/module.h"
|
2007-05-23 05:34:01 -04:00
|
|
|
struct delegpt;
|
2007-07-18 04:14:44 -04:00
|
|
|
struct iter_donotq;
|
2007-05-30 07:18:17 -04:00
|
|
|
struct iter_prep_list;
|
2008-09-03 10:40:09 -04:00
|
|
|
struct iter_priv;
|
2017-01-19 05:25:41 -05:00
|
|
|
struct rbtree_type;
|
2007-05-11 10:16:42 -04:00
|
|
|
|
2014-12-08 10:09:18 -05:00
|
|
|
/** max number of targets spawned for a query and its subqueries */
|
2015-09-28 03:21:48 -04:00
|
|
|
#define MAX_TARGET_COUNT 64
|
2024-08-08 03:27:45 -04:00
|
|
|
/** max number of upstream queries for a query and its subqueries, it is
|
|
|
|
|
* never reset. */
|
2024-08-20 08:08:52 -04:00
|
|
|
extern int MAX_GLOBAL_QUOTA;
|
2020-05-19 04:27:27 -04:00
|
|
|
/** max number of target lookups per qstate, per delegation point */
|
|
|
|
|
#define MAX_DP_TARGET_COUNT 16
|
|
|
|
|
/** max number of nxdomains allowed for target lookups for a query and
|
|
|
|
|
* its subqueries */
|
|
|
|
|
#define MAX_TARGET_NX 5
|
2022-06-29 11:31:23 -04:00
|
|
|
/** max number of nxdomains allowed for target lookups for a query and
|
|
|
|
|
* its subqueries when fallback has kicked in */
|
|
|
|
|
#define MAX_TARGET_NX_FALLBACK (MAX_TARGET_NX*2)
|
2007-05-31 08:51:36 -04:00
|
|
|
/** max number of referrals. Makes sure resolver does not run away */
|
2010-06-15 06:50:20 -04:00
|
|
|
#define MAX_REFERRAL_COUNT 130
|
2016-05-18 10:09:12 -04:00
|
|
|
/** max number of queries for which to perform dnsseclameness detection,
|
2017-09-15 10:29:28 -04:00
|
|
|
* (rrsigs missing detection) after that, just pick up that response */
|
2016-05-18 10:09:12 -04:00
|
|
|
#define DNSSEC_LAME_DETECT_COUNT 4
|
2016-03-17 10:44:41 -04:00
|
|
|
/**
|
|
|
|
|
* max number of QNAME minimisation iterations. Limits number of queries for
|
|
|
|
|
* QNAMEs with a lot of labels.
|
|
|
|
|
*/
|
|
|
|
|
#define MAX_MINIMISE_COUNT 10
|
2016-06-13 09:06:35 -04:00
|
|
|
/* max number of time-outs for minimised query. Prevents resolving failures
|
|
|
|
|
* when the QNAME minimisation QTYPE is blocked. */
|
|
|
|
|
#define MAX_MINIMISE_TIMEOUT_COUNT 3
|
2016-03-17 10:44:41 -04:00
|
|
|
/**
|
|
|
|
|
* number of labels from QNAME that are always send individually when using
|
|
|
|
|
* QNAME minimisation, even when the number of labels of the QNAME is bigger
|
2022-01-29 17:49:38 -05:00
|
|
|
* than MAX_MINIMISE_COUNT */
|
2016-03-17 10:44:41 -04:00
|
|
|
#define MINIMISE_ONE_LAB 4
|
|
|
|
|
#define MINIMISE_MULTIPLE_LABS (MAX_MINIMISE_COUNT - MINIMISE_ONE_LAB)
|
2011-09-16 10:11:12 -04:00
|
|
|
/** at what query-sent-count to stop target fetch policy */
|
|
|
|
|
#define TARGET_FETCH_STOP 3
|
2007-06-27 09:26:32 -04:00
|
|
|
/** how nice is a server without further information, in msec
|
|
|
|
|
* Equals rtt initial timeout value.
|
|
|
|
|
*/
|
2018-10-25 05:21:41 -04:00
|
|
|
extern int UNKNOWN_SERVER_NICENESS;
|
2007-06-27 09:26:32 -04:00
|
|
|
/** maximum timeout before a host is deemed unsuitable, in msec.
|
|
|
|
|
* After host_ttl this will be timed out and the host will be tried again.
|
2022-07-16 04:19:35 -04:00
|
|
|
* Equals RTT_MAX_TIMEOUT, and thus when RTT_MAX_TIMEOUT is overwritten by
|
|
|
|
|
* config infra_cache_max_rtt, it will be overwritten as well. */
|
|
|
|
|
extern int USEFUL_SERVER_TOP_TIMEOUT;
|
|
|
|
|
/** penalty to validation failed blacklisted IPs
|
|
|
|
|
* Equals USEFUL_SERVER_TOP_TIMEOUT*4, and thus when RTT_MAX_TIMEOUT is
|
|
|
|
|
* overwritten by config infra_cache_max_rtt, it will be overwritten as well. */
|
|
|
|
|
extern int BLACKLIST_PENALTY;
|
2008-03-25 11:33:24 -04:00
|
|
|
/** RTT band, within this amount from the best, servers are chosen randomly.
|
|
|
|
|
* Chosen so that the UNKNOWN_SERVER_NICENESS falls within the band of a
|
|
|
|
|
* fast server, this causes server exploration as a side benefit. msec. */
|
|
|
|
|
#define RTT_BAND 400
|
2023-10-04 12:16:22 -04:00
|
|
|
/** Number of retries for empty nodata packets before it is accepted. */
|
|
|
|
|
#define EMPTY_NODATA_RETRY_COUNT 2
|
2007-05-25 11:28:20 -04:00
|
|
|
|
2007-05-11 10:16:42 -04:00
|
|
|
/**
|
Fast Reload Option (#1042)
* - fast-reload, add unbound-control fast_reload
* - fast-reload, make a thread to service the unbound-control command.
* - fast-reload, communication sockets for information transfer.
* - fast-reload, fix compile for unbound-dnstap-socket.
* - fast-reload, set nonblocking communication to keep the server thread
responding to DNS requests.
* - fast-reload, poll routine to test for readiness, timeout fails connection.
* - fast-reload, detect loop in sock_poll_timeout routine.
* - fast-reload, send done and exited notification.
* - fast-reload, defines for constants in ipc.
* - fast-reload, ipc socket recv and send resists partial reads and writes and
can continue byte by byte. Also it can continue after an interrupt.
* - fast-reload, send exit command to thread when done.
* - fast-reload, output strings for client on string list.
* - fast-reload, add newline to terminal output.
* - fast-reload, send client string to remote client.
* - fast-reload, better debug output.
* - fast-reload, print queue structure, for output to the remote client.
* - fast-reload, move print items to print queue from fast_reload_thread struct.
* - fast-reload, keep list of pending print queue items in daemon struct.
* - fast-reload, comment explains in_list for printq to print remainder.
* - fast-reload, unit test testdata/fast_reload_thread.tdir that tests the
thread output.
* - fast-reload, fix test link for fast_reload_printq_list_delete function.
* - fast-reload, reread config file from disk.
* - fast-reload, unshare forwards, making the structure locked, with an rwlock.
* - fast-reload, for nonthreaded, the unbound-control commands forward,
forward_add and forward_delete should be distributed to other processes,
but when threaded, they should not be distributed to other threads because
the structure is not thread specific any more.
* - fast-reload, unshared stub hints, making the structure locked, with an rwlock.
* - fast-reload, helpful comments for hints lookup function return value.
* - fast-reload, fix bug in fast reload printout, the strlist appendlist routine,
and printout time statistics after the reload is done.
* - fast-reload, keep track of reloadtime and deletestime and print them.
* - fast-reload, keep track of constructtime and print it.
* - fast-reload, construct new items.
* - fast-reload, better comment.
* - fast-reload, reload the config and swap trees for forwards and stub hints.
* - fast-reload, in forwards_swap_tree set protection of trees with locks.
* - fast-reload, in hints_swap_tree also swap the node count of the trees.
* - fast-reload, reload ipc to stop and start threads.
* - fast-reload, unused forward declarations removed.
* - fast-reload, unit test that fast reload works with forwards and stubs.
* - fast-reload, fix clang analyzer warnings.
* - fast-reload, small documentation entry in unbound-control -h output.
* - fast-reload, printout memory use by fast reload, in bytes.
* - fast-reload, compile without threads.
* - fast-reload, document fast_reload in man page.
* - fast-reload, print ok when done successfully.
* - fast-reload, option for fast-reload commandline, +v verbosity option,
with timing and memory use output.
* - fast-reload, option for fast-reload commandline, +p does not pause threads.
* - fast-reload, option for fast-reload commandline, +d drops mesh queries.
* - fast-reload, fix to poll every thread with nopause to make certain that
resources are not held by the threads and can be deleted.
* - fast-reload, fix to use atomic store for config variables with nopause.
* - fast-reload, reload views.
* - fast-reload, when tag defines are different, it drops the queries.
* - fast-reload, fix tag define check.
* - fast-reload, document that tag change causes drop of queries.
* - fast-reload, fix space in documentation man page.
* - fast-reload, copy respip client information to query state, put views tree
in module env for lookup.
* - fast-reload, nicer respip view comparison.
* - fast-reload, respip global set is in module env.
* - fast-reload, document that respip_client_info acl info is copied.
* - fast-reload, reload the respip_set.
* - fast-reload, document no pause and pick up of use_response_ip boolean.
* - fast-reload, fix test compile.
* - fast-reload, reload local zones.
* Update locking management for iter_fwd and iter_hints methods. (#1054)
fast reload, move most of the locking management to iter_fwd and
iter_hints methods. The caller still has the ability to handle its
own locking, if desired, for atomic operations on sets of different
structs.
Co-authored-by: Wouter Wijngaards <wcawijngaards@users.noreply.github.com>
* - fast-reload, reload access-control.
* - fast-reload, reload access control interface, such as interface-action.
* - fast-reload, reload tcp-connection-limit.
* - fast-reload, improve comments on acl_list and tcl_list swap tree.
* - fast-reload, fixup references to old tcp connection limits in open tcp
connections.
* - fast-reload, fixup to clean tcp connection also for different linked order.
* - fast-reload, if no tcp connection limits existed, no need to remove
references for that.
* - fast-reload, document more options that work and do not work.
* - fast-reload, reload auth_zone and rpz data.
* - fast-reload, fix auth_zones_get_mem.
* - fast-reload, fix compilation of testbound for the new comm_timer_get_mem
reference in remote control.
* - fast-reload, change use_rpz with reload.
* - fast-reload, list changes in auth zones and stop zonemd callbacks for
deleted auth zones.
* - fast-reload, note xtree is not swapped, and why it is not swapped.
* - fast-reload, for added auth zones, pick up zone transfer and zonemd tasks.
* - fast-reload, unlock xfr when done with transfer pick up.
* - fast-reload, unlock z when picking up the xfr for it during transfer task
pick up.
* - fast-reload, pick up task changes for added, deleted and modified auth zones.
* - fast-reload, remove xfr of auth zone deletion without tasks.
* - fast-reload, pick up zone transfer config.
* - fast-reload, the main worker thread picks up the transfer tasks and also
performs setup of the xfer struct.
* - fast-reload, keep writelock on newzone when auth zone changes.
* - fast-reload, change cachedb_enabled setting.
* - fast-reload, pick up edns-strings config.
* - fast-reload, note that settings are not updated.
* - fast-reload, pick up dnstap config.
* - fast-reload, dnstap options that need to be loaded without +p.
* - fast-reload, fix auth zone reload
* - fast-reload, remove debug for auth zone test.
* - fast-reload, fix auth zone reload with zone transfer.
* - fast-reload, fix auth zone reload lock order.
* - fast-reload, remove debug from fast reload test.
* - fast-reload, remove unused function.
* - fast-reload, fix the worker trust anchor probe timer lock acquisition in
the probe answer callback routine for trust anchor probes.
* - fast-reload, reload trust anchors.
* - fast-reload, fix trust anchor reload lock on autr global data and test
for trust anchor reload.
* - fast-reload, adjust cache sizes.
* - fast-reload, reload cache sizes when changed.
* - fast-reload, reload validator env changes.
* - fast-reload, reload mesh changes.
* - fast-reload, check for incompatible changes.
* - fast-reload, improve error text for incompatible change.
* - fast-reload, fix check config option compatibility.
* - fast-reload, improve error text for nopause change.
* - fast-reload, fix spelling of incompatible options.
* - fast-reload, reload target-fetch-policy, outbound-msg-retry, max-sent-count
and max-query-restarts.
* - fast-reload, check nopause config change for target-fetch-policy.
* - fast-reload, reload do-not-query-address, private-address and capt-exempt.
* - fast-reload, check nopause config change for do-not-query-address,
private-address and capt-exempt.
* - fast-reload, check fast reload not possible due to interface and
outgoing-interface changes.
* - fast-reload, reload nat64 settings.
* - fast-reload, reload settings stored in the infra structure.
* - fast-reload, fix modstack lookup and remove outgoing-range check.
* - fast-reload, more explanation for config parse failure.
* - fast-reload, reload worker outside network changes.
* - fast-reload, detect incompatible changes in network settings.
* fast-reload, commit test files.
* - fast-reload, fix warnings for call types in windows compile.
* - fast-reload, fix warnings and comm_point_internal for tcp wouldblock calls.
* - fast-reload, extend lock checks for repeat thread ids.
* - fast-reload, additional test cases, cache change and tag changes.
* - fast-reload, fix documentation for auth_zone_verify_zonemd_with_key.
* - fast-reload, fix copy_cfg type casts and memory leak on config parse failure.
* - fast-reload, fix use of WSAPoll.
* Review comments for the fast reload feature (#1259)
* - fast-reload review, respip set can be null from a view.
* - fast-reload review, typos.
* - fast-reload review, keep clang static analyzer happy.
* - fast-reload review, don't forget to copy tag_actions.
* - fast-reload review, less indentation.
* - fast-reload review, don't leak respip_actions when reloading.
* - fast-reload review, protect NULL pointer dereference in get_mem
functions.
* - fast-reload review, add fast_reload_most_options.tdir to test most
options with high verbosity when fast reloading.
* - fast-reload review, don't skip new line on long error printouts.
* - fast-reload review, typo.
* - fast-reload review, use new_z for consistency.
* - fast-reload review, nit for unlock ordering to make eye comparison
with the lock counterpart easier.
* - fast-reload review, in case of error the sockets are already closed.
* - fast-reload review, identation.
* - fast-reload review, add static keywords.
* - fast-reload review, update unbound-control usage text.
* - fast-reload review, updates to the man page.
* - fast-reload, the fast-reload command is experimental.
* - fast-reload, fix compile of doqclient for fast reload functions.
* Changelog comment for #1042
- Merge #1042: Fast Reload. The unbound-control fast_reload is added.
It reads changed config in a thread, then only briefly pauses the
service threads, that keep running. DNS service is only interrupted
briefly, less than a second.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2025-03-31 09:25:24 -04:00
|
|
|
* Iterator global state for nat64.
|
2007-05-11 10:16:42 -04:00
|
|
|
*/
|
Fast Reload Option (#1042)
* - fast-reload, add unbound-control fast_reload
* - fast-reload, make a thread to service the unbound-control command.
* - fast-reload, communication sockets for information transfer.
* - fast-reload, fix compile for unbound-dnstap-socket.
* - fast-reload, set nonblocking communication to keep the server thread
responding to DNS requests.
* - fast-reload, poll routine to test for readiness, timeout fails connection.
* - fast-reload, detect loop in sock_poll_timeout routine.
* - fast-reload, send done and exited notification.
* - fast-reload, defines for constants in ipc.
* - fast-reload, ipc socket recv and send resists partial reads and writes and
can continue byte by byte. Also it can continue after an interrupt.
* - fast-reload, send exit command to thread when done.
* - fast-reload, output strings for client on string list.
* - fast-reload, add newline to terminal output.
* - fast-reload, send client string to remote client.
* - fast-reload, better debug output.
* - fast-reload, print queue structure, for output to the remote client.
* - fast-reload, move print items to print queue from fast_reload_thread struct.
* - fast-reload, keep list of pending print queue items in daemon struct.
* - fast-reload, comment explains in_list for printq to print remainder.
* - fast-reload, unit test testdata/fast_reload_thread.tdir that tests the
thread output.
* - fast-reload, fix test link for fast_reload_printq_list_delete function.
* - fast-reload, reread config file from disk.
* - fast-reload, unshare forwards, making the structure locked, with an rwlock.
* - fast-reload, for nonthreaded, the unbound-control commands forward,
forward_add and forward_delete should be distributed to other processes,
but when threaded, they should not be distributed to other threads because
the structure is not thread specific any more.
* - fast-reload, unshared stub hints, making the structure locked, with an rwlock.
* - fast-reload, helpful comments for hints lookup function return value.
* - fast-reload, fix bug in fast reload printout, the strlist appendlist routine,
and printout time statistics after the reload is done.
* - fast-reload, keep track of reloadtime and deletestime and print them.
* - fast-reload, keep track of constructtime and print it.
* - fast-reload, construct new items.
* - fast-reload, better comment.
* - fast-reload, reload the config and swap trees for forwards and stub hints.
* - fast-reload, in forwards_swap_tree set protection of trees with locks.
* - fast-reload, in hints_swap_tree also swap the node count of the trees.
* - fast-reload, reload ipc to stop and start threads.
* - fast-reload, unused forward declarations removed.
* - fast-reload, unit test that fast reload works with forwards and stubs.
* - fast-reload, fix clang analyzer warnings.
* - fast-reload, small documentation entry in unbound-control -h output.
* - fast-reload, printout memory use by fast reload, in bytes.
* - fast-reload, compile without threads.
* - fast-reload, document fast_reload in man page.
* - fast-reload, print ok when done successfully.
* - fast-reload, option for fast-reload commandline, +v verbosity option,
with timing and memory use output.
* - fast-reload, option for fast-reload commandline, +p does not pause threads.
* - fast-reload, option for fast-reload commandline, +d drops mesh queries.
* - fast-reload, fix to poll every thread with nopause to make certain that
resources are not held by the threads and can be deleted.
* - fast-reload, fix to use atomic store for config variables with nopause.
* - fast-reload, reload views.
* - fast-reload, when tag defines are different, it drops the queries.
* - fast-reload, fix tag define check.
* - fast-reload, document that tag change causes drop of queries.
* - fast-reload, fix space in documentation man page.
* - fast-reload, copy respip client information to query state, put views tree
in module env for lookup.
* - fast-reload, nicer respip view comparison.
* - fast-reload, respip global set is in module env.
* - fast-reload, document that respip_client_info acl info is copied.
* - fast-reload, reload the respip_set.
* - fast-reload, document no pause and pick up of use_response_ip boolean.
* - fast-reload, fix test compile.
* - fast-reload, reload local zones.
* Update locking management for iter_fwd and iter_hints methods. (#1054)
fast reload, move most of the locking management to iter_fwd and
iter_hints methods. The caller still has the ability to handle its
own locking, if desired, for atomic operations on sets of different
structs.
Co-authored-by: Wouter Wijngaards <wcawijngaards@users.noreply.github.com>
* - fast-reload, reload access-control.
* - fast-reload, reload access control interface, such as interface-action.
* - fast-reload, reload tcp-connection-limit.
* - fast-reload, improve comments on acl_list and tcl_list swap tree.
* - fast-reload, fixup references to old tcp connection limits in open tcp
connections.
* - fast-reload, fixup to clean tcp connection also for different linked order.
* - fast-reload, if no tcp connection limits existed, no need to remove
references for that.
* - fast-reload, document more options that work and do not work.
* - fast-reload, reload auth_zone and rpz data.
* - fast-reload, fix auth_zones_get_mem.
* - fast-reload, fix compilation of testbound for the new comm_timer_get_mem
reference in remote control.
* - fast-reload, change use_rpz with reload.
* - fast-reload, list changes in auth zones and stop zonemd callbacks for
deleted auth zones.
* - fast-reload, note xtree is not swapped, and why it is not swapped.
* - fast-reload, for added auth zones, pick up zone transfer and zonemd tasks.
* - fast-reload, unlock xfr when done with transfer pick up.
* - fast-reload, unlock z when picking up the xfr for it during transfer task
pick up.
* - fast-reload, pick up task changes for added, deleted and modified auth zones.
* - fast-reload, remove xfr of auth zone deletion without tasks.
* - fast-reload, pick up zone transfer config.
* - fast-reload, the main worker thread picks up the transfer tasks and also
performs setup of the xfer struct.
* - fast-reload, keep writelock on newzone when auth zone changes.
* - fast-reload, change cachedb_enabled setting.
* - fast-reload, pick up edns-strings config.
* - fast-reload, note that settings are not updated.
* - fast-reload, pick up dnstap config.
* - fast-reload, dnstap options that need to be loaded without +p.
* - fast-reload, fix auth zone reload
* - fast-reload, remove debug for auth zone test.
* - fast-reload, fix auth zone reload with zone transfer.
* - fast-reload, fix auth zone reload lock order.
* - fast-reload, remove debug from fast reload test.
* - fast-reload, remove unused function.
* - fast-reload, fix the worker trust anchor probe timer lock acquisition in
the probe answer callback routine for trust anchor probes.
* - fast-reload, reload trust anchors.
* - fast-reload, fix trust anchor reload lock on autr global data and test
for trust anchor reload.
* - fast-reload, adjust cache sizes.
* - fast-reload, reload cache sizes when changed.
* - fast-reload, reload validator env changes.
* - fast-reload, reload mesh changes.
* - fast-reload, check for incompatible changes.
* - fast-reload, improve error text for incompatible change.
* - fast-reload, fix check config option compatibility.
* - fast-reload, improve error text for nopause change.
* - fast-reload, fix spelling of incompatible options.
* - fast-reload, reload target-fetch-policy, outbound-msg-retry, max-sent-count
and max-query-restarts.
* - fast-reload, check nopause config change for target-fetch-policy.
* - fast-reload, reload do-not-query-address, private-address and capt-exempt.
* - fast-reload, check nopause config change for do-not-query-address,
private-address and capt-exempt.
* - fast-reload, check fast reload not possible due to interface and
outgoing-interface changes.
* - fast-reload, reload nat64 settings.
* - fast-reload, reload settings stored in the infra structure.
* - fast-reload, fix modstack lookup and remove outgoing-range check.
* - fast-reload, more explanation for config parse failure.
* - fast-reload, reload worker outside network changes.
* - fast-reload, detect incompatible changes in network settings.
* fast-reload, commit test files.
* - fast-reload, fix warnings for call types in windows compile.
* - fast-reload, fix warnings and comm_point_internal for tcp wouldblock calls.
* - fast-reload, extend lock checks for repeat thread ids.
* - fast-reload, additional test cases, cache change and tag changes.
* - fast-reload, fix documentation for auth_zone_verify_zonemd_with_key.
* - fast-reload, fix copy_cfg type casts and memory leak on config parse failure.
* - fast-reload, fix use of WSAPoll.
* Review comments for the fast reload feature (#1259)
* - fast-reload review, respip set can be null from a view.
* - fast-reload review, typos.
* - fast-reload review, keep clang static analyzer happy.
* - fast-reload review, don't forget to copy tag_actions.
* - fast-reload review, less indentation.
* - fast-reload review, don't leak respip_actions when reloading.
* - fast-reload review, protect NULL pointer dereference in get_mem
functions.
* - fast-reload review, add fast_reload_most_options.tdir to test most
options with high verbosity when fast reloading.
* - fast-reload review, don't skip new line on long error printouts.
* - fast-reload review, typo.
* - fast-reload review, use new_z for consistency.
* - fast-reload review, nit for unlock ordering to make eye comparison
with the lock counterpart easier.
* - fast-reload review, in case of error the sockets are already closed.
* - fast-reload review, identation.
* - fast-reload review, add static keywords.
* - fast-reload review, update unbound-control usage text.
* - fast-reload review, updates to the man page.
* - fast-reload, the fast-reload command is experimental.
* - fast-reload, fix compile of doqclient for fast reload functions.
* Changelog comment for #1042
- Merge #1042: Fast Reload. The unbound-control fast_reload is added.
It reads changed config in a thread, then only briefly pauses the
service threads, that keep running. DNS service is only interrupted
briefly, less than a second.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2025-03-31 09:25:24 -04:00
|
|
|
struct iter_nat64 {
|
2022-07-23 14:26:20 -04:00
|
|
|
/** A flag to locally apply NAT64 to make IPv4 addrs into IPv6 */
|
|
|
|
|
int use_nat64;
|
|
|
|
|
|
|
|
|
|
/** NAT64 prefix address, cf. dns64_env->prefix_addr */
|
|
|
|
|
struct sockaddr_storage nat64_prefix_addr;
|
|
|
|
|
|
|
|
|
|
/** sizeof(sockaddr_in6) */
|
|
|
|
|
socklen_t nat64_prefix_addrlen;
|
|
|
|
|
|
|
|
|
|
/** CIDR mask length of NAT64 prefix */
|
|
|
|
|
int nat64_prefix_net;
|
Fast Reload Option (#1042)
* - fast-reload, add unbound-control fast_reload
* - fast-reload, make a thread to service the unbound-control command.
* - fast-reload, communication sockets for information transfer.
* - fast-reload, fix compile for unbound-dnstap-socket.
* - fast-reload, set nonblocking communication to keep the server thread
responding to DNS requests.
* - fast-reload, poll routine to test for readiness, timeout fails connection.
* - fast-reload, detect loop in sock_poll_timeout routine.
* - fast-reload, send done and exited notification.
* - fast-reload, defines for constants in ipc.
* - fast-reload, ipc socket recv and send resists partial reads and writes and
can continue byte by byte. Also it can continue after an interrupt.
* - fast-reload, send exit command to thread when done.
* - fast-reload, output strings for client on string list.
* - fast-reload, add newline to terminal output.
* - fast-reload, send client string to remote client.
* - fast-reload, better debug output.
* - fast-reload, print queue structure, for output to the remote client.
* - fast-reload, move print items to print queue from fast_reload_thread struct.
* - fast-reload, keep list of pending print queue items in daemon struct.
* - fast-reload, comment explains in_list for printq to print remainder.
* - fast-reload, unit test testdata/fast_reload_thread.tdir that tests the
thread output.
* - fast-reload, fix test link for fast_reload_printq_list_delete function.
* - fast-reload, reread config file from disk.
* - fast-reload, unshare forwards, making the structure locked, with an rwlock.
* - fast-reload, for nonthreaded, the unbound-control commands forward,
forward_add and forward_delete should be distributed to other processes,
but when threaded, they should not be distributed to other threads because
the structure is not thread specific any more.
* - fast-reload, unshared stub hints, making the structure locked, with an rwlock.
* - fast-reload, helpful comments for hints lookup function return value.
* - fast-reload, fix bug in fast reload printout, the strlist appendlist routine,
and printout time statistics after the reload is done.
* - fast-reload, keep track of reloadtime and deletestime and print them.
* - fast-reload, keep track of constructtime and print it.
* - fast-reload, construct new items.
* - fast-reload, better comment.
* - fast-reload, reload the config and swap trees for forwards and stub hints.
* - fast-reload, in forwards_swap_tree set protection of trees with locks.
* - fast-reload, in hints_swap_tree also swap the node count of the trees.
* - fast-reload, reload ipc to stop and start threads.
* - fast-reload, unused forward declarations removed.
* - fast-reload, unit test that fast reload works with forwards and stubs.
* - fast-reload, fix clang analyzer warnings.
* - fast-reload, small documentation entry in unbound-control -h output.
* - fast-reload, printout memory use by fast reload, in bytes.
* - fast-reload, compile without threads.
* - fast-reload, document fast_reload in man page.
* - fast-reload, print ok when done successfully.
* - fast-reload, option for fast-reload commandline, +v verbosity option,
with timing and memory use output.
* - fast-reload, option for fast-reload commandline, +p does not pause threads.
* - fast-reload, option for fast-reload commandline, +d drops mesh queries.
* - fast-reload, fix to poll every thread with nopause to make certain that
resources are not held by the threads and can be deleted.
* - fast-reload, fix to use atomic store for config variables with nopause.
* - fast-reload, reload views.
* - fast-reload, when tag defines are different, it drops the queries.
* - fast-reload, fix tag define check.
* - fast-reload, document that tag change causes drop of queries.
* - fast-reload, fix space in documentation man page.
* - fast-reload, copy respip client information to query state, put views tree
in module env for lookup.
* - fast-reload, nicer respip view comparison.
* - fast-reload, respip global set is in module env.
* - fast-reload, document that respip_client_info acl info is copied.
* - fast-reload, reload the respip_set.
* - fast-reload, document no pause and pick up of use_response_ip boolean.
* - fast-reload, fix test compile.
* - fast-reload, reload local zones.
* Update locking management for iter_fwd and iter_hints methods. (#1054)
fast reload, move most of the locking management to iter_fwd and
iter_hints methods. The caller still has the ability to handle its
own locking, if desired, for atomic operations on sets of different
structs.
Co-authored-by: Wouter Wijngaards <wcawijngaards@users.noreply.github.com>
* - fast-reload, reload access-control.
* - fast-reload, reload access control interface, such as interface-action.
* - fast-reload, reload tcp-connection-limit.
* - fast-reload, improve comments on acl_list and tcl_list swap tree.
* - fast-reload, fixup references to old tcp connection limits in open tcp
connections.
* - fast-reload, fixup to clean tcp connection also for different linked order.
* - fast-reload, if no tcp connection limits existed, no need to remove
references for that.
* - fast-reload, document more options that work and do not work.
* - fast-reload, reload auth_zone and rpz data.
* - fast-reload, fix auth_zones_get_mem.
* - fast-reload, fix compilation of testbound for the new comm_timer_get_mem
reference in remote control.
* - fast-reload, change use_rpz with reload.
* - fast-reload, list changes in auth zones and stop zonemd callbacks for
deleted auth zones.
* - fast-reload, note xtree is not swapped, and why it is not swapped.
* - fast-reload, for added auth zones, pick up zone transfer and zonemd tasks.
* - fast-reload, unlock xfr when done with transfer pick up.
* - fast-reload, unlock z when picking up the xfr for it during transfer task
pick up.
* - fast-reload, pick up task changes for added, deleted and modified auth zones.
* - fast-reload, remove xfr of auth zone deletion without tasks.
* - fast-reload, pick up zone transfer config.
* - fast-reload, the main worker thread picks up the transfer tasks and also
performs setup of the xfer struct.
* - fast-reload, keep writelock on newzone when auth zone changes.
* - fast-reload, change cachedb_enabled setting.
* - fast-reload, pick up edns-strings config.
* - fast-reload, note that settings are not updated.
* - fast-reload, pick up dnstap config.
* - fast-reload, dnstap options that need to be loaded without +p.
* - fast-reload, fix auth zone reload
* - fast-reload, remove debug for auth zone test.
* - fast-reload, fix auth zone reload with zone transfer.
* - fast-reload, fix auth zone reload lock order.
* - fast-reload, remove debug from fast reload test.
* - fast-reload, remove unused function.
* - fast-reload, fix the worker trust anchor probe timer lock acquisition in
the probe answer callback routine for trust anchor probes.
* - fast-reload, reload trust anchors.
* - fast-reload, fix trust anchor reload lock on autr global data and test
for trust anchor reload.
* - fast-reload, adjust cache sizes.
* - fast-reload, reload cache sizes when changed.
* - fast-reload, reload validator env changes.
* - fast-reload, reload mesh changes.
* - fast-reload, check for incompatible changes.
* - fast-reload, improve error text for incompatible change.
* - fast-reload, fix check config option compatibility.
* - fast-reload, improve error text for nopause change.
* - fast-reload, fix spelling of incompatible options.
* - fast-reload, reload target-fetch-policy, outbound-msg-retry, max-sent-count
and max-query-restarts.
* - fast-reload, check nopause config change for target-fetch-policy.
* - fast-reload, reload do-not-query-address, private-address and capt-exempt.
* - fast-reload, check nopause config change for do-not-query-address,
private-address and capt-exempt.
* - fast-reload, check fast reload not possible due to interface and
outgoing-interface changes.
* - fast-reload, reload nat64 settings.
* - fast-reload, reload settings stored in the infra structure.
* - fast-reload, fix modstack lookup and remove outgoing-range check.
* - fast-reload, more explanation for config parse failure.
* - fast-reload, reload worker outside network changes.
* - fast-reload, detect incompatible changes in network settings.
* fast-reload, commit test files.
* - fast-reload, fix warnings for call types in windows compile.
* - fast-reload, fix warnings and comm_point_internal for tcp wouldblock calls.
* - fast-reload, extend lock checks for repeat thread ids.
* - fast-reload, additional test cases, cache change and tag changes.
* - fast-reload, fix documentation for auth_zone_verify_zonemd_with_key.
* - fast-reload, fix copy_cfg type casts and memory leak on config parse failure.
* - fast-reload, fix use of WSAPoll.
* Review comments for the fast reload feature (#1259)
* - fast-reload review, respip set can be null from a view.
* - fast-reload review, typos.
* - fast-reload review, keep clang static analyzer happy.
* - fast-reload review, don't forget to copy tag_actions.
* - fast-reload review, less indentation.
* - fast-reload review, don't leak respip_actions when reloading.
* - fast-reload review, protect NULL pointer dereference in get_mem
functions.
* - fast-reload review, add fast_reload_most_options.tdir to test most
options with high verbosity when fast reloading.
* - fast-reload review, don't skip new line on long error printouts.
* - fast-reload review, typo.
* - fast-reload review, use new_z for consistency.
* - fast-reload review, nit for unlock ordering to make eye comparison
with the lock counterpart easier.
* - fast-reload review, in case of error the sockets are already closed.
* - fast-reload review, identation.
* - fast-reload review, add static keywords.
* - fast-reload review, update unbound-control usage text.
* - fast-reload review, updates to the man page.
* - fast-reload, the fast-reload command is experimental.
* - fast-reload, fix compile of doqclient for fast reload functions.
* Changelog comment for #1042
- Merge #1042: Fast Reload. The unbound-control fast_reload is added.
It reads changed config in a thread, then only briefly pauses the
service threads, that keep running. DNS service is only interrupted
briefly, less than a second.
---------
Co-authored-by: Yorgos Thessalonikefs <yorgos@nlnetlabs.nl>
2025-03-31 09:25:24 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Global state for the iterator.
|
|
|
|
|
*/
|
|
|
|
|
struct iter_env {
|
|
|
|
|
/** A flag to indicate whether or not we have an IPv6 route */
|
|
|
|
|
int supports_ipv6;
|
|
|
|
|
|
|
|
|
|
/** A flag to indicate whether or not we have an IPv4 route */
|
|
|
|
|
int supports_ipv4;
|
|
|
|
|
|
|
|
|
|
/** State for nat64 */
|
|
|
|
|
struct iter_nat64 nat64;
|
2022-07-23 14:26:20 -04:00
|
|
|
|
2007-05-23 05:34:01 -04:00
|
|
|
/** A set of inetaddrs that should never be queried. */
|
2007-07-18 04:14:44 -04:00
|
|
|
struct iter_donotq* donotq;
|
2007-05-23 05:34:01 -04:00
|
|
|
|
2008-09-03 10:40:09 -04:00
|
|
|
/** private address space and private domains */
|
|
|
|
|
struct iter_priv* priv;
|
|
|
|
|
|
2015-05-01 08:36:16 -04:00
|
|
|
/** whitelist for capsforid names */
|
2017-01-19 05:25:41 -05:00
|
|
|
struct rbtree_type* caps_white;
|
2015-05-01 08:36:16 -04:00
|
|
|
|
2007-05-23 05:34:01 -04:00
|
|
|
/** The maximum dependency depth that this resolver will pursue. */
|
|
|
|
|
int max_dependency_depth;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The target fetch policy for each dependency level. This is
|
|
|
|
|
* described as a simple number (per dependency level):
|
|
|
|
|
* negative numbers (usually just -1) mean fetch-all,
|
|
|
|
|
* 0 means only fetch on demand, and
|
|
|
|
|
* positive numbers mean to fetch at most that many targets.
|
|
|
|
|
* array of max_dependency_depth+1 size.
|
|
|
|
|
*/
|
|
|
|
|
int* target_fetch_policy;
|
2017-08-03 08:52:33 -04:00
|
|
|
|
|
|
|
|
/** lock on ratelimit counter */
|
|
|
|
|
lock_basic_type queries_ratelimit_lock;
|
|
|
|
|
/** number of queries that have been ratelimited */
|
|
|
|
|
size_t num_queries_ratelimited;
|
2019-06-12 12:51:26 -04:00
|
|
|
|
|
|
|
|
/** number of retries on outgoing queries */
|
2021-09-08 09:07:11 -04:00
|
|
|
int outbound_msg_retry;
|
2022-12-13 07:50:05 -05:00
|
|
|
|
|
|
|
|
/** number of queries_sent */
|
|
|
|
|
int max_sent_count;
|
2022-12-13 09:08:11 -05:00
|
|
|
|
|
|
|
|
/** max number of query restarts to limit length of CNAME chain */
|
|
|
|
|
int max_query_restarts;
|
2015-11-30 11:10:26 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* QNAME minimisation state
|
|
|
|
|
*/
|
|
|
|
|
enum minimisation_state {
|
|
|
|
|
/**
|
|
|
|
|
* (Re)start minimisation. Outgoing QNAME should be set to dp->name.
|
2017-09-15 10:29:28 -04:00
|
|
|
* State entered on new query or after following referral or CNAME.
|
2015-11-30 11:10:26 -05:00
|
|
|
*/
|
|
|
|
|
INIT_MINIMISE_STATE = 0,
|
|
|
|
|
/**
|
2017-09-15 10:29:28 -04:00
|
|
|
* QNAME minimisation ongoing. Increase QNAME on every iteration.
|
2015-11-30 11:10:26 -05:00
|
|
|
*/
|
|
|
|
|
MINIMISE_STATE,
|
|
|
|
|
/**
|
|
|
|
|
* Don't increment QNAME this iteration
|
|
|
|
|
*/
|
|
|
|
|
SKIP_MINIMISE_STATE,
|
|
|
|
|
/**
|
|
|
|
|
* Send out full QNAME + original QTYPE
|
|
|
|
|
*/
|
|
|
|
|
DONOT_MINIMISE_STATE,
|
2007-05-23 05:34:01 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* State of the iterator for a query.
|
|
|
|
|
*/
|
|
|
|
|
enum iter_state {
|
|
|
|
|
/**
|
|
|
|
|
* Externally generated queries start at this state. Query restarts are
|
|
|
|
|
* reset to this state.
|
|
|
|
|
*/
|
|
|
|
|
INIT_REQUEST_STATE = 0,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Root priming events reactivate here, most other events pass
|
|
|
|
|
* through this naturally as the 2nd part of the INIT_REQUEST_STATE.
|
|
|
|
|
*/
|
|
|
|
|
INIT_REQUEST_2_STATE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Stub priming events reactivate here, most other events pass
|
|
|
|
|
* through this naturally as the 3rd part of the INIT_REQUEST_STATE.
|
|
|
|
|
*/
|
|
|
|
|
INIT_REQUEST_3_STATE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Each time a delegation point changes for a given query or a
|
|
|
|
|
* query times out and/or wakes up, this state is (re)visited.
|
2017-09-15 10:29:28 -04:00
|
|
|
* This state is responsible for iterating through a list of
|
2007-05-23 05:34:01 -04:00
|
|
|
* nameserver targets.
|
|
|
|
|
*/
|
|
|
|
|
QUERYTARGETS_STATE,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Responses to queries start at this state. This state handles
|
|
|
|
|
* the decision tree associated with handling responses.
|
|
|
|
|
*/
|
|
|
|
|
QUERY_RESP_STATE,
|
|
|
|
|
|
|
|
|
|
/** Responses to priming queries finish at this state. */
|
|
|
|
|
PRIME_RESP_STATE,
|
|
|
|
|
|
2009-12-15 04:10:04 -05:00
|
|
|
/** Collecting query class information, for qclass=ANY, when
|
|
|
|
|
* it spawns off queries for every class, it returns here. */
|
|
|
|
|
COLLECT_CLASS_STATE,
|
|
|
|
|
|
2012-03-19 11:44:21 -04:00
|
|
|
/** Find NS record to resolve DS record from, walking to the right
|
|
|
|
|
* NS spot until we find it */
|
|
|
|
|
DSNS_FIND_STATE,
|
|
|
|
|
|
2007-06-26 09:06:44 -04:00
|
|
|
/** Responses that are to be returned upstream end at this state.
|
|
|
|
|
* As well as responses to target queries. */
|
2007-05-23 05:34:01 -04:00
|
|
|
FINISHED_STATE
|
2007-05-11 10:16:42 -04:00
|
|
|
};
|
|
|
|
|
|
2022-06-29 11:31:23 -04:00
|
|
|
/**
|
|
|
|
|
* Shared counters for queries.
|
|
|
|
|
*/
|
|
|
|
|
enum target_count_variables {
|
|
|
|
|
/** Reference count for the shared iter_qstate->target_count. */
|
|
|
|
|
TARGET_COUNT_REF = 0,
|
|
|
|
|
/** Number of target queries spawned for the query and subqueries. */
|
|
|
|
|
TARGET_COUNT_QUERIES,
|
|
|
|
|
/** Number of nxdomain responses encountered. */
|
|
|
|
|
TARGET_COUNT_NX,
|
2024-08-08 03:27:45 -04:00
|
|
|
/** Global quota on number of queries to upstream servers per
|
|
|
|
|
* client request, that is never reset. */
|
|
|
|
|
TARGET_COUNT_GLOBAL_QUOTA,
|
2022-06-29 11:31:23 -04:00
|
|
|
|
|
|
|
|
/** This should stay last here, it is used for the allocation */
|
|
|
|
|
TARGET_COUNT_MAX,
|
|
|
|
|
};
|
|
|
|
|
|
2007-05-11 10:16:42 -04:00
|
|
|
/**
|
|
|
|
|
* Per query state for the iterator module.
|
|
|
|
|
*/
|
|
|
|
|
struct iter_qstate {
|
2007-05-24 09:24:44 -04:00
|
|
|
/**
|
|
|
|
|
* State of the iterator module.
|
2007-05-23 05:34:01 -04:00
|
|
|
* This is the state that event is in or should sent to -- all
|
|
|
|
|
* requests should start with the INIT_REQUEST_STATE. All
|
|
|
|
|
* responses should start with QUERY_RESP_STATE. Subsequent
|
|
|
|
|
* processing of the event will change this state.
|
|
|
|
|
*/
|
|
|
|
|
enum iter_state state;
|
|
|
|
|
|
2007-05-24 09:24:44 -04:00
|
|
|
/**
|
|
|
|
|
* Final state for the iterator module.
|
2007-05-23 05:34:01 -04:00
|
|
|
* This is the state that responses should be routed to once the
|
|
|
|
|
* response is final. For externally initiated queries, this
|
|
|
|
|
* will be FINISHED_STATE, locally initiated queries will have
|
|
|
|
|
* different final states.
|
|
|
|
|
*/
|
|
|
|
|
enum iter_state final_state;
|
|
|
|
|
|
2007-06-21 05:36:27 -04:00
|
|
|
/**
|
|
|
|
|
* The depth of this query, this means the depth of recursion.
|
|
|
|
|
* This address is needed for another query, which is an address
|
|
|
|
|
* needed for another query, etc. Original client query has depth 0.
|
|
|
|
|
*/
|
|
|
|
|
int depth;
|
|
|
|
|
|
2007-05-30 07:18:17 -04:00
|
|
|
/**
|
|
|
|
|
* The response
|
|
|
|
|
*/
|
|
|
|
|
struct dns_msg* response;
|
|
|
|
|
|
2007-05-23 05:34:01 -04:00
|
|
|
/**
|
|
|
|
|
* This is a list of RRsets that must be prepended to the
|
|
|
|
|
* ANSWER section of a response before being sent upstream.
|
|
|
|
|
*/
|
2007-09-04 10:06:43 -04:00
|
|
|
struct iter_prep_list* an_prepend_list;
|
2007-05-24 09:24:44 -04:00
|
|
|
/** Last element of the prepend list */
|
2007-09-04 10:06:43 -04:00
|
|
|
struct iter_prep_list* an_prepend_last;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This is the list of RRsets that must be prepended to the
|
|
|
|
|
* AUTHORITY section of the response before being sent upstream.
|
|
|
|
|
*/
|
|
|
|
|
struct iter_prep_list* ns_prepend_list;
|
|
|
|
|
/** Last element of the authority prepend list */
|
|
|
|
|
struct iter_prep_list* ns_prepend_last;
|
2007-05-23 05:34:01 -04:00
|
|
|
|
2007-06-22 09:24:26 -04:00
|
|
|
/** query name used for chasing the results. Initially the same as
|
|
|
|
|
* the state qinfo, but after CNAMEs this will be different.
|
|
|
|
|
* The query info used to elicit the results needed. */
|
|
|
|
|
struct query_info qchase;
|
|
|
|
|
/** query flags to use when chasing the answer (i.e. RD flag) */
|
|
|
|
|
uint16_t chase_flags;
|
2008-10-13 05:11:42 -04:00
|
|
|
/** true if we set RD bit because of last resort recursion lame query*/
|
|
|
|
|
int chase_to_rd;
|
2007-05-29 10:02:17 -04:00
|
|
|
|
2007-05-23 05:34:01 -04:00
|
|
|
/**
|
|
|
|
|
* This is the current delegation point for an in-progress query. This
|
|
|
|
|
* object retains state as to which delegation targets need to be
|
|
|
|
|
* (sub)queried for vs which ones have already been visited.
|
|
|
|
|
*/
|
|
|
|
|
struct delegpt* dp;
|
|
|
|
|
|
2008-10-06 10:46:22 -04:00
|
|
|
/** state for 0x20 fallback when capsfail happens, 0 not a fallback */
|
|
|
|
|
int caps_fallback;
|
|
|
|
|
/** state for capsfail: current server number to try */
|
|
|
|
|
size_t caps_server;
|
2014-06-24 04:24:28 -04:00
|
|
|
/** state for capsfail: stored query for comparisons. Can be NULL if
|
|
|
|
|
* no response had been seen prior to starting the fallback. */
|
2008-10-06 10:46:22 -04:00
|
|
|
struct reply_info* caps_reply;
|
2015-03-04 04:31:26 -05:00
|
|
|
struct dns_msg* caps_response;
|
2008-10-06 10:46:22 -04:00
|
|
|
|
2007-05-30 10:19:56 -04:00
|
|
|
/** Current delegation message - returned for non-RD queries */
|
|
|
|
|
struct dns_msg* deleg_msg;
|
|
|
|
|
|
2007-05-23 05:34:01 -04:00
|
|
|
/** number of outstanding target sub queries */
|
|
|
|
|
int num_target_queries;
|
|
|
|
|
|
|
|
|
|
/** outstanding direct queries */
|
|
|
|
|
int num_current_queries;
|
|
|
|
|
|
|
|
|
|
/** the number of times this query has been restarted. */
|
|
|
|
|
int query_restart_count;
|
|
|
|
|
|
2022-10-04 16:21:08 -04:00
|
|
|
/** the number of times this query has followed a referral. */
|
2007-05-23 05:34:01 -04:00
|
|
|
int referral_count;
|
|
|
|
|
|
2011-09-16 10:11:12 -04:00
|
|
|
/** number of queries fired off */
|
|
|
|
|
int sent_count;
|
2014-12-08 10:09:18 -05:00
|
|
|
|
2022-06-29 11:31:23 -04:00
|
|
|
/** malloced-array shared with this query and its subqueries. It keeps
|
|
|
|
|
* track of the defined enum target_count_variables counters. */
|
2014-12-08 10:09:18 -05:00
|
|
|
int* target_count;
|
2011-09-16 10:11:12 -04:00
|
|
|
|
2020-05-19 04:27:27 -04:00
|
|
|
/** number of target lookups per delegation point. Reset to 0 after
|
|
|
|
|
* receiving referral answer. Not shared with subqueries. */
|
|
|
|
|
int dp_target_count;
|
|
|
|
|
|
2022-06-29 11:31:23 -04:00
|
|
|
/** Delegation point that triggered the NXNS fallback; shared with
|
|
|
|
|
* this query and its subqueries, count-referenced by the reference
|
|
|
|
|
* counter in target_count.
|
|
|
|
|
* This also marks the fallback activation. */
|
|
|
|
|
uint8_t** nxns_dp;
|
|
|
|
|
|
2015-04-16 10:18:50 -04:00
|
|
|
/** if true, already tested for ratelimiting and passed the test */
|
|
|
|
|
int ratelimit_ok;
|
|
|
|
|
|
2010-05-28 10:15:29 -04:00
|
|
|
/**
|
|
|
|
|
* The query must store NS records from referrals as parentside RRs
|
|
|
|
|
* Enabled once it hits resolution problems, to throttle retries.
|
2010-06-15 05:47:11 -04:00
|
|
|
* If enabled it is the pointer to the old delegation point with
|
|
|
|
|
* the old retry counts for bad-nameserver-addresses.
|
2010-05-28 10:15:29 -04:00
|
|
|
*/
|
2010-06-15 05:47:11 -04:00
|
|
|
struct delegpt* store_parent_NS;
|
2010-05-28 10:15:29 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The query is for parent-side glue(A or AAAA) for a nameserver.
|
|
|
|
|
* If the item is seen as glue in a referral, and pside_glue is NULL,
|
|
|
|
|
* then it is stored in pside_glue for later.
|
|
|
|
|
* If it was never seen, at the end, then a negative caching element
|
|
|
|
|
* must be created.
|
|
|
|
|
* The (data or negative) RR cache element then throttles retries.
|
|
|
|
|
*/
|
|
|
|
|
int query_for_pside_glue;
|
|
|
|
|
/** the parent-side-glue element (NULL if none, its first match) */
|
|
|
|
|
struct ub_packed_rrset_key* pside_glue;
|
|
|
|
|
|
2012-03-21 11:01:01 -04:00
|
|
|
/** If nonNULL we are walking upwards from DS query to find NS */
|
|
|
|
|
uint8_t* dsns_point;
|
|
|
|
|
/** length of the dname in dsns_point */
|
|
|
|
|
size_t dsns_point_len;
|
|
|
|
|
|
2007-10-22 11:25:37 -04:00
|
|
|
/**
|
|
|
|
|
* expected dnssec information for this iteration step.
|
|
|
|
|
* If dnssec rrsigs are expected and not given, the server is marked
|
|
|
|
|
* lame (dnssec-lame).
|
|
|
|
|
*/
|
|
|
|
|
int dnssec_expected;
|
|
|
|
|
|
2010-05-04 04:39:04 -04:00
|
|
|
/**
|
|
|
|
|
* We are expecting dnssec information, but we also know the server
|
|
|
|
|
* is DNSSEC lame. The response need not be marked dnssec-lame again.
|
|
|
|
|
*/
|
|
|
|
|
int dnssec_lame_query;
|
|
|
|
|
|
2007-05-23 05:34:01 -04:00
|
|
|
/**
|
|
|
|
|
* This is flag that, if true, means that this event is
|
2007-08-01 08:59:37 -04:00
|
|
|
* waiting for a stub priming query.
|
2007-05-23 05:34:01 -04:00
|
|
|
*/
|
2007-08-01 08:59:37 -04:00
|
|
|
int wait_priming_stub;
|
2007-05-23 05:34:01 -04:00
|
|
|
|
2007-07-20 05:41:44 -04:00
|
|
|
/**
|
|
|
|
|
* This is a flag that, if true, means that this query is
|
|
|
|
|
* for (re)fetching glue from a zone. Since the address should
|
|
|
|
|
* have been glue, query again to the servers that should have
|
|
|
|
|
* been returning it as glue.
|
2007-07-25 10:12:44 -04:00
|
|
|
* The delegation point must be set to the one that should *not*
|
|
|
|
|
* be used when creating the state. A higher one will be attempted.
|
2007-07-20 05:41:44 -04:00
|
|
|
*/
|
|
|
|
|
int refetch_glue;
|
|
|
|
|
|
2023-10-04 12:16:22 -04:00
|
|
|
/**
|
|
|
|
|
* This flag detects that a completely empty nodata was received,
|
|
|
|
|
* already so that it is accepted later. */
|
|
|
|
|
int empty_nodata_found;
|
|
|
|
|
|
2007-05-22 08:36:02 -04:00
|
|
|
/** list of pending queries to authoritative servers. */
|
|
|
|
|
struct outbound_list outlist;
|
2015-11-30 11:10:26 -05:00
|
|
|
|
2022-01-26 08:35:22 -05:00
|
|
|
/** QNAME minimisation state, RFC9156 */
|
2015-11-30 11:10:26 -05:00
|
|
|
enum minimisation_state minimisation_state;
|
|
|
|
|
|
2018-08-07 08:43:49 -04:00
|
|
|
/** State for capsfail: QNAME minimisation state for comparisons. */
|
|
|
|
|
enum minimisation_state caps_minimisation_state;
|
|
|
|
|
|
2015-11-30 11:10:26 -05:00
|
|
|
/**
|
|
|
|
|
* The query info that is sent upstream. Will be a subset of qchase
|
|
|
|
|
* when qname minimisation is enabled.
|
|
|
|
|
*/
|
|
|
|
|
struct query_info qinfo_out;
|
2016-03-17 10:44:41 -04:00
|
|
|
|
|
|
|
|
/**
|
2017-09-15 10:29:28 -04:00
|
|
|
* Count number of QNAME minimisation iterations. Used to limit number of
|
2016-03-17 10:44:41 -04:00
|
|
|
* outgoing queries when QNAME minimisation is enabled.
|
|
|
|
|
*/
|
|
|
|
|
int minimise_count;
|
2016-06-13 09:06:35 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Count number of time-outs. Used to prevent resolving failures when
|
2020-04-06 12:00:06 -04:00
|
|
|
* the QNAME minimisation QTYPE is blocked. Used to determine if
|
|
|
|
|
* capsforid fallback should be started.*/
|
|
|
|
|
int timeout_count;
|
2018-01-30 10:44:49 -05:00
|
|
|
|
|
|
|
|
/** True if the current response is from auth_zone */
|
|
|
|
|
int auth_zone_response;
|
|
|
|
|
/** True if the auth_zones should not be consulted for the query */
|
|
|
|
|
int auth_zone_avoid;
|
2021-04-29 04:24:35 -04:00
|
|
|
/** true if there have been scrubbing failures of reply packets */
|
|
|
|
|
int scrub_failures;
|
|
|
|
|
/** true if there have been parse failures of reply packets */
|
|
|
|
|
int parse_failures;
|
|
|
|
|
/** a failure printout address for last received answer */
|
2023-08-21 08:32:13 -04:00
|
|
|
union {
|
|
|
|
|
struct in_addr in;
|
|
|
|
|
#ifdef AF_INET6
|
|
|
|
|
struct in6_addr in6;
|
|
|
|
|
#endif
|
|
|
|
|
} fail_addr;
|
|
|
|
|
/** which fail_addr, 0 is nothing, 4 or 6 */
|
|
|
|
|
int fail_addr_type;
|
2007-05-11 10:16:42 -04:00
|
|
|
};
|
|
|
|
|
|
2007-05-30 07:18:17 -04:00
|
|
|
/**
|
|
|
|
|
* List of prepend items
|
|
|
|
|
*/
|
|
|
|
|
struct iter_prep_list {
|
|
|
|
|
/** next in list */
|
|
|
|
|
struct iter_prep_list* next;
|
|
|
|
|
/** rrset */
|
|
|
|
|
struct ub_packed_rrset_key* rrset;
|
|
|
|
|
};
|
|
|
|
|
|
2007-05-11 10:16:42 -04:00
|
|
|
/**
|
|
|
|
|
* Get the iterator function block.
|
2007-05-24 09:24:44 -04:00
|
|
|
* @return: function block with function pointers to iterator methods.
|
2007-05-11 10:16:42 -04:00
|
|
|
*/
|
2010-07-07 09:13:36 -04:00
|
|
|
struct module_func_block* iter_get_funcblock(void);
|
2007-05-11 10:16:42 -04:00
|
|
|
|
2007-05-23 10:05:36 -04:00
|
|
|
/**
|
|
|
|
|
* Get iterator state as a string
|
|
|
|
|
* @param state: to convert
|
|
|
|
|
* @return constant string that is printable.
|
|
|
|
|
*/
|
|
|
|
|
const char* iter_state_to_string(enum iter_state state);
|
|
|
|
|
|
2007-05-25 11:28:20 -04:00
|
|
|
/**
|
|
|
|
|
* See if iterator state is a response state
|
|
|
|
|
* @param s: to inspect
|
|
|
|
|
* @return true if response state.
|
|
|
|
|
*/
|
|
|
|
|
int iter_state_is_responsestate(enum iter_state s);
|
|
|
|
|
|
2007-10-05 08:42:25 -04:00
|
|
|
/** iterator init */
|
|
|
|
|
int iter_init(struct module_env* env, int id);
|
|
|
|
|
|
|
|
|
|
/** iterator deinit */
|
|
|
|
|
void iter_deinit(struct module_env* env, int id);
|
|
|
|
|
|
|
|
|
|
/** iterator operate on a query */
|
|
|
|
|
void iter_operate(struct module_qstate* qstate, enum module_ev event, int id,
|
|
|
|
|
struct outbound_entry* outbound);
|
|
|
|
|
|
|
|
|
|
/**
|
2017-09-15 10:29:28 -04:00
|
|
|
* Return priming query results to interested super querystates.
|
2007-10-05 08:42:25 -04:00
|
|
|
*
|
|
|
|
|
* Sets the delegation point and delegation message (not nonRD queries).
|
|
|
|
|
* This is a callback from walk_supers.
|
|
|
|
|
*
|
|
|
|
|
* @param qstate: query state that finished.
|
|
|
|
|
* @param id: module id.
|
|
|
|
|
* @param super: the qstate to inform.
|
|
|
|
|
*/
|
|
|
|
|
void iter_inform_super(struct module_qstate* qstate, int id,
|
|
|
|
|
struct module_qstate* super);
|
|
|
|
|
|
|
|
|
|
/** iterator cleanup query state */
|
|
|
|
|
void iter_clear(struct module_qstate* qstate, int id);
|
|
|
|
|
|
|
|
|
|
/** iterator alloc size routine */
|
|
|
|
|
size_t iter_get_mem(struct module_env* env, int id);
|
|
|
|
|
|
2007-05-11 10:16:42 -04:00
|
|
|
#endif /* ITERATOR_ITERATOR_H */
|