From eb69d3f1c45d5b955cd10c6dcb28fee3d7a60d8e Mon Sep 17 00:00:00 2001 From: Erik Karlsson Date: Tue, 19 Sep 2023 13:37:59 +0200 Subject: [PATCH] interface: do not release device on link down 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 --- interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface.c b/interface.c index a18e872..151dc9d 100644 --- a/interface.c +++ b/interface.c @@ -774,7 +774,7 @@ interface_proto_event_cb(struct interface_proto_state *state, enum interface_pro 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); -- 2.30.2