Interval limiting module providing an xlat function.
More...
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/main_loop.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/unlang/xlat_func.h>
#include <freeradius-devel/util/rb.h>
#include <freeradius-devel/util/slab.h>
#include <freeradius-devel/util/timer.h>
#include <freeradius-devel/util/debug.h>
#include <freeradius-devel/util/strerror.h>
#include <pthread.h>
Go to the source code of this file.
|
| static int | interval_check (fr_rb_tree_t *tree, rlm_interval_thread_t *thread, void *owner, fr_timer_cb_t expire, rlm_interval_entry_t *find, fr_time_delta_t interval) |
| | Check interval limit.
|
| |
| static int8_t | interval_entry_cmp (void const *one, void const *two) |
| |
| static void | interval_expire_global (UNUSED fr_timer_list_t *tl, UNUSED fr_time_t now, void *uctx) |
| | Timer callback to expire entries (global scope)
|
| |
| static void | interval_expire_thread (UNUSED fr_timer_list_t *tl, UNUSED fr_time_t now, void *uctx) |
| | Timer callback to expire entries (thread scope)
|
| |
| static xlat_action_t | interval_xlat_global (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
| | Global scope xlat - always uses mutex-protected tree.
|
| |
| static int | interval_xlat_instantiate (xlat_inst_ctx_t const *xctx) |
| |
| static xlat_action_t | interval_xlat_thread (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *in) |
| | Thread scope xlat - uses thread-local tree or module thread instance.
|
| |
| static int | interval_xlat_thread_instantiate (xlat_thread_inst_ctx_t const *xctx) |
| |
| static int | mod_bootstrap (module_inst_ctx_t const *mctx) |
| |
| static int | mod_detach (module_detach_ctx_t const *mctx) |
| |
| static int | mod_instantiate (module_inst_ctx_t const *mctx) |
| |
| static int | mod_thread_instantiate (module_thread_inst_ctx_t const *mctx) |
| |
Interval limiting module providing an xlat function.
- Id
- 1a042ab5071847a64ce19818a0748b60dcb2dfad
- Copyright
- 2026 The FreeRADIUS server project
-
2026 Arran Cudbard-Bell a.cud.nosp@m.bard.nosp@m.b@fre.nosp@m.erad.nosp@m.ius.o.nosp@m.rg
Definition in file rlm_interval.c.
◆ rlm_interval_entry_t
| struct rlm_interval_entry_t |
◆ rlm_interval_mutable_t
| struct rlm_interval_mutable_t |
Mutable data for global scope (allocated outside mprotected instance data)
Definition at line 65 of file rlm_interval.c.
◆ rlm_interval_t
◆ rlm_interval_thread_t
| struct rlm_interval_thread_t |
Module thread instance data.
Definition at line 80 of file rlm_interval.c.
| Data Fields |
|
interval_slab_list_t * |
slab |
Slab allocator for entries. |
|
fr_timer_list_t * |
tl |
Timer list for entry expiry. |
|
fr_rb_tree_t * |
tree |
RBTree for keyed lookups (thread scope only). |
◆ rlm_interval_xlat_inst_t
| struct rlm_interval_xlat_inst_t |
Xlat instance data - stores the xlat expression pointer for keyless lookups.
Definition at line 88 of file rlm_interval.c.
| Data Fields |
|
xlat_exp_t const * |
ex |
Cached for keyless lookups. |
◆ rlm_interval_xlat_thread_inst_t
| struct rlm_interval_xlat_thread_inst_t |
Xlat thread instance data - stores last_used for keyless thread-scope lookups.
Definition at line 94 of file rlm_interval.c.
| Data Fields |
|
fr_time_t |
last_used |
Last used time for this call site. |
◆ rlm_interval_scope_t
| Enumerator |
|---|
| INTERVAL_SCOPE_GLOBAL | |
| INTERVAL_SCOPE_THREAD | |
Definition at line 40 of file rlm_interval.c.
◆ interval_check()
Check interval limit.
- Note
- Don't be tempted to move mutex handling in here. Yes you could probably reduce the size of the critical region, but you're going to break something and miss interaction effects. Just don't do it.
- Parameters
-
| [in] | tree | RBTree for lookups. |
| [in] | thread | Thread instance (for timer list and slab). |
| [in] | owner | Back-pointer to store in new entries (for expiry callback). |
| [in] | expire | Expiry callback function. |
| [in] | find | Entry with key to search for. |
| [in] | interval | Interval limit interval. |
- Returns
- 1 if allowed.
- 0 if interval limited.
- -1 on error.
Definition at line 172 of file rlm_interval.c.
◆ interval_entry_cmp()
| static int8_t interval_entry_cmp |
( |
void const * |
one, |
|
|
void const * |
two |
|
) |
| |
|
static |
◆ interval_expire_global()
Timer callback to expire entries (global scope)
Definition at line 143 of file rlm_interval.c.
◆ interval_expire_thread()
Timer callback to expire entries (thread scope)
Definition at line 132 of file rlm_interval.c.
◆ interval_xlat_global()
Global scope xlat - always uses mutex-protected tree.
Definition at line 218 of file rlm_interval.c.
◆ interval_xlat_instantiate()
◆ interval_xlat_thread()
Thread scope xlat - uses thread-local tree or module thread instance.
Definition at line 270 of file rlm_interval.c.
◆ interval_xlat_thread_instantiate()
◆ mod_bootstrap()
◆ mod_detach()
◆ mod_instantiate()
◆ mod_thread_instantiate()
◆ interval_scope_table
Initial value:= {
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition at line 45 of file rlm_interval.c.
◆ interval_scope_table_len
◆ interval_xlat_args
Initial value:= {
}
@ FR_TYPE_TIME_DELTA
A period of time measured in nanoseconds.
@ FR_TYPE_STRING
String of printable characters.
#define XLAT_ARG_PARSER_TERMINATOR
Definition at line 112 of file rlm_interval.c.
◆ module_config
Initial value:= {
.dflt = "global" },
}
int cf_table_parse_int(UNUSED TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
Generic function for parsing conf pair values as int.
#define CONF_PARSER_TERMINATOR
#define FR_CONF_OFFSET(_name, _struct, _field)
conf_parser_t which parses a single CONF_PAIR, writing the result to a field in a struct
#define FR_CONF_OFFSET_SUBSECTION(_name, _flags, _struct, _field, _subcs)
conf_parser_t which populates a sub-struct using a CONF_SECTION
static conf_parser_t reuse_config[]
static fr_table_num_sorted_t const interval_scope_table[]
static size_t interval_scope_table_len
Definition at line 103 of file rlm_interval.c.
◆ reuse_config
Initial value:= {
}
#define FR_SLAB_CONFIG_CONF_PARSER
conf_parser_t entries to populate user configurable slab values
Definition at line 98 of file rlm_interval.c.
◆ rlm_interval
Initial value:= {
.common = {
.name = "interval",
}
}
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
static int mod_detach(module_detach_ctx_t const *mctx)
static int mod_bootstrap(module_inst_ctx_t const *mctx)
static int mod_thread_instantiate(module_thread_inst_ctx_t const *mctx)
static const conf_parser_t module_config[]
static int mod_instantiate(module_inst_ctx_t const *mctx)
Module thread instance data.
Definition at line 455 of file rlm_interval.c.