From ebd39830cbb43e591c48b92a442aac4157a02af2 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 23 Feb 2021 16:41:04 +0100 Subject: main: change initialization order We must have initialized e.g. the NS protocol stack before calling handle_options(), as that might want to dumpy the VTY XML, and it can obviously only dump those nodes that are registered at that point. Change-Id: Icd1b8fb3f466cdace67ff0d4f7c85183d8266c41 --- src/sgsn/sgsn_main.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/sgsn/sgsn_main.c b/src/sgsn/sgsn_main.c index 6c57071a2..2cabbf3cf 100644 --- a/src/sgsn/sgsn_main.c +++ b/src/sgsn/sgsn_main.c @@ -407,23 +407,6 @@ int main(int argc, char **argv) osmo_sccp_vty_init(); #endif - handle_options(argc, argv); - - /* Backwards compatibility: for years, the default config file name was - * osmo_sgsn.cfg. All other Osmocom programs use osmo-*.cfg with a - * dash. To be able to use the new config file name without breaking - * previous setups that might rely on the legacy default config file - * name, we need to look for the old config file if no -c option was - * passed AND no file exists with the new default file name. */ - if (!sgsn->config_file) { - /* No -c option was passed */ - if (file_exists(CONFIG_FILE_LEGACY) - && !file_exists(CONFIG_FILE_DEFAULT)) - osmo_talloc_replace_string(sgsn, &sgsn->config_file, CONFIG_FILE_LEGACY); - else - osmo_talloc_replace_string(sgsn, &sgsn->config_file, CONFIG_FILE_DEFAULT); - } - rate_ctr_init(tall_sgsn_ctx); logging_vty_add_deprecated_subsys(tall_sgsn_ctx, "bssgp"); @@ -448,6 +431,23 @@ int main(int argc, char **argv) sgsn_auth_init(sgsn); sgsn_cdr_init(sgsn); + handle_options(argc, argv); + + /* Backwards compatibility: for years, the default config file name was + * osmo_sgsn.cfg. All other Osmocom programs use osmo-*.cfg with a + * dash. To be able to use the new config file name without breaking + * previous setups that might rely on the legacy default config file + * name, we need to look for the old config file if no -c option was + * passed AND no file exists with the new default file name. */ + if (!sgsn->config_file) { + /* No -c option was passed */ + if (file_exists(CONFIG_FILE_LEGACY) + && !file_exists(CONFIG_FILE_DEFAULT)) + osmo_talloc_replace_string(sgsn, &sgsn->config_file, CONFIG_FILE_LEGACY); + else + osmo_talloc_replace_string(sgsn, &sgsn->config_file, CONFIG_FILE_DEFAULT); + } + rc = sgsn_parse_config(sgsn->config_file); if (rc < 0) { LOGP(DGPRS, LOGL_FATAL, "Error in config file\n"); -- cgit v1.2.3