manager: set interface as removed when the link disappears

Set the device state as removed when the link disappears, so that in
the call to unrealize() when the device is unmanaged we also perform a
cleanup of it and especially, we terminate any DHCP client instances
running on the device.

If we keep DHCP clients running, we can hit assertions later when we
start another instance on the same interface, because we kill the old
dhclient from the pidfile, and the g_child_watch_add() done by the
first client instance is not able to waitpid() it, complaining with:

  GChildWatchSource: Exit status of a child process was requested but
  ECHILD was received by waitpid(). Most likely the process is
  ignoring SIGCHLD, or some other thread is invoking waitpid() with a
  nonpositive first argument; either behavior can break applications
  that use g_child_watch_add()/g_spawn_sync() either directly or
  indirectly.

https://bugzilla.redhat.com/show_bug.cgi?id=1436602
(cherry picked from commit df537d2eac)
This commit is contained in:
Beniamino Galvani
2017-04-13 18:28:08 +02:00
parent 297ad945f5
commit a39fac2248

View File

@@ -2355,6 +2355,7 @@ _platform_link_cb_idle (PlatformLinkCbData *data)
device = nm_manager_get_device_by_ifindex (self, data->ifindex);
if (device) {
if (nm_device_is_software (device)) {
nm_device_sys_iface_state_set (device, NM_DEVICE_SYS_IFACE_STATE_REMOVED);
/* Our software devices stick around until their connection is removed */
if (!nm_device_unrealize (device, FALSE, &error)) {
_LOGW (LOGD_DEVICE, "(%s): failed to unrealize: %s",