This file contains the data storage for RRsets. More...
#include "config.h"#include <ldns/wire2host.h>#include "util/data/packed_rrset.h"#include "util/data/dname.h"#include "util/storage/lookup3.h"#include "util/log.h"#include "util/alloc.h"#include "util/regional.h"#include "util/net_help.h"Functions | |
| void | ub_packed_rrset_parsedelete (struct ub_packed_rrset_key *pkey, struct alloc_cache *alloc) |
| Delete packed rrset key and data, not entered in hashtables yet. | |
| size_t | ub_rrset_sizefunc (void *key, void *data) |
| Calculate memory size of rrset entry. | |
| size_t | packed_rrset_sizeof (struct packed_rrset_data *d) |
| Memory size of rrset data. | |
| int | ub_rrset_compare (void *k1, void *k2) |
| compares two rrset keys. | |
| void | ub_rrset_key_delete (void *key, void *userdata) |
| Old key to be deleted. | |
| void | rrset_data_delete (void *data, void *userdata) |
| Old data to be deleted. | |
| int | rrsetdata_equal (struct packed_rrset_data *d1, struct packed_rrset_data *d2) |
| compare two rrset data structures. | |
| hashvalue_t | rrset_key_hash (struct packed_rrset_key *key) |
| Calculate hash value for a packed rrset key. | |
| void | packed_rrset_ptr_fixup (struct packed_rrset_data *data) |
| Fixup pointers in fixed data packed_rrset_data blob. | |
| void | get_cname_target (struct ub_packed_rrset_key *rrset, uint8_t **dname, size_t *dname_len) |
| Utility procedure to extract CNAME target name from its rdata. | |
| void | packed_rrset_ttl_add (struct packed_rrset_data *data, uint32_t add) |
| Fixup TTLs in fixed data packed_rrset_data blob. | |
| const char * | rrset_trust_to_string (enum rrset_trust s) |
| Get a printable string for a rrset trust value. | |
| const char * | sec_status_to_string (enum sec_status s) |
| Get a printable string for a security status value. | |
| void | log_rrset_key (enum verbosity_value v, const char *str, struct ub_packed_rrset_key *rrset) |
| Print string with neat domain name, type, class from rrset. | |
| uint32_t | ub_packed_rrset_ttl (struct ub_packed_rrset_key *key) |
| Get TTL of rrset. | |
| struct ub_packed_rrset_key * | packed_rrset_copy_region (struct ub_packed_rrset_key *key, struct regional *region, uint32_t now) |
| Allocate rrset in region - no more locks needed. | |
| struct ub_packed_rrset_key * | packed_rrset_copy_alloc (struct ub_packed_rrset_key *key, struct alloc_cache *alloc, uint32_t now) |
| Allocate rrset with malloc (from region or you are holding the lock). | |
| struct ub_packed_rrset_key * | ub_packed_rrset_heap_key (ldns_rr_list *rrset) |
| Create a ub_packed_rrset_key allocated on the heap. | |
| struct packed_rrset_data * | packed_rrset_heap_data (ldns_rr_list *rrset) |
| Create packed_rrset data on the heap. | |
| static ldns_rr * | torr (struct ub_packed_rrset_key *k, ldns_buffer *buf, size_t i) |
| convert i'th rr to ldns_rr | |
| ldns_rr_list * | packed_rrset_to_rr_list (struct ub_packed_rrset_key *k, ldns_buffer *buf) |
| Convert packed rrset to ldns rr list. | |
This file contains the data storage for RRsets.
| void ub_packed_rrset_parsedelete | ( | struct ub_packed_rrset_key * | pkey, |
| struct alloc_cache * | alloc | ||
| ) |
Delete packed rrset key and data, not entered in hashtables yet.
Used during parsing.
| pkey,: | rrset key structure with locks, key and data pointers. |
| alloc,: | where to return the unfree-able key structure. |
References ub_packed_rrset_key::entry, lruhash_entry::data, ub_packed_rrset_key::rk, packed_rrset_key::dname, ub_packed_rrset_key::id, and alloc_special_release().
Referenced by move_into_cache(), rrset_cache_update(), verifytest_file(), and reply_info_parsedelete().
| size_t ub_rrset_sizefunc | ( | void * | key, |
| void * | data | ||
| ) |
Calculate memory size of rrset entry.
For hash table usage.
| key,: | struct ub_packed_rrset_key*. |
| data,: | struct packed_rrset_data*. |
References packed_rrset_sizeof(), ub_packed_rrset_key::entry, and lruhash_entry::lock.
Referenced by rrset_cache_create(), and fptr_whitelist_hash_sizefunc().
| size_t packed_rrset_sizeof | ( | struct packed_rrset_data * | data | ) |
Memory size of rrset data.
RRset data must be filled in correctly.
| data,: | data to examine. |
References packed_rrset_data::rrsig_count, packed_rrset_data::rr_data, packed_rrset_data::count, packed_rrset_data::rr_len, and log_assert.
Referenced by repinfo_copy_rrsets(), ub_rrset_sizefunc(), packed_rrset_copy_region(), packed_rrset_copy_alloc(), key_entry_sizefunc(), key_entry_copy_toregion(), key_entry_copy(), key_entry_create_rrset(), key_entry_get_rrset(), and process_dlv_response().
| int ub_rrset_compare | ( | void * | k1, |
| void * | k2 | ||
| ) |
compares two rrset keys.
| k1,: | struct ub_packed_rrset_key*. |
| k2,: | struct ub_packed_rrset_key*. |
References ub_packed_rrset_key::rk, packed_rrset_key::type, packed_rrset_key::dname_len, query_dname_compare(), packed_rrset_key::dname, packed_rrset_key::rrset_class, and packed_rrset_key::flags.
Referenced by rrset_cache_create(), and fptr_whitelist_hash_compfunc().
| void ub_rrset_key_delete | ( | void * | key, |
| void * | userdata | ||
| ) |
Old key to be deleted.
RRset keys are recycled via alloc. The id is set to 0. So that other threads, after acquiring a lock always get the correct value, in this case the 0 deleted-special value.
| key,: | struct ub_packed_rrset_key*. |
| userdata,: | alloc structure to use for recycling. |
References ub_packed_rrset_key::id, ub_packed_rrset_key::rk, packed_rrset_key::dname, and alloc_special_release().
Referenced by rrset_cache_create(), and fptr_whitelist_hash_delkeyfunc().
| void rrset_data_delete | ( | void * | data, |
| void * | userdata | ||
| ) |
Old data to be deleted.
| data,: | what to delete. |
| userdata,: | user data ptr. |
Referenced by rrset_cache_create(), and fptr_whitelist_hash_deldatafunc().
| int rrsetdata_equal | ( | struct packed_rrset_data * | d1, |
| struct packed_rrset_data * | d2 | ||
| ) |
compare two rrset data structures.
Compared rdata and rrsigdata, not the trust or ttl value.
| d1,: | data to compare. |
| d2,: | data to compare. |
References packed_rrset_data::count, packed_rrset_data::rrsig_count, packed_rrset_data::rr_len, and packed_rrset_data::rr_data.
Referenced by rrset_cache_update(), rrset_update_sec_status(), and rrset_check_sec_status().
| hashvalue_t rrset_key_hash | ( | struct packed_rrset_key * | key | ) |
Calculate hash value for a packed rrset key.
| key,: | the rrset key with name, type, class, flags. |
References packed_rrset_key::type, dname_query_hash(), packed_rrset_key::dname, packed_rrset_key::rrset_class, and packed_rrset_key::flags.
Referenced by move_into_cache(), iter_store_parentside_rrset(), iter_store_parentside_neg(), synth_dname_msg(), rrset_cache_lookup(), rrset_update_sec_status(), rrset_check_sec_status(), and rrset_cache_remove().
| void packed_rrset_ptr_fixup | ( | struct packed_rrset_data * | data | ) |
Fixup pointers in fixed data packed_rrset_data blob.
After a memcpy of the data for example. Will set internal pointers right.
| data,: | rrset data structure. Otherwise correctly filled in. |
References packed_rrset_data::count, packed_rrset_data::rrsig_count, packed_rrset_data::rr_len, packed_rrset_data::rr_data, and packed_rrset_data::rr_ttl.
Referenced by move_into_cache(), iter_store_parentside_neg(), synth_dname_msg(), repinfo_copy_rrsets(), packed_rrset_copy_region(), packed_rrset_copy_alloc(), key_entry_copy_toregion(), key_entry_copy(), key_entry_create_rrset(), key_entry_get_rrset(), and process_dlv_response().
| void get_cname_target | ( | struct ub_packed_rrset_key * | rrset, |
| uint8_t ** | dname, | ||
| size_t * | dname_len | ||
| ) |
Utility procedure to extract CNAME target name from its rdata.
Failsafes; it will change passed dname to a valid dname or do nothing.
| rrset,: | the rrset structure. Must be a CNAME. Only first RR is used (multiple RRs are technically illegal anyway). Also works on type DNAME. Returns target name. |
| dname,: | this pointer is updated to point into the cname rdata. If a failsafe fails, nothing happens to the pointer (such as the rdata was not a valid dname, not a CNAME, ...). |
| dname_len,: | length of dname is returned. |
References ub_packed_rrset_key::rk, packed_rrset_key::type, ub_packed_rrset_key::entry, lruhash_entry::data, packed_rrset_data::count, packed_rrset_data::rr_len, packed_rrset_data::rr_data, and dname_valid().
Referenced by response_type_from_cache(), response_type_from_server(), handle_cname_response(), synth_dname_msg(), reply_find_final_cname_target(), reply_find_answer_rrset(), reply_check_cname_chain(), and val_chase_cname().
| void packed_rrset_ttl_add | ( | struct packed_rrset_data * | data, |
| uint32_t | add | ||
| ) |
Fixup TTLs in fixed data packed_rrset_data blob.
| data,: | rrset data structure. Otherwise correctly filled in. |
| add,: | how many seconds to add, pass time(0) for example. |
References packed_rrset_data::count, packed_rrset_data::rrsig_count, packed_rrset_data::ttl, and packed_rrset_data::rr_ttl.
Referenced by store_rrset(), dns_cache_store(), and packed_rrset_copy_alloc().
| const char* rrset_trust_to_string | ( | enum rrset_trust | s | ) |
Get a printable string for a rrset trust value.
| s,: | rrset trust value |
References rrset_trust_none, rrset_trust_add_noAA, rrset_trust_auth_noAA, rrset_trust_add_AA, rrset_trust_nonauth_ans_AA, rrset_trust_ans_noAA, rrset_trust_glue, rrset_trust_auth_AA, rrset_trust_ans_AA, rrset_trust_sec_noglue, rrset_trust_prim_noglue, rrset_trust_validated, and rrset_trust_ultimate.
| const char* sec_status_to_string | ( | enum sec_status | s | ) |
Get a printable string for a security status value.
| s,: | security status |
References sec_status_unchecked, sec_status_bogus, sec_status_indeterminate, sec_status_insecure, and sec_status_secure.
Referenced by verifytest_rrset(), verify_dnskey(), val_verify_rrset(), already_validated(), validate_nameerror_response(), validate_referral_response(), processValidate(), primeResponseToKE(), and process_dlv_response().
| void log_rrset_key | ( | enum verbosity_value | v, |
| const char * | str, | ||
| struct ub_packed_rrset_key * | rrset | ||
| ) |
Print string with neat domain name, type, class from rrset.
| v,: | at what verbosity level to print this. |
| str,: | string of message. |
| rrset,: | structure with name, type and class. |
References verbosity, log_nametypeclass(), ub_packed_rrset_key::rk, packed_rrset_key::dname, packed_rrset_key::type, and packed_rrset_key::rrset_class.
Referenced by iter_store_parentside_NS(), iter_store_parentside_neg(), iter_lookup_parent_NS_from_cache(), iter_lookup_parent_glue_from_cache(), processQueryResponse(), and processTargetResponse().
| uint32_t ub_packed_rrset_ttl | ( | struct ub_packed_rrset_key * | key | ) |
Get TTL of rrset.
RRset data must be filled in correctly.
| key,: | rrset key, with data to examine. |
References packed_rrset_data::ttl.
Referenced by iter_store_parentside_neg(), val_nsec_prove_nodata_dsreply(), and ds_response_to_ke().
| struct ub_packed_rrset_key* packed_rrset_copy_region | ( | struct ub_packed_rrset_key * | key, |
| struct regional * | region, | ||
| uint32_t | now | ||
| ) | [read] |
Allocate rrset in region - no more locks needed.
| key,: | a (just from rrset cache looked up) rrset key + valid, packed data record. |
| region,: | where to alloc the copy |
| now,: | adjust the TTLs to be relative (subtract from all TTLs). |
References regional_alloc(), ub_packed_rrset_key::entry, lruhash_entry::data, ub_packed_rrset_key::id, lruhash_entry::hash, lruhash_entry::key, ub_packed_rrset_key::rk, packed_rrset_key::dname, regional_alloc_init(), packed_rrset_key::dname_len, packed_rrset_sizeof(), packed_rrset_ptr_fixup(), packed_rrset_data::count, packed_rrset_data::rrsig_count, packed_rrset_data::rr_ttl, and packed_rrset_data::ttl.
Referenced by load_ref(), store_rrsets(), addr_to_additional(), find_add_ds(), dns_msg_authadd(), tomsg(), rrset_msg(), synth_dname_msg(), grab_nsec(), and val_find_DS().
| struct ub_packed_rrset_key* packed_rrset_copy_alloc | ( | struct ub_packed_rrset_key * | key, |
| struct alloc_cache * | alloc, | ||
| uint32_t | now | ||
| ) | [read] |
Allocate rrset with malloc (from region or you are holding the lock).
| key,: | key with data entry. |
| alloc,: | alloc_cache to create rrset_keys |
| now,: | adjust the TTLs to be absolute (add to all TTLs). |
References alloc_special_obtain(), ub_packed_rrset_key::entry, lruhash_entry::data, lruhash_entry::hash, ub_packed_rrset_key::rk, packed_rrset_key::dname, memdup(), packed_rrset_key::dname_len, alloc_special_release(), packed_rrset_sizeof(), packed_rrset_ptr_fixup(), and packed_rrset_ttl_add().
Referenced by iter_store_parentside_rrset().
| struct ub_packed_rrset_key* ub_packed_rrset_heap_key | ( | ldns_rr_list * | rrset | ) | [read] |
Create a ub_packed_rrset_key allocated on the heap.
It therefore does not have the correct ID value, and cannot be used inside the cache. It can be used in storage outside of the cache. Keys for the cache have to be obtained from alloc.h .
| rrset,: | the ldns rr set. |
References ub_packed_rrset_key::rk, packed_rrset_key::type, packed_rrset_key::rrset_class, packed_rrset_key::dname_len, packed_rrset_key::dname, and memdup().
Referenced by autr_assemble().
| struct packed_rrset_data* packed_rrset_heap_data | ( | ldns_rr_list * | rrset | ) | [read] |
Create packed_rrset data on the heap.
| rrset,: | the ldns rr set with the data to copy. |
References packed_rrset_data::count, packed_rrset_data::rrsig_count, packed_rrset_data::ttl, packed_rrset_data::rr_len, packed_rrset_data::rr_data, and packed_rrset_data::rr_ttl.
Referenced by autr_assemble().
| ldns_rr_list* packed_rrset_to_rr_list | ( | struct ub_packed_rrset_key * | rrset, |
| ldns_buffer * | buf | ||
| ) |
Convert packed rrset to ldns rr list.
| rrset,: | packed rrset. |
| buf,: | scratch buffer. |
References ub_packed_rrset_key::entry, lruhash_entry::data, packed_rrset_data::count, packed_rrset_data::rrsig_count, and torr().
Referenced by do_list_local_data(), reply_equal(), print_packet_rrsets(), check_contains_revoked(), update_events(), and autr_debug_print_tp().