netifd: Set interface state in teardown state before launching an interface event
authorHans Dedecker <dedeckeh@gmail.com>
Mon, 10 Mar 2014 15:27:53 +0000 (16:27 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 11 Mar 2014 09:24:21 +0000 (10:24 +0100)
Interface state needs to be set in teardown state before launching an interface event otherwise the up state will be reported as true in the ubus interface notify message

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
interface.c

index 43ba773..39460e4 100644 (file)
@@ -222,11 +222,14 @@ mark_interface_down(struct interface *iface)
 void
 __interface_set_down(struct interface *iface, bool force)
 {
-       switch (iface->state) {
+       enum interface_state state = iface->state;
+       switch (state) {
        case IFS_UP:
-               interface_event(iface, IFEV_DOWN);
        case IFS_SETUP:
                iface->state = IFS_TEARDOWN;
+               if (state == IFS_UP)
+                       interface_event(iface, IFEV_DOWN);
+
                interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, force);
                if (force)
                        interface_flush_state(iface);