|
unbound 0.1
|
An implementation of the Frame Streams data transport protocol for the Unbound DNSTAP message logging facility. More...
#include "util/locks.h"Data Structures | |
| struct | dt_msg_queue |
| A message buffer with dnstap messages queued up. More... | |
| struct | dt_msg_entry |
| An entry in the dt_msg_queue. More... | |
| struct | dt_frame_read_buf |
| Containing buffer and counter for reading DNSTAP frames. More... | |
| struct | dt_io_thread |
| IO thread that reads from the queues and writes them. More... | |
| struct | dt_io_list_item |
| IO thread list of queues list item lists a worker queue that should be looked at and sent to the log server. More... | |
Functions | |
| struct dt_msg_queue * | dt_msg_queue_create (struct comm_base *base) |
| Create new (empty) worker message queue. | |
| void | dt_msg_queue_delete (struct dt_msg_queue *mq) |
| Delete a worker message queue. | |
| void | dt_msg_queue_submit (struct dt_msg_queue *mq, void *buf, size_t len, int *congested) |
| Submit a message to the queue. | |
| void | mq_wakeup_cb (void *arg) |
| timer callback to wakeup dtio thread to process messages | |
| struct dt_io_thread * | dt_io_thread_create (void) |
| Create IO thread. | |
| void | dt_io_thread_delete (struct dt_io_thread *dtio) |
| Delete the IO thread structure. | |
| int | dt_io_thread_apply_cfg (struct dt_io_thread *dtio, struct config_file *cfg) |
| Apply config to the dtio thread. | |
| int | dt_io_thread_register_queue (struct dt_io_thread *dtio, struct dt_msg_queue *mq) |
| Register a msg queue to the io thread. | |
| void | dt_io_thread_unregister_queue (struct dt_io_thread *dtio, struct dt_msg_queue *mq) |
| Unregister queue from io thread. | |
| int | dt_io_thread_start (struct dt_io_thread *dtio, void *event_base_nothr, int numworkers) |
| Start the io thread. | |
| void | dt_io_thread_stop (struct dt_io_thread *dtio) |
| Stop the io thread. | |
| void | dtio_reconnect_timeout_cb (int fd, short bits, void *arg) |
| callback for the dnstap reconnect, to start reconnecting to output | |
| void | dtio_output_cb (int fd, short bits, void *arg) |
| callback for the dnstap events, to write to the output | |
| void | dtio_cmd_cb (int fd, short bits, void *arg) |
| callback for the dnstap commandpipe, to stop the dnstap IO | |
| void | dtio_stop_timer_cb (int fd, short bits, void *arg) |
| callback for the timer when the thread stops and wants to finish up | |
| void | dtio_stop_ev_cb (int fd, short bits, void *arg) |
| callback for the output when the thread stops and wants to finish up | |
| void | dtio_tap_callback (int fd, short bits, void *arg) |
| callback for unbound-dnstap-socket | |
| void | dtio_mainfdcallback (int fd, short bits, void *arg) |
| callback for unbound-dnstap-socket | |
An implementation of the Frame Streams data transport protocol for the Unbound DNSTAP message logging facility.
| struct dt_msg_queue * dt_msg_queue_create | ( | struct comm_base * | base | ) |
Create new (empty) worker message queue.
Limit set to default on max.
| base | event base for wakeup timer. |
References comm_timer_create(), dt_msg_queue_create(), dt_msg_queue::lock, dt_msg_queue::maxsize, mq_wakeup_cb(), and dt_msg_queue::wakeup_timer.
Referenced by dt_msg_queue_create().
| void dt_msg_queue_delete | ( | struct dt_msg_queue * | mq | ) |
Delete a worker message queue.
It has to be unlinked from access, so it can be deleted without lock worries. The queue is emptied (deleted).
| mq | message queue. |
References comm_timer_delete(), dt_msg_queue_clear(), dt_msg_queue_delete(), dt_msg_queue::lock, and dt_msg_queue::wakeup_timer.
Referenced by dt_msg_queue_delete().
| void dt_msg_queue_submit | ( | struct dt_msg_queue * | mq, |
| void * | buf, | ||
| size_t | len, | ||
| int * | congested ) |
Submit a message to the queue.
The queue is locked by the routine, the message is inserted, and then the queue is unlocked so the message can be picked up by the writer thread.
| mq | message queue. |
| buf | buffer with message (dnstap contents). The buffer must have been malloced by caller. It is linked in the queue, and is free()d after use. If the routine fails the buffer is freed as well (and nothing happens, the item could not be logged). |
| len | length of buffer. |
| congested | set true if the operation failed because the queue is congested, and the message is dropped. |
References dt_msg_entry::buf, dt_msg_queue::cursize, dt_msg_queue_start_timer(), dt_msg_queue_submit(), dt_msg_queue::dtio, DTIO_MSG_FOR_WAKEUP, dt_io_thread::event_added_is_write, dt_msg_queue::first, dt_msg_entry::len, dt_msg_queue::lock, log_err(), dt_msg_queue::maxsize, dt_msg_queue::msgcount, dt_msg_entry::next, and entry::next.
Referenced by dt_msg_queue_submit().
| void mq_wakeup_cb | ( | void * | arg | ) |
timer callback to wakeup dtio thread to process messages
References dt_msg_queue::dtio, dtio_wakeup(), mq_wakeup_cb(), dt_io_thread::wakeup_timer_enabled, and dt_io_thread::wakeup_timer_lock.
Referenced by dt_msg_queue_create(), fptr_whitelist_comm_timer(), and mq_wakeup_cb().
| struct dt_io_thread * dt_io_thread_create | ( | void | ) |
Create IO thread.
References dt_io_thread_create(), dt_io_thread::io_list, dt_io_thread::io_list_iter, dt_io_thread::io_list_lock, dt_io_thread::wakeup_timer_enabled, and dt_io_thread::wakeup_timer_lock.
Referenced by dt_io_thread_create().
| void dt_io_thread_delete | ( | struct dt_io_thread * | dtio | ) |
Delete the IO thread structure.
| dtio | the io thread that is deleted. It must not be running. |
References dt_io_thread::client_cert_file, dt_io_thread::client_key_file, dt_io_thread_delete(), dt_io_thread::io_list, dt_io_thread::io_list_lock, dt_io_thread::ip_str, dt_io_list_item::next, dt_io_thread::socket_path, dt_io_thread::ssl_ctx, dt_io_thread::tls_server_name, and dt_io_thread::wakeup_timer_lock.
Referenced by dt_io_thread_delete().
| int dt_io_thread_apply_cfg | ( | struct dt_io_thread * | dtio, |
| struct config_file * | cfg ) |
Apply config to the dtio thread.
| dtio | io thread, not yet started. |
| cfg | config file struct. |
References check_auth_name_for_ssl(), config_file::chrootdir, dt_io_thread::client_cert_file, dt_io_thread::client_key_file, connect_sslctx_create(), config_file::dnstap, config_file::dnstap_bidirectional, config_file::dnstap_ip, config_file::dnstap_socket_path, config_file::dnstap_tls, config_file::dnstap_tls_cert_bundle, config_file::dnstap_tls_client_cert_file, config_file::dnstap_tls_client_key_file, config_file::dnstap_tls_server_name, dt_io_thread_apply_cfg(), dt_io_thread::ip_str, dt_io_thread::is_bidirectional, log_err(), config_file::log_thread_id, log_warn(), dt_io_thread::socket_path, dt_io_thread::ssl_ctx, config_file::tls_cert_bundle, dt_io_thread::tls_server_name, config_file::tls_use_sni, dt_io_thread::tls_use_sni, config_file::tls_win_cert, dt_io_thread::upstream_is_tcp, dt_io_thread::upstream_is_tls, dt_io_thread::upstream_is_unix, and dt_io_thread::use_client_certs.
Referenced by dt_io_thread_apply_cfg().
| int dt_io_thread_register_queue | ( | struct dt_io_thread * | dtio, |
| struct dt_msg_queue * | mq ) |
Register a msg queue to the io thread.
It will be polled to see if there are messages and those then get removed and sent, when the thread is running.
| dtio | the io thread. |
| mq | message queue to register. |
References dt_io_thread_register_queue(), dt_msg_queue::dtio, dt_io_thread::io_list, dt_io_thread::io_list_iter, dt_io_thread::io_list_lock, dt_msg_queue::lock, dt_io_list_item::next, and dt_io_list_item::queue.
Referenced by dt_io_thread_register_queue().
| void dt_io_thread_unregister_queue | ( | struct dt_io_thread * | dtio, |
| struct dt_msg_queue * | mq ) |
Unregister queue from io thread.
| dtio | the io thread. |
| mq | message queue. |
References dt_io_thread_unregister_queue(), dt_msg_queue::dtio, dt_io_thread::io_list, dt_io_thread::io_list_iter, dt_io_thread::io_list_lock, dt_msg_queue::lock, dt_io_list_item::next, and dt_io_list_item::queue.
Referenced by dt_io_thread_unregister_queue().
| int dt_io_thread_start | ( | struct dt_io_thread * | dtio, |
| void * | event_base_nothr, | ||
| int | numworkers ) |
Start the io thread.
| dtio | the io thread. |
| event_base_nothr | the event base to attach the events to, in case we are running without threads. With threads, this is ignored and a thread is started to process the dnstap log messages. |
| numworkers | number of worker threads. The dnstap io thread is that number +1 as the threadnumber (in logs). |
References dt_io_thread::commandpipe, dnstap_io(), dt_io_thread_start(), dtio_setup_on_base(), dt_io_thread::event_base, log_err(), dt_io_thread::started, dt_io_thread::threadnum, and dt_io_thread::tid.
Referenced by dt_io_thread_start(), and worker_init().
| void dt_io_thread_stop | ( | struct dt_io_thread * | dtio | ) |
Stop the io thread.
| dtio | the io thread. |
References dt_io_thread::commandpipe, dt_io_thread_stop(), DTIO_COMMAND_STOP, dtio_desetup(), log_err(), sock_strerror(), dt_io_thread::started, dt_io_thread::tid, VERB_ALGO, verbose(), and dt_io_thread::want_to_exit.
Referenced by dt_io_thread_stop(), and worker_delete().
| void dtio_reconnect_timeout_cb | ( | int | fd, |
| short | bits, | ||
| void * | arg ) |
callback for the dnstap reconnect, to start reconnecting to output
References dtio_reconnect_timeout_cb().
| void dtio_output_cb | ( | int | fd, |
| short | bits, | ||
| void * | arg ) |
callback for the dnstap events, to write to the output
References dtio_output_cb().
| void dtio_cmd_cb | ( | int | fd, |
| short | bits, | ||
| void * | arg ) |
callback for the dnstap commandpipe, to stop the dnstap IO
References dtio_cmd_cb().
| void dtio_tap_callback | ( | int | fd, |
| short | bits, | ||
| void * | arg ) |
callback for unbound-dnstap-socket
References dtio_tap_callback().
Referenced by dtio_mainfdcallback(), dtio_tap_callback(), dtio_tap_callback(), and fptr_whitelist_event().
| void dtio_mainfdcallback | ( | int | fd, |
| short | bits, | ||
| void * | arg ) |
callback for unbound-dnstap-socket
References dtio_mainfdcallback().
Referenced by dtio_mainfdcallback(), dtio_mainfdcallback(), fptr_whitelist_event(), setup_local_list(), setup_tcp_list(), and setup_tls_list().