summaryrefslogtreecommitdiff
path: root/src/core/devices
diff options
context:
space:
mode:
authorAndrew Zaborowski <andrew.zaborowski@intel.com>2021-11-09 02:29:24 +0100
committerThomas Haller <thaller@redhat.com>2022-01-21 11:13:58 +0100
commite6e3fad4e444ed9ac41053cb620634282fea54e4 (patch)
tree768cba429cdaf911dd693e244af273b5ad0e81b2 /src/core/devices
parent2e7d4aa2f7be94dc742f126698d3dfaeeed900ea (diff)
downloadNetworkManager-e6e3fad4e444ed9ac41053cb620634282fea54e4.tar.gz
wifi: Check interface mode for both backends
In NMWifiFactory, move the check that prevents NMDevice's from being created for interfaces in Monitor and other modes, out of the wpa_supplicant-specific block so that it applies to both IWD and wpa_supplicant. This check allows P2P device creation to work differently that Infrastructure, Ad-Hoc and AP modes so it's needed for P2P support in the IWD backend. While there change the check to list the modes that are accepted rather than rely on some of the modes (Monitor, P2P-{Device,Client,GO}) being bunched together as _NM_802_11_MODE_UNKNOWN.
Diffstat (limited to 'src/core/devices')
-rw-r--r--src/core/devices/wifi/nm-wifi-factory.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/core/devices/wifi/nm-wifi-factory.c b/src/core/devices/wifi/nm-wifi-factory.c
index d17d04cee7..f44d187bcc 100644
--- a/src/core/devices/wifi/nm-wifi-factory.c
+++ b/src/core/devices/wifi/nm-wifi-factory.c
@@ -76,6 +76,7 @@ create_device(NMDeviceFactory *factory,
{
gs_free char *backend_free = NULL;
const char *backend;
+ _NM80211Mode mode;
g_return_val_if_fail(iface != NULL, NULL);
g_return_val_if_fail(plink != NULL, NULL);
@@ -85,6 +86,20 @@ create_device(NMDeviceFactory *factory,
if (plink->type != NM_LINK_TYPE_WIFI)
return nm_device_olpc_mesh_new(iface);
+ /* Ignore monitor-mode and other unhandled interface types.
+ * FIXME: keep TYPE_MONITOR devices in UNAVAILABLE state and manage
+ * them if/when they change to a handled type.
+ */
+ mode = nm_platform_wifi_get_mode(NM_PLATFORM_GET, plink->ifindex);
+ if (!NM_IN_SET(mode,
+ _NM_802_11_MODE_INFRA,
+ _NM_802_11_MODE_ADHOC,
+ _NM_802_11_MODE_AP,
+ _NM_802_11_MODE_MESH)) {
+ *out_ignore = TRUE;
+ return NULL;
+ }
+
backend = nm_config_data_get_device_config_by_pllink(NM_CONFIG_GET_DATA,
NM_CONFIG_KEYFILE_KEY_DEVICE_WIFI_BACKEND,
plink,
@@ -103,7 +118,6 @@ create_device(NMDeviceFactory *factory,
if (!g_ascii_strcasecmp(backend, "wpa_supplicant")) {
NMDevice *device;
_NMDeviceWifiCapabilities capabilities;
- _NM80211Mode mode;
if (!nm_platform_wifi_get_capabilities(NM_PLATFORM_GET, plink->ifindex, &capabilities)) {
nm_log_warn(LOGD_PLATFORM | LOGD_WIFI,
@@ -113,16 +127,6 @@ create_device(NMDeviceFactory *factory,
return NULL;
}
- /* Ignore monitor-mode and other unhandled interface types.
- * FIXME: keep TYPE_MONITOR devices in UNAVAILABLE state and manage
- * them if/when they change to a handled type.
- */
- mode = nm_platform_wifi_get_mode(NM_PLATFORM_GET, plink->ifindex);
- if (mode == _NM_802_11_MODE_UNKNOWN) {
- *out_ignore = TRUE;
- return NULL;
- }
-
device = nm_device_wifi_new(iface, capabilities);
g_signal_connect_object(device,