|
unbound 0.1
|
This file has functions to get queries from clients. More...
#include "config.h"#include <limits.h>#include <ctype.h>#include "services/listen_dnsport.h"#include "services/outside_network.h"#include "util/netevent.h"#include "util/log.h"#include "util/config_file.h"#include "util/net_help.h"#include "sldns/sbuffer.h"#include "sldns/parseutil.h"#include "sldns/wire2str.h"#include "services/mesh.h"#include "util/fptr_wlist.h"#include "util/locks.h"#include "util/timeval_func.h"#include <fcntl.h>#include <sys/time.h>Macros | |
| #define | TCP_BACKLOG 256 |
| number of queued TCP connections for listen() | |
Functions | |
| static void | verbose_print_addr (struct addrinfo *addr, const char *additional) |
| Debug print of the getaddrinfo returned address. | |
| void | verbose_print_unbound_socket (struct unbound_socket *ub_sock) |
| for debug and profiling purposes only | |
| int | create_udp_sock (int family, int socktype, struct sockaddr *addr, socklen_t addrlen, int v6only, int *inuse, int *noproto, int rcv, int snd, int listen, int *reuseport, int transparent, int freebind, int use_systemd, int dscp) |
| Create and bind nonblocking UDP socket. | |
| int | create_tcp_accept_sock (struct addrinfo *addr, int v6only, int *noproto, int *reuseport, int transparent, int mss, int nodelay, int freebind, int use_systemd, int dscp, const char *additional) |
| Create and bind TCP listening socket. | |
| char * | set_ip_dscp (int socket, int addrfamily, int dscp) |
| int | create_local_accept_sock (const char *path, int *noproto, int use_systemd) |
| Create and bind local listening socket. | |
| static int | make_sock (int stype, const char *ifname, int port, struct addrinfo *hints, int v6only, int *noip6, size_t rcv, size_t snd, int *reuseport, int transparent, int tcp_mss, int nodelay, int freebind, int use_systemd, int dscp, struct unbound_socket *ub_sock, const char *additional) |
| Create socket from getaddrinfo results. | |
| static int | make_sock_port (int stype, const char *ifname, int port, struct addrinfo *hints, int v6only, int *noip6, size_t rcv, size_t snd, int *reuseport, int transparent, int tcp_mss, int nodelay, int freebind, int use_systemd, int dscp, struct unbound_socket *ub_sock, const char *additional) |
| make socket and first see if ifname contains port override info | |
| static int | port_insert (struct listen_port **list, int s, enum listen_type ftype, int pp2_enabled, struct unbound_socket *ub_sock) |
| Add port to open ports list. | |
| static int | set_recvtimestamp (int s) |
| set fd to receive software timestamps | |
| static int | set_recvpktinfo (int s, int family) |
| set fd to receive source address packet info | |
| static int | ports_create_if (const char *ifname, int do_auto, int do_udp, int do_tcp, struct addrinfo *hints, int port, struct listen_port **list, size_t rcv, size_t snd, int ssl_port, struct config_strlist *tls_additional_port, int https_port, struct config_strlist *proxy_protocol_port, struct rbtree_type *allow_proxy_tree, int *reuseport, int transparent, int tcp_mss, int freebind, int http2_nodelay, int use_systemd, int dnscrypt_port, int dscp, int quic_port, int http_notls_downstream, int sock_queue_timeout) |
| Helper for ports_open. | |
| static int | listen_cp_insert (struct comm_point *c, struct listen_dnsport *front) |
| Add items to commpoint list in front. | |
| void | listen_setup_locks (void) |
| setup the locks for the listen ports | |
| void | listen_desetup_locks (void) |
| desetup the locks for the listen ports | |
| struct listen_dnsport * | listen_create (struct comm_base *base, struct listen_port *ports, size_t bufsize, int tcp_accept_count, int tcp_idle_timeout, int harden_large_queries, uint32_t http_max_streams, char *http_endpoint, int http_notls, struct tcl_list *tcp_conn_limit, void *dot_sslctx, void *doh_sslctx, void *quic_sslctx, struct dt_env *dtenv, struct doq_table *doq_table, struct ub_randstate *rnd, struct config_file *cfg, comm_point_callback_type *cb, void *cb_arg) |
| Create commpoints with for this thread for the shared ports. | |
| void | listen_list_delete (struct listen_list *list) |
| delete listen_list of commpoints. | |
| void | listen_delete (struct listen_dnsport *front) |
| delete the listening structure | |
| int | resolve_interface_names (char **ifs, int num_ifs, struct config_strlist *list, char ***resif, int *num_resif) |
| Resolve interface names in config and store result IP addresses. | |
| struct listen_port * | listening_ports_open (struct config_file *cfg, char **ifs, int num_ifs, int *reuseport, struct rbtree_type *allow_proxy_tree) |
| Create shared listening ports Getaddrinfo, create socket, bind and listen to zero or more interfaces for IP4 and/or IP6, for UDP and/or TCP. | |
| void | listening_ports_free (struct listen_port *list) |
| Close and delete the (list of) listening ports. | |
| size_t | listen_get_mem (struct listen_dnsport *listen) |
| get memory size used by the listening structs | |
| void | listen_stop_accept (struct listen_dnsport *listen) |
| stop accept handlers for TCP (until enabled again) | |
| void | listen_start_accept (struct listen_dnsport *listen) |
| start accept handlers for TCP (was stopped before) | |
| struct tcp_req_info * | tcp_req_info_create (struct comm_base *base, struct sldns_buffer *spoolbuf) |
| Create tcp request info structure that keeps track of open requests on the TCP channel that are resolved at the same time, and the pending results that have to get written back to that client. | |
| void | tcp_req_info_delete (struct tcp_req_info *req) |
| Delete tcp request structure. | |
| void | tcp_req_info_clear (struct tcp_req_info *req) |
| Clear tcp request structure. | |
| void | tcp_req_info_remove_mesh_state (struct tcp_req_info *req, struct mesh_state *m) |
| Remove mesh state entry from list in tcp_req_info. | |
| static void | tcp_req_info_setup_listen (struct tcp_req_info *req) |
| setup listening for read or write | |
| static struct tcp_req_done_item * | tcp_req_info_pop_done (struct tcp_req_info *req) |
| remove first item from list of pending results | |
| static void | tcp_req_info_start_write_buf (struct tcp_req_info *req, uint8_t *buf, size_t len) |
| Send given buffer and setup to write. | |
| static void | tcp_req_pickup_next_result (struct tcp_req_info *req) |
| pick up the next result and start writing it to the channel | |
| int | tcp_req_info_handle_read_close (struct tcp_req_info *req) |
| the read channel has closed | |
| void | tcp_req_info_handle_writedone (struct tcp_req_info *req) |
| Handle write done of the last result packet. | |
| void | tcp_req_info_handle_readdone (struct tcp_req_info *req) |
| Handle read done of a new request from the client. | |
| int | tcp_req_info_add_meshstate (struct tcp_req_info *req, struct mesh_area *mesh, struct mesh_state *m) |
| Add mesh state to the tcp req list of open requests. | |
| static int | tcp_req_info_add_result (struct tcp_req_info *req, uint8_t *buf, size_t len) |
| Add a result to the result list. | |
| void | tcp_req_info_send_reply (struct tcp_req_info *req) |
| Send reply on tcp simultaneous answer channel. | |
| size_t | tcp_req_info_get_stream_buffer_size (void) |
| get the size of currently used tcp stream wait buffers (in bytes) | |
| size_t | http2_get_query_buffer_size (void) |
| get the size of currently used HTTP2 query buffers (in bytes) | |
| size_t | http2_get_response_buffer_size (void) |
| get the size of currently used HTTP2 response buffers (in bytes) | |
| int | http2_submit_dns_response (void *ATTR_UNUSED(v)) |
| void | doq_stream_add_meshstate (struct doq_stream *stream, struct mesh_area *mesh, struct mesh_state *m) |
| add mesh state to doq stream | |
| void | doq_stream_remove_mesh_state (struct doq_stream *stream) |
| remove mesh state from doq stream | |
| struct rbtree_type * | allow_proxy_tree_create (void) |
| Create allow proxy tree. | |
| static void | allow_proxy_node_del (rbnode_type *node, void *ATTR_UNUSED(arg)) |
| delete elements from the allow proxy tree | |
| static void | allow_proxy_tree_clear (struct rbtree_type *allow_proxy_tree) |
| clear the allow proxy tree | |
| void | allow_proxy_tree_delete (struct rbtree_type *allow_proxy_tree) |
| Delete allow proxy tree. | |
| static int | allow_proxy_tree_insert (struct rbtree_type *allow_proxy_tree, const char *str) |
| Insert netblock into allow proxy tree. | |
| int | allow_proxy_tree_apply_cfg (struct rbtree_type *allow_proxy_tree, struct config_file *cfg) |
| Apply config to the allow proxy tree. | |
| int | allow_proxy_check_incoming_proxy (struct unbound_socket *ub_sock, struct sockaddr_storage *addr, socklen_t addrlen) |
| Check incoming proxy address, false is rejected. | |
| size_t | allow_proxy_tree_get_mem (struct rbtree_type *allow_proxy_tree) |
| Get memory usage of allow proxy tree. | |
| void | allow_proxy_tree_swap_tree (struct rbtree_type *a, struct rbtree_type *b) |
| Swap tree for allow proxy tree. | |
Variables | |
| static lock_basic_type | stream_wait_count_lock |
| lock on the counter of stream buffer memory | |
| static lock_basic_type | http2_query_buffer_count_lock |
| lock on the counter of HTTP2 query buffer memory | |
| static lock_basic_type | http2_response_buffer_count_lock |
| lock on the counter of HTTP2 response buffer memory | |
| static size_t | stream_wait_count = 0 |
| size (in bytes) of stream wait buffers | |
| static int | stream_wait_lock_inited = 0 |
| is the lock initialised for stream wait buffers | |
| static size_t | http2_query_buffer_count = 0 |
| size (in bytes) of HTTP2 query buffers | |
| static int | http2_query_buffer_lock_inited = 0 |
| is the lock initialised for HTTP2 query buffers | |
| static size_t | http2_response_buffer_count = 0 |
| size (in bytes) of HTTP2 response buffers | |
| static int | http2_response_buffer_lock_inited = 0 |
| is the lock initialised for HTTP2 response buffers | |
This file has functions to get queries from clients.
| #define TCP_BACKLOG 256 |
number of queued TCP connections for listen()
Referenced by create_local_accept_sock(), and create_tcp_accept_sock().
|
static |
Debug print of the getaddrinfo returned address.
| addr | the address returned. |
| additional | additional text that describes the type of socket, or NULL for no text. |
References VERB_ALGO, verbose(), verbose_print_addr(), and verbosity.
Referenced by create_tcp_accept_sock(), make_sock(), and verbose_print_addr().
| void verbose_print_unbound_socket | ( | struct unbound_socket * | ub_sock | ) |
for debug and profiling purposes only
| ub_sock | the structure containing created socket info we want to print or log for |
References unbound_socket::acl, unbound_socket::addr, addr_to_str(), unbound_socket::addrlen, unbound_socket::fam, log_info(), unbound_socket::s, VERB_ALGO, verbose_print_unbound_socket(), and verbosity.
Referenced by verbose_print_unbound_socket().
| int create_udp_sock | ( | int | family, |
| int | socktype, | ||
| struct sockaddr * | addr, | ||
| socklen_t | addrlen, | ||
| int | v6only, | ||
| int * | inuse, | ||
| int * | noproto, | ||
| int | rcv, | ||
| int | snd, | ||
| int | listen, | ||
| int * | reuseport, | ||
| int | transparent, | ||
| int | freebind, | ||
| int | use_systemd, | ||
| int | dscp ) |
Create and bind nonblocking UDP socket.
| family | for socket call. |
| socktype | for socket call. |
| addr | for bind call. |
| addrlen | for bind call. |
| v6only | if enabled, IP6 sockets get IP6ONLY option set. if enabled with value 2 IP6ONLY option is disabled. |
| inuse | on error, this is set true if the port was in use. |
| noproto | on error, this is set true if cause is that the IPv6 proto (family) is not available. |
| rcv | set size on rcvbuf with socket option, if 0 it is not set. |
| snd | set size on sndbuf with socket option, if 0 it is not set. |
| listen | if true, this is a listening UDP port, eg port 53, and set SO_REUSEADDR on it. |
| reuseport | if nonNULL and true, try to set SO_REUSEPORT on listening UDP port. Set to false on return if it failed to do so. |
| transparent | set IP_TRANSPARENT socket option. |
| freebind | set IP_FREEBIND socket option. |
| use_systemd | if true, fetch sockets from systemd. |
| dscp | DSCP to use. |
References create_udp_sock(), fd_set_nonblock(), log_err(), log_err_addr(), log_warn(), sock_close(), sock_strerror(), VERB_ALGO, verbose(), and verbosity.
Referenced by create_udp_sock(), fd_for_dest(), make_sock(), and udp_sockport().
| int create_tcp_accept_sock | ( | struct addrinfo * | addr, |
| int | v6only, | ||
| int * | noproto, | ||
| int * | reuseport, | ||
| int | transparent, | ||
| int | mss, | ||
| int | nodelay, | ||
| int | freebind, | ||
| int | use_systemd, | ||
| int | dscp, | ||
| const char * | additional ) |
Create and bind TCP listening socket.
| addr | address info ready to make socket. |
| v6only | enable ip6 only flag on ip6 sockets. |
| noproto | if error caused by lack of protocol support. |
| reuseport | if nonNULL and true, try to set SO_REUSEPORT on listening UDP port. Set to false on return if it failed to do so. |
| transparent | set IP_TRANSPARENT socket option. |
| mss | maximum segment size of the socket. if zero, leaves the default. |
| nodelay | if true set TCP_NODELAY and TCP_QUICKACK socket options. |
| freebind | set IP_FREEBIND socket option. |
| use_systemd | if true, fetch sockets from systemd. |
| dscp | DSCP to use. |
| additional | additional log information for the socket type. |
References create_tcp_accept_sock(), fd_set_nonblock(), log_err(), log_err_addr(), log_warn(), sock_close(), sock_strerror(), TCP_BACKLOG, VERB_ALGO, verbose(), verbose_print_addr(), and verbosity.
Referenced by add_open(), create_tcp_accept_sock(), and make_sock().
| int create_local_accept_sock | ( | const char * | path, |
| int * | noproto, | ||
| int | use_systemd ) |
Create and bind local listening socket.
| path | path to the socket. |
| noproto | on error, this is set true if cause is that local sockets are not supported. |
| use_systemd | if true, fetch sockets from systemd. |
References create_local_accept_sock(), fd_set_nonblock(), log_err(), sock_close(), TCP_BACKLOG, VERB_ALGO, and verbose().
Referenced by add_open(), create_local_accept_sock(), and tap_socket_setup().
|
static |
Create socket from getaddrinfo results.
References unbound_socket::acl, unbound_socket::addr, unbound_socket::addrlen, create_tcp_accept_sock(), create_udp_sock(), unbound_socket::fam, log_err(), make_sock(), memdup(), unbound_socket::s, sock_close(), and verbose_print_addr().
Referenced by make_sock(), and make_sock_port().
|
static |
make socket and first see if ifname contains port override info
References log_err(), make_sock(), and make_sock_port().
Referenced by make_sock_port(), and ports_create_if().
|
static |
Add port to open ports list.
| list | list head. changed. |
| s | fd. |
| ftype | if fd is UDP. |
| pp2_enabled | if PROXYv2 is enabled for this port. |
| ub_sock | socket with address. |
References listen_port::fd, listen_port::ftype, listen_port::next, port_insert(), listen_port::pp2_enabled, and listen_port::socket.
Referenced by port_insert(), and ports_create_if().
|
static |
set fd to receive software timestamps
References log_err(), set_recvtimestamp(), and SO_TIMESTAMP.
Referenced by ports_create_if(), and set_recvtimestamp().
|
static |
set fd to receive source address packet info
References log_err(), and set_recvpktinfo().
Referenced by ports_create_if(), and set_recvpktinfo().
|
static |
Helper for ports_open.
Creates one interface (or NULL for default).
| ifname | The interface ip address. |
| do_auto | use automatic interface detection. If enabled, then ifname must be the wildcard name. |
| do_udp | if udp should be used. |
| do_tcp | if tcp should be used. |
| hints | for getaddrinfo. family and flags have to be set by caller. |
| port | Port number to use. |
| list | list of open ports, appended to, changed to point to list head. |
| rcv | receive buffer size for UDP |
| snd | send buffer size for UDP |
| ssl_port | ssl service port number |
| tls_additional_port | list of additional ssl service port numbers. |
| https_port | DoH service port number |
| proxy_protocol_port | list of PROXYv2 port numbers. |
| allow_proxy_tree | the allow proxy tree. |
| reuseport | try to set SO_REUSEPORT if nonNULL and true. set to false on exit if reuseport failed due to no kernel support. |
| transparent | set IP_TRANSPARENT socket option. |
| tcp_mss | maximum segment size of tcp socket. default if zero. |
| freebind | set IP_FREEBIND socket option. |
| http2_nodelay | set TCP_NODELAY on HTTP/2 connection |
| use_systemd | if true, fetch sockets from systemd. |
| dnscrypt_port | dnscrypt service port number |
| dscp | DSCP to use. |
| quic_port | dns over quic port number. |
| http_notls_downstream | if no tls is used for https downstream. |
| sock_queue_timeout | the sock_queue_timeout from config. Seconds to wait to discard if UDP packets have waited for long in the socket buffer. |
References unbound_socket::addr, unbound_socket::allow_proxy_tree, fatal_exit(), if_is_dnscrypt(), if_is_https(), if_is_pp2(), if_is_quic(), if_is_ssl(), if_listens_on(), listen_type_doq, listen_type_http, listen_type_ssl, listen_type_tcp, listen_type_tcp_dnscrypt, listen_type_udp, listen_type_udp_dnscrypt, listen_type_udpancil, listen_type_udpancil_dnscrypt, log_err(), log_warn(), make_sock_port(), port_insert(), ports_create_if(), unbound_socket::s, set_recvpktinfo(), set_recvtimestamp(), sock_close(), VERB_ALGO, and verbose().
Referenced by listening_ports_open(), and ports_create_if().
|
static |
Add items to commpoint list in front.
| c | commpoint to add. |
| front | listen struct. |
References listen_list::com, listen_dnsport::cps, listen_cp_insert(), and listen_list::next.
Referenced by listen_cp_insert(), and listen_create().
| void listen_setup_locks | ( | void | ) |
setup the locks for the listen ports
References http2_query_buffer_count_lock, http2_query_buffer_lock_inited, http2_response_buffer_count_lock, http2_response_buffer_lock_inited, listen_setup_locks(), stream_wait_count_lock, and stream_wait_lock_inited.
Referenced by context_finalize(), daemon_init(), and listen_setup_locks().
| void listen_desetup_locks | ( | void | ) |
desetup the locks for the listen ports
References http2_query_buffer_count_lock, http2_query_buffer_lock_inited, http2_response_buffer_count_lock, http2_response_buffer_lock_inited, listen_desetup_locks(), stream_wait_count_lock, and stream_wait_lock_inited.
Referenced by daemon_delete(), listen_desetup_locks(), ub_ctx_create(), and ub_ctx_delete().
| struct listen_dnsport * listen_create | ( | struct comm_base * | base, |
| struct listen_port * | ports, | ||
| size_t | bufsize, | ||
| int | tcp_accept_count, | ||
| int | tcp_idle_timeout, | ||
| int | harden_large_queries, | ||
| uint32_t | http_max_streams, | ||
| char * | http_endpoint, | ||
| int | http_notls, | ||
| struct tcl_list * | tcp_conn_limit, | ||
| void * | dot_sslctx, | ||
| void * | doh_sslctx, | ||
| void * | quic_sslctx, | ||
| struct dt_env * | dtenv, | ||
| struct doq_table * | doq_table, | ||
| struct ub_randstate * | rnd, | ||
| struct config_file * | cfg, | ||
| comm_point_callback_type * | cb, | ||
| void * | cb_arg ) |
Create commpoints with for this thread for the shared ports.
| base | the comm_base that provides event functionality. for default all ifs. |
| ports | the list of shared ports. |
| bufsize | size of datagram buffer. |
| tcp_accept_count | max number of simultaneous TCP connections from clients. |
| tcp_idle_timeout | idle timeout for TCP connections in msec. |
| harden_large_queries | whether query size should be limited. |
| http_max_streams | maximum number of HTTP/2 streams per connection. |
| http_endpoint | HTTP endpoint to service queries on |
| http_notls | no TLS for http downstream |
| tcp_conn_limit | TCP connection limit info. |
| dot_sslctx | nonNULL if dot ssl context. |
| doh_sslctx | nonNULL if doh ssl context. |
| quic_sslctx | nonNULL if quic ssl context. |
| dtenv | nonNULL if dnstap enabled. |
| doq_table | the doq connection table, with shared information. |
| rnd | random state. |
| cfg | config file struct. |
| cb | callback function when a request arrives. It is passed the packet and user argument. Return true to send a reply. |
| cb_arg | user data argument for callback function. |
References comm_point::cb_arg, comm_point_create_doq(), comm_point_create_tcp(), comm_point_create_udp_ancil(), comm_point_delete(), listen_dnsport::cps, comm_point::do_not_close, comm_point::dtenv, listen_port::fd, listen_port::ftype, comm_point::http_endpoint, listen_cp_insert(), listen_create(), listen_delete(), listen_type_doq, listen_type_http, listen_type_ssl, listen_type_tcp, listen_type_tcp_dnscrypt, listen_type_udp, listen_type_udp_dnscrypt, listen_type_udpancil, listen_type_udpancil_dnscrypt, log_err(), log_warn(), listen_port::next, listen_port::pp2_enabled, sldns_buffer_new(), listen_port::socket, comm_point::ssl, comm_point::tcp_conn_limit, and listen_dnsport::udp_buff.
Referenced by listen_create(), and worker_init().
| void listen_list_delete | ( | struct listen_list * | list | ) |
delete listen_list of commpoints.
Calls commpointdelete() on items. This may close the fds or not depending on flags.
| list | to delete. |
References listen_list::com, comm_point_delete(), listen_list_delete(), and listen_list::next.
Referenced by daemon_remote_clear(), listen_delete(), and listen_list_delete().
| void listen_delete | ( | struct listen_dnsport * | listen | ) |
delete the listening structure
| listen | listening structure. |
References listen_dnsport::cps, listen_delete(), listen_list_delete(), sldns_buffer_free(), and listen_dnsport::udp_buff.
Referenced by listen_create(), listen_delete(), listen_delete(), and worker_delete().
| int resolve_interface_names | ( | char ** | ifs, |
| int | num_ifs, | ||
| struct config_strlist * | list, | ||
| char *** | resif, | ||
| int * | num_resif ) |
Resolve interface names in config and store result IP addresses.
| ifs | array of interfaces. The list of interface names, if not NULL. |
| num_ifs | length of ifs array. |
| list | if not NULL, this is used as the list of interface names. |
| resif | string array (malloced array of malloced strings) with result. NULL if cfg has none. |
| num_resif | length of resif. Zero if cfg has zero num_ifs. |
References config_del_strarray(), log_err(), config_strlist::next, resolve_interface_names(), and config_strlist::str.
Referenced by contact_server(), controlinterfacechecks(), daemon_open_shared_ports(), daemon_remote_open_ports(), interfacechecks(), read_acl_interface_tag_actions(), read_acl_interface_tag_datas(), read_acl_interface_tags(), read_acl_interface_view(), and resolve_interface_names().
| struct listen_port * listening_ports_open | ( | struct config_file * | cfg, |
| char ** | ifs, | ||
| int | num_ifs, | ||
| int * | reuseport, | ||
| struct rbtree_type * | allow_proxy_tree ) |
Create shared listening ports Getaddrinfo, create socket, bind and listen to zero or more interfaces for IP4 and/or IP6, for UDP and/or TCP.
On the given port number. It creates the sockets.
| cfg | settings on what ports to open. |
| ifs | interfaces to open, array of IP addresses, "ip[@port]". |
| num_ifs | length of ifs. |
| reuseport | set to true if you want reuseport, or NULL to not have it, set to false on exit if reuseport failed to apply (because of no kernel support). |
| allow_proxy_tree | the allow-proxy tree, for reference in pp2 sockets. |
References config_file::dnscrypt_port, config_file::do_ip4, config_file::do_ip6, config_file::do_tcp, config_file::do_udp, config_file::http_nodelay, config_file::http_notls_downstream, config_file::https_port, config_file::if_automatic, config_file::if_automatic_ports, config_file::incoming_num_tcp, config_file::ip_dscp, config_file::ip_freebind, config_file::ip_transparent, listening_ports_free(), listening_ports_open(), log_err(), config_file::port, ports_create_if(), config_file::proxy_protocol_port, config_file::quic_port, config_file::so_rcvbuf, config_file::so_sndbuf, config_file::sock_queue_timeout, config_file::ssl_port, str_is_ip6(), config_file::tcp_mss, config_file::tls_additional_port, and config_file::use_systemd.
Referenced by daemon_open_shared_ports(), and listening_ports_open().
| void listening_ports_free | ( | struct listen_port * | list | ) |
Close and delete the (list of) listening ports.
References unbound_socket::addr, listen_port::fd, listening_ports_free(), listen_port::next, sock_close(), and listen_port::socket.
Referenced by daemon_delete(), daemon_open_shared_ports(), daemon_remote_open_ports(), listening_ports_free(), and listening_ports_open().
| size_t listen_get_mem | ( | struct listen_dnsport * | listen | ) |
get memory size used by the listening structs
| listen | listening structure. |
References listen_dnsport::base, listen_list::com, listen_dnsport::cps, listen_get_mem(), listen_list::next, sldns_buffer_capacity(), and listen_dnsport::udp_buff.
Referenced by listen_get_mem(), and worker_mem_report().
| void listen_stop_accept | ( | struct listen_dnsport * | listen | ) |
stop accept handlers for TCP (until enabled again)
| listen | listening structure. |
References listen_list::com, listen_dnsport::cps, listen_stop_accept(), listen_list::next, comm_point::tcp_free, and comm_point::type.
Referenced by listen_stop_accept(), and worker_stop_accept().
| void listen_start_accept | ( | struct listen_dnsport * | listen | ) |
start accept handlers for TCP (was stopped before)
| listen | listening structure. |
References listen_list::com, listen_dnsport::cps, listen_start_accept(), listen_list::next, comm_point::tcp_free, and comm_point::type.
Referenced by listen_start_accept(), and worker_start_accept().
| struct tcp_req_info * tcp_req_info_create | ( | struct comm_base * | base, |
| struct sldns_buffer * | spoolbuf ) |
Create tcp request info structure that keeps track of open requests on the TCP channel that are resolved at the same time, and the pending results that have to get written back to that client.
| base | comm base for read again timer. |
| spoolbuf | shared buffer |
References comm_timer_create(), log_err(), tcp_req_info::read_again_timer, tcp_req_info::spool_buffer, and tcp_req_info_create().
Referenced by comm_point_create_tcp_handler(), and tcp_req_info_create().
| void tcp_req_info_delete | ( | struct tcp_req_info * | req | ) |
Delete tcp request structure.
Called by owning commpoint. Removes mesh entry references and stored results from the lists.
| req | the tcp request info |
References comm_timer_delete(), tcp_req_info::read_again_timer, tcp_req_info_clear(), and tcp_req_info_delete().
Referenced by comm_point_create_tcp_handler(), comm_point_delete(), and tcp_req_info_delete().
| void tcp_req_info_clear | ( | struct tcp_req_info * | req | ) |
Clear tcp request structure.
Removes list entries, sets it up ready for the next connection.
| req | tcp request info structure. |
References tcp_req_done_item::buf, comm_timer_disable(), comm_timer_is_set(), tcp_req_info::cp, tcp_req_info::done_req_list, tcp_req_done_item::len, tcp_req_open_item::mesh, tcp_req_open_item::mesh_state, mesh_state_remove_reply(), tcp_req_done_item::next, tcp_req_open_item::next, tcp_req_info::num_done_req, tcp_req_info::num_open_req, tcp_req_info::open_req_list, tcp_req_info::read_again_timer, tcp_req_info::read_is_closed, stream_wait_count, stream_wait_count_lock, tcp_req_info_clear(), VERB_CLIENT, and verbose().
Referenced by comm_point_close(), tcp_req_info_clear(), and tcp_req_info_delete().
| void tcp_req_info_remove_mesh_state | ( | struct tcp_req_info * | req, |
| struct mesh_state * | m ) |
Remove mesh state entry from list in tcp_req_info.
caller has to manage the mesh state reply entry in the mesh state.
| req | the tcp req info that has the entry removed from the list. |
| m | the state removed from the list. |
References tcp_req_open_item::mesh_state, tcp_req_open_item::next, tcp_req_info::num_open_req, tcp_req_info::open_req_list, and tcp_req_info_remove_mesh_state().
Referenced by mesh_new_client(), mesh_query_done(), mesh_serve_expired_callback(), mesh_state_cleanup(), and tcp_req_info_remove_mesh_state().
|
static |
setup listening for read or write
References adjusted_tcp_timeout(), comm_point_listen_for_rw(), tcp_req_info::cp, tcp_req_info::read_again, tcp_req_info::read_is_closed, comm_point::tcp_byte_count, comm_point::tcp_is_reading, and tcp_req_info_setup_listen().
Referenced by tcp_req_info_handle_readdone(), tcp_req_info_handle_writedone(), and tcp_req_info_setup_listen().
|
static |
remove first item from list of pending results
References tcp_req_info::done_req_list, tcp_req_done_item::len, log_assert, tcp_req_done_item::next, tcp_req_info::num_done_req, stream_wait_count, stream_wait_count_lock, and tcp_req_info_pop_done().
Referenced by tcp_req_info_pop_done(), and tcp_req_pickup_next_result().
|
static |
Send given buffer and setup to write.
References tcp_req_done_item::buf, comm_point::buffer, tcp_req_info::cp, tcp_req_done_item::len, sldns_buffer_clear(), sldns_buffer_flip(), sldns_buffer_write(), comm_point::tcp_is_reading, and tcp_req_info_start_write_buf().
Referenced by tcp_req_info_send_reply(), tcp_req_info_start_write_buf(), and tcp_req_pickup_next_result().
|
static |
pick up the next result and start writing it to the channel
References tcp_req_done_item::buf, tcp_req_done_item::len, tcp_req_info::num_done_req, tcp_req_info_pop_done(), tcp_req_info_start_write_buf(), and tcp_req_pickup_next_result().
Referenced by tcp_req_info_handle_readdone(), tcp_req_info_handle_writedone(), and tcp_req_pickup_next_result().
| int tcp_req_info_handle_read_close | ( | struct tcp_req_info * | req | ) |
the read channel has closed
| req | request. remaining queries are looked up and answered. |
References tcp_req_info::cp, comm_point::fd, tcp_req_info_handle_read_close(), VERB_ALGO, and verbose().
Referenced by comm_point_tcp_handle_read(), ssl_handle_read(), and tcp_req_info_handle_read_close().
| void tcp_req_info_handle_writedone | ( | struct tcp_req_info * | req | ) |
Handle write done of the last result packet.
| req | the tcp req info. |
References comm_point::buffer, comm_point_drop_reply(), tcp_req_info::cp, tcp_req_info::num_done_req, tcp_req_info::read_is_closed, comm_point::repinfo, sldns_buffer_clear(), comm_point::tcp_is_reading, tcp_req_info_handle_writedone(), tcp_req_info_setup_listen(), and tcp_req_pickup_next_result().
Referenced by tcp_callback_writer(), and tcp_req_info_handle_writedone().
| void tcp_req_info_handle_readdone | ( | struct tcp_req_info * | req | ) |
Handle read done of a new request from the client.
| req | the tcp req info. |
References adjusted_tcp_timeout(), comm_point::buffer, comm_point::callback, comm_point::cb_arg, tcp_req_info::cp, fptr_ok, fptr_whitelist_comm_point(), tcp_req_info::in_worker_handle, tcp_req_info::is_drop, tcp_req_info::is_reply, NETEVENT_NOERROR, comm_point::repinfo, sldns_buffer_clear(), sldns_buffer_set_limit(), tcp_req_info::spool_buffer, comm_point::tcp_is_reading, tcp_req_info_handle_readdone(), tcp_req_info_setup_listen(), and tcp_req_pickup_next_result().
Referenced by tcp_callback_reader(), and tcp_req_info_handle_readdone().
| int tcp_req_info_add_meshstate | ( | struct tcp_req_info * | req, |
| struct mesh_area * | mesh, | ||
| struct mesh_state * | m ) |
Add mesh state to the tcp req list of open requests.
So the comm_reply can be removed off the mesh reply list when the tcp channel has to be closed (for other reasons then that that request was done, eg. channel closed by client or some format error).
| req | tcp req info structure. It keeps track of the simultaneous requests and results on a tcp (or TLS) channel. |
| mesh | mesh area for the state. |
| m | mesh state to add. |
References log_assert, tcp_req_open_item::mesh, tcp_req_open_item::mesh_state, tcp_req_open_item::next, tcp_req_info::num_open_req, tcp_req_info::open_req_list, and tcp_req_info_add_meshstate().
Referenced by mesh_new_client(), and tcp_req_info_add_meshstate().
|
static |
Add a result to the result list.
At the end.
References tcp_req_done_item::buf, tcp_req_info::done_req_list, tcp_req_done_item::len, log_err(), memdup(), tcp_req_done_item::next, tcp_req_info::num_done_req, stream_wait_count, stream_wait_count_lock, stream_wait_max, tcp_req_info_add_result(), VERB_ALGO, and verbose().
Referenced by tcp_req_info_add_result(), and tcp_req_info_send_reply().
| void tcp_req_info_send_reply | ( | struct tcp_req_info * | req | ) |
Send reply on tcp simultaneous answer channel.
May queue it up.
| req | request info structure. |
References adjusted_tcp_timeout(), comm_point::buffer, comm_point_drop_reply(), tcp_req_info::cp, tcp_req_info::in_worker_handle, tcp_req_info::is_reply, comm_point::repinfo, sldns_buffer_begin(), sldns_buffer_clear(), sldns_buffer_flip(), sldns_buffer_limit(), sldns_buffer_write(), tcp_req_info::spool_buffer, comm_point::tcp_byte_count, comm_point::tcp_is_reading, tcp_req_info_add_result(), tcp_req_info_send_reply(), and tcp_req_info_start_write_buf().
Referenced by comm_point_send_reply(), and tcp_req_info_send_reply().
| size_t tcp_req_info_get_stream_buffer_size | ( | void | ) |
get the size of currently used tcp stream wait buffers (in bytes)
References stream_wait_count, stream_wait_count_lock, stream_wait_lock_inited, and tcp_req_info_get_stream_buffer_size().
Referenced by server_stats_compile(), and tcp_req_info_get_stream_buffer_size().
| size_t http2_get_query_buffer_size | ( | void | ) |
get the size of currently used HTTP2 query buffers (in bytes)
References http2_get_query_buffer_size(), http2_query_buffer_count, http2_query_buffer_count_lock, and http2_query_buffer_lock_inited.
Referenced by http2_get_query_buffer_size(), and server_stats_compile().
| size_t http2_get_response_buffer_size | ( | void | ) |
get the size of currently used HTTP2 response buffers (in bytes)
References http2_get_response_buffer_size(), http2_response_buffer_count, http2_response_buffer_count_lock, and http2_response_buffer_lock_inited.
Referenced by http2_get_response_buffer_size(), and server_stats_compile().
| void doq_stream_add_meshstate | ( | struct doq_stream * | stream, |
| struct mesh_area * | mesh, | ||
| struct mesh_state * | m ) |
add mesh state to doq stream
References doq_stream_add_meshstate().
Referenced by doq_stream_add_meshstate(), and mesh_new_client().
| void doq_stream_remove_mesh_state | ( | struct doq_stream * | stream | ) |
remove mesh state from doq stream
References doq_stream_remove_mesh_state().
Referenced by doq_stream_remove_mesh_state(), and mesh_new_client().
| struct rbtree_type * allow_proxy_tree_create | ( | void | ) |
Create allow proxy tree.
References addr_tree_init(), allow_proxy_tree_create(), and log_err().
Referenced by allow_proxy_tree_create(), daemon_init(), doq_client_timer_cb(), and fr_construct_from_config().
|
static |
delete elements from the allow proxy tree
References allow_proxy_node_del().
Referenced by allow_proxy_node_del(), allow_proxy_tree_clear(), and allow_proxy_tree_delete().
|
static |
clear the allow proxy tree
References addr_tree_init(), allow_proxy_node_del(), allow_proxy_tree_clear(), and traverse_postorder().
Referenced by allow_proxy_tree_apply_cfg(), and allow_proxy_tree_clear().
| void allow_proxy_tree_delete | ( | struct rbtree_type * | allow_proxy_tree | ) |
Delete allow proxy tree.
References allow_proxy_node_del(), allow_proxy_tree_delete(), and traverse_postorder().
Referenced by allow_proxy_tree_delete(), daemon_delete(), daemon_init(), doq_client_timer_cb(), and fr_construct_clear().
|
static |
Insert netblock into allow proxy tree.
References addr_tree_node::addr, addr_tree_insert(), addr_tree_node::addrlen, allow_proxy_tree_insert(), rbnode_type::key, log_err(), addr_tree_node::net, netblockstrtoaddr(), addr_tree_node::node, VERB_QUERY, and verbose().
Referenced by allow_proxy_tree_apply_cfg(), and allow_proxy_tree_insert().
| int allow_proxy_tree_apply_cfg | ( | struct rbtree_type * | allow_proxy_tree, |
| struct config_file * | cfg ) |
Apply config to the allow proxy tree.
References addr_tree_init_parents(), config_file::allow_proxy, allow_proxy_tree_apply_cfg(), allow_proxy_tree_clear(), allow_proxy_tree_insert(), config_strlist::next, and config_strlist::str.
Referenced by allow_proxy_tree_apply_cfg(), allow_proxy_tree_apply_cfg(), daemon_fork(), doq_client_timer_cb(), and fr_construct_from_config().
| int allow_proxy_check_incoming_proxy | ( | struct unbound_socket * | ub_sock, |
| struct sockaddr_storage * | addr, | ||
| socklen_t | addrlen ) |
Check incoming proxy address, false is rejected.
References addr_tree_node::addr, addr_tree_lookup(), addr_tree_node::addrlen, allow_proxy_check_incoming_proxy(), unbound_socket::allow_proxy_tree, and rbtree_type::count.
Referenced by allow_proxy_check_incoming_proxy(), and doq_client_timer_cb().
| size_t allow_proxy_tree_get_mem | ( | struct rbtree_type * | allow_proxy_tree | ) |
Get memory usage of allow proxy tree.
References allow_proxy_tree_get_mem(), and rbtree_type::count.
Referenced by allow_proxy_tree_get_mem(), doq_client_timer_cb(), and fr_printmem().
| void allow_proxy_tree_swap_tree | ( | struct rbtree_type * | a, |
| struct rbtree_type * | b ) |
Swap tree for allow proxy tree.
References allow_proxy_tree_swap_tree(), rbtree_type::count, and rbtree_type::root.
Referenced by allow_proxy_tree_swap_tree(), doq_client_timer_cb(), and fr_reload_config().
|
static |
lock on the counter of stream buffer memory
Referenced by listen_desetup_locks(), listen_setup_locks(), tcp_req_info_add_result(), tcp_req_info_clear(), tcp_req_info_get_stream_buffer_size(), and tcp_req_info_pop_done().
|
static |
lock on the counter of HTTP2 query buffer memory
Referenced by http2_get_query_buffer_size(), listen_desetup_locks(), and listen_setup_locks().
|
static |
lock on the counter of HTTP2 response buffer memory
Referenced by http2_get_response_buffer_size(), listen_desetup_locks(), and listen_setup_locks().
|
static |
size (in bytes) of stream wait buffers
Referenced by tcp_req_info_add_result(), tcp_req_info_clear(), tcp_req_info_get_stream_buffer_size(), and tcp_req_info_pop_done().
|
static |
is the lock initialised for stream wait buffers
Referenced by listen_desetup_locks(), listen_setup_locks(), and tcp_req_info_get_stream_buffer_size().
|
static |
size (in bytes) of HTTP2 query buffers
Referenced by http2_get_query_buffer_size().
|
static |
is the lock initialised for HTTP2 query buffers
Referenced by http2_get_query_buffer_size(), listen_desetup_locks(), and listen_setup_locks().
|
static |
size (in bytes) of HTTP2 response buffers
Referenced by http2_get_response_buffer_size().
|
static |
is the lock initialised for HTTP2 response buffers
Referenced by http2_get_response_buffer_size(), listen_desetup_locks(), and listen_setup_locks().