unbound: services/rpz.c File Reference

unbound 0.1

Data Structures | Typedefs | Functions
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
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.
static int | rpz_type_ignored (uint16_t rr_type)
| The RR types that are to be ignored.
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.
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.
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.
static struct clientip_synthesized_rrset * | rpz_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.
int | rpz_clear (struct rpz *r)
| Clear local-zones and respip data in RPZ, used after reloading file or AXFR/HTTP transfer.
void | rpz_finish_config (struct rpz *r)
| Prepare RPZ after processing feed content.
static struct ub_packed_rrset_key * | new_cname_override (struct regional *region, uint8_t *ct, size_t ctlen)
| new rrset containing CNAME override, does not yet contain a dname
struct rpz * | rpz_create (struct config_auth *p)
| Create RPZ.
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_rr * | rpz_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_rrset * | rpz_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.
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)
| Find RPZ local-zone by qname.
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.
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.
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)
void | rpz_remove_rr (struct rpz *r, 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.
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.
static struct clientip_synthesized_rr * | rpz_ipbased_trigger_lookup (struct clientip_synthesized_rrset *set, struct sockaddr_storage *addr, socklen_t addrlen, char *triggername)
static struct clientip_synthesized_rr * | rpz_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 local_rrset * | rpz_find_synthesized_rrset (uint16_t qtype, struct clientip_synthesized_rr *data)
static struct ub_packed_rrset_key * | make_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_add_soa (struct reply_info *rep, struct module_qstate *ms, struct auth_zone *az)
| add additional section SOA record to the reply.
static struct dns_msg * | rpz_dns_msg_new (struct regional *region)
static struct dns_msg * | rpz_synthesize_nodata (struct rpz *ATTR_UNUSED(r), struct module_qstate *ms, struct query_info *qinfo, struct auth_zone *az)
static struct dns_msg * | rpz_synthesize_nxdomain (struct rpz *r, struct module_qstate *ms, struct query_info *qinfo, struct auth_zone *az)
static struct dns_msg * | rpz_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_msg * | rpz_synthesize_nsip_localdata (struct rpz *r, struct module_qstate *ms, struct clientip_synthesized_rr *data, struct auth_zone *az)
static struct local_rrset * | local_data_find_type (struct local_data *data, uint16_t type, int alias_ok)
static struct dns_msg * | rpz_synthesize_nsdname_localdata (struct rpz *r, struct module_qstate *ms, struct local_zone *z, struct matched_delegation_point const *match, struct auth_zone *az)
static struct dns_msg * | rpz_synthesize_qname_localdata_msg (struct rpz *r, struct module_qstate *ms, struct query_info *qinfo, struct local_zone *z, struct auth_zone *az)
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_rr * | rpz_delegation_point_ipbased_trigger_lookup (struct rpz *rpz, struct iter_qstate *is)
static struct dns_msg * | rpz_apply_nsip_trigger (struct module_qstate *ms, struct rpz *r, struct clientip_synthesized_rr *raddr, struct auth_zone *az)
static struct dns_msg * | rpz_apply_nsdname_trigger (struct module_qstate *ms, struct rpz *r, struct local_zone *z, struct matched_delegation_point const *match, struct auth_zone *az)
static struct local_zone * | rpz_delegation_point_zone_lookup (struct delegpt *dp, struct local_zones *zones, uint16_t qclass, struct matched_delegation_point *match)
struct dns_msg * | rpz_callback_from_iterator_module (struct module_qstate *ms, struct iter_qstate *is)
| Callback to process when the iterator module is about to send queries.
struct dns_msg * | rpz_callback_from_iterator_cname (struct module_qstate *ms, struct iter_qstate *is)
| Callback to process when the iterator module has followed a cname.
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.
void | rpz_enable (struct rpz *r)
| Enable RPZ.
void | rpz_disable (struct rpz *r)
| Disable RPZ.

## 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(), print_ext(), respip_inform_print(), respip_rewrite_reply(), rpz_callback_from_iterator_cname(), rpz_callback_from_worker_request(), and rpz_insert_response_ip_trigger().

## ◆ 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

  dname | dname to work on
  maxdnamelen | maximum length of the dname

Returns
  : pointer to TLD label, NULL if not found or invalid dname

Referenced by rpz_dname_to_trigger(), and rpz_rr_to_action().

## ◆ 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.

References LDNS_RR_TYPE_DNAME, LDNS_RR_TYPE_DS, LDNS_RR_TYPE_NS, LDNS_RR_TYPE_RRSIG, and LDNS_RR_TYPE_SOA.

Referenced by rpz_insert_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_type | the RR type
  rdatawl | RDATA with 2 bytes length
  rdatalen | the length of rdatawl (including its 2 bytes length)

Returns
  : the RPZ action

References dname_count_labels(), dname_lab_startswith(), dname_subdomain_c(), dname_valid(), get_tld_label(), LDNS_RR_TYPE_CNAME, LDNS_RR_TYPE_DNAME, LDNS_RR_TYPE_DS, LDNS_RR_TYPE_NS, LDNS_RR_TYPE_RRSIG, LDNS_RR_TYPE_SOA, and log_assert.

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

  a | RPZ action

Returns
  : the respip action

References respip_always_deny, respip_always_nodata, respip_always_nxdomain, respip_always_transparent, respip_invalid, respip_redirect, and respip_truncate.

Referenced by rpz_insert_response_ip_trigger().

## ◆ 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

  dname | dname containing RPZ trigger
  dname_len | length of the dname

Returns
  : RPZ trigger enum

References dname_lab_startswith(), dname_subdomain_c(), dname_valid(), and get_tld_label().

Referenced by rpz_insert_rr(), and rpz_remove_rr().

## ◆ rpz_delete()

void rpz_delete | ( | struct rpz * | r | ) |

Delete RPZ.

Parameters

  r | RPZ struct to delete

References local_zones_delete(), regional_destroy(), 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

  r | RPZ to use

References local_zones_create(), local_zones_delete(), respip_set_create(), 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

  r | RPZ to use

References addr_tree_init_parents().

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 LDNS_MAX_DOMAINLEN, local_zones_create(), local_zones_delete(), log_err(), memdup(), new_cname_override(), regional_create_custom(), regional_destroy(), respip_set_create(), respip_set_delete(), config_auth::rpz_action_override, config_auth::rpz_cname, rpz_config_to_action(), config_auth::rpz_log, config_auth::rpz_log_name, config_auth::rpz_signal_nxdomain_ra, config_auth::rpz_taglist, config_auth::rpz_taglistlen, rpz::signal_nxdomain_ra, and sldns_str2wire_dname_buf().

Referenced by auth_zones_cfg().

## ◆ 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

  r | the rpz to add the policy to.
  azname | dname of the auth-zone
  aznamelen | the length of the auth-zone name
  dname | dname of the RR
  dnamelen | length of the dname
  rr_type | RR type of the RR
  rr_class | RR class of the RR
  rr_ttl | TTL of the RR
  rdatawl | rdata of the RR, prepended with the rdata size
  rdatalen | length if the RR, including the prepended rdata size
  rr | the complete RR, for logging purposes
  rr_len | the length of the complete RR

Returns
  : 0 on error

References dname_str(), dname_subdomain_c(), log_assert, log_err(), rpz_dname_to_trigger(), rpz_insert_response_ip_trigger(), rpz_rr_to_action(), rpz_trigger_to_string(), rpz_type_ignored(), sldns_wire2str_dname(), strip_dname_origin(), VERB_ALGO, and verbose().

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

  zones | local-zone tree
  qname | qname
  qname_len | length of qname
  qclass | qclass
  only_exact | if 1 only exact (non wildcard) matches are returned
  wr | get write lock for local-zone if 1, read lock if 0
  zones_keep_lock | if 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_qname_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

  z | local-zone for RPZ, holding write lock
  policydname | dname of RR to remove
  policydnamelen | length of policydname
  rr_type | RR type of RR to remove
  rdata | rdata of RR to remove
  rdatalen | length 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.

Referenced by rpz_remove_qname_trigger().

## ◆ 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

  raddr | respip node
  rr_type | RR type of RR to remove
  rdata | rdata of RR to remove
  rdatalen | length 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_rr()

void rpz_remove_rr | ( | struct rpz * | r,
|  | 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

  r | the rpz to add the policy to.
  aznamelen | the length of the auth-zone name
  dname | dname of the RR
  dnamelen | length of the dname
  rr_type | RR type of the RR
  rr_class | RR class of the RR
  rdatawl | rdata of the RR, prepended with the rdata size
  rdatalen | length if the RR, including the prepended rdata size

References LDNS_MAX_DOMAINLEN, rpz_dname_to_trigger(), rpz_remove_qname_trigger(), rpz_rr_to_action(), and strip_dname_origin().

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().

Referenced by rpz_callback_from_iterator_cname().

## ◆ 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

  qstate | the query state.
  iq | iterator 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, iter_qstate::dp, module_qstate::env, auth_zone::lock, local_zone::lock, match(), query_info::qclass, module_qstate::qinfo, auth_zone::rpz, auth_zone::rpz_az_next, auth_zones::rpz_first, auth_zones::rpz_lock, module_qstate::rpz_passthru, VERB_ALGO, and verbose().

Referenced by processQueryTargets().

## ◆ 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

  qstate | the query state.
  iq | iterator 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, dname_str(), module_qstate::env, module_qstate::is_drop, auth_zone::lock, local_zone::lock, log_rpz_apply(), local_zone::name, iter_qstate::qchase, query_info::qclass, module_qstate::qinfo, query_info::qname, query_info::qname_len, module_qstate::respip_action_info, respip_truncate, auth_zone::rpz, ub_server_stats::rpz_action, rpz_action_to_string(), auth_zone::rpz_az_next, rpz_find_zone(), auth_zones::rpz_first, auth_zones::rpz_lock, module_qstate::rpz_passthru, worker::stats, local_zone::type, VERB_ALGO, verbose(), verbosity, and module_env::worker.

Referenced by processQueryResponse().

## ◆ 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

  az | auth_zones struct, containing first RPZ item and RPZ lock
  env | module env
  qinfo | qinfo containing qname and qtype
  edns | edns data
  buf | buffer to write answer to
  temp | scratchpad
  repinfo | reply info
  taglist | taglist to lookup.
  taglen | length of taglist.
  stats | worker stats struct
  passthru | returns if the query can passthru further rpz processing.

Returns
  : 1 if client answer is ready, 0 to continue resolving

References dname_str(), local_zone_always_transparent, auth_zone::lock, local_zone::lock, log_assert, local_zone::name, query_info::qname, rpz_action_to_string(), local_zone::taglen, local_zone::taglist, local_zone::type, VERB_ALGO, verbose(), and verbosity.

Referenced by worker_handle_request().

## ◆ rpz_enable()

void rpz_enable | ( | struct rpz * | r | ) |

Enable RPZ.

Parameters

  r | RPZ struct to enable

Referenced by do_rpz_enable_disable().

## ◆ rpz_disable()

void rpz_disable | ( | struct rpz * | r | ) |

Disable RPZ.

Parameters

  r | RPZ struct to disable

Referenced by do_rpz_enable_disable().