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,