unbound: daemon/daemon.h File Reference

unbound 0.1

Data Structures | Functions
daemon.h File Reference

The daemon consists of global settings and a number of workers. More...

`#include "util/locks.h"`
`#include "util/alloc.h"`
`#include "services/modstack.h"`
`#include "dnstap/dnstap_config.h"`
`#include "dnscrypt/dnscrypt_config.h"`

## Data Structures
struct | daemon
| Structure holding worker list. More...

## Functions
struct daemon * | daemon_init (void)
| Initialize daemon structure.
int | daemon_open_shared_ports (struct daemon *daemon)
| Open shared listening ports (if needed).
int | daemon_privileged (struct daemon *daemon)
| Do daemon setup that needs privileges like opening privileged ports or opening device files.
void | daemon_fork (struct daemon *daemon)
| Fork workers and start service.
void | daemon_cleanup (struct daemon *daemon)
| Close off the worker thread information.
void | daemon_delete (struct daemon *daemon)
| Delete workers, close listening ports.
void | daemon_apply_cfg (struct daemon *daemon, struct config_file *cfg)
| Apply config settings.
int | setup_acl_for_ports (struct acl_list *list, struct listen_port *port_list)
| Setup acl list to have entries for the port list.
void | daemon_setup_sslctxs (struct daemon *daemon, struct config_file *cfg)
int | ssl_cert_changed (struct daemon *daemon, struct config_file *cfg)
| See if the SSL cert files have changed.
void * | daemon_setup_listen_dot_sslctx (struct daemon *daemon, struct config_file *cfg)
| Setup the listening DoT SSL_CTX, returns the ssl ctx.
void * | daemon_setup_listen_doh_sslctx (struct daemon *daemon, struct config_file *cfg)
| Setup the listening DoH SSL_CTX, returns the ssl ctx.
void * | daemon_setup_listen_quic_sslctx (struct daemon *daemon, struct config_file *cfg)
| Setup the listening Quic SSL_CTX, returns the ssl ctx.
void * | daemon_setup_connect_dot_sslctx (struct daemon *daemon, struct config_file *cfg)
| Setup the connect DoT SSL_CTX, returns the ssl ctx.

## Detailed Description

The daemon consists of global settings and a number of workers.

## Function Documentation

## ◆ daemon_init()

struct daemon * daemon_init | ( | void |  | ) |

Initialize daemon structure.

Returns
  : The daemon structure, or NULL on error.

References daemon::acl, daemon::acl_interface, acl_list_create(), acl_list_delete(), alloc_init(), module_env::auth_zones, auth_zones_create(), auth_zones_delete(), edns_known_options_delete(), edns_known_options_init(), module_env::edns_strings, edns_strings_create(), daemon::env, listen_setup_locks(), log_err(), daemon::mods, module_env::modstack, modstack_init(), daemon::need_to_exit, signal_handling_record(), daemon::superalloc, daemon::tcl, tcl_list_create(), tcl_list_delete(), daemon::time_boot, daemon::time_last_stat, and ub_openssl_lock_init().

Referenced by run_daemon(), and service_init().

## ◆ daemon_open_shared_ports()

int daemon_open_shared_ports | ( | struct daemon * | daemon | ) |

Open shared listening ports (if needed).

The cfg member pointer must have been set for the daemon.

Parameters

  daemon | the daemon.

Returns
  : false on error.

References daemon::acl_interface, acl_interface_init(), daemon::cfg, config_del_strarray(), config_file::control_port, daemon_remote_open_ports(), config_file::ifs, daemon::listening_port, listening_ports_free(), listening_ports_open(), log_assert, config_file::num_ifs, daemon::num_ports, config_file::num_threads, config_file::port, daemon::ports, daemon::rc_port, daemon::rc_ports, config_file::remote_control_enable, resolve_interface_names(), daemon::reuseport, setup_acl_for_ports(), and config_file::so_reuseport.

Referenced by run_daemon(), and service_init().

## ◆ daemon_privileged()

int daemon_privileged | ( | struct daemon * | daemon | ) |

Do daemon setup that needs privileges like opening privileged ports or opening device files.

The cfg member pointer must have been set for the daemon.

Parameters

  daemon | the daemon.

Returns
  : false on error.

References module_env::alloc, daemon::cfg, module_env::cfg, daemon::env, daemon::mods, modstack_call_startup(), config_file::module_conf, daemon::superalloc, and module_env::worker.

Referenced by perform_setup(), and service_init().

## ◆ daemon_fork()

void daemon_fork | ( | struct daemon * | daemon | ) |

Fork workers and start service.

When the routine exits, it is no longer forked.

Parameters

  daemon | the daemon.

References daemon::acl, daemon::acl_interface, acl_interface_apply_cfg(), acl_list_apply_cfg(), module_env::auth_zones, auth_zones_apply_cfg(), cachedb_is_enabled(), daemon::cfg, config_file::cookie_secret_file, daemon::cookie_secrets, cookie_secrets_apply_cfg(), cookie_secrets_create(), daemon_create_workers(), daemon_reload_sslctxs(), daemon_setup_modules(), daemon_start_others(), daemon_stop_others(), config_file::dnscrypt, module_env::edns_strings, edns_strings_apply_cfg(), daemon::env, forwards_apply_cfg(), forwards_create(), module_env::fwds, module_env::hints, hints_apply_cfg(), hints_create(), daemon::local_zones, local_zones_apply_cfg(), local_zones_create(), log_assert, log_info(), log_warn(), daemon::mods, modstack_find(), daemon::need_to_exit, worker::need_to_exit, daemon::ports, respip_global_apply_cfg(), module_env::respip_set, respip_set_create(), respip_set_is_empty(), respip_views_apply_cfg(), daemon::reuse_cache, worker::reuse_cache, set_log_thread_id(), config_file::shm_enable, signal_handling_playback(), config_file::stat_interval, daemon::stat_time_offset, daemon::stat_time_specific, daemon::tcl, tcl_list_apply_cfg(), daemon::use_response_ip, daemon::use_rpz, module_env::views, views_apply_cfg(), views_create(), worker_init(), worker_work(), and daemon::workers.

Referenced by run_daemon(), and service_main().

## ◆ daemon_cleanup()

void daemon_cleanup | ( | struct daemon * | daemon | ) |

Close off the worker thread information.

Bring the daemon back into state ready for daemon_fork again.

Parameters

  daemon | the daemon.

References module_env::auth_zones, auth_zones_cleanup(), daemon::cfg, daemon_clear_allocs(), daemon_remote_clear(), daemon::doq_table, daemon::env, daemon::fast_reload_printq_list, fast_reload_printq_list_delete(), daemon::fast_reload_thread, fast_reload_thread_stop(), forwards_delete(), module_env::fwds, module_env::hints, hints_delete(), daemon::local_zones, local_zones_delete(), log_assert, log_thread_set(), module_env::msg_cache, daemon::need_to_exit, daemon::num, daemon::old_num, daemon::rc, module_env::respip_set, respip_set_delete(), daemon::reuse_cache, module_env::rrset_cache, signal_handling_record(), slabhash_clear(), rrset_cache::table, module_env::views, views_delete(), worker_delete(), and daemon::workers.

Referenced by run_daemon(), service_deinit(), and service_main().

## ◆ daemon_delete()

void daemon_delete | ( | struct daemon * | daemon | ) |

Delete workers, close listening ports.

Parameters

  daemon | the daemon.

References daemon::acl, daemon::acl_interface, acl_list_delete(), alloc_clear(), module_env::auth_zones, auth_zones_delete(), daemon::cfgfile, daemon::chroot, daemon::cookie_secrets, cookie_secrets_delete(), daemon_delete_sslctxs(), daemon_remote_delete(), edns_known_options_delete(), module_env::edns_strings, edns_strings_delete(), daemon::env, module_env::infra_cache, infra_delete(), listen_desetup_locks(), listening_ports_free(), log_err(), daemon::mods, modstack_call_deinit(), modstack_call_destartup(), modstack_free(), module_env::msg_cache, daemon::num_ports, daemon::pidfile, daemon::ports, daemon::rand, daemon::rc, daemon::rc_ports, module_env::rrset_cache, rrset_cache_delete(), slabhash_delete(), daemon::superalloc, daemon::tcl, tcl_list_delete(), ub_c_lex_destroy(), ub_openssl_lock_delete(), and ub_randfree().

Referenced by run_daemon(), service_deinit(), and service_init().

## ◆ daemon_apply_cfg()

void daemon_apply_cfg | ( | struct daemon * | daemon,
|  | struct config_file * | cfg )

Apply config settings.

Parameters

  daemon | the daemon.
  cfg | new config settings.

References daemon::cfg, config_apply(), daemon_clear_allocs(), daemon::env, HASH_DEFAULT_STARTARRAY, infra_adjust(), module_env::infra_cache, log_warn(), module_env::msg_cache, config_file::msg_cache_size, config_file::msg_cache_slabs, msgreply_sizefunc(), config_file::num_threads, daemon::old_num, query_info_compare(), module_env::rrset_cache, rrset_cache_adjust(), config_file::rrset_cache_size, config_file::rrset_cache_slabs, slabhash_clear(), slabhash_create(), slabhash_delete(), slabhash_is_size(), daemon::superalloc, rrset_cache::table, and daemon::worker_allocs.

Referenced by apply_settings(), and service_init().

## ◆ setup_acl_for_ports()

int setup_acl_for_ports | ( | struct acl_list * | list,
|  | struct listen_port * | port_list )

Setup acl list to have entries for the port list.

Parameters

  list | the acl interface
  port_list | list of open ports, or none.

Returns
  false on failure

References unbound_socket::acl, acl_interface_insert(), acl_refuse, unbound_socket::addr, unbound_socket::addrlen, listen_port::next, and listen_port::socket.

Referenced by ct_acl_interface_setup_ports(), and daemon_open_shared_ports().