This file contains the infrastructure cache. More...
Data Structures | |
| struct | infra_key |
| Host information kept for every server, per zone. More... | |
| struct | infra_data |
| Host information encompasses host capabilities and retransmission timeouts. More... | |
| struct | infra_cache |
| Infra cache. More... | |
Defines | |
| #define | INFRA_HOST_STARTSIZE 32 |
| infra host cache default hash lookup size | |
| #define | INFRA_BYTES_NAME 14 |
| bytes per zonename reserved in the hostcache, dnamelen(zonename.com.) | |
Functions | |
| 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. | |
| 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) |
| Plain find infra data function (used by the the other functions) | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| size_t | infra_get_mem (struct infra_cache *infra) |
| Get memory used by the infra cache. | |
| size_t | infra_sizefunc (void *k, void *d) |
| calculate size for the hashtable, does not count size of lameness, so the hashtable is a fixed number of items | |
| int | infra_compfunc (void *key1, void *key2) |
| compare two addresses, returns -1, 0, or +1 | |
| void | infra_delkeyfunc (void *k, void *arg) |
| delete key, and destroy the lock | |
| void | infra_deldatafunc (void *d, void *arg) |
| delete data and destroy the lameness hashtable | |
This file contains the infrastructure cache.
| struct infra_cache* infra_create | ( | struct config_file * | cfg | ) | [read] |
Create infra cache.
| cfg,: | config parameters or NULL for defaults. |
References config_file::infra_cache_numhosts, infra_cache::hosts, slabhash_create(), config_file::infra_cache_slabs, INFRA_HOST_STARTSIZE, infra_sizefunc(), infra_compfunc(), infra_delkeyfunc(), infra_deldatafunc(), infra_cache::host_ttl, and config_file::host_ttl.
Referenced by infra_adjust(), and infra_test().
| void infra_delete | ( | struct infra_cache * | infra | ) |
Delete infra cache.
| infra,: | infrastructure cache to delete. |
References slabhash_delete(), and infra_cache::hosts.
Referenced by daemon_delete(), ub_ctx_delete(), infra_adjust(), and infra_test().
| 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_create(), infra_cache::host_ttl, config_file::host_ttl, config_file::infra_cache_numhosts, slabhash_get_size(), infra_cache::hosts, config_file::infra_cache_slabs, slabhash::size, and infra_delete().
Referenced by daemon_apply_cfg(), and context_finalize().
| 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] |
Plain find infra data function (used by the the other functions)
| 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::addrlen, infra_key::addr, infra_key::namelen, infra_key::zonename, infra_key::entry, lruhash_entry::hash, hash_infra(), lruhash_entry::key, lruhash_entry::data, slabhash_lookup(), and infra_cache::hosts.
Referenced by infra_host(), infra_set_lame(), infra_update_tcp_works(), infra_rtt_update(), infra_get_host_rto(), infra_edns_update(), and infra_get_lame_rtt().
| 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 infra_lookup_nottl(), lruhash_entry::data, infra_data::rtt, rtt_info::rto, lruhash_entry::lock, data_entry_init(), USEFUL_SERVER_TOP_TIMEOUT, new_entry(), infra_data::edns_version, infra_data::edns_lame_known, rtt_timeout(), slabhash_insert(), infra_cache::hosts, lruhash_entry::hash, PROBE_MAXRTO, rtt_notimeout(), and infra_data::probedelay.
Referenced by print_dp_details(), serviced_udp_send(), serviced_tcp_send(), and infra_test().
| 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 infra_lookup_nottl(), new_entry(), log_err(), lruhash_entry::data, data_entry_init(), infra_data::isdnsseclame, infra_data::rec_lame, infra_data::lame_type_A, infra_data::lame_other, slabhash_insert(), infra_cache::hosts, lruhash_entry::hash, and lruhash_entry::lock.
Referenced by processQueryResponse(), and infra_test().
| 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 infra_lookup_nottl(), new_entry(), lruhash_entry::data, data_entry_init(), rtt_lost(), infra_data::rtt, rtt_update(), infra_data::probedelay, rtt_info::rto, slabhash_insert(), infra_cache::hosts, lruhash_entry::hash, and lruhash_entry::lock.
Referenced by serviced_tcp_callback(), serviced_udp_callback(), do_infra_rtt(), and infra_test().
| 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 infra_lookup_nottl(), lruhash_entry::data, infra_data::rtt, rtt_info::rto, RTT_MAX_TIMEOUT, and lruhash_entry::lock.
Referenced by serviced_tcp_callback().
| 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 infra_lookup_nottl(), new_entry(), lruhash_entry::data, data_entry_init(), infra_data::edns_version, infra_data::edns_lame_known, slabhash_insert(), infra_cache::hosts, lruhash_entry::hash, and lruhash_entry::lock.
Referenced by serviced_tcp_callback(), serviced_udp_callback(), and infra_test().
| 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 infra_lookup_nottl(), lruhash_entry::data, rtt_unclamped(), infra_data::rtt, rtt_info::rto, PROBE_MAXRTO, infra_data::probedelay, rtt_notimeout(), USEFUL_SERVER_TOP_TIMEOUT, infra_data::ttl, lruhash_entry::lock, infra_data::lame_type_A, infra_data::lame_other, infra_data::isdnsseclame, and infra_data::rec_lame.
Referenced by print_dp_details(), and iter_filter_unsuitable().
| 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 infra_lookup_nottl(), infra_data::ttl, lruhash_entry::data, infra_data::rtt, infra_data::probedelay, and lruhash_entry::lock.
Referenced by print_dp_details().
| size_t infra_get_mem | ( | struct infra_cache * | infra | ) |
Get memory used by the infra cache.
| infra,: | infrastructure cache. |
References slabhash_get_mem(), and infra_cache::hosts.
Referenced by worker_mem_report().