]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
push more things to rlm_radius_udp
authorAlan T. DeKok <aland@freeradius.org>
Wed, 27 Nov 2024 19:39:25 +0000 (14:39 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 29 Nov 2024 14:15:10 +0000 (09:15 -0500)
in preparation for BIO handling

src/modules/rlm_radius/rlm_radius.c
src/modules/rlm_radius/rlm_radius.h
src/modules/rlm_radius/rlm_radius_udp.c

index 81ed6af31508a99cfc37180f7fee41bf863d9260..8cee28ddfed8439fc2efbd485218731dc6119608 100644 (file)
@@ -335,25 +335,6 @@ static int status_check_update_parse(TALLOC_CTX *ctx, void *out, UNUSED void *pa
 }
 
 
-static void mod_radius_signal(module_ctx_t const *mctx, request_t *request, fr_signal_t action)
-{
-       rlm_radius_t const      *inst = talloc_get_type_abort_const(mctx->mi->data, rlm_radius_t);
-       rlm_radius_io_t const   *io = (rlm_radius_io_t const *)inst->io_submodule->exported;            /* Public symbol exported by the module */
-
-       /*
-        *      We received a duplicate packet, but we're not doing
-        *      synchronous proxying.  Ignore the dup, and rely on the
-        *      IO submodule to time it's own retransmissions.
-        */
-       if ((action == FR_SIGNAL_DUP) && !inst->synchronous) return;
-
-       if (!io->signal) return;
-
-       io->signal(MODULE_CTX(inst->io_submodule,
-                             module_thread(inst->io_submodule)->data, mctx->env_data,
-                             mctx->rctx), request, action);
-}
-
 /** Do any RADIUS-layer fixups for proxying.
  *
  */
@@ -396,11 +377,8 @@ static unlang_action_t CC_HINT(nonnull) mod_process(rlm_rcode_t *p_result, modul
 {
        rlm_radius_t const      *inst = talloc_get_type_abort_const(mctx->mi->data, rlm_radius_t);
        rlm_rcode_t             rcode;
-       unlang_action_t         ua;
        fr_client_t             *client;
 
-       void                    *rctx = NULL;
-
        if (!request->packet->code) {
                REDEBUG("You MUST specify a packet code");
                RETURN_MODULE_FAIL;
@@ -447,14 +425,8 @@ static unlang_action_t CC_HINT(nonnull) mod_process(rlm_rcode_t *p_result, modul
         *      return another code which indicates what happened to
         *      the request...
         */
-       ua = inst->io->enqueue(&rcode, &rctx, inst->io_submodule->data,
-                              module_thread(inst->io_submodule)->data, request);
-       if (ua != UNLANG_ACTION_YIELD) {
-               fr_assert(rctx == NULL);
-               RETURN_MODULE_RCODE(rcode);
-       }
-
-       return unlang_module_yield(request, inst->io->resume, mod_radius_signal, 0, rctx);
+       return inst->io->enqueue(&rcode, inst->io_submodule->data,
+                                module_thread(inst->io_submodule)->data, request);
 }
 
 static int mod_instantiate(module_inst_ctx_t const *mctx)
index 3ef8c8b87db7022880844b17e4be49dbb2d71016..bc14e6e0e793c39097e3fa7c8b260694ac408e1a 100644 (file)
@@ -75,7 +75,7 @@ struct rlm_radius_s {
 /** Enqueue a request_t to an IO submodule
  *
  */
-typedef unlang_action_t (*rlm_radius_io_enqueue_t)(rlm_rcode_t *p_result, void **rctx, void *instance, void *thread, request_t *request);
+typedef unlang_action_t (*rlm_radius_io_enqueue_t)(rlm_rcode_t *p_result, void *instance, void *thread, request_t *request);
 
 /** Public structure describing an I/O path for an outgoing socket.
  *
@@ -84,6 +84,4 @@ typedef unlang_action_t (*rlm_radius_io_enqueue_t)(rlm_rcode_t *p_result, void *
 struct rlm_radius_io_s {
        module_t                common;                 //!< Common fields to all loadable modules.
        rlm_radius_io_enqueue_t enqueue;                //!< Enqueue a request_t with an IO submodule.
-       unlang_module_signal_t  signal;                 //!< Send a signal to an IO module.
-       module_method_t resume;                 //!< Resume a request, and get rcode.
 };
index aabc07be690e2376cc46eceb382d3ab6d60c1b99..e4e951321f84b1ce91972cf958d1bf6b5264f0b5 100644 (file)
@@ -2437,9 +2437,18 @@ static unlang_action_t mod_resume(rlm_rcode_t *p_result, module_ctx_t const *mct
 
 static void mod_signal(module_ctx_t const *mctx, UNUSED request_t *request, fr_signal_t action)
 {
-       udp_thread_t            *t = talloc_get_type_abort(mctx->thread, udp_thread_t);
+       rlm_radius_t const      *inst = talloc_get_type_abort_const(mctx->mi->data, rlm_radius_t);
+
+       udp_thread_t            *t = talloc_get_type_abort(module_thread(inst->io_submodule)->data, udp_thread_t);
        udp_result_t            *r = talloc_get_type_abort(mctx->rctx, udp_result_t);
 
+       /*
+        *      We received a duplicate packet, but we're not doing
+        *      synchronous proxying.  Ignore the dup, and rely on the
+        *      IO submodule to time it's own retransmissions.
+        */
+       if ((action == FR_SIGNAL_DUP) && !inst->synchronous) return;
+
        /*
         *      If we don't have a treq associated with the
         *      rctx it's likely because the request was
@@ -2526,7 +2535,7 @@ static int _udp_request_free(udp_request_t *u)
        return 0;
 }
 
-static unlang_action_t mod_enqueue(rlm_rcode_t *p_result, void **rctx_out, void *instance, void *thread, request_t *request)
+static unlang_action_t mod_enqueue(rlm_rcode_t *p_result, void *instance, void *thread, request_t *request)
 {
        rlm_radius_udp_t                *inst = talloc_get_type_abort(instance, rlm_radius_udp_t);
        udp_thread_t                    *t = talloc_get_type_abort(thread, udp_thread_t);
@@ -2603,9 +2612,7 @@ static unlang_action_t mod_enqueue(rlm_rcode_t *p_result, void **rctx_out, void
 
        talloc_set_destructor(u, _udp_request_free);
 
-       *rctx_out = r;
-
-       return UNLANG_ACTION_YIELD;
+       return unlang_module_yield(request, mod_resume, mod_signal, 0, r);
 }
 
 /** Instantiate thread data for the submodule.
@@ -2767,6 +2774,4 @@ rlm_radius_io_t rlm_radius_udp = {
                .thread_instantiate     = mod_thread_instantiate,
        },
        .enqueue                = mod_enqueue,
-       .signal                 = mod_signal,
-       .resume                 = mod_resume,
 };