add a command for allowing the setup task to schedule a restart
authorFelix Fietkau <nbd@openwrt.org>
Mon, 14 May 2012 20:45:21 +0000 (22:45 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 14 May 2012 20:45:21 +0000 (22:45 +0200)
dummy/netifd-proto.sh
proto-shell.c

index a38f9d996075af7ff3afa95c17048de3b47b30b0..365c4338f7ccaf38cf3cbf568243a6b01f7cfcf3 100755 (executable)
@@ -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
index 6b38ee9505951087f0f22f5355ea4774dc8e17ea..5309a55645b24b696bbf462aeb6407513bd62227 100644 (file)
@@ -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;
        }