The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
RADIUS UDP 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/udp.h>
#include <sys/socket.h>
#include "rlm_radius.h"
#include "track.h"
Go to the source code of this file.
Data Structures | |
struct | rlm_radius_udp_t |
Static configuration for the module. More... | |
struct | udp_coalesced_t |
struct | udp_handle_t |
Track the handle, which is tightly correlated with the FD. More... | |
struct | udp_request_s |
Connect request_t to local tracking structure. More... | |
struct | udp_result_t |
struct | udp_thread_t |
Macros | |
#define | check(_handle, _len_p) |
Typedefs | |
typedef struct udp_request_s | udp_request_t |
Functions | |
static int | _udp_handle_free (udp_handle_t *h) |
Free a connection handle, closing associated resources. More... | |
static int | _udp_request_free (udp_request_t *u) |
Free a udp_request_t. More... | |
static int | _udp_result_free (udp_result_t *r) |
Free a udp_result_t. More... | |
static bool | check_for_zombie (fr_event_list_t *el, fr_trunk_connection_t *tconn, fr_time_t now, fr_time_t last_sent) |
See if the connection is zombied. More... | |
static void | conn_close (UNUSED fr_event_list_t *el, void *handle, UNUSED void *uctx) |
Shutdown/close a file descriptor. More... | |
static void | conn_discard (UNUSED fr_event_list_t *el, int fd, UNUSED int flags, void *uctx) |
Read and discard data. More... | |
static void | conn_error (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, int fd_errno, void *uctx) |
Connection errored. More... | |
static void | conn_error_status_check (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, int fd_errno, void *uctx) |
Connection errored. More... | |
static fr_connection_state_t | conn_failed (void *handle, fr_connection_state_t state, UNUSED void *uctx) |
Connection failed. More... | |
static fr_connection_state_t | conn_init (void **h_out, fr_connection_t *conn, void *uctx) |
Initialise a new outbound connection. More... | |
static void | conn_readable_status_check (fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx) |
Read the incoming status-check response. More... | |
static void | conn_status_check_again (fr_event_list_t *el, UNUSED fr_time_t now, void *uctx) |
Send the next status check packet. More... | |
static void | conn_status_check_timeout (fr_event_list_t *el, fr_time_t now, void *uctx) |
Status check timer when opening the connection for the first time. More... | |
static void | conn_writable_status_check (fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx) |
Send our status-check packet as soon as the connection becomes writable. More... | |
static void | conn_writable_status_check (UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx) |
static decode_fail_t | decode (TALLOC_CTX *ctx, fr_pair_list_t *reply, uint8_t *response_code, udp_handle_t *h, request_t *request, udp_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. More... | |
static int | encode (rlm_radius_udp_t const *inst, request_t *request, udp_request_t *u, uint8_t id) |
static unlang_action_t | mod_enqueue (rlm_rcode_t *p_result, void **rctx_out, void *instance, void *thread, request_t *request) |
static int | mod_instantiate (module_inst_ctx_t const *mctx) |
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. More... | |
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. More... | |
static void | protocol_error_reply (udp_request_t *u, udp_result_t *r, udp_handle_t *h) |
Deal with Protocol-Error replies, and possible negotiation. More... | |
static void | request_cancel (UNUSED fr_connection_t *conn, void *preq_to_reset, fr_trunk_cancel_reason_t reason, UNUSED void *uctx) |
Remove the request from any tracking structures. More... | |
static void | request_complete (request_t *request, void *preq, void *rctx, UNUSED void *uctx) |
Response has already been written to the rctx at this point. More... | |
static void | request_conn_release (fr_connection_t *conn, void *preq_to_reset, UNUSED void *uctx) |
Clear out anything associated with the handle from the request. More... | |
static void | request_conn_release_replicate (UNUSED fr_connection_t *conn, void *preq_to_reset, UNUSED void *uctx) |
Clear out anything associated with the handle from the request. More... | |
static void | request_demux (UNUSED fr_event_list_t *el, fr_trunk_connection_t *tconn, fr_connection_t *conn, UNUSED void *uctx) |
static void | request_fail (request_t *request, void *preq, void *rctx, NDEBUG_UNUSED fr_trunk_request_state_t state, UNUSED void *uctx) |
Write out a canned failure. More... | |
static void | request_free (UNUSED request_t *request, void *preq_to_free, UNUSED void *uctx) |
Explicitly free resources associated with the protocol request. More... | |
static void | request_mux (fr_event_list_t *el, fr_trunk_connection_t *tconn, fr_connection_t *conn, UNUSED void *uctx) |
static void | request_mux_replicate (UNUSED fr_event_list_t *el, fr_trunk_connection_t *tconn, fr_connection_t *conn, UNUSED void *uctx) |
static int8_t | request_prioritise (void const *one, void const *two) |
static void | request_retry (fr_event_list_t *el, fr_time_t now, void *uctx) |
Handle retries when a request is being sent asynchronously. More... | |
static void | request_timeout (fr_event_list_t *el, fr_time_t now, void *uctx) |
Handle timeouts when a request is being sent synchronously. More... | |
static void | revive_timeout (UNUSED fr_event_list_t *el, UNUSED fr_time_t now, void *uctx) |
Revive a connection after "revive_interval". More... | |
static void | status_check_alloc (udp_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. More... | |
static void | status_check_reply (fr_trunk_request_t *treq, fr_time_t now) |
Deal with replies replies to status checks and possible negotiation. More... | |
static void | status_check_reset (udp_handle_t *h, udp_request_t *u) |
Reset a status_check packet, ready to reuse. More... | |
static void | status_check_retry (UNUSED fr_event_list_t *el, fr_time_t now, void *uctx) |
static fr_connection_t * | thread_conn_alloc (fr_trunk_connection_t *tconn, fr_event_list_t *el, fr_connection_conf_t const *conf, char const *log_prefix, void *uctx) |
static void | thread_conn_notify (fr_trunk_connection_t *tconn, fr_connection_t *conn, fr_event_list_t *el, fr_trunk_connection_event_t notify_on, UNUSED void *uctx) |
static void | thread_conn_notify_replicate (fr_trunk_connection_t *tconn, fr_connection_t *conn, fr_event_list_t *el, fr_trunk_connection_event_t notify_on, UNUSED void *uctx) |
A special version of the trunk/event loop glue function which always discards incoming data. More... | |
static void | udp_request_reset (udp_request_t *u) |
Clear out any connection specific resources from a udp request. More... | |
static void | udp_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. More... | |
static void | zombie_timeout (fr_event_list_t *el, fr_time_t now, void *uctx) |
Mark a connection dead after "zombie_interval". More... | |
Variables | |
static fr_dict_attr_t const * | attr_acct_delay_time |
static fr_dict_attr_t const * | attr_error_cause |
static fr_dict_attr_t const * | attr_event_timestamp |
static fr_dict_attr_t const * | attr_extended_attribute_1 |
static fr_dict_attr_t const * | attr_message_authenticator |
static fr_dict_attr_t const * | attr_nas_identifier |
static fr_dict_attr_t const * | attr_original_packet_code |
static fr_dict_attr_t const * | attr_packet_type |
static fr_dict_attr_t const * | attr_proxy_state |
static fr_dict_attr_t const * | attr_response_length |
static fr_dict_attr_t const * | attr_user_password |
static fr_dict_t const * | dict_radius |
static const conf_parser_t | module_config [] |
static rlm_rcode_t | radius_code_to_rcode [FR_RADIUS_CODE_MAX] |
Turn a reply code into a module rcode;. More... | |
rlm_radius_io_t | rlm_radius_udp |
fr_dict_autoload_t | rlm_radius_udp_dict [] |
fr_dict_attr_autoload_t | rlm_radius_udp_dict_attr [] |
RADIUS UDP transport.
Definition in file rlm_radius_udp.c.
struct rlm_radius_udp_t |
Static configuration for the module.
Definition at line 51 of file rlm_radius_udp.c.
Data Fields | ||
---|---|---|
CONF_SECTION * | config | |
fr_ipaddr_t | dst_ipaddr | IP of the home server. |
uint16_t | dst_port | Port of the home server. |
char const * | interface | Interface to bind to. |
uint32_t | max_packet_size | Maximum packet size. |
uint16_t | max_send_coalesce | Maximum number of packets to coalesce into one mmsg call. |
rlm_radius_t * | parent | rlm_radius instance. |
uint32_t | recv_buff | How big the kernel's receive buffer should be. |
bool | recv_buff_is_set | Whether we were provided with a recv_buf. |
bool | replicate | Copied from parent->replicate. |
char const * | secret | Shared secret. |
uint32_t | send_buff | How big the kernel's send buffer should be. |
bool | send_buff_is_set | Whether we were provided with a send_buf. |
fr_ipaddr_t | src_ipaddr | IP we open our socket on. |
fr_trunk_conf_t * | trunk_conf | trunk configuration |
struct udp_coalesced_t |
Definition at line 90 of file rlm_radius_udp.c.
Data Fields | ||
---|---|---|
struct iovec | out | Describes buffer to send. |
fr_trunk_request_t * | treq | Used for signalling. |
struct udp_handle_t |
Track the handle, which is tightly correlated with the FD.
Definition at line 98 of file rlm_radius_udp.c.
Data Fields | ||
---|---|---|
int | active | active packets |
uint8_t * | buffer | Receive buffer. |
size_t | buflen | Receive buffer length. |
udp_coalesced_t * | coalesced | Outbound coalesced requests. |
fr_trunk_request_t ** | coalesced | Outbound coalesced requests. |
int | fd | File descriptor. |
fr_time_t | first_sent | first time we sent a packet since going idle |
int | id | starts at 1. |
rlm_radius_udp_t const * | inst | Our module instance. |
rlm_tacacs_tcp_t const * | inst | Our module instance. |
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. |
struct mmsghdr * | mmsgvec | Vector of inbound/outbound packets. |
char const * | module_name | the module that opened the connection |
fr_time_t | mrs_time | Most recent sent time which had a reply. |
char const * | name | From IP PORT to IP PORT. |
tcp_buffer_t | recv | receive buffer |
tcp_buffer_t | send | send buffer |
size_t | send_buff_actual |
What we believe the maximum SO_SNDBUF size to be. We don't try and encode more packet data than this in one go. |
uint32_t | session_id | for TACACS+ "security". |
fr_ipaddr_t | src_ipaddr |
Source IP address. May be altered on bind to be the actual IP address packets will be sent on. This is why we can't use the inst src_ipaddr field. |
uint16_t | src_port |
Source port specific to this connection.
|
bool | status_checking | whether we're doing status checks |
udp_result_t * | status_r | for faking out status checks as real packets |
request_t * | status_request | |
udp_request_t * | status_u | for sending status check packets |
fr_trunk_connection_t * | tconn | trunk connection |
udp_thread_t * | thread | |
fr_trunk_request_t * | tracking[UINT8_MAX] | all sequential! |
radius_track_t * | tt | RADIUS ID tracking structure. |
fr_event_timer_t const * | zombie_ev | Zombie timeout. |
struct udp_request_s |
Connect request_t to local tracking structure.
Definition at line 148 of file rlm_radius_udp.c.
Data Fields | ||
---|---|---|
bool | can_retransmit | can we retransmit this packet? |
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. |
uint32_t | num_replies | number of reply packets, sent is in retry.count |
bool | outstanding | are we waiting for a reply? |
uint8_t * | packet | Packet we write to the network. |
size_t | packet_len | Length of the packet. |
uint32_t | priority | copied from request->async->priority |
fr_time_t | recv_time | copied from request->async->recv_time |
bool | require_ma | saved from the original packet. |
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? |
bool | synchronous | cached from inst->parent->synchronous |
struct udp_result_t |
Definition at line 83 of file rlm_radius_udp.c.
Data Fields | ||
---|---|---|
rlm_rcode_t | rcode | from the transport |
fr_trunk_request_t * | treq |
struct udp_thread_t |
Definition at line 75 of file rlm_radius_udp.c.
Data Fields | ||
---|---|---|
fr_event_list_t * | el | Event list. |
rlm_radius_udp_t const * | inst | our instance |
rlm_tacacs_tcp_t const * | inst | our instance |
fr_trunk_t * | trunk | trunk handler |
#define check | ( | _handle, | |
_len_p | |||
) |
Definition at line 45 of file rlm_radius_udp.c.
typedef struct udp_request_s udp_request_t |
Definition at line 1 of file rlm_radius_udp.c.
|
static |
Free a connection handle, closing associated resources.
Definition at line 681 of file rlm_radius_udp.c.
|
static |
Free a udp_request_t.
Definition at line 2660 of file rlm_radius_udp.c.
|
static |
Free a udp_result_t.
Allows us to set break points for debugging.
Definition at line 2642 of file rlm_radius_udp.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 1530 of file rlm_radius_udp.c.
|
static |
Shutdown/close a file descriptor.
Definition at line 870 of file rlm_radius_udp.c.
|
static |
Read and discard data.
Definition at line 950 of file rlm_radius_udp.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 985 of file rlm_radius_udp.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 432 of file rlm_radius_udp.c.
|
static |
Connection failed.
[in] | handle | of connection that failed. |
[in] | state | the connection was in when it failed. |
[in] | uctx | UNUSED. |
Definition at line 897 of file rlm_radius_udp.c.
|
static |
Initialise a new outbound connection.
[out] | h_out | Where to write the new file descriptor. |
[in] | conn | to initialise. |
[in] | uctx | A udp_thread_t |
Definition at line 712 of file rlm_radius_udp.c.
|
static |
Read the incoming status-check response.
If it's correct mark the connection as connected
Definition at line 515 of file rlm_radius_udp.c.
|
static |
Send the next status check packet.
Definition at line 501 of file rlm_radius_udp.c.
|
static |
Status check timer when opening the connection for the first time.
Setup retries, or fail the connection.
Definition at line 453 of file rlm_radius_udp.c.
|
static |
Send our status-check packet as soon as the connection becomes writable.
Definition at line 619 of file rlm_radius_udp.c.
|
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 1135 of file rlm_radius_udp.c.
|
static |
Definition at line 1196 of file rlm_radius_udp.c.
|
static |
|
static |
Definition at line 2797 of file rlm_radius_udp.c.
|
static |
Resume execution of the request, returning the rcode set during trunk execution.
Definition at line 2568 of file rlm_radius_udp.c.
|
static |
|
static |
Instantiate thread data for the submodule.
Definition at line 2754 of file rlm_radius_udp.c.
|
static |
Deal with Protocol-Error replies, and possible negotiation.
Definition at line 2097 of file rlm_radius_udp.c.
|
static |
Remove the request from any tracking structures.
Frees encoded packets if the request is being moved to a new connection
Definition at line 2448 of file rlm_radius_udp.c.
|
static |
Response has already been written to the rctx at this point.
Definition at line 2534 of file rlm_radius_udp.c.
|
static |
Clear out anything associated with the handle from the request.
Definition at line 2481 of file rlm_radius_udp.c.
|
static |
Clear out anything associated with the handle from the request.
Definition at line 2501 of file rlm_radius_udp.c.
|
static |
Definition at line 2283 of file rlm_radius_udp.c.
|
static |
Write out a canned failure.
Definition at line 2513 of file rlm_radius_udp.c.
|
static |
Explicitly free resources associated with the protocol request.
Definition at line 2551 of file rlm_radius_udp.c.
|
static |
Definition at line 1710 of file rlm_radius_udp.c.
|
static |
Definition at line 1966 of file rlm_radius_udp.c.
|
static |
Definition at line 1094 of file rlm_radius_udp.c.
|
static |
Handle retries when a request is being sent asynchronously.
Definition at line 1610 of file rlm_radius_udp.c.
|
static |
Handle timeouts when a request is being sent synchronously.
Definition at line 1587 of file rlm_radius_udp.c.
|
static |
Revive a connection after "revive_interval".
Definition at line 1460 of file rlm_radius_udp.c.
|
static |
Definition at line 323 of file rlm_radius_udp.c.
|
static |
Handle retries for a status check.
Definition at line 2212 of file rlm_radius_udp.c.
|
static |
Deal with replies replies to status checks and possible negotiation.
Definition at line 2227 of file rlm_radius_udp.c.
|
static |
Reset a status_check packet, ready to reuse.
Definition at line 306 of file rlm_radius_udp.c.
|
static |
Definition at line 1655 of file rlm_radius_udp.c.
|
static |
Definition at line 923 of file rlm_radius_udp.c.
|
static |
Definition at line 996 of file rlm_radius_udp.c.
|
static |
A special version of the trunk/event loop glue function which always discards incoming data.
Definition at line 1048 of file rlm_radius_udp.c.
|
static |
Clear out any connection specific resources from a udp request.
Definition at line 290 of file rlm_radius_udp.c.
|
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 271 of file rlm_radius_udp.c.
|
static |
Mark a connection dead after "zombie_interval".
Definition at line 1472 of file rlm_radius_udp.c.
|
static |
Definition at line 203 of file rlm_radius_udp.c.
|
static |
Definition at line 204 of file rlm_radius_udp.c.
|
static |
Definition at line 205 of file rlm_radius_udp.c.
|
static |
Definition at line 206 of file rlm_radius_udp.c.
|
static |
Definition at line 207 of file rlm_radius_udp.c.
|
static |
Definition at line 208 of file rlm_radius_udp.c.
|
static |
Definition at line 209 of file rlm_radius_udp.c.
|
static |
Definition at line 213 of file rlm_radius_udp.c.
|
static |
Definition at line 210 of file rlm_radius_udp.c.
|
static |
Definition at line 211 of file rlm_radius_udp.c.
|
static |
Definition at line 212 of file rlm_radius_udp.c.
|
static |
Definition at line 195 of file rlm_radius_udp.c.
|
static |
Definition at line 171 of file rlm_radius_udp.c.
|
static |
Turn a reply code into a module rcode;.
Definition at line 234 of file rlm_radius_udp.c.
rlm_radius_io_t rlm_radius_udp |
Definition at line 2892 of file rlm_radius_udp.c.
fr_dict_autoload_t rlm_radius_udp_dict |
Definition at line 198 of file rlm_radius_udp.c.
fr_dict_attr_autoload_t rlm_radius_udp_dict_attr |
Definition at line 216 of file rlm_radius_udp.c.