summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libnm-core/nm-connection.c21
-rw-r--r--libnm-core/nm-setting-connection.c2
-rw-r--r--libnm-core/nm-setting-private.h4
-rw-r--r--libnm-core/nm-setting.c15
-rw-r--r--libnm-core/nm-utils.c4
-rw-r--r--libnm-core/tests/test-general.c6
6 files changed, 31 insertions, 21 deletions
diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c
index f000d0c4d9..858f5aab88 100644
--- a/libnm-core/nm-connection.c
+++ b/libnm-core/nm-connection.c
@@ -585,21 +585,28 @@ _nm_connection_find_base_type_setting (NMConnection *connection)
NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE (connection);
GHashTableIter iter;
NMSetting *setting = NULL, *s_iter;
+ guint32 setting_prio, s_iter_prio;
g_hash_table_iter_init (&iter, priv->settings);
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &s_iter)) {
- if (!_nm_setting_is_base_type (s_iter))
+ s_iter_prio = _nm_setting_get_base_type_priority (s_iter);
+ if (!s_iter_prio)
continue;
if (setting) {
- NMSettingConnection *s_con = nm_connection_get_setting_connection (connection);
+ if (s_iter_prio > setting_prio) {
+ continue;
+ } else if (s_iter_prio == setting_prio) {
+ NMSettingConnection *s_con = nm_connection_get_setting_connection (connection);
- if (!s_con)
- return NULL;
- return nm_connection_get_setting_by_name (connection,
- nm_setting_connection_get_connection_type (s_con));
+ if (!s_con)
+ return NULL;
+ return nm_connection_get_setting_by_name (connection,
+ nm_setting_connection_get_connection_type (s_con));
+ }
}
setting = s_iter;
+ setting_prio = s_iter_prio;
}
return setting;
}
@@ -1620,7 +1627,7 @@ nm_connection_is_type (NMConnection *connection, const char *type)
if (!setting)
return FALSE;
- return _nm_setting_is_base_type (setting);
+ return !!_nm_setting_get_base_type_priority (setting);
}
static int
diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c
index 2d2247fe4c..257d6621af 100644
--- a/libnm-core/nm-setting-connection.c
+++ b/libnm-core/nm-setting-connection.c
@@ -926,7 +926,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
}
base_type = nm_setting_lookup_type (priv->type);
- if (base_type == G_TYPE_INVALID || !_nm_setting_type_is_base_type (base_type)) {
+ if (base_type == G_TYPE_INVALID || !_nm_setting_type_get_base_type_priority (base_type)) {
g_set_error (error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
diff --git a/libnm-core/nm-setting-private.h b/libnm-core/nm-setting-private.h
index 79b6ac8712..3d6e2d4d86 100644
--- a/libnm-core/nm-setting-private.h
+++ b/libnm-core/nm-setting-private.h
@@ -36,8 +36,8 @@ void _nm_register_setting (const char *name,
_nm_register_setting (NM_SETTING_ ## name ## _SETTING_NAME "", g_define_type_id, priority); \
} G_STMT_END
-gboolean _nm_setting_is_base_type (NMSetting *setting);
-gboolean _nm_setting_type_is_base_type (GType type);
+guint32 _nm_setting_get_base_type_priority (NMSetting *setting);
+guint32 _nm_setting_type_get_base_type_priority (GType type);
gint _nm_setting_compare_priority (gconstpointer a, gconstpointer b);
typedef enum NMSettingUpdateSecretResult {
diff --git a/libnm-core/nm-setting.c b/libnm-core/nm-setting.c
index 258cedc0eb..530dd0147a 100644
--- a/libnm-core/nm-setting.c
+++ b/libnm-core/nm-setting.c
@@ -211,8 +211,8 @@ _nm_setting_get_setting_priority (NMSetting *setting)
return priv->info->priority;
}
-gboolean
-_nm_setting_type_is_base_type (GType type)
+guint32
+_nm_setting_type_get_base_type_priority (GType type)
{
guint32 priority;
@@ -222,13 +222,16 @@ _nm_setting_type_is_base_type (GType type)
* base type.
*/
priority = _get_setting_type_priority (type);
- return (priority == 1 || priority == 2 || (type == NM_TYPE_SETTING_PPPOE));
+ if (priority == 1 || priority == 2 || (type == NM_TYPE_SETTING_PPPOE))
+ return priority;
+ else
+ return 0;
}
-gboolean
-_nm_setting_is_base_type (NMSetting *setting)
+guint32
+_nm_setting_get_base_type_priority (NMSetting *setting)
{
- return _nm_setting_type_is_base_type (G_OBJECT_TYPE (setting));
+ return _nm_setting_type_get_base_type_priority (G_OBJECT_TYPE (setting));
}
/**
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index 441a2dfd4e..dedad241ad 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -3896,8 +3896,8 @@ _nm_utils_inet6_is_token (const struct in6_addr *in6addr)
gboolean
nm_utils_check_virtual_device_compatibility (GType virtual_type, GType other_type)
{
- g_return_val_if_fail (_nm_setting_type_is_base_type (virtual_type), FALSE);
- g_return_val_if_fail (_nm_setting_type_is_base_type (other_type), FALSE);
+ g_return_val_if_fail (_nm_setting_type_get_base_type_priority (virtual_type), FALSE);
+ g_return_val_if_fail (_nm_setting_type_get_base_type_priority (other_type), FALSE);
if (virtual_type == NM_TYPE_SETTING_BOND) {
return ( other_type == NM_TYPE_SETTING_INFINIBAND
diff --git a/libnm-core/tests/test-general.c b/libnm-core/tests/test-general.c
index 435088eb91..cc8c6bd7f7 100644
--- a/libnm-core/tests/test-general.c
+++ b/libnm-core/tests/test-general.c
@@ -3492,7 +3492,7 @@ _test_connection_normalize_type_normalizable_setting (const char *type,
base_type = nm_setting_lookup_type (type);
g_assert (base_type != G_TYPE_INVALID);
- g_assert (_nm_setting_type_is_base_type (base_type));
+ g_assert (_nm_setting_type_get_base_type_priority (base_type));
con = nmtst_create_minimal_connection (id, NULL, NULL, &s_con);
@@ -3522,7 +3522,7 @@ _test_connection_normalize_type_unnormalizable_setting (const char *type)
base_type = nm_setting_lookup_type (type);
g_assert (base_type != G_TYPE_INVALID);
- g_assert (_nm_setting_type_is_base_type (base_type));
+ g_assert (_nm_setting_type_get_base_type_priority (base_type));
con = nmtst_create_minimal_connection (id, NULL, NULL, &s_con);
@@ -3545,7 +3545,7 @@ _test_connection_normalize_type_normalizable_type (const char *type,
base_type = nm_setting_lookup_type (type);
g_assert (base_type != G_TYPE_INVALID);
- g_assert (_nm_setting_type_is_base_type (base_type));
+ g_assert (_nm_setting_type_get_base_type_priority (base_type));
con = nmtst_create_minimal_connection (id, NULL, NULL, &s_con);