Electroneum
val_neg.h File Reference
#include "util/locks.h"
#include "util/rbtree.h"
Include dependency graph for val_neg.h:

Go to the source code of this file.

Classes

struct  val_neg_cache
 
struct  val_neg_zone
 
struct  val_neg_data
 

Functions

struct val_neg_cacheval_neg_create (struct config_file *cfg, size_t maxiter)
 
size_t val_neg_get_mem (struct val_neg_cache *neg)
 
void neg_cache_delete (struct val_neg_cache *neg)
 
int val_neg_data_compare (const void *a, const void *b)
 
int val_neg_zone_compare (const void *a, const void *b)
 
void val_neg_addreply (struct val_neg_cache *neg, struct reply_info *rep)
 
void val_neg_addreferral (struct val_neg_cache *neg, struct reply_info *rep, uint8_t *zone)
 
int val_neg_dlvlookup (struct val_neg_cache *neg, uint8_t *qname, size_t len, uint16_t qclass, struct rrset_cache *rrset_cache, time_t now)
 
struct dns_msgval_neg_getmsg (struct val_neg_cache *neg, struct query_info *qinfo, struct regional *region, struct rrset_cache *rrset_cache, struct sldns_buffer *buf, time_t now, int addsoa, uint8_t *topname, struct config_file *cfg)
 
void neg_insert_data (struct val_neg_cache *neg, struct val_neg_zone *zone, struct ub_packed_rrset_key *nsec)
 
void neg_delete_data (struct val_neg_cache *neg, struct val_neg_data *el)
 
struct val_neg_zoneneg_find_zone (struct val_neg_cache *neg, uint8_t *nm, size_t len, uint16_t dclass)
 
struct val_neg_zoneneg_create_zone (struct val_neg_cache *neg, uint8_t *nm, size_t nm_len, uint16_t dclass)
 
void val_neg_zone_take_inuse (struct val_neg_zone *zone)
 

Detailed Description

This file contains helper functions for the validator module. The functions help with aggressive negative caching. This creates new denials of existence, and proofs for absence of types from cached NSEC records.

Definition in file val_neg.h.

Function Documentation

◆ neg_cache_delete()

void neg_cache_delete ( struct val_neg_cache neg)

Destroy negative cache. There must no longer be any other threads.

Parameters
negnegative cache.

◆ neg_create_zone()

struct val_neg_zone* neg_create_zone ( struct val_neg_cache neg,
uint8_t nm,
size_t  nm_len,
uint16_t  dclass 
)

Create a new zone. Does not do locking.

Parameters
negnegative cache
nmwhat to look for.
nm_lenlength of name.
dclassclass of zone, host order.
Returns
zone or NULL if out of memory.

◆ neg_delete_data()

void neg_delete_data ( struct val_neg_cache neg,
struct val_neg_data el 
)

Delete a data element from the negative cache. May delete other data elements to keep tree coherent, or only mark the element as 'not in use'. Does not do locking.

Parameters
negnegative cache.
eldata element to delete.

◆ neg_find_zone()

struct val_neg_zone* neg_find_zone ( struct val_neg_cache neg,
uint8_t nm,
size_t  len,
uint16_t  dclass 
)

Find the given zone, from the SOA owner name and class Does not do locking.

Parameters
negnegative cache
nmwhat to look for.
lenlength of nm
dclassclass to look for.
Returns
zone or NULL if not found.

◆ neg_insert_data()

void neg_insert_data ( struct val_neg_cache neg,
struct val_neg_zone zone,
struct ub_packed_rrset_key nsec 
)

Insert data into the data tree of a zone Does not do locking.

Parameters
negnegative cache
zonezone to insert into
nsecrecord to insert.

◆ val_neg_addreferral()

void val_neg_addreferral ( struct val_neg_cache neg,
struct reply_info rep,
uint8_t zone 
)

Insert NSECs from this referral into the negative cache for reference.

Parameters
negnegative cache
repreferral reply with NS, NSECs.
zonebailiwick for the referral. Errors are ignored, means that storage is omitted.

◆ val_neg_addreply()

void val_neg_addreply ( struct val_neg_cache neg,
struct reply_info rep 
)

Insert NSECs from this message into the negative cache for reference.

Parameters
negnegative cache
repreply with NSECs. Errors are ignored, means that storage is omitted.

◆ val_neg_create()

struct val_neg_cache* val_neg_create ( struct config_file cfg,
size_t  maxiter 
)

Create negative cache

Parameters
cfgconfig options.
maxitermax nsec3 iterations allowed.
Returns
neg cache, empty or NULL on failure.

◆ val_neg_data_compare()

int val_neg_data_compare ( const void *  a,
const void *  b 
)

Comparison function for rbtree val neg data elements

◆ val_neg_dlvlookup()

int val_neg_dlvlookup ( struct val_neg_cache neg,
uint8_t qname,
size_t  len,
uint16_t  qclass,
struct rrset_cache rrset_cache,
time_t  now 
)

Perform a DLV style lookup During the lookup, we could find out that data has expired. In that case the neg_cache entries are removed, and lookup fails.

Parameters
negnegative cache.
qnamename to look for
lenlength of qname.
qclassclass to look in.
rrset_cachethe rrset cache, for NSEC lookups.
nowcurrent time for ttl checks.
Returns
0 on error 0 if no proof of negative 1 if indeed negative was proven thus, qname DLV qclass does not exist.

◆ val_neg_get_mem()

size_t val_neg_get_mem ( struct val_neg_cache neg)

see how much memory is in use by the negative cache.

Parameters
negnegative cache
Returns
number of bytes in use.

◆ val_neg_getmsg()

struct dns_msg* val_neg_getmsg ( struct val_neg_cache neg,
struct query_info qinfo,
struct regional region,
struct rrset_cache rrset_cache,
struct sldns_buffer buf,
time_t  now,
int  addsoa,
uint8_t topname,
struct config_file cfg 
)

For the given query, try to get a reply out of the negative cache. The reply still needs to be validated.

Parameters
negnegative cache.
qinfoquery
regionwhere to allocate reply.
rrset_cacherrset cache.
buftemporary buffer.
nowto check TTLs against.
addsoaif true, produce result for external consumption. if false, do not add SOA - for unbound-internal consumption.
topnamedo not look higher than this name, so that the result cannot be taken from a zone above the current trust anchor. Which could happen with multiple islands of trust. if NULL, then no trust anchor is used, but also the algorithm becomes more conservative, especially for opt-out zones, since the receiver may have a trust-anchor below the optout and thus the optout cannot be used to create a proof from the negative cache.
cfgconfig options.
Returns
a reply message if something was found. This reply may still need validation. NULL if nothing found (or out of memory).

◆ val_neg_zone_compare()

int val_neg_zone_compare ( const void *  a,
const void *  b 
)

Comparison function for rbtree val neg zone elements

◆ val_neg_zone_take_inuse()

void val_neg_zone_take_inuse ( struct val_neg_zone zone)

take a zone into use. increases counts of parents. Does not do locking.

Parameters
zonezone to take into use.