On IFPEV_DOWN, do not release the main device if the interface is
intended to be brought back up again by interface_handle_config_change
and there is no configuration change. This avoids releasing the device
and then claiming it again when link is lost.
Releasing and then claiming the device can, if the driver is
configured to power the PHY down when IFF_UP is cleared, cause the PHY
to be power cycled. This can in combination with glitchy hardware
and/or drivers where it takes a few seconds for the link to stabilize
after the PHY has been powered up cause a loop where loss of link
causes netifd to power cycle the PHY and when the PHY comes back up
the link glitches and the cycle repeats.
Signed-off-by: Erik Karlsson <erik.karlsson@genexis.eu>
netifd_log_message(L_NOTICE, "Interface '%s' is now down\n", iface->name);
mark_interface_down(iface);
interface_write_resolv_conf(iface->jail);
- if (iface->main_dev.dev)
+ if (iface->main_dev.dev && !(iface->config_state == IFC_NORMAL && iface->autostart && iface->available))
device_release(&iface->main_dev);
if (iface->l3_dev.dev)
device_remove_user(&iface->l3_dev);