From a95ea0eb294d646f17b5e1cf4f17cb1540f8af3a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 1 Sep 2021 17:23:09 +0200 Subject: [PATCH] cloud-setup: process iface-datas in sorted order The routes/rules that are configured are independent of the order in which we process the devices. That is, because they use the "iface_idx" for cases where there is ambiguity. Still, it feels nicer to always process them in a defined order. --- src/nm-cloud-setup/main.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/nm-cloud-setup/main.c b/src/nm-cloud-setup/main.c index bb5c0d5ded..403c8d7597 100644 --- a/src/nm-cloud-setup/main.c +++ b/src/nm-cloud-setup/main.c @@ -405,14 +405,15 @@ _nmc_mangle_connection(NMDevice * device, /*****************************************************************************/ static gboolean -_config_one(GCancellable * sigterm_cancellable, - NMClient * nmc, - const NMCSProviderGetConfigResult * result, - const char * hwaddr, - const NMCSProviderGetConfigIfaceData *config_data) +_config_one(GCancellable * sigterm_cancellable, + NMClient * nmc, + const NMCSProviderGetConfigResult *result, + guint idx) { - gs_unref_object NMDevice *device = NULL; - gs_unref_object NMConnection *applied_connection = NULL; + const NMCSProviderGetConfigIfaceData *config_data = result->iface_datas_arr[idx]; + const char * hwaddr = config_data->hwaddr; + gs_unref_object NMDevice *device = NULL; + gs_unref_object NMConnection *applied_connection = NULL; guint64 applied_version_id; gs_free_error GError *error = NULL; gboolean changed; @@ -537,14 +538,11 @@ _config_all(GCancellable * sigterm_cancellable, NMClient * nmc, const NMCSProviderGetConfigResult *result) { - GHashTableIter h_iter; - const NMCSProviderGetConfigIfaceData *c_config_data; - const char * c_hwaddr; - gboolean any_changes = FALSE; + gboolean any_changes = FALSE; + guint i; - g_hash_table_iter_init(&h_iter, result->iface_datas); - while (g_hash_table_iter_next(&h_iter, (gpointer *) &c_hwaddr, (gpointer *) &c_config_data)) { - if (_config_one(sigterm_cancellable, nmc, result, c_hwaddr, c_config_data)) + for (i = 0; i < result->n_iface_datas; i++) { + if (_config_one(sigterm_cancellable, nmc, result, i)) any_changes = TRUE; }