All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
process.c File Reference

Defines the state machines that control how requests are processed. More...

#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/process.h>
#include <freeradius-devel/modules.h>
#include <freeradius-devel/state.h>
#include <freeradius-devel/rad_assert.h>
#include <freeradius-devel/detail.h>
#include <signal.h>
#include <fcntl.h>
+ Include dependency graph for process.c:

Go to the source code of this file.

Macros

#define ASSERT_MASTER
 
#define CHECK_FOR_STOP   do { if (request->master_state == REQUEST_STOP_PROCESSING) {request_done(request, FR_ACTION_DONE);return;}} while (0)
 
#define COA_SEPARATE   if (request->coa) coa_separate(request->coa);
 
#define FD_MUTEX_LOCK(_x)
 
#define FD_MUTEX_UNLOCK(_x)
 
#define FINAL_STATE(_x)   NO_CHILD_THREAD; request->component = "<" #_x ">"; request->module = ""; request->child_state = _x
 
#define INSERT_EVENT(_function, _ctx)   if (!fr_event_insert(el, _function, _ctx, &((_ctx)->when), &((_ctx)->ev))) { _rad_panic(__FILE__, __LINE__, "Failed to insert event"); }
 
#define NO_CHILD_THREAD
 
#define PTHREAD_MUTEX_LOCK(_x)
 
#define PTHREAD_MUTEX_UNLOCK(_x)
 
#define rad_panic(x)   _rad_panic(__FILE__, __LINE__, x)
 
#define STATE_MACHINE_DECL(_x)   static void _x(REQUEST *request, int action)
 Declare a state in the state machine. More...
 
#define STATE_MACHINE_TIMER(_x)   state_machine_timer(__FILE__, __LINE__, request, &when, _x)
 Insert REQUEST back into the event heap, to continue executing at a future time. More...
 
#define TRACE_STATE_MACHINE   {}
 
#define USEC   (1000000)
 
#define we_are_master(_x)   (1)
 

Functions

static NEVER_RETURNS void _rad_panic (char const *file, unsigned int line, char const *msg)
 
static void add_jitter (struct timeval *when)
 
static void check_proxy (rad_listen_t *head)
 
static void coa_no_reply (REQUEST *request, int action)
 Process a request after the CoA has timed out. More...
 
static void coa_retransmit (REQUEST *request)
 
static void coa_running (REQUEST *request, int action)
 Process the request after receiving a coa reply. More...
 
static void coa_separate (REQUEST *request)
 
static void coa_wait_for_reply (REQUEST *request, int action)
 Wait for a reply after originating a CoA a request. More...
 
static void create_default_proxy_listener (int af)
 
static int eol_listener (void *ctx, void *data)
 
static int eol_proxy_listener (void *ctx, void *data)
 
static int event_new_fd (rad_listen_t *this)
 
static void event_poll_detail (void *ctx, struct timeval *now)
 
static void event_socket_handler (fr_event_list_t *xel, UNUSED int fd, void *ctx)
 
static void event_status (struct timeval *wake)
 
static void handle_signal_self (int flag)
 
static void home_trigger (home_server_t *home, char const *trigger)
 
static int insert_into_proxy_hash (REQUEST *request)
 
static void listener_free_cb (void *ctx, UNUSED struct timeval *now)
 
static void mark_home_server_alive (REQUEST *request, home_server_t *home)
 
void mark_home_server_dead (home_server_t *home, struct timeval *when)
 
static void mark_home_server_zombie (home_server_t *home, struct timeval *now, struct timeval *response_window)
 
static int null_handler (UNUSED REQUEST *request)
 
static int packet_entry_cmp (void const *one, void const *two)
 
static void ping_home_server (void *ctx, struct timeval *now)
 
static int process_proxy_reply (REQUEST *request, RADIUS_PACKET *reply)
 
static int proxy_delete_cb (UNUSED void *ctx, void *data)
 
static int proxy_eol_cb (void *ctx, void *data)
 
static void proxy_no_reply (REQUEST *request, int action)
 Process a request after the proxy has timed out. More...
 
static void proxy_reply_too_late (REQUEST *request)
 
static void proxy_running (REQUEST *request, int action)
 Process the request after receiving a proxy reply. More...
 
static int proxy_to_virtual_server (REQUEST *request)
 
static void proxy_wait_for_reply (REQUEST *request, int action)
 Wait for a reply after proxying a request. More...
 
void radius_event_free (void)
 
int radius_event_init (TALLOC_CTX *ctx)
 
fr_event_list_tradius_event_list_corral (UNUSED event_corral_t hint)
 
int radius_event_process (void)
 
int radius_event_start (bool have_children)
 
void radius_signal_self (int flag)
 
void radius_update_listener (rad_listen_t *this)
 
static void remove_from_proxy_hash (REQUEST *request)
 
static void remove_from_proxy_hash_nl (REQUEST *request, bool yank)
 
static void request_cleanup_delay (REQUEST *request, int action)
 Sit on a request until it's time to clean it up. More...
 
static void request_cleanup_delay_init (REQUEST *request)
 
static void request_coa_originate (REQUEST *request)
 
static int request_delete_cb (UNUSED void *ctx, void *data)
 
static void request_done (REQUEST *request, int action)
 Mark a request DONE and clean it up. More...
 
static void request_dup (REQUEST *request)
 
static void request_finish (REQUEST *request, int action)
 Do the final processing of a request before we reply to the NAS. More...
 
static void request_free (REQUEST *request)
 
static int request_init_delay (REQUEST *request)
 
static bool request_max_time (REQUEST *request)
 
static void request_ping (REQUEST *request, int action)
 Ping a home server. More...
 
static int request_pre_handler (REQUEST *request, UNUSED int action)
 
static int request_proxy (REQUEST *request, int retransmit) CC_HINT(nonnull)
 
static int request_proxy_anew (REQUEST *request)
 
int request_proxy_reply (RADIUS_PACKET *packet)
 
static void request_queue_or_run (REQUEST *request, fr_request_process_t process)
 
int request_receive (TALLOC_CTX *ctx, rad_listen_t *listener, RADIUS_PACKET *packet, RADCLIENT *client, RAD_REQUEST_FUNP fun)
 
static void request_response_delay (REQUEST *request, int action)
 Sit on a request until it's time to respond to it. More...
 
static struct timeval * request_response_window (REQUEST *request)
 
static void request_running (REQUEST *request, int action)
 Process a request from a client. More...
 
static REQUESTrequest_setup (TALLOC_CTX *ctx, rad_listen_t *listener, RADIUS_PACKET *packet, RADCLIENT *client, RAD_REQUEST_FUNP fun)
 
static void request_timer (void *ctx, struct timeval *now)
 
static void request_timer (void *ctx, UNUSED struct timeval *now)
 
static int request_will_proxy (REQUEST *request)
 Determine if a REQUEST needs to be proxied, and perform pre-proxy operations. More...
 
void revive_home_server (void *ctx, UNUSED struct timeval *now)
 
static int setup_post_proxy_fail (REQUEST *request)
 
 STATE_MACHINE_DECL (request_ping)
 
static void state_machine_timer (char const *file, int line, REQUEST *request, struct timeval *when, fr_state_action_t action)
 Insert REQUEST back into the event heap, to continue executing at a future time. More...
 
static void tcp_socket_timer (void *ctx, struct timeval *now)
 

Variables

static char const * action_codes []
 
fr_cond_tdebug_condition
 
fr_log_t debug_log
 
static fr_event_list_tel = NULL
 
time_t fr_start_time = (time_t)-1
 
static bool just_started = true
 
static rbtree_tpl = NULL
 
static TALLOC_CTX * proxy_ctx = NULL
 
static fr_packet_list_tproxy_list = NULL
 
pid_t radius_pid
 
static int request_num_counter = 1
 
static bool spawn_workers = false
 

Detailed Description

Defines the state machines that control how requests are processed.

Id:
d6113a2d69fdf67fc1986664a34d6511452c722a

Definition in file process.c.

Macro Definition Documentation

#define ASSERT_MASTER

Definition at line 285 of file process.c.

#define CHECK_FOR_STOP   do { if (request->master_state == REQUEST_STOP_PROCESSING) {request_done(request, FR_ACTION_DONE);return;}} while (0)
#define COA_SEPARATE   if (request->coa) coa_separate(request->coa);
#define FD_MUTEX_LOCK (   _x)

Definition at line 346 of file process.c.

#define FD_MUTEX_UNLOCK (   _x)

Definition at line 347 of file process.c.

#define FINAL_STATE (   _x)    NO_CHILD_THREAD; request->component = "<" #_x ">"; request->module = ""; request->child_state = _x

Definition at line 291 of file process.c.

#define INSERT_EVENT (   _function,
  _ctx 
)    if (!fr_event_insert(el, _function, _ctx, &((_ctx)->when), &((_ctx)->ev))) { _rad_panic(__FILE__, __LINE__, "Failed to insert event"); }
#define NO_CHILD_THREAD

Definition at line 256 of file process.c.

#define PTHREAD_MUTEX_LOCK (   _x)

Definition at line 254 of file process.c.

#define PTHREAD_MUTEX_UNLOCK (   _x)

Definition at line 255 of file process.c.

#define rad_panic (   x)    _rad_panic(__FILE__, __LINE__, x)

Definition at line 111 of file process.c.

#define STATE_MACHINE_DECL (   _x)    static void _x(REQUEST *request, int action)

Declare a state in the state machine.

Expands to the start of a function definition for a given state.

Parameters
_xthe name of the state.

Definition at line 119 of file process.c.

#define STATE_MACHINE_TIMER (   _x)    state_machine_timer(__FILE__, __LINE__, request, &when, _x)

Insert REQUEST back into the event heap, to continue executing at a future time.

Parameters
_xthe action to perform when we resume processing the request.

Definition at line 144 of file process.c.

#define TRACE_STATE_MACHINE   {}

Definition at line 102 of file process.c.

#define USEC   (1000000)
#define we_are_master (   _x)    (1)

Definition at line 281 of file process.c.

Function Documentation

static NEVER_RETURNS void _rad_panic ( char const *  file,
unsigned int  line,
char const *  msg 
)
static

Definition at line 105 of file process.c.

+ Here is the caller graph for this function:

static void add_jitter ( struct timeval *  when)
static

Definition at line 1974 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void check_proxy ( rad_listen_t head)
static

Definition at line 5264 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void coa_no_reply ( REQUEST request,
int  action 
)
static

Process a request after the CoA has timed out.

Run the packet through Post-Proxy-Type Fail

Definition at line 4431 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void coa_retransmit ( REQUEST request)
static

Definition at line 4217 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void coa_running ( REQUEST request,
int  action 
)
static

Process the request after receiving a coa reply.

Throught the post-proxy section, and the through the handler function.

Definition at line 4482 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void coa_separate ( REQUEST request)
static

Definition at line 4386 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void coa_wait_for_reply ( REQUEST request,
int  action 
)
static

Wait for a reply after originating a CoA a request.

Retransmit the proxied packet, or time out and go to coa_no_reply. Mark the home server unresponsive, etc.

If we do receive a reply, we transition to coa_running.

Definition at line 4359 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void create_default_proxy_listener ( int  af)
static

Definition at line 5217 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int eol_listener ( void *  ctx,
void *  data 
)
static

Definition at line 2022 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int eol_proxy_listener ( void *  ctx,
void *  data 
)
static

Definition at line 1993 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int event_new_fd ( rad_listen_t this)
static

Definition at line 4702 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void event_poll_detail ( void *  ctx,
struct timeval *  now 
)
static

Definition at line 4552 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void event_socket_handler ( fr_event_list_t xel,
UNUSED int  fd,
void *  ctx 
)
static

Definition at line 4519 of file process.c.

+ Here is the caller graph for this function:

static void event_status ( struct timeval *  wake)
static

Definition at line 4586 of file process.c.

+ Here is the caller graph for this function:

static void handle_signal_self ( int  flag)
static

Definition at line 5038 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void home_trigger ( home_server_t home,
char const *  trigger 
)
static

Definition at line 3554 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int insert_into_proxy_hash ( REQUEST request)
static

Definition at line 2137 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void listener_free_cb ( void *  ctx,
UNUSED struct timeval *  now 
)
static

Definition at line 4630 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void mark_home_server_alive ( REQUEST request,
home_server_t home 
)
static

Definition at line 2396 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mark_home_server_dead ( home_server_t home,
struct timeval *  when 
)

Definition at line 3652 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void mark_home_server_zombie ( home_server_t home,
struct timeval *  now,
struct timeval *  response_window 
)
static

Definition at line 3569 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int null_handler ( UNUSED REQUEST request)
static

Definition at line 3976 of file process.c.

+ Here is the caller graph for this function:

static int packet_entry_cmp ( void const *  one,
void const *  two 
)
static

Definition at line 5204 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void ping_home_server ( void *  ctx,
struct timeval *  now 
)
static

Definition at line 3380 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int process_proxy_reply ( REQUEST request,
RADIUS_PACKET reply 
)
static

Definition at line 2249 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int proxy_delete_cb ( UNUSED void *  ctx,
void *  data 
)
static

Definition at line 5444 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int proxy_eol_cb ( void *  ctx,
void *  data 
)
static

Definition at line 4663 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void proxy_no_reply ( REQUEST request,
int  action 
)
static

Process a request after the proxy has timed out.

Run the packet through Post-Proxy-Type Fail

Definition at line 2634 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void proxy_reply_too_late ( REQUEST request)
static

Definition at line 500 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void proxy_running ( REQUEST request,
int  action 
)
static

Process the request after receiving a proxy reply.

Throught the post-proxy section, and the through the handler function.

Definition at line 2683 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int proxy_to_virtual_server ( REQUEST request)
static

Definition at line 3053 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void proxy_wait_for_reply ( REQUEST request,
int  action 
)
static

Wait for a reply after proxying a request.

Retransmit the proxied packet, or time out and go to proxy_no_reply. Mark the home server unresponsive, etc.

If we do receive a reply, we transition to proxy_running.

Definition at line 3720 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void radius_event_free ( void  )

Definition at line 5524 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int radius_event_init ( TALLOC_CTX *  ctx)

Definition at line 5197 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

fr_event_list_t* radius_event_list_corral ( UNUSED event_corral_t  hint)

Definition at line 56 of file process.c.

int radius_event_process ( void  )

Definition at line 5581 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int radius_event_start ( bool  have_children)

Definition at line 5317 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void radius_signal_self ( int  flag)

Definition at line 5132 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void radius_update_listener ( rad_listen_t this)

Definition at line 336 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void remove_from_proxy_hash ( REQUEST request)
static

Definition at line 2110 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void remove_from_proxy_hash_nl ( REQUEST request,
bool  yank 
)
static

Definition at line 2048 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void request_cleanup_delay ( REQUEST request,
int  action 
)
static

Sit on a request until it's time to clean it up.

A NAS may not see a response from the server. When the NAS retransmits, we want to be able to send a cached reply back. The alternative is to re-process the packet, which does bad things for EAP, among others.

IF we do see a NAS retransmit, we extend the cleanup delay, because the NAS might miss our cached reply.

Otherwise, once we reach cleanup_delay, we transition to DONE.

Definition at line 1002 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void request_cleanup_delay_init ( REQUEST request)
static

Definition at line 748 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void request_coa_originate ( REQUEST request)
static

Definition at line 3984 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int request_delete_cb ( UNUSED void *  ctx,
void *  data 
)
static

Definition at line 5478 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void request_done ( REQUEST request,
int  action 
)
static

Mark a request DONE and clean it up.

When a request is DONE, it can have ties to a number of other portions of the server. The request hash, proxy hash, events, child threads, etc. This function takes care of either cleaning up the request, or managing the timers to wait for the ties to be removed.

Definition at line 528 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void request_dup ( REQUEST request)
static

Definition at line 966 of file process.c.

+ Here is the caller graph for this function:

static void request_finish ( REQUEST request,
int  action 
)
static

Do the final processing of a request before we reply to the NAS.

Various cleanups, suppress responses, copy Proxy-State, and set response_delay or cleanup_delay;

Definition at line 1207 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void request_free ( REQUEST request)
static

Definition at line 480 of file process.c.

+ Here is the caller graph for this function:

static int request_init_delay ( REQUEST request)
static

Definition at line 439 of file process.c.

+ Here is the caller graph for this function:

static bool request_max_time ( REQUEST request)
static

Definition at line 823 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void request_ping ( REQUEST request,
int  action 
)
static

Ping a home server.

Definition at line 3305 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int request_pre_handler ( REQUEST request,
UNUSED int  action 
)
static

Definition at line 1146 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int request_proxy ( REQUEST request,
int  retransmit 
)
static

Definition at line 3114 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int request_proxy_anew ( REQUEST request)
static

Definition at line 3216 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int request_proxy_reply ( RADIUS_PACKET packet)

Definition at line 2418 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void request_queue_or_run ( REQUEST request,
fr_request_process_t  process 
)
static

Definition at line 892 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int request_receive ( TALLOC_CTX *  ctx,
rad_listen_t listener,
RADIUS_PACKET packet,
RADCLIENT client,
RAD_REQUEST_FUNP  fun 
)

Definition at line 1523 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void request_response_delay ( REQUEST request,
int  action 
)
static

Sit on a request until it's time to respond to it.

For security reasons, rejects (and maybe some other) packets are delayed for a while before we respond. This delay means that badly behaved NASes don't hammer the server with authentication attempts.

Otherwise, once we reach response_delay, we send the reply, and transition to cleanup_delay.

Definition at line 1082 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static struct timeval* request_response_window ( REQUEST request)
static

Definition at line 413 of file process.c.

+ Here is the caller graph for this function:

static void request_running ( REQUEST request,
int  action 
)
static

Process a request from a client.

The outcome might be that the request is proxied.

Definition at line 1450 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static REQUEST* request_setup ( TALLOC_CTX *  ctx,
rad_listen_t listener,
RADIUS_PACKET packet,
RADCLIENT client,
RAD_REQUEST_FUNP  fun 
)
static

Definition at line 1745 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void request_timer ( void *  ctx,
struct timeval *  now 
)
static

+ Here is the caller graph for this function:

static void request_timer ( void *  ctx,
UNUSED struct timeval *  now 
)
static

Definition at line 463 of file process.c.

static int request_will_proxy ( REQUEST request)
static

Determine if a REQUEST needs to be proxied, and perform pre-proxy operations.

Whether a request will be proxied is determined by the attributes present in request->config. If any of the following attributes are found, the request may be proxied.

The key attributes are:

  • PW_PROXY_TO_REALM - Specifies a realm the request should be proxied to.
  • PW_HOME_SERVER_POOL - Specifies a specific home server pool to proxy to.
  • PW_PACKET_DST_IP_ADDRESS - Specifies a specific IPv4 home server to proxy to.
  • PW_PACKET_DST_IPV6_ADDRESS - Specifies a specific IPv6 home server to proxy to.

Certain packet types such as PW_CODE_STATUS_SERVER will never be proxied.

If request should be proxied, will:

  • Add request:Proxy-State
  • Strip the current username value of its realm (depending on config)
  • Create a CHAP-Challenge from the original request vector, if one doesn't already exist.
  • Call the pre-process section in the current server, or in the virtual server associated with the home server pool we're proxying to.
Todo:
A lot of this logic is RADIUS specific, and should be moved out into a protocol specific function.
Parameters
requestThe REQUEST to evaluate for proxying.
Returns
  • 0 if not proxying.
  • 1 if REQUEST should be proxied.
  • -1 on failure.

Definition at line 2743 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void revive_home_server ( void *  ctx,
UNUSED struct timeval *  now 
)

Definition at line 3626 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int setup_post_proxy_fail ( REQUEST request)
static

Definition at line 2578 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

STATE_MACHINE_DECL ( request_ping  )

Definition at line 354 of file process.c.

static void state_machine_timer ( char const *  file,
int  line,
REQUEST request,
struct timeval *  when,
fr_state_action_t  action 
)
inlinestatic

Insert REQUEST back into the event heap, to continue executing at a future time.

Parameters
filethe state machine timer call occurred in.
linethe state machine timer call occurred on.
requestto set add the timer event for.
whenthe event should fine.
actionto perform when we resume processing the request.

Definition at line 131 of file process.c.

+ Here is the call graph for this function:

static void tcp_socket_timer ( void *  ctx,
struct timeval *  now 
)
static

Definition at line 1857 of file process.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

char const* action_codes[]
static
Initial value:
= {
"INVALID",
"run",
"done",
"dup",
"timer",
"proxy-reply"
}

Definition at line 61 of file process.c.

fr_cond_t* debug_condition
fr_log_t debug_log
fr_event_list_t* el = NULL
static

Definition at line 54 of file process.c.

time_t fr_start_time = (time_t)-1

Definition at line 52 of file process.c.

bool just_started = true
static

Definition at line 51 of file process.c.

rbtree_t* pl = NULL
static

Definition at line 53 of file process.c.

TALLOC_CTX* proxy_ctx = NULL
static

Definition at line 235 of file process.c.

fr_packet_list_t* proxy_list = NULL
static

request_timeline

 Time sequence of a request
RQ-----------------P=============================Y-J-C
::::::::::::::::::::::::::::::::::::::::::::::::::::::::M
  • R: received. Duplicate detection is done, and request is cached.
  • Q: Request is placed onto a queue for child threads to pick up. If there are no child threads, the request goes immediately to P.
  • P: Processing the request through the modules.
  • Y: Reply is ready. Rejects MAY be delayed here. All other replies are sent immediately.
  • J: Reject is sent "response_delay" after the reply is ready.
  • C: For Access-Requests, After "cleanup_delay", the request is deleted. Accounting-Request packets go directly from Y to C.
  • M: Max request time. If the request hits this timer, it is forcibly stopped.

    Other considerations include duplicate and conflicting packets. When a dupicate packet is received, it is ignored until we've reached Y, as no response is ready. If the reply is a reject, duplicates are ignored until J, when we're ready to send the reply. In between the reply being sent (Y or J), and C, the server responds to duplicates by sending the cached reply.

    Conflicting packets are sent in 2 situations.

    The first is in between R and Y. In that case, we consider it as a hint that we're taking too long, and the NAS has given up on the request. We then behave just as if the M timer was reached, and we discard the current request. This allows us to process the new one.

    The second case is when we're at Y, but we haven't yet finished processing the request. This is a race condition in the threading code (avoiding locks is faster). It means that a thread has actually encoded and sent the reply, and that the NAS has responded with a new packet. The server can then safely mark the current request as "OK to delete", and behaves just as if the M timer was reached. This usually happens only in high-load situations.

    Duplicate packets are sent when the NAS thinks we're taking too long, and wants a reply. From R-Y, duplicates are ignored. From Y-J (for Access-Rejects), duplicates are also ignored. From Y-C, duplicates get a duplicate reply. And, they cause the "cleanup_delay" time to be extended. This extension means that we're more likely to send a duplicate reply (if we have one), or to suppress processing the packet twice if we didn't reply to it.

    All functions in this file should be thread-safe, and should assume thet the REQUEST structure is being accessed simultaneously by the main thread, and by the child worker threads. This means that timers, etc. cannot be updated in the child thread.

    Instead, the master thread periodically calls request->process with action TIMER. It's up to the individual functions to determine how to handle that. They need to check if they're being called from a child thread or the master, and then do different things based on that.

Definition at line 234 of file process.c.

pid_t radius_pid
int request_num_counter = 1
static

Definition at line 350 of file process.c.

bool spawn_workers = false
static

Definition at line 50 of file process.c.