interface: call proto teardown before marking the interface as down
[project/netifd.git] / interface.c
index 8627d97..35f20b0 100644 (file)
@@ -272,11 +272,14 @@ interface_check_state(struct interface *iface)
        switch (iface->state) {
        case IFS_UP:
                if (!iface->enabled || !link_state) {
-                       mark_interface_down(iface);
                        interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, false);
+                       mark_interface_down(iface);
                }
                break;
        case IFS_DOWN:
+               if (!iface->available)
+                       return;
+
                if (iface->autostart && iface->enabled && link_state && !config_init)
                        __interface_set_up(iface);
                break;
@@ -527,6 +530,7 @@ interface_cleanup(struct interface *iface)
 {
        struct interface_user *dep, *tmp;
 
+       uloop_timeout_cancel(&iface->remove_timer);
        device_remove_user(&iface->ext_dev);
 
        if (iface->parent_iface.iface)