![]() |
The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
IP Allocation module with a redis backend. More...
#include <freeradius-devel/server/base.h>#include <freeradius-devel/server/module_rlm.h>#include <freeradius-devel/server/modpriv.h>#include <freeradius-devel/util/debug.h>#include <freeradius-devel/util/base16.h>#include <freeradius-devel/util/token.h>#include <freeradius-devel/redis/base.h>#include <freeradius-devel/redis/cluster.h>#include <freeradius-devel/unlang/call_env.h>#include "redis_ippool.h"
Include dependency graph for rlm_redis_ippool.c:Go to the source code of this file.
Data Structures | |
| struct | redis_ippool_alloc_call_env_t |
| Call environment used when calling redis_ippool allocate method. More... | |
| struct | redis_ippool_bulk_release_call_env_t |
| Call environment used when calling redis_ippool bulk release method. More... | |
| struct | redis_ippool_release_call_env_t |
| Call environment used when calling redis_ippool release method. More... | |
| struct | redis_ippool_update_call_env_t |
| Call environment used when calling redis_ippool update method. More... | |
| struct | rlm_redis_ippool_t |
| rlm_redis module instance More... | |
Macros | |
| #define | CHECK_POOL_NAME |
| #define | EOL "\n" |
Functions | |
| static void | ippool_action_print (request_t *request, ippool_action_t action, fr_log_lvl_t lvl, fr_value_box_t const *key_prefix, fr_value_box_t const *ip, fr_value_box_t const *owner, fr_value_box_t const *gateway_id, uint32_t expires) |
| static fr_redis_rcode_t | ippool_script (redisReply **out, request_t *request, fr_redis_cluster_t *cluster, uint8_t const *key, size_t key_len, uint32_t wait_num, fr_time_delta_t wait_timeout, char const digest[], char const *script, char const *cmd,...) |
| Execute a script against Redis cluster. | |
| static int | ippool_wait_check (request_t *request, uint32_t wait_num, redisReply *reply) |
| Check the requisite number of slaves replicated the lease info. | |
| static unlang_action_t | mod_alloc (unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request) |
| static unlang_action_t | mod_bulk_release (unlang_result_t *p_result, UNUSED module_ctx_t const *mctx, request_t *request) |
| static int | mod_instantiate (module_inst_ctx_t const *mctx) |
| static int | mod_load (void) |
| static unlang_action_t | mod_release (unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request) |
| static unlang_action_t | mod_update (unlang_result_t *p_result, module_ctx_t const *mctx, request_t *request) |
| static ippool_rcode_t | redis_ippool_allocate (rlm_redis_ippool_t const *inst, request_t *request, redis_ippool_alloc_call_env_t *env, uint32_t lease_time) |
| Allocate a new IP address from a pool. | |
| static ippool_rcode_t | redis_ippool_release (rlm_redis_ippool_t const *inst, request_t *request, fr_value_box_t const *key_prefix, fr_ipaddr_t *ip, fr_value_box_t const *owner) |
| Release an existing IP address in a pool. | |
| static ippool_rcode_t | redis_ippool_update (rlm_redis_ippool_t const *inst, request_t *request, redis_ippool_update_call_env_t *env, fr_ipaddr_t *ip, fr_value_box_t const *owner, fr_value_box_t const *gateway_id, uint32_t expires) |
| Update an existing IP address in a pool. | |
Variables | |
| static char | lua_alloc_cmd [] |
| Lua script for allocating new leases. | |
| static char | lua_alloc_digest [(SHA1_DIGEST_LENGTH *2)+1] |
| static char | lua_release_cmd [] |
| Lua script for releasing leases. | |
| static char | lua_release_digest [(SHA1_DIGEST_LENGTH *2)+1] |
| static char | lua_update_cmd [] |
| Lua script for updating leases. | |
| static char | lua_update_digest [(SHA1_DIGEST_LENGTH *2)+1] |
| static conf_parser_t | module_config [] |
| static conf_parser_t | redis_config [] |
| static const call_env_method_t | redis_ippool_alloc_method_env |
| static const call_env_method_t | redis_ippool_bulk_release_method_env |
| static const call_env_method_t | redis_ippool_release_method_env |
| static const call_env_method_t | redis_ippool_update_method_env |
| module_rlm_t | rlm_redis_ippool |
IP Allocation module with a redis backend.
Performs lease management using a Redis backed.
Creates three types of objects:
{<pool name>:<pool type>}:pool (zset) contains IP addresses with priority set by expiry time.{<pool name>:<pool type>}:ip:<address> (hash) contains four keys{<pool name>:<pool type>}:device:<client id> (string) contains last IP address bound by this client.Definition in file rlm_redis_ippool.c.
| struct redis_ippool_alloc_call_env_t |
Call environment used when calling redis_ippool allocate method.
Definition at line 108 of file rlm_redis_ippool.c.
Collaboration diagram for redis_ippool_alloc_call_env_t:| Data Fields | ||
|---|---|---|
| tmpl_t * | allocated_address_attr | Attribute to populate with allocated IP. |
| tmpl_t * | expiry_attr | Time at which the lease will expire. |
| fr_value_box_t | gateway_id |
Gateway identifier, usually NAS-Identifier or Option 82 gateway. Used for bulk lease cleanups. |
| fr_value_box_t | lease_time | How long an IP address should be allocated for. |
| fr_value_box_t | offer_time | How long we should reserve a lease for during the pre-allocation stage (typically responding to DHCP discover). |
| fr_value_box_t | owner |
Unique lease owner identifier. Could be mac-address or a combination of User-Name and something unique to the device. |
| fr_value_box_t | pool_name | Name of the pool we're allocating IP addresses from. |
| tmpl_t * | range_attr | Attribute to write the range ID to. |
| fr_value_box_t | requested_address | Attribute to read the IP for renewal from. |
| struct redis_ippool_bulk_release_call_env_t |
Call environment used when calling redis_ippool bulk release method.
Definition at line 177 of file rlm_redis_ippool.c.
Collaboration diagram for redis_ippool_bulk_release_call_env_t:| Data Fields | ||
|---|---|---|
| fr_value_box_t | gateway_id |
Gateway identifier, usually NAS-Identifier or Option 82 gateway. Used for bulk lease cleanups. |
| fr_value_box_t | pool_name | Name of the pool we're allocating IP addresses from. |
| struct redis_ippool_release_call_env_t |
Call environment used when calling redis_ippool release method.
Definition at line 160 of file rlm_redis_ippool.c.
Collaboration diagram for redis_ippool_release_call_env_t:| Data Fields | ||
|---|---|---|
| fr_value_box_t | gateway_id |
Gateway identifier, usually NAS-Identifier or Option 82 gateway. Used for bulk lease cleanups. |
| fr_value_box_t | owner |
Unique lease owner identifier. Could be mac-address or a combination of User-Name and something unique to the device. |
| fr_value_box_t | pool_name | Name of the pool we're allocating IP addresses from. |
| fr_value_box_t | requested_address | Attribute to read the IP for renewal from. |
| struct redis_ippool_update_call_env_t |
Call environment used when calling redis_ippool update method.
Definition at line 136 of file rlm_redis_ippool.c.
Collaboration diagram for redis_ippool_update_call_env_t:| Data Fields | ||
|---|---|---|
| tmpl_t * | allocated_address_attr | Attribute to populate with allocated IP. |
| tmpl_t * | expiry_attr | Time at which the lease will expire. |
| fr_value_box_t | gateway_id |
Gateway identifier, usually NAS-Identifier or Option 82 gateway. Used for bulk lease cleanups. |
| fr_value_box_t | lease_time | How long an IP address should be allocated for. |
| fr_value_box_t | owner |
Unique lease owner identifier. Could be mac-address or a combination of User-Name and something unique to the device. |
| fr_value_box_t | pool_name | Name of the pool we're allocating IP addresses from. |
| tmpl_t * | range_attr | Attribute to write the range ID to. |
| fr_value_box_t | requested_address | Attribute to read the IP for renewal from. |
| struct rlm_redis_ippool_t |
rlm_redis module instance
Definition at line 61 of file rlm_redis_ippool.c.
Collaboration diagram for rlm_redis_ippool_t:| Data Fields | ||
|---|---|---|
| fr_redis_cluster_t * | cluster | Redis cluster. |
| fr_redis_conf_t | conf |
Connection parameters for the Redis server. Must be first field in this struct. |
| bool | copy_on_update | Copy the address provided by ip_address to the allocated_address_attr if updates are successful. |
| bool | ipv4_integer | Whether IPv4 addresses should be cast to integers, for renew operations. |
| char const * | name | Instance name. |
| uint32_t | wait_num | How many slaves we want to acknowledge allocations or updates. |
| fr_time_delta_t | wait_timeout | How long we wait for slaves to acknowledge writing. |
| #define CHECK_POOL_NAME |
Definition at line 1090 of file rlm_redis_ippool.c.
| #define EOL "\n" |
Definition at line 246 of file rlm_redis_ippool.c.
|
static |
Definition at line 484 of file rlm_redis_ippool.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Execute a script against Redis cluster.
Handles uploading the script to the server if required.
| [out] | out | Where to write Redis reply object resulting from the command. |
| [in] | request | The current request. |
| [in] | cluster | configuration. |
| [in] | key | to use to determine the cluster node. |
| [in] | key_len | length of the key. |
| [in] | wait_num | If > 0 wait until this many slaves have replicated the data from the last command. |
| [in] | wait_timeout | How long to wait for slaves to replicate the data. |
| [in] | digest | of script. |
| [in] | script | to upload. |
| [in] | cmd | EVALSHA command to execute. |
| [in] | ... | Arguments for the eval command. |
Definition at line 559 of file rlm_redis_ippool.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlinestatic |
Check the requisite number of slaves replicated the lease info.
| request | The current request. |
| wait_num | Number of slaves required. |
| reply | we got from the server. |
Definition at line 467 of file rlm_redis_ippool.c.
Here is the caller graph for this function:
|
static |
|
static |
Definition at line 1230 of file rlm_redis_ippool.c.
|
static |
|
static |
|
static |
|
static |
|
static |
Allocate a new IP address from a pool.
Definition at line 696 of file rlm_redis_ippool.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Release an existing IP address in a pool.
Definition at line 1015 of file rlm_redis_ippool.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Update an existing IP address in a pool.
Definition at line 878 of file rlm_redis_ippool.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Lua script for allocating new leases.
Returns
{ <rcode>[, <ip>][, <range>][, <lease time>][, <counter>] } Definition at line 260 of file rlm_redis_ippool.c.
|
static |
Definition at line 331 of file rlm_redis_ippool.c.
|
static |
Lua script for releasing leases.
Sets the expiry time to be NOW() - 1 to maximise time between IP address allocations.
Returns
array { <rcode>[, <counter>] } Definition at line 416 of file rlm_redis_ippool.c.
|
static |
Definition at line 456 of file rlm_redis_ippool.c.
|
static |
Lua script for updating leases.
Returns
array { <rcode>[, <range>] } Definition at line 348 of file rlm_redis_ippool.c.
|
static |
Definition at line 399 of file rlm_redis_ippool.c.
|
static |
Definition at line 86 of file rlm_redis_ippool.c.
|
static |
Definition at line 81 of file rlm_redis_ippool.c.
|
static |
Definition at line 184 of file rlm_redis_ippool.c.
|
static |
Definition at line 236 of file rlm_redis_ippool.c.
|
static |
Definition at line 223 of file rlm_redis_ippool.c.
|
static |
Definition at line 205 of file rlm_redis_ippool.c.
| module_rlm_t rlm_redis_ippool |
Definition at line 1288 of file rlm_redis_ippool.c.
1.9.8