X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=proto-shell.c;h=ea15fd913b983ac3a5fc578fb1540d81a7bee7c4;hp=b5d436ad7b743f501936c8462cd9a2310feacfa8;hb=46d52638f04c471a0e86d07ccae6a188f1a05ef5;hpb=b7d1c27b752df3e6c5dfe6a5b789d6cb0c87d0f6 diff --git a/proto-shell.c b/proto-shell.c index b5d436a..ea15fd9 100644 --- a/proto-shell.c +++ b/proto-shell.c @@ -222,6 +222,16 @@ proto_shell_parse_route_list(struct interface *iface, struct blob_attr *attr, } } +static void +proto_shell_parse_data(struct interface *iface, struct blob_attr *attr) +{ + struct blob_attr *cur; + int rem; + + blobmsg_for_each_attr(cur, attr, rem) + interface_add_data(iface, cur); +} + static struct device * proto_shell_create_tunnel(const char *name, struct blob_attr *attr) { @@ -250,6 +260,8 @@ enum { NOTIFY_ROUTES, NOTIFY_ROUTES6, NOTIFY_TUNNEL, + NOTIFY_DATA, + NOTIFY_KEEP, __NOTIFY_LAST }; @@ -266,6 +278,8 @@ static const struct blobmsg_policy notify_attr[__NOTIFY_LAST] = { [NOTIFY_ROUTES] = { .name = "routes", .type = BLOBMSG_TYPE_ARRAY }, [NOTIFY_ROUTES6] = { .name = "routes6", .type = BLOBMSG_TYPE_ARRAY }, [NOTIFY_TUNNEL] = { .name = "tunnel", .type = BLOBMSG_TYPE_TABLE }, + [NOTIFY_DATA] = { .name = "data", .type = BLOBMSG_TYPE_TABLE }, + [NOTIFY_KEEP] = { .name = "keep", .type = BLOBMSG_TYPE_BOOL }, }; static int @@ -277,6 +291,7 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr *data, const char *devname; int dev_create = 1; bool addr_ext = false; + bool keep = false; bool up; if (!tb[NOTIFY_LINK_UP]) @@ -288,6 +303,9 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr *data, return 0; } + if ((cur = tb[NOTIFY_KEEP]) != NULL) + keep = blobmsg_get_bool(cur); + if ((cur = tb[NOTIFY_ADDR_EXT]) != NULL) { addr_ext = blobmsg_get_bool(cur); if (addr_ext) @@ -297,7 +315,8 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr *data, if (!tb[NOTIFY_IFNAME]) { if (!iface->main_dev.dev) return UBUS_STATUS_INVALID_ARGUMENT; - } else { + } else if (!keep || iface->state != IFS_UP) { + keep = false; devname = blobmsg_data(tb[NOTIFY_IFNAME]); if (tb[NOTIFY_TUNNEL]) { dev = proto_shell_create_tunnel(devname, @@ -314,7 +333,9 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr *data, device_claim(&iface->l3_dev); } - interface_update_start(iface); + if (!keep) + interface_update_start(iface); + proto_apply_ip_settings(iface, data, addr_ext); if ((cur = tb[NOTIFY_ROUTES]) != NULL) @@ -325,7 +346,12 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr *data, interface_update_complete(state->proto.iface); - state->proto.proto_event(&state->proto, IFPEV_UP); + if (!keep) + state->proto.proto_event(&state->proto, IFPEV_UP); + state->sm = S_IDLE; + + if ((cur = tb[NOTIFY_DATA])) + proto_shell_parse_data(state->proto.iface, cur); return 0; }