device: don't set a fake permanent hardware address

Software devices don't have a permanent hardware address and thus it
doesn't make sense to enforce the 'fake' (generated) permanent one
when cloned-mac-address=permanent.  Also, setting the fake permanent
address on bond devices, prevents them from inheriting the first slave
hardware address, so let's just skip the setting of MAC when
cloned-mac-address=permanent and there is no real permanent address.

https://bugzilla.redhat.com/show_bug.cgi?id=1472965
(cherry picked from commit 2f4dfd0f2e)
This commit is contained in:
Beniamino Galvani 2017-07-25 10:37:14 +02:00
parent 20c55bf5a6
commit c8d0a0fcf7
2 changed files with 13 additions and 3 deletions

View file

@ -1150,7 +1150,8 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_wired_class)
* Beside explicitly specifing a MAC address, the special values "preserve", "permanent",
* "random" and "stable" are supported.
* "preserve" means not to touch the MAC address on activation.
* "permanent" means to use the permanent hardware address of the device.
* "permanent" means to use the permanent hardware address if the device
* has one (otherwise this is treated as "preserve").
* "random" creates a random MAC address on each connect.
* "stable" creates a hashed MAC address based on connection.stable-id and a
* machine dependent key.

View file

@ -13475,8 +13475,17 @@ _hw_addr_get_cloned (NMDevice *self, NMConnection *connection, gboolean is_wifi,
}
if (nm_streq (addr, NM_CLONED_MAC_PERMANENT)) {
addr = nm_device_get_permanent_hw_address (self);
if (!addr) {
gboolean is_fake;
addr = nm_device_get_permanent_hw_address_full (self, TRUE, &is_fake);
if (is_fake) {
/* Preserve the current address if the permanent address if fake */
NM_SET_OUT (preserve, TRUE);
NM_SET_OUT (hwaddr, NULL);
NM_SET_OUT (hwaddr_type, HW_ADDR_TYPE_UNSET);
NM_SET_OUT (hwaddr_detail, g_steal_pointer (&addr_setting_free) ?: g_strdup (addr_setting));
return TRUE;
} else if (!addr) {
g_set_error_literal (error,
NM_DEVICE_ERROR,
NM_DEVICE_ERROR_FAILED,