diff options
author | Thomas Haller <thaller@redhat.com> | 2020-06-06 20:49:48 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-06-19 17:14:10 +0200 |
commit | bb6c2d73713f69ceb6c827dcc7fb7dac91595ece (patch) | |
tree | 19d02b4e5023c0bd3f150c5df4fd79bcbbe28bc7 | |
parent | 19b6d38932f3496364899eb9393080c804f4a488 (diff) | |
download | NetworkManager-bb6c2d73713f69ceb6c827dcc7fb7dac91595ece.tar.gz |
libnm: ensure stable behavior in _nm_ip_route_attribute_validate_all()
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.c | 19 |
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 bc81129177..f7a022b6cb 100644 --- a/libnm-core/nm-setting-ip-config.c +++ b/libnm-core/nm-setting-ip-config.c @@ -1363,9 +1363,12 @@ nm_ip_route_attribute_validate (const char *name, gboolean _nm_ip_route_attribute_validate_all (const NMIPRoute *route, GError **error) { - GHashTableIter iter; - const char *key; + NMUtilsNamedValue attrs_static[G_N_ELEMENTS (ip_route_attribute_spec)]; + gs_free NMUtilsNamedValue *attrs_free = NULL; + const NMUtilsNamedValue *attrs; + guint attrs_len; GVariant *val; + guint i; guint8 u8; g_return_val_if_fail (route, FALSE); @@ -1374,9 +1377,15 @@ _nm_ip_route_attribute_validate_all (const NMIPRoute *route, GError **error) if (!route->attributes) return TRUE; - g_hash_table_iter_init (&iter, route->attributes); - while (g_hash_table_iter_next (&iter, (gpointer *) &key, (gpointer *) &val)) { - if (!nm_ip_route_attribute_validate (key, val, route->family, NULL, error)) + 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 *val2 = attrs[i].value_ptr; + + if (!nm_ip_route_attribute_validate (key, val2, route->family, NULL, NULL)) return FALSE; } |