The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
bio.c File Reference

RADIUS BIO transport. More...

#include <freeradius-devel/io/application.h>
#include <freeradius-devel/io/listen.h>
#include <freeradius-devel/io/pair.h>
#include <freeradius-devel/server/connection.h>
#include <freeradius-devel/unlang/function.h>
#include <freeradius-devel/unlang/load_balance_priv.h>
#include <freeradius-devel/unlang/subrequest.h>
#include <freeradius-devel/util/heap.h>
#include <freeradius-devel/util/rb_expire.h>
#include "track.h"
+ Include dependency graph for bio.c:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  bio_handle_ctx_t
 
struct  bio_handle_s
 Track the handle, which is tightly correlated with the FD. More...
 
struct  bio_handle_s.bio
 
struct  bio_request_s
 Connect request_t to local tracking structure. More...
 
struct  bio_thread_t
 
struct  bio_thread_t.bio
 
struct  home_server_t
 

Macros

#define DUP_INTERVAL   fr_time_delta_from_sec(1)
 
#define REQUIRE_MA(_h)   (((_h)->ctx.inst->require_message_authenticator == FR_RADIUS_REQUIRE_MA_YES) || *(_h)->ctx.inst->received_message_authenticator)
 

Typedefs

typedef struct bio_handle_s bio_handle_t
 Track the handle, which is tightly correlated with the FD.
 
typedef struct bio_request_s bio_request_t
 

Enumerations

enum  bio_limit_ports_t : uint8_t {
  LIMIT_PORTS_NONE = 0 ,
  LIMIT_PORTS_STATIC ,
  LIMIT_PORTS_DYNAMIC
}
 

Functions

static int _bio_handle_free (bio_handle_t *h)
 Free a connection handle, closing associated resources.
 
static int _bio_request_free (bio_request_t *u)
 Free a bio_request_t.
 
static bool bio_at_eof (bio_handle_t const *h)
 Is the connection at EOF?
 
static void bio_connected (fr_bio_t *bio)
 
static void bio_eof (fr_bio_t *bio)
 The BIO chain is at EOF, and has no more data for us.
 
static void bio_error (fr_bio_t *bio)
 
static void bio_request_reset (bio_request_t *u)
 Clear out any connection specific resources from a udp request.
 
static void bio_tracking_entry_log (fr_log_t const *log, fr_log_type_t log_type, char const *file, int line, radius_track_entry_t *te)
 Log additional information about a tracking entry.
 
static int bio_write_blocked (fr_bio_t *bio)
 Pause the connection when a stream BIO is blocked on write.
 
static int bio_write_resume (fr_bio_t *bio)
 Resume the connection when a stream BIO can write again.
 
static bool check_for_zombie (request_t *request, trunk_connection_t *tconn, fr_time_t now, fr_time_t last_sent)
 Decide whether a request timeout marks the connection as zombie.
 
static void conn_close (UNUSED fr_event_list_t *el, void *handle, void *uctx)
 Shutdown/close a file descriptor.
 
static void conn_discard (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx)
 Read and discard data.
 
static void conn_error (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, int fd_errno, void *uctx)
 Connection errored.
 
static connection_state_t conn_failed (void *handle, connection_state_t state, UNUSED void *uctx)
 Connection failed.
 
static connection_state_t conn_init (void **h_out, connection_t *conn, void *uctx)
 Initialise a new outbound connection.
 
static void conn_init_error (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, int fd_errno, void *uctx)
 Connection errored.
 
static void conn_init_next (UNUSED fr_timer_list_t *tl, UNUSED fr_time_t now, void *uctx)
 Perform the next step of init and negotiation.
 
static void conn_init_readable (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx)
 Read the connection during the init and negotiation stage.
 
static void conn_init_timeout (UNUSED fr_timer_list_t *tl, fr_time_t now, void *uctx)
 Status check timer when opening the connection for the first time.
 
static void conn_init_writable (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx)
 Send initial negotiation.
 
static void conn_writable_flush (fr_event_list_t *el, int fd, int flags, void *uctx)
 The fd is writable, and the connection is blocked on write.
 
static int conn_write_only (bio_handle_t *h)
 Replication is write-only, so the socket never reads.
 
static fr_radius_decode_fail_t decode (TALLOC_CTX *ctx, fr_pair_list_t *reply, uint8_t *response_code, bio_handle_t *h, request_t *request, bio_request_t *u, uint8_t const request_authenticator[static RADIUS_AUTH_VECTOR_LENGTH], uint8_t *data, size_t data_len)
 Decode response packet data, extracting relevant information and validating the packet.
 
static void do_retry (rlm_radius_t const *inst, bio_request_t *u, request_t *request, fr_retry_t const *retry)
 
static void do_signal (rlm_radius_t const *inst, bio_request_t *u, request_t *request, fr_signal_t action)
 
static int encode (bio_handle_t *h, request_t *request, bio_request_t *u, uint8_t id)
 
static fr_cmp_ret_t home_server_cmp (void const *one, void const *two)
 Dynamic home server code.
 
static void home_server_free (void *data)
 
static void mod_dup (request_t *request, bio_request_t *u)
 
static int mod_enqueue (bio_request_t **p_u, fr_retry_config_t const **p_retry_config, rlm_radius_t const *inst, trunk_t *trunk, request_t *request)
 
static unlang_action_t mod_resume (unlang_result_t *p_result, module_ctx_t const *mctx, UNUSED request_t *request)
 Resume execution of the request, returning the rcode set during trunk execution.
 
static void mod_retry (module_ctx_t const *mctx, request_t *request, fr_retry_t const *retry)
 Handle module retries.
 
static void mod_signal (module_ctx_t const *mctx, request_t *request, fr_signal_t action)
 
static int mod_thread_detach (module_thread_inst_ctx_t const *mctx)
 Free thread data for the submodule.
 
static int mod_thread_instantiate (module_thread_inst_ctx_t const *mctx)
 Instantiate thread data for the submodule.
 
static void mod_write (request_t *request, trunk_request_t *treq, bio_handle_t *h)
 
static void mux_requeue_if_blocked (trunk_connection_t *tconn)
 Requeue packets if the connection is blocked on write.
 
static void protocol_error_reply (bio_request_t *u, bio_handle_t *h)
 Deal with Protocol-Error replies, and possible negotiation.
 
static void request_cancel (UNUSED connection_t *conn, void *preq_to_reset, trunk_cancel_reason_t reason, UNUSED void *uctx)
 Remove the request from any tracking structures.
 
static void request_complete (request_t *request, NDEBUG_UNUSED void *preq, void *rctx, UNUSED void *uctx)
 Response has already been written to the rctx at this point.
 
static void request_conn_release (connection_t *conn, void *preq_to_reset, UNUSED void *uctx)
 Clear out anything associated with the handle from the request.
 
static void request_demux (UNUSED fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx)
 
static void request_fail (request_t *request, NDEBUG_UNUSED void *preq, void *rctx, NDEBUG_UNUSED trunk_request_state_t state, UNUSED void *uctx)
 Write out a canned failure.
 
static void request_mux (UNUSED fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx)
 
static fr_cmp_ret_t request_prioritise (void const *one, void const *two)
 
static void request_replicate_demux (UNUSED fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx)
 
static void request_replicate_mux (UNUSED fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx)
 
static void revive_timeout (UNUSED fr_timer_list_t *tl, UNUSED fr_time_t now, void *uctx)
 Revive a connection after "revive_interval".
 
static fr_bio_verify_action_t rlm_radius_verify (UNUSED fr_bio_t *bio, void *verify_ctx, UNUSED void *packet_ctx, const void *data, size_t *size)
 
static void status_check_alloc (bio_handle_t *h)
 
static void status_check_enqueue (trunk_connection_t *tconn, bio_handle_t *h, bool init)
 Queue a status check packet on an open connection, and wait for the reply.
 
static void status_check_next (UNUSED fr_timer_list_t *tl, UNUSED fr_time_t now, void *uctx)
 Send the next status check, after the previous status check got a reply.
 
static void status_check_reply (trunk_connection_t *tconn, bio_request_t *u, fr_time_t now)
 Deal with replies replies to status checks and possible negotiation.
 
static void status_check_reset (bio_handle_t *h, bio_request_t *u)
 Reset a status_check packet, ready to reuse.
 
static void status_check_timeout (UNUSED fr_timer_list_t *tl, fr_time_t now, void *uctx)
 We timed out, without getting a status check reply.
 
static connection_t * thread_conn_alloc (trunk_connection_t *tconn, fr_event_list_t *el, connection_conf_t const *conf, char const *log_prefix, void *uctx)
 
static void thread_conn_notify (trunk_connection_t *tconn, connection_t *conn, fr_event_list_t *el, trunk_connection_event_t notify_on, UNUSED void *uctx)
 
static void thread_conn_notify (trunk_connection_t *tconn, connection_t *conn, fr_event_list_t *el, trunk_connection_event_t notify_on, void *uctx)
 
static xlat_action_t xlat_radius_client (UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *args)
 
static xlat_action_t xlat_radius_replicate (UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *args)
 
static xlat_action_t xlat_sendto_resume (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, UNUSED fr_value_box_list_t *in)
 
static void xlat_sendto_retry (xlat_ctx_t const *xctx, request_t *request, fr_retry_t const *retry)
 
static void xlat_sendto_signal (xlat_ctx_t const *xctx, request_t *request, fr_signal_t action)
 
static void zombie_timeout (UNUSED fr_timer_list_t *tl, fr_time_t now, void *uctx)
 Mark a connection dead after "zombie_interval".
 

Variables

static const trunk_io_funcs_t io_funcs
 
static const trunk_io_funcs_t io_replicate_funcs
 
static rlm_rcode_t radius_code_to_rcode [FR_RADIUS_CODE_MAX]
 Turn a reply code into a module rcode;.
 
static xlat_arg_parser_t const xlat_radius_send_args []
 

Detailed Description

RADIUS BIO transport.

Id
ed85e9cc041741dac2a19d752b41fecbf856eb0f

Definition in file bio.c.


Data Structure Documentation

◆ bio_handle_ctx_t

struct bio_handle_ctx_t

Definition at line 46 of file bio.c.

+ Collaboration diagram for bio_handle_ctx_t:
Data Fields
bool dynamic is this a dynamic home server.
fr_event_list_t * el Event list.
fr_bio_fd_config_t fd_config for threads or sockets
fr_bio_fd_info_t const * fd_info status of the FD.
rlm_radius_t const * inst our instance
bio_limit_ports_t limit_source_ports What type of port limit is in use.
char const * module_name the module that opened the connection
fr_radius_ctx_t radius_ctx for signing packets
trunk_t * trunk trunk handler

◆ bio_handle_s

struct bio_handle_s

Track the handle, which is tightly correlated with the FD.

Definition at line 79 of file bio.c.

+ Collaboration diagram for bio_handle_s:
Data Fields
struct bio_handle_s.bio bio
uint8_t * buffer Receive buffer.
size_t buflen Receive buffer length.
connection_t * conn
bio_handle_ctx_t ctx common struct for home servers and BIO handles
bool eof The BIO chain is at EOF, see bio_eof().
int fd File descriptor.
fr_time_t first_unanswered When the current run of unanswered requests started.

Zero when no request is waiting for a reply since last_reply.

unlang_t const * instruction Instruction which triggered the start of the zombie period.
uint8_t last_id Used when replicating to ensure IDs are distributed evenly.
fr_time_t last_reply When we last received a reply.
fr_time_t last_sent last time we wrote a request.
uint32_t max_packet_size Our max packet size. may be different from the parent.
trunk_connection_event_t notify_on The events which the trunk last asked for.
bool radius_1_1 RADIUS/1.1 has been negotiated for this connection.
bool status_checking whether we're doing status checks
request_t * status_request
bio_request_t * status_u for sending status check packets
trunk_connection_t * tconn The trunk connection.

Set by thread_conn_notify(), so it is NULL until the trunk has started to use the connection.

uint32_t timeouts Requests which timed out without a reply since the last reply.

Compared with response_timeouts.

fr_timer_list_t * tl Timers for this connection.
radius_track_t * tt RADIUS ID tracking structure.
bool write_blocked A stream write blocked, and has not yet resumed.

See bio_write_blocked() and bio_write_resume().

fr_timer_t * zombie_ev Zombie timeout. Only used when status_check = no.

◆ bio_handle_s.bio

struct bio_handle_s.bio

Definition at line 91 of file bio.c.

Data Fields
fr_bio_t * fd raw FD
fr_bio_t * main what we use for IO
fr_bio_t * mem memory wrappers for stream sockets

◆ bio_request_s

struct bio_request_s

Connect request_t to local tracking structure.

Definition at line 157 of file bio.c.

+ Collaboration diagram for bio_request_s:
Data Fields
uint8_t code Packet code.
fr_timer_t * ev timer for retransmissions
fr_pair_list_t extra VPs for debugging, like Proxy-State.
uint8_t id Last ID assigned to this packet.
fr_time_t last_written when the last whole packet was last written.

Suppresses fast / duplicate NAS retransmissions

uint32_t num_replies number of reply packets, sent is in retry.count
uint8_t * packet Packet we write to the network.
size_t packet_len Length of the packet.
size_t partial partially sent data
uint32_t priority copied from request->async->priority
bool proxied is this request being proxied
rlm_rcode_t rcode from the transport
fr_time_t recv_time copied from request->async->recv_time
fr_retry_t retry retransmission timers
radius_track_entry_t * rr ID tracking, resend count, etc.
bool status_check is this packet a status check?
uint32_t token Last Token assigned to this packet. Only for RADIUS/1.1.
trunk_request_t * treq

◆ bio_thread_t

struct bio_thread_t

Definition at line 61 of file bio.c.

+ Collaboration diagram for bio_thread_t:
Data Fields
struct bio_thread_t.bio bio
connection_t ** connections
bio_handle_ctx_t ctx common struct for home servers and BIO handles
int num_ports

◆ bio_thread_t.bio

struct bio_thread_t.bio

Definition at line 64 of file bio.c.

Data Fields
fr_rb_expire_t expires for proxying / client sending
fr_bio_t * fd writing
uint32_t id for replication

◆ home_server_t

struct home_server_t

Definition at line 186 of file bio.c.

+ Collaboration diagram for home_server_t:
Data Fields
connection_t * connections[] for tracking outbound connections
bio_handle_ctx_t ctx for copying to bio_handle_t
fr_rb_expire_node_t expire
int num_ports

Macro Definition Documentation

◆ DUP_INTERVAL

#define DUP_INTERVAL   fr_time_delta_from_sec(1)

Definition at line 202 of file bio.c.

◆ REQUIRE_MA

#define REQUIRE_MA (   _h)    (((_h)->ctx.inst->require_message_authenticator == FR_RADIUS_REQUIRE_MA_YES) || *(_h)->ctx.inst->received_message_authenticator)

Typedef Documentation

◆ bio_handle_t

typedef struct bio_handle_s bio_handle_t

Track the handle, which is tightly correlated with the FD.

◆ bio_request_t

typedef struct bio_request_s bio_request_t

Definition at line 74 of file bio.c.

Enumeration Type Documentation

◆ bio_limit_ports_t

Enumerator
LIMIT_PORTS_NONE 

Source port not restricted.

LIMIT_PORTS_STATIC 

Limited source ports for static home servers.

LIMIT_PORTS_DYNAMIC 

Limited source ports for dynamic home servers.

Definition at line 40 of file bio.c.

Function Documentation

◆ _bio_handle_free()

static int _bio_handle_free ( bio_handle_t *  h)
static

Free a connection handle, closing associated resources.

Definition at line 1072 of file bio.c.

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

◆ _bio_request_free()

static int _bio_request_free ( bio_request_t *  u)
static

Free a bio_request_t.

Allows us to set break points for debugging.

Definition at line 3443 of file bio.c.

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

◆ bio_at_eof()

static bool bio_at_eof ( bio_handle_t const *  h)
inlinestatic

Is the connection at EOF?

Either the whole BIO chain is at EOF, or the fd is at EOF.

Definition at line 148 of file bio.c.

+ Here is the caller graph for this function:

◆ bio_connected()

static void bio_connected ( fr_bio_t *  bio)
static

Definition at line 1152 of file bio.c.

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

◆ bio_eof()

static void bio_eof ( fr_bio_t *  bio)
static

The BIO chain is at EOF, and has no more data for us.

For TLS, the peer sent us a close_notify alert. The fd BIO may not have seen EOF, as the peer can send a close_notify and keep the TCP connection open.

Definition at line 1181 of file bio.c.

◆ bio_error()

static void bio_error ( fr_bio_t *  bio)
static

Definition at line 1166 of file bio.c.

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

◆ bio_request_reset()

static void bio_request_reset ( bio_request_t *  u)
static

Clear out any connection specific resources from a udp request.

Definition at line 273 of file bio.c.

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

◆ bio_tracking_entry_log()

static void bio_tracking_entry_log ( fr_log_t const *  log,
fr_log_type_t  log_type,
char const *  file,
int  line,
radius_track_entry_t *  te 
)
static

Log additional information about a tracking entry.

Parameters
[in]teTracking entry we're logging information for.
[in]logdestination.
[in]log_typeType of log message.
[in]filethe logging request was made in.
[in]linelogging request was made on.

Definition at line 254 of file bio.c.

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

◆ bio_write_blocked()

static int bio_write_blocked ( fr_bio_t *  bio)
static

Pause the connection when a stream BIO is blocked on write.

Returns
  • 1 for "writes are blocked".

Definition at line 697 of file bio.c.

+ Here is the call graph for this function:

◆ bio_write_resume()

static int bio_write_resume ( fr_bio_t *  bio)
static

Resume the connection when a stream BIO can write again.

Returns
  • 1 for "writes can resume".

Definition at line 736 of file bio.c.

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

◆ check_for_zombie()

static bool check_for_zombie ( request_t *  request,
trunk_connection_t *  tconn,
fr_time_t  now,
fr_time_t  last_sent 
)
static

Decide whether a request timeout marks the connection as zombie.

This function is called by do_retry() when a request reaches max_rtx_duration or max_rtx_count. That call is skipped when:

  1. The request has no connection.
  2. The module is in replicate mode.
  3. The request is not in the TRUNK_REQUEST_STATE_SENT state.

In the third case, the home server had no chance to reply, because the module did not write the whole packet.

The connection becomes zombie only when all of the following conditions are true:

  1. The connection is open. A connection that is connecting or closing cannot send or receive status checks.
  2. The connection has not received a valid reply since the request was first sent.
  3. A run of unanswered requests exists, and the run started at least zombie_period ago.
  4. At least response_timeouts requests in a row have timed out, without receiving a reply between the timeouts.

An open connection that is already zombie, or that is running status checks, stays zombie.

When the connection becomes zombie, teh connectin is marked as inactive.

The value of status_check decides how the zombie state ends:

  • With status_check = no, a timer is started with zombie_period. When the timer fires, zombie_timeout() marks the connection as dead. As noted above, receiving a reply during this period marks the connection as alive again.
  • With status_check = yes, the function queues a status check on the connection. The connection leaves the zombie state after num_answers_to_alive replies. If a status check reaches max_rtx_duration or max_rtx_count, the connection is dead, and is reconnected.
Parameters
[in]requestthe request that timed out. The function reads the unlang instruction from the request when status_check = no.
[in]tconnthe trunk connection to check.
[in]nowthe current time, or zero if the function must read the clock.
[in]last_sentwhen the request was first sent (retry->start). This is not the time of the last write in h->last_sent.
Returns
  • true if the connection is zombie.
  • false if the connection is not zombie.

Definition at line 2215 of file bio.c.

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

◆ conn_close()

static void conn_close ( UNUSED fr_event_list_t *  el,
void *  handle,
void *  uctx 
)
static

Shutdown/close a file descriptor.

Definition at line 1533 of file bio.c.

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

◆ conn_discard()

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

Read and discard data.

Definition at line 1659 of file bio.c.

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

◆ conn_error()

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

Connection errored.

We were signalled by the event loop that a fatal error occurred on this connection.

Parameters
[in]elThe event list signalling.
[in]fdthat errored.
[in]flagsEl flags.
[in]fd_errnoThe nature of the error.
[in]uctxThe trunk connection handle (tconn).

Definition at line 1694 of file bio.c.

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

◆ conn_failed()

static connection_state_t conn_failed ( void *  handle,
connection_state_t  state,
UNUSED void *  uctx 
)
static

Connection failed.

Parameters
[in]handleof connection that failed.
[in]statethe connection was in when it failed.
[in]uctxUNUSED.

Definition at line 1603 of file bio.c.

+ Here is the caller graph for this function:

◆ conn_init()

static connection_state_t conn_init ( void **  h_out,
connection_t *  conn,
void *  uctx 
)
static

Initialise a new outbound connection.

Parameters
[out]h_outWhere to write the new file descriptor.
[in]connto initialise.
[in]uctxA bio_handle_ctx_t

Definition at line 1266 of file bio.c.

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

◆ conn_init_error()

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

Connection errored.

We were signalled by the event loop that a fatal error occurred on this connection.

Parameters
[in]elThe event list signalling.
[in]fdthat errored.
[in]flagsEl flags.
[in]fd_errnoThe nature of the error.
[in]uctxThe trunk connection handle (tconn).

Definition at line 402 of file bio.c.

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

◆ conn_init_next()

static void conn_init_next ( UNUSED fr_timer_list_t *  tl,
UNUSED fr_time_t  now,
void *  uctx 
)
static

Perform the next step of init and negotiation.

Definition at line 471 of file bio.c.

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

◆ conn_init_readable()

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

Read the connection during the init and negotiation stage.

Definition at line 492 of file bio.c.

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

◆ conn_init_timeout()

static void conn_init_timeout ( UNUSED fr_timer_list_t *  tl,
fr_time_t  now,
void *  uctx 
)
static

Status check timer when opening the connection for the first time.

Setup retries, or fail the connection.

Definition at line 423 of file bio.c.

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

◆ conn_init_writable()

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

Send initial negotiation.

Definition at line 616 of file bio.c.

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

◆ conn_writable_flush()

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

The fd is writable, and the connection is blocked on write.

Definition at line 1709 of file bio.c.

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

◆ conn_write_only()

static int conn_write_only ( bio_handle_t *  h)
static

Replication is write-only, so the socket never reads.

A stream socket has to be connected before this function runs, as shutdown() on a socket which is not connected fails with ENOTCONN.

Returns
  • 0 on success, or when the module is not replicating.
  • -1 on failure.

Definition at line 1137 of file bio.c.

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

◆ decode()

static fr_radius_decode_fail_t decode ( TALLOC_CTX *  ctx,
fr_pair_list_t *  reply,
uint8_t *  response_code,
bio_handle_t *  h,
request_t *  request,
bio_request_t *  u,
uint8_t const  request_authenticator[static RADIUS_AUTH_VECTOR_LENGTH],
uint8_t *  data,
size_t  data_len 
)
static

Decode response packet data, extracting relevant information and validating the packet.

Parameters
[in]ctxto allocate pairs in.
[out]replyPointer to head of pair list to add reply attributes to.
[out]response_codeThe type of response packet.
[in]hconnection handle.
[in]requestthe request.
[in]uUDP request.
[in]request_authenticatorfrom the original request.
[in]datato decode.
[in]data_lenLength of input data.
Returns
  • FR_RADIUS_FAIL_NONE on success.
  • FR_RADIUS_FAIL_* on failure.

Definition at line 1848 of file bio.c.

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

◆ do_retry()

static void do_retry ( rlm_radius_t const *  inst,
bio_request_t *  u,
request_t *  request,
fr_retry_t const *  retry 
)
static

Definition at line 2351 of file bio.c.

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

◆ do_signal()

static void do_signal ( rlm_radius_t const *  inst,
bio_request_t *  u,
request_t *  request,
fr_signal_t  action 
)
static

Definition at line 3392 of file bio.c.

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

◆ encode()

static int encode ( bio_handle_t *  h,
request_t *  request,
bio_request_t *  u,
uint8_t  id 
)
static

Definition at line 1923 of file bio.c.

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

◆ home_server_cmp()

static fr_cmp_ret_t home_server_cmp ( void const *  one,
void const *  two 
)
static

Dynamic home server code.

Definition at line 3860 of file bio.c.

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

◆ home_server_free()

static void home_server_free ( void *  data)
static

Definition at line 3591 of file bio.c.

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

◆ mod_dup()

static void mod_dup ( request_t *  request,
bio_request_t *  u 
)
static

Definition at line 2294 of file bio.c.

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

◆ mod_enqueue()

static int mod_enqueue ( bio_request_t **  p_u,
fr_retry_config_t const **  p_retry_config,
rlm_radius_t const *  inst,
trunk_t *  trunk,
request_t *  request 
)
static

Definition at line 3464 of file bio.c.

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

◆ mod_resume()

static unlang_action_t mod_resume ( unlang_result_t *  p_result,
module_ctx_t const *  mctx,
UNUSED request_t *  request 
)
static

Resume execution of the request, returning the rcode set during trunk execution.

Definition at line 3371 of file bio.c.

+ Here is the call graph for this function:

◆ mod_retry()

static void mod_retry ( module_ctx_t const *  mctx,
request_t *  request,
fr_retry_t const *  retry 
)
static

Handle module retries.

Definition at line 2343 of file bio.c.

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

◆ mod_signal()

static void mod_signal ( module_ctx_t const *  mctx,
request_t *  request,
fr_signal_t  action 
)
static

Definition at line 3383 of file bio.c.

+ Here is the call graph for this function:

◆ mod_thread_detach()

static int mod_thread_detach ( module_thread_inst_ctx_t const *  mctx)
static

Free thread data for the submodule.

Definition at line 3730 of file bio.c.

◆ mod_thread_instantiate()

static int mod_thread_instantiate ( module_thread_inst_ctx_t const *  mctx)
static

Instantiate thread data for the submodule.

Definition at line 3625 of file bio.c.

+ Here is the call graph for this function:

◆ mod_write()

static void mod_write ( request_t *  request,
trunk_request_t *  treq,
bio_handle_t *  h 
)
static

Definition at line 2505 of file bio.c.

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

◆ mux_requeue_if_blocked()

static void mux_requeue_if_blocked ( trunk_connection_t *  tconn)
static

Requeue packets if the connection is blocked on write.

bio_write_blocked() makes the connection inactive, and this function moves pending (but unwritten) requests out of the queue, to other connections.

Requests in the partial state stay on this connection.

Requests in the sent state stay on this connection, because they're waiting for a response.

Parameters
[in]tconnthe trunk connection which was just written to.

Definition at line 2463 of file bio.c.

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

◆ protocol_error_reply()

static void protocol_error_reply ( bio_request_t *  u,
bio_handle_t *  h 
)
static

Deal with Protocol-Error replies, and possible negotiation.

Definition at line 2760 of file bio.c.

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

◆ request_cancel()

static void request_cancel ( UNUSED connection_t *  conn,
void *  preq_to_reset,
trunk_cancel_reason_t  reason,
UNUSED void *  uctx 
)
static

Remove the request from any tracking structures.

Frees encoded packets if the request is being moved to a new connection

Definition at line 3266 of file bio.c.

◆ request_complete()

static void request_complete ( request_t *  request,
NDEBUG_UNUSED void *  preq,
void *  rctx,
UNUSED void *  uctx 
)
static

Response has already been written to the rctx at this point.

Definition at line 3346 of file bio.c.

+ Here is the call graph for this function:

◆ request_conn_release()

static void request_conn_release ( connection_t *  conn,
void *  preq_to_reset,
UNUSED void *  uctx 
)
static

Clear out anything associated with the handle from the request.

Definition at line 3298 of file bio.c.

+ Here is the call graph for this function:

◆ request_demux()

static void request_demux ( UNUSED fr_event_list_t *  el,
trunk_connection_t *  tconn,
connection_t *  conn,
UNUSED void *  uctx 
)
static

Definition at line 2929 of file bio.c.

+ Here is the call graph for this function:

◆ request_fail()

static void request_fail ( request_t *  request,
NDEBUG_UNUSED void *  preq,
void *  rctx,
NDEBUG_UNUSED trunk_request_state_t  state,
UNUSED void *  uctx 
)
static

Write out a canned failure.

Definition at line 3317 of file bio.c.

+ Here is the call graph for this function:

◆ request_mux()

static void request_mux ( UNUSED fr_event_list_t *  el,
trunk_connection_t *  tconn,
connection_t *  conn,
UNUSED void *  uctx 
)
static

Definition at line 2484 of file bio.c.

+ Here is the call graph for this function:

◆ request_prioritise()

static fr_cmp_ret_t request_prioritise ( void const *  one,
void const *  two 
)
static

Definition at line 1809 of file bio.c.

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

◆ request_replicate_demux()

static void request_replicate_demux ( UNUSED fr_event_list_t *  el,
trunk_connection_t *  tconn,
connection_t *  conn,
UNUSED void *  uctx 
)
static

Definition at line 3149 of file bio.c.

+ Here is the call graph for this function:

◆ request_replicate_mux()

static void request_replicate_mux ( UNUSED fr_event_list_t *  el,
trunk_connection_t *  tconn,
connection_t *  conn,
UNUSED void *  uctx 
)
static

Definition at line 3127 of file bio.c.

+ Here is the call graph for this function:

◆ revive_timeout()

static void revive_timeout ( UNUSED fr_timer_list_t *  tl,
UNUSED fr_time_t  now,
void *  uctx 
)
static

Revive a connection after "revive_interval".

Definition at line 2030 of file bio.c.

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

◆ rlm_radius_verify()

static fr_bio_verify_action_t rlm_radius_verify ( UNUSED fr_bio_t *  bio,
void *  verify_ctx,
UNUSED void *  packet_ctx,
const void *  data,
size_t *  size 
)
static

Definition at line 1188 of file bio.c.

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

◆ status_check_alloc()

static void status_check_alloc ( bio_handle_t *  h)
static

Definition at line 307 of file bio.c.

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

◆ status_check_enqueue()

static void status_check_enqueue ( trunk_connection_t *  tconn,
bio_handle_t *  h,
bool  init 
)
static

Queue a status check packet on an open connection, and wait for the reply.

The caller has already set up the retry state of the status check. The timer runs when the status check gets no reply before u->retry.next.

Definition at line 2150 of file bio.c.

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

◆ status_check_next()

static void status_check_next ( UNUSED fr_timer_list_t *  tl,
UNUSED fr_time_t  now,
void *  uctx 
)
static

Send the next status check, after the previous status check got a reply.

Definition at line 2873 of file bio.c.

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

◆ status_check_reply()

static void status_check_reply ( trunk_connection_t *  tconn,
bio_request_t *  u,
fr_time_t  now 
)
static

Deal with replies replies to status checks and possible negotiation.

Definition at line 2892 of file bio.c.

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

◆ status_check_reset()

static void status_check_reset ( bio_handle_t *  h,
bio_request_t *  u 
)
static

Reset a status_check packet, ready to reuse.

Definition at line 290 of file bio.c.

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

◆ status_check_timeout()

static void status_check_timeout ( UNUSED fr_timer_list_t *  tl,
fr_time_t  now,
void *  uctx 
)
static

We timed out, without getting a status check reply.

Definition at line 2101 of file bio.c.

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

◆ thread_conn_alloc()

static connection_t * thread_conn_alloc ( trunk_connection_t *  tconn,
fr_event_list_t *  el,
connection_conf_t const *  conf,
char const *  log_prefix,
void *  uctx 
)
static

Definition at line 1630 of file bio.c.

+ Here is the call graph for this function:

◆ thread_conn_notify() [1/2]

static void thread_conn_notify ( trunk_connection_t *  tconn,
connection_t *  conn,
fr_event_list_t *  el,
trunk_connection_event_t  notify_on,
UNUSED void *  uctx 
)
static

Definition at line 1738 of file bio.c.

+ Here is the call graph for this function:

◆ thread_conn_notify() [2/2]

static void thread_conn_notify ( trunk_connection_t *  tconn,
connection_t *  conn,
fr_event_list_t *  el,
trunk_connection_event_t  notify_on,
void *  uctx 
)
static
+ Here is the caller graph for this function:

◆ xlat_radius_client()

static xlat_action_t xlat_radius_client ( UNUSED TALLOC_CTX *  ctx,
UNUSED fr_dcursor_t *  out,
xlat_ctx_t const *  xctx,
request_t *  request,
fr_value_box_list_t *  args 
)
static

Definition at line 3911 of file bio.c.

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

◆ xlat_radius_replicate()

static xlat_action_t xlat_radius_replicate ( UNUSED TALLOC_CTX *  ctx,
UNUSED fr_dcursor_t *  out,
xlat_ctx_t const *  xctx,
request_t *  request,
fr_value_box_list_t *  args 
)
static

Definition at line 3753 of file bio.c.

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

◆ xlat_sendto_resume()

static xlat_action_t xlat_sendto_resume ( TALLOC_CTX *  ctx,
fr_dcursor_t *  out,
xlat_ctx_t const *  xctx,
request_t *  request,
UNUSED fr_value_box_list_t *  in 
)
static

Definition at line 3872 of file bio.c.

+ Here is the call graph for this function:

◆ xlat_sendto_retry()

static void xlat_sendto_retry ( xlat_ctx_t const *  xctx,
request_t *  request,
fr_retry_t const *  retry 
)
static

Definition at line 3900 of file bio.c.

+ Here is the call graph for this function:

◆ xlat_sendto_signal()

static void xlat_sendto_signal ( xlat_ctx_t const *  xctx,
request_t *  request,
fr_signal_t  action 
)
static

Definition at line 3889 of file bio.c.

+ Here is the call graph for this function:

◆ zombie_timeout()

static void zombie_timeout ( UNUSED fr_timer_list_t *  tl,
fr_time_t  now,
void *  uctx 
)
static

Mark a connection dead after "zombie_interval".

Definition at line 2042 of file bio.c.

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

Variable Documentation

◆ io_funcs

const trunk_io_funcs_t io_funcs
static
Initial value:
= {
.connection_alloc = thread_conn_alloc,
.connection_notify = thread_conn_notify,
.request_prioritise = request_prioritise,
.request_mux = request_mux,
.request_demux = request_demux,
.request_conn_release = request_conn_release,
.request_complete = request_complete,
.request_fail = request_fail,
.request_cancel = request_cancel,
}
static void request_demux(UNUSED fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx)
Definition bio.c:2929
static void request_conn_release(connection_t *conn, void *preq_to_reset, UNUSED void *uctx)
Clear out anything associated with the handle from the request.
Definition bio.c:3298
static fr_cmp_ret_t request_prioritise(void const *one, void const *two)
Definition bio.c:1809
static void request_cancel(UNUSED connection_t *conn, void *preq_to_reset, trunk_cancel_reason_t reason, UNUSED void *uctx)
Remove the request from any tracking structures.
Definition bio.c:3266
static void request_fail(request_t *request, NDEBUG_UNUSED void *preq, void *rctx, NDEBUG_UNUSED trunk_request_state_t state, UNUSED void *uctx)
Write out a canned failure.
Definition bio.c:3317
static void thread_conn_notify(trunk_connection_t *tconn, connection_t *conn, fr_event_list_t *el, trunk_connection_event_t notify_on, void *uctx)
static connection_t * thread_conn_alloc(trunk_connection_t *tconn, fr_event_list_t *el, connection_conf_t const *conf, char const *log_prefix, void *uctx)
Definition bio.c:1630
static void request_mux(UNUSED fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx)
Definition bio.c:2484
static void request_complete(request_t *request, NDEBUG_UNUSED void *preq, void *rctx, UNUSED void *uctx)
Response has already been written to the rctx at this point.
Definition bio.c:3346

Definition at line 3598 of file bio.c.

◆ io_replicate_funcs

const trunk_io_funcs_t io_replicate_funcs
static
Initial value:
= {
.connection_alloc = thread_conn_alloc,
.connection_notify = thread_conn_notify,
.request_prioritise = request_prioritise,
.request_mux = request_replicate_mux,
.request_demux = request_replicate_demux,
.request_conn_release = request_conn_release,
.request_complete = request_complete,
.request_fail = request_fail,
.request_cancel = request_cancel,
}
static void request_replicate_mux(UNUSED fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx)
Definition bio.c:3127
static void request_replicate_demux(UNUSED fr_event_list_t *el, trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx)
Definition bio.c:3149

Definition at line 3610 of file bio.c.

◆ radius_code_to_rcode

rlm_rcode_t radius_code_to_rcode[FR_RADIUS_CODE_MAX]
static
Initial value:
= {
}
@ FR_RADIUS_CODE_ACCESS_CHALLENGE
RFC2865 - Access-Challenge.
Definition defs.h:43
@ FR_RADIUS_CODE_DISCONNECT_ACK
RFC3575/RFC5176 - Disconnect-Ack (positive)
Definition defs.h:47
@ FR_RADIUS_CODE_ACCESS_ACCEPT
RFC2865 - Access-Accept.
Definition defs.h:34
@ FR_RADIUS_CODE_ACCOUNTING_RESPONSE
RFC2866 - Accounting-Response.
Definition defs.h:37
@ FR_RADIUS_CODE_COA_NAK
RFC3575/RFC5176 - CoA-Nak (not willing to perform)
Definition defs.h:51
@ FR_RADIUS_CODE_COA_ACK
RFC3575/RFC5176 - CoA-Ack (positive)
Definition defs.h:50
@ FR_RADIUS_CODE_DISCONNECT_NAK
RFC3575/RFC5176 - Disconnect-Nak (not willing to perform)
Definition defs.h:48
@ FR_RADIUS_CODE_PROTOCOL_ERROR
RFC7930 - Protocol-Error (generic NAK)
Definition defs.h:52
@ FR_RADIUS_CODE_ACCESS_REJECT
RFC2865 - Access-Reject.
Definition defs.h:35
@ RLM_MODULE_OK
The module is OK, continue.
Definition rcode.h:49
@ RLM_MODULE_REJECT
Immediately reject the request.
Definition rcode.h:47
@ RLM_MODULE_UPDATED
OK (pairs modified).
Definition rcode.h:55
@ RLM_MODULE_HANDLED
The module handled the request, so stop.
Definition rcode.h:50

Turn a reply code into a module rcode;.

Definition at line 208 of file bio.c.

◆ xlat_radius_send_args

xlat_arg_parser_t const xlat_radius_send_args[]
static
Initial value:
= {
{ .required = true, .single = true, .type = FR_TYPE_COMBO_IP_ADDR },
{ .required = true, .single = true, .type = FR_TYPE_UINT16 },
{ .required = true, .single = true, .type = FR_TYPE_STRING },
}
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_UINT16
16 Bit unsigned integer.
@ FR_TYPE_COMBO_IP_ADDR
IPv4 or IPv6 address depending on length.
#define XLAT_ARG_PARSER_TERMINATOR
Definition xlat.h:160

Definition at line 3743 of file bio.c.