handle the interface autostart option
[project/netifd.git] / interface.c
index 2d62bb0..387d349 100644 (file)
@@ -89,6 +89,7 @@ interface_event(struct interface *iface, enum interface_event ev)
 static void
 mark_interface_down(struct interface *iface)
 {
+       interface_del_all_routes(iface);
        interface_del_ctx_addr(iface, NULL);
        device_release(&iface->main_dev);
        iface->state = IFS_DOWN;
@@ -237,6 +238,11 @@ interface_alloc(const char *name, struct blob_attr *attr)
                        device_add_user(&iface->main_dev, dev);
        }
 
+       if ((cur = tb[IFACE_ATTR_AUTO]))
+               iface->autostart = blobmsg_get_bool(cur);
+       else
+               iface->autostart = true;
+
        netifd_ubus_add_interface(iface);
        config_set_state(&iface->config, attr);