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
This commit is contained in:
Harald Welte 2021-02-23 16:41:04 +01:00
parent b05c1d0ce4
commit ebd39830cb
1 changed files with 17 additions and 17 deletions

View File

@ -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");