The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Functions | Variables
network.c File Reference
#include <freeradius-devel/util/event.h>
#include <freeradius-devel/util/misc.h>
#include <freeradius-devel/util/rand.h>
#include <freeradius-devel/util/rb.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/atexit.h>
#include <freeradius-devel/util/talloc.h>
#include <freeradius-devel/io/channel.h>
#include <freeradius-devel/io/control.h>
#include <freeradius-devel/io/listen.h>
#include <freeradius-devel/io/network.h>
#include <freeradius-devel/io/queue.h>
#include <freeradius-devel/io/ring_buffer.h>
#include <freeradius-devel/io/worker.h>
+ Include dependency graph for network.c:

Go to the source code of this file.

Data Structures

struct  fr_network_inject_t
 
struct  fr_network_s
 
struct  fr_network_socket_t
 
struct  fr_network_worker_t
 Associate a worker thread with a network thread. More...
 

Macros

#define IALPHA   (8)
 
#define LOG_DST   nr->log
 
#define LOG_PREFIX   nr->name
 
#define MAX_WORKERS   64
 
#define OUTSTANDING(_x)   ((_x)->stats.in - (_x)->stats.out)
 
#define RTT(_old, _new)   fr_time_delta_wrap((fr_time_delta_unwrap(_new) + (fr_time_delta_unwrap(_old) * (IALPHA - 1))) / IALPHA)
 

Functions

static int _fr_network_free (fr_network_t *nr)
 Free any resources associated with a network thread. More...
 
static int _fr_network_rb_free (void *arg)
 
static int _network_socket_free (fr_network_socket_t *s)
 
static void _signal_pipe_read (UNUSED fr_event_list_t *el, int fd, UNUSED int flags, void *uctx)
 Read handler for signal pipe. More...
 
static int cmd_socket_list (FILE *fp, UNUSED FILE *fp_err, void *ctx, UNUSED fr_cmd_info_t const *info)
 
static int cmd_stats_self (FILE *fp, UNUSED FILE *fp_err, void *ctx, UNUSED fr_cmd_info_t const *info)
 
static int cmd_stats_socket (FILE *fp, FILE *fp_err, void *ctx, fr_cmd_info_t const *info)
 
void fr_network (fr_network_t *nr)
 The main network worker function. More...
 
static void fr_network_channel_callback (void *ctx, void const *data, size_t data_size, fr_time_t now)
 Handle a network control message callback for a channel. More...
 
fr_network_tfr_network_create (TALLOC_CTX *ctx, fr_event_list_t *el, char const *name, fr_log_t const *logger, fr_log_lvl_t lvl, fr_network_config_t const *config)
 Create a network. More...
 
int fr_network_destroy (fr_network_t *nr)
 Stop a network thread in an orderly way. More...
 
int fr_network_directory_add (fr_network_t *nr, fr_listen_t *li)
 Add a "watch directory" call to a network. More...
 
static void fr_network_directory_callback (void *ctx, void const *data, size_t data_size, UNUSED fr_time_t now)
 Handle a network control message callback for a new "watch directory". More...
 
static void fr_network_error (UNUSED fr_event_list_t *el, UNUSED int sockfd, int flags, int fd_errno, void *ctx)
 Handle errors for a socket. More...
 
int fr_network_exit (fr_network_t *nr)
 Signal a network thread to exit. More...
 
static void fr_network_inject_callback (void *ctx, void const *data, size_t data_size, UNUSED fr_time_t now)
 Handle a network control message callback for a packet sent to a socket. More...
 
int fr_network_listen_add (fr_network_t *nr, fr_listen_t *li)
 Add a fr_listen_t to a network. More...
 
static int fr_network_listen_add_self (fr_network_t *nr, fr_listen_t *listen)
 
static void fr_network_listen_callback (void *ctx, void const *data, size_t data_size, UNUSED fr_time_t now)
 Handle a network control message callback for a new listener. More...
 
int fr_network_listen_delete (fr_network_t *nr, fr_listen_t *li)
 Delete a socket from a network. More...
 
int fr_network_listen_inject (fr_network_t *nr, fr_listen_t *li, uint8_t const *packet, size_t packet_len, fr_time_t recv_time)
 Inject a packet for a listener to read. More...
 
size_t fr_network_listen_outstanding (fr_network_t *nr, fr_listen_t *li)
 Get the number of outstanding packets. More...
 
void fr_network_listen_read (fr_network_t *nr, fr_listen_t *li)
 Signal the network to read from a listener. More...
 
int fr_network_listen_send_packet (fr_network_t *nr, fr_listen_t *parent, fr_listen_t *li, const uint8_t *buffer, size_t buflen, fr_time_t recv_time, void *packet_ctx)
 Send a packet to the worker. More...
 
void fr_network_listen_write (fr_network_t *nr, fr_listen_t *li, uint8_t const *packet, size_t packet_len, void *packet_ctx, fr_time_t request_time)
 Inject a packet for a listener to write. More...
 
static void fr_network_post_event (fr_event_list_t *el, fr_time_t now, void *uctx)
 
static void fr_network_post_event (UNUSED fr_event_list_t *el, UNUSED fr_time_t now, void *uctx)
 Handle replies after all FD and timer events have been serviced. More...
 
static int fr_network_pre_event (fr_time_t now, fr_time_delta_t wake, void *uctx)
 
static int fr_network_pre_event (UNUSED fr_time_t now, UNUSED fr_time_delta_t wake, void *uctx)
 Run the event loop 'pre' callback. More...
 
static fr_ring_buffer_tfr_network_rb_init (void)
 Initialise thread local storage. More...
 
static void fr_network_read (UNUSED fr_event_list_t *el, int sockfd, UNUSED int flags, void *ctx)
 Read a packet from the network. More...
 
static void fr_network_recv_reply (void *ctx, fr_channel_t *ch, fr_channel_data_t *cd)
 Callback which handles a message being received on the network side. More...
 
static int fr_network_send_request (fr_network_t *nr, fr_channel_data_t *cd)
 Send a message on the "best" channel. More...
 
int fr_network_sendto_worker (fr_network_t *nr, fr_listen_t *li, void *packet_ctx, uint8_t const *data, size_t data_len, fr_time_t recv_time)
 
static void fr_network_socket_dead (fr_network_t *nr, fr_network_socket_t *s)
 
int fr_network_stats (fr_network_t const *nr, int num, uint64_t *stats)
 
void fr_network_stats_log (fr_network_t const *nr, fr_log_t const *log)
 
static void fr_network_suspend (fr_network_t *nr)
 
static void fr_network_unsuspend (fr_network_t *nr)
 
static void fr_network_vnode_extend (UNUSED fr_event_list_t *el, int sockfd, int fflags, void *ctx)
 Get a notification that a vnode changed. More...
 
int fr_network_worker_add (fr_network_t *nr, fr_worker_t *worker)
 Add a worker to a network in a different thread. More...
 
void fr_network_worker_add_self (fr_network_t *nr, fr_worker_t *worker)
 Add a worker to a network in the same thread. More...
 
static void fr_network_worker_started_callback (void *ctx, void const *data, size_t data_size, fr_time_t now)
 
static void fr_network_worker_started_callback (void *ctx, void const *data, size_t data_size, UNUSED fr_time_t now)
 Handle a network control message callback for a new worker. More...
 
static void fr_network_write (UNUSED fr_event_list_t *el, UNUSED int sockfd, UNUSED int flags, void *ctx)
 Write packets to the network. More...
 
static bool is_network_thread (fr_network_t const *nr)
 
static int8_t reply_cmp (void const *one, void const *two)
 
static int8_t socket_listen_cmp (void const *one, void const *two)
 
static int8_t socket_num_cmp (void const *one, void const *two)
 
static int8_t waiting_cmp (void const *one, void const *two)
 

Variables

fr_cmd_table_t cmd_network_table []
 
static _Thread_local fr_ring_buffer_tfr_network_rb
 
static fr_event_update_t const pause_write []
 
static fr_event_update_t const resume_write []
 

Data Structure Documentation

◆ fr_network_inject_t

struct fr_network_inject_t

Definition at line 51 of file network.c.

+ Collaboration diagram for fr_network_inject_t:
Data Fields
fr_listen_t * listen
uint8_t * packet
size_t packet_len
fr_time_t recv_time

◆ fr_network_s

struct fr_network_s

Definition at line 112 of file network.c.

+ Collaboration diagram for fr_network_s:
Data Fields
fr_atomic_queue_t * aq_control atomic queue for control messages sent to me
fr_network_config_t config configuration
fr_control_t * control the control plane
fr_event_list_t * el our event list
bool exiting are we exiting?
fr_log_t const * log log destination
fr_log_lvl_t lvl debug log level
int max_workers maximum number of allowed workers
char const * name Network ID for logging.
int num_blocked number of blocked workers
int num_pending_workers number of workers we're waiting to start.
int num_sockets actually a counter...
int num_workers number of active workers
fr_ring_buffer_t * rb ring buffer for my control-plane messages
fr_heap_t * replies replies from the worker, ordered by priority / origin time
int signal_pipe[2] Pipe for signalling the worker in an orderly way.

This is more deterministic than using async signals.

fr_rb_tree_t * sockets list of sockets we're managing, ordered by the listener
fr_rb_tree_t * sockets_by_num ordered by number;
fr_io_stats_t stats
bool suspended whether or not we're suspended.
pthread_t thread_id for self
fr_network_worker_t * workers[MAX_WORKERS] each worker

◆ fr_network_socket_t

struct fr_network_socket_t

Definition at line 73 of file network.c.

+ Collaboration diagram for fr_network_socket_t:
Data Fields
bool blocked is it blocked?
fr_channel_data_t * cd cached in case of allocation & read error
bool dead is it dead?
fr_event_filter_t filter what type of filter it is
fr_heap_index_t heap_id for the sockets_by_num heap
size_t leftover leftover data from a previous read
fr_listen_t * listen I/O ctx and functions.
fr_rb_node_t listen_node rbtree node for looking up by listener.
fr_message_set_t * ms message buffers for this socket.
fr_network_t * nr O(N) issues in talloc.
fr_rb_node_t num_node rbtree node for looking up by number.
int number unique ID
unsigned int outstanding number of outstanding packets sent to the worker
fr_channel_data_t * pending the currently pending partial packet
fr_io_stats_t stats
fr_heap_t * waiting packets waiting to be written
size_t written however much we did in a partial write

◆ fr_network_worker_t

struct fr_network_worker_t

Associate a worker thread with a network thread.

Definition at line 61 of file network.c.

+ Collaboration diagram for fr_network_worker_t:
Data Fields
bool blocked is this worker blocked?
fr_channel_t * channel channel to the worker
fr_time_delta_t cpu_time how much CPU time this worker has spent
fr_heap_index_t heap_id workers are in a heap
fr_time_delta_t predicted predicted processing time for one packet
fr_io_stats_t stats
fr_worker_t * worker worker pointer

Macro Definition Documentation

◆ IALPHA

#define IALPHA   (8)

Definition at line 477 of file network.c.

◆ LOG_DST

#define LOG_DST   nr->log

Definition at line 29 of file network.c.

◆ LOG_PREFIX

#define LOG_PREFIX   nr->name

Definition at line 27 of file network.c.

◆ MAX_WORKERS

#define MAX_WORKERS   64

Definition at line 47 of file network.c.

◆ OUTSTANDING

#define OUTSTANDING (   _x)    ((_x)->stats.in - (_x)->stats.out)

Definition at line 595 of file network.c.

◆ RTT

#define RTT (   _old,
  _new 
)    fr_time_delta_wrap((fr_time_delta_unwrap(_new) + (fr_time_delta_unwrap(_old) * (IALPHA - 1))) / IALPHA)

Definition at line 478 of file network.c.

Function Documentation

◆ _fr_network_free()

static int _fr_network_free ( fr_network_t nr)
static

Free any resources associated with a network thread.

Definition at line 1862 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _fr_network_rb_free()

static int _fr_network_rb_free ( void *  arg)
static

Definition at line 197 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _network_socket_free()

static int _network_socket_free ( fr_network_socket_t s)
static

Definition at line 1263 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _signal_pipe_read()

static void _signal_pipe_read ( UNUSED fr_event_list_t el,
int  fd,
UNUSED int  flags,
void *  uctx 
)
static

Read handler for signal pipe.

Definition at line 1764 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cmd_socket_list()

static int cmd_socket_list ( FILE *  fp,
UNUSED FILE *  fp_err,
void *  ctx,
UNUSED fr_cmd_info_t const *  info 
)
static

Definition at line 2050 of file network.c.

+ Here is the call graph for this function:

◆ cmd_stats_self()

static int cmd_stats_self ( FILE *  fp,
UNUSED FILE *  fp_err,
void *  ctx,
UNUSED fr_cmd_info_t const *  info 
)
static

Definition at line 2037 of file network.c.

+ Here is the call graph for this function:

◆ cmd_stats_socket()

static int cmd_stats_socket ( FILE *  fp,
FILE *  fp_err,
void *  ctx,
fr_cmd_info_t const *  info 
)
static

Definition at line 2070 of file network.c.

+ Here is the call graph for this function:

◆ fr_network()

void fr_network ( fr_network_t nr)

The main network worker function.

Parameters
[in]nrthe network data structure to run.

Definition at line 1794 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_channel_callback()

static void fr_network_channel_callback ( void *  ctx,
void const *  data,
size_t  data_size,
fr_time_t  now 
)
static

Handle a network control message callback for a channel.

This is called from the event loop when we get a notification from the event signalling pipe.

Parameters
[in]ctxthe network
[in]datathe message
[in]data_sizesize of the data
[in]nowthe current time

Definition at line 534 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_create()

fr_network_t* fr_network_create ( TALLOC_CTX *  ctx,
fr_event_list_t el,
char const *  name,
fr_log_t const *  logger,
fr_log_lvl_t  lvl,
fr_network_config_t const *  config 
)

Create a network.

Parameters
[in]ctxThe talloc ctx
[in]elThe event list
[in]nameNetworker identifier.
[in]loggerThe destination for all logging messages
[in]lvlLog level
[in]configconfiguration structure.
Returns
  • NULL on error
  • fr_network_t on success

Definition at line 1882 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_destroy()

int fr_network_destroy ( fr_network_t nr)

Stop a network thread in an orderly way.

Parameters
[in]nrthe network to stop

Definition at line 1681 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_directory_add()

int fr_network_directory_add ( fr_network_t nr,
fr_listen_t li 
)

Add a "watch directory" call to a network.

Parameters
nrthe network
lithe listener

Definition at line 278 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_directory_callback()

static void fr_network_directory_callback ( void *  ctx,
void const *  data,
size_t  data_size,
UNUSED fr_time_t  now 
)
static

Handle a network control message callback for a new "watch directory".

Parameters
[in]ctxthe network
[in]datathe message
[in]data_sizesize of the data
[in]nowthe current time

Definition at line 1434 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_error()

static void fr_network_error ( UNUSED fr_event_list_t el,
UNUSED int  sockfd,
int  flags,
int  fd_errno,
void *  ctx 
)
static

Handle errors for a socket.

Parameters
[in]elthe event list
[in]sockfdthe socket which has a fatal error.
[in]flagsreturned by kevent.
[in]fd_errnoreturned by kevent.
[in]ctxthe network socket context.

Definition at line 1100 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_exit()

int fr_network_exit ( fr_network_t nr)

Signal a network thread to exit.

Note
Request to exit will be processed asynchronously.
Parameters
[in]nrthe network data structure to manage
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 1849 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_inject_callback()

static void fr_network_inject_callback ( void *  ctx,
void const *  data,
size_t  data_size,
UNUSED fr_time_t  now 
)
static

Handle a network control message callback for a packet sent to a socket.

Parameters
[in]ctxthe network
[in]datathe message
[in]data_sizesize of the data
[in]nowthe current time

Definition at line 1555 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_listen_add()

int fr_network_listen_add ( fr_network_t nr,
fr_listen_t li 
)

Add a fr_listen_t to a network.

Parameters
nrthe network
lithe listener

Definition at line 236 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_listen_add_self()

static int fr_network_listen_add_self ( fr_network_t nr,
fr_listen_t listen 
)
static

Definition at line 1321 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_listen_callback()

static void fr_network_listen_callback ( void *  ctx,
void const *  data,
size_t  data_size,
UNUSED fr_time_t  now 
)
static

Handle a network control message callback for a new listener.

Parameters
[in]ctxthe network
[in]datathe message
[in]data_sizesize of the data
[in]nowthe current time

Definition at line 1307 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_listen_delete()

int fr_network_listen_delete ( fr_network_t nr,
fr_listen_t li 
)

Delete a socket from a network.

MUST be called only by the listener itself!.

Parameters
nrthe network
lithe listener

Definition at line 259 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_listen_inject()

int fr_network_listen_inject ( fr_network_t nr,
fr_listen_t li,
uint8_t const *  packet,
size_t  packet_len,
fr_time_t  recv_time 
)

Inject a packet for a listener to read.

Parameters
nrthe network
lithe listener where the packet is being injected
packetthe packet to be injected
packet_lenthe length of the packet
recv_timewhen the packet was received.
Returns
  • <0 on error
  • 0 on success

Definition at line 398 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_listen_outstanding()

size_t fr_network_listen_outstanding ( fr_network_t nr,
fr_listen_t li 
)

Get the number of outstanding packets.

Parameters
nrthe network
lithe listener that the packet was "read" from
Returns
  • <0 on error
  • the number of outstanding packets

Definition at line 805 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_listen_read()

void fr_network_listen_read ( fr_network_t nr,
fr_listen_t li 
)

Signal the network to read from a listener.

Parameters
nrthe network
lithe listener to read from

Definition at line 324 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_listen_send_packet()

int fr_network_listen_send_packet ( fr_network_t nr,
fr_listen_t parent,
fr_listen_t li,
const uint8_t buffer,
size_t  buflen,
fr_time_t  recv_time,
void *  packet_ctx 
)

Send a packet to the worker.

MUST only be called from the network thread.

Parameters
nrthe network
parentthe parent listener
lithe listener that the packet was "read" from. Can be "parent"
bufferthe packet to send
buflensize of the packet to send
recv_timeof the packet
packet_ctxfor the packet
Returns
  • <0 on error
  • 0 on success

Definition at line 763 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_listen_write()

void fr_network_listen_write ( fr_network_t nr,
fr_listen_t li,
uint8_t const *  packet,
size_t  packet_len,
void *  packet_ctx,
fr_time_t  request_time 
)

Inject a packet for a listener to write.

Parameters
nrthe network
lithe listener where the packet is being injected
packetthe packet to be written
packet_lenthe length of the packet
packet_ctxThe packet context to write
request_timewhen the packet was received.

Definition at line 350 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_post_event() [1/2]

static void fr_network_post_event ( fr_event_list_t el,
fr_time_t  now,
void *  uctx 
)
static
+ Here is the caller graph for this function:

◆ fr_network_post_event() [2/2]

static void fr_network_post_event ( UNUSED fr_event_list_t el,
UNUSED fr_time_t  now,
void *  uctx 
)
static

Handle replies after all FD and timer events have been serviced.

Parameters
elthe event loop
nowthe current time (mostly)
uctxthe fr_network_t

Definition at line 1606 of file network.c.

+ Here is the call graph for this function:

◆ fr_network_pre_event() [1/2]

static int fr_network_pre_event ( fr_time_t  now,
fr_time_delta_t  wake,
void *  uctx 
)
static
+ Here is the caller graph for this function:

◆ fr_network_pre_event() [2/2]

static int fr_network_pre_event ( UNUSED fr_time_t  now,
UNUSED fr_time_delta_t  wake,
void *  uctx 
)
static

Run the event loop 'pre' callback.

This function MUST DO NO WORK. All it does is check if there's work, and tell the event code to return to the main loop if there's work to do.

Parameters
[in]nowthe current time.
[in]wakethe time when the event loop will wake up.
[in]uctxthe network

Definition at line 1591 of file network.c.

+ Here is the call graph for this function:

◆ fr_network_rb_init()

static fr_ring_buffer_t* fr_network_rb_init ( void  )
inlinestatic

Initialise thread local storage.

Returns
fr_ring_buffer_t for messages

Definition at line 206 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_read()

static void fr_network_read ( UNUSED fr_event_list_t el,
int  sockfd,
UNUSED int  flags,
void *  ctx 
)
static

Read a packet from the network.

Parameters
[in]elthe event list.
[in]sockfdthe socket which is ready to read.
[in]flagsfrom kevent.
[in]ctxthe network socket context.

Definition at line 862 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_recv_reply()

static void fr_network_recv_reply ( void *  ctx,
fr_channel_t ch,
fr_channel_data_t cd 
)
static

Callback which handles a message being received on the network side.

Parameters
[in]ctxthe network
[in]chthe channel that the message is on.
[in]cdthe message (if any) to start with

Definition at line 486 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_send_request()

static int fr_network_send_request ( fr_network_t nr,
fr_channel_data_t cd 
)
static

Send a message on the "best" channel.

Parameters
nrthe network
cdthe message we've received

Definition at line 602 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_sendto_worker()

int fr_network_sendto_worker ( fr_network_t nr,
fr_listen_t li,
void *  packet_ctx,
uint8_t const *  data,
size_t  data_len,
fr_time_t  recv_time 
)

Definition at line 1030 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_socket_dead()

static void fr_network_socket_dead ( fr_network_t nr,
fr_network_socket_t s 
)
static

Definition at line 821 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_stats()

int fr_network_stats ( fr_network_t const *  nr,
int  num,
uint64_t *  stats 
)

Definition at line 2007 of file network.c.

◆ fr_network_stats_log()

void fr_network_stats_log ( fr_network_t const *  nr,
fr_log_t const *  log 
)

Definition at line 2023 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_suspend()

static void fr_network_suspend ( fr_network_t nr)
static

Definition at line 439 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_unsuspend()

static void fr_network_unsuspend ( fr_network_t nr)
static

Definition at line 458 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_vnode_extend()

static void fr_network_vnode_extend ( UNUSED fr_event_list_t el,
int  sockfd,
int  fflags,
void *  ctx 
)
static

Get a notification that a vnode changed.

Parameters
[in]elthe event list.
[in]sockfdthe socket which is ready to read.
[in]fflagsfrom kevent.
[in]ctxthe network socket context.

Definition at line 1075 of file network.c.

+ Here is the caller graph for this function:

◆ fr_network_worker_add()

int fr_network_worker_add ( fr_network_t nr,
fr_worker_t worker 
)

Add a worker to a network in a different thread.

Parameters
nrthe network
workerthe worker

Definition at line 293 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_worker_add_self()

void fr_network_worker_add_self ( fr_network_t nr,
fr_worker_t worker 
)

Add a worker to a network in the same thread.

Parameters
nrthe network
workerthe worker

Definition at line 313 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_network_worker_started_callback() [1/2]

static void fr_network_worker_started_callback ( void *  ctx,
void const *  data,
size_t  data_size,
fr_time_t  now 
)
static
+ Here is the caller graph for this function:

◆ fr_network_worker_started_callback() [2/2]

static void fr_network_worker_started_callback ( void *  ctx,
void const *  data,
size_t  data_size,
UNUSED fr_time_t  now 
)
static

Handle a network control message callback for a new worker.

Parameters
[in]ctxthe network
[in]datathe message
[in]data_sizesize of the data
[in]nowthe current time

Definition at line 1502 of file network.c.

+ Here is the call graph for this function:

◆ fr_network_write()

static void fr_network_write ( UNUSED fr_event_list_t el,
UNUSED int  sockfd,
UNUSED int  flags,
void *  ctx 
)
static

Write packets to the network.

Parameters
elthe event list
sockfdthe socket which is ready to write
flagsreturned by kevent.
ctxthe network socket context.

Definition at line 1138 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_network_thread()

static bool is_network_thread ( fr_network_t const *  nr)
inlinestatic

Definition at line 224 of file network.c.

+ Here is the caller graph for this function:

◆ reply_cmp()

static int8_t reply_cmp ( void const *  one,
void const *  two 
)
static

Definition at line 157 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ socket_listen_cmp()

static int8_t socket_listen_cmp ( void const *  one,
void const *  two 
)
static

Definition at line 179 of file network.c.

+ Here is the caller graph for this function:

◆ socket_num_cmp()

static int8_t socket_num_cmp ( void const *  one,
void const *  two 
)
static

Definition at line 186 of file network.c.

+ Here is the caller graph for this function:

◆ waiting_cmp()

static int8_t waiting_cmp ( void const *  one,
void const *  two 
)
static

Definition at line 168 of file network.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ cmd_network_table

fr_cmd_table_t cmd_network_table[]

Definition at line 2090 of file network.c.

◆ fr_network_rb

_Thread_local fr_ring_buffer_t* fr_network_rb
static

Definition at line 49 of file network.c.

◆ pause_write

fr_event_update_t const pause_write[]
static
Initial value:
= {
{ 0 }
}
#define FR_EVENT_SUSPEND(_s, _f)
Temporarily remove the filter for a func from kevent.
Definition: event.h:94
Callbacks for the FR_EVENT_FILTER_IO filter.
Definition: event.h:173

Definition at line 1120 of file network.c.

◆ resume_write

fr_event_update_t const resume_write[]
static
Initial value:
= {
{ 0 }
}
#define FR_EVENT_RESUME(_s, _f)
Re-add the filter for a func from kevent.
Definition: event.h:110

Definition at line 1125 of file network.c.