]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Revert "get rid of request->async->process and move to unlang functions"
authorAlan T. DeKok <aland@freeradius.org>
Thu, 16 Jan 2020 20:18:17 +0000 (15:18 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 16 Jan 2020 20:18:17 +0000 (15:18 -0500)
This reverts commit 55a07a1571c0ed80a1d83a519f41d694ad566498.

13 files changed:
src/lib/io/listen.h
src/lib/io/worker.c
src/lib/server/auth.c
src/lib/unlang/all.mk
src/lib/unlang/call.c
src/lib/unlang/io.c
src/lib/unlang/module.c
src/modules/proto_control/proto_control.c
src/modules/proto_control/proto_control.h
src/modules/proto_detail/proto_detail.c
src/modules/proto_dhcpv4/proto_dhcpv4.c
src/modules/proto_radius/proto_radius.c
src/modules/proto_vmps/proto_vmps.c

index 4f0c62eedb1ef3aedb536011be2e9b15bb404a01..57a53e5033f8618fef4180cc50e7be86a55f8c28 100644 (file)
@@ -47,6 +47,9 @@ struct fr_listen {
  *     Minimal data structure to use the new code.
  */
 struct fr_async_s {
+       module_method_t         process;                //!< The current state function.
+       void                    *process_inst;          //!< Instance data for the current state machine.
+
        fr_time_t               recv_time;
        fr_event_list_t         *el;
 
index e39929c5a80e91b354edc52f59f42ab512781c6d..3c416588f77d77a79c7827bf524e1cb86b080c2c 100644 (file)
@@ -505,6 +505,7 @@ finished:
 
 #ifndef NDEBUG
        request->async->el = NULL;
+       request->async->process = NULL;
        request->async->channel = NULL;
        request->async->packet_ctx = NULL;
        request->async->listen = NULL;
@@ -549,6 +550,10 @@ static void worker_stop_request(fr_worker_t *worker, REQUEST *request, fr_time_t
        if (request->time_order_id >= 0) (void) fr_heap_extract(worker->time_order, request);
        if (request->runnable_id >= 0) (void) fr_heap_extract(worker->runnable, request);
        if (request->async->listen->track_duplicates) rbtree_deletebydata(worker->dedup, request);
+
+#ifndef NDEBUG
+       request->async->process = NULL;
+#endif
 }
 
 /** Enforce max_request_time
@@ -717,6 +722,12 @@ nak:
         */
        listen->app->entry_point_set(listen->app_instance, request);
 
+       if (!request->async->process) {
+               RERROR("Protocol failed to set 'process' function");
+               worker_nak(worker, cd, now);
+               return;
+       }
+
        /*
         *      We're done with this message.
         */
@@ -854,6 +865,7 @@ redo:
        fr_time_tracking_resume(&request->async->tracking, now);
 
        rad_assert(request->parent == NULL);
+       rad_assert(request->async->process != NULL);
        rad_assert(request->async->listen != NULL);
        rad_assert(request->runnable_id < 0); /* removed from the runnable heap */
 
@@ -872,7 +884,7 @@ redo:
        /*
         *      Everything else, run the request.
         */
-       final = unlang_interpret(request);
+       final = request->async->process(request->async->process_inst, NULL, request);
 
        /*
         *      Figure out what to do next.
index 680f86e1bc193b4c095dfee15e5a4bbad4cdd5ff..861983276ca36bbf55d6e29c786486aa9be6729b 100644 (file)
@@ -32,7 +32,6 @@ RCSID("$Id$")
 #include <freeradius-devel/server/rcode.h>
 #include <freeradius-devel/server/state.h>
 #include <freeradius-devel/io/listen.h>
-#include <freeradius-devel/unlang/interpret.h>
 
 #include <freeradius-devel/util/print.h>
 
@@ -153,11 +152,6 @@ rlm_rcode_t rad_virtual_server(REQUEST *request)
        }
 
 runit:
-#if 1
-       RDEBUG("rad_virtual_server() needs to be fixed to work with the new method");
-       final = RLM_MODULE_REJECT;
-       return final;
-#else
        if (!request->async) {
 #ifdef __clang_analyzer__
                if (!request->parent) return RLM_MODULE_FAIL;
@@ -168,20 +162,8 @@ runit:
                talloc_set_name_const(request->async, talloc_get_name(request->parent->async));
        }
 
-       /*
-        *      @todo - copy root stack frame from the parent.  It
-        *      contains the method to call which processes the
-        *      packet.  Now that request->async->process is gone, we
-        *      have to fix this code.
-        *
-        *      However, if we're running another virtual server, we
-        *      should really be using the unlang "call"
-        *      functionality.  That code already looks at the virtual
-        *      server in order to tell the child how to run.
-        */
-
        RDEBUG("server %s {", cf_section_name2(request->server_cs));
-       final = unlang_interpret(request);
+       final = request->async->process(request->async->process_inst, NULL, request);
        RDEBUG("} # server %s", cf_section_name2(request->server_cs));
 
        fr_cond_assert(final == RLM_MODULE_OK);
@@ -196,7 +178,6 @@ runit:
        }
 
        return RLM_MODULE_OK;
-#endif
 }
 
 /*
index 72a0d605a33a291dee326f69ff829eddce64d28f..df844508b971c250af9ee9cb5252ed03f334b12e 100644 (file)
@@ -11,7 +11,6 @@ SOURCES       :=      base.c \
                io.c \
                load_balance.c \
                map.c \
-               method.c \
                module.c \
                parallel.c \
                return.c \
index 2e97a8e5cd1040707b8f95a4d4894fbb4a2bc8b2..cfebf0101f47f85b39bcce5835cf197a33301258 100644 (file)
@@ -27,7 +27,6 @@ RCSID("$Id$")
 #include <freeradius-devel/server/state.h>
 #include "unlang_priv.h"
 #include "subrequest_priv.h"
-#include "method.h"
 
 /** Send a signal from parent request to subrequest in another virtual server
  *
@@ -75,7 +74,7 @@ static unlang_action_t unlang_call_process(REQUEST *request, rlm_rcode_t *presul
         *      (e.g. Access-Request -> Accounting-Request) unless
         *      we're in a subrequest.
         */
-       rcode = unlang_interpret(child);
+       rcode = child->async->process(child->async->process_inst, NULL, child);
        if (rcode == RLM_MODULE_YIELD) {
                return UNLANG_ACTION_YIELD;
        }
@@ -187,7 +186,8 @@ static unlang_action_t unlang_call(REQUEST *request, rlm_rcode_t *presult)
         *      Tell the child how to run.
         */
        child->server_cs = g->server_cs;
-       unlang_interpret_push_method(child, process_inst, *process_p);
+       child->async->process = *process_p;
+       child->async->process_inst = process_inst;
 
        /*
         *      Expected by the process functions
index d41574dce3d6eed3ad2d740648ec1437d2ebcff7..fca77c5655c4e6a911484448d6e7dc4dd9475df0 100644 (file)
@@ -26,7 +26,6 @@ RCSID("$Id$")
 
 #include <freeradius-devel/io/listen.h>
 #include "unlang_priv.h"
-#include "method.h"
 
 /** Run the interpreter after creating a subrequest.
  *
@@ -116,7 +115,7 @@ REQUEST *unlang_io_subrequest_alloc(REQUEST *parent, fr_dict_t const *namespace,
         *      bare-bones function which just runs on section of
         *      "unlang", and doesn't send replies or anything else.
         */
-       unlang_interpret_push_method(child, NULL, unlang_io_process_interpret);
+       child->async->process = unlang_io_process_interpret;
 
        return child;
 }
index fed4f52b43daeef839478606091e689ba8a5b865..98e6f7fce13f81a9ab507a5dadab96de9b9ea2ce 100644 (file)
@@ -383,7 +383,6 @@ void unlang_module_push(rlm_rcode_t *out, REQUEST *request,
        frame->state = state;
 }
 
-
 /** Allocate a subrequest to run through a virtual server at some point in the future
  *
  * @param[in] parent           to hang sub request off of.
index e6b1992ef43a6df0c647afb98f1f3865f104dc8a..a958ebde13f2979b7703e59be62c000738d992d7 100644 (file)
@@ -26,7 +26,6 @@
 #include <freeradius-devel/io/listen.h>
 #include <freeradius-devel/server/module.h>
 #include <freeradius-devel/unlang/base.h>
-#include <freeradius-devel/unlang/method.h>
 #include <freeradius-devel/server/rad_assert.h>
 #include "proto_control.h"
 
@@ -116,7 +115,7 @@ static int type_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM
         *
         *      Future changes may allow different types of control access?
         */
-       return dl_module_instance(ctx, out, listen_cs,  parent_inst, "process", DL_MODULE_TYPE_SUBMODULE);
+       return dl_module_instance(ctx, out, listen_cs,  parent_inst, "all", DL_MODULE_TYPE_SUBMODULE);
 }
 
 /** Wrapper around dl_instance
@@ -299,10 +298,6 @@ static ssize_t mod_encode(void const *instance, REQUEST *request, uint8_t *buffe
        return inst->io.app_io->encode(inst->io.app_io_instance, request, buffer, buffer_len);
 }
 
-/*
- *     @todo - this function isn't actually used for anything, as
- *     there is no proto_control_process.c
- */
 static void mod_entry_point_set(void const *instance, REQUEST *request)
 {
        proto_control_t const *inst = talloc_get_type_abort_const(instance, proto_control_t);
@@ -318,13 +313,13 @@ static void mod_entry_point_set(void const *instance, REQUEST *request)
 
                app_process = (fr_app_worker_t const *) inst->dynamic_submodule->module->common;
 
-               unlang_interpret_push_method(request, inst->io.dynamic_submodule->data, app_process->entry_point);
+               request->async->process = app_process->entry_point;
                track->dynamic = 0;
                return;
        }
 
        rad_assert(inst->process != NULL);
-       unlang_interpret_push_method(request, NULL, inst->process);
+       request->async->process = inst->process;
 }
 
 
index 892f18edab27012239fd0248d4f1afdf83f8223d..a8468192885cb146448f1985033f59a2a9f165ca 100644 (file)
@@ -33,8 +33,8 @@
 typedef struct {
        fr_io_instance_t                io;                             //!< wrapper for IO abstraction
 
-       dl_module_inst_t                **type_submodule;               //!< Instance of the various types
-       dl_module_inst_t                *dynamic_submodule;             //!< proto_control_dynamic_client
+       dl_module_inst_t                        **type_submodule;               //!< Instance of the various types
+       dl_module_inst_t                        *dynamic_submodule;             //!< proto_control_dynamic_client
                                                                        //!< only one instance per type allowed.
        module_method_t                 process;                        //!< process function
 
index dddd114372ed3d3f3e836ec0d9a024fbbed81fdf..447ed4f240298301de510a6894c632be495343ea 100644 (file)
@@ -28,7 +28,6 @@
 #include <freeradius-devel/io/schedule.h>
 #include <freeradius-devel/io/application.h>
 #include <freeradius-devel/server/rad_assert.h>
-#include <freeradius-devel/unlang/method.h>
 #include "proto_detail.h"
 
 extern fr_app_t proto_detail;
@@ -402,8 +401,8 @@ static void mod_entry_point_set(void const *instance, REQUEST *request)
        app_process = (fr_app_worker_t const *)inst->type_submodule->module->common;
 
        request->server_cs = inst->server_cs;
-
-       unlang_interpret_push_method(request, inst->process_instance, app_process->entry_point);
+       request->async->process = app_process->entry_point;
+       request->async->process_inst = inst->process_instance;
 }
 
 /** Open listen sockets/connect to external event source
index 9b40cb02b03263a70430f36504ec2c81992ebad2..4a83682fbf497135bbe5df2b1b9cdd70f65dc8a3 100644 (file)
@@ -26,7 +26,6 @@
 #include <freeradius-devel/io/listen.h>
 #include <freeradius-devel/server/module.h>
 #include <freeradius-devel/unlang/base.h>
-#include <freeradius-devel/unlang/method.h>
 #include <freeradius-devel/server/rad_assert.h>
 #include "proto_dhcpv4.h"
 
@@ -430,7 +429,7 @@ static void mod_entry_point_set(void const *instance, REQUEST *request)
 
                app_process = (fr_app_worker_t const *) inst->io.dynamic_submodule->module->common;
 
-               unlang_interpret_push_method(request, inst->io.dynamic_submodule->data, app_process->entry_point);
+               request->async->process = app_process->entry_point;
                track->dynamic = 0;
                return;
        }
@@ -441,7 +440,8 @@ static void mod_entry_point_set(void const *instance, REQUEST *request)
                return;
        }
 
-       unlang_interpret_push_method(request, type_submodule->data, ((fr_app_worker_t const *)type_submodule->module->common)->entry_point);
+       request->async->process = ((fr_app_worker_t const *)type_submodule->module->common)->entry_point;
+       request->async->process_inst = type_submodule->data;
 }
 
 
index 17c41c58982922dee391423fffb0d92e5cb97b02..4349dbcc2e3d6e4d5008b9b742447c2c32aa5546 100644 (file)
@@ -27,7 +27,6 @@
 #include <freeradius-devel/io/listen.h>
 #include <freeradius-devel/server/module.h>
 #include <freeradius-devel/unlang/base.h>
-#include <freeradius-devel/unlang/method.h>
 #include <freeradius-devel/server/rad_assert.h>
 #include "proto_radius.h"
 
@@ -533,7 +532,8 @@ static void mod_entry_point_set(void const *instance, REQUEST *request)
 
                app_process = (fr_app_worker_t const *) inst->io.dynamic_submodule->module->common;
 
-               unlang_interpret_push_method(request, inst->io.dynamic_submodule->data, app_process->entry_point);
+               request->async->process = app_process->entry_point;
+               request->async->process_inst = inst->io.dynamic_submodule;
                track->dynamic = 0;
                return;
        }
@@ -544,7 +544,8 @@ static void mod_entry_point_set(void const *instance, REQUEST *request)
                return;
        }
 
-       unlang_interpret_push_method(request, type_submodule->data, ((fr_app_worker_t const *)type_submodule->module->common)->entry_point);
+       request->async->process = ((fr_app_worker_t const *)type_submodule->module->common)->entry_point;
+       request->async->process_inst = type_submodule->data;
 }
 
 
index 26fb9970db8c2cf5076c6ff0194bce6ec1a83014..f393576b29a9c63bb8004c10159b1953a47d7d30 100644 (file)
@@ -27,7 +27,6 @@
 #include <freeradius-devel/io/listen.h>
 #include <freeradius-devel/server/module.h>
 #include <freeradius-devel/unlang/base.h>
-#include <freeradius-devel/unlang/method.h>
 #include <freeradius-devel/server/rad_assert.h>
 
 #include <freeradius-devel/protocol/vmps/vmps.h>
@@ -402,7 +401,8 @@ static void mod_entry_point_set(void const *instance, REQUEST *request)
 
                app_process = (fr_app_worker_t const *) inst->io.dynamic_submodule->module->common;
 
-               unlang_interpret_push_method(request, inst->io.dynamic_submodule->data, app_process->entry_point);
+               request->async->process = app_process->entry_point;
+               request->async->process_inst = inst->io.dynamic_submodule;
                track->dynamic = 0;
                return;
        }
@@ -413,7 +413,8 @@ static void mod_entry_point_set(void const *instance, REQUEST *request)
                return;
        }
 
-       unlang_interpret_push_method(request, type_submodule->data, ((fr_app_worker_t const *)type_submodule->module->common)->entry_point);
+       request->async->process = ((fr_app_worker_t const *)type_submodule->module->common)->entry_point;
+       request->async->process_inst = type_submodule->data;
 }