implement a generic peerdns option to suppress proto handler dns entries
[project/netifd.git] / proto-shell.c
index 78585df..5309a55 100644 (file)
@@ -316,6 +316,7 @@ proto_shell_free(struct interface_proto_state *proto)
        struct proto_shell_state *state;
 
        state = container_of(proto, struct proto_shell_state, proto);
+       proto_shell_clear_host_dep(state);
        netifd_kill_process(&state->script_task);
        netifd_kill_process(&state->proto_task);
        free(state->config);
@@ -624,6 +625,22 @@ proto_shell_add_host_dependency(struct proto_shell_state *state, struct blob_att
 }
 
 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)
 {
        struct proto_shell_state *state;
@@ -650,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;
        }