From 82315ead3ed2497290f4127864af422de3a22deb Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 19 Feb 2026 14:40:13 +0100 Subject: [PATCH] Fail early if configuration module can not initialize properly In the case that the config module cannot load the driver for libconfig or yaml, currently, there might be a cascade of errors that are difficult for users to understand. For instance (partially redacted for clarity): [CONFIG] Error calling dlopen(libparams_libconfig.so): libparams_libconfig.so: cannot open shared object file: No such file or directory [CONFIG] config module "libconfig" couldn't be loaded [CONFIG] config_get, section log_config skipped, config module not properly initialized [LOG] init aborted, configuration couldn't be performed [CONFIG] config_get, section (null) skipped, config module not properly initialized [CONFIG] /home/francesco/openairinterface5g/common/config/config_userapi.c 68 nfapi has no processed integer availablle [CONFIG] config_get, section (null) skipped, config module not properly initialized Assertion (get_softmodem_params()->default_pdu_session_id == -1) failed! In get_common_options() /home/francesco/openairinterface5g/executables/softmodem-common.c:161 Use uicc0.pdu_sessions.[0].id to change the requested PDU session ID (is 0) Here, the error is the missing shared object, but a user is more likely to look at the last error instead of the first. This commit addresses it by checking early for CONFIG_ISFLAGSET(CONFIG_ABORT), and stopping if it is set. Additionally changes include making functions static, removing late CONFIG_ISFLAGSET() checks, and the CONFIG_ISFLAGSET() in load_configmodule(), because at that time "uniqCfg" is not set yet and thus does not do anything (this is likely a regression of an earlier cleanup). See-also: f50d5f5a9b5 ("make multiple config instead of one implicit global") --- common/config/config_load_configmodule.c | 10 +++------- executables/nr-softmodem.c | 7 +------ executables/nr-uesoftmodem.c | 2 +- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/common/config/config_load_configmodule.c b/common/config/config_load_configmodule.c index 14f4a4c81d..988e993dc6 100644 --- a/common/config/config_load_configmodule.c +++ b/common/config/config_load_configmodule.c @@ -63,7 +63,8 @@ static paramdef_t Config_Params[] = { }; // clang-format on -int load_config_sharedlib(configmodule_interface_t *cfgptr) { +static int load_config_sharedlib(configmodule_interface_t *cfgptr) +{ void *lib_handle; char fname[128]; char libname[FILENAME_MAX]; @@ -380,7 +381,7 @@ configmodule_interface_t *load_configmodule(int argc, Config_Params[idx].strptr = &(cfgptr->tmpdir); config_get(cfgptr, Config_Params, sizeofArray(Config_Params), CONFIG_SECTIONNAME); } else { - fprintf(stderr,"[CONFIG] %s %d config module \"%s\" couldn't be loaded\n", __FILE__, __LINE__,cfgmode); + fprintf(stderr, "[CONFIG] config module \"%s\" couldn't be loaded\n", cfgmode); cfgptr->rtflags = cfgptr->rtflags | CONFIG_HELP | CONFIG_ABORT; } } else { @@ -396,11 +397,6 @@ configmodule_interface_t *load_configmodule(int argc, if (cfgmode != NULL) free(cfgmode); - if (CONFIG_ISFLAGSET(CONFIG_ABORT)) { - config_printhelp(Config_Params, sizeofArray(Config_Params), CONFIG_SECTIONNAME); - // exit(-1); - } - return cfgptr; } diff --git a/executables/nr-softmodem.c b/executables/nr-softmodem.c index 614fecad62..938bbeee88 100644 --- a/executables/nr-softmodem.c +++ b/executables/nr-softmodem.c @@ -514,7 +514,7 @@ int main( int argc, char **argv ) { start_background_system(); ///static configuration for NR at the moment - if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == NULL) { + if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == NULL || CONFIG_ISFLAGSET(CONFIG_ABORT)) { exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); } @@ -528,11 +528,6 @@ int main( int argc, char **argv ) { lock_memory_to_ram(); get_options(uniqCfg); - if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) { - fprintf(stderr,"Getting configuration failed\n"); - exit(-1); - } - if (!has_cap_sys_nice()) LOG_W(UTIL, "no SYS_NICE capability: cannot set thread priority and affinity, consider running with sudo for optimum performance\n"); diff --git a/executables/nr-uesoftmodem.c b/executables/nr-uesoftmodem.c index a0e06850b7..50d3f6946e 100644 --- a/executables/nr-uesoftmodem.c +++ b/executables/nr-uesoftmodem.c @@ -248,7 +248,7 @@ int main(int argc, char **argv) { start_background_system(); - if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == NULL) { + if ((uniqCfg = load_configmodule(argc, argv, CONFIG_ENABLECMDLINEONLY)) == NULL || CONFIG_ISFLAGSET(CONFIG_ABORT)) { exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); } //set_softmodem_sighandler();