diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index 003552bc47..8a18440ce7 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, rstate->sw_enabled = FALSE; rstate->hw_enabled = FALSE; return; + case NM_RFKILL_STATE_HARD_BLOCKED_OS_NOT_OWNER: + /* TODO: do something special here */ + rstate->sw_enabled = FALSE; + rstate->hw_enabled = FALSE; + return; } nm_assert_not_reached(); } diff --git a/src/core/nm-rfkill-manager.c b/src/core/nm-rfkill-manager.c index bb6dcfd72c..2315973d85 100644 --- a/src/core/nm-rfkill-manager.c +++ b/src/core/nm-rfkill-manager.c @@ -90,6 +90,8 @@ nm_rfkill_state_to_string(NMRfkillState state) return "soft-blocked"; case NM_RFKILL_STATE_HARD_BLOCKED: return "hard-blocked"; + case NM_RFKILL_STATE_HARD_BLOCKED_OS_NOT_OWNER: + return "hard-blocked-os-not-owner"; } return nm_assert_unreachable_val("unknown"); } @@ -153,7 +155,7 @@ killswitch_destroy(Killswitch *ks) } static NMRfkillState -sysfs_state_to_nm_state(int sysfs_state) +sysfs_state_to_nm_state(int sysfs_state, int sysfs_reason) { switch (sysfs_state) { case 0: @@ -161,6 +163,11 @@ sysfs_state_to_nm_state(int sysfs_state) case 1: return NM_RFKILL_STATE_UNBLOCKED; case 2: + /* sysfs reason is a bitmap, in case we have both reasons (SIGNAL and NOT_OWNER), we want + * to consider the device as not owned. + */ + if (sysfs_reason & 2) + return NM_RFKILL_STATE_HARD_BLOCKED_OS_NOT_OWNER; return NM_RFKILL_STATE_HARD_BLOCKED; default: nm_log_warn(LOGD_RFKILL, "unhandled rfkill state %d", sysfs_state); @@ -191,6 +198,7 @@ recheck_killswitches(NMRfkillManager *self) struct udev_device *device; NMRfkillState dev_state; int sysfs_state; + int sysfs_reason; device = udev_device_new_from_subsystem_sysname(nm_udev_client_get_udev(priv->udev_client), "rfkill", @@ -203,15 +211,23 @@ recheck_killswitches(NMRfkillManager *self) G_MININT, G_MAXINT, -1); - dev_state = sysfs_state_to_nm_state(sysfs_state); + sysfs_reason = _nm_utils_ascii_str_to_int64( + udev_device_get_property_value(device, "RFKILL_STATE_REASON"), + 10, + G_MININT, + G_MAXINT, + 1); /* defaults to SIGNAL in case the kernel does not support this */ + + 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", + "%s rfkill%s switch %s state now %d/%u reason: 0x%x", nm_rfkill_type_to_string(ks->rtype), ks->platform ? " platform" : "", ks->name, sysfs_state, - dev_state); + dev_state, + sysfs_reason); if (ks->platform == FALSE) { if (dev_state > poll_states[ks->rtype]) diff --git a/src/core/nm-rfkill-manager.h b/src/core/nm-rfkill-manager.h index db1385ea6a..a9c723f154 100644 --- a/src/core/nm-rfkill-manager.h +++ b/src/core/nm-rfkill-manager.h @@ -11,6 +11,13 @@ typedef enum { NM_RFKILL_STATE_UNBLOCKED = 0, NM_RFKILL_STATE_SOFT_BLOCKED = 1, NM_RFKILL_STATE_HARD_BLOCKED = 2, + /* 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, } NMRfkillState; typedef enum {