tcp_conn_limit.h File Reference

This file keeps track of the limit on the number of TCP connections each client makes the server. More...

#include "util/storage/dnstree.h"
#include "util/locks.h"

Data Structures

struct  tcl_list
 TCP connection limit storage structure. More...
 
struct  tcl_addr
 An address span with connection limit information. More...
 

Functions

struct tcl_listtcl_list_create (void)
 Create TCP connection limit structure.
 
void tcl_list_delete (struct tcl_list *tcl)
 Delete TCP connection limit structure.
 
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_addrtcl_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.
 

Detailed Description

This file keeps track of the limit on the number of TCP connections each client makes the server.

Function Documentation

◆ tcl_list_create()

struct tcl_list * tcl_list_create ( void  )

Create TCP connection limit structure.

Returns
new structure or NULL on error.

References tcl_list::region, regional_create(), and tcl_list_delete().

Referenced by daemon_init().

◆ tcl_list_delete()

void tcl_list_delete ( struct tcl_list tcl)

Delete TCP connection limit structure.

Parameters
tclto delete.

References tcl_list::region, regional_destroy(), traverse_postorder(), and tcl_list::tree.

Referenced by daemon_delete(), daemon_init(), and tcl_list_create().

◆ tcl_list_apply_cfg()

int tcl_list_apply_cfg ( struct tcl_list tcl,
struct config_file cfg 
)

Process TCP connection limit config.

Parameters
tclwhere to store.
cfgconfig options.
Returns
0 on error.

References addr_tree_init(), addr_tree_init_parents(), read_tcl_list(), tcl_list::region, regional_free_all(), and tcl_list::tree.

Referenced by daemon_fork().

◆ tcl_new_connection()

int tcl_new_connection ( struct tcl_addr tcl)

Increment TCP connection count if found, provided the count was below the limit.

Parameters
tclstructure for tcl storage, or NULL.
Returns
: 0 if limit reached, 1 if tcl was NULL or limit not reached.

References tcl_addr::count, tcl_addr::limit, and tcl_addr::lock.

Referenced by comm_point_perform_accept().

◆ tcl_close_connection()

void tcl_close_connection ( struct tcl_addr tcl)

Decrement TCP connection count if found.

Parameters
tclstructure for tcl storage, or NULL.

References tcl_addr::count, tcl_addr::lock, and log_assert.

Referenced by comm_point_close().

◆ tcl_addr_lookup()

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.

Parameters
tclstructure for address storage.
addraddress to check
addrlenlength of addr.
Returns
: tcl structure from this address.

References addr_tree_lookup(), and tcl_list::tree.

Referenced by comm_point_perform_accept().

◆ tcl_list_get_mem()

size_t tcl_list_get_mem ( struct tcl_list tcl)

Get memory used by TCP connection limit structure.

Parameters
tclstructure for address storage.
Returns
bytes in use.

References tcl_list::region, and regional_get_mem().