X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=proto-shell.c;h=ef56aa808fc33e39fdf95a8bee50ecc35ec49316;hb=153a12143b9fef4b5d3c3a6597f6fe967a17c9d7;hp=8a3ff69bedd0f16ae5b2079435b6777046df9787;hpb=6ed631e55686b909e6db25838e6e591316933c97;p=project%2Fnetifd.git diff --git a/proto-shell.c b/proto-shell.c index 8a3ff69..ef56aa8 100644 --- a/proto-shell.c +++ b/proto-shell.c @@ -44,7 +44,6 @@ struct proto_shell_handler { char *config_buf; char *script_name; bool init_available; - bool no_proto_task; struct uci_blob_param_list config; }; @@ -306,7 +305,7 @@ proto_shell_task_finish(struct proto_shell_state *state, if (state->renew_pending) proto_shell_handler(&state->proto, PROTO_CMD_RENEW, false); - else if (!state->handler->no_proto_task && + else if (!(state->handler->proto.flags & PROTO_FLAG_NO_TASK) && !state->proto_task.uloop.pending && state->sm == S_SETUP) proto_shell_handler(&state->proto, @@ -539,10 +538,10 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr *data, return UBUS_STATUS_UNKNOWN_ERROR; device_set_present(dev, true); - - interface_update_start(iface); } + interface_update_start(iface, keep); + proto_apply_ip_settings(iface, data, addr_ext); if ((cur = tb[NOTIFY_ROUTES]) != NULL) @@ -563,8 +562,7 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr *data, interface_update_complete(state->proto.iface); if ((state->sm != S_SETUP_ABORT) && (state->sm != S_TEARDOWN)) { - if (!keep) - state->proto.proto_event(&state->proto, IFPEV_UP); + state->proto.proto_event(&state->proto, IFPEV_UP); state->sm = S_IDLE; } @@ -708,6 +706,8 @@ proto_shell_add_host_dependency(struct proto_shell_state *state, struct blob_att return UBUS_STATUS_PERMISSION_DENIED; dep = calloc(1, sizeof(*dep) + strlen(ifname) + 1); + if (!dep) + return UBUS_STATUS_UNKNOWN_ERROR; if (!host[0] && ifname[0]) { dep->any = true; @@ -834,6 +834,9 @@ proto_shell_attach(const struct proto_handler *h, struct interface *iface, struct proto_shell_state *state; state = calloc(1, sizeof(*state)); + if (!state) + return NULL; + INIT_LIST_HEAD(&state->deps); state->config = malloc(blob_pad_len(attr)); @@ -887,7 +890,8 @@ proto_shell_add_handler(const char *script, const char *name, json_object *obj) handler->proto.flags |= PROTO_FLAG_NODEV; tmp = json_get_field(obj, "no-proto-task", json_type_boolean); - handler->no_proto_task = tmp && json_object_get_boolean(tmp); + if (tmp && json_object_get_boolean(tmp)) + handler->proto.flags |= PROTO_FLAG_NO_TASK; tmp = json_get_field(obj, "available", json_type_boolean); if (tmp && json_object_get_boolean(tmp)) @@ -901,6 +905,10 @@ proto_shell_add_handler(const char *script, const char *name, json_object *obj) if (tmp && json_object_get_boolean(tmp)) handler->proto.flags |= PROTO_FLAG_LASTERROR; + tmp = json_get_field(obj, "teardown-on-l3-link-down", json_type_boolean); + if (tmp && json_object_get_boolean(tmp)) + handler->proto.flags |= PROTO_FLAG_TEARDOWN_ON_L3_LINK_DOWN; + config = json_get_field(obj, "config", json_type_array); if (config) handler->config_buf = netifd_handler_parse_config(&handler->config, config);