The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions | Variables
rlm_kv.c File Reference

Provide an ephemeral, in-memory kv store. More...

#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/module.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/unlang/xlat_func.h>
#include <freeradius-devel/util/htrie.h>
+ Include dependency graph for rlm_kv.c:

Go to the source code of this file.

Data Structures

struct  rlm_kv_data_s
 KV structure. More...
 
struct  rlm_kv_mutable_t
 Mutable data structure which is shared across all threads. More...
 
struct  rlm_kv_t
 

Macros

#define LOG_PREFIX   mctx->mi->name
 

Typedefs

typedef struct rlm_kv_data_s rlm_kv_data_t
 

Functions

static xlat_action_t kv_delete_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, UNUSED request_t *request, fr_value_box_list_t *args)
 Delete an entry from the KV.
 
static xlat_action_t kv_read_xlat (TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_ctx_t const *xctx, UNUSED request_t *request, fr_value_box_list_t *args)
 Read an entry from the KV.
 
static xlat_action_t kv_write_xlat (UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_t *out, xlat_ctx_t const *xctx, UNUSED request_t *request, fr_value_box_list_t *args)
 Write an entry to the KV.
 
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_mutable_free (rlm_kv_mutable_t *mutable)
 

Variables

static xlat_arg_parser_t const kv_read_xlat_args []
 
static xlat_arg_parser_t const kv_write_xlat_args []
 
static const conf_parser_t module_config []
 
module_rlm_t rlm_kv
 

Detailed Description

Provide an ephemeral, in-memory kv store.

Id
b095d598276c0cb09d804e6f6acd3c1ba1e7358f

This module will use infinite memory if asked, as it doesn't track or expire old entries.

This module uses cross-thread mutex locks, so if used a lot, it will cause all threads to synchronise, and will kill performance.

Definition in file rlm_kv.c.


Data Structure Documentation

◆ rlm_kv_data_s

struct rlm_kv_data_s

KV structure.

The "key" field MUST be first, so that we can do lookups by giving the htrie code a "fr_value_box_t*", which is the key.

Definition at line 52 of file rlm_kv.c.

+ Collaboration diagram for rlm_kv_data_s:
Data Fields
rlm_kv_entry_t entry for expiration
fr_value_box_t key indexed key
fr_value_box_t value value to store

◆ rlm_kv_mutable_t

struct rlm_kv_mutable_t

Mutable data structure which is shared across all threads.

Definition at line 63 of file rlm_kv.c.

+ Collaboration diagram for rlm_kv_mutable_t:
Data Fields
rlm_kv_list_t list for expiring old entries
pthread_mutex_t mutex for thread locking.
fr_htrie_t * tree for kv stores.

◆ rlm_kv_t

struct rlm_kv_t

Definition at line 69 of file rlm_kv.c.

+ Collaboration diagram for rlm_kv_t:
Data Fields
fr_htrie_type_t htype
char const * key_type data type of the key
uint32_t max_entries
rlm_kv_mutable_t * mutable
fr_type_t type

Macro Definition Documentation

◆ LOG_PREFIX

#define LOG_PREFIX   mctx->mi->name

Definition at line 33 of file rlm_kv.c.

Typedef Documentation

◆ rlm_kv_data_t

typedef struct rlm_kv_data_s rlm_kv_data_t

Definition at line 42 of file rlm_kv.c.

Function Documentation

◆ kv_delete_xlat()

static xlat_action_t kv_delete_xlat ( TALLOC_CTX *  ctx,
fr_dcursor_t out,
xlat_ctx_t const *  xctx,
UNUSED request_t request,
fr_value_box_list_t *  args 
)
static

Delete an entry from the KV.

Returns the deleted entry, if one exists. Otherwise returns nothing.

kv.delete(key)

Definition at line 222 of file rlm_kv.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ kv_read_xlat()

static xlat_action_t kv_read_xlat ( TALLOC_CTX *  ctx,
fr_dcursor_t out,
xlat_ctx_t const *  xctx,
UNUSED request_t request,
fr_value_box_list_t *  args 
)
static

Read an entry from the KV.

kv.read(key)

Definition at line 174 of file rlm_kv.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ kv_write_xlat()

static xlat_action_t kv_write_xlat ( UNUSED TALLOC_CTX *  ctx,
UNUSED fr_dcursor_t out,
xlat_ctx_t const *  xctx,
UNUSED request_t request,
fr_value_box_list_t *  args 
)
static

Write an entry to the KV.

kv.write(key, value)

Definition at line 103 of file rlm_kv.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mod_bootstrap()

static int mod_bootstrap ( module_inst_ctx_t const *  mctx)
static

Definition at line 316 of file rlm_kv.c.

+ Here is the call graph for this function:

◆ mod_detach()

static int mod_detach ( module_detach_ctx_t const *  mctx)
static

Definition at line 271 of file rlm_kv.c.

+ Here is the call graph for this function:

◆ mod_instantiate()

static int mod_instantiate ( module_inst_ctx_t const *  mctx)
static

Definition at line 278 of file rlm_kv.c.

+ Here is the call graph for this function:

◆ mod_mutable_free()

static int mod_mutable_free ( rlm_kv_mutable_t mutable)
static

Definition at line 265 of file rlm_kv.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ kv_read_xlat_args

xlat_arg_parser_t const kv_read_xlat_args[]
static
Initial value:
= {
{ .required = true, .single = true, .type = FR_TYPE_VOID },
}
@ FR_TYPE_VOID
User data.
#define XLAT_ARG_PARSER_TERMINATOR
Definition xlat.h:170

Definition at line 94 of file rlm_kv.c.

◆ kv_write_xlat_args

xlat_arg_parser_t const kv_write_xlat_args[]
static
Initial value:
= {
{ .required = true, .single = true, .type = FR_TYPE_VOID },
{ .required = true, .single = true, .type = FR_TYPE_VOID },
}

Definition at line 88 of file rlm_kv.c.

◆ module_config

const conf_parser_t module_config[]
static
Initial value:
= {
{ FR_CONF_OFFSET("key_type", rlm_kv_t, key_type), .dflt = "string" },
{ FR_CONF_OFFSET("max_entries", rlm_kv_t, max_entries), .dflt = "8192" },
}
#define CONF_PARSER_TERMINATOR
Definition cf_parse.h:660
#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
Definition cf_parse.h:283

Definition at line 80 of file rlm_kv.c.

◆ rlm_kv

module_rlm_t rlm_kv
Initial value:
= {
.common = {
.name = "kv",
.inst_size = sizeof(rlm_kv_t),
.bootstrap = mod_bootstrap,
.instantiate = mod_instantiate,
.detach = mod_detach,
},
}
#define MODULE_MAGIC_INIT
Stop people using different module/library/server versions together.
Definition dl_module.h:63
static const conf_parser_t config[]
Definition base.c:172
static int mod_detach(module_detach_ctx_t const *mctx)
Definition rlm_kv.c:271
static int mod_bootstrap(module_inst_ctx_t const *mctx)
Definition rlm_kv.c:316
static const conf_parser_t module_config[]
Definition rlm_kv.c:80
static int mod_instantiate(module_inst_ctx_t const *mctx)
Definition rlm_kv.c:278

Definition at line 333 of file rlm_kv.c.