]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add flatten migration configuration
authorAlan T. DeKok <aland@freeradius.org>
Mon, 21 Aug 2023 16:16:54 +0000 (12:16 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 21 Aug 2023 16:16:54 +0000 (12:16 -0400)
it turns out "unflatten" is hard, so we need to find a better way
to deal with things

src/bin/radiusd.c
src/lib/io/worker.c
src/lib/io/worker.h
src/lib/server/main_config.c
src/lib/server/main_config.h

index a06c917526346b36a4acc9378df78883611f4b35..e482826eb2464fd4eb8b8a2bc998a36d8d00cf35 100644 (file)
@@ -846,6 +846,8 @@ int main(int argc, char *argv[])
                COPY(max_request_time);
                COPY(unflatten_after_decode);
                COPY(unflatten_before_encode);
+               COPY(flatten_after_decode);
+               COPY(flatten_before_encode);
 
                /*
                 *      Single server mode: use the global event list.
index bc722fcf1dfc2fcc187dda0dad6a0f2d526cac7d..8db41e13f0b49cd89e4f97e60a43a24e571ab73b 100644 (file)
@@ -672,7 +672,10 @@ static void worker_send_reply(fr_worker_t *worker, request_t *request, bool send
 
                if (worker->config.unflatten_before_encode) {
                        fr_pair_unflatten(request->pair_list.reply);
-               } /* else noop */
+
+               } else if (worker->config.flatten_before_encode) {
+                       fr_pair_flatten(request->pair_list.reply);
+               }
 
                if (listen->app_io->encode) {
                        slen = listen->app_io->encode(listen->app_io_instance, request,
@@ -856,6 +859,9 @@ nak:
 
        if (worker->config.unflatten_after_decode) {
                fr_pair_unflatten(request->pair_list.request);
+
+       } else if (worker->config.flatten_after_decode) {
+               fr_pair_flatten(request->pair_list.request);
        }
 
        /*
index ac56d9a89b577860e906282f05fe2bd96d4307eb..8eee4da464487cc5a2543a01ada4e64df5ab0d19 100644 (file)
@@ -65,8 +65,11 @@ typedef struct {
 
        fr_time_delta_t max_request_time;       //!< maximum time a request can be processed
 
-       bool            unflatten_after_decode;         //!< the worker will call "unflatten" after protocol decoding
-       bool            unflatten_before_encode;        //!< the worker will call "unflatten" before all encoding
+       bool            unflatten_after_decode;  //!< the worker will call "unflatten" after protocol decoding
+       bool            unflatten_before_encode; //!< the worker will call "unflatten" before all encoding
+
+       bool            flatten_after_decode;    //!< the worker will call "flatten" after protocol decoding
+       bool            flatten_before_encode;   //!< the worker will call "flatten" before all encoding
 
        size_t          talloc_pool_size;       //!< for each request
 } fr_worker_config_t;
index ed3d60583a4253deb49c3080242151819b498390..8595c962f83da9d69471ac8aca3f0f9886455786 100644 (file)
@@ -191,6 +191,8 @@ static const CONF_PARSER thread_config[] = {
 static const CONF_PARSER migrate_config[] = {
        { FR_CONF_OFFSET("unflatten_after_decode", FR_TYPE_BOOL | FR_TYPE_HIDDEN, main_config_t, unflatten_after_decode) },
        { FR_CONF_OFFSET("unflatten_before_encode", FR_TYPE_BOOL | FR_TYPE_HIDDEN, main_config_t, unflatten_before_encode) },
+       { FR_CONF_OFFSET("flatten_after_decode", FR_TYPE_BOOL | FR_TYPE_HIDDEN, main_config_t, flatten_after_decode) },
+       { FR_CONF_OFFSET("flatten_before_encode", FR_TYPE_BOOL | FR_TYPE_HIDDEN, main_config_t, flatten_before_encode) },
        { FR_CONF_OFFSET("tmpl_tokenize_all_nested", FR_TYPE_BOOL | FR_TYPE_HIDDEN, main_config_t, tmpl_tokenize_all_nested) },
        { FR_CONF_OFFSET("use_new_conditions", FR_TYPE_BOOL | FR_TYPE_HIDDEN, main_config_t, use_new_conditions) },
        { FR_CONF_OFFSET("rewrite_update", FR_TYPE_BOOL | FR_TYPE_HIDDEN, main_config_t, rewrite_update) },
index 5be14f0891d19d904328875ff0727238dfb46b63..9129b4fd37fd588eb6c273d8d29aaf773942f9b3 100644 (file)
@@ -161,6 +161,8 @@ struct main_config_s {
         */
        bool            unflatten_after_decode;         //!< the worker will call "unflatten" after protocol decoding
        bool            unflatten_before_encode;        //!< the worker will call "unflatten" before all encoding
+       bool            flatten_after_decode;           //!< the worker will call "flatten" after protocol decoding
+       bool            flatten_before_encode;          //!< the worker will call "flatten" before all encoding
        bool            tmpl_tokenize_all_nested;       //!< tmpl_tokenize will create nested tmpls instead of flat ones
        bool            use_new_conditions;             //!< the new xlat expressions will be used for conditions, instead of the old code
        bool            rewrite_update;                 //!< rewrite "update" to be new edit sections