]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Allow control of triggers for rlm_redis_* using a conf option
authorNick Porter <nick@portercomputing.co.uk>
Tue, 26 Aug 2025 16:12:26 +0000 (17:12 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Tue, 26 Aug 2025 16:21:03 +0000 (17:21 +0100)
src/lib/redis/base.h
src/lib/redis/cluster.c
src/lib/redis/cluster.h
src/modules/rlm_cache/drivers/rlm_cache_redis/rlm_cache_redis.c
src/modules/rlm_redis/rlm_redis.c
src/modules/rlm_redis_ippool/rlm_redis_ippool.c
src/modules/rlm_redis_ippool/rlm_redis_ippool_tool.c
src/modules/rlm_rediswho/rlm_rediswho.c

index cab25800cb164b423c26f821fbe40bb32e3970e6..0dbda0a425b8279358bc1269912faad0c128e0ee 100644 (file)
@@ -128,6 +128,8 @@ typedef struct {
        fr_time_delta_t         reconnection_delay;
 
        char const              *log_prefix;
+
+       bool                    triggers;       //!< Do we run triggers.
 } fr_redis_conf_t;
 
 #define REDIS_COMMON_CONFIG \
@@ -140,7 +142,8 @@ typedef struct {
        { FR_CONF_OFFSET_FLAGS("password", CONF_FLAG_SECRET, fr_redis_conf_t, password) }, \
        { FR_CONF_OFFSET("max_nodes", fr_redis_conf_t, max_nodes), .dflt = "20" }, \
        { FR_CONF_OFFSET("max_alt", fr_redis_conf_t, max_alt), .dflt = "3" }, \
-       { FR_CONF_OFFSET("max_redirects", fr_redis_conf_t, max_redirects), .dflt = "2" }
+       { FR_CONF_OFFSET("max_redirects", fr_redis_conf_t, max_redirects), .dflt = "2" }, \
+       { FR_CONF_OFFSET("triggers", fr_redis_conf_t, triggers) }
 
 void           fr_redis_version_print(void);
 
index 4455d5030956bc4982faeb8f8e0a689946b152fd..170abdcc6b66d1f00dd83ca6afe703e78d6421e0 100644 (file)
@@ -2249,7 +2249,6 @@ bool fr_redis_cluster_min_version(fr_redis_cluster_t *cluster, char const *min_v
  * @param module               Configuration section to search for 'server' conf pairs in.
  * @param conf                 Base redis server configuration. Cluster nodes share database
  *                             number and password.
- * @param triggers_enabled     Whether triggers should be enabled.
  * @param log_prefix           Custom log prefix.  Defaults to @verbatim rlm_<module> (<instance>) @endverbatim.
  * @param trigger_prefix       Custom trigger prefix.  Defaults to @verbatim modules.<module>.pool @endverbatim.
  * @param trigger_args         Argument pairs to pass to the trigger in addition to Connection-Pool-Server,
@@ -2261,7 +2260,6 @@ bool fr_redis_cluster_min_version(fr_redis_cluster_t *cluster, char const *min_v
 fr_redis_cluster_t *fr_redis_cluster_alloc(TALLOC_CTX *ctx,
                                           CONF_SECTION *module,
                                           fr_redis_conf_t *conf,
-                                          bool triggers_enabled,
                                           char const *log_prefix,
                                           char const *trigger_prefix,
                                           fr_pair_list_t *trigger_args)
@@ -2277,16 +2275,13 @@ fr_redis_cluster_t *fr_redis_cluster_alloc(TALLOC_CTX *ctx,
        uint64_t                num_nodes;
        fr_redis_cluster_t      *cluster;
 
-       fr_assert(triggers_enabled || !trigger_prefix);
-       fr_assert(triggers_enabled || (!trigger_args || fr_pair_list_empty(trigger_args)));
-
        MEM(cluster = talloc_zero(NULL, fr_redis_cluster_t));
        fr_pair_list_init(&cluster->trigger_args);
 
        cs_name1 = cf_section_name1(module);
        cs_name2 = cf_section_name2(module);
 
-       cluster->triggers_enabled = triggers_enabled;
+       cluster->triggers_enabled = conf->triggers;
        if (cluster->triggers_enabled) {
                /*
                 *      Setup trigger prefix
index f0a0aaf99fa4c22e26d1d8c7a71b3257c6e0a39a..c9c6382c46b0e9078776925824809660edb2bb75 100644 (file)
@@ -131,7 +131,6 @@ bool fr_redis_cluster_min_version(fr_redis_cluster_t *cluster, char const *min_v
 fr_redis_cluster_t *fr_redis_cluster_alloc(TALLOC_CTX *ctx,
                                           CONF_SECTION *module,
                                           fr_redis_conf_t *conf,
-                                          bool enable_triggers,
                                           char const *log_prefix,
                                           char const *trigger_prefix,
                                           fr_pair_list_t *trigger_args);
index f5036d8391adcaa88af7bf83f354a869dc1c270d..b6d04492dffd03d183423d843752b323fd2d0b93 100644 (file)
@@ -77,7 +77,7 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
 
        snprintf(buffer, sizeof(buffer), "rlm_cache (%s)", mctx->mi->parent->name);
 
-       driver->cluster = fr_redis_cluster_alloc(driver, mctx->mi->conf, &driver->conf, true,
+       driver->cluster = fr_redis_cluster_alloc(driver, mctx->mi->conf, &driver->conf,
                                                 buffer, "modules.cache.pool", NULL);
        if (!driver->cluster) {
                ERROR("Cluster failure");
index 6521d08d88511f6e055114742afd0f2217d4da19..07083e555fa6042a11beb86b0d1c05cf30f6380d 100644 (file)
@@ -792,7 +792,7 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
        fr_socket_t *nodes;
        int ret, i;
 
-       inst->cluster = fr_redis_cluster_alloc(inst, mctx->mi->conf, &inst->conf, true, NULL, NULL, NULL);
+       inst->cluster = fr_redis_cluster_alloc(inst, mctx->mi->conf, &inst->conf, NULL, NULL, NULL);
        if (!inst->cluster) return -1;
 
        /*
index 4c7ffb465ddf0aea90127179634231fa5519c5ee..ecb2cb033c4fd697462fd44d2ab6fe4120ce11dd 100644 (file)
@@ -1243,7 +1243,7 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
 
        fr_assert(subcs);
 
-       inst->cluster = fr_redis_cluster_alloc(inst, subcs, &inst->conf, true, NULL, NULL, NULL);
+       inst->cluster = fr_redis_cluster_alloc(inst, subcs, &inst->conf, NULL, NULL, NULL);
        if (!inst->cluster) return -1;
 
        if (!fr_redis_cluster_min_version(inst->cluster, "3.0.2")) {
index ecc4d12e4649e7c9fb6a10bc6f93c979f9f9bc71..b49be5f3f3df9e76fd6c60eb9359dad8460aa79b 100644 (file)
@@ -1266,7 +1266,11 @@ static int driver_init(TALLOC_CTX *ctx, CONF_SECTION *conf, void **instance)
                return -1;
        }
 
-       this->cluster = fr_redis_cluster_alloc(this, conf, &this->conf, false,
+       /*
+        *  Triggers won't work from the tool
+        */
+       this->conf.triggers = false;
+       this->cluster = fr_redis_cluster_alloc(this, conf, &this->conf,
                                               "rlm_redis_ippool_tool", NULL, NULL);
        if (!this->cluster) {
                talloc_free(this);
index 9d14adc7d2cfd1d02fad09b2a43e6b117d2d95e8..1febd0008ebcd104af4364945030daee460eb54d 100644 (file)
@@ -243,7 +243,7 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
        rlm_rediswho_t  *inst = talloc_get_type_abort(mctx->mi->data, rlm_rediswho_t);
        CONF_SECTION    *conf = mctx->mi->conf;
 
-       inst->cluster = fr_redis_cluster_alloc(inst, conf, &inst->conf, true, NULL, NULL, NULL);
+       inst->cluster = fr_redis_cluster_alloc(inst, conf, &inst->conf, NULL, NULL, NULL);
        if (!inst->cluster) return -1;
 
        return 0;