mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-06 09:20:32 +01:00
core: explicitly pass D-Bus path to nm_utils_log_connection_diff()
No longer rely on nm_connection_get_path() being meaningful in server. It also was wrong. During update, nm_settings_connection_update() would call nm_utils_log_connection_diff (replace_connection, NM_CONNECTION (self), ... where replace_connection has no path set, and nothing was logged. Fix it, by explicitly passing the D-Bus path. Also, because nm-core-utils.c should be independent of nm-dbus-object.h.
This commit is contained in:
parent
9efa7c7220
commit
b0bf9b2b9b
5 changed files with 30 additions and 17 deletions
|
|
@ -2234,7 +2234,13 @@ _log_connection_sort_names (LogConnectionSettingData *setting_data, GArray *sort
|
|||
}
|
||||
|
||||
void
|
||||
nm_utils_log_connection_diff (NMConnection *connection, NMConnection *diff_base, guint32 level, guint64 domain, const char *name, const char *prefix)
|
||||
nm_utils_log_connection_diff (NMConnection *connection,
|
||||
NMConnection *diff_base,
|
||||
guint32 level,
|
||||
guint64 domain,
|
||||
const char *name,
|
||||
const char *prefix,
|
||||
const char *dbus_path)
|
||||
{
|
||||
GHashTable *connection_diff = NULL;
|
||||
GArray *sorted_hashes;
|
||||
|
|
@ -2310,7 +2316,6 @@ nm_utils_log_connection_diff (NMConnection *connection, NMConnection *diff_base,
|
|||
|
||||
if (print_header) {
|
||||
GError *err_verify = NULL;
|
||||
const char *path = nm_connection_get_path (connection);
|
||||
const char *t1, *t2;
|
||||
|
||||
t1 = nm_connection_get_connection_type (connection);
|
||||
|
|
@ -2320,12 +2325,12 @@ nm_utils_log_connection_diff (NMConnection *connection, NMConnection *diff_base,
|
|||
prefix, name,
|
||||
connection, G_OBJECT_TYPE_NAME (connection), NM_PRINT_FMT_QUOTE_STRING (t1),
|
||||
diff_base, G_OBJECT_TYPE_NAME (diff_base), NM_PRINT_FMT_QUOTE_STRING (t2),
|
||||
NM_PRINT_FMT_QUOTED (path, " [", path, "]", ""));
|
||||
NM_PRINT_FMT_QUOTED (dbus_path, " [", dbus_path, "]", ""));
|
||||
} else {
|
||||
nm_log (level, domain, NULL, NULL, "%sconnection '%s' (%p/%s/%s%s%s):%s%s%s",
|
||||
prefix, name,
|
||||
connection, G_OBJECT_TYPE_NAME (connection), NM_PRINT_FMT_QUOTE_STRING (t1),
|
||||
NM_PRINT_FMT_QUOTED (path, " [", path, "]", ""));
|
||||
NM_PRINT_FMT_QUOTED (dbus_path, " [", dbus_path, "]", ""));
|
||||
}
|
||||
print_header = FALSE;
|
||||
|
||||
|
|
|
|||
|
|
@ -231,7 +231,12 @@ const char *nm_utils_new_infiniband_name (char *name, const char *parent_name, i
|
|||
|
||||
int nm_utils_cmp_connection_by_autoconnect_priority (NMConnection *a, NMConnection *b);
|
||||
|
||||
void nm_utils_log_connection_diff (NMConnection *connection, NMConnection *diff_base, guint32 level, guint64 domain, const char *name, const char *prefix);
|
||||
void nm_utils_log_connection_diff (NMConnection *connection,
|
||||
NMConnection *diff_base,
|
||||
guint32 level, guint64 domain,
|
||||
const char *name,
|
||||
const char *prefix,
|
||||
const char *dbus_path);
|
||||
|
||||
gint64 nm_utils_get_monotonic_timestamp_ns (void);
|
||||
gint64 nm_utils_get_monotonic_timestamp_us (void);
|
||||
|
|
|
|||
|
|
@ -661,8 +661,10 @@ nm_settings_connection_update (NMSettingsConnection *self,
|
|||
NM_SETTING_COMPARE_FLAG_EXACT)) {
|
||||
gs_unref_object NMConnection *simple = NULL;
|
||||
|
||||
if (log_diff_name)
|
||||
nm_utils_log_connection_diff (replace_connection, NM_CONNECTION (self), LOGL_DEBUG, LOGD_CORE, log_diff_name, "++ ");
|
||||
if (log_diff_name) {
|
||||
nm_utils_log_connection_diff (replace_connection, NM_CONNECTION (self), LOGL_DEBUG, LOGD_CORE, log_diff_name, "++ ",
|
||||
nm_dbus_object_get_path (NM_DBUS_OBJECT (self)));
|
||||
}
|
||||
|
||||
/* Make a copy of agent-owned secrets because they won't be present in
|
||||
* the connection returned by plugins, as plugins return only what was
|
||||
|
|
|
|||
|
|
@ -1031,7 +1031,8 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection)
|
|||
g_object_ref (connection));
|
||||
_clear_connections_cached_list (&priv->connections_cached_list);
|
||||
|
||||
nm_utils_log_connection_diff (NM_CONNECTION (connection), NULL, LOGL_DEBUG, LOGD_CORE, "new connection", "++ ");
|
||||
nm_utils_log_connection_diff (NM_CONNECTION (connection), NULL, LOGL_DEBUG, LOGD_CORE, "new connection", "++ ",
|
||||
path);
|
||||
|
||||
/* Only emit the individual connection-added signal after connections
|
||||
* have been initially loaded.
|
||||
|
|
|
|||
|
|
@ -232,13 +232,13 @@ test_nm_utils_log_connection_diff (void)
|
|||
|
||||
connection = nm_simple_connection_new ();
|
||||
nm_connection_add_setting (connection, nm_setting_connection_new ());
|
||||
nm_utils_log_connection_diff (connection, NULL, LOGL_DEBUG, LOGD_CORE, "test1", ">>> ");
|
||||
nm_utils_log_connection_diff (connection, NULL, LOGL_DEBUG, LOGD_CORE, "test1", ">>> ", NULL);
|
||||
|
||||
nm_connection_add_setting (connection, nm_setting_wired_new ());
|
||||
nm_utils_log_connection_diff (connection, NULL, LOGL_DEBUG, LOGD_CORE, "test2", ">>> ");
|
||||
nm_utils_log_connection_diff (connection, NULL, LOGL_DEBUG, LOGD_CORE, "test2", ">>> ", NULL);
|
||||
|
||||
connection2 = nm_simple_connection_new_clone (connection);
|
||||
nm_utils_log_connection_diff (connection, connection2, LOGL_DEBUG, LOGD_CORE, "test3", ">>> ");
|
||||
nm_utils_log_connection_diff (connection, connection2, LOGL_DEBUG, LOGD_CORE, "test3", ">>> ", NULL);
|
||||
|
||||
g_object_set (nm_connection_get_setting_connection (connection),
|
||||
NM_SETTING_CONNECTION_ID, "id",
|
||||
|
|
@ -248,24 +248,24 @@ test_nm_utils_log_connection_diff (void)
|
|||
NM_SETTING_CONNECTION_ID, "id2",
|
||||
NM_SETTING_CONNECTION_MASTER, "master2",
|
||||
NULL);
|
||||
nm_utils_log_connection_diff (connection, connection2, LOGL_DEBUG, LOGD_CORE, "test4", ">>> ");
|
||||
nm_utils_log_connection_diff (connection, connection2, LOGL_DEBUG, LOGD_CORE, "test4", ">>> ", NULL);
|
||||
|
||||
nm_connection_add_setting (connection, nm_setting_802_1x_new ());
|
||||
nm_utils_log_connection_diff (connection, connection2, LOGL_DEBUG, LOGD_CORE, "test5", ">>> ");
|
||||
nm_utils_log_connection_diff (connection, connection2, LOGL_DEBUG, LOGD_CORE, "test5", ">>> ", NULL);
|
||||
|
||||
g_object_set (nm_connection_get_setting_802_1x (connection),
|
||||
NM_SETTING_802_1X_PASSWORD, "id2",
|
||||
NM_SETTING_802_1X_PASSWORD_FLAGS, NM_SETTING_SECRET_FLAG_NOT_SAVED,
|
||||
NULL);
|
||||
nm_utils_log_connection_diff (connection, NULL, LOGL_DEBUG, LOGD_CORE, "test6", ">>> ");
|
||||
nm_utils_log_connection_diff (connection, connection2, LOGL_DEBUG, LOGD_CORE, "test7", ">>> ");
|
||||
nm_utils_log_connection_diff (connection2, connection, LOGL_DEBUG, LOGD_CORE, "test8", ">>> ");
|
||||
nm_utils_log_connection_diff (connection, NULL, LOGL_DEBUG, LOGD_CORE, "test6", ">>> ", NULL);
|
||||
nm_utils_log_connection_diff (connection, connection2, LOGL_DEBUG, LOGD_CORE, "test7", ">>> ", NULL);
|
||||
nm_utils_log_connection_diff (connection2, connection, LOGL_DEBUG, LOGD_CORE, "test8", ">>> ", NULL);
|
||||
|
||||
g_clear_object (&connection);
|
||||
g_clear_object (&connection2);
|
||||
|
||||
connection = nmtst_create_minimal_connection ("id-vpn-1", NULL, NM_SETTING_VPN_SETTING_NAME, NULL);
|
||||
nm_utils_log_connection_diff (connection, NULL, LOGL_DEBUG, LOGD_CORE, "test-vpn-1", ">>> ");
|
||||
nm_utils_log_connection_diff (connection, NULL, LOGL_DEBUG, LOGD_CORE, "test-vpn-1", ">>> ", NULL);
|
||||
|
||||
g_clear_object (&connection);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue