• Dan Williams's avatar
    core: fix deactivation of assumed connections on device removal (bgo #729833) · 4b6f0d50
    Dan Williams authored
    The following procedure leaves an NMActiveConnection around for a deactivated
    device, which causes errors in libnm-glib clients when they cannot create the
    GObject for the non-existent device of the AC.
    1) allow a device which can assume connections to be activated
    2) stop NM, which should leave the device's IP configuration up
    3) start NM and allow it to assume the device's existing connection
    4) remove the device, either by unplugging it or 'rmmod'
    The device is removed by nm-manager.c::remove_device(), but the device object
    is not moved to UNMANAGED state, leaving the NMActiveConnection completely
    unaware the device has gone away.
    The nm-manager.c::remove_device() code did not correctly handle moving a
    forcibly removed (eg, by unplugging or 'ip link del' or 'rmmod') device to
    the UNMANAGED state when the device was active with an assumed connection.
    To fix this, make the conditions when the device should be deactivated
    on removal much more explicit.
    A device should be deactivated on removal if:
    1) it is forcibly removed, eg by the kernel network interface being
    removed due to 'ip link del' or hotplugging, or internally by NM due
    to a parent WWAN interface taking priority over a WWAN ethernet interface
    2) if the device cannot assume connections, in which case NetworkManager
    must have activated the device and since we cannot assume the connection
    on restart, we should deactivate it
    3) if the device is not activated, to ensure that its IPv6 parameters
    and other things get reset to the pre-NetworkManager values
nm-manager.c 169 KB