From 5ea86c98fc2729e78cb6b8ce7b1d3981133a6145 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 8 Apr 2020 12:27:49 -0500 Subject: [PATCH] main: Add iwd_get_rtnl --- src/iwd.h | 1 + src/main.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/iwd.h b/src/iwd.h index 8b63aa7d..fc3a178f 100644 --- a/src/iwd.h +++ b/src/iwd.h @@ -34,6 +34,7 @@ struct l_genl_family; const struct l_settings *iwd_get_config(void); struct l_genl *iwd_get_genl(void); +struct l_netlink *iwd_get_rtnl(void); void netdev_shutdown(void); diff --git a/src/main.c b/src/main.c index e1b9073c..acd72131 100644 --- a/src/main.c +++ b/src/main.c @@ -47,6 +47,7 @@ #include "src/backtrace.h" static struct l_genl *genl; +static struct l_netlink *rtnl; static struct l_settings *iwd_config; static struct l_timeout *timeout; static const char *interfaces; @@ -103,6 +104,11 @@ struct l_genl *iwd_get_genl(void) return genl; } +struct l_netlink *iwd_get_rtnl(void) +{ + return rtnl; +} + const char *iwd_get_iface_whitelist(void) { return interfaces; @@ -481,6 +487,15 @@ int main(int argc, char *argv[]) if (getenv("IWD_GENL_DEBUG")) l_genl_set_debug(genl, do_debug, "[GENL] ", NULL); + rtnl = l_netlink_new(NETLINK_ROUTE); + if (!rtnl) { + l_error("Failed to open route netlink socket"); + goto fail_rtnl; + } + + if (getenv("IWD_RTNL_DEBUG")) + l_netlink_set_debug(rtnl, do_debug, "[RTNL] ", NULL); + dbus = l_dbus_new_default(L_DBUS_SYSTEM_BUS); if (!dbus) { l_error("Failed to initialize D-Bus"); @@ -504,6 +519,8 @@ int main(int argc, char *argv[]) storage_cleanup_dirs(); fail_dbus: l_genl_unref(genl); +fail_rtnl: + l_netlink_destroy(rtnl); fail_genl: l_settings_free(iwd_config);