main: move module init into nl80211_appeared
PATCH 1/11 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.
--- src/main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
src/main.c +5 -4
@@ -147,6 +147,11 @@ 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 ; + } +manager_init (nl80211, interfaces, nointerfaces);anqp_init (nl80211);
@@ -482,14 +487,10 @@ 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 2/11 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
@@ -157,8 +157,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,
@@ -484,16 +482,12 @@ int main(int argc, char *argv[])eap_init (eap_mtu);eapol_init (); -if (!netdev_init ()) - goto fail_netdev; -plugin_init (plugins, noplugins); 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 3/11 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
@@ -480,7 +480,6 @@ int main(int argc, char *argv[])dbus_init (dbus);eap_init (eap_mtu); -eapol_init ();plugin_init (plugins, noplugins); exit_status =l_main_run_with_signal (signal_handler,NULL );
@@ -488,7 +487,6 @@ int main(int argc, char *argv[])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 4/11 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
@@ -153,7 +153,6 @@ static void nl80211_appeared(const struct l_genl_family_info *info, }manager_init (nl80211, interfaces, nointerfaces); -anqp_init (nl80211);if (!wiphy_init (nl80211, phys, nophys))l_error ("Unable to init wiphy functionality" );
@@ -491,7 +490,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 5/11 agent: utilize IWD_MODULE
In reply to James PrestwoodConverts agent into an IWD module. This removes the dbus dependency on agent. Since dbus is initialized very early we can assume dbus_get_bus is going to return a valid object.
--- src/agent.c | 19 ++++++++++++------- src/agent.h | 2 -- src/dbus.c | 3 +-- 3 files changed, 13 insertions(+), 11 deletions(-)
src/agent.c +12 -7
@@ -29,6 +29,7 @@#include <ell/ell.h> #include "src/dbus.h" #include "src/agent.h" +#include "src/iwd.h" static unsigned int next_request_id =0 ;
@@ -619,8 +620,10 @@ static bool release_agent(void *data, void *user_data)return true; } -bool agent_init(struct l_dbus *dbus) +static int agent_init(void) { + struct l_dbus *dbus = dbus_get_bus(); + agents = l_queue_new(); if (!l_dbus_register_interface(dbus, IWD_AGENT_MANAGER_INTERFACE,
@@ -628,7 +631,7 @@ bool agent_init(struct l_dbus *dbus) NULL, false)) {l_info ("Unable to register %s interface" ,IWD_AGENT_MANAGER_INTERFACE ); -return false; +return -EIO ; } if (!l_dbus_object_add_interface(dbus, IWD_AGENT_MANAGER_PATH,
@@ -637,24 +640,26 @@ bool agent_init(struct l_dbus *dbus)l_info ("Unable to register the agent manager object on '%s'" ,IWD_AGENT_MANAGER_PATH );l_dbus_unregister_interface (dbus,IWD_AGENT_MANAGER_INTERFACE ); -return false; +return -EIO ; } -return true; +return 0 ; } -bool agent_exit (struct l_dbus *dbus) +static void agent_exit (void ) { +struct l_dbus *dbus =dbus_get_bus (); +l_dbus_unregister_object (dbus,IWD_AGENT_MANAGER_PATH );l_dbus_unregister_interface (dbus,IWD_AGENT_MANAGER_INTERFACE );l_queue_destroy (agents, agent_free); agents =NULL ; - -return true; }void agent_shutdown (void ) {l_queue_foreach_remove (agents, release_agent,NULL ); } + +IWD_MODULE (agent, agent_init, agent_exit);
src/agent.h +0 -2
@@ -37,8 +37,6 @@ typedef void (*agent_request_user_name_passwd_func_t) (enum agent_result result, void *user_data);typedef void (*agent_request_destroy_func_t )(void *user_data); -bool agent_init (struct l_dbus *dbus); -bool agent_exit (struct l_dbus *dbus);void agent_shutdown (void ); unsigned int agent_request_passphrase(const char *path,
src/dbus.c +1 -2
@@ -210,12 +210,11 @@ struct l_dbus *dbus_get_bus(void)bool dbus_init (struct l_dbus *dbus) { g_dbus = dbus; -return agent_init (dbus); +return true; }void dbus_exit (void ) { -agent_exit (g_dbus); g_dbus =NULL ; }
Signature · 1 line
2.17.1
Denis Kenzior
AppliedRe: [PATCH 05/11] agent: utilize IWD_MODULE
Hi James,
Quoted 9 lines · James Prestwood
Converts agent into an IWD module. This removes the dbus dependency on agent. Since dbus is initialized very early we can assume
dbus_get_busis going to return a valid object.--- src/agent.c | 19 ++++++++++++------- src/agent.h | 2 -- src/dbus.c | 3 +-- 3 files changed, 13 insertions(+), 11 deletions(-)
Applied, thanks.
Regards,
-Denis
PATCH 6/11 manager: utilize IWD_MODULE
In reply to James PrestwoodConverts manager into an IWD module. Two getters needed to be added so manager can get the white/black list of interfaces.
--- src/iwd.h | 5 ++--- src/main.c | 13 ++++++++++--- src/manager.c | 26 ++++++++++++++++++-------- 3 files changed, 30 insertions(+), 14 deletions(-)
src/iwd.h +2 -3
@@ -30,9 +30,8 @@ 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); -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;
src/main.c +10 -3
@@ -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"
@@ -152,8 +162,6 @@ static void nl80211_appeared(const struct l_genl_family_info *info,return ; } -manager_init (nl80211, interfaces, nointerfaces); -if (!wiphy_init (nl80211, phys, nophys))l_error ("Unable to init wiphy functionality" ); }
@@ -489,7 +497,6 @@ int main(int argc, char *argv[])eap_exit ();if (nl80211) { -manager_exit ();wiphy_exit ();l_genl_family_free (nl80211); }
src/manager.c +18 -8
@@ -584,16 +584,18 @@ 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) +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;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; + nl80211 =l_genl_family_new (genl,NL80211_GENL_NAME );if (if_whitelist) whitelist_filter =l_strsplit (if_whitelist,',' );
@@ -606,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 );
@@ -617,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 );
@@ -629,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 =
@@ -637,10 +639,15 @@ 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); +return -EIO ; } -void manager_exit (void ) +static void manager_exit (void ) {l_strfreev (whitelist_filter);l_strfreev (blacklist_filter);
@@ -648,6 +655,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
Re: [PATCH 06/11] manager: utilize IWD_MODULE
Hi James,
Quoted 2 lines · James Prestwood
Converts manager into an IWD module. Two getters needed to be added so manager can get the white/black list of interfaces.
Can we split this up into two commits please. One for the getter refactoring and one for the module migration.
Quoted 11 lines
--- src/iwd.h | 5 ++--- src/main.c | 13 ++++++++++--- src/manager.c | 26 ++++++++++++++++++-------- 3 files changed, 30 insertions(+), 14 deletions(-)src/iwd.h +0
-0
src/iwd.h struct l_genl *iwd_get_genl(void); · line 34
Quoted 8 lines
src/iwd.h +2
-3@@ -30,9 +30,8 @@ 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); -void manager_exit (void ); +const char *iwd_get_iface_whitelist (void ); +const char *iwd_get_iface_blacklist (void );
Don't we also have phy lists? Ah I guess you take care of this in the next patch...
Quoted 3 lines
src/iwd.h +0
-0struct iwd_module_desc {const char *name;
<snip>
src/iwd.h bool manager_init(struct l_genl_family *in, · line 646
Quoted 10 lines
src/iwd.h +5
-1@@ -637,10 +639,15 @@ 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);
Maybe reset nl80211 to NULL just to be pedantic
src/iwd.h bool manager_init(struct l_genl_family *in, · line 653
Quoted 8 lines
src/iwd.h +2
-1+return -EIO ; } -void manager_exit (void ) +static void manager_exit (void ) {l_strfreev (whitelist_filter);l_strfreev (blacklist_filter);
Regards,
-Denis
PATCH 7/11 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/iwd.h | 2 ++ src/main.c | 25 ++++++++++++++----------- src/wiphy.c | 20 ++++++++++++-------- src/wiphy.h | 4 ---- 4 files changed, 28 insertions(+), 23 deletions(-)
src/iwd.h +2 -0
@@ -32,6 +32,8 @@ 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;
src/main.c +14 -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 ; }
@@ -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"
@@ -155,15 +165,13 @@ 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 ();return ; } - -if (!wiphy_init (nl80211, phys, nophys)) -l_error ("Unable to init wiphy functionality" ); } static void request_name_callback(struct l_dbus *dbus, bool success,
@@ -496,11 +504,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 +12 -8
@@ -1150,12 +1150,16 @@ 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) +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 ;
@@ -1169,8 +1173,6 @@ bool wiphy_init(struct l_genl_family *in, const char *whitelist,l_queue_destroy (wiphy_list,NULL ); } - nl80211 = in; - wiphy_list =l_queue_new ();rfkill_watch_add (wiphy_rfkill_cb,NULL );
@@ -1190,10 +1192,10 @@ bool wiphy_init(struct l_genl_family *in, const char *whitelist,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);
@@ -1201,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 -4
@@ -81,7 +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,const char *whitelist, -const char *blacklist); -bool wiphy_exit (void );
Signature · 1 line
2.17.1
PATCH 8/11 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
@@ -365,7 +365,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 (;;) {
@@ -463,9 +462,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 ;
@@ -494,7 +491,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 ();plugin_init (plugins, noplugins); exit_status =l_main_run_with_signal (signal_handler,NULL );
Signature · 1 line
2.17.1
PATCH 9/11 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 10/11 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 11/11 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
@@ -491,16 +491,12 @@ int main(int argc, char *argv[])l_dbus_set_disconnect_handler (dbus, dbus_disconnected,NULL ,NULL );dbus_init (dbus); -eap_init (); -plugin_init (plugins, noplugins); 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