{
struct interface_error *error;
int i, len = 0;
- int *datalen;
+ int *datalen = NULL;
char *dest;
if (n_data) {
static void
mark_interface_down(struct interface *iface)
{
+ interface_del_ctx_addr(iface, NULL);
release_device(iface->main_dev.dev);
iface->state = IFS_DOWN;
}
return ret;
iface->state = IFS_SETUP;
- ret = iface->proto->handler(iface->proto, PROTO_CMD_SETUP, false);
+ ret = interface_proto_event(iface->proto, PROTO_CMD_SETUP, false);
if (ret) {
mark_interface_down(iface);
return ret;
iface->state = IFS_TEARDOWN;
interface_event(iface, IFEV_DOWN);
- iface->proto->handler(iface->proto, PROTO_CMD_TEARDOWN, force);
- release_device(iface->main_dev.dev);
+ interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, force);
}
static void
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);
void interface_set_proto_state(struct interface *iface, struct interface_proto_state *state)
{
if (iface->proto) {
- iface->proto->handler(iface->proto, PROTO_CMD_TEARDOWN, true);
+ interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, true);
iface->proto->free(iface->proto);
iface->proto = NULL;
}
}
struct interface *
-alloc_interface(const char *name)
+alloc_interface(const char *name, struct uci_section *s)
{
struct interface *iface;
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);
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);
+ }
+}