+ }
+
+ interface_ip_update_start(state->proto.iface);
+
+ if ((cur = tb[NOTIFY_ADDR_EXT]) != NULL)
+ addr_ext = blobmsg_get_bool(cur);
+
+ if ((cur = tb[NOTIFY_IPADDR]) != NULL)
+ proto_shell_parse_addr_list(state->proto.iface, cur, false, addr_ext);
+
+ if ((cur = tb[NOTIFY_IP6ADDR]) != NULL)
+ proto_shell_parse_addr_list(state->proto.iface, cur, true, addr_ext);
+
+ if ((cur = tb[NOTIFY_ROUTES]) != NULL)
+ proto_shell_parse_route_list(state->proto.iface, cur, false);
+
+ if ((cur = tb[NOTIFY_ROUTES6]) != NULL)
+ proto_shell_parse_route_list(state->proto.iface, cur, true);
+
+ if ((cur = tb[NOTIFY_DNS]) != NULL)
+ interface_add_dns_server_list(state->proto.iface, cur);
+
+ if ((cur = tb[NOTIFY_DNS_SEARCH]) != NULL)
+ interface_add_dns_search_list(state->proto.iface, cur);
+
+ interface_ip_update_complete(state->proto.iface);
+
+ state->proto.proto_event(&state->proto, IFPEV_UP);
+
+ return 0;
+}
+
+static bool
+fill_string_list(struct blob_attr *attr, char **argv, int max)
+{
+ struct blob_attr *cur;
+ int argc = 0;
+ int rem;
+
+ if (!attr)
+ goto out;
+
+ blobmsg_for_each_attr(cur, attr, rem) {
+ if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING)
+ return false;
+
+ if (!blobmsg_check_attr(cur, NULL))
+ return false;
+
+ argv[argc++] = blobmsg_data(cur);
+ if (argc == max - 1)
+ return false;
+ }
+
+out:
+ argv[argc] = NULL;
+ return true;
+}
+
+static int
+proto_shell_run_command(struct proto_shell_state *state, struct blob_attr **tb)
+{
+ char *argv[64];
+ char *env[32];
+
+ if (!tb[NOTIFY_COMMAND])
+ goto error;
+
+ if (!fill_string_list(tb[NOTIFY_COMMAND], argv, ARRAY_SIZE(argv)))
+ goto error;
+
+ if (!fill_string_list(tb[NOTIFY_ENV], env, ARRAY_SIZE(env)))
+ goto error;
+
+ start_process((const char **) argv, (char **) env, &state->proto_task);
+
+ return 0;
+
+error:
+ return UBUS_STATUS_INVALID_ARGUMENT;
+}
+
+static int
+proto_shell_kill_command(struct proto_shell_state *state, struct blob_attr **tb)
+{
+ unsigned int signal = ~0;
+
+ if (tb[NOTIFY_SIGNAL])
+ signal = blobmsg_get_u32(tb[NOTIFY_SIGNAL]);
+
+ if (signal > 31)
+ signal = SIGTERM;
+
+ if (state->proto_task.pending) {
+ kill(state->proto_task.pid, signal);
+ state->teardown_wait_task = true;