diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2014-12-01 16:53:12 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2014-12-02 11:44:49 +0100 |
commit | e257744f9ed397b06cbcc2944527221a1a09d92f (patch) | |
tree | d980157601c1eb49af69bf33ad840a7a3558f2b2 | |
parent | 20566c76de0d18162af020852ae1e2055addcfff (diff) | |
download | NetworkManager-e257744f9ed397b06cbcc2944527221a1a09d92f.tar.gz |
device: Deal with links that vanish during initialization
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
https://bugzilla.gnome.org/show_bug.cgi?id=740992
-rw-r--r-- | src/devices/nm-device-ethernet.c | 7 | ||||
-rw-r--r-- | src/devices/nm-device-vlan.c | 3 | ||||
-rw-r--r-- | src/devices/wifi/nm-device-wifi.c | 3 |
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. |