device: fix nm_utils_match_connection() for NMSettingInfiniband:mac-address

<debug> [1474469475.3318] Connection 'inf_ib0' differs from candidate 't-inf' in infiniband.mac-address
    <debug> [1474469475.3318] manager: (inf_ib0): generated connection 'inf_ib0'

https://bugzilla.redhat.com/show_bug.cgi?id=1375558
(cherry picked from commit 78957c0d39)
This commit is contained in:
Thomas Haller 2016-09-21 17:07:42 +02:00
parent 766f040681
commit f6c0c2d46e

View file

@ -527,6 +527,39 @@ check_connection_mac_address (NMConnection *orig,
return FALSE;
}
static gboolean
check_connection_infiniband_mac_address (NMConnection *orig,
NMConnection *candidate,
GHashTable *settings)
{
GHashTable *props;
const char *orig_mac = NULL, *cand_mac = NULL;
NMSettingInfiniband *s_infiniband_orig, *s_infiniband_cand;
props = check_property_in_hash (settings,
NM_SETTING_INFINIBAND_SETTING_NAME,
NM_SETTING_INFINIBAND_MAC_ADDRESS);
if (!props)
return TRUE;
/* If one of the MAC addresses is NULL, we accept that connection */
s_infiniband_orig = nm_connection_get_setting_infiniband (orig);
if (s_infiniband_orig)
orig_mac = nm_setting_infiniband_get_mac_address (s_infiniband_orig);
s_infiniband_cand = nm_connection_get_setting_infiniband (candidate);
if (s_infiniband_cand)
cand_mac = nm_setting_infiniband_get_mac_address (s_infiniband_cand);
if (!orig_mac || !cand_mac) {
remove_from_hash (settings, props,
NM_SETTING_INFINIBAND_SETTING_NAME,
NM_SETTING_INFINIBAND_MAC_ADDRESS);
return TRUE;
}
return FALSE;
}
static gboolean
check_connection_cloned_mac_address (NMConnection *orig,
NMConnection *candidate,
@ -640,6 +673,9 @@ check_possible_match (NMConnection *orig,
if (!check_connection_mac_address (orig, candidate, settings))
return NULL;
if (!check_connection_infiniband_mac_address (orig, candidate, settings))
return NULL;
if (!check_connection_cloned_mac_address (orig, candidate, settings))
return NULL;