The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Defines functions for module (re-)initialisation. More...
#include <freeradius-devel/server/base.h>
#include <freeradius-devel/server/cf_file.h>
#include <freeradius-devel/server/modpriv.h>
#include <freeradius-devel/server/module_rlm.h>
#include <freeradius-devel/server/radmin.h>
#include <freeradius-devel/server/request_data.h>
#include <freeradius-devel/server/module.h>
#include <freeradius-devel/util/strerror.h>
#include <freeradius-devel/unlang/xlat_func.h>
Go to the source code of this file.
Functions | |
static int | _module_global_list_free (UNUSED void *uctx) |
static int | _module_global_list_init (void *uctx) |
static int | _module_instance_free (module_instance_t *mi) |
Free module's instance data, and any xlats or paircmps. More... | |
static int8_t | _module_instance_global_cmp (void const *one, void const *two) |
Sort module instance data first by list then by number. More... | |
static int | _module_list_free (module_list_t *ml) |
Free all modules loaded by the server. More... | |
static int | _module_thread_inst_free (module_thread_instance_t *ti) |
static int | _module_thread_inst_list_free (void *tilp) |
Free the thread local heap on exit. More... | |
static int | cmd_set_module_status (UNUSED FILE *fp, FILE *fp_err, void *ctx, fr_cmd_info_t const *info) |
static int | cmd_show_module_config (FILE *fp, UNUSED FILE *fp_err, void *ctx, UNUSED fr_cmd_info_t const *info) |
static int | cmd_show_module_list (FILE *fp, UNUSED FILE *fp_err, UNUSED void *uctx, UNUSED fr_cmd_info_t const *info) |
static int | cmd_show_module_status (FILE *fp, UNUSED FILE *fp_err, void *ctx, UNUSED fr_cmd_info_t const *info) |
module_instance_t * | module_alloc (module_list_t *ml, module_instance_t const *parent, dl_module_type_t type, char const *mod_name, char const *inst_name) |
Allocate a new module and add it to a module list for later bootstrap/instantiation. More... | |
int | module_bootstrap (module_instance_t *mi) |
Manually complete module bootstrap by calling its instantiate function. More... | |
module_instance_t * | module_by_data (module_list_t const *ml, void const *data) |
Find an existing module instance by its private instance data. More... | |
module_instance_t * | module_by_name (module_list_t const *ml, module_instance_t const *parent, char const *asked_name) |
Find an existing module instance by its name and parent. More... | |
int | module_conf_parse (module_instance_t *mi, CONF_SECTION *mod_conf) |
Parse the configuration associated with a module. More... | |
void | module_free (module_instance_t *mi) |
Explicitly free a module if a fatal error occurs during bootstrap. More... | |
static int8_t | module_instance_data_cmp (void const *one, void const *two) |
Compare module's by their private instance data. More... | |
static fr_slen_t | module_instance_name (TALLOC_CTX *ctx, char **out, module_list_t const *ml, module_instance_t const *parent, char const *inst_name) |
Generate a module name from the module's name and its parents. More... | |
static int8_t | module_instance_name_cmp (void const *one, void const *two) |
Compare module instances by parent and name. More... | |
int | module_instantiate (module_instance_t *instance) |
Manually complete module setup by calling its instantiate function. More... | |
module_list_t * | module_list_alloc (TALLOC_CTX *ctx, char const *name) |
Allocate a new module list. More... | |
static int | module_name_tab_expand (UNUSED TALLOC_CTX *talloc_ctx, UNUSED void *uctx, fr_cmd_info_t *info, int max_expansions, char const **expansions) |
module_instance_t * | module_parent (module_instance_t const *child) |
Find the module's parent (if any) More... | |
module_instance_t * | module_root (module_instance_t const *child) |
Find the module's shallowest parent. More... | |
int | module_submodule_parse (UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule) |
Generic callback for conf_parser_t to load a submodule. More... | |
module_thread_instance_t * | module_thread (module_instance_t *mi) |
Retrieve module/thread specific instance for a module. More... | |
module_thread_instance_t * | module_thread_by_data (module_list_t const *ml, void const *data) |
Retrieve module/thread specific instance data for a module. More... | |
static int | module_thread_instantiate (TALLOC_CTX *ctx, module_thread_instance_t **out, module_list_t const *ml, module_instance_t *mi, fr_event_list_t *el) |
Allocate thread-local instance data for a module. More... | |
int | modules_bootstrap (module_list_t const *ml) |
Bootstrap any modules which have not been bootstrapped already. More... | |
void | modules_init (char const *lib_dir) |
Perform global initialisation for modules. More... | |
int | modules_instantiate (module_list_t const *ml) |
Completes instantiation of modules. More... | |
void | modules_thread_detach (module_list_t const *ml) |
Remove thread-specific data for a given module list. More... | |
int | modules_thread_instantiate (TALLOC_CTX *ctx, module_list_t const *ml, fr_event_list_t *el) |
Creates per-thread instance data for modules which need it. More... | |
Variables | |
return | count |
static dl_module_loader_t * | dl_modules = NULL |
dl module tracking More... | |
fr_cmd_table_t | module_cmd_list_table [] |
fr_cmd_table_t | module_cmd_table [] |
static fr_heap_t * | module_global_inst_list |
Heap of all lists/modules used to get a common index with module_thread_inst_list. More... | |
static _Thread_local bool | module_list_in_sync = true |
Toggle used to determine if it's safe to use index based lookups. More... | |
static _Thread_local module_thread_instance_t ** | module_thread_inst_list |
An array of thread-local module lists. More... | |
return | |
Defines functions for module (re-)initialisation.
Definition in file module.c.
|
static |
|
static |
|
static |
|
static |
Sort module instance data first by list then by number.
The module's position in the global instance heap informs of us of its position in the thread-specific heap, which allows for O(1) lookups.
Definition at line 231 of file module.c.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
module_instance_t* module_alloc | ( | module_list_t * | ml, |
module_instance_t const * | parent, | ||
dl_module_type_t | type, | ||
char const * | mod_name, | ||
char const * | inst_name | ||
) |
Allocate a new module and add it to a module list for later bootstrap/instantiation.
[in] | ml | To add module to. |
[in] | parent | of the module being bootstrapped, if this is a submodule. If this is not a submodule parent must be NULL. |
[in] | type | What type of module we're loading. Determines the prefix added to the library name. Should be one of:
|
[in] | mod_name | The name of this module, i.e. 'redis' for 'rlm_redis'. |
[in] | inst_name | Instance name for this module, i.e. "aws_redis_01". The notable exception is if this is a submodule, in which case inst_name is usually the mod_name. |
Definition at line 976 of file module.c.
int module_bootstrap | ( | module_instance_t * | mi | ) |
Manually complete module bootstrap by calling its instantiate function.
[in] | mi | Module instance to bootstrap. |
Definition at line 788 of file module.c.
module_instance_t* module_by_data | ( | module_list_t const * | ml, |
void const * | data | ||
) |
Find an existing module instance by its private instance data.
[in] | ml | to search in. |
[in] | data | to resolve to module_instance_t. |
Definition at line 438 of file module.c.
module_instance_t* module_by_name | ( | module_list_t const * | ml, |
module_instance_t const * | parent, | ||
char const * | asked_name | ||
) |
Find an existing module instance by its name and parent.
[in] | ml | to search in. |
[in] | parent | to qualify search with. |
[in] | asked_name | The name of the module we're attempting to find. May include '-' which indicates that it's ok for the module not to be loaded. |
Definition at line 367 of file module.c.
int module_conf_parse | ( | module_instance_t * | mi, |
CONF_SECTION * | mod_conf | ||
) |
void module_free | ( | module_instance_t * | mi | ) |
|
static |
|
static |
Generate a module name from the module's name and its parents.
[in] | ctx | Where to allocate the module name. |
[out] | out | Where to write a pointer to the instance name. |
[in] | ml | Module list in which to find the parent. |
[in] | parent | of the module. |
[in] | inst_name | module's instance name. |
Definition at line 857 of file module.c.
|
static |
int module_instantiate | ( | module_instance_t * | instance | ) |
module_list_t* module_list_alloc | ( | TALLOC_CTX * | ctx, |
char const * | name | ||
) |
Allocate a new module list.
This is used to instantiate and destroy modules in distinct phases for example, we may need to load all proto modules before rlm modules.
If the list is freed all module instance data will be freed. If no more instances of the module exist the module be unloaded.
[in] | ctx | To allocate the list in. |
[in] | name | of the list. |
Definition at line 1118 of file module.c.
|
static |
module_instance_t* module_parent | ( | module_instance_t const * | child | ) |
module_instance_t* module_root | ( | module_instance_t const * | child | ) |
int module_submodule_parse | ( | UNUSED TALLOC_CTX * | ctx, |
void * | out, | ||
void * | parent, | ||
CONF_ITEM * | ci, | ||
conf_parser_t const * | rule | ||
) |
Generic callback for conf_parser_t to load a submodule.
conf_parser_t entry should point to a module_instance_t field in the instance data
[in] | ctx | unused. |
[out] | out | A pointer to a pointer to a module_instance_t. |
[in] | parent | This must point to the instance data of the parent module. |
[in] | ci | The CONF_PAIR containing the name of the submodule to load. |
[in] | rule | uctx pointer must be a pointer to a module_list_t ** containing the list to search in. |
Definition at line 311 of file module.c.
module_thread_instance_t* module_thread | ( | module_instance_t * | mi | ) |
Retrieve module/thread specific instance for a module.
[in] | mi | to find thread specific data for. |
Definition at line 459 of file module.c.
module_thread_instance_t* module_thread_by_data | ( | module_list_t const * | ml, |
void const * | data | ||
) |
Retrieve module/thread specific instance data for a module.
[in] | ml | Module list module belongs to. |
[in] | data | Private instance data of the module. Same as what would be provided by module_by_data. |
Definition at line 485 of file module.c.
|
static |
Allocate thread-local instance data for a module.
The majority of modules will have a single set of thread-specific instance data.
An exception is dynamic modules, which may have multiple sets of thread-specific instance data tied to a specific dynamic use of that module.
[in] | ctx | Talloc ctx to bind thread specific data to. |
[out] | out | Where to write the allocated module_thread_instance_t. |
[in] | ml | Module list to perform thread instantiation for. |
[in] | mi | Module instance to perform thread instantiation for. |
[in] | el | Event list serviced by this thread. |
Definition at line 597 of file module.c.
int modules_bootstrap | ( | module_list_t const * | ml | ) |
Bootstrap any modules which have not been bootstrapped already.
Allows the module to initialise connection pools, and complete any registrations that depend on attributes created during the bootstrap phase.
[in] | ml | containing modules to bootstrap. |
Definition at line 830 of file module.c.
void modules_init | ( | char const * | lib_dir | ) |
int modules_instantiate | ( | module_list_t const * | ml | ) |
Completes instantiation of modules.
Allows the module to initialise connection pools, and complete any registrations that depend on attributes created during the bootstrap phase.
[in] | ml | containing modules to instantiate. |
Definition at line 759 of file module.c.
void modules_thread_detach | ( | module_list_t const * | ml | ) |
int modules_thread_instantiate | ( | TALLOC_CTX * | ctx, |
module_list_t const * | ml, | ||
fr_event_list_t * | el | ||
) |
Creates per-thread instance data for modules which need it.
Must be called by any new threads before attempting to execute unlang sections.
[in] | ctx | Talloc ctx to bind thread specific data to. |
[in] | ml | Module list to perform thread instantiation for. |
[in] | el | Event list serviced by this thread. |
Definition at line 663 of file module.c.
|
static |
fr_cmd_table_t module_cmd_list_table[] |
fr_cmd_table_t module_cmd_table[] |
|
static |
Toggle used to determine if it's safe to use index based lookups.
Index based heap lookups are significantly more efficient than binary searches, but they can only be performed when all module data is inserted into both the global module list and the thread local module list.
When we start removing module lists or modules from the thread local heap those heaps no longer have a common index with the global module list so we need to revert back to doing binary searches instead of using common indexes.
|
static |