X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=interface.c;h=0a53151c5a33959430c07ef3f1e5ef330e100283;hp=823a06f16dab02bb88315ef21f8e7064ade9ed8d;hb=85218c601b0f5895f9025910643761930c02eb1a;hpb=d6bcf552c169c1d0fd317f9654b8c81c3d838362 diff --git a/interface.c b/interface.c index 823a06f..0a53151 100644 --- a/interface.c +++ b/interface.c @@ -26,7 +26,7 @@ void interface_add_error(struct interface *iface, const char *subsystem, { struct interface_error *error; int i, len = 0; - int *datalen; + int *datalen = NULL; char *dest; if (n_data) { @@ -64,6 +64,7 @@ interface_event(struct interface *iface, enum interface_event ev) static void mark_interface_down(struct interface *iface) { + interface_del_ctx_addr(iface, NULL); release_device(iface->main_dev.dev); iface->state = IFS_DOWN; } @@ -130,7 +131,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); @@ -175,7 +176,7 @@ void interface_set_proto_state(struct interface *iface, struct interface_proto_s } struct interface * -alloc_interface(const char *name) +alloc_interface(const char *name, struct uci_section *s) { struct interface *iface; @@ -184,18 +185,15 @@ alloc_interface(const char *name) return iface; iface = calloc(1, sizeof(*iface)); - - interface_set_proto_state(iface, get_default_proto()); - if (!iface->proto) { - free(iface); - return NULL; - } - iface->main_dev.cb = interface_cb; iface->l3_iface = &iface->main_dev; strncpy(iface->name, name, sizeof(iface->name) - 1); list_add(&iface->list, &interfaces); INIT_LIST_HEAD(&iface->errors); + INIT_LIST_HEAD(&iface->address); + INIT_LIST_HEAD(&iface->routes); + + proto_attach_interface(iface, s); netifd_ubus_add_interface(iface); @@ -277,3 +275,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); + } +}