* [PATCH v2 01/12] main: move module init into nl80211_appeared
@ 2019-10-11 19:29 James Prestwood
2019-10-11 19:29 ` [PATCH v2 02/12] netdev: utilize IWD_MODULE James Prestwood
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: James Prestwood @ 2019-10-11 19:29 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 1579 bytes --]
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
diff --git a/src/main.c b/src/main.c
index b34da3d0..0e6fad14 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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:
--
2.17.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 02/12] netdev: utilize IWD_MODULE
2019-10-11 19:29 [PATCH v2 01/12] main: move module init into nl80211_appeared James Prestwood
@ 2019-10-11 19:29 ` James Prestwood
2019-10-11 19:29 ` [PATCH v2 03/12] eapol: " James Prestwood
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2019-10-11 19:29 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 3453 bytes --]
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(-)
diff --git a/src/iwd.h b/src/iwd.h
index 8bb4f64f..7ae7e4b4 100644
--- a/src/iwd.h
+++ b/src/iwd.h
@@ -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,
diff --git a/src/main.c b/src/main.c
index 0e6fad14..4ff5f010 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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();
diff --git a/src/netdev.c b/src/netdev.c
index 773f0795..1828f5d0 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -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);
--
2.17.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 03/12] eapol: utilize IWD_MODULE
2019-10-11 19:29 [PATCH v2 01/12] main: move module init into nl80211_appeared James Prestwood
2019-10-11 19:29 ` [PATCH v2 02/12] netdev: utilize IWD_MODULE James Prestwood
@ 2019-10-11 19:29 ` James Prestwood
2019-10-11 19:29 ` [PATCH v2 04/12] anqp: " James Prestwood
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2019-10-11 19:29 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 2326 bytes --]
This 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(-)
diff --git a/src/eapol.c b/src/eapol.c
index 414d1c69..6732b370 100644
--- a/src/eapol.c
+++ b/src/eapol.c
@@ -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);
diff --git a/src/eapol.h b/src/eapol.h
index 1a1862bd..9462b56d 100644
--- a/src/eapol.h
+++ b/src/eapol.h
@@ -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);
diff --git a/src/main.c b/src/main.c
index 4ff5f010..1acee95e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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) {
diff --git a/src/netdev.c b/src/netdev.c
index 1828f5d0..0785f0c4 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -4841,3 +4841,4 @@ void netdev_shutdown(void)
}
IWD_MODULE(netdev, netdev_init, netdev_exit);
+IWD_MODULE_DEPENDS(netdev, eapol);
--
2.17.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 04/12] anqp: utilize IWD_MODULE
2019-10-11 19:29 [PATCH v2 01/12] main: move module init into nl80211_appeared James Prestwood
2019-10-11 19:29 ` [PATCH v2 02/12] netdev: utilize IWD_MODULE James Prestwood
2019-10-11 19:29 ` [PATCH v2 03/12] eapol: " James Prestwood
@ 2019-10-11 19:29 ` James Prestwood
2019-10-11 19:29 ` [PATCH v2 05/12] manager: remove white/black list from argument James Prestwood
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2019-10-11 19:29 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 2176 bytes --]
This 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(-)
diff --git a/src/anqp.c b/src/anqp.c
index 9f006bd6..a47530ab 100644
--- a/src/anqp.c
+++ b/src/anqp.c
@@ -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);
diff --git a/src/anqp.h b/src/anqp.h
index 62d097d1..998277dd 100644
--- a/src/anqp.h
+++ b/src/anqp.h
@@ -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);
diff --git a/src/main.c b/src/main.c
index 1acee95e..08bf38a3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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);
}
--
2.17.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 05/12] manager: remove white/black list from argument
2019-10-11 19:29 [PATCH v2 01/12] main: move module init into nl80211_appeared James Prestwood
` (2 preceding siblings ...)
2019-10-11 19:29 ` [PATCH v2 04/12] anqp: " James Prestwood
@ 2019-10-11 19:29 ` James Prestwood
2019-10-11 19:29 ` [PATCH v2 06/12] manager: utilize IWD_MODULE James Prestwood
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2019-10-11 19:29 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 2172 bytes --]
Instead 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(-)
diff --git a/src/iwd.h b/src/iwd.h
index 7ae7e4b4..1fa1e25a 100644
--- a/src/iwd.h
+++ b/src/iwd.h
@@ -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);
diff --git a/src/main.c b/src/main.c
index 08bf38a3..d4915412 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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");
diff --git a/src/manager.c b/src/manager.c
index 1a04b071..e731cf9d 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -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;
--
2.17.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 06/12] manager: utilize IWD_MODULE
2019-10-11 19:29 [PATCH v2 01/12] main: move module init into nl80211_appeared James Prestwood
` (3 preceding siblings ...)
2019-10-11 19:29 ` [PATCH v2 05/12] manager: remove white/black list from argument James Prestwood
@ 2019-10-11 19:29 ` James Prestwood
2019-10-11 19:29 ` [PATCH v2 07/12] wiphy: remove white/blacklist from wiphy_init James Prestwood
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2019-10-11 19:29 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 3439 bytes --]
Converts manager into an IWD module.
---
src/iwd.h | 3 ---
src/main.c | 3 ---
src/manager.c | 25 ++++++++++++++++++-------
3 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/src/iwd.h b/src/iwd.h
index 1fa1e25a..8814c244 100644
--- a/src/iwd.h
+++ b/src/iwd.h
@@ -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);
diff --git a/src/main.c b/src/main.c
index d4915412..761d869e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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);
}
diff --git a/src/manager.c b/src/manager.c
index e731cf9d..f1e50421 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -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);
--
2.17.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 07/12] wiphy: remove white/blacklist from wiphy_init
2019-10-11 19:29 [PATCH v2 01/12] main: move module init into nl80211_appeared James Prestwood
` (4 preceding siblings ...)
2019-10-11 19:29 ` [PATCH v2 06/12] manager: utilize IWD_MODULE James Prestwood
@ 2019-10-11 19:29 ` James Prestwood
2019-10-11 19:29 ` [PATCH v2 08/12] wiphy: utilize IWD_MODULE James Prestwood
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2019-10-11 19:29 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 2451 bytes --]
wiphy 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(-)
diff --git a/src/iwd.h b/src/iwd.h
index 8814c244..6073fae5 100644
--- a/src/iwd.h
+++ b/src/iwd.h
@@ -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);
diff --git a/src/main.c b/src/main.c
index 761d869e..50a1499d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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");
}
diff --git a/src/wiphy.c b/src/wiphy.c
index b672afd4..3316a084 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -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;
diff --git a/src/wiphy.h b/src/wiphy.h
index 10cf5373..ac94585f 100644
--- a/src/wiphy.h
+++ b/src/wiphy.h
@@ -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);
--
2.17.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 08/12] wiphy: utilize IWD_MODULE
2019-10-11 19:29 [PATCH v2 01/12] main: move module init into nl80211_appeared James Prestwood
` (5 preceding siblings ...)
2019-10-11 19:29 ` [PATCH v2 07/12] wiphy: remove white/blacklist from wiphy_init James Prestwood
@ 2019-10-11 19:29 ` James Prestwood
2019-10-11 19:29 ` [PATCH v2 09/12] eap: remove mtu argument from eap_init James Prestwood
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2019-10-11 19:29 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 3913 bytes --]
This 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(-)
diff --git a/src/main.c b/src/main.c
index 50a1499d..af6f0f74 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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();
diff --git a/src/wiphy.c b/src/wiphy.c
index 3316a084..169631af 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -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);
diff --git a/src/wiphy.h b/src/wiphy.h
index ac94585f..61e1caf8 100644
--- a/src/wiphy.h
+++ b/src/wiphy.h
@@ -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);
--
2.17.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 09/12] eap: remove mtu argument from eap_init
2019-10-11 19:29 [PATCH v2 01/12] main: move module init into nl80211_appeared James Prestwood
` (6 preceding siblings ...)
2019-10-11 19:29 ` [PATCH v2 08/12] wiphy: utilize IWD_MODULE James Prestwood
@ 2019-10-11 19:29 ` James Prestwood
2019-10-11 19:29 ` [PATCH v2 10/12] wired: update with new eap_init James Prestwood
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2019-10-11 19:29 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 2857 bytes --]
This 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(-)
diff --git a/src/eap.c b/src/eap.c
index f605f432..b0fa72cf 100644
--- a/src/eap.c
+++ b/src/eap.c
@@ -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)
diff --git a/src/eap.h b/src/eap.h
index de939cdc..8f128304 100644
--- a/src/eap.h
+++ b/src/eap.h
@@ -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);
diff --git a/src/main.c b/src/main.c
index af6f0f74..1ff8d5d8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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();
--
2.17.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 10/12] wired: update with new eap_init
2019-10-11 19:29 [PATCH v2 01/12] main: move module init into nl80211_appeared James Prestwood
` (7 preceding siblings ...)
2019-10-11 19:29 ` [PATCH v2 09/12] eap: remove mtu argument from eap_init James Prestwood
@ 2019-10-11 19:29 ` James Prestwood
2019-10-11 19:29 ` [PATCH v2 11/12] unit: update wsc/eapol " James Prestwood
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2019-10-11 19:29 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 426 bytes --]
---
wired/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/wired/main.c b/wired/main.c
index 7e6d26dd..09dbb72d 100644
--- a/wired/main.c
+++ b/wired/main.c
@@ -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);
}
--
2.17.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 11/12] unit: update wsc/eapol with new eap_init
2019-10-11 19:29 [PATCH v2 01/12] main: move module init into nl80211_appeared James Prestwood
` (8 preceding siblings ...)
2019-10-11 19:29 ` [PATCH v2 10/12] wired: update with new eap_init James Prestwood
@ 2019-10-11 19:29 ` James Prestwood
2019-10-11 19:29 ` [PATCH v2 12/12] eap: utilize IWD_MODULE James Prestwood
2019-10-11 20:49 ` [PATCH v2 01/12] main: move module init into nl80211_appeared Denis Kenzior
11 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2019-10-11 19:29 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 2919 bytes --]
test-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(-)
diff --git a/unit/test-eapol.c b/unit/test-eapol.c
index 177b2577..f7099e6d 100644
--- a/unit/test-eapol.c
+++ b/unit/test-eapol.c
@@ -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);
diff --git a/unit/test-wsc.c b/unit/test-wsc.c
index b1a6d786..b4814622 100644
--- a/unit/test-wsc.c
+++ b/unit/test-wsc.c
@@ -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);
--
2.17.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 12/12] eap: utilize IWD_MODULE
2019-10-11 19:29 [PATCH v2 01/12] main: move module init into nl80211_appeared James Prestwood
` (9 preceding siblings ...)
2019-10-11 19:29 ` [PATCH v2 11/12] unit: update wsc/eapol " James Prestwood
@ 2019-10-11 19:29 ` James Prestwood
2019-10-11 20:49 ` [PATCH v2 01/12] main: move module init into nl80211_appeared Denis Kenzior
11 siblings, 0 replies; 13+ messages in thread
From: James Prestwood @ 2019-10-11 19:29 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 1903 bytes --]
Converts eap into an IWD module.
---
src/eap.c | 7 ++++++-
src/eap.h | 2 +-
src/main.c | 4 ----
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/eap.c b/src/eap.c
index b0fa72cf..23868811 100644
--- a/src/eap.c
+++ b/src/eap.c
@@ -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);
diff --git a/src/eap.h b/src/eap.h
index 8f128304..8b2de8c9 100644
--- a/src/eap.h
+++ b/src/eap.h
@@ -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);
diff --git a/src/main.c b/src/main.c
index 1ff8d5d8..871104dd 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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();
--
2.17.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 01/12] main: move module init into nl80211_appeared
2019-10-11 19:29 [PATCH v2 01/12] main: move module init into nl80211_appeared James Prestwood
` (10 preceding siblings ...)
2019-10-11 19:29 ` [PATCH v2 12/12] eap: utilize IWD_MODULE James Prestwood
@ 2019-10-11 20:49 ` Denis Kenzior
11 siblings, 0 replies; 13+ messages in thread
From: Denis Kenzior @ 2019-10-11 20:49 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 872 bytes --]
Hi James,
On 10/11/19 2:29 PM, James Prestwood wrote:
> 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
>
All applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2019-10-11 20:49 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-11 19:29 [PATCH v2 01/12] main: move module init into nl80211_appeared James Prestwood
2019-10-11 19:29 ` [PATCH v2 02/12] netdev: utilize IWD_MODULE James Prestwood
2019-10-11 19:29 ` [PATCH v2 03/12] eapol: " James Prestwood
2019-10-11 19:29 ` [PATCH v2 04/12] anqp: " James Prestwood
2019-10-11 19:29 ` [PATCH v2 05/12] manager: remove white/black list from argument James Prestwood
2019-10-11 19:29 ` [PATCH v2 06/12] manager: utilize IWD_MODULE James Prestwood
2019-10-11 19:29 ` [PATCH v2 07/12] wiphy: remove white/blacklist from wiphy_init James Prestwood
2019-10-11 19:29 ` [PATCH v2 08/12] wiphy: utilize IWD_MODULE James Prestwood
2019-10-11 19:29 ` [PATCH v2 09/12] eap: remove mtu argument from eap_init James Prestwood
2019-10-11 19:29 ` [PATCH v2 10/12] wired: update with new eap_init James Prestwood
2019-10-11 19:29 ` [PATCH v2 11/12] unit: update wsc/eapol " James Prestwood
2019-10-11 19:29 ` [PATCH v2 12/12] eap: utilize IWD_MODULE James Prestwood
2019-10-11 20:49 ` [PATCH v2 01/12] main: move module init into nl80211_appeared Denis Kenzior
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.