From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.01.org
Subject: [PATCH 02/11] netdev: utilize IWD_MODULE
Date: Fri, 11 Oct 2019 10:24:08 -0700 [thread overview]
Message-ID: <20191011172417.23328-2-prestwoj@gmail.com> (raw)
In-Reply-To: <20191011172417.23328-1-prestwoj@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3489 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 786b30d6..7707dfb8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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();
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
next prev parent reply other threads:[~2019-10-11 17:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-11 17:24 [PATCH 01/11] main: move module init into nl80211_appeared James Prestwood
2019-10-11 17:24 ` James Prestwood [this message]
2019-10-11 17:24 ` [PATCH 03/11] eapol: utilize IWD_MODULE James Prestwood
2019-10-11 17:24 ` [PATCH 04/11] anqp: " James Prestwood
2019-10-11 17:24 ` [PATCH 05/11] agent: " James Prestwood
2019-10-11 18:53 ` Denis Kenzior
2019-10-11 17:24 ` [PATCH 06/11] manager: " James Prestwood
2019-10-11 18:57 ` Denis Kenzior
2019-10-11 17:24 ` [PATCH 07/11] wiphy: " James Prestwood
2019-10-11 17:24 ` [PATCH 08/11] eap: remove mtu argument from eap_init James Prestwood
2019-10-11 17:24 ` [PATCH 09/11] wired: update with new eap_init James Prestwood
2019-10-11 17:24 ` [PATCH 10/11] unit: update wsc/eapol " James Prestwood
2019-10-11 17:24 ` [PATCH 11/11] eap: utilize IWD_MODULE James Prestwood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191011172417.23328-2-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=iwd@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox