rpz.c File Reference

This file contains functions to enable RPZ service. More...

#include "config.h"
#include "services/rpz.h"
#include "util/config_file.h"
#include "sldns/wire2str.h"
#include "sldns/str2wire.h"
#include "util/data/dname.h"
#include "util/net_help.h"
#include "util/log.h"
#include "util/locks.h"
#include "util/regional.h"
#include "util/data/msgencode.h"
#include "services/cache/dns.h"
#include "iterator/iterator.h"
#include "iterator/iter_delegpt.h"
#include "daemon/worker.h"

Data Structures

struct  matched_delegation_point
 

Typedefs

typedef struct resp_addr rpz_aclnode_type
 

Functions

const char * rpz_action_to_string (enum rpz_action a)
 string for RPZ action enum More...
 
static enum rpz_action rpz_config_to_action (char *a)
 RPZ action enum for config string.
 
static const char * rpz_trigger_to_string (enum rpz_trigger r)
 string for RPZ trigger enum
 
static uint8_t * get_tld_label (uint8_t *dname, size_t maxdnamelen)
 Get the label that is just before the root label. More...
 
static int rpz_type_ignored (uint16_t rr_type)
 The RR types that are to be ignored. More...
 
static enum rpz_action rpz_rr_to_action (uint16_t rr_type, uint8_t *rdatawl, size_t rdatalen)
 Classify RPZ action for RR type/rdata. More...
 
static enum localzone_type rpz_action_to_localzone_type (enum rpz_action a)
 
enum respip_action rpz_action_to_respip_action (enum rpz_action a)
 Classify respip action for RPZ action. More...
 
static enum rpz_action localzone_type_to_rpz_action (enum localzone_type lzt)
 
enum rpz_action respip_action_to_rpz_action (enum respip_action a)
 
static enum rpz_trigger rpz_dname_to_trigger (uint8_t *dname, size_t dname_len)
 Get RPZ trigger for dname. More...
 
static struct clientip_synthesized_rrsetrpz_clientip_synthesized_set_create (void)
 
static void rpz_clientip_synthesized_rr_delete (rbnode_type *n, void *ATTR_UNUSED(arg))
 
static void rpz_clientip_synthesized_set_delete (struct clientip_synthesized_rrset *set)
 
void rpz_delete (struct rpz *r)
 Delete RPZ. More...
 
int rpz_clear (struct rpz *r)
 Clear local-zones and respip data in RPZ, used after reloading file or AXFR/HTTP transfer. More...
 
void rpz_finish_config (struct rpz *r)
 Prepare RPZ after processing feed content. More...
 
static struct ub_packed_rrset_keynew_cname_override (struct regional *region, uint8_t *ct, size_t ctlen)
 new rrset containing CNAME override, does not yet contain a dname
 
static void delete_cname_override (struct rpz *r)
 delete the cname override
 
static int rpz_apply_cfg_elements (struct rpz *r, struct config_auth *p)
 Apply rpz config elements to the rpz structure, false on failure.
 
struct rpzrpz_create (struct config_auth *p)
 Create RPZ. More...
 
int rpz_config (struct rpz *r, struct config_auth *p)
 Change config on rpz, after reload. More...
 
static size_t strip_dname_origin (uint8_t *dname, size_t dnamelen, size_t originlen, uint8_t *newdname, size_t maxnewdnamelen)
 Remove RPZ zone name from dname Copy dname to newdname, without the originlen number of trailing bytes.
 
static void rpz_insert_local_zones_trigger (struct local_zones *lz, uint8_t *dname, size_t dnamelen, enum rpz_action a, uint16_t rrtype, uint16_t rrclass, uint32_t ttl, uint8_t *rdata, size_t rdata_len, uint8_t *rr, size_t rr_len)
 
static void rpz_log_dname (char const *msg, uint8_t *dname, size_t dname_len)
 
static void rpz_insert_qname_trigger (struct rpz *r, uint8_t *dname, size_t dnamelen, enum rpz_action a, uint16_t rrtype, uint16_t rrclass, uint32_t ttl, uint8_t *rdata, size_t rdata_len, uint8_t *rr, size_t rr_len)
 
static int rpz_strip_nsdname_suffix (uint8_t *dname, size_t maxdnamelen, uint8_t **stripdname, size_t *stripdnamelen)
 
static void rpz_insert_nsdname_trigger (struct rpz *r, uint8_t *dname, size_t dnamelen, enum rpz_action a, uint16_t rrtype, uint16_t rrclass, uint32_t ttl, uint8_t *rdata, size_t rdata_len, uint8_t *rr, size_t rr_len)
 
static int rpz_insert_ipaddr_based_trigger (struct respip_set *set, struct sockaddr_storage *addr, socklen_t addrlen, int net, enum rpz_action a, uint16_t rrtype, uint16_t rrclass, uint32_t ttl, uint8_t *rdata, size_t rdata_len, uint8_t *rr, size_t rr_len)
 
static struct clientip_synthesized_rrrpz_clientip_ensure_entry (struct clientip_synthesized_rrset *set, struct sockaddr_storage *addr, socklen_t addrlen, int net)
 
static void rpz_report_rrset_error (const char *msg, uint8_t *rr, size_t rr_len)
 
static struct local_rrsetrpz_clientip_new_rrset (struct regional *region, struct clientip_synthesized_rr *raddr, uint16_t rrtype, uint16_t rrclass)
 
static int rpz_clientip_enter_rr (struct regional *region, struct clientip_synthesized_rr *raddr, uint16_t rrtype, uint16_t rrclass, time_t ttl, uint8_t *rdata, size_t rdata_len)
 
static int rpz_clientip_insert_trigger_rr (struct clientip_synthesized_rrset *set, struct sockaddr_storage *addr, socklen_t addrlen, int net, enum rpz_action a, uint16_t rrtype, uint16_t rrclass, uint32_t ttl, uint8_t *rdata, size_t rdata_len, uint8_t *rr, size_t rr_len)
 
static int rpz_insert_clientip_trigger (struct rpz *r, uint8_t *dname, size_t dnamelen, enum rpz_action a, uint16_t rrtype, uint16_t rrclass, uint32_t ttl, uint8_t *rdata, size_t rdata_len, uint8_t *rr, size_t rr_len)
 
static int rpz_insert_nsip_trigger (struct rpz *r, uint8_t *dname, size_t dnamelen, enum rpz_action a, uint16_t rrtype, uint16_t rrclass, uint32_t ttl, uint8_t *rdata, size_t rdata_len, uint8_t *rr, size_t rr_len)
 
static int rpz_insert_response_ip_trigger (struct rpz *r, uint8_t *dname, size_t dnamelen, enum rpz_action a, uint16_t rrtype, uint16_t rrclass, uint32_t ttl, uint8_t *rdata, size_t rdata_len, uint8_t *rr, size_t rr_len)
 Insert RR into RPZ's respip_set.
 
int rpz_insert_rr (struct rpz *r, uint8_t *azname, size_t aznamelen, uint8_t *dname, size_t dnamelen, uint16_t rr_type, uint16_t rr_class, uint32_t rr_ttl, uint8_t *rdatawl, size_t rdatalen, uint8_t *rr, size_t rr_len)
 Create policy from RR and add to this RPZ. More...
 
static struct local_zonerpz_find_zone (struct local_zones *zones, uint8_t *qname, size_t qname_len, uint16_t qclass, int only_exact, int wr, int zones_keep_lock)
 Find RPZ local-zone by qname. More...
 
static struct local_rrsetrpz_find_synthesized_rrset (uint16_t qtype, struct clientip_synthesized_rr *data, int alias_ok)
 Find entry for RR type in the list of rrsets for the clientip.
 
static int rpz_data_delete_rr (struct local_zone *z, uint8_t *policydname, size_t policydnamelen, uint16_t rr_type, uint8_t *rdata, size_t rdatalen)
 Remove RR from RPZ's local-data. More...
 
static int rpz_rrset_delete_rr (struct resp_addr *raddr, uint16_t rr_type, uint8_t *rdata, size_t rdatalen)
 Remove RR from RPZ's respip set. More...
 
static void rpz_remove_local_zones_trigger (struct local_zones *zones, uint8_t *dname, size_t dnamelen, enum rpz_action a, uint16_t rr_type, uint16_t rr_class, uint8_t *rdatawl, size_t rdatalen)
 Remove RR from rpz localzones structure.
 
static void rpz_remove_qname_trigger (struct rpz *r, uint8_t *dname, size_t dnamelen, enum rpz_action a, uint16_t rr_type, uint16_t rr_class, uint8_t *rdatawl, size_t rdatalen)
 Remove RR from RPZ's local-zone.
 
static void rpz_remove_response_ip_trigger (struct rpz *r, uint8_t *dname, size_t dnamelen, enum rpz_action a, uint16_t rr_type, uint8_t *rdatawl, size_t rdatalen)
 
static void del_local_rrset_from_list (struct local_rrset **list_head, uint16_t dtype)
 find and remove type from list of local_rrset entries
 
static int rpz_remove_clientip_rr (struct clientip_synthesized_rr *node, uint16_t rr_type, uint8_t *rdatawl, size_t rdatalen)
 Delete client-ip trigger RR from its RRset and perhaps also the rrset from the linked list. More...
 
static void rpz_clientip_remove_trigger_rr (struct clientip_synthesized_rrset *set, struct sockaddr_storage *addr, socklen_t addrlen, int net, enum rpz_action a, uint16_t rr_type, uint8_t *rdatawl, size_t rdatalen)
 remove trigger RR from clientip_syntheized set tree.
 
static void rpz_remove_clientip_trigger (struct rpz *r, uint8_t *dname, size_t dnamelen, enum rpz_action a, uint16_t rr_type, uint8_t *rdatawl, size_t rdatalen)
 Remove clientip trigger RR from RPZ.
 
static void rpz_remove_nsip_trigger (struct rpz *r, uint8_t *dname, size_t dnamelen, enum rpz_action a, uint16_t rr_type, uint8_t *rdatawl, size_t rdatalen)
 Remove nsip trigger RR from RPZ.
 
static void rpz_remove_nsdname_trigger (struct rpz *r, uint8_t *dname, size_t dnamelen, enum rpz_action a, uint16_t rr_type, uint16_t rr_class, uint8_t *rdatawl, size_t rdatalen)
 Remove nsdname trigger RR from RPZ.
 
void rpz_remove_rr (struct rpz *r, uint8_t *azname, size_t aznamelen, uint8_t *dname, size_t dnamelen, uint16_t rr_type, uint16_t rr_class, uint8_t *rdatawl, size_t rdatalen)
 Delete policy matching RR, used for IXFR. More...
 
static void log_rpz_apply (char *trigger, uint8_t *dname, struct addr_tree_node *addrnode, enum rpz_action a, struct query_info *qinfo, struct comm_reply *repinfo, struct module_qstate *ms, char *log_name)
 print log information for an applied RPZ policy. More...
 
static struct clientip_synthesized_rrrpz_ipbased_trigger_lookup (struct clientip_synthesized_rrset *set, struct sockaddr_storage *addr, socklen_t addrlen, char *triggername)
 
static struct clientip_synthesized_rrrpz_resolve_client_action_and_zone (struct auth_zones *az, struct query_info *qinfo, struct comm_reply *repinfo, uint8_t *taglist, size_t taglen, struct ub_server_stats *stats, struct local_zone **z_out, struct auth_zone **a_out, struct rpz **r_out)
 
static int rpz_is_udp_query (struct comm_reply *repinfo)
 
static int rpz_local_encode (struct module_env *env, struct query_info *qinfo, struct edns_data *edns, struct comm_reply *repinfo, sldns_buffer *buf, struct regional *temp, struct ub_packed_rrset_key *rrset, int ansec, int rcode, struct ub_packed_rrset_key *soa_rrset)
 encode answer consisting of 1 rrset
 
static struct ub_packed_rrset_keymake_soa_ubrrset (struct auth_zone *auth_zone, struct auth_rrset *soa, struct regional *temp)
 allocate SOA record ubrrsetkey in region
 
static void rpz_apply_clientip_localdata_action (struct clientip_synthesized_rr *raddr, struct module_env *env, struct query_info *qinfo, struct edns_data *edns, struct comm_reply *repinfo, sldns_buffer *buf, struct regional *temp, struct auth_zone *auth_zone)
 
static int rpz_apply_cname_override_action (struct rpz *r, struct query_info *qinfo, struct regional *temp)
 Apply the cname override action, during worker request callback. More...
 
static int rpz_add_soa (struct reply_info *rep, struct module_qstate *ms, struct auth_zone *az)
 add additional section SOA record to the reply. More...
 
static struct dns_msgrpz_dns_msg_new (struct regional *region)
 
static struct dns_msgrpz_synthesize_nodata (struct rpz *ATTR_UNUSED(r), struct module_qstate *ms, struct query_info *qinfo, struct auth_zone *az)
 
static struct dns_msgrpz_synthesize_nxdomain (struct rpz *r, struct module_qstate *ms, struct query_info *qinfo, struct auth_zone *az)
 
static struct dns_msgrpz_synthesize_localdata_from_rrset (struct rpz *ATTR_UNUSED(r), struct module_qstate *ms, struct query_info *qi, struct local_rrset *rrset, struct auth_zone *az)
 
static struct dns_msgrpz_synthesize_nsip_localdata (struct rpz *r, struct module_qstate *ms, struct query_info *qi, struct clientip_synthesized_rr *data, struct auth_zone *az)
 
static struct local_rrsetlocal_data_find_type (struct local_data *data, uint16_t type, int alias_ok)
 
static struct dns_msgrpz_synthesize_nsdname_localdata (struct rpz *r, struct module_qstate *ms, struct query_info *qi, struct local_zone *z, struct matched_delegation_point const *match, struct auth_zone *az)
 
static struct dns_msgrpz_synthesize_qname_localdata_msg (struct rpz *r, struct module_qstate *ms, struct query_info *qinfo, struct local_zone *z, struct auth_zone *az)
 
static struct dns_msgrpz_synthesize_cname_override_msg (struct rpz *r, struct module_qstate *ms, struct query_info *qinfo)
 Synthesize a CNAME message for RPZ action override.
 
static int rpz_synthesize_qname_localdata (struct module_env *env, struct rpz *r, struct local_zone *z, enum localzone_type lzt, struct query_info *qinfo, struct edns_data *edns, sldns_buffer *buf, struct regional *temp, struct comm_reply *repinfo, struct ub_server_stats *stats)
 
static struct clientip_synthesized_rrrpz_delegation_point_ipbased_trigger_lookup (struct rpz *rpz, struct iter_qstate *is)
 
static struct dns_msgrpz_apply_nsip_trigger (struct module_qstate *ms, struct query_info *qchase, struct rpz *r, struct clientip_synthesized_rr *raddr, struct auth_zone *az)
 
static struct dns_msgrpz_apply_nsdname_trigger (struct module_qstate *ms, struct query_info *qchase, struct rpz *r, struct local_zone *z, struct matched_delegation_point const *match, struct auth_zone *az)
 
static struct local_zonerpz_delegation_point_zone_lookup (struct delegpt *dp, struct local_zones *zones, uint16_t qclass, struct matched_delegation_point *match)
 
struct dns_msgrpz_callback_from_iterator_module (struct module_qstate *ms, struct iter_qstate *is)
 Callback to process when the iterator module is about to send queries. More...
 
struct dns_msgrpz_callback_from_iterator_cname (struct module_qstate *ms, struct iter_qstate *is)
 Callback to process when the iterator module has followed a cname. More...
 
static int rpz_apply_maybe_clientip_trigger (struct auth_zones *az, struct module_env *env, struct query_info *qinfo, struct edns_data *edns, struct comm_reply *repinfo, uint8_t *taglist, size_t taglen, struct ub_server_stats *stats, sldns_buffer *buf, struct regional *temp, struct local_zone **z_out, struct auth_zone **a_out, struct rpz **r_out, int *passthru)
 
int rpz_callback_from_worker_request (struct auth_zones *az, struct module_env *env, struct query_info *qinfo, struct edns_data *edns, sldns_buffer *buf, struct regional *temp, struct comm_reply *repinfo, uint8_t *taglist, size_t taglen, struct ub_server_stats *stats, int *passthru)
 Walk over the RPZ zones to find and apply a QNAME trigger policy. More...
 
void rpz_enable (struct rpz *r)
 Enable RPZ. More...
 
void rpz_disable (struct rpz *r)
 Disable RPZ. More...
 

Detailed Description

This file contains functions to enable RPZ service.

Function Documentation

◆ rpz_action_to_string()

const char* rpz_action_to_string ( enum rpz_action  a)

string for RPZ action enum

String for RPZ action enum.

Referenced by log_rpz_apply(), and respip_inform_print().

◆ get_tld_label()

static uint8_t* get_tld_label ( uint8_t *  dname,
size_t  maxdnamelen 
)
static

Get the label that is just before the root label.

Parameters
dnamedname to work on
maxdnamelenmaximum length of the dname
Returns
: pointer to TLD label, NULL if not found or invalid dname

◆ rpz_type_ignored()

static int rpz_type_ignored ( uint16_t  rr_type)
static

The RR types that are to be ignored.

DNSSEC RRs at the apex, and SOA and NS are ignored.

Referenced by rpz_insert_rr(), and rpz_remove_rr().

◆ rpz_rr_to_action()

static enum rpz_action rpz_rr_to_action ( uint16_t  rr_type,
uint8_t *  rdatawl,
size_t  rdatalen 
)
static

Classify RPZ action for RR type/rdata.

Parameters
rr_typethe RR type
rdatawlRDATA with 2 bytes length
rdatalenthe length of rdatawl (including its 2 bytes length)
Returns
: the RPZ action

Referenced by rpz_insert_rr(), and rpz_remove_rr().

◆ rpz_action_to_respip_action()

enum respip_action rpz_action_to_respip_action ( enum rpz_action  a)

Classify respip action for RPZ action.

Parameters
aRPZ action
Returns
: the respip action

References LDNS_RR_TYPE_DNAME, LDNS_RR_TYPE_NS, and LDNS_RR_TYPE_SOA.

◆ rpz_dname_to_trigger()

static enum rpz_trigger rpz_dname_to_trigger ( uint8_t *  dname,
size_t  dname_len 
)
static

Get RPZ trigger for dname.

Parameters
dnamedname containing RPZ trigger
dname_lenlength of the dname
Returns
: RPZ trigger enum

Referenced by rpz_insert_rr().

◆ rpz_delete()

void rpz_delete ( struct rpz r)

Delete RPZ.

Parameters
rRPZ struct to delete

References local_zones_delete(), and respip_set_delete().

Referenced by auth_zone_delete().

◆ rpz_clear()

int rpz_clear ( struct rpz r)

Clear local-zones and respip data in RPZ, used after reloading file or AXFR/HTTP transfer.

Parameters
rRPZ to use

References local_zones_delete(), and respip_set_delete().

Referenced by apply_axfr(), apply_http(), and auth_zone_read_zonefile().

◆ rpz_finish_config()

void rpz_finish_config ( struct rpz r)

Prepare RPZ after processing feed content.

Parameters
rRPZ to use

References addr_tree_init_parents(), and clientip_synthesized_rrset::lock.

Referenced by auth_zone_read_zonefile(), and xfr_process_chunk_list().

◆ rpz_create()

struct rpz* rpz_create ( struct config_auth p)

Create RPZ.

RPZ must be added to linked list after creation.

Returns
: the newly created RPZ

References local_zones_create(), regional_create_custom(), and respip_set_create().

Referenced by auth_zones_cfg().

◆ rpz_config()

int rpz_config ( struct rpz r,
struct config_auth p 
)

Change config on rpz, after reload.

Parameters
rthe rpz structure.
pthe config that was read.
Returns
false on failure.

References delete_cname_override(), and rpz_apply_cfg_elements().

◆ rpz_insert_rr()

int rpz_insert_rr ( struct rpz r,
uint8_t *  azname,
size_t  aznamelen,
uint8_t *  dname,
size_t  dnamelen,
uint16_t  rr_type,
uint16_t  rr_class,
uint32_t  rr_ttl,
uint8_t *  rdatawl,
size_t  rdatalen,
uint8_t *  rr,
size_t  rr_len 
)

Create policy from RR and add to this RPZ.

Parameters
rthe rpz to add the policy to.
aznamedname of the auth-zone
aznamelenthe length of the auth-zone name
dnamedname of the RR
dnamelenlength of the dname
rr_typeRR type of the RR
rr_classRR class of the RR
rr_ttlTTL of the RR
rdatawlrdata of the RR, prepended with the rdata size
rdatalenlength if the RR, including the prepended rdata size
rrthe complete RR, for logging purposes
rr_lenthe length of the complete RR
Returns
: 0 on error

References dname_str(), dname_subdomain_c(), log_assert, log_err(), rpz_dname_to_trigger(), rpz_rr_to_action(), rpz_type_ignored(), sldns_wire2str_dname(), and strip_dname_origin().

Referenced by az_insert_rr().

◆ rpz_find_zone()

static struct local_zone* rpz_find_zone ( struct local_zones zones,
uint8_t *  qname,
size_t  qname_len,
uint16_t  qclass,
int  only_exact,
int  wr,
int  zones_keep_lock 
)
static

Find RPZ local-zone by qname.

Parameters
zoneslocal-zone tree
qnameqname
qname_lenlength of qname
qclassqclass
only_exactif 1 only exact (non wildcard) matches are returned
wrget write lock for local-zone if 1, read lock if 0
zones_keep_lockif set do not release the r->local_zones lock, this makes the caller of this function responsible for releasing the lock.
Returns
: NULL or local-zone holding rd or wr lock

References dname_count_labels(), dname_count_size_labels(), dname_get_shared_topdomain(), LDNS_MAX_DOMAINLEN, LDNS_RR_CLASS_IN, local_zones_find_le(), local_zones::lock, local_zone::lock, and local_zone::name.

Referenced by rpz_callback_from_iterator_cname(), and rpz_remove_local_zones_trigger().

◆ rpz_data_delete_rr()

static int rpz_data_delete_rr ( struct local_zone z,
uint8_t *  policydname,
size_t  policydnamelen,
uint16_t  rr_type,
uint8_t *  rdata,
size_t  rdatalen 
)
static

Remove RR from RPZ's local-data.

Parameters
zlocal-zone for RPZ, holding write lock
policydnamedname of RR to remove
policydnamelenlength of policydname
rr_typeRR type of RR to remove
rdatardata of RR to remove
rdatalenlength of rdata
Returns
: 1 if zone must be removed after RR deletion

References packed_rrset_data::count, dname_count_labels(), local_rrset_remove_rr(), local_zone_find_data(), local_rrset::next, packed_rrset_find_rr(), and local_data::rrsets.

◆ rpz_rrset_delete_rr()

static int rpz_rrset_delete_rr ( struct resp_addr raddr,
uint16_t  rr_type,
uint8_t *  rdata,
size_t  rdatalen 
)
static

Remove RR from RPZ's respip set.

Parameters
raddrrespip node
rr_typeRR type of RR to remove
rdatardata of RR to remove
rdatalenlength of rdata
Returns
: 1 if zone must be removed after RR deletion

References packed_rrset_data::count, resp_addr::data, lruhash_entry::data, ub_packed_rrset_key::entry, local_rrset_remove_rr(), packed_rrset_find_rr(), ub_packed_rrset_key::rk, and packed_rrset_key::type.

◆ rpz_remove_clientip_rr()

static int rpz_remove_clientip_rr ( struct clientip_synthesized_rr node,
uint16_t  rr_type,
uint8_t *  rdatawl,
size_t  rdatalen 
)
static

Delete client-ip trigger RR from its RRset and perhaps also the rrset from the linked list.

Returns if the local data is empty and the node can be deleted too, or not.

References packed_rrset_data::count, clientip_synthesized_rr::data, lruhash_entry::data, del_local_rrset_from_list(), ub_packed_rrset_key::entry, local_rrset_remove_rr(), packed_rrset_find_rr(), rpz_find_synthesized_rrset(), and local_rrset::rrset.

◆ rpz_remove_rr()

void rpz_remove_rr ( struct rpz r,
uint8_t *  azname,
size_t  aznamelen,
uint8_t *  dname,
size_t  dnamelen,
uint16_t  rr_type,
uint16_t  rr_class,
uint8_t *  rdatawl,
size_t  rdatalen 
)

Delete policy matching RR, used for IXFR.

Parameters
rthe rpz to add the policy to.
aznamedname of the auth-zone
aznamelenthe length of the auth-zone name
dnamedname of the RR
dnamelenlength of the dname
rr_typeRR type of the RR
rr_classRR class of the RR
rdatawlrdata of the RR, prepended with the rdata size
rdatalenlength if the RR, including the prepended rdata size

References dname_subdomain_c(), LDNS_MAX_DOMAINLEN, rpz_rr_to_action(), and rpz_type_ignored().

Referenced by az_remove_rr().

◆ log_rpz_apply()

static void log_rpz_apply ( char *  trigger,
uint8_t *  dname,
struct addr_tree_node addrnode,
enum rpz_action  a,
struct query_info qinfo,
struct comm_reply repinfo,
struct module_qstate ms,
char *  log_name 
)
static

print log information for an applied RPZ policy.

Based on local-zone's lz_inform_print(). The repinfo contains the reply address. If it is NULL, the module state is used to report the first IP address (if any). The dname is used, for the applied rpz, if NULL, addrnode is used.

References addr_to_str(), comm_reply::client_addr, comm_reply::client_addrlen, dname_str(), LDNS_MAX_DOMAINLEN, log_nametypeclass(), module_qstate::mesh_info, query_info::qclass, query_info::qname, query_info::qtype, mesh_reply::query_reply, mesh_state::reply_list, and rpz_action_to_string().

◆ rpz_apply_cname_override_action()

static int rpz_apply_cname_override_action ( struct rpz r,
struct query_info qinfo,
struct regional temp 
)
static

◆ rpz_add_soa()

static int rpz_add_soa ( struct reply_info rep,
struct module_qstate ms,
struct auth_zone az 
)
static

add additional section SOA record to the reply.

Since this gets fed into the normal iterator answer creation, it gets minimal-responses applied to it, that can remove the additional SOA again.

References reply_info::ar_numrrsets, auth_zone_get_soa_rrset(), make_soa_ubrrset(), module_qstate::region, regional_alloc_zero(), reply_info::rrset_count, and reply_info::rrsets.

◆ rpz_callback_from_iterator_module()

struct dns_msg* rpz_callback_from_iterator_module ( struct module_qstate qstate,
struct iter_qstate iq 
)

Callback to process when the iterator module is about to send queries.

Checks for nsip and nsdname triggers.

Parameters
qstatethe query state.
iqiterator module query state.
Returns
NULL if nothing is done. Or a new message with the contents from the rpz, based on the delegation point. It is allocated in the qstate region.

References module_env::auth_zones, module_qstate::client_info, module_qstate::env, auth_zone::lock, match(), auth_zone::rpz, auth_zone::rpz_az_next, auth_zones::rpz_first, auth_zones::rpz_lock, module_qstate::rpz_passthru, taglist_intersect(), VERB_ALGO, and verbose().

◆ rpz_callback_from_iterator_cname()

struct dns_msg* rpz_callback_from_iterator_cname ( struct module_qstate qstate,
struct iter_qstate iq 
)

Callback to process when the iterator module has followed a cname.

There can be a qname trigger for the new query name.

Parameters
qstatethe query state.
iqiterator module query state.
Returns
NULL if nothing is done. Or a new message with the contents from the rpz, based on the iq.qchase. It is allocated in the qstate region.

References module_env::auth_zones, module_qstate::client_info, module_qstate::env, auth_zone::lock, iter_qstate::qchase, query_info::qclass, query_info::qname, query_info::qname_len, auth_zone::rpz, auth_zone::rpz_az_next, rpz_find_zone(), auth_zones::rpz_first, auth_zones::rpz_lock, module_qstate::rpz_passthru, taglist_intersect(), VERB_ALGO, and verbose().

◆ rpz_callback_from_worker_request()

int rpz_callback_from_worker_request ( struct auth_zones az,
struct module_env env,
struct query_info qinfo,
struct edns_data edns,
sldns_buffer buf,
struct regional temp,
struct comm_reply repinfo,
uint8_t *  taglist,
size_t  taglen,
struct ub_server_stats stats,
int *  passthru 
)

Walk over the RPZ zones to find and apply a QNAME trigger policy.

Parameters
azauth_zones struct, containing first RPZ item and RPZ lock
envmodule env
qinfoqinfo containing qname and qtype
ednsedns data
bufbuffer to write answer to
tempscratchpad
repinforeply info
taglisttaglist to lookup.
taglenlength of taglist.
statsworker stats struct
passthrureturns if the query can passthru further rpz processing.
Returns
: 1 if client answer is ready, 0 to continue resolving

◆ rpz_enable()

void rpz_enable ( struct rpz r)

Enable RPZ.

Parameters
rRPZ struct to enable

Referenced by do_rpz_enable_disable().

◆ rpz_disable()

void rpz_disable ( struct rpz r)

Disable RPZ.

Parameters
rRPZ struct to disable

Referenced by do_rpz_enable_disable().