diff --git a/man/NetworkManager.conf.xml b/man/NetworkManager.conf.xml
index 9f5906efed..b70438ded3 100644
--- a/man/NetworkManager.conf.xml
+++ b/man/NetworkManager.conf.xml
@@ -1042,7 +1042,7 @@ enable=nm-version-min:1.3,nm-version-min:1.2.6,nm-version-min:1.0.16
HWADDR
- Match the MAC address of the device. Globbing is not supported
+ Match the permanent MAC address of the device. Globbing is not supported
interface-name:IFNAME
@@ -1057,7 +1057,7 @@ enable=nm-version-min:1.3,nm-version-min:1.2.6,nm-version-min:1.0.16
mac:HWADDR
- Match the MAC address of the device. Globbing is not supported
+ Match the permanent MAC address of the device. Globbing is not supported
s390-subchannels:HWADDR
diff --git a/src/devices/bluetooth/nm-device-bt.c b/src/devices/bluetooth/nm-device-bt.c
index 8f3772c69b..67ae15bc82 100644
--- a/src/devices/bluetooth/nm-device-bt.c
+++ b/src/devices/bluetooth/nm-device-bt.c
@@ -1002,7 +1002,7 @@ nm_device_bt_new (NMBluezDevice *bt_device,
NM_DEVICE_UDI, udi,
NM_DEVICE_IFACE, bdaddr,
NM_DEVICE_DRIVER, "bluez",
- NM_DEVICE_HW_ADDRESS, bdaddr,
+ NM_DEVICE_PERM_HW_ADDRESS, bdaddr,
NM_DEVICE_BT_DEVICE, bt_device,
NM_DEVICE_BT_NAME, name,
NM_DEVICE_BT_CAPABILITIES, capabilities,
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 0b4432ecfd..e9e1e88193 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -11632,9 +11632,9 @@ nm_device_spec_match_list (NMDevice *self, const GSList *specs)
static NMMatchSpecMatchType
spec_match_list (NMDevice *self, const GSList *specs)
{
- NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMMatchSpecMatchType matched = NM_MATCH_SPEC_NO_MATCH, m;
const GSList *iter;
+ const char *hw_addr_perm;
for (iter = specs; iter; iter = g_slist_next (iter)) {
if (!strcmp ((const char *) iter->data, "*")) {
@@ -11642,8 +11642,10 @@ spec_match_list (NMDevice *self, const GSList *specs)
break;
}
}
- if (priv->hw_addr_len && priv->hw_addr) {
- m = nm_match_spec_hwaddr (specs, priv->hw_addr);
+
+ hw_addr_perm = nm_device_get_permanent_hw_address (self, FALSE);
+ if (hw_addr_perm) {
+ m = nm_match_spec_hwaddr (specs, hw_addr_perm);
matched = MAX (matched, m);
}
if (matched != NM_MATCH_SPEC_NEG_MATCH) {
@@ -11717,7 +11719,6 @@ constructor (GType type,
NMDevice *self;
NMDevicePrivate *priv;
const NMPlatformLink *pllink;
- guint count;
klass = G_OBJECT_CLASS (nm_device_parent_class);
object = klass->constructor (type, n_construct_params, construct_params);
@@ -11737,15 +11738,15 @@ constructor (GType type,
}
}
- if (priv->hw_addr) {
- count = _nm_utils_hwaddr_length (priv->hw_addr);
- if (count <= 0) {
- _LOGW (LOGD_DEVICE, "hw-addr: could not parse hw-address '%s'", priv->hw_addr);
- g_clear_pointer (&priv->hw_addr, g_free);
- } else {
- priv->hw_addr_len = count;
- _LOGT (LOGD_DEVICE, "hw-addr: set current hw-address '%s'", priv->hw_addr);
+ if (priv->hw_addr_perm) {
+ priv->hw_addr_len = _nm_utils_hwaddr_length (priv->hw_addr_perm);
+ if (!priv->hw_addr_len) {
+ g_clear_pointer (&priv->hw_addr_perm, g_free);
+ g_return_val_if_reached (object);
}
+
+ priv->hw_addr = g_strdup (priv->hw_addr_perm);
+ _LOGT (LOGD_DEVICE, "hw-addr: has permanent hw-address '%s'", priv->hw_addr_perm);
}
return object;
@@ -11982,9 +11983,9 @@ set_property (GObject *object, guint prop_id,
case PROP_IS_MASTER:
priv->is_master = g_value_get_boolean (value);
break;
- case PROP_HW_ADDRESS:
+ case PROP_PERM_HW_ADDRESS:
/* construct only */
- priv->hw_addr = g_value_dup_string (value);
+ priv->hw_addr_perm = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -12354,12 +12355,12 @@ nm_device_class_init (NMDeviceClass *klass)
obj_properties[PROP_HW_ADDRESS] =
g_param_spec_string (NM_DEVICE_HW_ADDRESS, "", "",
NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS);
obj_properties[PROP_PERM_HW_ADDRESS] =
g_param_spec_string (NM_DEVICE_PERM_HW_ADDRESS, "", "",
NULL,
- G_PARAM_READABLE |
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
obj_properties[PROP_HAS_PENDING_ACTION] =
g_param_spec_boolean (NM_DEVICE_HAS_PENDING_ACTION, "", "",
diff --git a/src/nm-config.c b/src/nm-config.c
index eb827c33ae..4bc4f48340 100644
--- a/src/nm-config.c
+++ b/src/nm-config.c
@@ -399,7 +399,9 @@ nm_config_set_no_auto_default_for_device (NMConfig *self, NMDevice *device)
priv = NM_CONFIG_GET_PRIVATE (self);
- hw_address = nm_device_get_hw_address (device);
+ hw_address = nm_device_get_permanent_hw_address (device, FALSE);
+ if (!hw_address)
+ return;
no_auto_default_current = nm_config_data_get_no_auto_default (priv->config_data);
diff --git a/src/tests/config/nm-test-device.c b/src/tests/config/nm-test-device.c
index be67646fb4..1ae964eef2 100644
--- a/src/tests/config/nm-test-device.c
+++ b/src/tests/config/nm-test-device.c
@@ -73,6 +73,6 @@ nm_test_device_new (const char *hwaddr)
{
return g_object_new (NM_TYPE_TEST_DEVICE,
NM_DEVICE_IFACE, "dummy",
- NM_DEVICE_HW_ADDRESS, hwaddr,
+ NM_DEVICE_PERM_HW_ADDRESS, hwaddr,
NULL);
}