interface: fix "ifup-failed" hotplug event handling
authorMartin Schiller <ms@dev.tdt.de>
Tue, 10 Apr 2018 04:21:39 +0000 (06:21 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Tue, 10 Apr 2018 19:10:18 +0000 (21:10 +0200)
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@dev.tdt.de>
interface.c

index 900a523dc4252280277ca1cf559b9111929e219b..2a23984922a10c34fe237a837552fb023ce24d23 100644 (file)
@@ -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);