2019-04-11 03:10:24 +02:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Wireless daemon for Linux
|
|
|
|
*
|
|
|
|
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <linux/if_ether.h>
|
|
|
|
#include <fnmatch.h>
|
|
|
|
|
|
|
|
#include <ell/ell.h>
|
|
|
|
|
|
|
|
#include "linux/nl80211.h"
|
|
|
|
|
2019-09-20 04:32:52 +02:00
|
|
|
#include "src/nl80211util.h"
|
2019-04-11 03:10:24 +02:00
|
|
|
#include "src/iwd.h"
|
2019-11-07 23:33:51 +01:00
|
|
|
#include "src/module.h"
|
2019-04-11 03:10:26 +02:00
|
|
|
#include "src/netdev.h"
|
2019-04-11 03:10:24 +02:00
|
|
|
#include "src/wiphy.h"
|
|
|
|
#include "src/util.h"
|
|
|
|
#include "src/common.h"
|
2019-07-15 21:04:43 +02:00
|
|
|
#include "src/nl80211cmd.h"
|
2020-04-03 18:14:16 +02:00
|
|
|
#include "src/p2p.h"
|
2019-04-11 03:10:24 +02:00
|
|
|
|
|
|
|
static struct l_genl_family *nl80211 = NULL;
|
2019-04-11 03:10:29 +02:00
|
|
|
static char **whitelist_filter;
|
|
|
|
static char **blacklist_filter;
|
2019-07-02 01:30:10 +02:00
|
|
|
static bool randomize;
|
2019-10-25 16:20:42 +02:00
|
|
|
static bool use_default;
|
2019-04-11 03:10:24 +02:00
|
|
|
|
2019-04-11 03:10:26 +02:00
|
|
|
struct wiphy_setup_state {
|
|
|
|
uint32_t id;
|
|
|
|
struct wiphy *wiphy;
|
|
|
|
unsigned int pending_cmd_count;
|
|
|
|
bool aborted;
|
2020-01-28 19:29:35 +01:00
|
|
|
bool retry;
|
2019-04-11 03:10:28 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Data we may need if the driver does not seem to support interface
|
|
|
|
* manipulation and we fall back to using the driver-created default
|
|
|
|
* interface.
|
|
|
|
*/
|
|
|
|
bool use_default;
|
|
|
|
struct l_genl_msg *default_if_msg;
|
2019-04-11 03:10:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct l_queue *pending_wiphys;
|
|
|
|
|
2019-05-08 03:15:27 +02:00
|
|
|
/* With these drivers don't even try creating our interfaces */
|
2019-08-04 00:35:14 +02:00
|
|
|
static const char *default_if_driver_list[] = {
|
2019-05-08 03:15:27 +02:00
|
|
|
/*
|
|
|
|
* The out-of-tree rtl88x2bu crashes the kernel hard. Seemingly
|
|
|
|
* many other drivers are built from the same source code so
|
|
|
|
* blacklist all of them. Unfortunately there are in-tree drivers
|
|
|
|
* that also match these names and may be fine. Use
|
2019-10-25 16:20:42 +02:00
|
|
|
* UseDefaultInterface to override.
|
2019-05-08 03:15:27 +02:00
|
|
|
*/
|
|
|
|
"rtl81*",
|
|
|
|
"rtl87*",
|
|
|
|
"rtl88*",
|
|
|
|
"rtw_*",
|
2020-02-04 23:00:46 +01:00
|
|
|
"brcmfmac",
|
2021-01-27 16:58:34 +01:00
|
|
|
"bcmsdh_sdmmc",
|
2019-05-08 03:15:27 +02:00
|
|
|
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2019-04-11 03:10:26 +02:00
|
|
|
static void wiphy_setup_state_free(void *data)
|
|
|
|
{
|
|
|
|
struct wiphy_setup_state *state = data;
|
|
|
|
|
2019-04-11 03:10:28 +02:00
|
|
|
if (state->default_if_msg)
|
|
|
|
l_genl_msg_unref(state->default_if_msg);
|
|
|
|
|
2019-04-11 03:10:26 +02:00
|
|
|
L_WARN_ON(state->pending_cmd_count);
|
|
|
|
l_free(state);
|
|
|
|
}
|
|
|
|
|
2019-05-08 03:15:25 +02:00
|
|
|
static void wiphy_setup_state_destroy(struct wiphy_setup_state *state)
|
|
|
|
{
|
|
|
|
l_queue_remove(pending_wiphys, state);
|
|
|
|
wiphy_setup_state_free(state);
|
|
|
|
}
|
|
|
|
|
2019-04-11 03:10:28 +02:00
|
|
|
static bool manager_use_default(struct wiphy_setup_state *state)
|
|
|
|
{
|
2019-12-19 04:50:56 +01:00
|
|
|
uint8_t addr_buf[6];
|
|
|
|
uint8_t *addr = NULL;
|
|
|
|
|
2019-04-11 03:10:28 +02:00
|
|
|
l_debug("");
|
|
|
|
|
|
|
|
if (!state->default_if_msg) {
|
|
|
|
l_error("No default interface for wiphy %u",
|
|
|
|
(unsigned int) state->id);
|
2020-02-05 16:14:47 +01:00
|
|
|
state->retry = true;
|
2019-04-11 03:10:28 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-12-19 04:50:56 +01:00
|
|
|
if (randomize) {
|
|
|
|
wiphy_generate_random_address(state->wiphy, addr_buf);
|
|
|
|
addr = addr_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
netdev_create_from_genl(state->default_if_msg, addr);
|
2019-04-11 03:10:28 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-04-03 18:14:16 +02:00
|
|
|
static void manager_new_station_interface_cb(struct l_genl_msg *msg,
|
|
|
|
void *user_data)
|
2019-04-11 03:10:26 +02:00
|
|
|
{
|
|
|
|
struct wiphy_setup_state *state = user_data;
|
2019-12-19 04:50:56 +01:00
|
|
|
uint8_t addr_buf[6];
|
|
|
|
uint8_t *addr = NULL;
|
2020-01-28 19:29:35 +01:00
|
|
|
int error;
|
2019-04-11 03:10:26 +02:00
|
|
|
|
|
|
|
l_debug("");
|
|
|
|
|
|
|
|
if (state->aborted)
|
|
|
|
return;
|
|
|
|
|
2020-01-28 19:29:35 +01:00
|
|
|
error = l_genl_msg_get_error(msg);
|
|
|
|
if (error < 0) {
|
2019-04-11 03:10:26 +02:00
|
|
|
l_error("NEW_INTERFACE failed: %s",
|
|
|
|
strerror(-l_genl_msg_get_error(msg)));
|
2020-01-28 19:29:35 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If we receive an EBUSY most likely the wiphy is still
|
|
|
|
* initializing, the default interface has not been created
|
|
|
|
* yet and the wiphy needs some time. Retry when we
|
|
|
|
* receive a NEW_INTERFACE event.
|
|
|
|
*/
|
|
|
|
if (error == -EBUSY) {
|
|
|
|
state->retry = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-04-11 03:10:26 +02:00
|
|
|
/*
|
|
|
|
* Nothing we can do to use this wiphy since by now we
|
|
|
|
* will have successfully deleted any default interface
|
|
|
|
* there may have been.
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-12-19 04:50:56 +01:00
|
|
|
if (randomize && !wiphy_has_feature(state->wiphy,
|
|
|
|
NL80211_FEATURE_MAC_ON_CREATE)) {
|
|
|
|
wiphy_generate_random_address(state->wiphy, addr_buf);
|
|
|
|
addr = addr_buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
netdev_create_from_genl(msg, addr);
|
2019-04-11 03:10:26 +02:00
|
|
|
}
|
|
|
|
|
2020-04-03 18:14:16 +02:00
|
|
|
static void manager_new_p2p_interface_cb(struct l_genl_msg *msg,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
struct wiphy_setup_state *state = user_data;
|
|
|
|
|
|
|
|
l_debug("");
|
|
|
|
|
|
|
|
if (state->aborted)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (l_genl_msg_get_error(msg) < 0) {
|
|
|
|
l_error("NEW_INTERFACE failed for p2p-device: %s",
|
|
|
|
strerror(-l_genl_msg_get_error(msg)));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
p2p_device_update_from_genl(msg, true);
|
|
|
|
}
|
|
|
|
|
2019-04-11 03:10:26 +02:00
|
|
|
static void manager_new_interface_done(void *user_data)
|
|
|
|
{
|
|
|
|
struct wiphy_setup_state *state = user_data;
|
|
|
|
|
|
|
|
state->pending_cmd_count--;
|
2020-01-28 19:29:35 +01:00
|
|
|
|
|
|
|
if (!state->pending_cmd_count && !state->retry)
|
|
|
|
wiphy_setup_state_destroy(state);
|
2019-04-11 03:10:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void manager_create_interfaces(struct wiphy_setup_state *state)
|
|
|
|
{
|
|
|
|
struct l_genl_msg *msg;
|
|
|
|
char ifname[10];
|
2020-04-03 18:14:16 +02:00
|
|
|
uint32_t iftype;
|
2019-04-11 03:10:26 +02:00
|
|
|
unsigned cmd_id;
|
|
|
|
|
2019-05-08 03:15:25 +02:00
|
|
|
if (state->aborted)
|
2019-04-11 03:10:26 +02:00
|
|
|
return;
|
|
|
|
|
2019-04-11 03:10:28 +02:00
|
|
|
if (state->use_default) {
|
|
|
|
manager_use_default(state);
|
2020-04-03 18:14:16 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Some drivers don't let us touch the default interface
|
|
|
|
* but still allow us to create/destroy P2P interfaces, so
|
|
|
|
* give it a chance.
|
|
|
|
*/
|
|
|
|
goto try_create_p2p;
|
2019-04-11 03:10:28 +02:00
|
|
|
}
|
|
|
|
|
2019-04-11 03:10:26 +02:00
|
|
|
/*
|
|
|
|
* Current policy: we maintain one netdev per wiphy for station,
|
|
|
|
* AP and Ad-Hoc modes, one optional p2p-device and zero or more
|
2020-04-03 18:14:16 +02:00
|
|
|
* p2p-GOs or p2p-clients. The P2P-client/GO interfaces will be
|
2019-04-11 03:10:26 +02:00
|
|
|
* created on request.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* To be improved */
|
|
|
|
snprintf(ifname, sizeof(ifname), "wlan%i", (int) state->id);
|
|
|
|
l_debug("creating %s", ifname);
|
2020-04-03 18:14:16 +02:00
|
|
|
iftype = NL80211_IFTYPE_STATION;
|
2019-04-11 03:10:26 +02:00
|
|
|
|
|
|
|
msg = l_genl_msg_new(NL80211_CMD_NEW_INTERFACE);
|
|
|
|
l_genl_msg_append_attr(msg, NL80211_ATTR_WIPHY, 4, &state->id);
|
|
|
|
l_genl_msg_append_attr(msg, NL80211_ATTR_IFTYPE, 4, &iftype);
|
|
|
|
l_genl_msg_append_attr(msg, NL80211_ATTR_IFNAME,
|
|
|
|
strlen(ifname) + 1, ifname);
|
|
|
|
l_genl_msg_append_attr(msg, NL80211_ATTR_4ADDR, 1, "\0");
|
|
|
|
l_genl_msg_append_attr(msg, NL80211_ATTR_SOCKET_OWNER, 0, "");
|
2019-07-02 01:30:10 +02:00
|
|
|
|
|
|
|
if (randomize && wiphy_has_feature(state->wiphy,
|
|
|
|
NL80211_FEATURE_MAC_ON_CREATE)) {
|
|
|
|
uint8_t random_addr[6];
|
|
|
|
|
|
|
|
wiphy_generate_random_address(state->wiphy, random_addr);
|
|
|
|
l_debug("Creating interface on phy: %s with random addr: "MAC,
|
|
|
|
wiphy_get_name(state->wiphy),
|
|
|
|
MAC_STR(random_addr));
|
|
|
|
l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, 6, random_addr);
|
|
|
|
}
|
|
|
|
|
2019-04-11 03:10:26 +02:00
|
|
|
cmd_id = l_genl_family_send(nl80211, msg,
|
2020-04-03 18:14:16 +02:00
|
|
|
manager_new_station_interface_cb, state,
|
|
|
|
manager_new_interface_done);
|
|
|
|
|
|
|
|
if (!cmd_id) {
|
|
|
|
l_error("Error sending NEW_INTERFACE for %s", ifname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
state->pending_cmd_count++;
|
|
|
|
|
|
|
|
try_create_p2p:
|
|
|
|
/*
|
|
|
|
* Require the MAC on create feature so we can send our desired
|
|
|
|
* interface address during GO Negotiation before actually creating
|
|
|
|
* the local Client/GO interface. Could be worked around if needed.
|
|
|
|
*/
|
|
|
|
if (!wiphy_supports_iftype(state->wiphy, NL80211_IFTYPE_P2P_DEVICE) ||
|
|
|
|
!wiphy_supports_iftype(state->wiphy,
|
|
|
|
NL80211_IFTYPE_P2P_CLIENT) ||
|
|
|
|
!wiphy_has_feature(state->wiphy,
|
|
|
|
NL80211_FEATURE_MAC_ON_CREATE))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use wlan%i-p2p for now. We might want to use
|
|
|
|
* <default_interface's_name>-p2p here (in case state->use_default
|
|
|
|
* is true) but the risk is that we'd go over the interface name
|
|
|
|
* length limit.
|
|
|
|
*/
|
|
|
|
snprintf(ifname, sizeof(ifname), "wlan%i-p2p", (int) state->id);
|
|
|
|
l_debug("creating %s", ifname);
|
|
|
|
iftype = NL80211_IFTYPE_P2P_DEVICE;
|
|
|
|
|
|
|
|
msg = l_genl_msg_new(NL80211_CMD_NEW_INTERFACE);
|
|
|
|
l_genl_msg_append_attr(msg, NL80211_ATTR_WIPHY, 4, &state->id);
|
|
|
|
l_genl_msg_append_attr(msg, NL80211_ATTR_IFTYPE, 4, &iftype);
|
|
|
|
l_genl_msg_append_attr(msg, NL80211_ATTR_IFNAME,
|
|
|
|
strlen(ifname) + 1, ifname);
|
|
|
|
l_genl_msg_append_attr(msg, NL80211_ATTR_4ADDR, 1, "\0");
|
|
|
|
l_genl_msg_append_attr(msg, NL80211_ATTR_SOCKET_OWNER, 0, "");
|
|
|
|
cmd_id = l_genl_family_send(nl80211, msg,
|
|
|
|
manager_new_p2p_interface_cb, state,
|
2019-04-11 03:10:26 +02:00
|
|
|
manager_new_interface_done);
|
|
|
|
|
|
|
|
if (!cmd_id) {
|
2019-05-13 15:44:31 +02:00
|
|
|
l_error("Error sending NEW_INTERFACE for %s", ifname);
|
2019-04-11 03:10:26 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
state->pending_cmd_count++;
|
|
|
|
}
|
|
|
|
|
2020-01-28 19:29:35 +01:00
|
|
|
static bool manager_wiphy_check_setup_done(struct wiphy_setup_state *state)
|
|
|
|
{
|
|
|
|
if (state->pending_cmd_count || state->retry)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
manager_create_interfaces(state);
|
|
|
|
|
|
|
|
return !state->pending_cmd_count && !state->retry;
|
|
|
|
}
|
|
|
|
|
2019-04-11 03:10:26 +02:00
|
|
|
static void manager_setup_cmd_done(void *user_data)
|
|
|
|
{
|
|
|
|
struct wiphy_setup_state *state = user_data;
|
|
|
|
|
|
|
|
state->pending_cmd_count--;
|
|
|
|
|
2020-01-28 19:29:35 +01:00
|
|
|
if (manager_wiphy_check_setup_done(state))
|
2019-05-08 03:15:25 +02:00
|
|
|
wiphy_setup_state_destroy(state);
|
2019-04-11 03:10:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void manager_del_interface_cb(struct l_genl_msg *msg, void *user_data)
|
|
|
|
{
|
|
|
|
struct wiphy_setup_state *state = user_data;
|
|
|
|
|
|
|
|
l_debug("");
|
|
|
|
|
|
|
|
if (state->aborted)
|
|
|
|
return;
|
|
|
|
|
2019-04-11 03:10:28 +02:00
|
|
|
if (l_genl_msg_get_error(msg) < 0) {
|
2019-04-11 03:10:26 +02:00
|
|
|
l_error("DEL_INTERFACE failed: %s",
|
|
|
|
strerror(-l_genl_msg_get_error(msg)));
|
2019-04-11 03:10:28 +02:00
|
|
|
state->use_default = true;
|
|
|
|
}
|
2019-04-11 03:10:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void manager_get_interface_cb(struct l_genl_msg *msg, void *user_data)
|
|
|
|
{
|
|
|
|
struct wiphy_setup_state *state = user_data;
|
2019-09-20 04:48:47 +02:00
|
|
|
uint32_t wiphy;
|
|
|
|
uint32_t ifindex;
|
|
|
|
uint32_t iftype;
|
|
|
|
uint64_t wdev;
|
|
|
|
const char *ifname;
|
2019-04-11 03:10:26 +02:00
|
|
|
struct l_genl_msg *del_msg;
|
|
|
|
unsigned cmd_id;
|
2019-04-11 03:10:29 +02:00
|
|
|
char *pattern;
|
|
|
|
unsigned int i;
|
|
|
|
bool whitelisted = false, blacklisted = false;
|
2019-04-11 03:10:26 +02:00
|
|
|
|
|
|
|
l_debug("");
|
|
|
|
|
|
|
|
if (state->aborted)
|
|
|
|
return;
|
|
|
|
|
2019-09-20 04:48:47 +02:00
|
|
|
if (nl80211_parse_attrs(msg, NL80211_ATTR_WDEV, &wdev,
|
|
|
|
NL80211_ATTR_WIPHY, &wiphy,
|
|
|
|
NL80211_ATTR_IFTYPE, &iftype,
|
|
|
|
NL80211_ATTR_UNSPEC) < 0)
|
2019-04-11 03:10:26 +02:00
|
|
|
return;
|
|
|
|
|
2019-09-20 04:48:47 +02:00
|
|
|
if (wiphy != state->id) {
|
2020-01-21 07:21:38 +01:00
|
|
|
l_debug("Wiphy attribute mismatch, wanted: %u, got %u",
|
2019-09-20 04:48:47 +02:00
|
|
|
state->id, wiphy);
|
|
|
|
return;
|
|
|
|
}
|
2019-04-11 03:10:26 +02:00
|
|
|
|
2019-09-20 04:48:47 +02:00
|
|
|
if (nl80211_parse_attrs(msg, NL80211_ATTR_IFINDEX, &ifindex,
|
|
|
|
NL80211_ATTR_IFNAME, &ifname,
|
|
|
|
NL80211_ATTR_UNSPEC) < 0)
|
|
|
|
goto delete_interface;
|
2019-04-11 03:10:26 +02:00
|
|
|
|
2019-09-20 04:48:47 +02:00
|
|
|
if (whitelist_filter) {
|
|
|
|
for (i = 0; (pattern = whitelist_filter[i]); i++) {
|
|
|
|
if (fnmatch(pattern, ifname, 0) != 0)
|
|
|
|
continue;
|
2019-04-11 03:10:26 +02:00
|
|
|
|
2019-09-20 04:48:47 +02:00
|
|
|
whitelisted = true;
|
2019-04-11 03:10:26 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-20 04:48:47 +02:00
|
|
|
if (blacklist_filter) {
|
|
|
|
for (i = 0; (pattern = blacklist_filter[i]); i++) {
|
|
|
|
if (fnmatch(pattern, ifname, 0) != 0)
|
|
|
|
continue;
|
2019-04-11 03:10:29 +02:00
|
|
|
|
2019-09-20 04:48:47 +02:00
|
|
|
blacklisted = true;
|
|
|
|
break;
|
2019-04-11 03:10:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-11 03:10:28 +02:00
|
|
|
/*
|
|
|
|
* If this interface is usable as our default netdev in case the
|
|
|
|
* driver does not support interface manipulation, save the message
|
|
|
|
* just in case.
|
|
|
|
*/
|
2019-09-20 04:48:47 +02:00
|
|
|
if ((iftype == NL80211_IFTYPE_ADHOC ||
|
|
|
|
iftype == NL80211_IFTYPE_STATION ||
|
|
|
|
iftype == NL80211_IFTYPE_AP) &&
|
2019-04-11 03:10:29 +02:00
|
|
|
!state->default_if_msg &&
|
|
|
|
(!whitelist_filter || whitelisted) &&
|
|
|
|
!blacklisted)
|
2019-04-11 03:10:28 +02:00
|
|
|
state->default_if_msg = l_genl_msg_ref(msg);
|
|
|
|
|
2019-09-20 04:48:47 +02:00
|
|
|
delete_interface:
|
2019-04-11 03:10:28 +02:00
|
|
|
if (state->use_default)
|
|
|
|
return;
|
|
|
|
|
2019-04-11 03:10:26 +02:00
|
|
|
del_msg = l_genl_msg_new(NL80211_CMD_DEL_INTERFACE);
|
2019-09-20 04:48:47 +02:00
|
|
|
l_genl_msg_append_attr(del_msg, NL80211_ATTR_WDEV, 8, &wdev);
|
2019-04-11 03:10:26 +02:00
|
|
|
l_genl_msg_append_attr(del_msg, NL80211_ATTR_WIPHY, 4, &state->id);
|
|
|
|
cmd_id = l_genl_family_send(nl80211, del_msg,
|
|
|
|
manager_del_interface_cb, state,
|
|
|
|
manager_setup_cmd_done);
|
|
|
|
|
|
|
|
if (!cmd_id) {
|
2019-09-20 04:48:47 +02:00
|
|
|
l_error("Sending DEL_INTERFACE for wdev: %" PRIu64" failed",
|
|
|
|
wdev);
|
2019-04-11 03:10:28 +02:00
|
|
|
state->use_default = true;
|
2019-04-11 03:10:26 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
l_debug("");
|
|
|
|
state->pending_cmd_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool manager_wiphy_state_match(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
const struct wiphy_setup_state *state = a;
|
|
|
|
uint32_t id = L_PTR_TO_UINT(b);
|
|
|
|
|
|
|
|
return (state->id == id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct wiphy_setup_state *manager_find_pending(uint32_t id)
|
|
|
|
{
|
|
|
|
return l_queue_find(pending_wiphys, manager_wiphy_state_match,
|
|
|
|
L_UINT_TO_PTR(id));
|
|
|
|
}
|
|
|
|
|
2019-09-20 04:35:55 +02:00
|
|
|
static uint32_t manager_parse_wiphy_id(struct l_genl_msg *msg)
|
2019-04-11 03:10:24 +02:00
|
|
|
{
|
2019-09-20 04:35:55 +02:00
|
|
|
uint32_t wiphy;
|
2019-04-11 03:10:24 +02:00
|
|
|
|
2019-09-20 04:35:55 +02:00
|
|
|
if (nl80211_parse_attrs(msg, NL80211_ATTR_WIPHY, &wiphy,
|
|
|
|
NL80211_ATTR_UNSPEC) < 0)
|
|
|
|
return -1;
|
2019-04-11 03:10:24 +02:00
|
|
|
|
2019-09-20 04:35:55 +02:00
|
|
|
return wiphy;
|
2019-04-11 03:10:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void manager_del_wiphy_event(struct l_genl_msg *msg)
|
|
|
|
{
|
2019-04-11 03:10:26 +02:00
|
|
|
struct wiphy_setup_state *state;
|
2019-04-11 03:10:24 +02:00
|
|
|
struct wiphy *wiphy;
|
|
|
|
uint32_t id;
|
|
|
|
|
2019-09-20 04:35:55 +02:00
|
|
|
id = manager_parse_wiphy_id(msg);
|
2019-04-11 03:10:24 +02:00
|
|
|
|
2019-04-11 03:10:26 +02:00
|
|
|
state = manager_find_pending(id);
|
|
|
|
if (state) {
|
|
|
|
if (state->pending_cmd_count)
|
|
|
|
state->aborted = true;
|
|
|
|
else
|
2019-05-08 03:15:25 +02:00
|
|
|
wiphy_setup_state_destroy(state);
|
2019-04-11 03:10:26 +02:00
|
|
|
}
|
|
|
|
|
2019-04-11 03:10:24 +02:00
|
|
|
wiphy = wiphy_find(id);
|
|
|
|
if (wiphy)
|
|
|
|
wiphy_destroy(wiphy);
|
|
|
|
}
|
|
|
|
|
2019-04-17 00:37:41 +02:00
|
|
|
static void manager_interface_dump_callback(struct l_genl_msg *msg,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
struct wiphy_setup_state *state;
|
|
|
|
|
|
|
|
l_debug("");
|
|
|
|
|
2019-09-20 04:35:55 +02:00
|
|
|
state = manager_find_pending(manager_parse_wiphy_id(msg));
|
2019-09-19 23:29:24 +02:00
|
|
|
if (!state)
|
2019-04-17 00:37:41 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
manager_get_interface_cb(msg, state);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:16:44 +01:00
|
|
|
static bool manager_check_create_interfaces(void *data, void *user_data)
|
2019-04-17 00:37:41 +02:00
|
|
|
{
|
2020-01-27 15:16:44 +01:00
|
|
|
struct wiphy_setup_state *state = data;
|
2020-02-03 23:25:07 +01:00
|
|
|
|
2020-01-28 19:29:35 +01:00
|
|
|
if (!manager_wiphy_check_setup_done(state))
|
2019-05-08 03:15:25 +02:00
|
|
|
return false;
|
|
|
|
|
2020-01-28 19:29:35 +01:00
|
|
|
/* If we are here, there were no interfaces for this phy */
|
2019-05-08 03:15:25 +02:00
|
|
|
wiphy_setup_state_free(state);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void manager_interface_dump_done(void *user_data)
|
|
|
|
{
|
2020-01-27 15:16:44 +01:00
|
|
|
l_queue_foreach_remove(pending_wiphys,
|
2019-05-08 03:15:25 +02:00
|
|
|
manager_check_create_interfaces, NULL);
|
2019-04-17 00:37:41 +02:00
|
|
|
}
|
|
|
|
|
2020-02-03 23:25:07 +01:00
|
|
|
/* We are dumping multiple wiphys for the very first time */
|
2019-04-11 03:10:24 +02:00
|
|
|
static void manager_wiphy_dump_callback(struct l_genl_msg *msg, void *user_data)
|
|
|
|
{
|
2020-02-03 23:25:07 +01:00
|
|
|
uint32_t id;
|
|
|
|
const char *name;
|
|
|
|
struct wiphy *wiphy;
|
|
|
|
struct wiphy_setup_state *state;
|
|
|
|
|
|
|
|
if (nl80211_parse_attrs(msg, NL80211_ATTR_WIPHY, &id,
|
|
|
|
NL80211_ATTR_WIPHY_NAME, &name,
|
|
|
|
NL80211_ATTR_UNSPEC) < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A Wiphy split dump can generate many (6+) NEW_WIPHY messages
|
|
|
|
* We need to parse attributes from all of them, but only perform
|
|
|
|
* initialization steps once for each new wiphy detected
|
|
|
|
*/
|
|
|
|
wiphy = wiphy_find(id);
|
|
|
|
if (wiphy)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
wiphy = wiphy_create(id, name);
|
|
|
|
if (!wiphy || wiphy_is_blacklisted(wiphy))
|
|
|
|
return;
|
|
|
|
|
|
|
|
state = l_new(struct wiphy_setup_state, 1);
|
|
|
|
state->id = id;
|
|
|
|
state->wiphy = wiphy;
|
|
|
|
|
2020-05-04 17:24:17 +02:00
|
|
|
l_debug("New wiphy %s added (%d)", name, id);
|
|
|
|
|
2020-02-03 23:25:07 +01:00
|
|
|
l_queue_push_tail(pending_wiphys, state);
|
|
|
|
|
|
|
|
done:
|
|
|
|
wiphy_update_from_genl(wiphy, msg);
|
2019-04-11 03:10:24 +02:00
|
|
|
}
|
|
|
|
|
2020-02-03 23:25:07 +01:00
|
|
|
/* We are dumping a single wiphy, due to a NEW_WIPHY event */
|
|
|
|
static void manager_wiphy_filtered_dump_callback(struct l_genl_msg *msg,
|
|
|
|
void *user_data)
|
2019-09-19 23:29:24 +02:00
|
|
|
{
|
2020-02-03 23:25:07 +01:00
|
|
|
struct wiphy_setup_state *state = user_data;
|
|
|
|
|
|
|
|
wiphy_update_from_genl(state->wiphy, msg);
|
|
|
|
}
|
|
|
|
|
2020-02-05 21:25:11 +01:00
|
|
|
static void manager_wiphy_dump_done(void *user_data)
|
|
|
|
{
|
|
|
|
const struct l_queue_entry *e;
|
|
|
|
|
|
|
|
for (e = l_queue_get_entries(pending_wiphys); e; e = e->next) {
|
|
|
|
struct wiphy_setup_state *state = e->data;
|
|
|
|
|
|
|
|
wiphy_create_complete(state->wiphy);
|
|
|
|
state->use_default = use_default;
|
|
|
|
|
|
|
|
/* If whitelist/blacklist were given only try to use existing
|
|
|
|
* interfaces same as when the driver does not support
|
|
|
|
* NEW_INTERFACE or DEL_INTERFACE, otherwise the interface
|
|
|
|
* names will become meaningless after we've created our own
|
|
|
|
* interface(s). Optimally phy name white/blacklists should
|
|
|
|
* be used.
|
|
|
|
*/
|
|
|
|
if (whitelist_filter || blacklist_filter)
|
|
|
|
state->use_default = true;
|
|
|
|
|
|
|
|
if (!state->use_default) {
|
|
|
|
const char *driver = wiphy_get_driver(state->wiphy);
|
|
|
|
|
2021-02-18 21:43:56 +01:00
|
|
|
if (driver) {
|
|
|
|
const char **e;
|
|
|
|
|
|
|
|
for (e = default_if_driver_list; *e; e++)
|
|
|
|
if (fnmatch(*e, driver, 0) == 0)
|
|
|
|
state->use_default = true;
|
|
|
|
} else
|
|
|
|
state->use_default = true;
|
2020-02-05 21:25:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (state->use_default)
|
|
|
|
l_info("Wiphy %s will only use the default interface",
|
|
|
|
wiphy_get_name(state->wiphy));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-03 23:25:07 +01:00
|
|
|
static int manager_wiphy_filtered_dump(uint32_t wiphy_id,
|
|
|
|
l_genl_msg_func_t cb,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
struct l_genl_msg *msg;
|
2019-09-19 23:29:24 +02:00
|
|
|
unsigned int wiphy_cmd_id;
|
|
|
|
unsigned int iface_cmd_id;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Until fixed, a NEW_WIPHY event will not include all the information
|
|
|
|
* that may be available, but a dump will. Because of this we do both
|
2020-01-21 07:21:38 +01:00
|
|
|
* GET_WIPHY/GET_INTERFACE, same as we would during initialization.
|
2019-09-19 23:29:24 +02:00
|
|
|
*/
|
|
|
|
msg = l_genl_msg_new_sized(NL80211_CMD_GET_WIPHY, 128);
|
|
|
|
l_genl_msg_append_attr(msg, NL80211_ATTR_SPLIT_WIPHY_DUMP, 0, NULL);
|
|
|
|
l_genl_msg_append_attr(msg, NL80211_ATTR_WIPHY, 4, &wiphy_id);
|
|
|
|
|
2020-02-05 21:25:11 +01:00
|
|
|
wiphy_cmd_id = l_genl_family_dump(nl80211, msg, cb, user_data,
|
|
|
|
manager_wiphy_dump_done);
|
2019-09-19 23:29:24 +02:00
|
|
|
if (!wiphy_cmd_id) {
|
|
|
|
l_error("Could not dump wiphy %u", wiphy_id);
|
|
|
|
l_genl_msg_unref(msg);
|
2020-02-03 23:25:07 +01:00
|
|
|
return -EIO;
|
2019-09-19 23:29:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* As the first step after new wiphy is detected we will query
|
|
|
|
* the initial interface setup, delete the default interfaces
|
|
|
|
* and create interfaces for our own use with NL80211_ATTR_SOCKET_OWNER
|
|
|
|
* on them. After that if new interfaces are created outside of
|
|
|
|
* IWD, or removed outside of IWD, we don't touch them and will
|
|
|
|
* try to minimally adapt to handle the removals correctly. It's
|
|
|
|
* a very unlikely situation in any case but it wouldn't make
|
|
|
|
* sense to try to continually enforce our setup fighting against
|
|
|
|
* some other process, and it wouldn't make sense to try to
|
|
|
|
* manage and use additional interfaces beyond the one or two
|
|
|
|
* we need for our operations.
|
|
|
|
*/
|
|
|
|
msg = l_genl_msg_new(NL80211_CMD_GET_INTERFACE);
|
|
|
|
l_genl_msg_append_attr(msg, NL80211_ATTR_WIPHY, 4, &wiphy_id);
|
|
|
|
|
|
|
|
iface_cmd_id = l_genl_family_dump(nl80211, msg,
|
|
|
|
manager_interface_dump_callback,
|
|
|
|
NULL, manager_interface_dump_done);
|
|
|
|
|
|
|
|
if (!iface_cmd_id) {
|
|
|
|
l_error("Could not dump interface for wiphy %u", wiphy_id);
|
|
|
|
l_genl_family_cancel(nl80211, wiphy_cmd_id);
|
|
|
|
l_genl_msg_unref(msg);
|
2020-02-03 23:25:07 +01:00
|
|
|
return -EIO;
|
2019-09-19 23:29:24 +02:00
|
|
|
}
|
2020-02-03 23:25:07 +01:00
|
|
|
|
|
|
|
return 0;
|
2019-09-19 23:29:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void manager_config_notify(struct l_genl_msg *msg, void *user_data)
|
|
|
|
{
|
|
|
|
uint8_t cmd;
|
2020-02-03 23:25:07 +01:00
|
|
|
uint32_t wiphy_id;
|
2020-01-28 19:29:35 +01:00
|
|
|
struct wiphy_setup_state *state;
|
2019-09-19 23:29:24 +02:00
|
|
|
|
2020-02-03 23:25:07 +01:00
|
|
|
if (!pending_wiphys)
|
|
|
|
return;
|
|
|
|
|
2019-09-19 23:29:24 +02:00
|
|
|
cmd = l_genl_msg_get_command(msg);
|
|
|
|
|
|
|
|
l_debug("Notification of command %s(%u)",
|
|
|
|
nl80211cmd_to_string(cmd), cmd);
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case NL80211_CMD_NEW_WIPHY:
|
2020-02-03 23:25:07 +01:00
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
struct wiphy *wiphy;
|
|
|
|
|
|
|
|
if (nl80211_parse_attrs(msg, NL80211_ATTR_WIPHY, &wiphy_id,
|
|
|
|
NL80211_ATTR_WIPHY_NAME, &name,
|
|
|
|
NL80211_ATTR_UNSPEC) < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NEW_WIPHY events are sent in three cases:
|
|
|
|
* 1. New wiphy is detected
|
|
|
|
* 2. Wiphy is moved to a new namespace
|
|
|
|
* 3. Wiphy is renamed
|
|
|
|
*
|
|
|
|
* Take care of case 3 here without re-parsing the entire
|
|
|
|
* wiphy structure, potentially causing leaks, etc.
|
|
|
|
*/
|
|
|
|
wiphy = wiphy_find(wiphy_id);
|
|
|
|
if (wiphy) {
|
|
|
|
wiphy_update_name(wiphy, name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wiphy = wiphy_create(wiphy_id, name);
|
|
|
|
if (!wiphy || wiphy_is_blacklisted(wiphy))
|
|
|
|
return;
|
|
|
|
|
|
|
|
state = l_new(struct wiphy_setup_state, 1);
|
|
|
|
state->id = wiphy_id;
|
|
|
|
state->wiphy = wiphy;
|
|
|
|
|
|
|
|
if (manager_wiphy_filtered_dump(wiphy_id,
|
|
|
|
manager_wiphy_filtered_dump_callback,
|
|
|
|
state) < 0) {
|
|
|
|
wiphy_setup_state_free(state);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
l_queue_push_tail(pending_wiphys, state);
|
|
|
|
return;
|
|
|
|
}
|
2019-09-19 23:29:24 +02:00
|
|
|
|
|
|
|
case NL80211_CMD_DEL_WIPHY:
|
|
|
|
manager_del_wiphy_event(msg);
|
2020-02-03 23:25:07 +01:00
|
|
|
return;
|
2019-09-19 23:29:24 +02:00
|
|
|
|
|
|
|
case NL80211_CMD_NEW_INTERFACE:
|
|
|
|
/*
|
2020-01-28 19:29:35 +01:00
|
|
|
* Interfaces are normally dumped on the NEW_WIPHY events and
|
|
|
|
* and we have nothing to do here. But check if by any chance
|
|
|
|
* we've queried this wiphy and it was still busy initialising,
|
|
|
|
* in that case retry the setup now that an interface, likely
|
|
|
|
* the initial default one, has been added.
|
2019-09-19 23:29:24 +02:00
|
|
|
*/
|
2020-02-04 18:05:10 +01:00
|
|
|
wiphy_id = manager_parse_wiphy_id(msg);
|
|
|
|
state = manager_find_pending(wiphy_id);
|
2020-01-28 19:29:35 +01:00
|
|
|
|
|
|
|
if (state && state->retry) {
|
|
|
|
state->retry = false;
|
|
|
|
l_debug("Retrying setup of wiphy %u", state->id);
|
|
|
|
|
|
|
|
manager_get_interface_cb(msg, state);
|
|
|
|
|
|
|
|
if (manager_wiphy_check_setup_done(state))
|
|
|
|
wiphy_setup_state_destroy(state);
|
2020-02-03 23:25:07 +01:00
|
|
|
|
|
|
|
return;
|
2020-01-28 19:29:35 +01:00
|
|
|
}
|
|
|
|
|
2020-02-03 23:25:07 +01:00
|
|
|
if (!wiphy_find(wiphy_id)) {
|
|
|
|
l_warn("Received a NEW_INTERFACE for a wiphy id"
|
|
|
|
" that isn't tracked. This is most ikely a"
|
|
|
|
" kernel bug where NEW_WIPHY events that are"
|
|
|
|
" too large are dropped on the floor."
|
|
|
|
" Attempting a workaround...");
|
|
|
|
manager_wiphy_filtered_dump(wiphy_id,
|
|
|
|
manager_wiphy_dump_callback,
|
|
|
|
NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
2019-09-19 23:29:24 +02:00
|
|
|
|
|
|
|
case NL80211_CMD_DEL_INTERFACE:
|
2020-04-03 18:14:16 +02:00
|
|
|
{
|
|
|
|
uint32_t ifindex;
|
|
|
|
|
|
|
|
if (nl80211_parse_attrs(msg, NL80211_ATTR_IFINDEX, &ifindex,
|
|
|
|
NL80211_ATTR_UNSPEC) < 0) {
|
|
|
|
uint64_t wdev_id;
|
|
|
|
struct p2p_device *p2p_device;
|
|
|
|
|
|
|
|
if (nl80211_parse_attrs(msg, NL80211_ATTR_WDEV,
|
|
|
|
&wdev_id,
|
|
|
|
NL80211_ATTR_UNSPEC) < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
p2p_device = p2p_device_find(wdev_id);
|
|
|
|
if (!p2p_device)
|
|
|
|
return;
|
|
|
|
|
|
|
|
p2p_device_destroy(p2p_device);
|
|
|
|
} else {
|
|
|
|
struct netdev *netdev = netdev_find(ifindex);
|
|
|
|
|
|
|
|
if (!netdev)
|
|
|
|
return;
|
|
|
|
|
|
|
|
netdev_destroy(netdev);
|
|
|
|
}
|
2019-09-19 23:29:24 +02:00
|
|
|
|
2020-02-03 23:25:07 +01:00
|
|
|
return;
|
2019-09-19 23:29:24 +02:00
|
|
|
}
|
2020-04-03 18:14:16 +02:00
|
|
|
}
|
2019-09-19 23:29:24 +02:00
|
|
|
}
|
|
|
|
|
2019-10-11 21:29:27 +02:00
|
|
|
static int manager_init(void)
|
2019-04-11 03:10:24 +02:00
|
|
|
{
|
2019-10-11 21:29:27 +02:00
|
|
|
struct l_genl *genl = iwd_get_genl();
|
2019-07-02 01:30:10 +02:00
|
|
|
const struct l_settings *config = iwd_get_config();
|
2019-04-16 23:18:59 +02:00
|
|
|
struct l_genl_msg *msg;
|
2019-04-17 00:37:41 +02:00
|
|
|
unsigned int wiphy_dump;
|
|
|
|
unsigned int interface_dump;
|
2019-07-02 01:30:10 +02:00
|
|
|
const char *randomize_str;
|
2019-10-11 21:29:26 +02:00
|
|
|
const char *if_whitelist = iwd_get_iface_whitelist();
|
|
|
|
const char *if_blacklist = iwd_get_iface_blacklist();
|
2019-04-11 03:10:24 +02:00
|
|
|
|
2019-10-11 21:29:27 +02:00
|
|
|
nl80211 = l_genl_family_new(genl, NL80211_GENL_NAME);
|
2019-04-11 03:10:24 +02:00
|
|
|
|
2019-04-11 03:10:29 +02:00
|
|
|
if (if_whitelist)
|
|
|
|
whitelist_filter = l_strsplit(if_whitelist, ',');
|
|
|
|
|
|
|
|
if (if_blacklist)
|
|
|
|
blacklist_filter = l_strsplit(if_blacklist, ',');
|
|
|
|
|
2019-04-11 03:10:26 +02:00
|
|
|
pending_wiphys = l_queue_new();
|
|
|
|
|
2019-04-16 23:18:59 +02:00
|
|
|
if (!l_genl_family_register(nl80211, "config", manager_config_notify,
|
|
|
|
NULL, NULL)) {
|
|
|
|
l_error("Registering for config notifications failed");
|
2019-10-11 21:29:27 +02:00
|
|
|
goto error;
|
2019-04-16 23:18:59 +02:00
|
|
|
}
|
|
|
|
|
2019-08-21 04:27:45 +02:00
|
|
|
msg = l_genl_msg_new_sized(NL80211_CMD_GET_WIPHY, 128);
|
2019-08-21 01:04:27 +02:00
|
|
|
l_genl_msg_append_attr(msg, NL80211_ATTR_SPLIT_WIPHY_DUMP, 0, NULL);
|
2019-04-17 00:37:41 +02:00
|
|
|
wiphy_dump = l_genl_family_dump(nl80211, msg,
|
|
|
|
manager_wiphy_dump_callback,
|
2020-02-05 21:25:11 +01:00
|
|
|
NULL,
|
|
|
|
manager_wiphy_dump_done);
|
2019-04-17 00:37:41 +02:00
|
|
|
if (!wiphy_dump) {
|
2019-04-16 23:18:59 +02:00
|
|
|
l_error("Initial wiphy information dump failed");
|
|
|
|
l_genl_msg_unref(msg);
|
2019-10-11 21:29:27 +02:00
|
|
|
goto error;
|
2019-04-16 23:18:59 +02:00
|
|
|
}
|
|
|
|
|
2019-04-17 00:37:41 +02:00
|
|
|
msg = l_genl_msg_new(NL80211_CMD_GET_INTERFACE);
|
|
|
|
interface_dump = l_genl_family_dump(nl80211, msg,
|
|
|
|
manager_interface_dump_callback,
|
|
|
|
NULL,
|
|
|
|
manager_interface_dump_done);
|
|
|
|
if (!interface_dump) {
|
|
|
|
l_error("Initial interface information dump failed");
|
|
|
|
l_genl_msg_unref(msg);
|
|
|
|
l_genl_family_cancel(nl80211, wiphy_dump);
|
2019-10-11 21:29:27 +02:00
|
|
|
goto error;
|
2019-04-17 00:37:41 +02:00
|
|
|
}
|
|
|
|
|
2019-10-25 18:21:04 +02:00
|
|
|
randomize_str = l_settings_get_value(config, "General",
|
|
|
|
"AddressRandomization");
|
|
|
|
if (randomize_str) {
|
|
|
|
if (!strcmp(randomize_str, "once"))
|
|
|
|
randomize = true;
|
|
|
|
else if (!strcmp(randomize_str, "disabled"))
|
|
|
|
randomize = false;
|
|
|
|
}
|
2019-07-02 01:30:10 +02:00
|
|
|
|
2019-10-25 16:20:42 +02:00
|
|
|
if (!l_settings_get_bool(config, "General",
|
2021-06-01 17:29:42 +02:00
|
|
|
"UseDefaultInterface", &use_default))
|
|
|
|
use_default = false;
|
2019-10-25 16:20:42 +02:00
|
|
|
|
2019-10-11 21:29:27 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
error:
|
|
|
|
l_queue_destroy(pending_wiphys, NULL);
|
2019-10-11 22:41:16 +02:00
|
|
|
pending_wiphys = NULL;
|
|
|
|
|
2019-10-11 21:29:27 +02:00
|
|
|
l_genl_family_free(nl80211);
|
|
|
|
nl80211 = NULL;
|
|
|
|
|
|
|
|
return -EIO;
|
2019-04-11 03:10:24 +02:00
|
|
|
}
|
|
|
|
|
2019-10-11 21:29:27 +02:00
|
|
|
static void manager_exit(void)
|
2019-04-11 03:10:24 +02:00
|
|
|
{
|
2019-04-11 03:10:29 +02:00
|
|
|
l_strfreev(whitelist_filter);
|
|
|
|
l_strfreev(blacklist_filter);
|
|
|
|
|
2019-06-21 19:22:48 +02:00
|
|
|
l_queue_destroy(pending_wiphys, wiphy_setup_state_free);
|
2019-04-11 03:10:26 +02:00
|
|
|
pending_wiphys = NULL;
|
|
|
|
|
2019-10-11 21:29:27 +02:00
|
|
|
l_genl_family_free(nl80211);
|
2019-04-11 03:10:24 +02:00
|
|
|
nl80211 = NULL;
|
2019-07-02 01:30:10 +02:00
|
|
|
randomize = false;
|
2019-04-11 03:10:24 +02:00
|
|
|
}
|
2019-10-11 21:29:27 +02:00
|
|
|
|
|
|
|
IWD_MODULE(manager, manager_init, manager_exit);
|