summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-04-21 13:08:21 +0200
committerThomas Haller <thaller@redhat.com>2018-04-23 15:43:39 +0200
commite96b1270a686018d0529ac578f85413a9341ec97 (patch)
tree90eb5403c417372e78aa4fc34ec5c8f9cda87591
parent86b54a65e63cdcee8d518f3198cbafce9f8ad7b3 (diff)
downloadNetworkManager-e96b1270a686018d0529ac578f85413a9341ec97.tar.gz
core: sort DHCP options that are exported on D-Bus
Otherwise, the order is undefined and unstable. If you call GetManagedObjects() on D-Bus multiple times, it's a very nice property if the diff is small and not full not noise.
-rw-r--r--src/nm-dhcp4-config.c17
-rw-r--r--src/nm-dhcp6-config.c17
2 files changed, 10 insertions, 24 deletions
diff --git a/src/nm-dhcp4-config.c b/src/nm-dhcp4-config.c
index 08becf3c34..ceafddf56e 100644
--- a/src/nm-dhcp4-config.c
+++ b/src/nm-dhcp4-config.c
@@ -27,6 +27,7 @@
#include "nm-dbus-interface.h"
#include "nm-utils.h"
#include "nm-dbus-object.h"
+#include "nm-core-utils.h"
/*****************************************************************************/
@@ -58,22 +59,14 @@ nm_dhcp4_config_set_options (NMDhcp4Config *self,
GHashTable *options)
{
NMDhcp4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (self);
- GHashTableIter iter;
- const char *key, *value;
- GVariantBuilder builder;
+ GVariant *val;
g_return_if_fail (NM_IS_DHCP4_CONFIG (self));
- g_return_if_fail (options != NULL);
+ g_return_if_fail (options);
+ val = nm_utils_strdict_to_variant (options);
g_variant_unref (priv->options);
-
- g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
- g_hash_table_iter_init (&iter, options);
- while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value))
- g_variant_builder_add (&builder, "{sv}", key, g_variant_new_string (value));
-
- priv->options = g_variant_builder_end (&builder);
- g_variant_ref_sink (priv->options);
+ priv->options = g_variant_ref_sink (val);
_notify (self, PROP_OPTIONS);
}
diff --git a/src/nm-dhcp6-config.c b/src/nm-dhcp6-config.c
index 5bb6c7403a..d477521afe 100644
--- a/src/nm-dhcp6-config.c
+++ b/src/nm-dhcp6-config.c
@@ -27,6 +27,7 @@
#include "nm-dbus-interface.h"
#include "nm-utils.h"
#include "nm-dbus-object.h"
+#include "nm-core-utils.h"
/*****************************************************************************/
@@ -58,22 +59,14 @@ nm_dhcp6_config_set_options (NMDhcp6Config *self,
GHashTable *options)
{
NMDhcp6ConfigPrivate *priv = NM_DHCP6_CONFIG_GET_PRIVATE (self);
- GHashTableIter iter;
- const char *key, *value;
- GVariantBuilder builder;
+ GVariant *val;
g_return_if_fail (NM_IS_DHCP6_CONFIG (self));
- g_return_if_fail (options != NULL);
+ g_return_if_fail (options);
+ val = nm_utils_strdict_to_variant (options);
g_variant_unref (priv->options);
-
- g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
- g_hash_table_iter_init (&iter, options);
- while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value))
- g_variant_builder_add (&builder, "{sv}", key, g_variant_new_string (value));
-
- priv->options = g_variant_builder_end (&builder);
- g_variant_ref_sink (priv->options);
+ priv->options = g_variant_ref_sink (val);
_notify (self, PROP_OPTIONS);
}