[PATCH netifd] interface: do not release device on link down
Erik Karlsson
erik.r.karlsson at gmail.com
Tue Sep 19 04:37:59 PDT 2023
From: Erik Karlsson <erik.karlsson at genexis.eu>
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 at genexis.eu>
---
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.25.1
More information about the openwrt-devel
mailing list