]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
use macro for common case
authorAlan T. DeKok <aland@freeradius.org>
Thu, 17 Jul 2025 16:56:09 +0000 (12:56 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 17 Jul 2025 19:37:21 +0000 (15:37 -0400)
some instructions didn't return on timeout.  So using a common
initializer is beneficial

src/lib/unlang/call.c
src/lib/unlang/finally.c
src/lib/unlang/function.c
src/lib/unlang/interpret.c
src/lib/unlang/mod_action.h
src/lib/unlang/module.c
src/lib/unlang/timeout.c
src/lib/unlang/tmpl.c
src/lib/unlang/xlat.c

index e0248321391729faf892e31958620fd596520db3..756e959fa30a28280218ba7dafa58620d68e85b9 100644 (file)
@@ -181,20 +181,7 @@ unlang_action_t unlang_call_push(unlang_result_t *p_result, request_t *request,
                                .name = name,
                                .debug_name = name,
                                .ci = CF_TO_ITEM(server_cs),
-                               .actions = {
-                                       .actions = {
-                                               [RLM_MODULE_REJECT]     = 0,
-                                               [RLM_MODULE_FAIL]       = MOD_ACTION_RETURN,    /* Exit out of nested levels */
-                                               [RLM_MODULE_OK]         = 0,
-                                               [RLM_MODULE_HANDLED]    = 0,
-                                               [RLM_MODULE_INVALID]    = 0,
-                                               [RLM_MODULE_DISALLOW]   = 0,
-                                               [RLM_MODULE_NOTFOUND]   = 0,
-                                               [RLM_MODULE_NOOP]       = 0,
-                                               [RLM_MODULE_UPDATED]    = 0
-                                       },
-                                       .retry = RETRY_INIT,
-                               },
+                               .actions = MOD_ACTIONS_FAIL_TIMEOUT_RETURN,
                        },
 
                        .cs = server_cs,
index 7c23b8ca43303c1ecf8d7d20e9603e6ce2a87dd5..ec4205bed0deff3a27bed6a630e836db68a7ad95 100644 (file)
@@ -134,21 +134,7 @@ int unlang_finally_push_instruction(request_t *request, void *instruction, fr_ti
                .type = UNLANG_TYPE_FINALLY,
                .name = "finally",
                .debug_name = "finally",
-               .actions = {
-                       .actions = {
-                               [RLM_MODULE_REJECT]     = 0,
-                               [RLM_MODULE_FAIL]       = MOD_ACTION_RETURN,    /* Exit out of nested levels */
-                               [RLM_MODULE_OK]         = 0,
-                               [RLM_MODULE_HANDLED]    = 0,
-                               [RLM_MODULE_INVALID]    = 0,
-                               [RLM_MODULE_DISALLOW]   = 0,
-                               [RLM_MODULE_NOTFOUND]   = 0,
-                               [RLM_MODULE_NOOP]       = 0,
-                               [RLM_MODULE_TIMEOUT]    = MOD_ACTION_RETURN,    /* Exit out of nested levels */
-                               [RLM_MODULE_UPDATED]    = 0
-                       },
-                       .retry = RETRY_INIT,
-               },
+               .actions = MOD_ACTIONS_FAIL_TIMEOUT_RETURN,
        };
 
        unlang_frame_state_finally_t    *state;
index b4ea4a795d817ac19a7be05710011892151371fd..7c8dc1174b0cb1ccc14088ac2ed07cffc5aac71b 100644 (file)
@@ -62,28 +62,7 @@ static unlang_t function_instruction = {
        .type = UNLANG_TYPE_FUNCTION,
        .name = "function",
        .debug_name = "function",
-       .actions = {
-               /*
-                *      By default, functions don't change the section rcode.
-                *      We can't make generalisations about what the intent
-                *      of the function callbacks are, so isntead of having
-                *      implicit, confusing behaviour, we always discard the
-                *      rcode UNLESS the function explicitly sets it.
-                */
-               .actions = {
-                       [RLM_MODULE_REJECT]     = MOD_ACTION_NOT_SET,
-                       [RLM_MODULE_FAIL]       = MOD_ACTION_NOT_SET,
-                       [RLM_MODULE_OK]         = MOD_ACTION_NOT_SET,
-                       [RLM_MODULE_HANDLED]    = MOD_ACTION_NOT_SET,
-                       [RLM_MODULE_INVALID]    = MOD_ACTION_NOT_SET,
-                       [RLM_MODULE_DISALLOW]   = MOD_ACTION_NOT_SET,
-                       [RLM_MODULE_NOTFOUND]   = MOD_ACTION_NOT_SET,
-                       [RLM_MODULE_NOOP]       = MOD_ACTION_NOT_SET,
-                       [RLM_MODULE_UPDATED]    = MOD_ACTION_NOT_SET,
-                       [RLM_MODULE_TIMEOUT]    = MOD_ACTION_NOT_SET
-               },
-               .retry = RETRY_INIT,
-       }
+       .actions = DEFAULT_MOD_ACTIONS,
 };
 
 /** Generic signal handler
index 7048073f5686995b2ec409791da42598d30bbbaf..139408b67ee2c16e0e038a0ada97e195c031fb17 100644 (file)
@@ -1212,28 +1212,7 @@ void *unlang_interpret_stack_alloc(TALLOC_CTX *ctx)
         */
        static unlang_t unlang_instruction = {
                .debug_name = "top",
-               .actions = {
-                       /*
-                       *       By default, functions don't change the section rcode.
-                       *       We can't make generalisations about what the intent
-                       *       of the function callbacks are, so isntead of having
-                       *       implicit, confusing behaviour, we always discard the
-                       *       rcode UNLESS the function explicitly sets it.
-                       */
-                       .actions = {
-                               [RLM_MODULE_REJECT]     = MOD_ACTION_NOT_SET,
-                               [RLM_MODULE_FAIL]       = MOD_ACTION_NOT_SET,
-                               [RLM_MODULE_OK]         = MOD_ACTION_NOT_SET,
-                               [RLM_MODULE_HANDLED]    = MOD_ACTION_NOT_SET,
-                               [RLM_MODULE_INVALID]    = MOD_ACTION_NOT_SET,
-                               [RLM_MODULE_DISALLOW]   = MOD_ACTION_NOT_SET,
-                               [RLM_MODULE_NOTFOUND]   = MOD_ACTION_NOT_SET,
-                               [RLM_MODULE_NOOP]       = MOD_ACTION_NOT_SET,
-                               [RLM_MODULE_UPDATED]    = MOD_ACTION_NOT_SET,
-                               [RLM_MODULE_TIMEOUT]    = MOD_ACTION_NOT_SET
-                       },
-                       .retry = RETRY_INIT
-               }
+               .actions = DEFAULT_MOD_ACTIONS,
        };
 
        unlang_stack_t *stack;
index 033ff29ca7c65aa5824fcb5e6607fda7a335d127..23fadd2f8d3b972c94873ec7d715b87774cf26c6 100644 (file)
@@ -66,6 +66,7 @@ typedef struct {
 } unlang_mod_actions_t;
 
 #define DEFAULT_MOD_ACTIONS { .actions = {}, .retry = RETRY_INIT }
+#define MOD_ACTIONS_FAIL_TIMEOUT_RETURN { .actions = { [RLM_MODULE_FAIL] = MOD_ACTION_RETURN, [RLM_MODULE_TIMEOUT] = MOD_ACTION_RETURN,}, .retry = RETRY_INIT }
 
 extern unlang_mod_actions_t const mod_actions_authenticate;
 extern unlang_mod_actions_t const mod_actions_authorize;
index 7b4bae2647393118ce226b05434b54002f86ec73..2cf5869044a6517c4d05c33e7dc15e69ae32e2dd 100644 (file)
@@ -66,21 +66,7 @@ int unlang_module_push(unlang_result_t *p_result, request_t *request,
                        .type = UNLANG_TYPE_MODULE,
                        .name = mi->name,
                        .debug_name = mi->name,
-                       .actions = {
-                               .actions = {
-                                       [RLM_MODULE_REJECT]     = 0,
-                                       [RLM_MODULE_FAIL]       = MOD_ACTION_RETURN,    /* Exit out of nested levels */
-                                       [RLM_MODULE_OK]         = 0,
-                                       [RLM_MODULE_HANDLED]    = 0,
-                                       [RLM_MODULE_INVALID]    = 0,
-                                       [RLM_MODULE_DISALLOW]   = 0,
-                                       [RLM_MODULE_NOTFOUND]   = 0,
-                                       [RLM_MODULE_NOOP]       = 0,
-                                       [RLM_MODULE_UPDATED]    = 0,
-                                       [RLM_MODULE_TIMEOUT]    = MOD_ACTION_RETURN,    /* Exit out of nested levels */
-                               },
-                               .retry = RETRY_INIT,
-                       },
+                       .actions = MOD_ACTIONS_FAIL_TIMEOUT_RETURN,
                },
                .mmc = {
                        .mi = mi,
index d7fcdb50745832a3c555a42b4936d25332009abd..2a85cb4636fc9d7932d0e51083c9434aab89012f 100644 (file)
@@ -203,21 +203,7 @@ int unlang_timeout_section_push(request_t *request, CONF_SECTION *cs, fr_time_de
                .type = UNLANG_TYPE_TIMEOUT,
                .name = "timeout",
                .debug_name = "timeout",
-               .actions = {
-                       .actions = {
-                               [RLM_MODULE_REJECT]     = 0,
-                               [RLM_MODULE_FAIL]       = MOD_ACTION_RETURN,    /* Exit out of nested levels */
-                               [RLM_MODULE_OK]         = 0,
-                               [RLM_MODULE_HANDLED]    = 0,
-                               [RLM_MODULE_INVALID]    = 0,
-                               [RLM_MODULE_DISALLOW]   = 0,
-                               [RLM_MODULE_NOTFOUND]   = 0,
-                               [RLM_MODULE_NOOP]       = 0,
-                               [RLM_MODULE_TIMEOUT]    = MOD_ACTION_RETURN,    /* Exit out of nested levels */
-                               [RLM_MODULE_UPDATED]    = 0
-                       },
-                       .retry = RETRY_INIT,
-               },
+               .actions = MOD_ACTIONS_FAIL_TIMEOUT_RETURN,
        };
 
        unlang_frame_state_timeout_t    *state;
index c005709578a4e4c550cc078c1dd584e1ae75dc39..f16ff49da7c4e8c30fa5e7001634a8a8b0e6f708 100644 (file)
@@ -283,20 +283,7 @@ int unlang_tmpl_push(TALLOC_CTX *ctx, unlang_result_t *p_result, fr_value_box_li
                .type = UNLANG_TYPE_TMPL,
                .name = "tmpl",
                .debug_name = "tmpl",
-               .actions = {
-                       .actions = {
-                               [RLM_MODULE_REJECT]     = 0,
-                               [RLM_MODULE_FAIL]       = MOD_ACTION_RETURN,
-                               [RLM_MODULE_OK]         = 0,
-                               [RLM_MODULE_HANDLED]    = 0,
-                               [RLM_MODULE_INVALID]    = 0,
-                               [RLM_MODULE_DISALLOW]   = 0,
-                               [RLM_MODULE_NOTFOUND]   = 0,
-                               [RLM_MODULE_NOOP]       = 0,
-                               [RLM_MODULE_UPDATED]    = 0
-                       },
-                       .retry = RETRY_INIT,
-               },
+               .actions = MOD_ACTIONS_FAIL_TIMEOUT_RETURN,
        };
 
        static const unlang_t tmpl_instruction_fail = {
index ccdab7b4344b8dca37df8bb3fe4c6bd5d751d1c4..6c18582583b830f5f0da0ac927cf464a382d3478 100644 (file)
@@ -208,20 +208,7 @@ static int unlang_xlat_push_internal(TALLOC_CTX *ctx, unlang_result_t *p_result,
                .type = UNLANG_TYPE_XLAT,
                .name = "xlat",
                .debug_name = "xlat",
-               .actions = {
-                       .actions = {
-                               [RLM_MODULE_REJECT]     = 0,
-                               [RLM_MODULE_FAIL]       = MOD_ACTION_RETURN,    /* Exit out of nested levels */
-                               [RLM_MODULE_OK]         = 0,
-                               [RLM_MODULE_HANDLED]    = 0,
-                               [RLM_MODULE_INVALID]    = 0,
-                               [RLM_MODULE_DISALLOW]   = 0,
-                               [RLM_MODULE_NOTFOUND]   = 0,
-                               [RLM_MODULE_NOOP]       = 0,
-                               [RLM_MODULE_UPDATED]    = 0
-                       },
-                       .retry = RETRY_INIT,
-               },
+               .actions = MOD_ACTIONS_FAIL_TIMEOUT_RETURN,
        };
 
        unlang_frame_state_xlat_t       *state;