2007-06-21 11:36:13 -04:00
|
|
|
/*
|
|
|
|
|
* services/mesh.h - deal with mesh of query states and handle events for that.
|
|
|
|
|
*
|
|
|
|
|
* 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-06-21 11:36:13 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \file
|
|
|
|
|
*
|
|
|
|
|
* This file contains functions to assist in dealing with a mesh of
|
|
|
|
|
* query states. This mesh is supposed to be thread-specific.
|
|
|
|
|
* It consists of query states (per qname, qtype, qclass) and connections
|
|
|
|
|
* between query states and the super and subquery states, and replies to
|
|
|
|
|
* send back to clients.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef SERVICES_MESH_H
|
|
|
|
|
#define SERVICES_MESH_H
|
|
|
|
|
|
|
|
|
|
#include "util/rbtree.h"
|
|
|
|
|
#include "util/netevent.h"
|
|
|
|
|
#include "util/data/msgparse.h"
|
2007-06-22 08:39:08 -04:00
|
|
|
#include "util/module.h"
|
2007-12-04 08:23:41 -05:00
|
|
|
#include "services/modstack.h"
|
2019-08-01 08:31:37 -04:00
|
|
|
#include "services/rpz.h"
|
2019-12-23 10:02:43 -05:00
|
|
|
#include "libunbound/unbound.h"
|
2013-12-03 04:11:16 -05:00
|
|
|
struct sldns_buffer;
|
2007-06-21 11:36:13 -04:00
|
|
|
struct mesh_state;
|
|
|
|
|
struct mesh_reply;
|
2007-12-06 10:11:07 -05:00
|
|
|
struct mesh_cb;
|
2007-06-21 11:36:13 -04:00
|
|
|
struct query_info;
|
|
|
|
|
struct reply_info;
|
2007-06-22 06:09:21 -04:00
|
|
|
struct outbound_entry;
|
2007-06-27 10:59:44 -04:00
|
|
|
struct timehist;
|
2017-03-07 09:58:51 -05:00
|
|
|
struct respip_client_info;
|
2007-06-21 11:36:13 -04:00
|
|
|
|
2007-10-03 04:36:47 -04:00
|
|
|
/**
|
|
|
|
|
* Maximum number of mesh state activations. Any more is likely an
|
|
|
|
|
* infinite loop in the module. It is then terminated.
|
|
|
|
|
*/
|
2019-01-17 03:58:09 -05:00
|
|
|
#define MESH_MAX_ACTIVATION 10000
|
2007-10-03 04:36:47 -04:00
|
|
|
|
2010-06-10 10:10:17 -04:00
|
|
|
/**
|
|
|
|
|
* Max number of references-to-references-to-references.. search size.
|
|
|
|
|
* Any more is treated like 'too large', and the creation of a new
|
|
|
|
|
* dependency is failed (so that no loops can be created).
|
|
|
|
|
*/
|
|
|
|
|
#define MESH_MAX_SUBSUB 1024
|
|
|
|
|
|
2007-06-21 11:36:13 -04:00
|
|
|
/**
|
|
|
|
|
* Mesh of query states
|
|
|
|
|
*/
|
2007-06-22 06:09:21 -04:00
|
|
|
struct mesh_area {
|
2007-12-04 08:23:41 -05:00
|
|
|
/** active module stack */
|
|
|
|
|
struct module_stack mods;
|
2007-06-25 09:54:03 -04:00
|
|
|
/** environment for new states */
|
|
|
|
|
struct module_env* env;
|
2007-06-22 08:39:08 -04:00
|
|
|
|
2007-06-22 06:09:21 -04:00
|
|
|
/** set of runnable queries (mesh_state.run_node) */
|
2017-01-19 05:25:41 -05:00
|
|
|
rbtree_type run;
|
2007-06-22 06:09:21 -04:00
|
|
|
/** rbtree of all current queries (mesh_state.node)*/
|
2017-01-19 05:25:41 -05:00
|
|
|
rbtree_type all;
|
2007-06-22 06:09:21 -04:00
|
|
|
|
2024-10-29 10:21:52 -04:00
|
|
|
/** number of queries for unbound's auth_zones, upstream query */
|
|
|
|
|
size_t num_query_authzone_up;
|
|
|
|
|
/** number of queries for unbound's auth_zones, downstream answers */
|
|
|
|
|
size_t num_query_authzone_down;
|
|
|
|
|
|
2007-06-22 06:09:21 -04:00
|
|
|
/** count of the total number of mesh_reply entries */
|
|
|
|
|
size_t num_reply_addrs;
|
|
|
|
|
/** count of the number of mesh_states that have mesh_replies
|
|
|
|
|
* Because a state can send results to multiple reply addresses,
|
|
|
|
|
* this number must be equal or lower than num_reply_addrs. */
|
|
|
|
|
size_t num_reply_states;
|
|
|
|
|
/** number of mesh_states that have no mesh_replies, and also
|
|
|
|
|
* an empty set of super-states, thus are 'toplevel' or detached
|
|
|
|
|
* internal opportunistic queries */
|
|
|
|
|
size_t num_detached_states;
|
2008-09-02 09:04:47 -04:00
|
|
|
/** number of reply states in the forever list */
|
|
|
|
|
size_t num_forever_states;
|
|
|
|
|
|
|
|
|
|
/** max total number of reply states to have */
|
|
|
|
|
size_t max_reply_states;
|
|
|
|
|
/** max forever number of reply states to have */
|
|
|
|
|
size_t max_forever_states;
|
|
|
|
|
|
|
|
|
|
/** stats, cumulative number of reply states jostled out */
|
|
|
|
|
size_t stats_jostled;
|
|
|
|
|
/** stats, cumulative number of incoming client msgs dropped */
|
|
|
|
|
size_t stats_dropped;
|
2020-02-05 08:20:27 -05:00
|
|
|
/** stats, number of expired replies sent */
|
|
|
|
|
size_t ans_expired;
|
2023-05-30 11:49:50 -04:00
|
|
|
/** stats, number of cached replies from cachedb */
|
|
|
|
|
size_t ans_cachedb;
|
2007-06-25 09:54:03 -04:00
|
|
|
/** number of replies sent */
|
|
|
|
|
size_t replies_sent;
|
|
|
|
|
/** sum of waiting times for the replies */
|
|
|
|
|
struct timeval replies_sum_wait;
|
2007-06-27 10:59:44 -04:00
|
|
|
/** histogram of time values */
|
|
|
|
|
struct timehist* histogram;
|
2008-09-16 10:08:38 -04:00
|
|
|
/** (extended stats) secure replies */
|
|
|
|
|
size_t ans_secure;
|
|
|
|
|
/** (extended stats) bogus replies */
|
|
|
|
|
size_t ans_bogus;
|
2025-07-12 10:29:38 -04:00
|
|
|
/** (extended stats) number of validation operations */
|
|
|
|
|
size_t val_ops;
|
2008-09-16 10:08:38 -04:00
|
|
|
/** (extended stats) rcodes in replies */
|
2019-12-23 10:02:43 -05:00
|
|
|
size_t ans_rcode[UB_STATS_RCODE_NUM];
|
2008-09-16 10:08:38 -04:00
|
|
|
/** (extended stats) rcode nodata in replies */
|
|
|
|
|
size_t ans_nodata;
|
2019-08-01 08:31:37 -04:00
|
|
|
/** (extended stats) type of applied RPZ action */
|
2019-12-23 10:02:43 -05:00
|
|
|
size_t rpz_action[UB_STATS_RPZ_ACTION_NUM];
|
2024-11-01 10:52:58 -04:00
|
|
|
/** stats, number of queries removed due to discard-timeout */
|
|
|
|
|
size_t num_queries_discard_timeout;
|
|
|
|
|
/** stats, number of queries removed due to wait-limit */
|
|
|
|
|
size_t num_queries_wait_limit;
|
2025-04-07 04:25:10 -04:00
|
|
|
/** stats, number of dns error reports generated */
|
|
|
|
|
size_t num_dns_error_reports;
|
2008-09-02 09:04:47 -04:00
|
|
|
|
2011-10-24 09:49:59 -04:00
|
|
|
/** backup of query if other operations recurse and need the
|
|
|
|
|
* network buffers */
|
2013-12-03 04:11:16 -05:00
|
|
|
struct sldns_buffer* qbuf_bak;
|
2011-10-24 09:49:59 -04:00
|
|
|
|
2008-09-02 09:04:47 -04:00
|
|
|
/** double linked list of the run-to-completion query states.
|
|
|
|
|
* These are query states with a reply */
|
|
|
|
|
struct mesh_state* forever_first;
|
|
|
|
|
/** last entry in run forever list */
|
|
|
|
|
struct mesh_state* forever_last;
|
|
|
|
|
|
|
|
|
|
/** double linked list of the query states that can be jostled out
|
|
|
|
|
* by new queries if too old. These are query states with a reply */
|
|
|
|
|
struct mesh_state* jostle_first;
|
|
|
|
|
/** last entry in jostle list - this is the entry that is newest */
|
|
|
|
|
struct mesh_state* jostle_last;
|
2008-10-06 05:28:50 -04:00
|
|
|
/** timeout for jostling. if age is lower, it does not get jostled. */
|
|
|
|
|
struct timeval jostle_max;
|
2020-02-05 08:20:27 -05:00
|
|
|
|
|
|
|
|
/** If we need to use response ip (value passed from daemon)*/
|
|
|
|
|
int use_response_ip;
|
|
|
|
|
/** If we need to use RPZ (value passed from daemon) */
|
|
|
|
|
int use_rpz;
|
2007-06-21 11:36:13 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A mesh query state
|
2007-06-22 06:09:21 -04:00
|
|
|
* Unique per qname, qtype, qclass (from the qstate).
|
2007-08-01 07:17:30 -04:00
|
|
|
* And RD / CD flag; in case a client turns it off.
|
2007-06-21 11:36:13 -04:00
|
|
|
* And priming queries are different from ordinary queries (because of hints).
|
2007-06-22 06:09:21 -04:00
|
|
|
*
|
|
|
|
|
* The entire structure is allocated in a region, this region is the qstate
|
|
|
|
|
* region. All parts (rbtree nodes etc) are also allocated in the region.
|
2007-06-21 11:36:13 -04:00
|
|
|
*/
|
|
|
|
|
struct mesh_state {
|
2007-06-22 08:39:08 -04:00
|
|
|
/** node in mesh_area all tree, key is this struct. Must be first. */
|
2017-01-19 05:25:41 -05:00
|
|
|
rbnode_type node;
|
2007-06-22 06:09:21 -04:00
|
|
|
/** node in mesh_area runnable tree, key is this struct */
|
2017-01-19 05:25:41 -05:00
|
|
|
rbnode_type run_node;
|
2007-06-22 06:09:21 -04:00
|
|
|
/** the query state. Note that the qinfo and query_flags
|
|
|
|
|
* may not change. */
|
2007-06-22 08:39:08 -04:00
|
|
|
struct module_qstate s;
|
2007-06-21 11:36:13 -04:00
|
|
|
/** the list of replies to clients for the results */
|
|
|
|
|
struct mesh_reply* reply_list;
|
2007-12-06 10:11:07 -05:00
|
|
|
/** the list of callbacks for the results */
|
|
|
|
|
struct mesh_cb* cb_list;
|
2007-06-21 11:36:13 -04:00
|
|
|
/** set of superstates (that want this state's result)
|
|
|
|
|
* contains struct mesh_state_ref* */
|
2017-01-19 05:25:41 -05:00
|
|
|
rbtree_type super_set;
|
2007-06-21 11:36:13 -04:00
|
|
|
/** set of substates (that this state needs to continue)
|
|
|
|
|
* contains struct mesh_state_ref* */
|
2017-01-19 05:25:41 -05:00
|
|
|
rbtree_type sub_set;
|
2007-10-03 04:36:47 -04:00
|
|
|
/** number of activations for the mesh state */
|
|
|
|
|
size_t num_activated;
|
2008-09-02 09:04:47 -04:00
|
|
|
|
|
|
|
|
/** previous in linked list for reply states */
|
|
|
|
|
struct mesh_state* prev;
|
|
|
|
|
/** next in linked list for reply states */
|
|
|
|
|
struct mesh_state* next;
|
|
|
|
|
/** if this state is in the forever list, jostle list, or neither */
|
|
|
|
|
enum mesh_list_select { mesh_no_list, mesh_forever_list,
|
|
|
|
|
mesh_jostle_list } list_select;
|
2016-12-06 08:42:51 -05:00
|
|
|
/** pointer to this state for uniqueness or NULL */
|
|
|
|
|
struct mesh_state* unique;
|
2008-11-05 05:38:22 -05:00
|
|
|
|
|
|
|
|
/** true if replies have been sent out (at end for alignment) */
|
|
|
|
|
uint8_t replies_sent;
|
2007-06-21 11:36:13 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Rbtree reference to a mesh_state.
|
|
|
|
|
* Used in super_set and sub_set.
|
|
|
|
|
*/
|
|
|
|
|
struct mesh_state_ref {
|
|
|
|
|
/** node in rbtree for set, key is this structure */
|
2017-01-19 05:25:41 -05:00
|
|
|
rbnode_type node;
|
2007-06-21 11:36:13 -04:00
|
|
|
/** the mesh state */
|
|
|
|
|
struct mesh_state* s;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reply to a client
|
|
|
|
|
*/
|
|
|
|
|
struct mesh_reply {
|
|
|
|
|
/** next in reply list */
|
|
|
|
|
struct mesh_reply* next;
|
|
|
|
|
/** the query reply destination, packet buffer and where to send. */
|
|
|
|
|
struct comm_reply query_reply;
|
|
|
|
|
/** edns data from query */
|
|
|
|
|
struct edns_data edns;
|
2007-06-22 06:09:21 -04:00
|
|
|
/** the time when request was entered */
|
|
|
|
|
struct timeval start_time;
|
2007-06-21 11:36:13 -04:00
|
|
|
/** id of query, in network byteorder. */
|
|
|
|
|
uint16_t qid;
|
|
|
|
|
/** flags of query, for reply flags */
|
|
|
|
|
uint16_t qflags;
|
2008-02-26 15:45:20 -05:00
|
|
|
/** qname from this query. len same as mesh qinfo. */
|
|
|
|
|
uint8_t* qname;
|
2016-10-18 09:18:20 -04:00
|
|
|
/** same as that in query_info. */
|
|
|
|
|
struct local_rrset* local_alias;
|
2020-05-07 10:36:26 -04:00
|
|
|
/** send query to this http2 stream, if set */
|
|
|
|
|
struct http2_stream* h2_stream;
|
2007-06-21 11:36:13 -04:00
|
|
|
};
|
|
|
|
|
|
2007-12-06 10:11:07 -05:00
|
|
|
/**
|
|
|
|
|
* Mesh result callback func.
|
2018-08-03 10:00:46 -04:00
|
|
|
* called as func(cb_arg, rcode, buffer_with_reply, security, why_bogus,
|
|
|
|
|
* was_ratelimited);
|
2009-10-08 13:05:53 -04:00
|
|
|
*/
|
2018-08-03 10:00:46 -04:00
|
|
|
typedef void (*mesh_cb_func_type)(void* cb_arg, int rcode, struct sldns_buffer*,
|
|
|
|
|
enum sec_status, char* why_bogus, int was_ratelimited);
|
2007-12-06 10:11:07 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Callback to result routine
|
|
|
|
|
*/
|
|
|
|
|
struct mesh_cb {
|
|
|
|
|
/** next in list */
|
|
|
|
|
struct mesh_cb* next;
|
|
|
|
|
/** edns data from query */
|
|
|
|
|
struct edns_data edns;
|
|
|
|
|
/** id of query, in network byteorder. */
|
|
|
|
|
uint16_t qid;
|
|
|
|
|
/** flags of query, for reply flags */
|
|
|
|
|
uint16_t qflags;
|
|
|
|
|
/** buffer for reply */
|
2013-12-03 04:11:16 -05:00
|
|
|
struct sldns_buffer* buf;
|
2007-12-06 10:11:07 -05:00
|
|
|
/** callback routine for results. if rcode != 0 buf has message.
|
2018-08-03 10:00:46 -04:00
|
|
|
* called as cb(cb_arg, rcode, buf, sec_state, why_bogus, was_ratelimited);
|
2007-12-06 10:11:07 -05:00
|
|
|
*/
|
2017-01-19 05:25:41 -05:00
|
|
|
mesh_cb_func_type cb;
|
2007-12-06 10:11:07 -05:00
|
|
|
/** user arg for callback */
|
|
|
|
|
void* cb_arg;
|
|
|
|
|
};
|
|
|
|
|
|
2007-06-22 06:09:21 -04:00
|
|
|
/* ------------------- Functions for worker -------------------- */
|
|
|
|
|
|
2007-06-21 11:36:13 -04:00
|
|
|
/**
|
|
|
|
|
* Allocate mesh, to empty.
|
2007-12-04 08:23:41 -05:00
|
|
|
* @param stack: module stack to activate, copied (as readonly reference).
|
2007-06-25 09:54:03 -04:00
|
|
|
* @param env: environment for new queries.
|
2007-06-21 11:36:13 -04:00
|
|
|
* @return mesh: the new mesh or NULL on error.
|
|
|
|
|
*/
|
2007-12-04 08:23:41 -05:00
|
|
|
struct mesh_area* mesh_create(struct module_stack* stack,
|
|
|
|
|
struct module_env* env);
|
2007-06-21 11:36:13 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete mesh, and all query states and replies in it.
|
|
|
|
|
* @param mesh: the mesh to delete.
|
|
|
|
|
*/
|
2007-06-22 06:09:21 -04:00
|
|
|
void mesh_delete(struct mesh_area* mesh);
|
2007-06-21 11:36:13 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* New query incoming from clients. Create new query state if needed, and
|
|
|
|
|
* add mesh_reply to it. Returns error to client on malloc failures.
|
2007-06-22 06:09:21 -04:00
|
|
|
* Will run the mesh area queries to process if a new query state is created.
|
|
|
|
|
*
|
2007-06-21 11:36:13 -04:00
|
|
|
* @param mesh: the mesh.
|
|
|
|
|
* @param qinfo: query from client.
|
2017-03-07 09:58:51 -05:00
|
|
|
* @param cinfo: additional information associated with the query client.
|
|
|
|
|
* 'cinfo' itself is ephemeral but data pointed to by its members
|
|
|
|
|
* can be assumed to be valid and unchanged until the query processing is
|
|
|
|
|
* completed.
|
2007-06-21 11:36:13 -04:00
|
|
|
* @param qflags: flags from client query.
|
|
|
|
|
* @param edns: edns data from client query.
|
|
|
|
|
* @param rep: where to reply to.
|
2007-06-22 06:09:21 -04:00
|
|
|
* @param qid: query id to reply with.
|
2022-02-15 10:20:12 -05:00
|
|
|
* @param rpz_passthru: if true, the rpz passthru was previously found and
|
|
|
|
|
* further rpz processing is stopped.
|
2007-06-21 11:36:13 -04:00
|
|
|
*/
|
2007-06-22 06:09:21 -04:00
|
|
|
void mesh_new_client(struct mesh_area* mesh, struct query_info* qinfo,
|
2017-03-07 09:58:51 -05:00
|
|
|
struct respip_client_info* cinfo, uint16_t qflags,
|
2022-02-15 10:20:12 -05:00
|
|
|
struct edns_data* edns, struct comm_reply* rep, uint16_t qid,
|
|
|
|
|
int rpz_passthru);
|
2007-06-22 06:09:21 -04:00
|
|
|
|
2007-12-06 10:11:07 -05:00
|
|
|
/**
|
|
|
|
|
* New query with callback. Create new query state if needed, and
|
|
|
|
|
* add mesh_cb to it.
|
|
|
|
|
* Will run the mesh area queries to process if a new query state is created.
|
|
|
|
|
*
|
|
|
|
|
* @param mesh: the mesh.
|
|
|
|
|
* @param qinfo: query from client.
|
|
|
|
|
* @param qflags: flags from client query.
|
|
|
|
|
* @param edns: edns data from client query.
|
|
|
|
|
* @param buf: buffer for reply contents.
|
|
|
|
|
* @param qid: query id to reply with.
|
|
|
|
|
* @param cb: callback function.
|
|
|
|
|
* @param cb_arg: callback user arg.
|
2022-02-15 10:20:12 -05:00
|
|
|
* @param rpz_passthru: if true, the rpz passthru was previously found and
|
|
|
|
|
* further rpz processing is stopped.
|
2007-12-06 10:11:07 -05:00
|
|
|
* @return 0 on error.
|
|
|
|
|
*/
|
|
|
|
|
int mesh_new_callback(struct mesh_area* mesh, struct query_info* qinfo,
|
2013-12-03 04:11:16 -05:00
|
|
|
uint16_t qflags, struct edns_data* edns, struct sldns_buffer* buf,
|
2022-02-15 10:20:12 -05:00
|
|
|
uint16_t qid, mesh_cb_func_type cb, void* cb_arg, int rpz_passthru);
|
2007-12-06 10:11:07 -05:00
|
|
|
|
2010-01-07 09:38:18 -05:00
|
|
|
/**
|
|
|
|
|
* New prefetch message. Create new query state if needed.
|
|
|
|
|
* Will run the mesh area queries to process if a new query state is created.
|
|
|
|
|
*
|
|
|
|
|
* @param mesh: the mesh.
|
|
|
|
|
* @param qinfo: query from client.
|
|
|
|
|
* @param qflags: flags from client query.
|
2010-01-08 10:59:36 -05:00
|
|
|
* @param leeway: TTL leeway what to expire earlier for this update.
|
2022-02-15 10:20:12 -05:00
|
|
|
* @param rpz_passthru: if true, the rpz passthru was previously found and
|
|
|
|
|
* further rpz processing is stopped.
|
2023-07-06 15:57:27 -04:00
|
|
|
* @param addr: sockaddr_storage for the client; to be used with subnet.
|
2021-02-17 07:39:15 -05:00
|
|
|
* @param opt_list: edns opt_list from the client; to be used when subnet is
|
|
|
|
|
* enabled.
|
2010-01-07 09:38:18 -05:00
|
|
|
*/
|
|
|
|
|
void mesh_new_prefetch(struct mesh_area* mesh, struct query_info* qinfo,
|
2021-02-17 07:39:15 -05:00
|
|
|
uint16_t qflags, time_t leeway, int rpz_passthru,
|
2023-07-06 15:57:27 -04:00
|
|
|
struct sockaddr_storage* addr, struct edns_option* opt_list);
|
2010-01-07 09:38:18 -05:00
|
|
|
|
2007-06-22 06:09:21 -04:00
|
|
|
/**
|
|
|
|
|
* Handle new event from the wire. A serviced query has returned.
|
|
|
|
|
* The query state will be made runnable, and the mesh_area will process
|
|
|
|
|
* query states until processing is complete.
|
|
|
|
|
*
|
|
|
|
|
* @param mesh: the query mesh.
|
|
|
|
|
* @param e: outbound entry, with query state to run and reply pointer.
|
|
|
|
|
* @param reply: the comm point reply info.
|
2008-10-06 10:46:22 -04:00
|
|
|
* @param what: NETEVENT_* error code (if not 0, what is wrong, TIMEOUT).
|
2007-06-22 06:09:21 -04:00
|
|
|
*/
|
|
|
|
|
void mesh_report_reply(struct mesh_area* mesh, struct outbound_entry* e,
|
2008-10-06 10:46:22 -04:00
|
|
|
struct comm_reply* reply, int what);
|
2007-06-22 06:09:21 -04:00
|
|
|
|
|
|
|
|
/* ------------------- Functions for module environment --------------- */
|
2007-06-21 11:36:13 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Detach-subqueries.
|
|
|
|
|
* Remove all sub-query references from this query state.
|
2007-06-25 09:54:03 -04:00
|
|
|
* Keeps super-references of those sub-queries correct.
|
|
|
|
|
* Updates stat items in mesh_area structure.
|
2007-06-21 11:36:13 -04:00
|
|
|
* @param qstate: used to find mesh state.
|
|
|
|
|
*/
|
|
|
|
|
void mesh_detach_subs(struct module_qstate* qstate);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Attach subquery.
|
|
|
|
|
* Creates it if it does not exist already.
|
|
|
|
|
* Keeps sub and super references correct.
|
2010-06-10 10:10:17 -04:00
|
|
|
* Performs a cycle detection - for double check - and fails if there is one.
|
|
|
|
|
* Also fails if the sub-sub-references become too large.
|
2007-06-25 09:54:03 -04:00
|
|
|
* Updates stat items in mesh_area structure.
|
2007-06-21 11:36:13 -04:00
|
|
|
* Pass if it is priming query or not.
|
|
|
|
|
* return:
|
|
|
|
|
* o if error (malloc) happened.
|
|
|
|
|
* o need to initialise the new state (module init; it is a new state).
|
|
|
|
|
* so that the next run of the query with this module is successful.
|
|
|
|
|
* o no init needed, attachment successful.
|
|
|
|
|
*
|
|
|
|
|
* @param qstate: the state to find mesh state, and that wants to receive
|
|
|
|
|
* the results from the new subquery.
|
|
|
|
|
* @param qinfo: what to query for (copied).
|
2025-09-30 05:28:15 -04:00
|
|
|
* @param cinfo: if non-NULL client specific info that may affect IP-based
|
|
|
|
|
* actions that apply to the query result. It is copied.
|
2007-08-01 07:17:30 -04:00
|
|
|
* @param qflags: what flags to use (RD / CD flag or not).
|
2007-06-22 06:09:21 -04:00
|
|
|
* @param prime: if it is a (stub) priming query.
|
2014-11-18 10:15:57 -05:00
|
|
|
* @param valrec: if it is a validation recursion query (lookup of key, DS).
|
2007-06-21 11:36:13 -04:00
|
|
|
* @param newq: If the new subquery needs initialisation, it is returned,
|
|
|
|
|
* otherwise NULL is returned.
|
|
|
|
|
* @return: false on error, true if success (and init may be needed).
|
|
|
|
|
*/
|
|
|
|
|
int mesh_attach_sub(struct module_qstate* qstate, struct query_info* qinfo,
|
2025-09-30 05:28:15 -04:00
|
|
|
struct respip_client_info* cinfo, uint16_t qflags, int prime,
|
|
|
|
|
int valrec, struct module_qstate** newq);
|
2007-06-21 11:36:13 -04:00
|
|
|
|
2017-05-02 09:17:56 -04:00
|
|
|
/**
|
|
|
|
|
* Add detached query.
|
|
|
|
|
* Creates it if it does not exist already.
|
|
|
|
|
* Does not make super/sub references.
|
|
|
|
|
* Performs a cycle detection - for double check - and fails if there is one.
|
|
|
|
|
* Updates stat items in mesh_area structure.
|
|
|
|
|
* Pass if it is priming query or not.
|
|
|
|
|
* return:
|
|
|
|
|
* o if error (malloc) happened.
|
|
|
|
|
* o need to initialise the new state (module init; it is a new state).
|
|
|
|
|
* so that the next run of the query with this module is successful.
|
|
|
|
|
* o no init needed, attachment successful.
|
|
|
|
|
* o added subquery, created if it did not exist already.
|
|
|
|
|
*
|
|
|
|
|
* @param qstate: the state to find mesh state, and that wants to receive
|
|
|
|
|
* the results from the new subquery.
|
|
|
|
|
* @param qinfo: what to query for (copied).
|
2025-09-30 05:28:15 -04:00
|
|
|
* @param cinfo: if non-NULL client specific info that may affect IP-based
|
|
|
|
|
* actions that apply to the query result. It is copied.
|
2017-05-02 09:17:56 -04:00
|
|
|
* @param qflags: what flags to use (RD / CD flag or not).
|
|
|
|
|
* @param prime: if it is a (stub) priming query.
|
|
|
|
|
* @param valrec: if it is a validation recursion query (lookup of key, DS).
|
|
|
|
|
* @param newq: If the new subquery needs initialisation, it is returned,
|
|
|
|
|
* otherwise NULL is returned.
|
|
|
|
|
* @param sub: The added mesh state, created if it did not exist already.
|
|
|
|
|
* @return: false on error, true if success (and init may be needed).
|
|
|
|
|
*/
|
|
|
|
|
int mesh_add_sub(struct module_qstate* qstate, struct query_info* qinfo,
|
2025-09-30 05:28:15 -04:00
|
|
|
struct respip_client_info* cinfo, uint16_t qflags, int prime,
|
|
|
|
|
int valrec, struct module_qstate** newq, struct mesh_state** sub);
|
2017-05-02 09:17:56 -04:00
|
|
|
|
2007-06-21 11:36:13 -04:00
|
|
|
/**
|
|
|
|
|
* Query state is done, send messages to reply entries.
|
|
|
|
|
* Encode messages using reply entry values and the querystate (with original
|
|
|
|
|
* qinfo), using given reply_info.
|
|
|
|
|
* Pass errcode != 0 if an error reply is needed.
|
|
|
|
|
* If no reply entries, nothing is done.
|
|
|
|
|
* Must be called before a module can module_finished or return module_error.
|
|
|
|
|
* The module must handle the super query states itself as well.
|
|
|
|
|
*
|
2007-08-02 05:58:24 -04:00
|
|
|
* @param mstate: mesh state that is done. return_rcode and return_msg
|
|
|
|
|
* are used for replies.
|
|
|
|
|
* return_rcode: if not 0 (NOERROR) an error is sent back (and
|
|
|
|
|
* return_msg is ignored).
|
|
|
|
|
* return_msg: reply to encode and send back to clients.
|
2007-06-21 11:36:13 -04:00
|
|
|
*/
|
2007-08-02 05:58:24 -04:00
|
|
|
void mesh_query_done(struct mesh_state* mstate);
|
2007-06-21 11:36:13 -04:00
|
|
|
|
|
|
|
|
/**
|
2007-08-02 04:07:50 -04:00
|
|
|
* Call inform_super for the super query states that are interested in the
|
2007-06-21 11:36:13 -04:00
|
|
|
* results from this query state. These can then be changed for error
|
|
|
|
|
* or results.
|
2007-08-02 04:07:50 -04:00
|
|
|
* Called when a module is module_finished or returns module_error.
|
2011-10-17 09:11:58 -04:00
|
|
|
* The super query states become runnable with event module_event_pass,
|
|
|
|
|
* it calls the current module for the super with the inform_super event.
|
2007-06-21 11:36:13 -04:00
|
|
|
*
|
2007-08-02 08:22:29 -04:00
|
|
|
* @param mesh: mesh area to add newly runnable modules to.
|
|
|
|
|
* @param mstate: the state that has results, used to find mesh state.
|
2007-06-21 11:36:13 -04:00
|
|
|
*/
|
2007-08-02 08:22:29 -04:00
|
|
|
void mesh_walk_supers(struct mesh_area* mesh, struct mesh_state* mstate);
|
2007-06-21 11:36:13 -04:00
|
|
|
|
2007-06-26 09:06:44 -04:00
|
|
|
/**
|
|
|
|
|
* Delete mesh state, cleanup and also rbtrees and so on.
|
|
|
|
|
* Will detach from all super/subnodes.
|
|
|
|
|
* @param qstate: to remove.
|
|
|
|
|
*/
|
|
|
|
|
void mesh_state_delete(struct module_qstate* qstate);
|
|
|
|
|
|
2007-06-22 06:09:21 -04:00
|
|
|
/* ------------------- Functions for mesh -------------------- */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create and initialize a new mesh state and its query state
|
2007-06-22 08:39:08 -04:00
|
|
|
* Does not put the mesh state into rbtrees and so on.
|
|
|
|
|
* @param env: module environment to set.
|
|
|
|
|
* @param qinfo: query info that the mesh is for.
|
2017-03-07 09:58:51 -05:00
|
|
|
* @param cinfo: control info for the query client (can be NULL).
|
2007-08-01 07:17:30 -04:00
|
|
|
* @param qflags: flags for query (RD / CD flag).
|
2007-06-22 08:39:08 -04:00
|
|
|
* @param prime: if true, it is a priming query, set is_priming on mesh state.
|
2014-11-18 10:15:57 -05:00
|
|
|
* @param valrec: if true, it is a validation recursion query, and sets
|
|
|
|
|
* is_valrec on the mesh state.
|
2007-06-22 08:39:08 -04:00
|
|
|
* @return: new mesh state or NULL on allocation error.
|
2007-06-22 06:09:21 -04:00
|
|
|
*/
|
2017-03-07 09:58:51 -05:00
|
|
|
struct mesh_state* mesh_state_create(struct module_env* env,
|
|
|
|
|
struct query_info* qinfo, struct respip_client_info* cinfo,
|
|
|
|
|
uint16_t qflags, int prime, int valrec);
|
2007-06-22 06:09:21 -04:00
|
|
|
|
2016-12-06 08:42:51 -05:00
|
|
|
/**
|
|
|
|
|
* Make a mesh state unique.
|
|
|
|
|
* A unique mesh state uses it's unique member to point to itself.
|
|
|
|
|
* @param mstate: mesh state to check.
|
|
|
|
|
*/
|
|
|
|
|
void mesh_state_make_unique(struct mesh_state* mstate);
|
|
|
|
|
|
2007-06-22 06:09:21 -04:00
|
|
|
/**
|
|
|
|
|
* Cleanup a mesh state and its query state. Does not do rbtree or
|
|
|
|
|
* reference cleanup.
|
2007-06-22 08:39:08 -04:00
|
|
|
* @param mstate: mesh state to cleanup. Its pointer may no longer be used
|
|
|
|
|
* afterwards. Cleanup rbtrees before calling this function.
|
2007-06-22 06:09:21 -04:00
|
|
|
*/
|
2007-06-22 08:39:08 -04:00
|
|
|
void mesh_state_cleanup(struct mesh_state* mstate);
|
2007-06-22 06:09:21 -04:00
|
|
|
|
2009-02-12 08:21:19 -05:00
|
|
|
/**
|
|
|
|
|
* Delete all mesh states from the mesh.
|
|
|
|
|
* @param mesh: the mesh area to clear
|
|
|
|
|
*/
|
|
|
|
|
void mesh_delete_all(struct mesh_area* mesh);
|
|
|
|
|
|
2007-06-25 09:54:03 -04:00
|
|
|
/**
|
|
|
|
|
* Find a mesh state in the mesh area. Pass relevant flags.
|
|
|
|
|
*
|
|
|
|
|
* @param mesh: the mesh area to look in.
|
2017-03-07 09:58:51 -05:00
|
|
|
* @param cinfo: if non-NULL client specific info that may affect IP-based
|
|
|
|
|
* actions that apply to the query result.
|
2007-06-25 09:54:03 -04:00
|
|
|
* @param qinfo: what query
|
2007-08-01 07:17:30 -04:00
|
|
|
* @param qflags: if RD / CD bit is set or not.
|
2007-06-25 09:54:03 -04:00
|
|
|
* @param prime: if it is a priming query.
|
2014-11-18 10:15:57 -05:00
|
|
|
* @param valrec: if it is a validation-recursion query.
|
2007-06-25 09:54:03 -04:00
|
|
|
* @return: mesh state or NULL if not found.
|
|
|
|
|
*/
|
2017-03-07 09:58:51 -05:00
|
|
|
struct mesh_state* mesh_area_find(struct mesh_area* mesh,
|
|
|
|
|
struct respip_client_info* cinfo, struct query_info* qinfo,
|
|
|
|
|
uint16_t qflags, int prime, int valrec);
|
2007-06-25 09:54:03 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Setup attachment super/sub relation between super and sub mesh state.
|
|
|
|
|
* The relation must not be present when calling the function.
|
|
|
|
|
* Does not update stat items in mesh_area.
|
|
|
|
|
* @param super: super state.
|
|
|
|
|
* @param sub: sub state.
|
|
|
|
|
* @return: 0 on alloc error.
|
|
|
|
|
*/
|
|
|
|
|
int mesh_state_attachment(struct mesh_state* super, struct mesh_state* sub);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create new reply structure and attach it to a mesh state.
|
|
|
|
|
* Does not update stat items in mesh area.
|
|
|
|
|
* @param s: the mesh state.
|
|
|
|
|
* @param edns: edns data for reply (bufsize).
|
|
|
|
|
* @param rep: comm point reply info.
|
|
|
|
|
* @param qid: ID of reply.
|
|
|
|
|
* @param qflags: original query flags.
|
2016-10-18 09:18:20 -04:00
|
|
|
* @param qinfo: original query info.
|
2007-06-25 09:54:03 -04:00
|
|
|
* @return: 0 on alloc error.
|
|
|
|
|
*/
|
2016-10-18 09:18:20 -04:00
|
|
|
int mesh_state_add_reply(struct mesh_state* s, struct edns_data* edns,
|
|
|
|
|
struct comm_reply* rep, uint16_t qid, uint16_t qflags,
|
|
|
|
|
const struct query_info* qinfo);
|
2007-06-25 09:54:03 -04:00
|
|
|
|
2007-12-06 10:11:07 -05:00
|
|
|
/**
|
|
|
|
|
* Create new callback structure and attach it to a mesh state.
|
|
|
|
|
* Does not update stat items in mesh area.
|
|
|
|
|
* @param s: the mesh state.
|
|
|
|
|
* @param edns: edns data for reply (bufsize).
|
|
|
|
|
* @param buf: buffer for reply
|
|
|
|
|
* @param cb: callback to call with results.
|
|
|
|
|
* @param cb_arg: callback user arg.
|
|
|
|
|
* @param qid: ID of reply.
|
|
|
|
|
* @param qflags: original query flags.
|
|
|
|
|
* @return: 0 on alloc error.
|
|
|
|
|
*/
|
|
|
|
|
int mesh_state_add_cb(struct mesh_state* s, struct edns_data* edns,
|
2017-01-19 06:34:21 -05:00
|
|
|
struct sldns_buffer* buf, mesh_cb_func_type cb, void* cb_arg,
|
|
|
|
|
uint16_t qid, uint16_t qflags);
|
2007-12-06 10:11:07 -05:00
|
|
|
|
2007-06-25 09:54:03 -04:00
|
|
|
/**
|
|
|
|
|
* Run the mesh. Run all runnable mesh states. Which can create new
|
|
|
|
|
* runnable mesh states. Until completion. Automatically called by
|
|
|
|
|
* mesh_report_reply and mesh_new_client as needed.
|
|
|
|
|
* @param mesh: mesh area.
|
|
|
|
|
* @param mstate: first mesh state to run.
|
|
|
|
|
* @param ev: event the mstate. Others get event_pass.
|
|
|
|
|
* @param e: if a reply, its outbound entry.
|
|
|
|
|
*/
|
|
|
|
|
void mesh_run(struct mesh_area* mesh, struct mesh_state* mstate,
|
|
|
|
|
enum module_ev ev, struct outbound_entry* e);
|
|
|
|
|
|
2007-06-26 11:24:07 -04:00
|
|
|
/**
|
|
|
|
|
* Print some stats about the mesh to the log.
|
|
|
|
|
* @param mesh: the mesh to print it for.
|
|
|
|
|
* @param str: descriptive string to go with it.
|
|
|
|
|
*/
|
|
|
|
|
void mesh_stats(struct mesh_area* mesh, const char* str);
|
|
|
|
|
|
2008-02-05 05:23:44 -05:00
|
|
|
/**
|
|
|
|
|
* Clear the stats that the mesh keeps (number of queries serviced)
|
|
|
|
|
* @param mesh: the mesh
|
|
|
|
|
*/
|
|
|
|
|
void mesh_stats_clear(struct mesh_area* mesh);
|
|
|
|
|
|
2007-08-13 08:23:49 -04:00
|
|
|
/**
|
|
|
|
|
* Print all the states in the mesh to the log.
|
|
|
|
|
* @param mesh: the mesh to print all states of.
|
|
|
|
|
*/
|
|
|
|
|
void mesh_log_list(struct mesh_area* mesh);
|
|
|
|
|
|
2007-07-20 11:51:06 -04:00
|
|
|
/**
|
|
|
|
|
* Calculate memory size in use by mesh and all queries inside it.
|
|
|
|
|
* @param mesh: the mesh to examine.
|
|
|
|
|
* @return size in bytes.
|
|
|
|
|
*/
|
|
|
|
|
size_t mesh_get_mem(struct mesh_area* mesh);
|
|
|
|
|
|
2007-07-26 05:29:21 -04:00
|
|
|
/**
|
|
|
|
|
* Find cycle; see if the given mesh is in the targets sub, or sub-sub, ...
|
|
|
|
|
* trees.
|
2010-06-10 10:10:17 -04:00
|
|
|
* If the sub-sub structure is too large, it returns 'a cycle'=2.
|
2007-07-26 05:29:21 -04:00
|
|
|
* @param qstate: given mesh querystate.
|
|
|
|
|
* @param qinfo: query info for dependency.
|
2007-08-01 07:29:12 -04:00
|
|
|
* @param flags: query flags of dependency.
|
|
|
|
|
* @param prime: if dependency is a priming query or not.
|
2014-11-18 10:15:57 -05:00
|
|
|
* @param valrec: if it is a validation recursion query (lookup of key, DS).
|
2007-07-26 05:29:21 -04:00
|
|
|
* @return true if the name,type,class exists and the given qstate mesh exists
|
|
|
|
|
* as a dependency of that name. Thus if qstate becomes dependent on
|
2010-06-10 10:10:17 -04:00
|
|
|
* name,type,class then a cycle is created, this is return value 1.
|
|
|
|
|
* Too large to search is value 2 (also true).
|
2007-07-26 05:29:21 -04:00
|
|
|
*/
|
2007-08-01 07:29:12 -04:00
|
|
|
int mesh_detect_cycle(struct module_qstate* qstate, struct query_info* qinfo,
|
2014-11-18 10:15:57 -05:00
|
|
|
uint16_t flags, int prime, int valrec);
|
2007-07-26 05:29:21 -04:00
|
|
|
|
2007-10-05 07:41:12 -04:00
|
|
|
/** compare two mesh_states */
|
|
|
|
|
int mesh_state_compare(const void* ap, const void* bp);
|
|
|
|
|
|
|
|
|
|
/** compare two mesh references */
|
|
|
|
|
int mesh_state_ref_compare(const void* ap, const void* bp);
|
|
|
|
|
|
2008-09-02 09:04:47 -04:00
|
|
|
/**
|
|
|
|
|
* Make space for another recursion state for a reply in the mesh
|
|
|
|
|
* @param mesh: mesh area
|
2011-10-24 09:49:59 -04:00
|
|
|
* @param qbuf: query buffer to save if recursion is invoked to make space.
|
|
|
|
|
* This buffer is necessary, because the following sequence in calls
|
|
|
|
|
* can result in an overwrite of the incoming query:
|
|
|
|
|
* delete_other_mesh_query - iter_clean - serviced_delete - waiting
|
|
|
|
|
* udp query is sent - on error callback - callback sends SERVFAIL reply
|
|
|
|
|
* over the same network channel, and shared UDP buffer is overwritten.
|
|
|
|
|
* You can pass NULL if there is no buffer that must be backed up.
|
2008-09-02 09:04:47 -04:00
|
|
|
* @return false if no space is available.
|
|
|
|
|
*/
|
2013-12-03 04:11:16 -05:00
|
|
|
int mesh_make_new_space(struct mesh_area* mesh, struct sldns_buffer* qbuf);
|
2008-09-02 09:04:47 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Insert mesh state into a double linked list. Inserted at end.
|
|
|
|
|
* @param m: mesh state.
|
|
|
|
|
* @param fp: pointer to the first-elem-pointer of the list.
|
|
|
|
|
* @param lp: pointer to the last-elem-pointer of the list.
|
|
|
|
|
*/
|
|
|
|
|
void mesh_list_insert(struct mesh_state* m, struct mesh_state** fp,
|
|
|
|
|
struct mesh_state** lp);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Remove mesh state from a double linked list. Remove from any position.
|
|
|
|
|
* @param m: mesh state.
|
|
|
|
|
* @param fp: pointer to the first-elem-pointer of the list.
|
|
|
|
|
* @param lp: pointer to the last-elem-pointer of the list.
|
|
|
|
|
*/
|
|
|
|
|
void mesh_list_remove(struct mesh_state* m, struct mesh_state** fp,
|
|
|
|
|
struct mesh_state** lp);
|
|
|
|
|
|
2019-01-11 09:12:27 -05:00
|
|
|
/**
|
|
|
|
|
* Remove mesh reply entry from the reply entry list. Searches for
|
2019-01-15 08:42:22 -05:00
|
|
|
* the comm_point pointer.
|
2019-01-11 09:12:27 -05:00
|
|
|
* @param mesh: to update the counters.
|
|
|
|
|
* @param m: the mesh state.
|
2019-01-15 08:42:22 -05:00
|
|
|
* @param cp: the comm_point to remove from the list.
|
2019-01-11 09:12:27 -05:00
|
|
|
*/
|
|
|
|
|
void mesh_state_remove_reply(struct mesh_area* mesh, struct mesh_state* m,
|
|
|
|
|
struct comm_point* cp);
|
|
|
|
|
|
2020-02-05 08:20:27 -05:00
|
|
|
/** Callback for when the serve expired client timer has run out. Tries to
|
|
|
|
|
* find an expired answer in the cache and reply that to the client.
|
|
|
|
|
* @param arg: the argument passed to the callback.
|
|
|
|
|
*/
|
|
|
|
|
void mesh_serve_expired_callback(void* arg);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Try to get a (expired) cached answer.
|
|
|
|
|
* This needs to behave like the worker's answer_from_cache() in order to have
|
|
|
|
|
* the same behavior as when replying from cache.
|
|
|
|
|
* @param qstate: the module qstate.
|
|
|
|
|
* @param lookup_qinfo: the query info to look for in the cache.
|
2024-09-24 10:47:04 -04:00
|
|
|
* @param is_expired: set if the cached answer is expired.
|
2020-02-05 08:20:27 -05:00
|
|
|
* @return dns_msg if a cached answer was found, otherwise NULL.
|
|
|
|
|
*/
|
|
|
|
|
struct dns_msg*
|
|
|
|
|
mesh_serve_expired_lookup(struct module_qstate* qstate,
|
2024-09-24 10:47:04 -04:00
|
|
|
struct query_info* lookup_qinfo, int* is_expired);
|
2020-02-05 08:20:27 -05:00
|
|
|
|
2022-09-21 05:10:38 -04:00
|
|
|
/**
|
|
|
|
|
* See if the mesh has space for more queries. You can allocate queries
|
|
|
|
|
* anyway, but this checks for the allocated space.
|
|
|
|
|
* @param mesh: mesh area.
|
|
|
|
|
* @return true if the query list is full.
|
|
|
|
|
* It checks the number of all queries, not just number of reply states,
|
|
|
|
|
* that have a client address. So that spawned queries count too,
|
|
|
|
|
* that were created by the iterator, or other modules.
|
|
|
|
|
*/
|
|
|
|
|
int mesh_jostle_exceeded(struct mesh_area* mesh);
|
|
|
|
|
|
2024-04-10 05:21:28 -04:00
|
|
|
/**
|
|
|
|
|
* Give the serve expired responses.
|
|
|
|
|
* @param mstate: mesh state for query that has serve_expired_data.
|
|
|
|
|
*/
|
|
|
|
|
void mesh_respond_serve_expired(struct mesh_state* mstate);
|
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
|
* Remove callback from mesh. Removes the callback from the state.
|
|
|
|
|
* The state itself is left to run. Searches for the pointer values.
|
|
|
|
|
*
|
|
|
|
|
* @param mesh: the mesh.
|
|
|
|
|
* @param qinfo: query from client.
|
|
|
|
|
* @param qflags: flags from client query.
|
|
|
|
|
* @param cb: callback function.
|
|
|
|
|
* @param cb_arg: callback user arg.
|
|
|
|
|
*/
|
|
|
|
|
void mesh_remove_callback(struct mesh_area* mesh, struct query_info* qinfo,
|
|
|
|
|
uint16_t qflags, mesh_cb_func_type cb, void* cb_arg);
|
|
|
|
|
|
2007-06-21 11:36:13 -04:00
|
|
|
#endif /* SERVICES_MESH_H */
|