5ac481bbc0
Let's keep rhel-7.4 and Fedora package in sync, so Fedora benefits from bugfixes during rhel-7.4 development and RHEL benefits from additional testing by the community. These are all upstream patches originally cherry-picked from nm-1-8 branch.
141 lines
5.7 KiB
Diff
141 lines
5.7 KiB
Diff
From f2d099c8c534ee426dbc31a3a61fcf27c18b92d8 Mon Sep 17 00:00:00 2001
|
|
From: Thomas Haller <thaller@redhat.com>
|
|
Date: Thu, 11 May 2017 19:26:28 +0200
|
|
Subject: [PATCH 1/2] core: cleanup logging reading device-state
|
|
|
|
- print string value instead of numerical "managed"
|
|
- for missing state, print the same format. After all,
|
|
some defaults apply and it is interesting to know what
|
|
they are.
|
|
|
|
(cherry picked from commit 81008c90ac9832ade1c9783078823fdd45221225)
|
|
(cherry picked from commit 8da225283b9977554a6b78e73dc03d22b8703027)
|
|
---
|
|
src/nm-config.c | 30 +++++++++++++-----------------
|
|
1 file changed, 13 insertions(+), 17 deletions(-)
|
|
|
|
diff --git a/src/nm-config.c b/src/nm-config.c
|
|
index 2cdf855..954cad7 100644
|
|
--- a/src/nm-config.c
|
|
+++ b/src/nm-config.c
|
|
@@ -1873,6 +1873,13 @@ _nm_config_state_set (NMConfig *self,
|
|
#define DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_PERM_HW_ADDR_FAKE "perm-hw-addr-fake"
|
|
#define DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_CONNECTION_UUID "connection-uuid"
|
|
|
|
+NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_device_state_managed_type_to_str, NMConfigDeviceStateManagedType,
|
|
+ NM_UTILS_LOOKUP_DEFAULT_NM_ASSERT ("unknown"),
|
|
+ NM_UTILS_LOOKUP_STR_ITEM (NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_UNKNOWN, "unknown"),
|
|
+ NM_UTILS_LOOKUP_STR_ITEM (NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_UNMANAGED, "unmanaged"),
|
|
+ NM_UTILS_LOOKUP_STR_ITEM (NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_MANAGED, "managed"),
|
|
+);
|
|
+
|
|
static NMConfigDeviceStateData *
|
|
_config_device_state_data_new (int ifindex, GKeyFile *kf)
|
|
{
|
|
@@ -1968,27 +1975,16 @@ nm_config_device_state_load (int ifindex)
|
|
|
|
device_state = _config_device_state_data_new (ifindex, kf);
|
|
|
|
- if (kf) {
|
|
- _LOGT ("device-state: read #%d (%s); managed=%d%s%s%s%s%s%s",
|
|
- ifindex, path,
|
|
- device_state->managed,
|
|
- NM_PRINT_FMT_QUOTED (device_state->connection_uuid, ", connection-uuid=", device_state->connection_uuid, "", ""),
|
|
- NM_PRINT_FMT_QUOTED (device_state->perm_hw_addr_fake, ", perm-hw-addr-fake=", device_state->perm_hw_addr_fake, "", ""));
|
|
- } else {
|
|
- _LOGT ("device-state: read #%d (%s); no persistent state",
|
|
- ifindex, path);
|
|
- }
|
|
+ _LOGT ("device-state: %s #%d (%s); managed=%s%s%s%s%s%s%s",
|
|
+ kf ? "read" : "miss",
|
|
+ ifindex, path,
|
|
+ _device_state_managed_type_to_str (device_state->managed),
|
|
+ NM_PRINT_FMT_QUOTED (device_state->connection_uuid, ", connection-uuid=", device_state->connection_uuid, "", ""),
|
|
+ NM_PRINT_FMT_QUOTED (device_state->perm_hw_addr_fake, ", perm-hw-addr-fake=", device_state->perm_hw_addr_fake, "", ""));
|
|
|
|
return device_state;
|
|
}
|
|
|
|
-NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_device_state_managed_type_to_str, NMConfigDeviceStateManagedType,
|
|
- NM_UTILS_LOOKUP_DEFAULT_NM_ASSERT ("unknown"),
|
|
- NM_UTILS_LOOKUP_STR_ITEM (NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_UNKNOWN, "unknown"),
|
|
- NM_UTILS_LOOKUP_STR_ITEM (NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_UNMANAGED, "unmanaged"),
|
|
- NM_UTILS_LOOKUP_STR_ITEM (NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_MANAGED, "managed"),
|
|
-);
|
|
-
|
|
gboolean
|
|
nm_config_device_state_write (int ifindex,
|
|
NMConfigDeviceStateManagedType managed,
|
|
--
|
|
2.9.3
|
|
|
|
|
|
From 41ff1247a2dcfd6c781cbce2fac12ab6ae657727 Mon Sep 17 00:00:00 2001
|
|
From: Thomas Haller <thaller@redhat.com>
|
|
Date: Thu, 11 May 2017 19:40:55 +0200
|
|
Subject: [PATCH 2/2] core: fix reading device state file
|
|
|
|
For manged=unknown, we don't write the value to the
|
|
device state keyfile. The results in an empty file,
|
|
or at least, a keyfile that doesn't have device.managed
|
|
set.
|
|
|
|
On read, we must treat a missing device.managed flag as
|
|
unknown, and not as unmanaged. Otherwise, on restart
|
|
a device becomes marked as explicitly unmanaged.
|
|
|
|
This was broken by commit 142ebb1 "core: only persist explicit managed
|
|
state in device's state file", where we started conditionally
|
|
to no longer write the managed state.
|
|
|
|
Reported-by: Michael Biebl <mbiebl@debian.org>
|
|
Fixes: 142ebb10376ec592593f15b0359f38be89c97620
|
|
(cherry picked from commit 348ffdec183ee198499dad1365906e8d16ff4122)
|
|
(cherry picked from commit 33d3ec3b3e5d2e737afc8db6c64850e67db5c12d)
|
|
---
|
|
src/nm-config.c | 24 +++++++++++++-----------
|
|
1 file changed, 13 insertions(+), 11 deletions(-)
|
|
|
|
diff --git a/src/nm-config.c b/src/nm-config.c
|
|
index 954cad7..54ccf9a 100644
|
|
--- a/src/nm-config.c
|
|
+++ b/src/nm-config.c
|
|
@@ -1894,21 +1894,23 @@ _config_device_state_data_new (int ifindex, GKeyFile *kf)
|
|
nm_assert (ifindex > 0);
|
|
|
|
if (kf) {
|
|
- gboolean managed;
|
|
-
|
|
- managed = nm_config_keyfile_get_boolean (kf,
|
|
- DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE,
|
|
- DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_MANAGED,
|
|
- FALSE);
|
|
- managed_type = managed
|
|
- ? NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_MANAGED
|
|
- : NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_UNMANAGED;
|
|
-
|
|
- if (managed) {
|
|
+ switch (nm_config_keyfile_get_boolean (kf,
|
|
+ DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE,
|
|
+ DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_MANAGED,
|
|
+ -1)) {
|
|
+ case TRUE:
|
|
+ managed_type = NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_MANAGED;
|
|
connection_uuid = nm_config_keyfile_get_value (kf,
|
|
DEVICE_RUN_STATE_KEYFILE_GROUP_DEVICE,
|
|
DEVICE_RUN_STATE_KEYFILE_KEY_DEVICE_CONNECTION_UUID,
|
|
NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY);
|
|
+ break;
|
|
+ case FALSE:
|
|
+ managed_type = NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_UNMANAGED;
|
|
+ break;
|
|
+ case -1:
|
|
+ /* missing property in keyfile. */
|
|
+ break;
|
|
}
|
|
|
|
perm_hw_addr_fake = nm_config_keyfile_get_value (kf,
|
|
--
|
|
2.9.3
|
|
|