![]() |
The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
|
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 [] |
RADIUS BIO transport.
Definition in file bio.c.
| struct bio_handle_ctx_t |
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 |
| struct bio_handle_s |
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 |
| 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. |
| struct bio_handle_s.bio |
| struct bio_request_s |
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 | |
| struct bio_thread_t |
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 | |
| 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 |
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 | |
| #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) |
| 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 |
| enum bio_limit_ports_t : uint8_t |
|
static |
|
static |
|
inlinestatic |
|
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 254 of file bio.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
|
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:
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:
zombie_period ago.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:
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.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.| [in] | request | the request that timed out. The function reads the unlang instruction from the request when status_check = no. |
| [in] | tconn | the trunk connection to check. |
| [in] | now | the current time, or zero if the function must read the clock. |
| [in] | last_sent | when the request was first sent (retry->start). This is not the time of the last write in h->last_sent. |
Definition at line 2215 of file bio.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
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 1694 of file bio.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
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_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:
|
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 402 of file bio.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
|
static |
|
static |
|
static |
|
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.
Definition at line 1137 of file bio.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
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 1848 of file bio.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
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.
| [in] | tconn | the 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:
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
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:
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Here is the caller graph for this function:
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Turn a reply code into a module rcode;.
|
static |
1.9.8