#include "util/data/packed_rrset.h"
Data Structures | |
struct | libworker |
The library-worker status structure Internal to the worker. More... | |
struct | libworker_res_list |
List of results (arbitrary command serializations) to write back. More... | |
Functions | |
int | libworker_bg (struct ub_ctx *ctx) |
Create a background worker. | |
int | libworker_fg (struct ub_ctx *ctx, struct ctx_query *q) |
Create a foreground worker. | |
void | libworker_alloc_cleanup (void *arg) |
cleanup the cache to remove all rrset IDs from it, arg is libworker | |
int | libworker_send_packet (ldns_buffer *pkt, struct sockaddr_storage *addr, socklen_t addrlen, int timeout, struct module_qstate *q, int use_tcp) |
Worker service routine to send udp messages for modules. | |
struct outbound_entry * | libworker_send_query (uint8_t *qname, size_t qnamelen, uint16_t qtype, uint16_t qclass, uint16_t flags, int dnssec, struct sockaddr_storage *addr, socklen_t addrlen, struct module_qstate *q) |
Worker service routine to send serviced queries to authoritative servers. | |
int | libworker_handle_reply (struct comm_point *c, void *arg, int error, struct comm_reply *reply_info) |
process incoming replies from the network | |
int | libworker_handle_service_reply (struct comm_point *c, void *arg, int error, struct comm_reply *reply_info) |
process incoming serviced query replies from the network | |
int | libworker_handle_control_cmd (struct comm_point *c, void *arg, int err, struct comm_reply *rep) |
handle control command coming into server | |
int | libworker_handle_result_write (struct comm_point *c, void *arg, int err, struct comm_reply *rep) |
handle opportunity to write result back | |
int | libworker_write_msg (int fd, uint8_t *buf, uint32_t len, int nonblock) |
Write length bytes followed by message. | |
int | libworker_read_msg (int fd, uint8_t **buf, uint32_t *len, int nonblock) |
Read length bytes followed by message. | |
void | libworker_enter_result (struct ub_result *res, ldns_buffer *buf, struct regional *temp, enum sec_status msg_security) |
fill result from parsed message, on error fills servfail |
The worker is called by a procedure and if in the background continues until exit, if in the foreground returns from the procedure when done.
int libworker_bg | ( | struct ub_ctx * | ctx | ) |
Create a background worker.
ctx,: | is updated with pid/tid of the background worker. a new allocation cache is obtained from ctx. It contains the threadnumber and unique id for further (shared) cache insertions. |
References ub_ctx::bg_pid, ub_ctx::bg_tid, ub_ctx::cfglock, ub_ctx::dothread, fatal_exit(), libworker::is_bg_thread, libworker_dobg(), libworker_setup(), ub_ctx::qqpipe, ub_ctx::rrpipe, libworker::thread_num, UB_FORKFAIL, UB_NOERROR, and UB_NOMEM.
Referenced by ub_resolve_async().
Create a foreground worker.
This worker will join the threadpool of resolver threads. It exits when the query answer has been obtained (or error). This routine blocks until the worker is finished.
ctx,: | new allocation cache obtained and returned to it. | |
q,: | query (result is stored in here). |
References libworker::back, libworker::base, BIT_RD, comm_base_dispatch(), libworker::env, libworker_delete(), libworker_fg_done_cb(), libworker_fillup_fg(), libworker_setup(), ub_ctx::local_zones, local_zones_answer(), module_env::mesh, mesh_new_callback(), query_info::qname, module_env::scratch, sec_status_insecure, setup_qinfo_edns(), UB_INITFAIL, UB_NOERROR, UB_NOMEM, UB_SYNTAX, outside_network::udp_buff, and ctx_query::w.
Referenced by ub_resolve().
int libworker_send_packet | ( | ldns_buffer * | pkt, | |
struct sockaddr_storage * | addr, | |||
socklen_t | addrlen, | |||
int | timeout, | |||
struct module_qstate * | q, | |||
int | use_tcp | |||
) |
Worker service routine to send udp messages for modules.
pkt,: | packet to send. | |
addr,: | where to. | |
addrlen,: | length of addr. | |
timeout,: | seconds to wait until timeout. | |
q,: | wich query state to reactivate upon return. | |
use_tcp,: | true to use TCP, false for UDP. |
References libworker::back, module_qstate::env, libworker_handle_reply(), log_assert, pending_tcp_query(), pending_udp_query(), and module_env::worker.
Referenced by fptr_whitelist_modenv_send_packet(), and libworker_setup().
struct outbound_entry* libworker_send_query | ( | uint8_t * | qname, | |
size_t | qnamelen, | |||
uint16_t | qtype, | |||
uint16_t | qclass, | |||
uint16_t | flags, | |||
int | dnssec, | |||
struct sockaddr_storage * | addr, | |||
socklen_t | addrlen, | |||
struct module_qstate * | q | |||
) | [read] |
Worker service routine to send serviced queries to authoritative servers.
qname,: | query name. (host order) | |
qnamelen,: | length in bytes of qname, including trailing 0. | |
qtype,: | query type. (host order) | |
qclass,: | query class. (host order) | |
flags,: | host order flags word, with opcode and CD bit. | |
dnssec,: | if set, EDNS record will have DO bit set. | |
addr,: | where to. | |
addrlen,: | length of addr. | |
q,: | wich query state to reactivate upon return. |
References libworker::back, module_qstate::env, libworker_handle_service_reply(), log_assert, outbound_entry_compare(), outnet_serviced_query(), module_qstate::region, regional_alloc(), outside_network::udp_buff, and module_env::worker.
Referenced by fptr_whitelist_modenv_send_query(), and libworker_setup().
int libworker_write_msg | ( | int | fd, | |
uint8_t * | buf, | |||
uint32_t | len, | |||
int | nonblock | |||
) |
Write length bytes followed by message.
fd,: | the socket to write on. Is nonblocking. Set to blocking by the function, and back to non-blocking at exit of function. | |
buf,: | the message. | |
len,: | length of message. | |
nonblock,: | if set to true, the first write is nonblocking. If the first write fails the function returns -1. If set false, the first write is blocking. |
References fd_set_block(), fd_set_nonblock(), and log_err().
Referenced by libworker_dobg(), ub_cancel(), ub_ctx_delete(), and ub_resolve_async().
int libworker_read_msg | ( | int | fd, | |
uint8_t ** | buf, | |||
uint32_t * | len, | |||
int | nonblock | |||
) |
Read length bytes followed by message.
fd,: | the socket to write on. Is nonblocking. Set to blocking by the function, and back to non-blocking at exit of function. | |
buf,: | the message, malloced. | |
len,: | length of message, returned. | |
nonblock,: | if set to true, the first read is nonblocking. If the first read fails the function returns -1. If set false, the first read is blocking. |
References fd_set_block(), fd_set_nonblock(), and log_err().
Referenced by ub_ctx_delete(), ub_process(), and ub_wait().
void libworker_enter_result | ( | struct ub_result * | res, | |
ldns_buffer * | buf, | |||
struct regional * | temp, | |||
enum sec_status | msg_security | |||
) |
fill result from parsed message, on error fills servfail
res,: | is clear at start, filled in at end. | |
buf,: | contains DNS message. | |
temp,: | temporary buffer for parse. | |
msg_security,: | security status of the DNS message. On error, the res may contain a different status (out of memory is not secure, not bogus). |
References ub_result::bogus, ub_result::data, fill_res(), reply_info::flags, FLAGS_GET_RCODE, ub_result::havedata, log_err(), ub_result::nxdomain, parse_reply(), ub_result::rcode, reply_find_answer_rrset(), reply_find_final_cname_target(), sec_status_bogus, sec_status_secure, and ub_result::secure.
Referenced by libworker_fillup_fg(), and process_answer_detail().