summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2014-12-01 16:53:12 +0100
committerLubomir Rintel <lkundrak@v3.sk>2014-12-01 17:53:36 +0100
commit7793c1c4c816505df8dc2dcdf5458a1f8b525b82 (patch)
tree4072b15fc4af8498c439db2dbbc76159889ca1fa
parentc3246d962dfac87e6eb4ced023d900744969cf6f (diff)
downloadNetworkManager-lr/device-rm.tar.gz
device: Deal with links that vanish during initializationlr/device-rm
nm_device_get_hw_address() may return NULL and nm_platform_link_get_type may return NM_LINK_TYPE_NONE. While it might be a good idea to check for such cases at the init time it seems easier to just ignore it and prevent blowing up in subsequent deactivation. A quick test case: # while :; do ip link add moo0 type veth peer moo1; ip link del moo0 ; done Yields: NetworkManager:ERROR:devices/nm-device-ethernet.c:268:constructor: assertion failed: (link_type == NM_LINK_TYPE_ETHERNET || link_type == NM_LINK_TYPE_VETH) nm_device_set_hw_addr: assertion 'addr != NULL' failed
-rw-r--r--src/devices/nm-device-ethernet.c7
-rw-r--r--src/devices/nm-device-vlan.c3
-rw-r--r--src/devices/wifi/nm-device-wifi.c3
3 files changed, 9 insertions, 4 deletions
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index f103c915e3..ac408d3d9f 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -265,7 +265,9 @@ constructor (GType type,
int ifindex = nm_device_get_ifindex (NM_DEVICE (object));
NMLinkType link_type = nm_platform_link_get_type (ifindex);
- g_assert (link_type == NM_LINK_TYPE_ETHERNET || link_type == NM_LINK_TYPE_VETH);
+ g_assert ( link_type == NM_LINK_TYPE_ETHERNET
+ || link_type == NM_LINK_TYPE_VETH
+ || link_type == NM_LINK_TYPE_NONE);
#endif
/* s390 stuff */
@@ -1389,7 +1391,8 @@ deactivate (NMDevice *device)
NM_DEVICE_ETHERNET_GET_PRIVATE (device)->last_pppoe_time = nm_utils_get_monotonic_timestamp_s ();
/* Reset MAC address back to initial address */
- nm_device_set_hw_addr (device, priv->initial_hw_addr, "reset", LOGD_ETHER);
+ if (priv->initial_hw_addr)
+ nm_device_set_hw_addr (device, priv->initial_hw_addr, "reset", LOGD_ETHER);
}
static gboolean
diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c
index a245a434b2..c69bcdedde 100644
--- a/src/devices/nm-device-vlan.c
+++ b/src/devices/nm-device-vlan.c
@@ -390,7 +390,8 @@ deactivate (NMDevice *device)
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self);
/* Reset MAC address back to initial address */
- nm_device_set_hw_addr (device, priv->initial_hw_addr, "reset", LOGD_VLAN);
+ if (priv->initial_hw_addr)
+ nm_device_set_hw_addr (device, priv->initial_hw_addr, "reset", LOGD_VLAN);
}
/******************************************************************/
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index 440f1225dd..dd7754b33e 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -741,7 +741,8 @@ deactivate (NMDevice *device)
nm_platform_wifi_indicate_addressing_running (ifindex, FALSE);
/* Reset MAC address back to initial address */
- nm_device_set_hw_addr (device, priv->initial_hw_addr, "reset", LOGD_WIFI);
+ if (priv->initial_hw_addr)
+ nm_device_set_hw_addr (device, priv->initial_hw_addr, "reset", LOGD_WIFI);
/* Ensure we're in infrastructure mode after deactivation; some devices
* (usually older ones) don't scan well in adhoc mode.