|
unbound 0.1
|
This file helps the server discard excess TCP connections. More...
#include "config.h"#include "util/regional.h"#include "util/log.h"#include "util/config_file.h"#include "util/net_help.h"#include "util/tcp_conn_limit.h"#include "services/localzone.h"#include "sldns/str2wire.h"Functions | |
| struct tcl_list * | tcl_list_create (void) |
| Create TCP connection limit structure. | |
| static void | tcl_list_free_node (rbnode_type *node, void *ATTR_UNUSED(arg)) |
| void | tcl_list_delete (struct tcl_list *tcl) |
| Delete TCP connection limit structure. | |
| static struct tcl_addr * | tcl_list_insert (struct tcl_list *tcl, struct sockaddr_storage *addr, socklen_t addrlen, int net, uint32_t limit, int complain_duplicates) |
| insert new address into tcl_list structure | |
| static int | tcl_list_str_cfg (struct tcl_list *tcl, const char *str, const char *s2, int complain_duplicates) |
| apply tcl_list string | |
| static int | read_tcl_list (struct tcl_list *tcl, struct config_file *cfg) |
| read tcl_list config | |
| int | tcl_list_apply_cfg (struct tcl_list *tcl, struct config_file *cfg) |
| Process TCP connection limit config. | |
| int | tcl_new_connection (struct tcl_addr *tcl) |
| Increment TCP connection count if found, provided the count was below the limit. | |
| void | tcl_close_connection (struct tcl_addr *tcl) |
| Decrement TCP connection count if found. | |
| struct tcl_addr * | tcl_addr_lookup (struct tcl_list *tcl, struct sockaddr_storage *addr, socklen_t addrlen) |
| Lookup address to see its TCP connection limit structure. | |
| size_t | tcl_list_get_mem (struct tcl_list *tcl) |
| Get memory used by TCP connection limit structure. | |
| void | tcl_list_swap_tree (struct tcl_list *tcl, struct tcl_list *data) |
| Swap internal tree with preallocated entries. | |
This file helps the server discard excess TCP connections.
| struct tcl_list * tcl_list_create | ( | void | ) |
Create TCP connection limit structure.
References tcl_list::region, regional_create(), tcl_list_create(), and tcl_list_delete().
Referenced by daemon_init(), fr_construct_from_config(), and tcl_list_create().
| void tcl_list_delete | ( | struct tcl_list * | tcl | ) |
Delete TCP connection limit structure.
| tcl | to delete. |
References tcl_list::region, regional_destroy(), tcl_list_delete(), traverse_postorder(), and tcl_list::tree.
Referenced by daemon_delete(), daemon_init(), fr_construct_clear(), tcl_list_create(), and tcl_list_delete().
|
static |
insert new address into tcl_list structure
References addr_tree_insert(), tcl_addr::limit, addr_tree_node::node, tcl_addr::node, tcl_list::region, regional_alloc_zero(), tcl_list_insert(), tcl_list::tree, VERB_QUERY, and verbose().
Referenced by tcl_list_insert(), and tcl_list_str_cfg().
|
static |
apply tcl_list string
References log_err(), netblockstrtoaddr(), tcl_list_insert(), and tcl_list_str_cfg().
Referenced by read_tcl_list(), and tcl_list_str_cfg().
|
static |
read tcl_list config
References log_assert, config_str2list::next, read_tcl_list(), config_str2list::str, config_str2list::str2, tcl_list_str_cfg(), and config_file::tcp_connection_limits.
Referenced by read_tcl_list(), and tcl_list_apply_cfg().
| int tcl_list_apply_cfg | ( | struct tcl_list * | tcl, |
| struct config_file * | cfg ) |
Process TCP connection limit config.
| tcl | where to store. |
| cfg | config options. |
References addr_tree_init(), addr_tree_init_parents(), read_tcl_list(), tcl_list::region, regional_free_all(), tcl_list_apply_cfg(), and tcl_list::tree.
Referenced by daemon_fork(), fr_construct_from_config(), and tcl_list_apply_cfg().
| int tcl_new_connection | ( | struct tcl_addr * | tcl | ) |
Increment TCP connection count if found, provided the count was below the limit.
| tcl | structure for tcl storage, or NULL. |
References tcl_addr::count, tcl_addr::limit, tcl_addr::lock, and tcl_new_connection().
Referenced by comm_point_perform_accept(), and tcl_new_connection().
| void tcl_close_connection | ( | struct tcl_addr * | tcl | ) |
Decrement TCP connection count if found.
| tcl | structure for tcl storage, or NULL. |
References tcl_addr::count, tcl_addr::lock, log_assert, and tcl_close_connection().
Referenced by comm_point_close(), and tcl_close_connection().
| struct tcl_addr * tcl_addr_lookup | ( | struct tcl_list * | tcl, |
| struct sockaddr_storage * | addr, | ||
| socklen_t | addrlen ) |
Lookup address to see its TCP connection limit structure.
| tcl | structure for address storage. |
| addr | address to check |
| addrlen | length of addr. |
References addr_tree_lookup(), tcl_addr_lookup(), and tcl_list::tree.
Referenced by comm_point_perform_accept(), and tcl_addr_lookup().
| size_t tcl_list_get_mem | ( | struct tcl_list * | tcl | ) |
Get memory used by TCP connection limit structure.
| tcl | structure for address storage. |
References tcl_list::region, regional_get_mem(), and tcl_list_get_mem().
Referenced by fr_printmem(), and tcl_list_get_mem().
Swap internal tree with preallocated entries.
Caller should manage tcl_addr item locks.
| tcl | the tcp connection list structure. |
| data | the data structure used to take elements from. This contains the old elements on return. |
References regional::data, tcl_list::region, tcl_list_swap_tree(), and tcl_list::tree.
Referenced by fr_reload_config(), and tcl_list_swap_tree().