remote.h File Reference

This file contains the remote control functionality for the daemon. More...

#include "util/locks.h"

Data Structures

struct  rc_state
 a busy control command connection, SSL state More...
 
struct  daemon_remote
 The remote control tool state. More...
 
struct  remote_stream
 Connection to print to, either SSL or plain over fd. More...
 
struct  fast_reload_printq
 Fast reload printout queue. More...
 
struct  fast_reload_auth_change
 Fast reload auth zone change. More...
 
struct  fast_reload_thread
 Fast reload thread structure. More...
 

Macros

#define REMOTE_CONTROL_TCP_TIMEOUT   120000
 number of milliseconds timeout on incoming remote control handshake
 

Typedefs

typedef struct remote_stream RES
 

Enumerations

enum  fast_reload_notification {
  fast_reload_notification_none = 0 , fast_reload_notification_done = 1 , fast_reload_notification_done_error = 2 , fast_reload_notification_exit = 3 ,
  fast_reload_notification_exited = 4 , fast_reload_notification_printout = 5 , fast_reload_notification_reload_stop = 6 , fast_reload_notification_reload_ack = 7 ,
  fast_reload_notification_reload_start = 8 , fast_reload_notification_reload_nopause_poll = 9
}
 Notification status. More...
 

Functions

struct daemon_remotedaemon_remote_create (struct config_file *cfg)
 Create new remote control state for the daemon.
 
void daemon_remote_delete (struct daemon_remote *rc)
 remote control state to delete.
 
void daemon_remote_clear (struct daemon_remote *rc)
 remote control state to clear up.
 
struct listen_portdaemon_remote_open_ports (struct config_file *cfg)
 Open and create listening ports for remote control.
 
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)
 
void daemon_remote_exec (struct worker *worker)
 Handle nonthreaded remote cmd execution.
 
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.
 
void fast_reload_service_cb (int fd, short bits, void *arg)
 fast reload thread commands to remote service thread event callback
 
int fast_reload_client_callback (struct comm_point *c, void *arg, int err, struct comm_reply *rep)
 fast reload callback for the remote control client connection
 
void fast_reload_printq_list_delete (struct fast_reload_printq *list)
 fast reload printq delete list
 
void fast_reload_worker_pickup_changes (struct worker *worker)
 Pick up per worker changes after a fast reload.
 

Detailed Description

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 SSLv3/TLS capable web browser. The channel is secured using SSLv3 or TLSv1, and certificates. Both the server and the client(control tool) have their own keys.

Enumeration Type Documentation

◆ fast_reload_notification

Notification status.

This is exchanged between the fast reload thread and the server thread, over the commpair sockets.

Enumerator
fast_reload_notification_none 

nothing, not used

fast_reload_notification_done 

the fast reload thread is done

fast_reload_notification_done_error 

the fast reload thread is done but with an error, it failed

fast_reload_notification_exit 

the fast reload thread is told to exit by the server thread.

Sent on server quit while the reload is running.

fast_reload_notification_exited 

the fast reload thread has exited, after being told to exit

fast_reload_notification_printout 

the fast reload thread has information to print out

fast_reload_notification_reload_stop 

stop as part of the reload the thread and other threads

fast_reload_notification_reload_ack 

ack the stop as part of the reload, and also ack start

fast_reload_notification_reload_start 

resume from stop as part of the reload

fast_reload_notification_reload_nopause_poll 

the fast reload thread wants the mainthread to poll workers, after the reload, sent when nopause is used

Function Documentation

◆ daemon_remote_create()

struct daemon_remote * daemon_remote_create ( struct config_file cfg)

Create new remote control state for the daemon.

Parameters
cfgconfig file with key file settings.
Returns
new state, or NULL on failure.

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

◆ daemon_remote_delete()

void daemon_remote_delete ( struct daemon_remote rc)

remote control state to delete.

Parameters
rcstate to delete.

References daemon_remote_clear(), and rc_state::rc.

Referenced by daemon_delete(), and daemon_remote_create().

◆ daemon_remote_clear()

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

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

◆ daemon_remote_open_ports()

struct listen_port * daemon_remote_open_ports ( struct config_file cfg)

Open and create listening ports for remote control.

Parameters
cfgconfig options.
Returns
list of ports or NULL on failure. can be freed with listening_ports_free().

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

◆ daemon_remote_open_accept()

int daemon_remote_open_accept ( struct daemon_remote rc,
struct listen_port ports,
struct worker worker 
)

Setup comm points for accepting remote control connections.

Parameters
rcstate
portsalready opened ports.
workerworker with communication base. and links to command channels.
Returns
false on error.

References accept_open(), listen_port::fd, log_err(), listen_port::next, and daemon_remote::worker.

Referenced by worker_init().

◆ daemon_remote_stop_accept()

void daemon_remote_stop_accept ( struct daemon_remote rc)

Stop accept handlers for TCP (until enabled again)

Parameters
rcstate

References daemon_remote::accept_list, listen_list::com, and listen_list::next.

Referenced by worker_stop_accept().

◆ daemon_remote_start_accept()

void daemon_remote_start_accept ( struct daemon_remote rc)

Stop accept handlers for TCP (until enabled again)

Parameters
rcstate

References daemon_remote::accept_list, listen_list::com, and listen_list::next.

Referenced by worker_start_accept().

◆ daemon_remote_exec()

void daemon_remote_exec ( struct worker worker)

Handle nonthreaded remote cmd execution.

Parameters
workerthis worker (the remote worker).

References worker::cmd, execute_cmd(), log_err(), tube_read_msg(), VERB_ALGO, and verbose().

◆ fast_reload_thread_start()

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.

Parameters
sslthe RES connection to print to.
workerthe remote servicing worker.
sthe 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_verbverbosity to print output at. 0 is nothing, 1 is some and 2 is more detail.
fr_nopauseoption to not pause threads during reload.
fr_drop_meshoption 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().

◆ fast_reload_thread_stop()

void fast_reload_thread_stop ( struct fast_reload_thread fast_reload_thread)

Stop fast reload thread.

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