From 334177bdc30caf7f8dc9577e3380a5739244ab35 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 22 Apr 2024 17:46:26 +0200 Subject: [PATCH 1/3] wifi-p2p: don't add pending action for group interface The group interface is only used during activation; there is no need to add a pending action for it, because when the device is in activating state it already delays "startup-complete" via other pending actions. --- src/core/devices/wifi/nm-device-wifi-p2p.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/core/devices/wifi/nm-device-wifi-p2p.c b/src/core/devices/wifi/nm-device-wifi-p2p.c index 981811a3b1..a8a70485a5 100644 --- a/src/core/devices/wifi/nm-device-wifi-p2p.c +++ b/src/core/devices/wifi/nm-device-wifi-p2p.c @@ -774,7 +774,6 @@ supplicant_group_iface_is_ready(NMDeviceWifiP2P *self) return; } - _set_is_waiting_for_supplicant(self, FALSE); check_group_iface_ready(self); } @@ -875,7 +874,6 @@ supplicant_iface_group_started_cb(NMSupplicantInterface *iface, state = nm_supplicant_interface_get_state(priv->group_iface); if (state == NM_SUPPLICANT_INTERFACE_STATE_STARTING) { - _set_is_waiting_for_supplicant(self, TRUE); return; } From 6a9f61122e27dbe83f34873b9af502ed5960a09d Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 22 Apr 2024 17:48:55 +0200 Subject: [PATCH 2/3] wifi-p2p: implement get_enabled()/set_enabled() Add function to set and report the rfkill state. For now, only print a message; the state will be used in the next commit. --- src/core/devices/wifi/nm-device-wifi-p2p.c | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/core/devices/wifi/nm-device-wifi-p2p.c b/src/core/devices/wifi/nm-device-wifi-p2p.c index a8a70485a5..58fcd370e7 100644 --- a/src/core/devices/wifi/nm-device-wifi-p2p.c +++ b/src/core/devices/wifi/nm-device-wifi-p2p.c @@ -54,6 +54,7 @@ typedef struct { guint peer_missing_id; bool is_waiting_for_supplicant : 1; + bool enabled : 1; } NMDeviceWifiP2PPrivate; struct _NMDeviceWifiP2P { @@ -1120,6 +1121,28 @@ impl_device_wifi_p2p_stop_find(NMDBusObject *obj, NULL); } +static gboolean +get_enabled(NMDevice *device) +{ + return NM_DEVICE_WIFI_P2P_GET_PRIVATE(device)->enabled; +} + +static void +set_enabled(NMDevice *device, gboolean enabled) +{ + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(device); + NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); + + enabled = !!enabled; + + if (priv->enabled == enabled) + return; + + priv->enabled = enabled; + + _LOGD(LOGD_DEVICE | LOGD_WIFI, "device now %s", enabled ? "enabled" : "disabled"); +} + /*****************************************************************************/ NMSupplicantInterface * @@ -1336,6 +1359,8 @@ nm_device_wifi_p2p_class_init(NMDeviceWifiP2PClass *klass) device_class->get_configured_mtu = get_configured_mtu; device_class->get_auto_ip_config_method = get_auto_ip_config_method; device_class->act_stage3_ip_config = act_stage3_ip_config; + device_class->set_enabled = set_enabled; + device_class->get_enabled = get_enabled; device_class->deactivate = deactivate; device_class->unmanaged_on_quit = unmanaged_on_quit; From 82032955dd5dfa3d9b96515cd2009ac819ce58fd Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Mon, 22 Apr 2024 17:59:50 +0200 Subject: [PATCH 3/3] wifi-p2p: consider if the device is enabled when adding pending action If the device gets rfkill-blocked, remove the pending action "waiting-for-supplicant", as it can prevent reaching "startup-complete". https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1004 --- src/core/devices/wifi/nm-device-wifi-p2p.c | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/core/devices/wifi/nm-device-wifi-p2p.c b/src/core/devices/wifi/nm-device-wifi-p2p.c index 58fcd370e7..f06383b102 100644 --- a/src/core/devices/wifi/nm-device-wifi-p2p.c +++ b/src/core/devices/wifi/nm-device-wifi-p2p.c @@ -916,7 +916,7 @@ supplicant_interfaces_release(NMDeviceWifiP2P *self, gboolean set_is_waiting) supplicant_group_interface_release(self); - if (set_is_waiting) + if (set_is_waiting && priv->enabled) _set_is_waiting_for_supplicant(self, TRUE); } @@ -947,9 +947,10 @@ device_state_changed(NMDevice *device, case NM_DEVICE_STATE_UNMANAGED: break; case NM_DEVICE_STATE_UNAVAILABLE: - if (!priv->mgmt_iface - || !nm_supplicant_interface_state_is_operational( - nm_supplicant_interface_get_state(priv->mgmt_iface))) + if (priv->enabled + && (!priv->mgmt_iface + || !nm_supplicant_interface_state_is_operational( + nm_supplicant_interface_get_state(priv->mgmt_iface)))) _set_is_waiting_for_supplicant(self, TRUE); break; case NM_DEVICE_STATE_NEED_AUTH: @@ -1141,6 +1142,10 @@ set_enabled(NMDevice *device, gboolean enabled) priv->enabled = enabled; _LOGD(LOGD_DEVICE | LOGD_WIFI, "device now %s", enabled ? "enabled" : "disabled"); + + if (!enabled) { + _set_is_waiting_for_supplicant(self, FALSE); + } } /*****************************************************************************/ @@ -1193,10 +1198,12 @@ done: nm_device_queue_recheck_available(NM_DEVICE(self), NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE, NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED); - _set_is_waiting_for_supplicant(self, - !priv->mgmt_iface - || !nm_supplicant_interface_state_is_operational( - nm_supplicant_interface_get_state(priv->mgmt_iface))); + _set_is_waiting_for_supplicant( + self, + priv->enabled + && (!priv->mgmt_iface + || !nm_supplicant_interface_state_is_operational( + nm_supplicant_interface_get_state(priv->mgmt_iface)))); } void