[LEDE-DEV] [PATCH netifd] interface: fix "ifup-failed" hotplug event handling

Martin Schiller ms at dev.tdt.de
Mon Apr 9 21:21:39 PDT 2018


The ifup-failed event should only be triggered when the former
interface state is IFS_SETUP.

Otherwise, there will also be an ifup-failed event in the
IFS_TEARDOWN stateif you do an manual ifdown <IFC>.

Signed-off-by: Martin Schiller <ms at dev.tdt.de>
---
 interface.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/interface.c b/interface.c
index 900a523..2a23984 100644
--- a/interface.c
+++ b/interface.c
@@ -267,10 +267,16 @@ mark_interface_down(struct interface *iface)
 
 	iface->link_up_event = false;
 	iface->state = IFS_DOWN;
-	if (state == IFS_UP)
+	switch (state) {
+	case IFS_UP:
 		interface_event(iface, IFEV_DOWN);
-	else
+		break;
+	case IFS_SETUP:
 		interface_event(iface, IFEV_UP_FAILED);
+		break;
+	default:
+		break;
+	}
 	interface_ip_set_enabled(&iface->config_ip, false);
 	interface_ip_set_enabled(&iface->proto_ip, false);
 	interface_ip_flush(&iface->proto_ip);
-- 
2.11.0




More information about the Lede-dev mailing list