mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-03 18:17:59 +02:00
core: negotiate the best base setting
When the two base settings are present, use one of higher priority. This will pick the "bridge" setting when both "bridge" and "bluetooth" are present for a Bluetooth NAP connection.
This commit is contained in:
parent
7b5712acd2
commit
2c1a178f5b
6 changed files with 31 additions and 21 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue