The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
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/missing.h>
#include <freeradius-devel/server/connection.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/heap.h>
#include <freeradius-devel/util/rb_expire.h>
#include <sys/socket.h>
#include "track.h"
Go to the source code of this file.
Data Structures | |
struct | bio_handle_ctx_t |
struct | bio_handle_t |
Track the handle, which is tightly correlated with the FD. More... | |
struct | bio_handle_t.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 | check(_handle, _len_p) |
#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_request_s | bio_request_t |
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 void | bio_connected (fr_bio_t *bio) |
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 bool | check_for_zombie (fr_event_list_t *el, trunk_connection_t *tconn, fr_time_t now, fr_time_t last_sent) |
See if the connection is zombied. | |
static void | conn_close (UNUSED fr_event_list_t *el, void *handle, UNUSED 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 (fr_event_list_t *el, UNUSED fr_time_t now, void *uctx) |
Perform the next step of init and negotiation. | |
static void | conn_init_readable (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 (fr_event_list_t *el, fr_time_t now, void *uctx) |
Status check timer when opening the connection for the first time. | |
static void | conn_init_writable (fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx) |
Send initial negotiation. | |
static void | conn_init_writable (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx) |
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 void | do_signal (rlm_radius_t const *inst, bio_request_t *u, UNUSED 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 int8_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 (rlm_rcode_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, UNUSED request_t *request, fr_signal_t action) |
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 | 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 int8_t | request_prioritise (void const *one, void const *two) |
static void | revive_timeout (UNUSED fr_event_list_t *el, 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_next (UNUSED fr_event_list_t *el, UNUSED fr_time_t now, void *uctx) |
Handle retries for a status check. | |
static void | status_check_reply (trunk_request_t *treq, 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 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 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, UNUSED 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 (fr_event_list_t *el, fr_time_t now, void *uctx) |
Mark a connection dead after "zombie_interval". | |
Variables | |
static const trunk_io_funcs_t | io_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 [] |
RADIUS BIO transport.
Definition in file bio.c.
struct bio_handle_ctx_t |
Data Fields | ||
---|---|---|
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 |
char const * | module_name | the module that opened the connection |
fr_radius_ctx_t | radius_ctx | |
trunk_t * | trunk | trunk handler |
struct bio_handle_t |
Data Fields | ||
---|---|---|
struct bio_handle_t.bio | bio | |
uint8_t * | buffer | Receive buffer. |
size_t | buflen | Receive buffer length. |
connection_t * | conn | |
bio_handle_ctx_t | ctx | |
int | fd |
from thread or home server File descriptor. |
fr_time_t | first_sent | first time we sent a packet since going idle |
uint8_t | last_id | Used when replicating to ensure IDs are distributed evenly. |
fr_time_t | last_idle | last time we had nothing to do |
fr_time_t | last_reply | When we last received a reply. |
fr_time_t | last_sent | last time we sent a packet. |
uint32_t | max_packet_size | Our max packet size. may be different from the parent. |
fr_time_t | mrs_time | Most recent sent time which had a reply. |
bool | status_checking | whether we're doing status checks |
request_t * | status_request | |
bio_request_t * | status_u | for sending status check packets |
radius_track_t * | tt | RADIUS ID tracking structure. |
fr_event_timer_t const * | zombie_ev | Zombie timeout. |
struct bio_handle_t.bio |
struct bio_request_s |
Data Fields | ||
---|---|---|
uint8_t | code | Packet code. |
fr_event_timer_t const * | ev | timer for retransmissions |
fr_pair_list_t | extra | VPs for debugging, like Proxy-State. |
uint8_t | id | Last ID assigned to this packet. |
bool | is_retry | |
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? |
trunk_request_t * | treq |
struct bio_thread_t |
Data Fields | ||
---|---|---|
struct bio_thread_t.bio | bio | |
bio_handle_ctx_t | ctx | for copying to bio_handle_t |
struct bio_thread_t.bio |
Data Fields | ||
---|---|---|
fr_rb_expire_t | expires | for proxying / client sending |
fr_bio_t * | fd | writing |
uint32_t | id | for replication |
struct home_server_t |
Data Fields | ||
---|---|---|
bio_handle_ctx_t | ctx | for copying to bio_handle_t |
fr_rb_expire_node_t | expire | |
fr_bio_fd_config_t | fd_config | fil descriptor configuration |
#define check | ( | _handle, | |
_len_p | |||
) |
#define REQUIRE_MA | ( | _h | ) | (((_h)->ctx.inst->require_message_authenticator == FR_RADIUS_REQUIRE_MA_YES) || (_h)->ctx.inst->received_message_authenticator) |
typedef struct bio_request_s bio_request_t |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Log additional information about a tracking entry.
[in] | te | Tracking entry we're logging information for. |
[in] | log | destination. |
[in] | log_type | Type of log message. |
[in] | file | the logging request was made in. |
[in] | line | logging request was made on. |
Definition at line 194 of file bio.c.
|
static |
See if the connection is zombied.
We check for zombie when major events happen: 1) request hits its final timeout 2) request timer hits, and it needs to be retransmitted 3) a DUP packet comes in, and the request needs to be retransmitted 4) we're sending a packet.
There MIGHT not be retries configured, so we MUST check for zombie when any new packet comes in. Similarly, there MIGHT not be new packets, but retries are configured, so we have to check there, too.
Also, the socket might not be writable for a while. There MIGHT be a long time between getting the timer / DUP signal, and the request finally being written to the socket. So we need to check for zombie at BOTH the timeout and the mux / write function.
Definition at line 1347 of file bio.c.
|
static |
|
static |
|
static |
Connection errored.
We were signalled by the event loop that a fatal error occurred on this connection.
[in] | el | The event list signalling. |
[in] | fd | that errored. |
[in] | flags | El flags. |
[in] | fd_errno | The nature of the error. |
[in] | uctx | The trunk connection handle (tconn). |
Definition at line 976 of file bio.c.
|
static |
|
static |
Initialise a new outbound connection.
[out] | h_out | Where to write the new file descriptor. |
[in] | conn | to initialise. |
[in] | uctx | A bio_thread_t |
Definition at line 733 of file bio.c.
|
static |
Connection errored.
We were signalled by the event loop that a fatal error occurred on this connection.
[in] | el | The event list signalling. |
[in] | fd | that errored. |
[in] | flags | El flags. |
[in] | fd_errno | The nature of the error. |
[in] | uctx | The trunk connection handle (tconn). |
Definition at line 357 of file bio.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Decode response packet data, extracting relevant information and validating the packet.
[in] | ctx | to allocate pairs in. |
[out] | reply | Pointer to head of pair list to add reply attributes to. |
[out] | response_code | The type of response packet. |
[in] | h | connection handle. |
[in] | request | the request. |
[in] | u | UDP request. |
[in] | request_authenticator | from the original request. |
[in] | data | to decode. |
[in] | data_len | Length of input data. |
Definition at line 1096 of file bio.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Turn a reply code into a module rcode;.
|
static |