ethernet: complete an interface name in complete_connection()

If the AddAndActivate() caller didn't explicitely a MAC address, default
to pinpointing the connection to the device by the means of an interface
name. This makes more sense than a MAC address with stable device names.
This commit is contained in:
Lubomir Rintel 2019-05-07 10:21:04 +02:00
parent e9c6b55b16
commit dbdc34b99c

View file

@ -1390,8 +1390,6 @@ complete_connection (NMDevice *device,
{
NMSettingWired *s_wired;
NMSettingPppoe *s_pppoe;
const char *perm_hw_addr;
gboolean perm_hw_addr_is_fake;
s_pppoe = nm_connection_get_setting_pppoe (connection);
@ -1401,6 +1399,12 @@ complete_connection (NMDevice *device,
if (s_pppoe && !nm_setting_verify (NM_SETTING (s_pppoe), NULL, error))
return FALSE;
s_wired = nm_connection_get_setting_wired (connection);
if (!s_wired) {
s_wired = (NMSettingWired *) nm_setting_wired_new ();
nm_connection_add_setting (connection, NM_SETTING (s_wired));
}
/* Default to an ethernet-only connection, but if a PPPoE setting was given
* then PPPoE should be our connection type.
*/
@ -1411,22 +1415,9 @@ complete_connection (NMDevice *device,
NULL,
s_pppoe ? _("PPPoE connection") : _("Wired connection"),
NULL,
NULL,
nm_setting_wired_get_mac_address (s_wired) ? NULL : nm_device_get_iface (device),
s_pppoe ? FALSE : TRUE); /* No IPv6 by default yet for PPPoE */
s_wired = nm_connection_get_setting_wired (connection);
if (!s_wired) {
s_wired = (NMSettingWired *) nm_setting_wired_new ();
nm_connection_add_setting (connection, NM_SETTING (s_wired));
}
perm_hw_addr = nm_device_get_permanent_hw_address_full (device, TRUE, &perm_hw_addr_is_fake);
if (perm_hw_addr && !perm_hw_addr_is_fake && !nm_setting_wired_get_mac_address (s_wired)) {
g_object_set (G_OBJECT (s_wired),
NM_SETTING_WIRED_MAC_ADDRESS, perm_hw_addr,
NULL);
}
return TRUE;
}