summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2013-11-06 20:20:58 -0600
committerDan Williams <dcbw@redhat.com>2013-11-08 16:46:44 -0600
commit8bb9a65c917992b5e5a0e110ca4a3982e6d1f6dd (patch)
tree382851d49d43f42969986d132166a44dceea30f9
parent24995b2c96731d16c56de30cd8dfbcb78a484720 (diff)
downloadNetworkManager-8bb9a65c917992b5e5a0e110ca4a3982e6d1f6dd.tar.gz
ethernet: handle cloned/permanent MAC when updating connection
-rw-r--r--src/devices/nm-device-ethernet.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index 83f27b86b3..7b1c248eb8 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -1238,19 +1238,38 @@ spec_match_list (NMDevice *device, const GSList *specs)
static void
update_connection (NMDevice *device, NMConnection *connection)
{
+ NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device);
NMSettingWired *s_wired = nm_connection_get_setting_wired (connection);
guint maclen;
gconstpointer mac = nm_device_get_hw_address (device, &maclen);
+ static const guint8 null_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
+ const char *mac_prop = NM_SETTING_WIRED_MAC_ADDRESS;
+ GByteArray *array;
if (!s_wired) {
s_wired = (NMSettingWired *) nm_setting_wired_new ();
nm_connection_add_setting (connection, (NMSetting *) s_wired);
}
- if (mac && maclen == 6) {
- GBytes *address = g_bytes_new (mac, maclen);
+ /* If the device reports a permanent address, use that for the MAC address
+ * and the current MAC, if different, is the cloned MAC.
+ */
+ if (priv->perm_hw_addr && memcmp (priv->perm_hw_addr, null_mac, ETH_ALEN)) {
+ array = g_byte_array_sized_new (ETH_ALEN);
+ g_byte_array_append (array, priv->perm_hw_addr, ETH_ALEN);
+ g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, array, NULL);
+ g_byte_array_unref (array);
+
+ mac_prop = NULL;
+ if (mac && memcmp (priv->perm_hw_addr, mac, ETH_ALEN))
+ mac_prop = NM_SETTING_WIRED_CLONED_MAC_ADDRESS;
+ }
- g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, address, NULL);
+ if (mac_prop && mac && maclen == ETH_ALEN) {
+ array = g_byte_array_sized_new (ETH_ALEN);
+ g_byte_array_append (array, (guint8 *) mac, maclen);
+ g_object_set (s_wired, mac_prop, array, NULL);
+ g_byte_array_unref (array);
}
/* We don't set the MTU as we don't know whether it was set explicitly */