From b3e937e11a24fc211b5269af5ffe96ad29ca4ee2 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 17 Aug 2018 23:32:30 -0500 Subject: [PATCH] main: Rework initialization order Group together all the configuration settings / reading code together for more readability. Initialize eap, eapol and rfkill before device --- src/main.c | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/src/main.c b/src/main.c index 94905692..9382b86a 100644 --- a/src/main.c +++ b/src/main.c @@ -389,7 +389,6 @@ int main(int argc, char *argv[]) config_dir = CONFIGDIR; config_path = l_strdup_printf("/%s/%s", config_dir, "main.conf"); - iwd_config = l_settings_new(); if (!l_settings_load_from_file(iwd_config, config_path)) @@ -397,50 +396,47 @@ int main(int argc, char *argv[]) l_free(config_path); + __eapol_set_config(iwd_config); + + if (!l_settings_get_uint(iwd_config, "EAP", "mtu", &eap_mtu)) + eap_mtu = 1400; /* on WiFi the real MTU is around 2304 */ + + exit_status = EXIT_FAILURE; + if (!dbus_init(enable_dbus_debug)) { - exit_status = EXIT_FAILURE; - goto done; + l_error("Failed to initialize D-Bus"); + goto fail_dbus; } genl = l_genl_new_default(); if (!genl) { l_error("Failed to open generic netlink socket"); - exit_status = EXIT_FAILURE; goto fail_genl; } if (getenv("IWD_GENL_DEBUG")) l_genl_set_debug(genl, do_debug, "[GENL] ", NULL); - if (!device_init()) { - exit_status = EXIT_FAILURE; - goto fail_device; - } - - l_debug("Opening nl80211 interface"); - nl80211 = l_genl_family_new(genl, NL80211_GENL_NAME); if (!nl80211) { l_error("Failed to open nl80211 interface"); - exit_status = EXIT_FAILURE; goto fail_nl80211; } l_genl_family_set_watches(nl80211, nl80211_appeared, nl80211_vanished, nl80211, NULL); - if (!l_settings_get_uint(iwd_config, "EAP", "mtu", &eap_mtu)) - eap_mtu = 1400; /* on WiFi the real MTU is around 2304 */ + eap_init(eap_mtu); + eapol_init(); + rfkill_init(); - __eapol_set_config(iwd_config); + if (!device_init()) + goto fail_device; adhoc_init(); wsc_init(); - eap_init(eap_mtu); - eapol_init(); network_init(); known_networks_init(); - rfkill_init(); sim_auth_init(); plugin_init(plugins, noplugins); @@ -449,26 +445,22 @@ int main(int argc, char *argv[]) plugin_exit(); sim_auth_exit(); - rfkill_exit(); known_networks_exit(); network_exit(); - eapol_exit(); - eap_exit(); wsc_exit(); adhoc_exit(); + device_exit(); +fail_device: + rfkill_exit(); + eapol_exit(); + eap_exit(); l_genl_family_unref(nl80211); - fail_nl80211: - device_exit(); - -fail_device: l_genl_unref(genl); - fail_genl: dbus_exit(); - -done: +fail_dbus: l_settings_free(iwd_config); l_signal_remove(signal);