summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2022-03-28 11:15:24 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2022-03-29 09:12:36 +0200
commit2343148da81a06c5776c5ca80f26e30a72b8c758 (patch)
tree2c3ed7100c839138ae023989b306e6420ec81665
parent2bdca1f5d6f514586d6b3fdd43066eba09b0e50f (diff)
downloadNetworkManager-2343148da81a06c5776c5ca80f26e30a72b8c758.tar.gz
core: introduce "unavailable" rfkill state
Introduce a new "unavailable" rfkill state to indicate that no rfkill hardware was found. Currently it is still handled as "unblocked".
-rw-r--r--src/core/nm-manager.c5
-rw-r--r--src/core/nm-rfkill-manager.c14
-rw-r--r--src/core/nm-rfkill-manager.h9
3 files changed, 18 insertions, 10 deletions
diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c
index 046fa819e9..05650f79bf 100644
--- a/src/core/nm-manager.c
+++ b/src/core/nm-manager.c
@@ -2323,6 +2323,11 @@ _rfkill_radio_state_set_from_manager(NMRfkillManager *rfkill_mgr,
RfkillRadioState *rstate)
{
switch (nm_rfkill_manager_get_rfkill_state(rfkill_mgr, rtype)) {
+ case NM_RFKILL_STATE_UNAVAILABLE:
+ rstate->sw_enabled = TRUE;
+ rstate->hw_enabled = TRUE;
+ rstate->os_owner = TRUE;
+ return;
case NM_RFKILL_STATE_UNBLOCKED:
rstate->sw_enabled = TRUE;
rstate->hw_enabled = TRUE;
diff --git a/src/core/nm-rfkill-manager.c b/src/core/nm-rfkill-manager.c
index 9eac097294..60404c5321 100644
--- a/src/core/nm-rfkill-manager.c
+++ b/src/core/nm-rfkill-manager.c
@@ -84,6 +84,8 @@ static const char *
nm_rfkill_state_to_string(NMRfkillState state)
{
switch (state) {
+ case NM_RFKILL_STATE_UNAVAILABLE:
+ return "unavailable";
case NM_RFKILL_STATE_UNBLOCKED:
return "unblocked";
case NM_RFKILL_STATE_SOFT_BLOCKED:
@@ -188,8 +190,8 @@ recheck_killswitches(NMRfkillManager *self)
/* Default state is unblocked */
for (i = 0; i < NM_RFKILL_TYPE_MAX; i++) {
- poll_states[i] = NM_RFKILL_STATE_UNBLOCKED;
- platform_states[i] = NM_RFKILL_STATE_UNBLOCKED;
+ poll_states[i] = NM_RFKILL_STATE_UNAVAILABLE;
+ platform_states[i] = NM_RFKILL_STATE_UNAVAILABLE;
platform_checked[i] = FALSE;
}
@@ -222,12 +224,12 @@ recheck_killswitches(NMRfkillManager *self)
dev_state = sysfs_state_to_nm_state(sysfs_state, sysfs_reason);
nm_log_dbg(LOGD_RFKILL,
- "%s rfkill%s switch %s state now %d/%u reason: 0x%x",
+ "%s rfkill%s switch %s state now %d/%s reason: 0x%x",
nm_rfkill_type_to_string(ks->rtype),
ks->platform ? " platform" : "",
ks->name,
sysfs_state,
- dev_state,
+ nm_rfkill_state_to_string(dev_state),
sysfs_reason);
if (ks->platform == FALSE) {
@@ -248,7 +250,7 @@ recheck_killswitches(NMRfkillManager *self)
/* blocked platform switch state overrides device state, otherwise
* let the device state stand. (bgo #655773)
*/
- if (platform_states[i] != NM_RFKILL_STATE_UNBLOCKED)
+ if (platform_states[i] > NM_RFKILL_STATE_UNBLOCKED)
poll_states[i] = platform_states[i];
}
@@ -396,7 +398,7 @@ nm_rfkill_manager_init(NMRfkillManager *self)
c_list_init(&priv->killswitch_lst_head);
for (i = 0; i < NM_RFKILL_TYPE_MAX; i++)
- priv->rfkill_states[i] = NM_RFKILL_STATE_UNBLOCKED;
+ priv->rfkill_states[i] = NM_RFKILL_STATE_UNAVAILABLE;
priv->udev_client = nm_udev_client_new(NM_MAKE_STRV("rfkill"), handle_uevent, self);
diff --git a/src/core/nm-rfkill-manager.h b/src/core/nm-rfkill-manager.h
index a9c723f154..acca144532 100644
--- a/src/core/nm-rfkill-manager.h
+++ b/src/core/nm-rfkill-manager.h
@@ -8,16 +8,17 @@
#define __NM_RFKILL_MANAGER_H__
typedef enum {
- NM_RFKILL_STATE_UNBLOCKED = 0,
- NM_RFKILL_STATE_SOFT_BLOCKED = 1,
- NM_RFKILL_STATE_HARD_BLOCKED = 2,
+ NM_RFKILL_STATE_UNAVAILABLE = 0,
+ NM_RFKILL_STATE_UNBLOCKED = 1,
+ NM_RFKILL_STATE_SOFT_BLOCKED = 2,
+ NM_RFKILL_STATE_HARD_BLOCKED = 3,
/* NM_RFKILL_STATE_HARD_BLOCKED_OS_NOT_OWNER means that the CSME firmware
* is currently controlling the device. This feature is implmented on Intel
* wifi devices only.
* The NetworkManager can get ownership on the device, but it requires to
* first ask ownership through the iwlmei kernel module.
*/
- NM_RFKILL_STATE_HARD_BLOCKED_OS_NOT_OWNER = 3,
+ NM_RFKILL_STATE_HARD_BLOCKED_OS_NOT_OWNER = 4,
} NMRfkillState;
typedef enum {