core: improve ifname matching of existing x generated connections (rh #1077743)
DEVICE="ens3" ONBOOT=yes NETBOOT=yes UUID="23466771-f5fa-4ca9-856f-eaf4a8e20c3f" BOOTPROTO=none IPADDR="10.0.0.2" PREFIX="24" GATEWAY="10.0.0.1" HWADDR="52:54:00:12:34:56" TYPE=Ethernet NAME="ens3" This ifcfg file results in connection.interface-name=ens3. However, device-generated connection didn't set interface-name property. Fix that by setting interface-name property when generating a connection. Also allow matching connections if interface-name is not set in a connection. https://bugzilla.redhat.com/show_bug.cgi?id=1077743
This commit is contained in:
@@ -753,6 +753,35 @@ check_ip4_method_disabled_auto (NMConnection *orig,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
check_connection_interface_name (NMConnection *orig,
|
||||
NMConnection *candidate,
|
||||
GHashTable *settings)
|
||||
{
|
||||
GHashTable *props;
|
||||
const char *orig_ifname, *cand_ifname;
|
||||
NMSettingConnection *s_con_orig, *s_con_cand;
|
||||
|
||||
props = g_hash_table_lookup (settings, NM_SETTING_CONNECTION_SETTING_NAME);
|
||||
if ( !props
|
||||
|| (g_hash_table_size (props) != 1)
|
||||
|| !g_hash_table_lookup (props, NM_SETTING_CONNECTION_INTERFACE_NAME)) {
|
||||
/* We only handle 'interface-name' here. */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If one of the interface name is NULL, we accept that connection */
|
||||
s_con_orig = nm_connection_get_setting_connection (orig);
|
||||
s_con_cand = nm_connection_get_setting_connection (candidate);
|
||||
orig_ifname = nm_setting_connection_get_interface_name (s_con_orig);
|
||||
cand_ifname = nm_setting_connection_get_interface_name (s_con_cand);
|
||||
|
||||
if (!orig_ifname || !cand_ifname)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static NMConnection *
|
||||
check_possible_match (NMConnection *orig,
|
||||
NMConnection *candidate,
|
||||
@@ -770,6 +799,9 @@ check_possible_match (NMConnection *orig,
|
||||
if (check_ip4_method_disabled_auto (orig, candidate, settings, device_has_carrier))
|
||||
return candidate;
|
||||
|
||||
if (check_connection_interface_name (orig, candidate, settings))
|
||||
return candidate;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user