|
unbound
0.1
|
This file contains the infrastructure cache. More...
#include "config.h"#include <ldns/rr.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"Defines | |
| #define | PROBE_MAXRTO 12000 /* in msec */ |
| Timeout when only a single probe query per IP is allowed. | |
Functions | |
| 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)) |
| struct infra_cache * | infra_create (struct config_file *cfg) |
| Create infra cache. | |
| 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_t | hash_addr (struct sockaddr_storage *addr, socklen_t addrlen) |
| calculate the hash value for a host key | |
| static hashvalue_t | 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, uint32_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, uint32_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, uint32_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, uint32_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 roundtrip, int orig_rtt, uint32_t timenow) |
| Update rtt information for the host. | |
| int | 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, uint32_t timenow) |
| 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, uint32_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, uint32_t timenow) |
| Get Lameness information and average RTT if host is in the cache. | |
| size_t | infra_get_mem (struct infra_cache *infra) |
| Get memory used by the infra cache. | |
This file contains the infrastructure cache.
| #define PROBE_MAXRTO 12000 /* in msec */ |
Timeout when only a single probe query per IP is allowed.
Referenced by infra_get_lame_rtt(), and infra_host().
| struct infra_cache* infra_create | ( | struct config_file * | cfg | ) | [read] |
Create infra cache.
| cfg,: | config parameters or NULL for defaults. |
References infra_cache::host_ttl, config_file::host_ttl, infra_cache::hosts, config_file::infra_cache_numhosts, config_file::infra_cache_slabs, infra_compfunc(), infra_deldatafunc(), infra_delkeyfunc(), INFRA_HOST_STARTSIZE, infra_sizefunc(), and slabhash_create().
Referenced by infra_adjust(), and infra_test().
| void infra_delete | ( | struct infra_cache * | infra | ) |
Delete infra cache.
| infra,: | infrastructure cache to delete. |
References infra_cache::hosts, and slabhash_delete().
Referenced by daemon_delete(), infra_adjust(), infra_test(), and ub_ctx_delete().
| struct infra_cache* infra_adjust | ( | struct infra_cache * | infra, |
| struct config_file * | cfg | ||
| ) | [read] |
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::host_ttl, config_file::host_ttl, infra_cache::hosts, config_file::infra_cache_numhosts, config_file::infra_cache_slabs, infra_create(), infra_delete(), slabhash::size, and slabhash_get_size().
Referenced by context_finalize(), and daemon_apply_cfg().
| 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 | ||
| ) | [read] |
lookup version that does not check host ttl (you check it)
Plain find infra data function (used by the the other functions)
References infra_key::addr, infra_key::addrlen, lruhash_entry::data, infra_key::entry, lruhash_entry::hash, hash_infra(), infra_cache::hosts, 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_rtt_update(), infra_set_lame(), and infra_update_tcp_works().
| static struct lruhash_entry* new_entry | ( | struct infra_cache * | infra, |
| struct sockaddr_storage * | addr, | ||
| socklen_t | addrlen, | ||
| uint8_t * | name, | ||
| size_t | namelen, | ||
| uint32_t | tm | ||
| ) | [static, read] |
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, and infra_key::zonename.
Referenced by infra_edns_update(), infra_host(), infra_rtt_update(), and infra_set_lame().
| int infra_host | ( | struct infra_cache * | infra, |
| struct sockaddr_storage * | addr, | ||
| socklen_t | addrlen, | ||
| uint8_t * | name, | ||
| size_t | namelen, | ||
| uint32_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_lookup_nottl(), lruhash_entry::lock, new_entry(), PROBE_MAXRTO, infra_data::probedelay, rtt_info::rto, infra_data::rtt, rtt_notimeout(), rtt_timeout(), slabhash_insert(), and USEFUL_SERVER_TOP_TIMEOUT.
Referenced by 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, | ||
| uint32_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_data::isdnsseclame, infra_data::lame_other, infra_data::lame_type_A, lruhash_entry::lock, log_err(), new_entry(), infra_data::rec_lame, and slabhash_insert().
Referenced by 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(), lruhash_entry::lock, rtt_info::rto, infra_data::rtt, and RTT_MAX_TIMEOUT.
Referenced by 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 | roundtrip, | ||
| int | orig_rtt, | ||
| uint32_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 |
| 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(), lruhash_entry::lock, new_entry(), infra_data::probedelay, rtt_info::rto, infra_data::rtt, rtt_lost(), rtt_update(), and slabhash_insert().
Referenced by do_infra_rtt(), infra_test(), serviced_tcp_callback(), and serviced_udp_callback().
| int 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, | ||
| uint32_t | timenow | ||
| ) |
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. |
References lruhash_entry::data, infra_lookup_nottl(), lruhash_entry::lock, infra_data::probedelay, infra_data::rtt, and infra_data::ttl.
Referenced by 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, | ||
| uint32_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_lookup_nottl(), lruhash_entry::lock, new_entry(), and slabhash_insert().
Referenced by 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, | ||
| uint32_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_lookup_nottl(), infra_data::isdnsseclame, infra_data::lame_other, infra_data::lame_type_A, lruhash_entry::lock, PROBE_MAXRTO, infra_data::probedelay, infra_data::rec_lame, rtt_info::rto, infra_data::rtt, rtt_notimeout(), rtt_unclamped(), infra_data::ttl, and USEFUL_SERVER_TOP_TIMEOUT.
Referenced by iter_filter_unsuitable(), and print_dp_details().
| size_t infra_get_mem | ( | struct infra_cache * | infra | ) |
Get memory used by the infra cache.
| infra,: | infrastructure cache. |
References infra_cache::hosts, and slabhash_get_mem().
Referenced by worker_mem_report().
1.7.6.1