summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-05-14 20:57:53 +0200
committerThomas Haller <thaller@redhat.com>2020-05-20 21:27:17 +0200
commit3c33604aefcfb6665d51952f131d298e39b3fe60 (patch)
treedd8f4313aa5856f78f51607b08dc555de771205f
parentd1b35c9f69fc7b8838b2358a0f30a8da39e17c91 (diff)
downloadNetworkManager-3c33604aefcfb6665d51952f131d298e39b3fe60.tar.gz
libnm: check options in NMSettingEthtool.verify() in defined order
Iterating the hash gives the entries in undefined order. That means, when validation would fail for more than one option, then the error message arbitrarily points out one or the other. Instead, process the entries in a defined order.
-rw-r--r--libnm-core/nm-setting-ethtool.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/libnm-core/nm-setting-ethtool.c b/libnm-core/nm-setting-ethtool.c
index 28307e4941..17fbdc62a1 100644
--- a/libnm-core/nm-setting-ethtool.c
+++ b/libnm-core/nm-setting-ethtool.c
@@ -198,6 +198,8 @@ nm_setting_ethtool_clear_features (NMSettingEthtool *setting)
nm_ethtool_optname_is_feature);
}
+/*****************************************************************************/
+
guint
nm_setting_ethtool_init_features (NMSettingEthtool *setting,
NMTernary *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */)
@@ -277,17 +279,16 @@ nm_setting_ethtool_get_optnames (NMSettingEthtool *setting,
static gboolean
verify (NMSetting *setting, NMConnection *connection, GError **error)
{
- GHashTable *hash;
- GHashTableIter iter;
- const char *optname;
- GVariant *variant;
+ const char *const*optnames;
+ GVariant *const*variants;
+ guint len;
+ guint i;
- hash = _nm_setting_option_hash (setting, FALSE);
- if (!hash)
- return TRUE;
+ len = _nm_setting_option_get_all (setting, &optnames, &variants);
- g_hash_table_iter_init (&iter, hash);
- while (g_hash_table_iter_next (&iter, (gpointer *) &optname, (gpointer *) &variant)) {
+ for (i = 0; i < len; i++) {
+ const char *optname = optnames[i];
+ GVariant *variant = variants[i];
const GVariantType *variant_type;
NMEthtoolID ethtool_id;