The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Master IO handler. More...
#include <freeradius-devel/io/listen.h>
#include <freeradius-devel/io/master.h>
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/module.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/misc.h>
#include <freeradius-devel/util/syserror.h>
Go to the source code of this file.
Data Structures | |
struct | fr_io_client_s |
Client definitions for master IO. More... | |
struct | fr_io_connection_s |
Track a connection. More... | |
struct | fr_io_pending_packet_t |
A saved packet. More... | |
struct | fr_io_thread_t |
Macros | |
#define | COPY_FIELD(_x) c->_x = parent->_x |
#define | COPY_FIELD(_x) client->radclient->_x = radclient->_x |
#define | DUP_FIELD(_x) do { if (parent->_x) {c->_x = talloc_strdup(c, parent->_x); if (!c->_x) {goto error;}}} while (0) |
#define | DUP_FIELD(_x) client->radclient->_x = talloc_strdup(client->radclient, radclient->_x) |
Typedefs | |
typedef struct fr_io_connection_s | fr_io_connection_t |
Enumerations | |
enum | fr_io_client_state_t { PR_CLIENT_INVALID = 0 , PR_CLIENT_STATIC , PR_CLIENT_NAK , PR_CLIENT_DYNAMIC , PR_CLIENT_CONNECTED , PR_CLIENT_PENDING } |
Client states. More... | |
Functions | |
static int | _client_free (fr_io_client_t *client) |
static int | _client_live_free (fr_io_client_t *client) |
static int8_t | address_cmp (void const *one, void const *two) |
static int8_t | alive_client_cmp (void const *one, void const *two) |
static fr_io_client_t * | client_alloc (TALLOC_CTX *ctx, fr_io_client_state_t state, fr_io_instance_t const *inst, fr_io_thread_t *thread, fr_client_t *radclient, fr_ipaddr_t const *network) |
static void | client_expiry_timer (fr_event_list_t *el, fr_time_t now, void *uctx) |
static int8_t | connection_cmp (void const *one, void const *two) |
static int | connection_free (fr_io_connection_t *connection) |
static uint32_t | connection_hash (void const *ctx) |
static int | count_connections (UNUSED uint8_t const *key, UNUSED size_t keylen, void *data, void *ctx) |
Count the number of connections used by active clients. | |
static fr_io_connection_t * | fr_io_connection_alloc (fr_io_instance_t const *inst, fr_io_thread_t *thread, fr_io_client_t *client, int fd, fr_io_address_t *address, fr_io_connection_t *nak) |
Create a new connection. | |
int | fr_io_listen_free (fr_listen_t *li) |
static fr_io_pending_packet_t * | fr_io_pending_alloc (fr_io_client_t *client, uint8_t const *buffer, size_t packet_len, fr_io_track_t *track, int priority) |
static fr_io_track_t * | fr_io_track_add (fr_io_client_t *client, fr_io_address_t *address, uint8_t const *packet, size_t packet_len, fr_time_t recv_time, bool *is_dup) |
int | fr_master_io_listen (fr_io_instance_t *inst, fr_schedule_t *sc, size_t default_message_size, size_t num_messages) |
fr_trie_t * | fr_master_io_network (TALLOC_CTX *ctx, int af, fr_ipaddr_t *allow, fr_ipaddr_t *deny) |
Create a trie from arrays of allow / deny IP addresses. | |
fr_io_track_t * | fr_master_io_track_alloc (fr_listen_t *li, fr_client_t *radclient, fr_ipaddr_t const *src_ipaddr, int src_port, fr_ipaddr_t const *dst_ipaddr, int dst_port) |
static void | get_inst (fr_listen_t *li, fr_io_instance_t const **inst, fr_io_thread_t **thread, fr_io_connection_t **connection, fr_listen_t **child) |
static int | mod_close (fr_listen_t *li) |
Close the socket. | |
static void | mod_event_list_set (fr_listen_t *li, fr_event_list_t *el, void *nr) |
Set the event list for a new socket. | |
static int | mod_inject (fr_listen_t *li, uint8_t const *buffer, size_t buffer_len, fr_time_t recv_time) |
Inject a packet to a connection. | |
static int | mod_instantiate (module_inst_ctx_t const *mctx) |
static char const * | mod_name (fr_listen_t *li) |
static int | mod_open (fr_listen_t *li) |
Open a new listener. | |
static ssize_t | mod_read (fr_listen_t *li, void **packet_ctx, fr_time_t *recv_time_p, uint8_t *buffer, size_t buffer_len, size_t *leftover) |
Implement 99% of the read routines. | |
static ssize_t | mod_write (fr_listen_t *li, void *packet_ctx, fr_time_t request_time, uint8_t *buffer, size_t buffer_len, size_t written) |
static void | packet_expiry_timer (fr_event_list_t *el, fr_time_t now, void *uctx) |
static int8_t | pending_client_cmp (void const *one, void const *two) |
static int | pending_free (fr_io_pending_packet_t *pending) |
static int8_t | pending_packet_cmp (void const *one, void const *two) |
static fr_io_pending_packet_t * | pending_packet_pop (fr_io_thread_t *thread) |
static fr_client_t * | radclient_alloc (TALLOC_CTX *ctx, int ipproto, fr_io_address_t *address) |
static fr_client_t * | radclient_clone (TALLOC_CTX *ctx, fr_client_t const *parent) |
static int8_t | track_cmp (void const *one, void const *two) |
static int8_t | track_connected_cmp (void const *one, void const *two) |
static int | track_dedup_free (fr_io_track_t *track) |
static int | track_free (fr_io_track_t *track) |
Variables | |
fr_app_io_t | fr_master_app_io |
static fr_event_update_t | pause_read [] |
static fr_event_update_t | resume_read [] |
Master IO handler.
Definition in file master.c.
struct fr_io_client_s |
Data Fields | ||
---|---|---|
fr_hash_table_t * | addresses | list of src/dst addresses used by this client |
fr_heap_index_t | alive_id | for all clients |
fr_io_connection_t * | connection | parent connection |
fr_event_timer_t const * | ev | when we clean up the client |
fr_hash_table_t * | ht | for tracking connected sockets |
bool | in_trie | is the client in the trie? |
fr_io_instance_t const * | inst | parent instance for master IO handler |
pthread_mutex_t | mutex | for parent / child signaling |
fr_ipaddr_t | network | network for dynamic clients |
int | packets | number of packets using this client |
fr_heap_t * | pending | pending packets for this client |
fr_heap_index_t | pending_id | for pending clients |
fr_client_t * | radclient | old-style definition of this client |
bool | ready_to_delete | are we ready to delete this client? |
fr_ipaddr_t | src_ipaddr | packets come from this address |
fr_io_client_state_t | state | state of this client |
fr_rb_tree_t * | table | tracking table for packets |
fr_io_thread_t * | thread | |
bool | use_connected | does this client allow connected sub-sockets? |
struct fr_io_connection_s |
Track a connection.
This structure contains information about the connection, a pointer to the library instance so that we can clean up on exit, and the listener.
It also points to a client structure which is for this connection, and only this connection.
Finally, a pointer to the parent client, so that the child can tell the parent it's alive, and the parent can push packets to the child.
Data Fields | ||
---|---|---|
fr_io_address_t * | address | full information about the connection. |
fr_listen_t * | child | child listener (app_io) for this socket |
fr_io_client_t * | client | our local client (pending or connected). |
bool | dead | roundabout way to get the network side to close a socket |
fr_event_list_t * | el | event list for this connection |
bool | in_parent_hash | for tracking thread issues |
fr_listen_t * | listen | master listener for this socket |
module_instance_t * | mi | for submodule |
char const * | name | taken from proto_FOO_TRANSPORT |
fr_network_t * | nr | network for this connection |
int | packets | number of packets using this connection |
fr_io_client_t * | parent | points to the parent client. |
bool | paused | event filter doesn't like resuming something that isn't paused |
struct fr_io_pending_packet_t |
Data Fields | ||
---|---|---|
uint8_t * | buffer | |
size_t | buffer_len | |
fr_heap_index_t | heap_id | |
uint32_t | priority | |
fr_time_t | recv_time | |
fr_io_track_t * | track |
struct fr_io_thread_t |
Data Fields | ||
---|---|---|
fr_heap_t * | alive_clients | heap of active clients |
fr_listen_t * | child | The child (app_io) IO path. |
uint64_t | client_id | Unique client identifier. |
fr_event_list_t * | el | event list, for the master socket. |
fr_listen_t * | listen | The master IO path. |
fr_network_t * | nr | network for the master socket |
uint32_t | num_connections | number of dynamic connections |
uint32_t | num_pending_packets | number of pending packets |
fr_heap_t * | pending_clients | heap of pending clients |
fr_schedule_t * | sc | the scheduler |
fr_trie_t * | trie | trie of clients |
#define COPY_FIELD | ( | _x | ) | client->radclient->_x = radclient->_x |
#define DUP_FIELD | ( | _x | ) | do { if (parent->_x) {c->_x = talloc_strdup(c, parent->_x); if (!c->_x) {goto error;}}} while (0) |
#define DUP_FIELD | ( | _x | ) | client->radclient->_x = talloc_strdup(client->radclient, radclient->_x) |
typedef struct fr_io_connection_s fr_io_connection_t |
enum fr_io_client_state_t |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Count the number of connections used by active clients.
Unfortunately, we also count NAK'd connections, too, even if they are closed. The alternative is to walk through all connections for each client, which would be a long time.
Definition at line 436 of file master.c.
|
static |
int fr_io_listen_free | ( | fr_listen_t * | li | ) |
|
static |
|
static |
int fr_master_io_listen | ( | fr_io_instance_t * | inst, |
fr_schedule_t * | sc, | ||
size_t | default_message_size, | ||
size_t | num_messages | ||
) |
fr_trie_t * fr_master_io_network | ( | TALLOC_CTX * | ctx, |
int | af, | ||
fr_ipaddr_t * | allow, | ||
fr_ipaddr_t * | deny | ||
) |
Create a trie from arrays of allow / deny IP addresses.
ctx | the talloc ctx |
af | the address family to allow |
allow | the array of IPs / networks to allow. MUST be talloc'd |
deny | the array of IPs / networks to deny. MAY be NULL, MUST be talloc'd |
Definition at line 2767 of file master.c.
fr_io_track_t * fr_master_io_track_alloc | ( | fr_listen_t * | li, |
fr_client_t * | radclient, | ||
fr_ipaddr_t const * | src_ipaddr, | ||
int | src_port, | ||
fr_ipaddr_t const * | dst_ipaddr, | ||
int | dst_port | ||
) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
fr_app_io_t fr_master_app_io |
|
static |
|
static |