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.
This commit is contained in:
Thomas Haller 2021-09-01 17:23:09 +02:00
parent 1c5cb9d3c2
commit a95ea0eb29
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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;
}