main: move module init into nl80211_appeared
PATCH v2 1/12 main: move module init into nl80211_appeared
In preparation for integrating IWD_MODULE into modules which require nl80211 we move the module init into the nl80211_appeared callback. This will guarentee that the nl80211 is available during module init and allow modules to get their own copy of nl80211 rather than needing a set function (e.g. netdev_set_nl80211).
Since the dbus name request callback happens before this as well any dbus module can also use IWD_MODULE and simply assume the dbus object is ready.
plugin_init was also deferred to nl80211_appeared since some plugins depend on modules being initialized.
--- src/main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
-v2:
* Moved plugin_init after iwd_modules_init
src/main.c +7 -5
@@ -147,6 +147,13 @@ static void nl80211_appeared(const struct l_genl_family_info *info,l_debug ("Found nl80211 interface" ); nl80211 =l_genl_family_new (genl,NL80211_GENL_NAME ); +if (iwd_modules_init () <0 ) { +l_main_quit (); +return ; + } + +plugin_init (plugins, noplugins); +manager_init (nl80211, interfaces, nointerfaces);anqp_init (nl80211);
@@ -482,14 +489,9 @@ int main(int argc, char *argv[])if (!netdev_init ()) goto fail_netdev; -if (iwd_modules_init () <0 ) - goto fail_modules; - -plugin_init (plugins, noplugins); exit_status =l_main_run_with_signal (signal_handler,NULL );plugin_exit (); -fail_modules:iwd_modules_exit ();netdev_exit (); fail_netdev:
Signature · 1 line
2.17.1
PATCH v2 2/12 netdev: utilize IWD_MODULE
Since iwd_modules_init is now defered until nl80211_appeared, we can assume the nl80211 object is available. This removes the need for netdev_set_nl80211 completely.
--- src/iwd.h | 3 --- src/main.c | 8 +------- src/netdev.c | 25 +++++++++++++------------ 3 files changed, 14 insertions(+), 22 deletions(-)
src/iwd.h +0 -3
@@ -28,9 +28,6 @@ struct l_genl_family;const struct l_settings *iwd_get_config (void );struct l_genl *iwd_get_genl (void ); -bool netdev_init (void ); -void netdev_exit (void ); -void netdev_set_nl80211 (struct l_genl_family *nl80211);void netdev_shutdown (void ); bool manager_init(struct l_genl_family *in,
src/main.c +1 -7
@@ -159,8 +159,6 @@ static void nl80211_appeared(const struct l_genl_family_info *info,if (!wiphy_init (nl80211, phys, nophys))l_error ("Unable to init wiphy functionality" ); - -netdev_set_nl80211 (nl80211); } static void request_name_callback(struct l_dbus *dbus, bool success,
@@ -486,15 +484,11 @@ int main(int argc, char *argv[])eap_init (eap_mtu);eapol_init (); -if (!netdev_init ()) - goto fail_netdev; - exit_status =l_main_run_with_signal (signal_handler,NULL );plugin_exit ();iwd_modules_exit (); -netdev_exit (); -fail_netdev: +eapol_exit ();eap_exit ();
src/netdev.c +13 -12
@@ -4755,20 +4755,22 @@ bool netdev_watch_remove(uint32_t id)return watchlist_remove (&netdev_watches, id); } -bool netdev_init (void ) +static int netdev_init (void ) {struct l_genl *genl =iwd_get_genl ();const struct l_settings *settings =iwd_get_config (); + nl80211 =l_genl_family_new (genl,NL80211_GENL_NAME ); +if (rtnl) -return false; +return -EALREADY ;l_debug ("Opening route netlink socket" ); rtnl =l_netlink_new (NETLINK_ROUTE );if (!rtnl) {l_error ("Failed to open route netlink socket" ); -return false; +return -EIO ; }if (getenv ("IWD_RTNL_DEBUG" ))
@@ -4778,7 +4780,7 @@ bool netdev_init(void) netdev_link_notify, NULL, NULL)) { l_error("Failed to register for RTNL link notifications");l_netlink_destroy (rtnl); -return false; +return -EIO ; } if (!l_settings_get_int(settings, "General", "roam_rssi_threshold",
@@ -4801,19 +4803,14 @@ bool netdev_init(void)if (!unicast_watch)l_error ("Registering for unicast notification failed" ); -return true; -} - -void netdev_set_nl80211 (struct l_genl_family *in) -{ - nl80211 = in; -if (!l_genl_family_register (nl80211,"mlme" , netdev_mlme_notify,NULL ,NULL ))l_error ("Registering for MLME notification failed" ); + +return 0 ; } -void netdev_exit (void ) +static void netdev_exit (void ) {struct l_genl *genl =iwd_get_genl ();
@@ -4823,6 +4820,8 @@ void netdev_exit(void)l_genl_remove_unicast_watch (genl, unicast_watch);watchlist_destroy (&netdev_watches); + +l_genl_family_free (nl80211); nl80211 =NULL ;l_debug ("Closing route netlink socket" );
@@ -4840,3 +4839,5 @@ void netdev_shutdown(void)l_queue_destroy (netdev_list, netdev_free); netdev_list =NULL ; } + +IWD_MODULE (netdev, netdev_init, netdev_exit);
Signature · 1 line
2.17.1
PATCH v2 3/12 eapol: utilize IWD_MODULE
In reply to James PrestwoodThis converts eapol to using IWD modules. The init/exit APIs did need to remain exposed for unit tests.
Netdev was updated to depend on eapol.
--- src/eapol.c | 11 ++++++----- src/eapol.h | 4 ++-- src/main.c | 2 -- src/netdev.c | 1 + 4 files changed, 9 insertions(+), 9 deletions(-)
src/eapol.c +6 -5
@@ -40,6 +40,7 @@#include "src/handshake.h" #include "src/watchlist.h" #include "src/erp.h" +#include "src/iwd.h" static struct l_queue *state_machines;static struct l_queue *preauths;
@@ -2705,16 +2706,16 @@ void __eapol_set_config(struct l_settings *config) eapol_4way_handshake_time =5 ; } -bool eapol_init () +int eapol_init (void ) { state_machines =l_queue_new (); preauths =l_queue_new ();watchlist_init (&frame_watches, &eapol_frame_watch_ops); -return true; +return 0 ; } -bool eapol_exit () +void eapol_exit (void ) {if (!l_queue_isempty (state_machines))l_warn ("stale eapol state machines found" );
@@ -2727,6 +2728,6 @@ bool eapol_exit()l_queue_destroy (preauths, preauth_sm_destroy);watchlist_destroy (&frame_watches); - -return true; } + +IWD_MODULE (eapol, eapol_init, eapol_exit);
src/eapol.h +2 -2
@@ -128,5 +128,5 @@ struct preauth_sm *eapol_preauth_start(const uint8_t *aa, eapol_preauth_destroy_func_t destroy);void eapol_preauth_cancel (uint32_t ifindex); -bool eapol_init (); -bool eapol_exit (); +int eapol_init (void ); +void eapol_exit (void );
src/main.c +0 -2
@@ -482,14 +482,12 @@ int main(int argc, char *argv[])dbus_init (dbus);eap_init (eap_mtu); -eapol_init (); exit_status =l_main_run_with_signal (signal_handler,NULL );plugin_exit ();iwd_modules_exit (); -eapol_exit ();eap_exit ();if (nl80211) {
src/netdev.c +1 -0
@@ -4841,3 +4841,4 @@ void netdev_shutdown(void) }IWD_MODULE (netdev, netdev_init, netdev_exit); +IWD_MODULE_DEPENDS (netdev, eapol);
Signature · 1 line
2.17.1
PATCH v2 4/12 anqp: utilize IWD_MODULE
In reply to James PrestwoodThis converts anqp into an IWD module.
--- src/anqp.c | 12 ++++++++---- src/anqp.h | 3 --- src/main.c | 2 -- 3 files changed, 8 insertions(+), 9 deletions(-)
src/anqp.c +8 -4
@@ -474,11 +474,11 @@ static void anqp_mlme_notify(struct l_genl_msg *msg, void *user_data) } } -bool anqp_init (struct l_genl_family *in) +static int anqp_init (void ) {struct l_genl *genl =iwd_get_genl (); - nl80211 = in; + nl80211 =l_genl_family_new (genl,NL80211_GENL_NAME ); anqp_requests =l_queue_new ();
@@ -492,13 +492,14 @@ bool anqp_init(struct l_genl_family *in) NULL, NULL))l_error ("Registering for MLME notification failed" ); -return true; +return 0 ; } -void anqp_exit (void ) +static void anqp_exit (void ) {struct l_genl *genl =iwd_get_genl (); +l_genl_family_free (nl80211); nl80211 =NULL ;l_queue_destroy (anqp_requests, anqp_destroy);
@@ -507,3 +508,6 @@ void anqp_exit(void)l_genl_remove_unicast_watch (genl, unicast_watch); } + +IWD_MODULE (anqp, anqp_init, anqp_exit); +IWD_MODULE_DEPENDS (anqp, netdev);
src/anqp.h +0 -3
@@ -38,6 +38,3 @@ uint32_t anqp_request(uint32_t ifindex, const uint8_t *addr, struct scan_bss *bss, const uint8_t *anqp, size_t len, anqp_response_func_t cb, void *user_data, anqp_destroy_func_t destroy); - -bool anqp_init (struct l_genl_family *in); -void anqp_exit (void );
src/main.c +0 -2
@@ -155,7 +155,6 @@ static void nl80211_appeared(const struct l_genl_family_info *info,plugin_init (plugins, noplugins);manager_init (nl80211, interfaces, nointerfaces); -anqp_init (nl80211);if (!wiphy_init (nl80211, phys, nophys))l_error ("Unable to init wiphy functionality" );
@@ -492,7 +491,6 @@ int main(int argc, char *argv[])if (nl80211) {manager_exit (); -anqp_exit ();wiphy_exit ();l_genl_family_free (nl80211); }
Signature · 1 line
2.17.1
PATCH v2 5/12 manager: remove white/black list from argument
In reply to James PrestwoodInstead we add getters for these lists that manager_init can use.
--- src/iwd.h | 6 ++++-- src/main.c | 12 +++++++++++- src/manager.c | 5 +++-- 3 files changed, 18 insertions(+), 5 deletions(-)
src/iwd.h +4 -2
@@ -30,10 +30,12 @@ struct l_genl *iwd_get_genl(void);void netdev_shutdown (void ); -bool manager_init (struct l_genl_family *in, -const char *if_whitelist,const char *if_blacklist); +bool manager_init (struct l_genl_family *in);void manager_exit (void ); +const char *iwd_get_iface_whitelist (void ); +const char *iwd_get_iface_blacklist (void ); +struct iwd_module_desc {const char *name;int (*init)(void );
src/main.c +11 -1
@@ -102,6 +102,16 @@ struct l_genl *iwd_get_genl(void)return genl; } +const char *iwd_get_iface_whitelist (void ) +{ +return interfaces; +} + +const char *iwd_get_iface_blacklist (void ) +{ +return nointerfaces; +} +static void usage (void ) { printf("iwd - Wireless daemon\n"
@@ -154,7 +164,7 @@ static void nl80211_appeared(const struct l_genl_family_info *info,plugin_init (plugins, noplugins); -manager_init (nl80211, interfaces, nointerfaces); +manager_init (nl80211);if (!wiphy_init (nl80211, phys, nophys))l_error ("Unable to init wiphy functionality" );
src/manager.c +3 -2
@@ -584,14 +584,15 @@ static void manager_config_notify(struct l_genl_msg *msg, void *user_data) } } -bool manager_init (struct l_genl_family *in, -const char *if_whitelist,const char *if_blacklist) +bool manager_init (struct l_genl_family *in) {const struct l_settings *config =iwd_get_config ();struct l_genl_msg *msg;unsigned int wiphy_dump;unsigned int interface_dump;const char *randomize_str; +const char *if_whitelist =iwd_get_iface_whitelist (); +const char *if_blacklist =iwd_get_iface_blacklist (); nl80211 = in;
Signature · 1 line
2.17.1
PATCH v2 6/12 manager: utilize IWD_MODULE
In reply to James PrestwoodConverts manager into an IWD module.
--- src/iwd.h | 3 --- src/main.c | 3 --- src/manager.c | 25 ++++++++++++++++++------- 3 files changed, 18 insertions(+), 13 deletions(-)
src/iwd.h +0 -3
@@ -30,9 +30,6 @@ struct l_genl *iwd_get_genl(void);void netdev_shutdown (void ); -bool manager_init (struct l_genl_family *in); -void manager_exit (void ); -const char *iwd_get_iface_whitelist (void );const char *iwd_get_iface_blacklist (void );
src/main.c +0 -3
@@ -164,8 +164,6 @@ static void nl80211_appeared(const struct l_genl_family_info *info,plugin_init (plugins, noplugins); -manager_init (nl80211); -if (!wiphy_init (nl80211, phys, nophys))l_error ("Unable to init wiphy functionality" ); }
@@ -500,7 +498,6 @@ int main(int argc, char *argv[])eap_exit ();if (nl80211) { -manager_exit ();wiphy_exit ();l_genl_family_free (nl80211); }
src/manager.c +18 -7
@@ -584,8 +584,9 @@ static void manager_config_notify(struct l_genl_msg *msg, void *user_data) } } -bool manager_init (struct l_genl_family *in) +static int manager_init (void ) { +struct l_genl *genl =iwd_get_genl ();const struct l_settings *config =iwd_get_config ();struct l_genl_msg *msg;unsigned int wiphy_dump;
@@ -594,7 +595,7 @@ bool manager_init(struct l_genl_family *in)const char *if_whitelist =iwd_get_iface_whitelist ();const char *if_blacklist =iwd_get_iface_blacklist (); - nl80211 = in; + nl80211 =l_genl_family_new (genl,NL80211_GENL_NAME );if (if_whitelist) whitelist_filter =l_strsplit (if_whitelist,',' );
@@ -607,7 +608,7 @@ bool manager_init(struct l_genl_family *in)if (!l_genl_family_register (nl80211,"config" , manager_config_notify,NULL ,NULL )) {l_error ("Registering for config notifications failed" ); -return false; + goto error; } msg =l_genl_msg_new_sized (NL80211_CMD_GET_WIPHY ,128 );
@@ -618,7 +619,7 @@ bool manager_init(struct l_genl_family *in)if (!wiphy_dump) {l_error ("Initial wiphy information dump failed" );l_genl_msg_unref (msg); -return false; + goto error; } msg =l_genl_msg_new (NL80211_CMD_GET_INTERFACE );
@@ -630,7 +631,7 @@ bool manager_init(struct l_genl_family *in)l_error ("Initial interface information dump failed" );l_genl_msg_unref (msg);l_genl_family_cancel (nl80211, wiphy_dump); -return false; + goto error; } randomize_str =
@@ -638,10 +639,17 @@ bool manager_init(struct l_genl_family *in)if (randomize_str && !strcmp (randomize_str,"once" )) randomize = true; -return true; +return 0 ; + +error: +l_queue_destroy (pending_wiphys,NULL ); +l_genl_family_free (nl80211); + nl80211 =NULL ; + +return -EIO ; } -void manager_exit (void ) +static void manager_exit (void ) {l_strfreev (whitelist_filter);l_strfreev (blacklist_filter);
@@ -649,6 +657,9 @@ void manager_exit(void)l_queue_destroy (pending_wiphys, wiphy_setup_state_free); pending_wiphys =NULL ; +l_genl_family_free (nl80211); nl80211 =NULL ; randomize = false; } + +IWD_MODULE (manager, manager_init, manager_exit);
Signature · 1 line
2.17.1
PATCH v2 7/12 wiphy: remove white/blacklist from wiphy_init
In reply to James Prestwoodwiphy will now use getters for the phy white/black list.
--- src/iwd.h | 3 +++ src/main.c | 12 +++++++++++- src/wiphy.c | 5 +++-- src/wiphy.h | 3 +-- 4 files changed, 18 insertions(+), 5 deletions(-)
src/iwd.h +3 -0
@@ -33,6 +33,9 @@ void netdev_shutdown(void);const char *iwd_get_iface_whitelist (void );const char *iwd_get_iface_blacklist (void ); +const char *iwd_get_phy_whitelist (void ); +const char *iwd_get_phy_blacklist (void ); +struct iwd_module_desc {const char *name;int (*init)(void );
src/main.c +11 -1
@@ -112,6 +112,16 @@ const char *iwd_get_iface_blacklist(void)return nointerfaces; } +const char *iwd_get_phy_whitelist (void ) +{ +return phys; +} + +const char *iwd_get_phy_blacklist (void ) +{ +return nophys; +} +static void usage (void ) { printf("iwd - Wireless daemon\n"
@@ -164,7 +174,7 @@ static void nl80211_appeared(const struct l_genl_family_info *info,plugin_init (plugins, noplugins); -if (!wiphy_init (nl80211, phys, nophys)) +if (!wiphy_init (nl80211))l_error ("Unable to init wiphy functionality" ); }
src/wiphy.c +3 -2
@@ -1150,12 +1150,13 @@ static void setup_wiphy_interface(struct l_dbus_interface *interface) NULL); } -bool wiphy_init (struct l_genl_family *in,const char *whitelist, -const char *blacklist) +bool wiphy_init (struct l_genl_family *in) {const struct l_settings *config =iwd_get_config ();const char *s =l_settings_get_value (config,"General" ,"mac_randomize_bytes" ); +const char *whitelist =iwd_get_phy_whitelist (); +const char *blacklist =iwd_get_phy_blacklist ();if (s && !strcmp (s,"nic" )) mac_randomize_bytes =3 ;
src/wiphy.h +1 -2
@@ -82,6 +82,5 @@ uint32_t wiphy_state_watch_add(struct wiphy *wiphy, wiphy_destroy_func_t destroy);bool wiphy_state_watch_remove (struct wiphy *wiphy,uint32_t id); -bool wiphy_init (struct l_genl_family *in,const char *whitelist, -const char *blacklist); +bool wiphy_init (struct l_genl_family *in);bool wiphy_exit (void );
Signature · 1 line
2.17.1
PATCH v2 8/12 wiphy: utilize IWD_MODULE
In reply to James PrestwoodThis converts wiphy into an IWD module. nl80211 was completely removed from main.c as it is no longer passed with manager or wiphy.
--- src/main.c | 15 ++++----------- src/wiphy.c | 17 ++++++++++------- src/wiphy.h | 3 --- 3 files changed, 14 insertions(+), 21 deletions(-)
src/main.c +4 -11
@@ -46,7 +46,6 @@#include "src/backtrace.h" static struct l_genl *genl; -static struct l_genl_family *nl80211;static struct l_settings *iwd_config;static struct l_timeout *timeout;static const char *interfaces;
@@ -57,6 +56,7 @@ static const char *plugins;static const char *noplugins;static const char *debugopt;static bool terminating; +static bool nl80211_complete;static void main_loop_quit (struct l_timeout *timeout,void *user_data) {
@@ -70,7 +70,7 @@ static void iwd_shutdown(void) terminating = true; -if (!nl80211) { +if (!nl80211_complete) {l_main_quit ();return ; }
@@ -165,7 +165,8 @@ static void nl80211_appeared(const struct l_genl_family_info *info, void *user_data) {l_debug ("Found nl80211 interface" ); - nl80211 =l_genl_family_new (genl,NL80211_GENL_NAME ); + + nl80211_complete = true;if (iwd_modules_init () <0 ) {l_main_quit ();
@@ -173,9 +174,6 @@ static void nl80211_appeared(const struct l_genl_family_info *info, }plugin_init (plugins, noplugins); - -if (!wiphy_init (nl80211)) -l_error ("Unable to init wiphy functionality" ); } static void request_name_callback(struct l_dbus *dbus, bool success,
@@ -507,11 +505,6 @@ int main(int argc, char *argv[])eap_exit (); -if (nl80211) { -wiphy_exit (); -l_genl_family_free (nl80211); - } -dbus_exit ();l_dbus_destroy (dbus);storage_cleanup_dirs ();
src/wiphy.c +10 -7
@@ -1150,14 +1150,17 @@ static void setup_wiphy_interface(struct l_dbus_interface *interface) NULL); } -bool wiphy_init (struct l_genl_family *in) +static int wiphy_init (void ) { +struct l_genl *genl =iwd_get_genl ();const struct l_settings *config =iwd_get_config ();const char *s =l_settings_get_value (config,"General" ,"mac_randomize_bytes" );const char *whitelist =iwd_get_phy_whitelist ();const char *blacklist =iwd_get_phy_blacklist (); + nl80211 =l_genl_family_new (genl,NL80211_GENL_NAME ); +if (s && !strcmp (s,"nic" )) mac_randomize_bytes =3 ;
@@ -1170,8 +1173,6 @@ bool wiphy_init(struct l_genl_family *in)l_queue_destroy (wiphy_list,NULL ); } - nl80211 = in; - wiphy_list =l_queue_new ();rfkill_watch_add (wiphy_rfkill_cb,NULL );
@@ -1191,10 +1192,10 @@ bool wiphy_init(struct l_genl_family *in)if (blacklist) blacklist_filter =l_strsplit (blacklist,',' ); -return true; +return 0 ; } -bool wiphy_exit (void ) +static void wiphy_exit (void ) {l_strfreev (whitelist_filter);l_strfreev (blacklist_filter);
@@ -1202,12 +1203,14 @@ bool wiphy_exit(void)l_queue_destroy (wiphy_list, wiphy_free); wiphy_list =NULL ; +l_genl_family_free (nl80211); nl80211 =NULL ; mac_randomize_bytes =6 ;l_dbus_unregister_interface (dbus_get_bus (),IWD_WIPHY_INTERFACE );l_hwdb_unref (hwdb); - -return true; } + +IWD_MODULE (wiphy, wiphy_init, wiphy_exit); +IWD_MODULE_DEPENDS (wiphy, rfkill);
src/wiphy.h +0 -3
@@ -81,6 +81,3 @@ uint32_t wiphy_state_watch_add(struct wiphy *wiphy, wiphy_state_watch_func_t func, void *user_data, wiphy_destroy_func_t destroy);bool wiphy_state_watch_remove (struct wiphy *wiphy,uint32_t id); - -bool wiphy_init (struct l_genl_family *in); -bool wiphy_exit (void );
Signature · 1 line
2.17.1
PATCH v2 9/12 eap: remove mtu argument from eap_init
In reply to James PrestwoodThis was refactored to set the mtu via __eap_set_config rather than passing the MTU into eap_init. This makes eap work in a similar fashion as eapol (i.e. __eapol_set_config).
If __eap_set_config is not used, the MTU will be set to 1020, which is the same as previously passing 0 to eap_init.
--- src/eap.c | 12 ++++++++---- src/eap.h | 4 +++- src/main.c | 7 ++----- 3 files changed, 13 insertions(+), 10 deletions(-)
src/eap.c +8 -4
@@ -676,6 +676,12 @@ int eap_unregister_method(struct eap_method *method)return -ENOENT ; } +void __eap_set_config (struct l_settings *config) +{ +if (!l_settings_get_uint (config,"EAP" ,"mtu" , &default_mtu)) + default_mtu =1400 ;/* on WiFi the real MTU is around 2304 */ +} +static void __eap_method_enable (struct eap_method_desc *start,struct eap_method_desc *stop) {
@@ -715,7 +721,7 @@ static void __eap_method_disable(struct eap_method_desc *start,extern struct eap_method_desc __start___eap[];extern struct eap_method_desc __stop___eap[]; -void eap_init (uint32_t mtu) +void eap_init (void ) { eap_methods =l_queue_new ();__eap_method_enable (__start___eap, __stop___eap);
@@ -725,10 +731,8 @@ void eap_init(uint32_t mtu)* EAP is capable of functioning on lower layers that * provide an EAP MTU size of 1020 octets or greater. */ -if (mtu ==0 ) +if (default_mtu ==0 ) default_mtu =1020 ; -else - default_mtu = mtu; }void eap_exit (void )
src/eap.h +3 -1
@@ -93,5 +93,7 @@ const char *eap_get_identity(struct eap_state *eap);void eap_rx_packet (struct eap_state *eap,const uint8_t *pkt,size_t len); -void eap_init (uint32_t default_mtu); +void __eap_set_config (struct l_settings *config); + +void eap_init (void );void eap_exit (void );
src/main.c +2 -5
@@ -367,7 +367,6 @@ int main(int argc, char *argv[])struct l_dbus *dbus;const char *config_dir;char **config_dirs; -uint32_t eap_mtu;int i;for (;;) {
@@ -465,9 +464,7 @@ int main(int argc, char *argv[])l_strv_free (config_dirs);__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 */ +__eap_set_config (iwd_config); exit_status =EXIT_FAILURE ;
@@ -496,7 +493,7 @@ int main(int argc, char *argv[])l_dbus_set_disconnect_handler (dbus, dbus_disconnected,NULL ,NULL );dbus_init (dbus); -eap_init (eap_mtu); +eap_init (); exit_status =l_main_run_with_signal (signal_handler,NULL );plugin_exit ();
Signature · 1 line
2.17.1
PATCH v2 10/12 wired: update with new eap_init
In reply to James Prestwood--- wired/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
wired/main.c +1 -1
@@ -46,7 +46,7 @@ static void dbus_ready(struct l_dbus *dbus, void *user_data)l_info ("System ready" ); -eap_init (0 ); +eap_init ();network_init ();ethdev_init (opts->interfaces, opts->nointerfaces); }
Signature · 1 line
2.17.1
PATCH v2 11/12 unit: update wsc/eapol with new eap_init
In reply to James Prestwoodtest-eapol was passing zero as the MTU, so this simply needed to be updated to remove that parameter.
test-wsc was actually setting a MTU value so when building the settings we now add the proper value so the MTU can be set with __eap_set_config.
--- unit/test-eapol.c | 4 ++-- unit/test-wsc.c | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-)
unit/test-eapol.c +2 -2
@@ -2912,7 +2912,7 @@ static void eapol_sm_test_tls(struct eapol_8021x_tls_test_state *s, aa = ap_address; spa = sta_address; -eap_init (0 ); +eap_init ();eapol_init ();__handshake_set_get_nonce_func (test_nonce);
@@ -3375,7 +3375,7 @@ static void eapol_sm_test_eap_nak(const void *data) aa = ap_address; spa = sta_address; -eap_init (0 ); +eap_init ();eapol_init ();__handshake_set_get_nonce_func (test_nonce);
unit/test-wsc.c +6 -2
@@ -1989,7 +1989,7 @@ static void wsc_test_pbc_handshake(const void *data)char *hex;struct l_settings *settings; -eap_init (1400 ); +eap_init ();eapol_init (); hs =test_handshake_state_new (1 );
@@ -2006,6 +2006,7 @@ static void wsc_test_pbc_handshake(const void *data)eapol_sm_set_event_func (sm, verify_credential); settings =l_settings_new (); +l_settings_set_uint (settings,"EAP" ,"mtu" ,1400 );l_settings_set_string (settings,"Security" ,"EAP-Identity" ,"WFA-SimpleConfig-Enrollee-1-0" );l_settings_set_string (settings,"Security" ,"EAP-Method" ,"WSC" );
@@ -2039,6 +2040,7 @@ static void wsc_test_pbc_handshake(const void *data)l_settings_set_string (settings,"WSC" ,"IV2" ,"4e3a4cf088176989e148d4c10b96e8fd" ); +__eap_set_config (settings);handshake_state_set_8021x_config (hs, settings);eapol_start (sm);
@@ -2097,7 +2099,7 @@ static void wsc_test_retransmission_no_fragmentation(const void *data)char *hex;struct l_settings *settings; -eap_init (1400 ); +eap_init ();eapol_init (); hs =test_handshake_state_new (1 );
@@ -2114,6 +2116,7 @@ static void wsc_test_retransmission_no_fragmentation(const void *data)eapol_sm_set_event_func (sm, verify_credential); settings =l_settings_new (); +l_settings_set_uint (settings,"EAP" ,"mtu" ,1400 );l_settings_set_string (settings,"Security" ,"EAP-Identity" ,"WFA-SimpleConfig-Enrollee-1-0" );l_settings_set_string (settings,"Security" ,"EAP-Method" ,"WSC" );
@@ -2147,6 +2150,7 @@ static void wsc_test_retransmission_no_fragmentation(const void *data)l_settings_set_string (settings,"WSC" ,"IV2" ,"4e3a4cf088176989e148d4c10b96e8fd" ); +__eap_set_config (settings);handshake_state_set_8021x_config (hs, settings);eapol_start (sm);
Signature · 1 line
2.17.1
PATCH v2 12/12 eap: utilize IWD_MODULE
In reply to James PrestwoodConverts eap into an IWD module.
--- src/eap.c | 7 ++++++- src/eap.h | 2 +- src/main.c | 4 ---- 3 files changed, 7 insertions(+), 6 deletions(-)
src/eap.c +6 -1
@@ -33,6 +33,7 @@#include "src/missing.h" #include "src/eap.h" #include "src/eap-private.h" +#include "src/iwd.h" static uint32_t default_mtu;static struct l_queue *eap_methods;
@@ -721,7 +722,7 @@ static void __eap_method_disable(struct eap_method_desc *start,extern struct eap_method_desc __start___eap[];extern struct eap_method_desc __stop___eap[]; -void eap_init (void ) +int eap_init (void ) { eap_methods =l_queue_new ();__eap_method_enable (__start___eap, __stop___eap);
@@ -733,6 +734,8 @@ void eap_init(void)*/ if (default_mtu ==0 ) default_mtu =1020 ; + +return 0 ; }void eap_exit (void )
@@ -740,3 +743,5 @@ void eap_exit(void)__eap_method_disable (__start___eap, __stop___eap);l_queue_destroy (eap_methods,NULL ); } + +IWD_MODULE (eap, eap_init, eap_exit);
src/eap.h +1 -1
@@ -95,5 +95,5 @@ void eap_rx_packet(struct eap_state *eap, const uint8_t *pkt, size_t len);void __eap_set_config (struct l_settings *config); -void eap_init (void ); +int eap_init (void );void eap_exit (void );
src/main.c +0 -4
@@ -493,15 +493,11 @@ int main(int argc, char *argv[])l_dbus_set_disconnect_handler (dbus, dbus_disconnected,NULL ,NULL );dbus_init (dbus); -eap_init (); - exit_status =l_main_run_with_signal (signal_handler,NULL );plugin_exit ();iwd_modules_exit (); -eap_exit (); -dbus_exit ();l_dbus_destroy (dbus);storage_cleanup_dirs ();
Signature · 1 line
2.17.1
Hi James,
Quoted 10 lines · James Prestwood
In preparation for integrating
IWD_MODULEinto modules which require nl80211 we move the module init into thenl80211_appearedcallback. This will guarentee that the nl80211 is available during module init and allow modules to get their own copy of nl80211 rather than needing a set function (e.g.netdev_set_nl80211).Since the dbus name request callback happens before this as well any dbus module can also use
IWD_MODULEand simply assume the dbus object is ready.
Quoted 9 lines
plugin_initwas also deferred tonl80211_appearedsince some plugins depend on modules being initialized.--- src/main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)-v2:
* Movedplugin_initafteriwd_modules_init
All applied, thanks.
Regards,
-Denis