This file contains the remote control functionality for the daemon. More...
#include "config.h"
#include <ctype.h>
#include "daemon/remote.h"
#include "daemon/worker.h"
#include "daemon/daemon.h"
#include "daemon/stats.h"
#include "daemon/cachedump.h"
#include "util/log.h"
#include "util/config_file.h"
#include "util/net_help.h"
#include "util/module.h"
#include "util/ub_event.h"
#include "services/listen_dnsport.h"
#include "services/cache/rrset.h"
#include "services/cache/infra.h"
#include "services/mesh.h"
#include "services/localzone.h"
#include "services/authzone.h"
#include "services/rpz.h"
#include "util/storage/slabhash.h"
#include "util/fptr_wlist.h"
#include "util/data/dname.h"
#include "validator/validator.h"
#include "validator/val_kcache.h"
#include "validator/val_kentry.h"
#include "validator/val_anchor.h"
#include "validator/val_neg.h"
#include "iterator/iterator.h"
#include "iterator/iter_fwd.h"
#include "iterator/iter_hints.h"
#include "iterator/iter_delegpt.h"
#include "iterator/iter_utils.h"
#include "iterator/iter_donotq.h"
#include "iterator/iter_priv.h"
#include "services/outbound_list.h"
#include "services/outside_network.h"
#include "sldns/str2wire.h"
#include "sldns/parseutil.h"
#include "sldns/wire2str.h"
#include "sldns/sbuffer.h"
#include "util/timeval_func.h"
#include "util/tcp_conn_limit.h"
#include "util/edns.h"
Data Structures | |
struct | del_info |
Local info for deletion functions. More... | |
struct | infra_arg |
structure for argument data for dump infra host More... | |
struct | ratelimit_list_arg |
struct for user arg ratelimit list More... | |
struct | fast_reload_construct |
Structure with constructed elements for use during fast reload. More... | |
Macros | |
#define | SQ "=" |
what to put on statistics lines between var and value, ": " or "=" | |
#define | MAX_CMD_STRLINE 1024 |
Acceptable lengths of str lines. | |
#define | MAX_STDIN_STRLINE 2048 |
#define | IPC_LOOP_MAX 200 |
What number of loop iterations is too much for ipc retries. | |
#define | IPC_NOTIFICATION_WAIT 200 |
Timeout in msec for ipc socket poll. | |
#define | ip_ratelimit_list_arg ratelimit_list_arg |
Functions | |
static void | fr_printq_delete (struct fast_reload_printq *printq) |
fast reload printq delete | |
static void | fr_main_perform_printout (struct fast_reload_thread *fr) |
Fast reload, the remote control thread handles that the fast reload thread has output to be printed, on the linked list that is locked. | |
static int | fr_printq_empty (struct fast_reload_printq *printq) |
fast reload printq, returns true if the list is empty and no item | |
static void | fr_printq_list_insert (struct fast_reload_printq *printq, struct daemon *daemon) |
fast reload printq, insert onto list | |
static void | fr_printq_remove (struct fast_reload_printq *printq) |
fast reload printq, remove the printq when no longer needed, like the stream is closed. | |
static void | fr_check_cmd_from_thread (struct fast_reload_thread *fr) |
Fast reload, poll for and handle cmd from fast reload thread. | |
static int | remote_setup_ctx (struct daemon_remote *rc, struct config_file *cfg) |
struct daemon_remote * | daemon_remote_create (struct config_file *cfg) |
Create new remote control state for the daemon. | |
void | daemon_remote_clear (struct daemon_remote *rc) |
remote control state to clear up. | |
void | daemon_remote_delete (struct daemon_remote *rc) |
remote control state to delete. | |
static int | add_open (const char *ip, int nr, struct listen_port **list, int noproto_is_err, struct config_file *cfg) |
Add and open a new control port. | |
struct listen_port * | daemon_remote_open_ports (struct config_file *cfg) |
Open and create listening ports for remote control. | |
static int | accept_open (struct daemon_remote *rc, int fd) |
open accept commpoint | |
int | daemon_remote_open_accept (struct daemon_remote *rc, struct listen_port *ports, struct worker *worker) |
Setup comm points for accepting remote control connections. | |
void | daemon_remote_stop_accept (struct daemon_remote *rc) |
Stop accept handlers for TCP (until enabled again) | |
void | daemon_remote_start_accept (struct daemon_remote *rc) |
Stop accept handlers for TCP (until enabled again) | |
int | remote_accept_callback (struct comm_point *c, void *arg, int err, struct comm_reply *ATTR_UNUSED(rep)) |
static void | state_list_remove_elem (struct rc_state **list, struct comm_point *c) |
delete from list | |
static void | clean_point (struct daemon_remote *rc, struct rc_state *s) |
decrease active count and remove commpoint from busy list | |
int | ssl_print_text (RES *res, const char *text) |
static int | ssl_print_vmsg (RES *ssl, const char *format, va_list args) |
print text over the ssl connection | |
int | ssl_printf (RES *ssl, const char *format,...) |
printf style printing to the ssl connection | |
int | ssl_read_line (RES *res, char *buf, size_t max) |
static char * | skipwhite (char *str) |
skip whitespace, return new pointer into string | |
static void | send_ok (RES *ssl) |
send the OK to the control client | |
static void | distribute_cmd (struct daemon_remote *rc, RES *ssl, char *cmd) |
tell other processes to execute the command | |
static void | do_stop (RES *ssl, struct worker *worker) |
do the stop command | |
static void | do_reload (RES *ssl, struct worker *worker, int reuse_cache) |
do the reload command | |
static int | fr_parse_options (RES *ssl, char *arg, int *fr_verb, int *fr_nopause, int *fr_drop_mesh) |
parse fast reload command options. | |
static void | do_fast_reload (RES *ssl, struct worker *worker, struct rc_state *s, char *arg) |
do the fast_reload command | |
static void | do_verbosity (RES *ssl, char *str) |
do the verbosity command | |
static int | print_stats (RES *ssl, const char *nm, struct ub_stats_info *s) |
print stats from statinfo | |
static int | print_thread_stats (RES *ssl, int i, struct ub_stats_info *s) |
print stats for one thread | |
static int | print_longnum (RES *ssl, const char *desc, size_t x) |
print long number | |
static int | print_mem (RES *ssl, struct worker *worker, struct daemon *daemon, struct ub_stats_info *s) |
print mem stats | |
static int | print_uptime (RES *ssl, struct worker *worker, int reset) |
print uptime stats | |
static int | print_hist (RES *ssl, struct ub_stats_info *s) |
print extended histogram | |
static int | print_ext (RES *ssl, struct ub_stats_info *s, int inhibit_zero) |
print extended stats | |
static void | do_stats (RES *ssl, struct worker *worker, int reset) |
do the stats command | |
static int | parse_arg_name (RES *ssl, char *str, uint8_t **res, size_t *len, int *labs) |
parse commandline argument domain name | |
static int | find_arg2 (RES *ssl, char *arg, char **arg2) |
find second argument, modifies string | |
static int | perform_zone_add (RES *ssl, struct local_zones *zones, char *arg) |
Add a new zone. | |
static void | do_zone_add (RES *ssl, struct local_zones *zones, char *arg) |
Do the local_zone command. | |
static void | do_zones_add (struct daemon_remote *rc, RES *ssl, struct worker *worker) |
Do the local_zones command. | |
static int | perform_zone_remove (RES *ssl, struct local_zones *zones, char *arg) |
Remove a zone. | |
static void | do_zone_remove (RES *ssl, struct local_zones *zones, char *arg) |
Do the local_zone_remove command. | |
static void | do_zones_remove (struct daemon_remote *rc, RES *ssl, struct worker *worker) |
Do the local_zones_remove command. | |
static int | check_RR_syntax (RES *ssl, char *str, int line) |
check syntax of newly added RR | |
static int | perform_data_add (RES *ssl, struct local_zones *zones, char *arg, int line) |
Add new RR data. | |
static void | do_data_add (RES *ssl, struct local_zones *zones, char *arg) |
Do the local_data command. | |
static void | do_datas_add (struct daemon_remote *rc, RES *ssl, struct worker *worker) |
Do the local_datas command. | |
static int | perform_data_remove (RES *ssl, struct local_zones *zones, char *arg) |
Remove RR data. | |
static void | do_data_remove (RES *ssl, struct local_zones *zones, char *arg) |
Do the local_data_remove command. | |
static void | do_datas_remove (struct daemon_remote *rc, RES *ssl, struct worker *worker) |
Do the local_datas_remove command. | |
static void | do_view_zone_add (RES *ssl, struct worker *worker, char *arg) |
Add a new zone to view. | |
static void | do_view_zone_remove (RES *ssl, struct worker *worker, char *arg) |
Remove a zone from view. | |
static void | do_view_data_add (RES *ssl, struct worker *worker, char *arg) |
Add new RR data to view. | |
static void | do_view_datas_add (struct daemon_remote *rc, RES *ssl, struct worker *worker, char *arg) |
Add new RR data from stdin to view. | |
static void | do_view_data_remove (RES *ssl, struct worker *worker, char *arg) |
Remove RR data from view. | |
static void | do_view_datas_remove (struct daemon_remote *rc, RES *ssl, struct worker *worker, char *arg) |
Remove RR data from stdin from view. | |
static void | do_lookup (RES *ssl, struct worker *worker, char *arg) |
cache lookup of nameservers | |
static void | do_cache_remove (struct worker *worker, uint8_t *nm, size_t nmlen, uint16_t t, uint16_t c, int remcachedb) |
flush something from rrset and msg caches | |
static int | parse_remcachedb (RES *ssl, char **arg, int *pc) |
parse '+c' option, modifies string to return remainder. | |
static void | do_flush_type (RES *ssl, struct worker *worker, char *arg) |
flush a type | |
static void | do_flush_stats (RES *ssl, struct worker *worker) |
flush statistics | |
static void | infra_del_host (struct lruhash_entry *e, void *arg) |
callback to delete hosts in infra cache | |
static void | do_flush_infra (RES *ssl, struct worker *worker, char *arg) |
flush infra cache | |
static void | do_flush_requestlist (RES *ssl, struct worker *worker) |
flush requestlist | |
static void | zone_del_rrset (struct lruhash_entry *e, void *arg) |
callback to delete rrsets in a zone | |
static void | zone_del_msg (struct lruhash_entry *e, void *arg) |
callback to delete messages in a zone | |
static void | zone_del_kcache (struct lruhash_entry *e, void *arg) |
callback to delete keys in zone | |
static void | do_flush_zone (RES *ssl, struct worker *worker, char *arg) |
remove all rrsets and keys from zone from cache | |
static void | bogus_del_rrset (struct lruhash_entry *e, void *arg) |
callback to delete bogus rrsets | |
static void | bogus_del_msg (struct lruhash_entry *e, void *arg) |
callback to delete bogus messages | |
static void | bogus_del_kcache (struct lruhash_entry *e, void *arg) |
callback to delete bogus keys | |
static void | do_flush_bogus (RES *ssl, struct worker *worker, char *arg) |
remove all bogus rrsets, msgs and keys from cache | |
static void | negative_del_rrset (struct lruhash_entry *e, void *arg) |
callback to delete negative and servfail rrsets | |
static void | negative_del_msg (struct lruhash_entry *e, void *arg) |
callback to delete negative and servfail messages | |
static void | negative_del_kcache (struct lruhash_entry *e, void *arg) |
callback to delete negative key entries | |
static void | do_flush_negative (RES *ssl, struct worker *worker, char *arg) |
remove all negative(NODATA,NXDOMAIN), and servfail messages from cache | |
static void | do_flush_name (RES *ssl, struct worker *w, char *arg) |
remove name rrset from cache | |
static int | ssl_print_name_dp (RES *ssl, const char *str, uint8_t *nm, uint16_t dclass, struct delegpt *dp) |
printout a delegation point info | |
static int | print_root_fwds (RES *ssl, struct iter_forwards *fwds, uint8_t *root) |
print root forwards | |
static struct delegpt * | parse_delegpt (RES *ssl, char *args, uint8_t *nm) |
parse args into delegpt | |
static void | do_forward (RES *ssl, struct worker *worker, char *args) |
do the forward command | |
static int | parse_fs_args (RES *ssl, char *args, uint8_t **nm, struct delegpt **dp, int *insecure, int *prime, int *tls) |
static void | do_forward_add (RES *ssl, struct worker *worker, char *args) |
do the forward_add command | |
static void | do_forward_remove (RES *ssl, struct worker *worker, char *args) |
do the forward_remove command | |
static void | do_stub_add (RES *ssl, struct worker *worker, char *args) |
do the stub_add command | |
static void | do_stub_remove (RES *ssl, struct worker *worker, char *args) |
do the stub_remove command | |
static void | do_insecure_add (RES *ssl, struct worker *worker, char *arg) |
do the insecure_add command | |
static void | do_insecure_remove (RES *ssl, struct worker *worker, char *arg) |
do the insecure_remove command | |
static void | do_insecure_list (RES *ssl, struct worker *worker) |
static void | do_status (RES *ssl, struct worker *worker) |
do the status command | |
static void | get_mesh_age (struct mesh_state *m, char *buf, size_t len, struct module_env *env) |
get age for the mesh state | |
static void | get_mesh_status (struct mesh_area *mesh, struct mesh_state *m, char *buf, size_t len) |
get status of a mesh state | |
static void | do_dump_requestlist (RES *ssl, struct worker *worker) |
do the dump_requestlist command | |
static void | dump_infra_host (struct lruhash_entry *e, void *arg) |
callback for every host element in the infra cache | |
static void | do_dump_infra (RES *ssl, struct worker *worker) |
do the dump_infra command | |
static void | do_log_reopen (RES *ssl, struct worker *worker) |
do the log_reopen command | |
static void | do_auth_zone_reload (RES *ssl, struct worker *worker, char *arg) |
do the auth_zone_reload command | |
static void | do_auth_zone_transfer (RES *ssl, struct worker *worker, char *arg) |
do the auth_zone_transfer command | |
static void | do_set_option (RES *ssl, struct worker *worker, char *arg) |
do the set_option command | |
void | remote_get_opt_ssl (char *line, void *arg) |
routine to printout option values over SSL | |
static void | do_get_option (RES *ssl, struct worker *worker, char *arg) |
do the get_option command | |
static void | do_list_forwards (RES *ssl, struct worker *worker) |
do the list_forwards command | |
static void | do_list_stubs (RES *ssl, struct worker *worker) |
do the list_stubs command | |
static void | do_list_auth_zones (RES *ssl, struct auth_zones *az) |
do the list_auth_zones command | |
static void | do_list_local_zones (RES *ssl, struct local_zones *zones) |
do the list_local_zones command | |
static void | do_list_local_data (RES *ssl, struct worker *worker, struct local_zones *zones) |
do the list_local_data command | |
static void | do_view_list_local_zones (RES *ssl, struct worker *worker, char *arg) |
do the view_list_local_zones command | |
static void | do_view_list_local_data (RES *ssl, struct worker *worker, char *arg) |
do the view_list_local_data command | |
static void | rate_list (struct lruhash_entry *e, void *arg) |
list items in the ratelimit table | |
static void | ip_rate_list (struct lruhash_entry *e, void *arg) |
list items in the ip_ratelimit table | |
static void | do_ratelimit_list (RES *ssl, struct worker *worker, char *arg) |
do the ratelimit_list command | |
static void | do_ip_ratelimit_list (RES *ssl, struct worker *worker, char *arg) |
do the ip_ratelimit_list command | |
static void | do_rpz_enable_disable (RES *ssl, struct worker *worker, char *arg, int enable) |
do the rpz_enable/disable command | |
static void | do_rpz_enable (RES *ssl, struct worker *worker, char *arg) |
do the rpz_enable command | |
static void | do_rpz_disable (RES *ssl, struct worker *worker, char *arg) |
do the rpz_disable command | |
static int | cookie_secret_file_dump (RES *ssl, struct worker *worker) |
Write the cookie secrets to file, returns 0 on failure. | |
static void | do_activate_cookie_secret (RES *ssl, struct worker *worker) |
Activate cookie secret. | |
static void | do_drop_cookie_secret (RES *ssl, struct worker *worker) |
Drop cookie secret. | |
static void | do_add_cookie_secret (RES *ssl, struct worker *worker, char *arg) |
Add cookie secret. | |
static void | do_print_cookie_secrets (RES *ssl, struct worker *worker) |
Print cookie secrets. | |
static int | cmdcmp (char *p, const char *cmd, size_t len) |
check for name with end-of-string, space or tab after it | |
static void | execute_cmd (struct daemon_remote *rc, struct rc_state *s, RES *ssl, char *cmd, struct worker *worker) |
execute a remote control command | |
void | daemon_remote_exec (struct worker *worker) |
Handle nonthreaded remote cmd execution. | |
static void | handle_req (struct daemon_remote *rc, struct rc_state *s, RES *res) |
handle remote control request | |
static int | remote_handshake_later (struct daemon_remote *rc, struct rc_state *s, struct comm_point *c, int r, int r2) |
handle SSL_do_handshake changes to the file descriptor to wait for later | |
int | remote_control_callback (struct comm_point *c, void *arg, int err, struct comm_reply *ATTR_UNUSED(rep)) |
static int | sock_poll_timeout (int fd, int timeout, int pollin, int pollout, int *event) |
This routine polls a socket for readiness. | |
static const char * | fr_notification_to_string (enum fast_reload_notification status) |
fast reload convert fast reload notification status to string | |
static int | fr_poll_for_quit (struct fast_reload_thread *fr) |
fast reload, poll for notification incoming. | |
static void | fr_send_notification (struct fast_reload_thread *fr, enum fast_reload_notification status) |
fast reload thread. | |
static int | fr_output_text (struct fast_reload_thread *fr, const char *msg) |
fast reload thread queue up text string for output | |
static int | fr_output_vmsg (struct fast_reload_thread *fr, const char *format, va_list args) |
fast reload thread output vmsg function | |
static int | fr_output_printf (struct fast_reload_thread *fr, const char *format,...) ATTR_FORMAT(printf |
fast reload thread printout function, with printf arguments | |
static void | fr_init_time (struct timeval *time_start, struct timeval *time_read, struct timeval *time_construct, struct timeval *time_reload, struct timeval *time_end) |
fast reload thread, init time counters | |
static int | fr_read_config (struct fast_reload_thread *fr, struct config_file **newcfg) |
fast reload thread, read config | |
static int | taglist_equal (char **tagname_a, int num_tags_a, char **tagname_b, int num_tags_b) |
Check if two taglists are equal. | |
static int | taglist_change_at_end (char **tagname_a, int num_tags_a, char **tagname_b, int num_tags_b) |
Check the change from a to b is only new entries at the end. | |
static int | fr_check_tag_defines (struct fast_reload_thread *fr, struct config_file *newcfg) |
fast reload thread, check tag defines. | |
static void | fr_check_changed_cfg (int cmp, const char *desc, char *str, size_t len) |
fast reload thread, check if config item has changed, if not add to the explanatory string. | |
static void | fr_check_changed_cfg_str (char *cmp1, char *cmp2, const char *desc, char *str, size_t len) |
fast reload thread, check if config string has changed, checks NULLs. | |
static void | fr_check_changed_cfg_strlist (struct config_strlist *cmp1, struct config_strlist *cmp2, const char *desc, char *str, size_t len) |
fast reload thread, check if config strlist has changed. | |
static void | fr_check_changed_cfg_str2list (struct config_str2list *cmp1, struct config_str2list *cmp2, const char *desc, char *str, size_t len) |
fast reload thread, check if config str2list has changed. | |
static int | fr_check_compat_cfg (struct fast_reload_thread *fr, struct config_file *newcfg) |
fast reload thread, check compatible config items | |
static int | fr_check_nopause_cfg (struct fast_reload_thread *fr, struct config_file *newcfg) |
fast reload thread, check nopause config items | |
static void | fr_construct_clear (struct fast_reload_construct *ct) |
fast reload thread, clear construct information, deletes items | |
static size_t | getmem_config_strlist (struct config_strlist *p) |
get memory for strlist | |
static size_t | getmem_config_str2list (struct config_str2list *p) |
get memory for str2list | |
static size_t | getmem_config_str3list (struct config_str3list *p) |
get memory for str3list | |
static size_t | getmem_config_strbytelist (struct config_strbytelist *p) |
get memory for strbytelist | |
static size_t | getmem_ifs (int numifs, char **ifs) |
get memory used by ifs array | |
static size_t | getmem_config_stub (struct config_stub *p) |
get memory for config_stub | |
static size_t | getmem_config_auth (struct config_auth *p) |
get memory for config_auth | |
static size_t | getmem_config_view (struct config_view *p) |
get memory for config_view | |
static size_t | config_file_getmem (struct config_file *cfg) |
get memory used by config_file item, estimate | |
static int | fr_printmem (struct fast_reload_thread *fr, struct config_file *newcfg, struct fast_reload_construct *ct) |
fast reload thread, print memory used by construct of items. | |
static int | ct_acl_interface_setup_ports (struct acl_list *acl_interface, struct daemon *daemon) |
fast reload thread, setup the acl_interface for the ports that the server has. | |
static int | fr_add_auth_zone_change (struct fast_reload_thread *fr, struct auth_zone *old_z, struct auth_zone *new_z, int is_deleted, int is_added, int is_changed) |
fast reload, add new change to list of auth zones | |
static int | xfr_auth_master_equal (struct auth_master *m1, struct auth_master *m2) |
See if auth master is equal. | |
static int | xfr_masterlist_equal (struct auth_master *list1, struct auth_master *list2) |
See if list of auth masters is equal. | |
static int | xfr_masters_equal (struct auth_xfer *xfr1, struct auth_xfer *xfr2) |
See if the list of masters has changed. | |
static int | auth_zones_check_changes (struct fast_reload_thread *fr, struct fast_reload_construct *ct) |
Check what has changed in auth zones, like added and deleted zones. | |
static int | fr_construct_from_config (struct fast_reload_thread *fr, struct config_file *newcfg, struct fast_reload_construct *ct) |
fast reload thread, construct from config the new items | |
static int | fr_finish_time (struct fast_reload_thread *fr, struct timeval *time_start, struct timeval *time_read, struct timeval *time_construct, struct timeval *time_reload, struct timeval *time_end) |
fast reload thread, finish timers | |
static void | auth_zones_swap (struct auth_zones *az, struct auth_zones *data) |
Swap auth zone information. | |
static void | fr_adjust_cache (struct module_env *env, struct config_file *oldcfg) |
fast reload thread, adjust the cache sizes | |
static void | fr_adjust_iter_env (struct module_env *env, struct fast_reload_construct *ct) |
fast reload thread, adjust the iterator env | |
static void | fr_adjust_val_env (struct module_env *env, struct fast_reload_construct *ct, struct config_file *oldcfg) |
fast reload thread, adjust the validator env | |
static void | fr_adjust_infra (struct module_env *env, struct fast_reload_construct *ct) |
fast reload thread, adjust the infra cache parameters | |
static int | fr_reload_config (struct fast_reload_thread *fr, struct config_file *newcfg, struct fast_reload_construct *ct) |
fast reload thread, reload config with putting the new config items in place and swapping out the old items. | |
static void | fr_poll_for_ack (struct fast_reload_thread *fr) |
fast reload, poll for ack incoming. | |
static int | fr_reload_ipc (struct fast_reload_thread *fr, struct config_file *newcfg, struct fast_reload_construct *ct) |
fast reload thread, reload ipc communication to stop and start threads. | |
static int | fr_load_config (struct fast_reload_thread *fr, struct timeval *time_read, struct timeval *time_construct, struct timeval *time_reload) |
fast reload thread, load config | |
static void * | fast_reload_thread_main (void *arg) |
fast reload thread. | |
static int | create_socketpair (int *pair, struct ub_randstate *rand) |
create a socketpair for bidirectional communication, false on failure | |
static int | fast_reload_thread_setup (struct worker *worker, int fr_verb, int fr_nopause, int fr_drop_mesh) |
fast reload thread. | |
static void | fr_auth_change_list_delete (struct fast_reload_auth_change *auth_zone_change_list) |
fast reload, delete auth zone change list | |
static void | fast_reload_thread_desetup (struct fast_reload_thread *fast_reload_thread) |
fast reload thread. | |
static void | fr_send_cmd_to (struct fast_reload_thread *fr, enum fast_reload_notification status, int check_cmds, int blocking) |
Fast reload thread, send a command to the thread. | |
static void | fr_main_perform_done (struct fast_reload_thread *fr) |
Fast reload, the main thread handles that the fast reload thread has exited. | |
static void | cfg_strlist_append_listhead (struct config_strlist_head *list, struct config_strlist_head *more) |
Append strlist after strlist. | |
static void | fr_read_ack_from_workers (struct fast_reload_thread *fr) |
fast reload, receive ack from workers that they are waiting, run by the mainthr after sending them reload_stop. | |
static void | fr_poll_for_reload_start (struct fast_reload_thread *fr) |
fast reload, poll for reload_start in mainthr waiting on a notification from the fast reload thread. | |
static void | fr_worker_pickup_mesh (struct worker *worker) |
Pick up the worker mesh changes, after fast reload. | |
static void | tcl_remove_old (struct listen_dnsport *front) |
Remove the old tcl_addr entries from the open connections. | |
static void | auth_zone_zonemd_stop_lookup (struct auth_zone *z, struct mesh_area *mesh) |
Stop zonemd lookup. | |
static void | fr_pickup_auth_locks (struct worker *worker, struct auth_zone *namez, struct auth_zone *old_z, struct auth_zone *new_z, struct auth_xfer **xfr, struct auth_xfer **loadxfr) |
Pick up the auth zone locks. | |
static void | fr_worker_auth_del (struct worker *worker, struct fast_reload_auth_change *item, int for_change) |
Fast reload, worker picks up deleted auth zone. | |
static void | auth_xfr_pickup_config (struct auth_xfer *loadxfr, struct auth_xfer *xfr) |
Fast reload, auth xfer config is picked up. | |
static void | fr_worker_auth_add (struct worker *worker, struct fast_reload_auth_change *item, int for_change) |
Fast reload, worker picks up added auth zone. | |
static void | fr_worker_auth_cha (struct worker *worker, struct fast_reload_auth_change *item) |
Fast reload, worker picks up changed auth zone. | |
static void | fr_worker_pickup_auth_changes (struct worker *worker, struct fast_reload_auth_change *auth_zone_change_list) |
Fast reload, the worker picks up changes in auth zones. | |
static void | fr_worker_pickup_outside_network (struct worker *worker) |
Fast reload, the worker picks up changes in outside_network. | |
void | fast_reload_worker_pickup_changes (struct worker *worker) |
Pick up per worker changes after a fast reload. | |
static void | fr_main_perform_reload_stop (struct fast_reload_thread *fr) |
fast reload thread, handle reload_stop notification, send reload stop to other threads over IPC and collect their ack. | |
static void | fr_main_perform_reload_nopause_poll (struct fast_reload_thread *fr) |
Fast reload, the main thread performs the nopause poll. | |
static void | fr_main_perform_cmd (struct fast_reload_thread *fr, enum fast_reload_notification status) |
Fast reload, perform the command received from the fast reload thread. | |
static void | fr_main_handle_cmd (struct fast_reload_thread *fr) |
Fast reload, handle command from fast reload to the main thread. | |
void | fast_reload_service_cb (int ATTR_UNUSED(fd), short ATTR_UNUSED(bits), void *arg) |
static int | fr_client_send_item_fd (struct fast_reload_printq *printq) |
fast reload, send client item for fd, returns bytes sent, or 0 for wait later, or -1 on failure. | |
static int | fr_client_send_item (struct fast_reload_printq *printq) |
fast reload, send current client item. | |
static void | fr_client_pickup_next_item (struct fast_reload_printq *printq) |
fast reload, pick up the next item to print | |
int | fast_reload_client_callback (struct comm_point *ATTR_UNUSED(c), void *arg, int err, struct comm_reply *ATTR_UNUSED(rep)) |
static struct fast_reload_printq * | fr_printq_create (struct comm_point *c, struct worker *worker) |
fast reload printq create | |
void | fast_reload_printq_list_delete (struct fast_reload_printq *list) |
fast reload printq delete list | |
static void | fr_printq_list_remove (struct fast_reload_printq *printq) |
fast reload printq remove the item from the printq list | |
static void | fr_send_stop (struct fast_reload_thread *fr) |
fast reload thread, send stop command to the thread, from the main thread. | |
void | fast_reload_thread_start (RES *ssl, struct worker *worker, struct rc_state *s, int fr_verb, int fr_nopause, int fr_drop_mesh) |
Start fast reload thread. | |
void | fast_reload_thread_stop (struct fast_reload_thread *fast_reload_thread) |
Stop fast reload thread. | |
This file contains the remote control functionality for the daemon.
The remote control can be performed using either the commandline unbound-control tool, or a TLS capable web browser. The channel is secured using TLSv1, and certificates. Both the server and the client(control tool) have their own keys.
struct daemon_remote * daemon_remote_create | ( | struct config_file * | cfg | ) |
Create new remote control state for the daemon.
cfg | config file with key file settings. |
References config_file::control_ifs, config_file::control_use_cert, daemon_remote_delete(), config_strlist_head::first, log_err(), log_warn(), daemon_remote::max_active, config_strlist::next, options_remote_is_address(), config_file::remote_control_enable, and config_strlist::str.
Referenced by service_init().
void daemon_remote_clear | ( | struct daemon_remote * | rc | ) |
remote control state to clear up.
Busy and accept points are closed. Does not delete the rc itself, or the ssl context (with its keys).
rc | state to clear. |
References daemon_remote::accept_list, daemon_remote::active, daemon_remote::busy_list, rc_state::c, comm_point_delete(), listen_list_delete(), rc_state::next, rc_state::rc, and daemon_remote::worker.
Referenced by daemon_cleanup(), and daemon_remote_delete().
void daemon_remote_delete | ( | struct daemon_remote * | rc | ) |
remote control state to delete.
rc | state to delete. |
References daemon_remote_clear(), and rc_state::rc.
Referenced by daemon_delete(), and daemon_remote_create().
|
static |
Add and open a new control port.
ip | ip str |
nr | port nr |
list | list head |
noproto_is_err | if lack of protocol support is an error. |
cfg | config with username for chown of unix-sockets. |
References cfg_gid, cfg_uid, create_local_accept_sock(), create_tcp_accept_sock(), listen_port::fd, config_file::ip_dscp, config_file::ip_freebind, config_file::ip_transparent, log_assert, log_err(), listen_port::next, sock_close(), config_file::use_systemd, config_file::username, VERB_QUERY, and verbose().
Referenced by daemon_remote_open_ports().
struct listen_port * daemon_remote_open_ports | ( | struct config_file * | cfg | ) |
Open and create listening ports for remote control.
cfg | config options. |
References add_open(), config_del_strarray(), config_file::control_ifs, config_file::control_port, config_file::do_ip4, config_file::do_ip6, config_strlist_head::first, listening_ports_free(), log_assert, config_file::remote_control_enable, and resolve_interface_names().
Referenced by daemon_open_shared_ports().
int daemon_remote_open_accept | ( | struct daemon_remote * | rc, |
struct listen_port * | ports, | ||
struct worker * | worker | ||
) |
Setup comm points for accepting remote control connections.
rc | state |
ports | already opened ports. |
worker | worker with communication base. and links to command channels. |
References accept_open(), listen_port::fd, log_err(), listen_port::next, and daemon_remote::worker.
Referenced by worker_init().
void daemon_remote_stop_accept | ( | struct daemon_remote * | rc | ) |
Stop accept handlers for TCP (until enabled again)
rc | state |
References daemon_remote::accept_list, listen_list::com, and listen_list::next.
Referenced by worker_stop_accept().
void daemon_remote_start_accept | ( | struct daemon_remote * | rc | ) |
Stop accept handlers for TCP (until enabled again)
rc | state |
References daemon_remote::accept_list, listen_list::com, and listen_list::next.
Referenced by worker_start_accept().
Write the cookie secrets to file, returns 0
on failure.
Caller has to hold the lock.
References module_env::cfg, cookie_secrets::cookie_count, cookie_secret::cookie_secret, config_file::cookie_secret_file, daemon::cookie_secrets, worker::daemon, worker::env, hex_ntop(), log_assert, and ssl_printf().
Referenced by do_activate_cookie_secret(), do_add_cookie_secret(), and do_drop_cookie_secret().
void daemon_remote_exec | ( | struct worker * | worker | ) |
Handle nonthreaded remote cmd execution.
worker | this worker (the remote worker). |
References worker::cmd, execute_cmd(), log_err(), tube_read_msg(), VERB_ALGO, and verbose().
|
static |
This routine polls a socket for readiness.
fd | file descriptor, -1 uses no fd for a timer only. |
timeout | time in msec to wait. 0 means nonblocking test, -1 waits blocking for events. |
pollin | check for input event. |
pollout | check for output event. |
event | output variable, set to true if the event happens. It is false if there was an error or timeout. |
References IPC_LOOP_MAX, log_assert, log_err(), and sock_strerror().
Referenced by create_socketpair(), fr_check_cmd_from_thread(), fr_poll_for_ack(), fr_poll_for_quit(), fr_poll_for_reload_start(), fr_send_cmd_to(), and fr_send_notification().
|
static |
fast reload, poll for notification incoming.
True if quit
References fast_reload_thread::commpair, fast_reload_notification_exit, fr_notification_to_string(), IPC_LOOP_MAX, log_err(), fast_reload_thread::need_to_quit, sock_poll_timeout(), sock_strerror(), VERB_ALGO, and verbose().
Referenced by fast_reload_thread_main(), fr_construct_from_config(), fr_load_config(), fr_printmem(), fr_read_config(), and fr_send_notification().
|
static |
fast reload thread.
Send notification from the fast reload thread
References fast_reload_thread::commpair, fr_notification_to_string(), fr_poll_for_quit(), IPC_LOOP_MAX, IPC_NOTIFICATION_WAIT, log_err(), sock_poll_timeout(), sock_strerror(), VERB_ALGO, and verbose().
Referenced by fast_reload_thread_main(), fr_check_compat_cfg(), fr_check_nopause_cfg(), fr_check_tag_defines(), fr_finish_time(), fr_load_config(), fr_printmem(), fr_read_config(), and fr_reload_ipc().
|
static |
fast reload thread printout function, with printf arguments
fast reload thread printout function, prints to list and signals the remote control thread to move that to get written to the socket of the remote control connection.
References fr_output_vmsg().
Referenced by fast_reload_thread_main(), fr_check_compat_cfg(), fr_check_nopause_cfg(), fr_check_tag_defines(), fr_finish_time(), fr_load_config(), fr_printmem(), and fr_read_config().
|
static |
fast reload thread.
the thread main function
References fast_reload_notification_done, fast_reload_notification_done_error, fast_reload_notification_exited, fast_reload_notification_printout, fr_finish_time(), fr_init_time(), fr_load_config(), fr_output_printf(), fr_poll_for_quit(), fr_send_notification(), fast_reload_thread::fr_verb, log_thread_set(), fast_reload_thread::need_to_quit, fast_reload_thread::threadnum, VERB_ALGO, and verbose().
Referenced by fast_reload_thread_start().
|
static |
fast reload thread.
setup the thread info
References fast_reload_thread::commpair, fast_reload_thread::commreload, create_socketpair(), worker::daemon, daemon::fast_reload_drop_mesh, daemon::fast_reload_thread, fast_reload_thread::fr_drop_mesh, fast_reload_thread::fr_nopause, fast_reload_thread::fr_output, fast_reload_thread::fr_output_lock, fast_reload_thread::fr_verb, daemon::num, daemon::rand, sock_close(), fast_reload_thread::threadnum, and fast_reload_thread::worker.
Referenced by fast_reload_thread_start().
|
static |
fast reload thread.
desetup and delete the thread info.
References fast_reload_thread::auth_zone_change_list, fast_reload_thread::commpair, fast_reload_thread::commreload, config_delstrlist(), worker::daemon, config_strlist_head::first, fr_auth_change_list_delete(), fr_main_perform_printout(), fast_reload_thread::fr_output, fast_reload_thread::fr_output_lock, fr_printq_delete(), fr_printq_empty(), fr_printq_list_insert(), fast_reload_thread::printq, fast_reload_thread::service_event, fast_reload_thread::service_event_is_added, sock_close(), ub_event_del(), ub_event_free(), and fast_reload_thread::worker.
Referenced by fast_reload_thread_start(), and fr_main_perform_done().
|
static |
Fast reload thread, send a command to the thread.
Blocking on timeout. It handles received input from the thread, if any is received.
References fast_reload_thread::commpair, fr_check_cmd_from_thread(), fr_notification_to_string(), IPC_LOOP_MAX, IPC_NOTIFICATION_WAIT, log_assert, log_err(), sock_poll_timeout(), sock_strerror(), VERB_ALGO, and verbose().
Referenced by fr_main_perform_reload_nopause_poll(), fr_main_perform_reload_stop(), and fr_send_stop().
|
static |
Remove the old tcl_addr entries from the open connections.
They are only incremented when an accept is performed on a tcp comm point.
front | listening comm ports of the worker. |
References listen_list::com, listen_dnsport::cps, comm_point::max_tcp_count, listen_list::next, comm_point::tcl_addr, comm_point::tcp_handlers, and comm_point::type.
Referenced by fast_reload_worker_pickup_changes().
|
static |
fast reload thread, handle reload_stop notification, send reload stop to other threads over IPC and collect their ack.
When that is done, ack to the caller, the fast reload thread, and wait for it to send start.
References worker::daemon, worker::env, daemon::fast_reload_drop_mesh, fast_reload_notification_reload_ack, fast_reload_worker_pickup_changes(), fr_poll_for_reload_start(), fr_read_ack_from_workers(), fr_send_cmd_to(), module_env::mesh, mesh_delete_all(), daemon::num, worker::thread_num, VERB_ALGO, verbose(), fast_reload_thread::worker, worker_cmd_reload_start, worker_cmd_reload_stop, worker_send_cmd(), and daemon::workers.
Referenced by fr_main_perform_cmd().
|
static |
Fast reload, the main thread performs the nopause poll.
It polls every other worker thread briefly over the command pipe ipc. The command takes no time for the worker, it can return immediately. After that it sends an acknowledgement to the fastreload thread.
References worker::daemon, fast_reload_notification_reload_ack, fast_reload_worker_pickup_changes(), fr_read_ack_from_workers(), fr_send_cmd_to(), daemon::num, worker::thread_num, fast_reload_thread::worker, worker_cmd_reload_poll, worker_send_cmd(), and daemon::workers.
Referenced by fr_main_perform_cmd().
|
static |
fast reload, send current client item.
false on failure or wait later.
References fast_reload_printq::client_byte_count, fast_reload_printq::client_len, fr_client_send_item_fd(), fr_printq_remove(), and fast_reload_printq::remote.
void fast_reload_thread_start | ( | RES * | ssl, |
struct worker * | worker, | ||
struct rc_state * | s, | ||
int | fr_verb, | ||
int | fr_nopause, | ||
int | fr_drop_mesh | ||
) |
Start fast reload thread.
ssl | the RES connection to print to. |
worker | the remote servicing worker. |
s | the rc_state that is servicing the remote control connection to the remote control client. It needs to be moved away to stay connected while the fast reload is running. |
fr_verb | verbosity to print output at. 0 is nothing, 1 is some and 2 is more detail. |
fr_nopause | option to not pause threads during reload. |
fr_drop_mesh | option to drop mesh queries. |
References daemon_remote::active, worker::base, daemon_remote::busy_list, rc_state::c, fast_reload_printq::client_cp, fast_reload_thread::commpair, worker::daemon, daemon::fast_reload_thread, fast_reload_thread_desetup(), fast_reload_thread_main(), fast_reload_thread_setup(), comm_point::fd, fd_set_nonblock(), fr_printq_create(), log_assert, log_err(), fast_reload_thread::printq, rc_state::rc, fast_reload_printq::remote, fast_reload_thread::service_event, fast_reload_thread::service_event_is_added, ssl_printf(), fast_reload_thread::started, state_list_remove_elem(), fast_reload_thread::tid, UB_EV_PERSIST, UB_EV_READ, ub_event_add(), and ub_event_new().
Referenced by do_fast_reload().
void fast_reload_thread_stop | ( | struct fast_reload_thread * | fast_reload_thread | ) |
Stop fast reload thread.
fast_reload_thread | the thread struct. |
References worker::daemon, daemon::fast_reload_thread, fr_main_perform_done(), fr_send_stop(), and fast_reload_thread::worker.
Referenced by daemon_cleanup().