mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 04:50:30 +01:00
utils: extend connection matching function for UUID in controller
When matching two connections one might be using UUID and the other one could be using interface-name for the controller property. When recovering from a fresh start NM does not have any context and when generating a connection we are using UUID as the controller. It is always hard to guess what is the right candidate to pick but at least something NM can do is checking if the UUID matches a connection with the same controller interface-name. If there are no other conflicts, then we can assume that is a good canditate to activate. This is a follow up to `dc254f90e2b306700a0b81f7194e9b0438c62f4c`. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1684
This commit is contained in:
parent
5565aebf30
commit
5b8fdd25ab
1 changed files with 51 additions and 0 deletions
|
|
@ -23,6 +23,7 @@
|
|||
#include "nm-setting-connection.h"
|
||||
#include "nm-setting-ip4-config.h"
|
||||
#include "nm-setting-ip6-config.h"
|
||||
#include "settings/nm-settings.h"
|
||||
#include "libnm-core-intern/nm-core-internal.h"
|
||||
#include "libnm-platform/nmp-object.h"
|
||||
|
||||
|
|
@ -684,6 +685,53 @@ check_connection_cloned_mac_address(NMConnection *orig,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_connection_controller(NMConnection *orig, NMConnection *candidate, GHashTable *settings)
|
||||
{
|
||||
GHashTable *props;
|
||||
const char *orig_controller = NULL, *cand_controller = NULL;
|
||||
NMSettingConnection *s_con_orig, *s_con_cand, *s_con_controller;
|
||||
NMSettingsConnection *con_controller;
|
||||
|
||||
props = check_property_in_hash(settings,
|
||||
NM_SETTING_CONNECTION_SETTING_NAME,
|
||||
NM_SETTING_CONNECTION_MASTER);
|
||||
if (!props)
|
||||
return TRUE;
|
||||
|
||||
s_con_orig = nm_connection_get_setting_connection(orig);
|
||||
s_con_cand = nm_connection_get_setting_connection(candidate);
|
||||
orig_controller = nm_setting_connection_get_master(s_con_orig);
|
||||
cand_controller = nm_setting_connection_get_master(s_con_cand);
|
||||
|
||||
/* A generated connection uses the UUID to specify the controller. Accept
|
||||
* candidates that specify as controller an interface name matching that
|
||||
* UUID */
|
||||
if (orig_controller && cand_controller) {
|
||||
if (nm_utils_is_uuid(orig_controller)) {
|
||||
con_controller = nm_settings_get_connection_by_uuid(NM_SETTINGS_GET, orig_controller);
|
||||
/* no connection found for that uuid */
|
||||
if (!con_controller)
|
||||
return FALSE;
|
||||
|
||||
s_con_controller =
|
||||
nm_settings_connection_get_setting(con_controller, NM_META_SETTING_TYPE_CONNECTION);
|
||||
if (nm_streq0(nm_setting_connection_get_interface_name(s_con_controller),
|
||||
cand_controller)) {
|
||||
remove_from_hash(settings,
|
||||
props,
|
||||
NM_SETTING_CONNECTION_SETTING_NAME,
|
||||
NM_SETTING_CONNECTION_MASTER);
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_connection_s390_props(NMConnection *orig, NMConnection *candidate, GHashTable *settings)
|
||||
{
|
||||
|
|
@ -765,6 +813,9 @@ check_possible_match(NMConnection *orig,
|
|||
if (!check_connection_cloned_mac_address(orig, candidate, settings))
|
||||
return NULL;
|
||||
|
||||
if (!check_connection_controller(orig, candidate, settings))
|
||||
return NULL;
|
||||
|
||||
if (!check_connection_s390_props(orig, candidate, settings))
|
||||
return NULL;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue