From: Alan T. DeKok Date: Mon, 21 Aug 2023 16:16:54 +0000 (-0400) Subject: add flatten migration configuration X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07fbb2e7fca0d1399c4bdc792a37fb47fb9f4419;p=thirdparty%2Ffreeradius-server.git add flatten migration configuration it turns out "unflatten" is hard, so we need to find a better way to deal with things --- diff --git a/src/bin/radiusd.c b/src/bin/radiusd.c index a06c9175263..e482826eb24 100644 --- a/src/bin/radiusd.c +++ b/src/bin/radiusd.c @@ -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. diff --git a/src/lib/io/worker.c b/src/lib/io/worker.c index bc722fcf1df..8db41e13f0b 100644 --- a/src/lib/io/worker.c +++ b/src/lib/io/worker.c @@ -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); } /* diff --git a/src/lib/io/worker.h b/src/lib/io/worker.h index ac56d9a89b5..8eee4da4644 100644 --- a/src/lib/io/worker.h +++ b/src/lib/io/worker.h @@ -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; diff --git a/src/lib/server/main_config.c b/src/lib/server/main_config.c index ed3d60583a4..8595c962f83 100644 --- a/src/lib/server/main_config.c +++ b/src/lib/server/main_config.c @@ -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) }, diff --git a/src/lib/server/main_config.h b/src/lib/server/main_config.h index 5be14f0891d..9129b4fd37f 100644 --- a/src/lib/server/main_config.h +++ b/src/lib/server/main_config.h @@ -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