|
unbound 0.1
|
This file contains the infrastructure cache. More...
#include "config.h"#include "sldns/rrdef.h"#include "sldns/str2wire.h"#include "sldns/sbuffer.h"#include "sldns/wire2str.h"#include "services/cache/infra.h"#include "util/storage/slabhash.h"#include "util/storage/lookup3.h"#include "util/data/dname.h"#include "util/log.h"#include "util/net_help.h"#include "util/config_file.h"#include "iterator/iterator.h"Functions | |
| int | still_useful_timeout () |
| Minus 1000 because that is outside of the RTTBAND, so blacklisted servers stay blacklisted if this is chosen. | |
| size_t | infra_sizefunc (void *k, void *ATTR_UNUSED(d)) |
| int | infra_compfunc (void *key1, void *key2) |
| compare two addresses, returns -1, 0, or +1 | |
| void | infra_delkeyfunc (void *k, void *ATTR_UNUSED(arg)) |
| void | infra_deldatafunc (void *d, void *ATTR_UNUSED(arg)) |
| size_t | rate_sizefunc (void *k, void *ATTR_UNUSED(d)) |
| int | rate_compfunc (void *key1, void *key2) |
| compare two names, returns -1, 0, or +1 | |
| void | rate_delkeyfunc (void *k, void *ATTR_UNUSED(arg)) |
| void | rate_deldatafunc (void *d, void *ATTR_UNUSED(arg)) |
| static struct domain_limit_data * | domain_limit_findcreate (struct rbtree_type *domain_limits, char *name) |
| find or create element in domainlimit tree | |
| static int | infra_ratelimit_cfg_insert (struct rbtree_type *domain_limits, struct config_file *cfg) |
| insert rate limit configuration into lookup tree | |
| int | setup_domain_limits (struct rbtree_type *domain_limits, struct config_file *cfg) |
| setup domain limits tree (0 on failure) | |
| static struct wait_limit_netblock_info * | wait_limit_netblock_findcreate (struct rbtree_type *tree, char *str) |
| find or create element in wait limit netblock tree | |
| static int | infra_wait_limit_netblock_insert (rbtree_type *wait_limits_netblock, rbtree_type *wait_limits_cookie_netblock, struct config_file *cfg) |
| insert wait limit information into lookup tree | |
| static int | wait_limit_netblock_default (struct rbtree_type *tree, char *str, int limit) |
| Add a default wait limit netblock. | |
| int | setup_wait_limits (rbtree_type *wait_limits_netblock, rbtree_type *wait_limits_cookie_netblock, struct config_file *cfg) |
| setup wait limits tree (0 on failure) | |
| struct infra_cache * | infra_create (struct config_file *cfg) |
| Create infra cache. | |
| static void | domain_limit_free (rbnode_type *n, void *ATTR_UNUSED(arg)) |
| delete domain_limit entries | |
| void | domain_limits_free (struct rbtree_type *domain_limits) |
| Free the domain limits tree. | |
| static void | wait_limit_netblock_del (rbnode_type *n, void *ATTR_UNUSED(arg)) |
| delete wait_limit_netblock_info entries | |
| void | wait_limits_free (struct rbtree_type *wait_limits_tree) |
| Free the wait limits and wait cookie limits tree. | |
| void | infra_delete (struct infra_cache *infra) |
| Delete infra cache. | |
| struct infra_cache * | infra_adjust (struct infra_cache *infra, struct config_file *cfg) |
| Adjust infra cache to use updated configuration settings. | |
| static hashvalue_type | hash_addr (struct sockaddr_storage *addr, socklen_t addrlen, int use_port) |
| calculate the hash value for a host key set use_port to a non-0 number to use the port in the hash calculation; 0 to ignore the port. | |
| static hashvalue_type | hash_infra (struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *name) |
| calculate infra hash for a key | |
| struct lruhash_entry * | infra_lookup_nottl (struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *name, size_t namelen, int wr) |
| lookup version that does not check host ttl (you check it) | |
| static void | data_entry_init (struct infra_cache *infra, struct lruhash_entry *e, time_t timenow) |
| init the data elements | |
| static struct lruhash_entry * | new_entry (struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *name, size_t namelen, time_t tm) |
| Create and init a new entry for a host. | |
| int | infra_host (struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *nm, size_t nmlen, time_t timenow, int *edns_vs, uint8_t *edns_lame_known, int *to) |
| Find host information to send a packet. | |
| int | infra_set_lame (struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *nm, size_t nmlen, time_t timenow, int dnsseclame, int reclame, uint16_t qtype) |
| Set a host to be lame for the given zone. | |
| void | infra_update_tcp_works (struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *nm, size_t nmlen) |
| Update information for the host, store that a TCP transaction works. | |
| int | infra_rtt_update (struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *nm, size_t nmlen, int qtype, int roundtrip, int orig_rtt, time_t timenow) |
| Update rtt information for the host. | |
| long long | infra_get_host_rto (struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *nm, size_t nmlen, struct rtt_info *rtt, int *delay, time_t timenow, int *tA, int *tAAAA, int *tother) |
| Get additional (debug) info on timing. | |
| int | infra_edns_update (struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *nm, size_t nmlen, int edns_version, time_t timenow) |
| Update edns information for the host. | |
| int | infra_get_lame_rtt (struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, uint8_t *name, size_t namelen, uint16_t qtype, int *lame, int *dnsseclame, int *reclame, int *rtt, time_t timenow) |
| Get Lameness information and average RTT if host is in the cache. | |
| int | infra_find_ratelimit (struct infra_cache *infra, uint8_t *name, size_t namelen) |
| find the ratelimit in qps for a domain. | |
| size_t | ip_rate_sizefunc (void *k, void *ATTR_UNUSED(d)) |
| int | ip_rate_compfunc (void *key1, void *key2) |
| void | ip_rate_delkeyfunc (void *k, void *ATTR_UNUSED(arg)) |
| static struct lruhash_entry * | infra_find_ratedata (struct infra_cache *infra, uint8_t *name, size_t namelen, int wr) |
| find data item in array, for write access, caller unlocks | |
| static struct lruhash_entry * | infra_find_ip_ratedata (struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, int wr) |
| find data item in array for ip addresses | |
| static void | infra_create_ratedata (struct infra_cache *infra, uint8_t *name, size_t namelen, time_t timenow) |
| create rate data item for name, number 1 in now | |
| static void | infra_ip_create_ratedata (struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, time_t timenow, int mesh_wait) |
| create rate data item for ip address | |
| static int * | infra_rate_find_second_or_none (void *data, time_t t, int should_add) |
| Find the second and return its rate counter. | |
| static int * | infra_rate_give_second (void *data, time_t t) |
| find the second and return its rate counter, if none, remove oldest to accommodate | |
| static int * | infra_rate_get_second (void *data, time_t t) |
| find the second and return its rate counter only if it exists. | |
| int | infra_rate_max (void *data, time_t now, int backoff) |
| find the maximum rate stored. | |
| int | infra_ratelimit_inc (struct infra_cache *infra, uint8_t *name, size_t namelen, time_t timenow, int backoff, struct query_info *qinfo, struct comm_reply *replylist) |
| Increment the query rate counter for a delegation point. | |
| void | infra_ratelimit_dec (struct infra_cache *infra, uint8_t *name, size_t namelen, time_t timenow) |
| Decrement the query rate counter for a delegation point. | |
| int | infra_ratelimit_exceeded (struct infra_cache *infra, uint8_t *name, size_t namelen, time_t timenow, int backoff) |
| See if the query rate counter for a delegation point is exceeded. | |
| size_t | infra_get_mem (struct infra_cache *infra) |
| Get memory used by the infra cache. | |
| static int | check_ip_ratelimit (struct sockaddr_storage *addr, socklen_t addrlen, struct sldns_buffer *buffer, int premax, int max, int has_cookie) |
| int | infra_ip_ratelimit_inc (struct infra_cache *infra, struct sockaddr_storage *addr, socklen_t addrlen, time_t timenow, int has_cookie, int backoff, struct sldns_buffer *buffer) |
| Update query ratelimit hash and decide whether or not a query should be dropped. | |
| int | infra_wait_limit_allowed (struct infra_cache *infra, struct comm_reply *rep, int cookie_valid, struct config_file *cfg) |
| See if the IP address can have another reply in the wait limit. | |
| void | infra_wait_limit_inc (struct infra_cache *infra, struct comm_reply *rep, time_t timenow, struct config_file *cfg) |
| Increment number of waiting replies for IP. | |
| void | infra_wait_limit_dec (struct infra_cache *infra, struct comm_reply *rep, struct config_file *cfg) |
| Decrement number of waiting replies for IP. | |
Variables | |
| int | infra_dp_ratelimit = 0 |
| ratelimit value for delegation point | |
| int | infra_ip_ratelimit = 0 |
| ratelimit value for client ip addresses, in queries per second. | |
| int | infra_ip_ratelimit_cookie = 0 |
| ratelimit value for client ip addresses, in queries per second. | |
This file contains the infrastructure cache.
| int still_useful_timeout | ( | ) |
Minus 1000 because that is outside of the RTTBAND, so blacklisted servers stay blacklisted if this is chosen.
exported for unit test
If USEFUL_SERVER_TOP_TIMEOUT is below 1000 (configured via RTT_MAX_TIMEOUT, infra-cache-max-rtt) change it to just above the RTT_BAND.
Minus 1000 because that is outside of the RTTBAND, so blacklisted servers stay blacklisted if this is chosen.
References RTT_BAND, still_useful_timeout(), and USEFUL_SERVER_TOP_TIMEOUT.
Referenced by infra_get_lame_rtt(), infra_update_tcp_works(), rate_deldatafunc(), and still_useful_timeout().
| int infra_compfunc | ( | void * | key1, |
| void * | key2 ) |
compare two addresses, returns -1, 0, or +1
References infra_key::addr, infra_key::addrlen, infra_compfunc(), infra_key::namelen, query_dname_compare(), sockaddr_cmp(), and infra_key::zonename.
Referenced by fptr_whitelist_hash_compfunc(), infra_compfunc(), infra_create(), and infra_sizefunc().
| int rate_compfunc | ( | void * | key1, |
| void * | key2 ) |
compare two names, returns -1, 0, or +1
References rate_key::name, rate_key::namelen, query_dname_compare(), and rate_compfunc().
Referenced by fptr_whitelist_hash_compfunc(), infra_create(), rate_compfunc(), and rate_sizefunc().
|
static |
find or create element in domainlimit tree
References domain_limit_data::below, name_tree_node::dclass, dname_count_labels(), domain_limit_findcreate(), rbnode_type::key, name_tree_node::labs, LDNS_RR_CLASS_IN, name_tree_node::len, domain_limit_data::lim, log_err(), name_tree_node::name, name_tree_find(), name_tree_insert(), domain_limit_data::node, name_tree_node::node, and sldns_str2wire_dname().
Referenced by domain_limit_findcreate(), and infra_ratelimit_cfg_insert().
|
static |
insert rate limit configuration into lookup tree
References domain_limit_data::below, domain_limit_findcreate(), infra_ratelimit_cfg_insert(), domain_limit_data::lim, config_str2list::next, config_file::ratelimit_below_domain, config_file::ratelimit_for_domain, config_str2list::str, and config_str2list::str2.
Referenced by infra_ratelimit_cfg_insert(), and setup_domain_limits().
| int setup_domain_limits | ( | struct rbtree_type * | domain_limits, |
| struct config_file * | cfg ) |
setup domain limits tree (0 on failure)
References infra_ratelimit_cfg_insert(), name_tree_init(), name_tree_init_parents(), and setup_domain_limits().
Referenced by fr_construct_from_config(), infra_create(), rate_deldatafunc(), and setup_domain_limits().
|
static |
find or create element in wait limit netblock tree
References addr_tree_find(), addr_tree_insert(), wait_limit_netblock_info::limit, log_err(), netblockstrtoaddr(), wait_limit_netblock_info::node, and wait_limit_netblock_findcreate().
Referenced by infra_wait_limit_netblock_insert(), wait_limit_netblock_default(), and wait_limit_netblock_findcreate().
|
static |
insert wait limit information into lookup tree
References infra_wait_limit_netblock_insert(), wait_limit_netblock_info::limit, config_str2list::next, config_str2list::str, config_str2list::str2, config_file::wait_limit_cookie_netblock, config_file::wait_limit_netblock, and wait_limit_netblock_findcreate().
Referenced by infra_wait_limit_netblock_insert(), and setup_wait_limits().
|
static |
Add a default wait limit netblock.
References wait_limit_netblock_info::limit, wait_limit_netblock_default(), and wait_limit_netblock_findcreate().
Referenced by setup_wait_limits(), and wait_limit_netblock_default().
| int setup_wait_limits | ( | rbtree_type * | wait_limits_netblock, |
| rbtree_type * | wait_limits_cookie_netblock, | ||
| struct config_file * | cfg ) |
setup wait limits tree (0 on failure)
References addr_tree_init(), addr_tree_init_parents(), infra_wait_limit_netblock_insert(), setup_wait_limits(), and wait_limit_netblock_default().
Referenced by fr_construct_from_config(), infra_create(), rate_deldatafunc(), and setup_wait_limits().
| struct infra_cache * infra_create | ( | struct config_file * | cfg | ) |
Create infra cache.
| cfg | config parameters or NULL for defaults. |
References infra_cache::client_ip_rates, infra_cache::domain_limits, infra_cache::domain_rates, config_file::host_ttl, infra_cache::host_ttl, infra_cache::hosts, INFRA_BYTES_NAME, config_file::infra_cache_numhosts, config_file::infra_cache_slabs, infra_compfunc(), infra_create(), infra_delete(), infra_dp_ratelimit, INFRA_HOST_STARTSIZE, infra_ip_ratelimit, infra_ip_ratelimit_cookie, config_file::infra_keep_probing, infra_cache::infra_keep_probing, config_file::ip_ratelimit, config_file::ip_ratelimit_cookie, config_file::ip_ratelimit_size, config_file::ip_ratelimit_slabs, rate_compfunc(), config_file::ratelimit, config_file::ratelimit_size, config_file::ratelimit_slabs, setup_domain_limits(), setup_wait_limits(), slabhash_create(), infra_cache::wait_limits_cookie_netblock, and infra_cache::wait_limits_netblock.
Referenced by infra_adjust(), infra_create(), and infra_test().
|
static |
delete domain_limit entries
References domain_limit_free().
Referenced by domain_limit_free(), and domain_limits_free().
| void domain_limits_free | ( | struct rbtree_type * | domain_limits | ) |
Free the domain limits tree.
References domain_limit_free(), domain_limits_free(), and traverse_postorder().
Referenced by domain_limits_free(), fr_construct_clear(), infra_delete(), and rate_deldatafunc().
|
static |
delete wait_limit_netblock_info entries
References wait_limit_netblock_del().
Referenced by wait_limit_netblock_del(), and wait_limits_free().
| void wait_limits_free | ( | struct rbtree_type * | wait_limits_tree | ) |
Free the wait limits and wait cookie limits tree.
References traverse_postorder(), wait_limit_netblock_del(), and wait_limits_free().
Referenced by fr_construct_clear(), infra_delete(), rate_deldatafunc(), and wait_limits_free().
| void infra_delete | ( | struct infra_cache * | infra | ) |
Delete infra cache.
| infra | infrastructure cache to delete. |
References infra_cache::client_ip_rates, infra_cache::domain_limits, domain_limits_free(), infra_cache::domain_rates, infra_cache::hosts, infra_delete(), slabhash_delete(), infra_cache::wait_limits_cookie_netblock, wait_limits_free(), and infra_cache::wait_limits_netblock.
Referenced by daemon_delete(), infra_create(), infra_delete(), infra_test(), and ub_ctx_delete().
| struct infra_cache * infra_adjust | ( | struct infra_cache * | infra, |
| struct config_file * | cfg ) |
Adjust infra cache to use updated configuration settings.
This may clean the cache. Operates a bit like realloc. There may be no threading or use by other threads.
| infra | existing cache. If NULL a new infra cache is returned. |
| cfg | config options. |
References infra_cache::client_ip_rates, infra_cache::domain_rates, config_file::host_ttl, infra_cache::host_ttl, infra_cache::hosts, infra_adjust(), INFRA_BYTES_NAME, config_file::infra_cache_numhosts, config_file::infra_cache_slabs, infra_create(), infra_dp_ratelimit, infra_ip_ratelimit, infra_ip_ratelimit_cookie, config_file::infra_keep_probing, infra_cache::infra_keep_probing, config_file::ip_ratelimit, config_file::ip_ratelimit_cookie, config_file::ip_ratelimit_size, config_file::ip_ratelimit_slabs, config_file::ratelimit, config_file::ratelimit_size, config_file::ratelimit_slabs, and slabhash_is_size().
Referenced by context_finalize(), daemon_apply_cfg(), and infra_adjust().
|
static |
calculate the hash value for a host key set use_port to a non-0 number to use the port in the hash calculation; 0 to ignore the port.
References infra_key::addr, addr_is_ip6(), infra_key::addrlen, hash_addr(), INET6_SIZE, and INET_SIZE.
Referenced by hash_addr(), hash_infra(), infra_find_ip_ratedata(), and infra_ip_create_ratedata().
|
static |
calculate infra hash for a key
References dname_query_hash(), hash_addr(), and hash_infra().
Referenced by hash_infra(), infra_lookup_nottl(), and new_entry().
| struct lruhash_entry * infra_lookup_nottl | ( | struct infra_cache * | infra, |
| struct sockaddr_storage * | addr, | ||
| socklen_t | addrlen, | ||
| uint8_t * | name, | ||
| size_t | namelen, | ||
| int | wr ) |
lookup version that does not check host ttl (you check it)
Plain find infra data function (used by the other functions).
lookup version that does not check host ttl (you check it)
| infra | infrastructure cache. |
| addr | host address. |
| addrlen | length of addr. |
| name | domain name of zone. |
| namelen | length of domain name. |
| wr | if true, writelock, else readlock. |
References infra_key::addr, infra_key::addrlen, lruhash_entry::data, infra_key::entry, lruhash_entry::hash, hash_infra(), infra_cache::hosts, infra_lookup_nottl(), lruhash_entry::key, infra_key::namelen, slabhash_lookup(), and infra_key::zonename.
Referenced by infra_edns_update(), infra_get_host_rto(), infra_get_lame_rtt(), infra_host(), infra_lookup_nottl(), infra_rtt_update(), infra_set_lame(), and infra_update_tcp_works().
|
static |
init the data elements
References lruhash_entry::data, data_entry_init(), infra_data::edns_lame_known, infra_data::edns_version, infra_cache::host_ttl, infra_data::isdnsseclame, infra_data::lame_other, infra_data::lame_type_A, infra_data::probedelay, infra_data::rec_lame, infra_data::rtt, rtt_init(), infra_data::timeout_A, infra_data::timeout_AAAA, infra_data::timeout_other, and infra_data::ttl.
Referenced by data_entry_init(), infra_edns_update(), infra_host(), infra_rtt_update(), infra_set_lame(), and new_entry().
|
static |
Create and init a new entry for a host.
| infra | infra structure with config parameters. |
| addr | host address. |
| addrlen | length of addr. |
| name | name of zone |
| namelen | length of name. |
| tm | time now. |
References infra_key::addr, infra_key::addrlen, lruhash_entry::data, data_entry_init(), infra_key::entry, lruhash_entry::hash, hash_infra(), lruhash_entry::key, lruhash_entry::lock, memdup(), infra_key::namelen, new_entry(), and infra_key::zonename.
Referenced by infra_edns_update(), infra_host(), infra_rtt_update(), infra_set_lame(), new_entry(), new_entry(), and read_entry().
| int infra_host | ( | struct infra_cache * | infra, |
| struct sockaddr_storage * | addr, | ||
| socklen_t | addrlen, | ||
| uint8_t * | name, | ||
| size_t | namelen, | ||
| time_t | timenow, | ||
| int * | edns_vs, | ||
| uint8_t * | edns_lame_known, | ||
| int * | to ) |
Find host information to send a packet.
Creates new entry if not found. Lameness is empty. EDNS is 0 (try with first), and rtt is returned for the first message to it. Use this to send a packet only, because it also locks out others when probing is restricted.
| infra | infrastructure cache. |
| addr | host address. |
| addrlen | length of addr. |
| name | domain name of zone. |
| namelen | length of domain name. |
| timenow | what time it is now. |
| edns_vs | edns version it supports, is returned. |
| edns_lame_known | if EDNS lame (EDNS is dropped in transit) has already been probed, is returned. |
| to | timeout to use, is returned. |
References lruhash_entry::data, data_entry_init(), infra_data::edns_lame_known, infra_data::edns_version, lruhash_entry::hash, infra_cache::hosts, infra_host(), infra_cache::infra_keep_probing, infra_lookup_nottl(), lruhash_entry::lock, new_entry(), PROBE_MAXRTO, infra_data::probedelay, rtt_info::rto, infra_data::rtt, rtt_notimeout(), rtt_timeout(), slabhash_insert(), infra_data::timeout_A, infra_data::timeout_AAAA, infra_data::timeout_other, and USEFUL_SERVER_TOP_TIMEOUT.
Referenced by expon_timeout_backoff(), infra_host(), infra_test(), print_dp_details(), serviced_tcp_send(), and serviced_udp_send().
| int infra_set_lame | ( | struct infra_cache * | infra, |
| struct sockaddr_storage * | addr, | ||
| socklen_t | addrlen, | ||
| uint8_t * | name, | ||
| size_t | namelen, | ||
| time_t | timenow, | ||
| int | dnsseclame, | ||
| int | reclame, | ||
| uint16_t | qtype ) |
Set a host to be lame for the given zone.
| infra | infrastructure cache. |
| addr | host address. |
| addrlen | length of addr. |
| name | domain name of zone apex. |
| namelen | length of domain name. |
| timenow | what time it is now. |
| dnsseclame | if true the host is set dnssec lame. if false, the host is marked lame (not serving the zone). |
| reclame | if true host is a recursor not AA server. if false, dnsseclame or marked lame. |
| qtype | the query type for which it is lame. |
References lruhash_entry::data, data_entry_init(), lruhash_entry::hash, infra_cache::hosts, infra_lookup_nottl(), infra_set_lame(), infra_data::isdnsseclame, infra_data::lame_other, infra_data::lame_type_A, LDNS_RR_TYPE_A, lruhash_entry::lock, log_err(), new_entry(), infra_data::rec_lame, and slabhash_insert().
Referenced by infra_set_lame(), infra_test(), and processQueryResponse().
| void infra_update_tcp_works | ( | struct infra_cache * | infra, |
| struct sockaddr_storage * | addr, | ||
| socklen_t | addrlen, | ||
| uint8_t * | name, | ||
| size_t | namelen ) |
Update information for the host, store that a TCP transaction works.
| infra | infrastructure cache. |
| addr | host address. |
| addrlen | length of addr. |
| name | name of zone |
| namelen | length of name |
References lruhash_entry::data, infra_lookup_nottl(), infra_update_tcp_works(), lruhash_entry::lock, rtt_info::rto, infra_data::rtt, RTT_MAX_TIMEOUT, and still_useful_timeout().
Referenced by infra_update_tcp_works(), and serviced_tcp_callback().
| int infra_rtt_update | ( | struct infra_cache * | infra, |
| struct sockaddr_storage * | addr, | ||
| socklen_t | addrlen, | ||
| uint8_t * | name, | ||
| size_t | namelen, | ||
| int | qtype, | ||
| int | roundtrip, | ||
| int | orig_rtt, | ||
| time_t | timenow ) |
Update rtt information for the host.
| infra | infrastructure cache. |
| addr | host address. |
| addrlen | length of addr. |
| name | zone name |
| namelen | zone name length |
| qtype | query type. |
| roundtrip | estimate of roundtrip time in milliseconds or -1 for timeout. |
| orig_rtt | original rtt for the query that timed out (roundtrip==-1). ignored if roundtrip != -1. |
| timenow | what time it is now. |
References lruhash_entry::data, data_entry_init(), lruhash_entry::hash, infra_cache::hosts, infra_lookup_nottl(), infra_rtt_update(), LDNS_RR_TYPE_A, LDNS_RR_TYPE_AAAA, lruhash_entry::lock, new_entry(), infra_data::probedelay, rtt_info::rto, infra_data::rtt, rtt_init(), rtt_lost(), rtt_unclamped(), rtt_update(), slabhash_insert(), infra_data::timeout_A, infra_data::timeout_AAAA, TIMEOUT_COUNT_MAX, infra_data::timeout_other, and USEFUL_SERVER_TOP_TIMEOUT.
Referenced by do_infra_rtt(), expon_timeout_backoff(), infra_rtt_update(), infra_test(), serviced_tcp_callback(), and serviced_udp_callback().
| long long infra_get_host_rto | ( | struct infra_cache * | infra, |
| struct sockaddr_storage * | addr, | ||
| socklen_t | addrlen, | ||
| uint8_t * | name, | ||
| size_t | namelen, | ||
| struct rtt_info * | rtt, | ||
| int * | delay, | ||
| time_t | timenow, | ||
| int * | tA, | ||
| int * | tAAAA, | ||
| int * | tother ) |
Get additional (debug) info on timing.
| infra | infra cache. |
| addr | host address. |
| addrlen | length of addr. |
| name | zone name |
| namelen | zone name length |
| rtt | the rtt_info is copied into here (caller alloced return struct). |
| delay | probe delay (if any). |
| timenow | what time it is now. |
| tA | timeout counter on type A. |
| tAAAA | timeout counter on type AAAA. |
| tother | timeout counter on type other. |
References lruhash_entry::data, infra_get_host_rto(), infra_lookup_nottl(), lruhash_entry::lock, infra_data::probedelay, infra_data::rtt, infra_data::timeout_A, infra_data::timeout_AAAA, infra_data::timeout_other, and infra_data::ttl.
Referenced by infra_get_host_rto(), and print_dp_details().
| int infra_edns_update | ( | struct infra_cache * | infra, |
| struct sockaddr_storage * | addr, | ||
| socklen_t | addrlen, | ||
| uint8_t * | name, | ||
| size_t | namelen, | ||
| int | edns_version, | ||
| time_t | timenow ) |
Update edns information for the host.
| infra | infrastructure cache. |
| addr | host address. |
| addrlen | length of addr. |
| name | name of zone |
| namelen | length of name |
| edns_version | the version that it publishes. If it is known to support EDNS then no-EDNS is not stored over it. |
| timenow | what time it is now. |
References lruhash_entry::data, data_entry_init(), infra_data::edns_lame_known, infra_data::edns_version, lruhash_entry::hash, infra_cache::hosts, infra_edns_update(), infra_lookup_nottl(), lruhash_entry::lock, new_entry(), and slabhash_insert().
Referenced by infra_edns_update(), infra_test(), serviced_tcp_callback(), and serviced_udp_callback().
| int infra_get_lame_rtt | ( | struct infra_cache * | infra, |
| struct sockaddr_storage * | addr, | ||
| socklen_t | addrlen, | ||
| uint8_t * | name, | ||
| size_t | namelen, | ||
| uint16_t | qtype, | ||
| int * | lame, | ||
| int * | dnsseclame, | ||
| int * | reclame, | ||
| int * | rtt, | ||
| time_t | timenow ) |
Get Lameness information and average RTT if host is in the cache.
This information is to be used for server selection.
| infra | infrastructure cache. |
| addr | host address. |
| addrlen | length of addr. |
| name | zone name. |
| namelen | zone name length. |
| qtype | the query to be made. |
| lame | if function returns true, this returns lameness of the zone. |
| dnsseclame | if function returns true, this returns if the zone is dnssec-lame. |
| reclame | if function returns true, this is if it is recursion lame. |
| rtt | if function returns true, this returns avg rtt of the server. The rtt value is unclamped and reflects recent timeouts. |
| timenow | what time it is now. |
References lruhash_entry::data, infra_get_lame_rtt(), infra_cache::infra_keep_probing, infra_lookup_nottl(), infra_data::isdnsseclame, infra_data::lame_other, infra_data::lame_type_A, LDNS_RR_TYPE_A, LDNS_RR_TYPE_AAAA, lruhash_entry::lock, PROBE_MAXRTO, infra_data::probedelay, infra_data::rec_lame, rtt_info::rto, infra_data::rtt, rtt_notimeout(), rtt_unclamped(), still_useful_timeout(), infra_data::timeout_A, infra_data::timeout_AAAA, TIMEOUT_COUNT_MAX, infra_data::timeout_other, infra_data::ttl, and USEFUL_SERVER_TOP_TIMEOUT.
Referenced by infra_get_lame_rtt(), iter_filter_unsuitable(), and print_dp_details().
| int infra_find_ratelimit | ( | struct infra_cache * | infra, |
| uint8_t * | name, | ||
| size_t | namelen ) |
find the ratelimit in qps for a domain.
0 if no limit for domain.
References domain_limit_data::below, dname_count_labels(), infra_cache::domain_limits, infra_dp_ratelimit, infra_find_ratelimit(), name_tree_node::labs, LDNS_RR_CLASS_IN, domain_limit_data::lim, name_tree_lookup(), domain_limit_data::node, and name_tree_node::parent.
Referenced by infra_find_ratelimit(), infra_ratelimit_exceeded(), infra_ratelimit_inc(), and rate_list().
|
static |
find data item in array, for write access, caller unlocks
References dname_query_hash(), infra_cache::domain_rates, rate_key::entry, lruhash_entry::hash, infra_find_ratedata(), rate_key::name, rate_key::namelen, and slabhash_lookup().
Referenced by infra_find_ratedata(), infra_ratelimit_dec(), infra_ratelimit_exceeded(), and infra_ratelimit_inc().
|
static |
find data item in array for ip addresses
References ip_rate_key::addr, ip_rate_key::addrlen, infra_cache::client_ip_rates, ip_rate_key::entry, lruhash_entry::hash, hash_addr(), infra_find_ip_ratedata(), and slabhash_lookup().
Referenced by infra_find_ip_ratedata(), infra_ip_ratelimit_inc(), infra_wait_limit_allowed(), infra_wait_limit_dec(), and infra_wait_limit_inc().
|
static |
create rate data item for name, number 1 in now
References lruhash_entry::data, dname_query_hash(), infra_cache::domain_rates, rate_key::entry, lruhash_entry::hash, infra_create_ratedata(), lruhash_entry::key, lruhash_entry::lock, memdup(), rate_key::name, rate_key::namelen, rate_data::qps, slabhash_insert(), and rate_data::timestamp.
Referenced by infra_create_ratedata(), and infra_ratelimit_inc().
|
static |
create rate data item for ip address
References ip_rate_key::addr, ip_rate_key::addrlen, infra_cache::client_ip_rates, lruhash_entry::data, ip_rate_key::entry, lruhash_entry::hash, hash_addr(), infra_ip_create_ratedata(), lruhash_entry::key, lruhash_entry::lock, and slabhash_insert().
Referenced by infra_ip_create_ratedata(), infra_ip_ratelimit_inc(), and infra_wait_limit_inc().
|
static |
Find the second and return its rate counter.
If none and should_add, remove oldest to accommodate. Else return none.
References infra_rate_find_second_or_none(), rate_data::qps, RATE_WINDOW, and rate_data::timestamp.
Referenced by infra_rate_find_second_or_none(), infra_rate_get_second(), and infra_rate_give_second().
|
static |
find the second and return its rate counter, if none, remove oldest to accommodate
References infra_rate_find_second_or_none(), and infra_rate_give_second().
Referenced by infra_ip_ratelimit_inc(), infra_rate_give_second(), and infra_ratelimit_inc().
|
static |
find the second and return its rate counter only if it exists.
Caller should check for NULL return value
References infra_rate_find_second_or_none(), and infra_rate_get_second().
Referenced by infra_rate_get_second(), and infra_ratelimit_dec().
| int infra_rate_max | ( | void * | data, |
| time_t | now, | ||
| int | backoff ) |
find the maximum rate stored.
0 if no information. When backoff is enabled look for the maximum in the whole RATE_WINDOW.
References infra_rate_max(), rate_data::qps, RATE_WINDOW, and rate_data::timestamp.
Referenced by infra_ip_ratelimit_inc(), infra_rate_max(), infra_ratelimit_exceeded(), infra_ratelimit_inc(), ip_rate_list(), and rate_list().
| int infra_ratelimit_inc | ( | struct infra_cache * | infra, |
| uint8_t * | name, | ||
| size_t | namelen, | ||
| time_t | timenow, | ||
| int | backoff, | ||
| struct query_info * | qinfo, | ||
| struct comm_reply * | replylist ) |
Increment the query rate counter for a delegation point.
| infra | infra cache. |
| name | zone name |
| namelen | zone name length |
| timenow | what time it is now. |
| backoff | if backoff is enabled. |
| qinfo | for logging, query name. |
| replylist | for logging, querier's address (if any). |
References addr_to_str(), dname_str(), infra_create_ratedata(), infra_dp_ratelimit, infra_find_ratedata(), infra_find_ratelimit(), infra_rate_give_second(), infra_rate_max(), infra_ratelimit_inc(), LDNS_MAX_DOMAINLEN, query_info::qclass, query_info::qname, query_info::qtype, comm_reply::remote_addr, comm_reply::remote_addrlen, sldns_wire2str_class_buf(), sldns_wire2str_type_buf(), VERB_OPS, and verbose().
Referenced by infra_ratelimit_inc(), and outnet_serviced_query().
| void infra_ratelimit_dec | ( | struct infra_cache * | infra, |
| uint8_t * | name, | ||
| size_t | namelen, | ||
| time_t | timenow ) |
Decrement the query rate counter for a delegation point.
Because the reply received for the delegation point was pleasant, we do not charge this delegation point with it (i.e. it was a referral). Should call it with same second as when inc() was called.
| infra | infra cache. |
| name | zone name |
| namelen | zone name length |
| timenow | what time it is now. |
References infra_dp_ratelimit, infra_find_ratedata(), infra_rate_get_second(), and infra_ratelimit_dec().
Referenced by infra_ratelimit_dec(), outnet_serviced_query(), and processQueryResponse().
| int infra_ratelimit_exceeded | ( | struct infra_cache * | infra, |
| uint8_t * | name, | ||
| size_t | namelen, | ||
| time_t | timenow, | ||
| int | backoff ) |
See if the query rate counter for a delegation point is exceeded.
So, no queries are going to be allowed.
| infra | infra cache. |
| name | zone name |
| namelen | zone name length |
| timenow | what time it is now. |
| backoff | if backoff is enabled. |
References infra_dp_ratelimit, infra_find_ratedata(), infra_find_ratelimit(), infra_rate_max(), and infra_ratelimit_exceeded().
Referenced by infra_ratelimit_exceeded().
| size_t infra_get_mem | ( | struct infra_cache * | infra | ) |
Get memory used by the infra cache.
| infra | infrastructure cache. |
References infra_cache::client_ip_rates, infra_cache::domain_rates, infra_cache::hosts, infra_get_mem(), and slabhash_get_mem().
Referenced by infra_get_mem(), and worker_mem_report().
| int infra_ip_ratelimit_inc | ( | struct infra_cache * | infra, |
| struct sockaddr_storage * | addr, | ||
| socklen_t | addrlen, | ||
| time_t | timenow, | ||
| int | has_cookie, | ||
| int | backoff, | ||
| struct sldns_buffer * | buffer ) |
Update query ratelimit hash and decide whether or not a query should be dropped.
| infra | infra cache |
| addr | client address |
| addrlen | client address length |
| timenow | what time it is now. |
| has_cookie | if the request came with a DNS Cookie. |
| backoff | if backoff is enabled. |
| buffer | with query for logging. |
References infra_find_ip_ratedata(), infra_ip_create_ratedata(), infra_ip_ratelimit, infra_ip_ratelimit_inc(), infra_rate_give_second(), and infra_rate_max().
Referenced by infra_ip_ratelimit_inc().
| int infra_wait_limit_allowed | ( | struct infra_cache * | infra, |
| struct comm_reply * | rep, | ||
| int | cookie_valid, | ||
| struct config_file * | cfg ) |
See if the IP address can have another reply in the wait limit.
References addr_tree_lookup(), comm_reply::client_addr, comm_reply::client_addrlen, infra_find_ip_ratedata(), infra_wait_limit_allowed(), wait_limit_netblock_info::limit, rate_data::mesh_wait, config_file::wait_limit, config_file::wait_limit_cookie, infra_cache::wait_limits_cookie_netblock, and infra_cache::wait_limits_netblock.
Referenced by infra_wait_limit_allowed(), mesh_new_client(), and rate_deldatafunc().
| void infra_wait_limit_inc | ( | struct infra_cache * | infra, |
| struct comm_reply * | rep, | ||
| time_t | timenow, | ||
| struct config_file * | cfg ) |
Increment number of waiting replies for IP.
References comm_reply::client_addr, comm_reply::client_addrlen, infra_find_ip_ratedata(), infra_ip_create_ratedata(), infra_wait_limit_inc(), rate_data::mesh_wait, and config_file::wait_limit.
Referenced by infra_wait_limit_inc(), mesh_new_client(), and rate_deldatafunc().
| void infra_wait_limit_dec | ( | struct infra_cache * | infra, |
| struct comm_reply * | rep, | ||
| struct config_file * | cfg ) |
Decrement number of waiting replies for IP.
References comm_reply::client_addr, comm_reply::client_addrlen, infra_find_ip_ratedata(), infra_wait_limit_dec(), rate_data::mesh_wait, and config_file::wait_limit.
Referenced by infra_wait_limit_dec(), mesh_query_done(), mesh_send_reply(), mesh_serve_expired_callback(), mesh_state_cleanup(), mesh_state_remove_reply(), and rate_deldatafunc().
| int infra_dp_ratelimit = 0 |
ratelimit value for delegation point
ratelimit, unless overridden by domain_limits, 0 is off
ratelimit value for delegation point
Referenced by config_set_option(), do_ratelimit_list(), fr_adjust_infra(), infra_adjust(), infra_create(), infra_find_ratelimit(), infra_ratelimit_dec(), infra_ratelimit_exceeded(), and infra_ratelimit_inc().
| int infra_ip_ratelimit = 0 |
ratelimit value for client ip addresses, in queries per second.
ip ratelimit, 0 is off
ratelimit value for client ip addresses, in queries per second.
Referenced by config_set_option(), do_ip_ratelimit_list(), fr_adjust_infra(), infra_adjust(), infra_create(), infra_ip_ratelimit_inc(), and ip_rate_list().
| int infra_ip_ratelimit_cookie = 0 |
ratelimit value for client ip addresses, in queries per second.
ip ratelimit for DNS Cookie clients, 0 is off
For clients with a valid DNS Cookie.
ratelimit value for client ip addresses, in queries per second.
Referenced by config_set_option(), fr_adjust_infra(), infra_adjust(), and infra_create().