summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-06-06 20:49:48 +0200
committerThomas Haller <thaller@redhat.com>2020-06-07 15:26:09 +0200
commit0f691c19758649ca07ef825670e45963d66abd65 (patch)
tree765048d54c1c506dca87b448e2cec2e9ddb24217
parent9b337df11c1f904084aeb65473f24fcc2c441bf0 (diff)
downloadNetworkManager-th/stdict-values.tar.gz
libnm: ensure stable behavior in _nm_ip_route_attribute_validate_all()th/stdict-values
Check the attributes in a defined, stable order. This is necessary, so that consistently the same error gets reported.
-rw-r--r--libnm-core/nm-setting-ip-config.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/libnm-core/nm-setting-ip-config.c b/libnm-core/nm-setting-ip-config.c
index 09a3428362..b7a0ae9daf 100644
--- a/libnm-core/nm-setting-ip-config.c
+++ b/libnm-core/nm-setting-ip-config.c
@@ -1350,20 +1350,29 @@ nm_ip_route_attribute_validate (const char *name,
gboolean
_nm_ip_route_attribute_validate_all (const NMIPRoute *route)
{
- GHashTableIter iter;
- const char *key;
- GVariant *val;
+ NMUtilsNamedValue attrs_static[G_N_ELEMENTS (ip_route_attribute_spec)];
+ gs_free NMUtilsNamedValue *attrs_free = NULL;
+ const NMUtilsNamedValue *attrs;
+ guint attrs_len;
+ guint i;
g_return_val_if_fail (route, FALSE);
if (!route->attributes)
return TRUE;
- g_hash_table_iter_init (&iter, route->attributes);
- while (g_hash_table_iter_next (&iter, (gpointer *) &key, (gpointer *) &val)) {
+ attrs = nm_utils_named_values_from_strdict (route->attributes,
+ &attrs_len,
+ attrs_static,
+ &attrs_free);
+ for (i = 0; i < attrs_len; i++) {
+ const char *key = attrs[i].name;
+ GVariant *val = attrs[i].value_ptr;
+
if (!nm_ip_route_attribute_validate (key, val, route->family, NULL, NULL))
return FALSE;
}
+
return TRUE;
}