prevent autostart of interfaces during config init
authorFelix Fietkau <nbd@openwrt.org>
Tue, 5 Apr 2011 00:35:29 +0000 (02:35 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 5 Apr 2011 00:35:29 +0000 (02:35 +0200)
config.c
interface.c
interface.h
netifd.h

index 66cee8463b812fd8d82c5b141cac2700331ad515..51e355cefd35721d2664082cbe0cfb7bcfc7533f 100644 (file)
--- a/config.c
+++ b/config.c
@@ -6,6 +6,7 @@
 #include "interface.h"
 
 struct uci_context *uci_ctx;
+bool config_init = false;
 
 static void config_parse_interface(struct uci_section *s)
 {
@@ -40,6 +41,7 @@ void config_init_interfaces(const char *name)
                return;
        }
 
+       config_init = true;
        uci_foreach_element(&p->sections, e) {
                struct uci_section *s = uci_to_section(e);
 
@@ -49,4 +51,7 @@ void config_init_interfaces(const char *name)
                if (!strcmp(s->type, "interface"))
                        config_parse_interface(s);
        }
+       config_init = false;
+
+       start_pending_interfaces();
 }
index 823a06f16dab02bb88315ef21f8e7064ade9ed8d..06a36ed7bbd5c80fb5d63419fff4301152f12026 100644 (file)
@@ -130,7 +130,7 @@ interface_cb(struct device_user *dep, enum device_event ev)
        iface->active = new_state;
 
        if (new_state) {
-               if (iface->autostart)
+               if (iface->autostart && !config_init)
                        set_interface_up(iface);
        } else
                __set_interface_down(iface, true);
@@ -277,3 +277,14 @@ set_interface_down(struct interface *iface)
 
        return 0;
 }
+
+void
+start_pending_interfaces(void)
+{
+       struct interface *iface;
+
+       list_for_each_entry(iface, &interfaces, list) {
+               if (iface->active && iface->autostart)
+                       set_interface_up(iface);
+       }
+}
index 6bd8761ee7d2fdb36f14b3137bbf550d78091c77..92bae5ab170cd3a8b92df49e717df08dcae0c8ef 100644 (file)
@@ -69,4 +69,6 @@ void interface_add_error(struct interface *iface, const char *subsystem,
 
 int interface_attach_bridge(struct interface *iface, struct uci_section *s);
 
+void start_pending_interfaces(void);
+
 #endif
index 17b839b722fb133abd3963ca20856a6e98012d88..160ea3bccd7636c8a0de49466c5c33333d39c614 100644 (file)
--- a/netifd.h
+++ b/netifd.h
@@ -23,6 +23,7 @@ struct device;
 struct interface;
 
 extern struct uci_context *uci_ctx;
+extern bool config_init;
 
 void config_init_interfaces(const char *name);