X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=interface.c;h=18322d7e4ad6b961184cf21b89fba9d4ad5aa9e6;hp=49fc830cc065c94ba79c85c10fdac009b9a0a9a1;hb=65963f0ad2207b55dc7715015839b59b58855a67;hpb=266d92dd83bd5bfe520f3e2838794bf9bb827c07;ds=sidebyside diff --git a/interface.c b/interface.c index 49fc830..18322d7 100644 --- a/interface.c +++ b/interface.c @@ -43,6 +43,7 @@ enum { IFACE_ATTR_IP4TABLE, IFACE_ATTR_IP6TABLE, IFACE_ATTR_IP6CLASS, + IFACE_ATTR_DELEGATE, IFACE_ATTR_MAX }; @@ -61,6 +62,7 @@ static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = { [IFACE_ATTR_IP4TABLE] = { .name = "ip4table", .type = BLOBMSG_TYPE_STRING }, [IFACE_ATTR_IP6TABLE] = { .name = "ip6table", .type = BLOBMSG_TYPE_STRING }, [IFACE_ATTR_IP6CLASS] = { .name = "ip6class", .type = BLOBMSG_TYPE_ARRAY }, + [IFACE_ATTR_DELEGATE] = { .name = "delegate", .type = BLOBMSG_TYPE_BOOL }, }; static const struct uci_blob_param_info iface_attr_info[IFACE_ATTR_MAX] = { @@ -151,7 +153,7 @@ interface_add_data(struct interface *iface, const struct blob_attr *data) n = calloc(1, sizeof(*n) + blob_pad_len(data)); memcpy(n->data, data, blob_pad_len(data)); - n->node.key = blobmsg_name(data); + n->node.key = blobmsg_name(n->data); o = avl_find_element(&iface->data, n->node.key, o, node); if (o) @@ -378,6 +380,7 @@ interface_alias_cb(struct interface_user *dep, struct interface *iface, enum int interface_remove_user(dep); break; case IFEV_RELOAD: + case IFEV_UPDATE: break; } } @@ -483,8 +486,10 @@ interface_proto_cb(struct interface_proto_state *state, enum interface_proto_eve switch (ev) { case IFPEV_UP: - if (iface->state != IFS_SETUP) + if (iface->state != IFS_SETUP) { + interface_event(iface, IFEV_UPDATE); return; + } interface_ip_set_enabled(&iface->config_ip, true); system_flush_routes(); @@ -533,7 +538,7 @@ void interface_set_proto_state(struct interface *iface, struct interface_proto_s void interface_init(struct interface *iface, const char *name, - struct blob_attr *config, bool dynamic) + struct blob_attr *config) { struct blob_attr *tb[IFACE_ATTR_MAX]; struct blob_attr *cur; @@ -602,11 +607,15 @@ interface_init(struct interface *iface, const char *name, DPRINTF("Failed to resolve routing table: %s\n", (char *) blobmsg_data(cur)); } + iface->proto_ip.no_delegation = !blobmsg_get_bool_default(tb[IFACE_ATTR_DELEGATE], true); + iface->config_autostart = iface->autostart; - iface->dynamic = dynamic; +} - if (iface->dynamic) - iface->node.version = -1; // Don't delete on reload +void interface_set_dynamic(struct interface *iface) +{ + iface->dynamic = true; + iface->node.version = -1; // Don't delete on reload } static bool __interface_add(struct interface *iface, struct blob_attr *config, bool alias)