summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2023-05-10 16:22:08 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2023-05-15 10:10:42 +0200
commit1494774bd129ae00f6bdf3a88881952fdf8a10a7 (patch)
tree6f651c6d8c08c0c829e132eca53a848a9aebaebf
parentfc0fc4ab0dd0f36c39f4633d21599f6cf5468908 (diff)
downloadNetworkManager-1494774bd129ae00f6bdf3a88881952fdf8a10a7.tar.gz
device: add functions to get and set sys-iface-state before sleep
-rw-r--r--src/core/devices/nm-device.c24
-rw-r--r--src/core/devices/nm-device.h4
2 files changed, 27 insertions, 1 deletions
diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c
index 6639492ee5..516fc657a0 100644
--- a/src/core/devices/nm-device.c
+++ b/src/core/devices/nm-device.c
@@ -570,6 +570,8 @@ typedef struct _NMDevicePrivate {
NMDeviceSysIfaceState sys_iface_state_;
};
+ NMDeviceSysIfaceState sys_iface_state_before_sleep;
+
bool carrier : 1;
bool ignore_carrier : 1;
@@ -3052,6 +3054,22 @@ nm_device_sys_iface_state_set(NMDevice *self, NMDeviceSysIfaceState sys_iface_st
nm_assert(priv->sys_iface_state == sys_iface_state);
}
+void
+nm_device_notify_sleeping(NMDevice *self)
+{
+ NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self);
+
+ priv->sys_iface_state_before_sleep = priv->sys_iface_state;
+}
+
+NMDeviceSysIfaceState
+nm_device_get_sys_iface_state_before_sleep(NMDevice *self)
+{
+ NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self);
+
+ return priv->sys_iface_state_before_sleep;
+}
+
static void
_active_connection_set_state_flags_full(NMDevice *self,
NMActivationStateFlags flags,
@@ -17961,7 +17979,11 @@ nm_device_init(NMDevice *self)
priv->unmanaged_mask = priv->unmanaged_flags;
priv->available_connections = g_hash_table_new_full(nm_direct_hash, NULL, g_object_unref, NULL);
priv->ip6_saved_properties = g_hash_table_new_full(nm_str_hash, g_str_equal, NULL, g_free);
- priv->sys_iface_state_ = NM_DEVICE_SYS_IFACE_STATE_EXTERNAL;
+
+ priv->sys_iface_state_ = NM_DEVICE_SYS_IFACE_STATE_EXTERNAL;
+ /* If networking is already disabled at boot, we want to manage all devices
+ * after re-enabling networking; hence, the initial state is MANAGED. */
+ priv->sys_iface_state_before_sleep = NM_DEVICE_SYS_IFACE_STATE_MANAGED;
priv->promisc_reset = NM_OPTION_BOOL_DEFAULT;
}
diff --git a/src/core/devices/nm-device.h b/src/core/devices/nm-device.h
index d32b77dc83..8d8249d1a2 100644
--- a/src/core/devices/nm-device.h
+++ b/src/core/devices/nm-device.h
@@ -728,6 +728,10 @@ gboolean nm_device_sys_iface_state_is_external_or_assume(NMDevice *self);
void nm_device_sys_iface_state_set(NMDevice *device, NMDeviceSysIfaceState sys_iface_state);
+void nm_device_notify_sleeping(NMDevice *self);
+
+NMDeviceSysIfaceState nm_device_get_sys_iface_state_before_sleep(NMDevice *self);
+
void nm_device_state_changed(NMDevice *device, NMDeviceState state, NMDeviceStateReason reason);
void nm_device_queue_state(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason);