|
Electroneum
|
#include "util/storage/lruhash.h"#include "util/storage/slabhash.h"#include "util/data/packed_rrset.h"
Go to the source code of this file.
Classes | |
| struct | rrset_cache |
Functions | |
| struct rrset_cache * | rrset_cache_create (struct config_file *cfg, struct alloc_cache *alloc) |
| void | rrset_cache_delete (struct rrset_cache *r) |
| struct rrset_cache * | rrset_cache_adjust (struct rrset_cache *r, struct config_file *cfg, struct alloc_cache *alloc) |
| void | rrset_cache_touch (struct rrset_cache *r, struct ub_packed_rrset_key *key, hashvalue_type hash, rrset_id_type id) |
| int | rrset_cache_update (struct rrset_cache *r, struct rrset_ref *ref, struct alloc_cache *alloc, time_t timenow) |
| void | rrset_cache_update_wildcard (struct rrset_cache *rrset_cache, struct ub_packed_rrset_key *rrset, uint8_t *ce, size_t ce_len, struct alloc_cache *alloc, time_t timenow) |
| struct ub_packed_rrset_key * | rrset_cache_lookup (struct rrset_cache *r, uint8_t *qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, uint32_t flags, time_t timenow, int wr) |
| int | rrset_array_lock (struct rrset_ref *ref, size_t count, time_t timenow) |
| void | rrset_array_unlock (struct rrset_ref *ref, size_t count) |
| void | rrset_array_unlock_touch (struct rrset_cache *r, struct regional *scratch, struct rrset_ref *ref, size_t count) |
| void | rrset_update_sec_status (struct rrset_cache *r, struct ub_packed_rrset_key *rrset, time_t now) |
| void | rrset_check_sec_status (struct rrset_cache *r, struct ub_packed_rrset_key *rrset, time_t now) |
| void | rrset_cache_remove (struct rrset_cache *r, uint8_t *nm, size_t nmlen, uint16_t type, uint16_t dclass, uint32_t flags) |
| void | rrset_markdel (void *key) |
This file contains the rrset cache.
Definition in file rrset.h.
| int rrset_array_lock | ( | struct rrset_ref * | ref, |
| size_t | count, | ||
| time_t | timenow | ||
| ) |
Obtain readlock on a (sorted) list of rrset references. Checks TTLs and IDs of the rrsets and rollbacks locking if not Ok.
| ref | array of rrset references (key pointer and ID value). duplicate references are allowed and handled. |
| count | size of array. |
| timenow | used to compare with TTL. |
| void rrset_array_unlock | ( | struct rrset_ref * | ref, |
| size_t | count | ||
| ) |
Unlock array (sorted) of rrset references.
| ref | array of rrset references (key pointer and ID value). duplicate references are allowed and handled. |
| count | size of array. |
| void rrset_array_unlock_touch | ( | struct rrset_cache * | r, |
| struct regional * | scratch, | ||
| struct rrset_ref * | ref, | ||
| size_t | count | ||
| ) |
Unlock array (sorted) of rrset references and at the same time touch LRU on the rrsets. It needs the scratch region for temporary storage as it uses the initial locks to obtain hash values.
| r | the rrset cache. In this cache LRU is updated. |
| scratch | region for temporary storage of hash values. if memory allocation fails, the lru touch fails silently, but locks are released. memory errors are logged. |
| ref | array of rrset references (key pointer and ID value). duplicate references are allowed and handled. |
| count | size of array. |
| struct rrset_cache* rrset_cache_adjust | ( | struct rrset_cache * | r, |
| struct config_file * | cfg, | ||
| struct alloc_cache * | alloc | ||
| ) |
Adjust settings of the cache to settings from the config file. May purge the cache. May recreate the cache. There may be no threading or use by other threads.
| r | rrset cache to adjust (like realloc). |
| cfg | config settings or NULL for defaults. |
| alloc | initial default rrset key allocation. |
| struct rrset_cache* rrset_cache_create | ( | struct config_file * | cfg, |
| struct alloc_cache * | alloc | ||
| ) |
Create rrset cache
| cfg | config settings or NULL for defaults. |
| alloc | initial default rrset key allocation. |
| void rrset_cache_delete | ( | struct rrset_cache * | r | ) |
Delete rrset cache
| r | rrset cache to delete. |
| struct ub_packed_rrset_key* rrset_cache_lookup | ( | struct rrset_cache * | r, |
| uint8_t * | qname, | ||
| size_t | qnamelen, | ||
| uint16_t | qtype, | ||
| uint16_t | qclass, | ||
| uint32_t | flags, | ||
| time_t | timenow, | ||
| int | wr | ||
| ) |
Lookup rrset. You obtain read/write lock. You must unlock before lookup anything of else.
| r | the rrset cache. |
| qname | name of rrset to lookup. |
| qnamelen | length of name of rrset to lookup. |
| qtype | type of rrset to lookup (host order). |
| qclass | class of rrset to lookup (host order). |
| flags | rrset flags, or 0. |
| timenow | used to compare with TTL. |
| wr | set true to get writelock. |
| void rrset_cache_remove | ( | struct rrset_cache * | r, |
| uint8_t * | nm, | ||
| size_t | nmlen, | ||
| uint16_t | type, | ||
| uint16_t | dclass, | ||
| uint32_t | flags | ||
| ) |
Remove an rrset from the cache, by name and type and flags
| r | rrset cache |
| nm | name of rrset |
| nmlen | length of name |
| type | type of rrset |
| dclass | class of rrset, host order |
| flags | flags of rrset, host order |
| void rrset_cache_touch | ( | struct rrset_cache * | r, |
| struct ub_packed_rrset_key * | key, | ||
| hashvalue_type | hash, | ||
| rrset_id_type | id | ||
| ) |
Touch rrset, with given pointer and id. Caller may not hold a lock on ANY rrset, this could give deadlock.
This routine is faster than a hashtable lookup: o no bin_lock is acquired. o no walk through the bin-overflow-list. o no comparison of the entry key to find it.
| r | rrset cache. |
| key | rrset key. Marked recently used (if it was not deleted before the lock is acquired, in that case nothing happens). |
| hash | hash value of the item. Please read it from the key when you have it locked. Used to find slab from slabhash. |
| id | used to check that the item is unchanged and not deleted. |
| int rrset_cache_update | ( | struct rrset_cache * | r, |
| struct rrset_ref * | ref, | ||
| struct alloc_cache * | alloc, | ||
| time_t | timenow | ||
| ) |
Update an rrset in the rrset cache. Stores the information for later use. Will lookup if the rrset is in the cache and perform an update if necessary. If the item was present, and superior, references are returned to that. The passed item is then deallocated with rrset_parsedelete.
A superior rrset is: o rrset with better trust value. o same trust value, different rdata, newly passed rrset is inserted. If rdata is the same, TTL in the cache is updated.
| r | the rrset cache. |
| ref | reference (ptr and id) to the rrset. Pass reference setup for the new rrset. The reference may be changed if the cached rrset is superior. Before calling the rrset is presumed newly allocated and changeable. Afer calling you do not hold a lock, and the rrset is inserted in the hashtable so you need a lock to change it. |
| alloc | how to allocate (and deallocate) the special rrset key. |
| timenow | current time (to see if ttl in cache is expired). |
| void rrset_cache_update_wildcard | ( | struct rrset_cache * | rrset_cache, |
| struct ub_packed_rrset_key * | rrset, | ||
| uint8_t * | ce, | ||
| size_t | ce_len, | ||
| struct alloc_cache * | alloc, | ||
| time_t | timenow | ||
| ) |
Update or add an rrset in the rrset cache using a wildcard dname. Generates wildcard dname by prepending the wildcard label to the closest encloser. Will lookup if the rrset is in the cache and perform an update if necessary.
| rrset_cache | the rrset cache. |
| rrset | which rrset to cache as wildcard. This rrset is left untouched. |
| ce | the closest encloser, will be uses to generate the wildcard dname. |
| ce_len | the closest encloser lenght. |
| alloc | how to allocate (and deallocate) the special rrset key. |
| timenow | current time (to see if ttl in cache is expired). |
| void rrset_check_sec_status | ( | struct rrset_cache * | r, |
| struct ub_packed_rrset_key * | rrset, | ||
| time_t | now | ||
| ) |
Looks up security status of an rrset. Looks up the rrset. If found, checks if rdata is equal, and entry did not expire. If so, it will update the security, trust and rrset-ttl values.
| r | the rrset cache. |
| rrset | This rrset may change security status due to the cache. But its status will only improve, towards secure. |
| now | current time. |
| void rrset_markdel | ( | void * | key | ) |
mark rrset to be deleted, set id=0
| void rrset_update_sec_status | ( | struct rrset_cache * | r, |
| struct ub_packed_rrset_key * | rrset, | ||
| time_t | now | ||
| ) |
Update security status of an rrset. Looks up the rrset. If found, checks if rdata is equal. If so, it will update the security, trust and rrset-ttl values. The values are only updated if security is increased (towards secure).
| r | the rrset cache. |
| rrset | which rrset to attempt to update. This rrset is left untouched. The rrset in the cache is updated in-place. |
| now | current time. |