return 0;
}
-static void
-proto_shell_set_down(struct proto_shell_state *state)
-{
- if (!state->l3_dev.dev)
- return;
-
- device_remove_user(&state->l3_dev);
-}
-
static int
proto_shell_handler(struct interface_proto_state *proto,
enum interface_proto_cmd cmd, bool force)
state = container_of(p, struct proto_shell_state, setup_task);
uloop_timeout_cancel(&state->setup_timeout);
if (state->teardown_pending) {
- state->teardown_pending = 0;
+ state->teardown_pending = false;
proto_shell_handler(&state->proto, PROTO_CMD_TEARDOWN, false);
}
}
struct proto_shell_state *state;
state = container_of(p, struct proto_shell_state, teardown_task);
- proto_shell_set_down(state);
state->proto.proto_event(&state->proto, IFPEV_DOWN);
+ if (state->l3_dev.dev)
+ device_remove_user(&state->l3_dev);
}
static void
if (!tb[NOTIFY_IFNAME])
return UBUS_STATUS_INVALID_ARGUMENT;
- device_add_user(&state->l3_dev,
- device_get(blobmsg_data(tb[NOTIFY_IFNAME]), true));
- device_claim(&state->l3_dev);
- state->proto.iface->l3_dev = &state->l3_dev;
+ if (!state->l3_dev.dev) {
+ device_add_user(&state->l3_dev,
+ device_get(blobmsg_data(tb[NOTIFY_IFNAME]), true));
+ device_claim(&state->l3_dev);
+ state->proto.iface->l3_dev = &state->l3_dev;
+ }
state->proto.proto_event(&state->proto, IFPEV_UP);
} else {
- proto_shell_set_down(state);
+ state->proto.proto_event(&state->proto, IFPEV_LINK_LOST);
}
return 0;