From: Felix Fietkau Date: Mon, 14 May 2012 20:45:21 +0000 (+0200) Subject: add a command for allowing the setup task to schedule a restart X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=3d49dba94c7a2ebaa8626acf81ca74a22c7784f7;p=project%2Fnetifd.git add a command for allowing the setup task to schedule a restart --- diff --git a/dummy/netifd-proto.sh b/dummy/netifd-proto.sh index a38f9d9..365c433 100755 --- a/dummy/netifd-proto.sh +++ b/dummy/netifd-proto.sh @@ -296,6 +296,13 @@ proto_add_host_dependency() { _proto_notify "$interface" -S } +proto_setup_failed() { + local interface="$1" + json_init + json_add_int action 7 + _proto_notify "$interface" +} + init_proto() { proto="$1"; shift cmd="$1"; shift diff --git a/proto-shell.c b/proto-shell.c index 6b38ee9..5309a55 100644 --- a/proto-shell.c +++ b/proto-shell.c @@ -624,6 +624,22 @@ proto_shell_add_host_dependency(struct proto_shell_state *state, struct blob_att return 0; } +static int +proto_shell_setup_failed(struct proto_shell_state *state) +{ + switch (state->sm) { + case S_IDLE: + state->proto.proto_event(&state->proto, IFPEV_LINK_LOST); + /* fall through */ + case S_SETUP: + proto_shell_handler(&state->proto, PROTO_CMD_TEARDOWN, false); + break; + default: + break; + } + return 0; +} + static int proto_shell_notify(struct interface_proto_state *proto, struct blob_attr *attr) { @@ -651,6 +667,8 @@ proto_shell_notify(struct interface_proto_state *proto, struct blob_attr *attr) return proto_shell_set_available(state, tb); case 6: return proto_shell_add_host_dependency(state, tb); + case 7: + return proto_shell_setup_failed(state); default: return UBUS_STATUS_INVALID_ARGUMENT; }