2 Unix SMB/CIFS implementation.
3 Samba internal messaging functions
4 Copyright (C) 2007 by Volker Lendecke
5 Copyright (C) 2007 by Andrew Tridgell
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "ctdbd_conn.h"
26 #ifdef CLUSTER_SUPPORT
28 #include "ctdb_packet.h"
32 * It is not possible to include ctdb.h and tdb_compat.h (included via
33 * some other include above) without warnings. This fixes those
41 #ifdef typesafe_cb_preargs
42 #undef typesafe_cb_preargs
45 #ifdef typesafe_cb_postargs
46 #undef typesafe_cb_postargs
49 /* paths to these include files come from --with-ctdb= in configure */
52 #include "ctdb_private.h"
54 struct ctdbd_connection {
55 struct messaging_context *msg_ctx;
59 struct ctdb_packet_context *pkt;
60 struct tevent_fd *fde;
62 void (*release_ip_handler)(const char *ip_addr, void *private_data);
63 void *release_ip_priv;
66 static uint32_t ctdbd_next_reqid(struct ctdbd_connection *conn)
69 if (conn->reqid == 0) {
75 static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
76 uint32_t vnn, uint32_t opcode,
77 uint64_t srvid, uint32_t flags, TDB_DATA data,
78 TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
82 * exit on fatal communications errors with the ctdbd daemon
84 static void cluster_fatal(const char *why)
86 DEBUG(0,("cluster fatal event: %s - exiting immediately\n", why));
87 /* we don't use smb_panic() as we don't want to delay to write
88 a core file. We need to release this process id immediately
89 so that someone else can take over without getting sharing
97 static void ctdb_packet_dump(struct ctdb_req_header *hdr)
99 if (DEBUGLEVEL < 11) {
102 DEBUGADD(11, ("len=%d, magic=%x, vers=%d, gen=%d, op=%d, reqid=%d\n",
103 (int)hdr->length, (int)hdr->ctdb_magic,
104 (int)hdr->ctdb_version, (int)hdr->generation,
105 (int)hdr->operation, (int)hdr->reqid));
109 * Register a srvid with ctdbd
111 NTSTATUS register_with_ctdbd(struct ctdbd_connection *conn, uint64_t srvid)
115 return ctdbd_control(conn, CTDB_CURRENT_NODE,
116 CTDB_CONTROL_REGISTER_SRVID, srvid, 0,
117 tdb_null, NULL, NULL, &cstatus);
121 * get our vnn from the cluster
123 static NTSTATUS get_cluster_vnn(struct ctdbd_connection *conn, uint32_t *vnn)
127 status = ctdbd_control(conn,
128 CTDB_CURRENT_NODE, CTDB_CONTROL_GET_PNN, 0, 0,
129 tdb_null, NULL, NULL, &cstatus);
130 if (!NT_STATUS_IS_OK(status)) {
131 cluster_fatal("ctdbd_control failed\n");
133 *vnn = (uint32_t)cstatus;
138 * Are we active (i.e. not banned or stopped?)
140 static bool ctdbd_working(struct ctdbd_connection *conn, uint32_t vnn)
145 struct ctdb_node_map *m;
146 uint32_t failure_flags;
150 status = ctdbd_control(conn, CTDB_CURRENT_NODE,
151 CTDB_CONTROL_GET_NODEMAP, 0, 0,
152 tdb_null, talloc_tos(), &outdata, &cstatus);
153 if (!NT_STATUS_IS_OK(status)) {
154 cluster_fatal("ctdbd_control failed\n");
156 if ((cstatus != 0) || (outdata.dptr == NULL)) {
157 DEBUG(2, ("Received invalid ctdb data\n"));
161 m = (struct ctdb_node_map *)outdata.dptr;
163 for (i=0; i<m->num; i++) {
164 if (vnn == m->nodes[i].pnn) {
170 DEBUG(2, ("Did not find ourselves (node %d) in nodemap\n",
175 failure_flags = NODE_FLAGS_BANNED | NODE_FLAGS_DISCONNECTED
176 | NODE_FLAGS_PERMANENTLY_DISABLED | NODE_FLAGS_STOPPED;
178 if ((m->nodes[i].flags & failure_flags) != 0) {
179 DEBUG(2, ("Node has status %x, not active\n",
180 (int)m->nodes[i].flags));
186 TALLOC_FREE(outdata.dptr);
190 uint32_t ctdbd_vnn(const struct ctdbd_connection *conn)
192 return conn->our_vnn;
196 * Get us a ctdb connection
199 static NTSTATUS ctdbd_connect(TALLOC_CTX *mem_ctx,
200 struct ctdb_packet_context **presult)
202 struct ctdb_packet_context *result;
203 const char *sockname = lp_ctdbd_socket();
204 struct sockaddr_un addr = { 0, };
208 fd = socket(AF_UNIX, SOCK_STREAM, 0);
210 DEBUG(3, ("Could not create socket: %s\n", strerror(errno)));
211 return map_nt_error_from_unix(errno);
214 addr.sun_family = AF_UNIX;
215 snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", sockname);
217 salen = sizeof(struct sockaddr_un);
218 if (connect(fd, (struct sockaddr *)(void *)&addr, salen) == -1) {
219 DEBUG(1, ("connect(%s) failed: %s\n", sockname,
222 return map_nt_error_from_unix(errno);
225 if (!(result = ctdb_packet_init(mem_ctx, fd))) {
227 return NT_STATUS_NO_MEMORY;
235 * Do we have a complete ctdb packet in the queue?
238 static bool ctdb_req_complete(const uint8_t *buf, size_t available,
244 if (available < sizeof(msglen)) {
248 msglen = *((const uint32_t *)buf);
250 DEBUG(11, ("msglen = %d\n", msglen));
252 if (msglen < sizeof(struct ctdb_req_header)) {
253 DEBUG(0, ("Got invalid msglen: %d, expected at least %d for "
254 "the req_header\n", (int)msglen,
255 (int)sizeof(struct ctdb_req_header)));
256 cluster_fatal("ctdbd protocol error\n");
259 if (available < msglen) {
268 * State necessary to defer an incoming message while we are waiting for a
272 struct deferred_msg_state {
273 struct messaging_context *msg_ctx;
274 struct messaging_rec *rec;
278 * Timed event handler for the deferred message
281 static void deferred_message_dispatch(struct tevent_context *event_ctx,
282 struct tevent_timer *te,
286 struct deferred_msg_state *state = talloc_get_type_abort(
287 private_data, struct deferred_msg_state);
289 messaging_dispatch_rec(state->msg_ctx, state->rec);
294 struct req_pull_state {
300 * Pull a ctdb request out of the incoming ctdb_packet queue
303 static NTSTATUS ctdb_req_pull(uint8_t *buf, size_t length,
306 struct req_pull_state *state = (struct req_pull_state *)private_data;
308 state->req.data = talloc_move(state->mem_ctx, &buf);
309 state->req.length = length;
314 * Fetch a messaging_rec from an incoming ctdb style message
317 static struct messaging_rec *ctdb_pull_messaging_rec(TALLOC_CTX *mem_ctx,
318 size_t overall_length,
319 struct ctdb_req_message *msg)
321 struct messaging_rec *result;
323 enum ndr_err_code ndr_err;
325 if ((overall_length < offsetof(struct ctdb_req_message, data))
327 < offsetof(struct ctdb_req_message, data) + msg->datalen)) {
329 cluster_fatal("got invalid msg length");
332 if (!(result = talloc(mem_ctx, struct messaging_rec))) {
333 DEBUG(0, ("talloc failed\n"));
337 blob = data_blob_const(msg->data, msg->datalen);
339 ndr_err = ndr_pull_struct_blob(
340 &blob, result, result,
341 (ndr_pull_flags_fn_t)ndr_pull_messaging_rec);
343 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
344 DEBUG(0, ("ndr_pull_struct_blob failed: %s\n",
345 ndr_errstr(ndr_err)));
350 if (DEBUGLEVEL >= 11) {
351 DEBUG(11, ("ctdb_pull_messaging_rec:\n"));
352 NDR_PRINT_DEBUG(messaging_rec, result);
358 static NTSTATUS ctdb_packet_fd_read_sync(struct ctdb_packet_context *ctx)
360 int timeout = lp_ctdb_timeout();
365 return ctdb_packet_fd_read_sync_timeout(ctx, timeout);
369 * Read a full ctdbd request. If we have a messaging context, defer incoming
370 * messages that might come in between.
373 static NTSTATUS ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid,
374 TALLOC_CTX *mem_ctx, void *result)
376 struct ctdb_req_header *hdr;
377 struct req_pull_state state;
382 state.mem_ctx = mem_ctx;
384 while (!ctdb_packet_handler(conn->pkt, ctdb_req_complete,
385 ctdb_req_pull, &state, &status)) {
389 status = ctdb_packet_fd_read_sync(conn->pkt);
391 if (NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_BUSY)) {
394 } else if (NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {
399 if (!NT_STATUS_IS_OK(status)) {
400 DEBUG(0, ("packet_fd_read failed: %s\n", nt_errstr(status)));
401 cluster_fatal("ctdbd died\n");
405 if (!NT_STATUS_IS_OK(status)) {
406 DEBUG(0, ("Could not read ctdb_packet: %s\n", nt_errstr(status)));
407 cluster_fatal("ctdbd died\n");
410 hdr = (struct ctdb_req_header *)state.req.data;
412 DEBUG(11, ("Received ctdb packet\n"));
413 ctdb_packet_dump(hdr);
415 if (hdr->operation == CTDB_REQ_MESSAGE) {
416 struct tevent_timer *evt;
417 struct deferred_msg_state *msg_state;
418 struct ctdb_req_message *msg = (struct ctdb_req_message *)hdr;
420 if (conn->msg_ctx == NULL) {
421 DEBUG(1, ("Got a message without having a msg ctx, "
422 "dropping msg %llu\n",
423 (long long unsigned)msg->srvid));
427 if ((conn->release_ip_handler != NULL)
428 && (msg->srvid == CTDB_SRVID_RELEASE_IP)) {
429 /* must be dispatched immediately */
430 DEBUG(10, ("received CTDB_SRVID_RELEASE_IP\n"));
431 conn->release_ip_handler((const char *)msg->data,
432 conn->release_ip_priv);
437 if ((msg->srvid == CTDB_SRVID_RECONFIGURE)
438 || (msg->srvid == CTDB_SRVID_SAMBA_NOTIFY)) {
440 DEBUG(1, ("ctdb_read_req: Got %s message\n",
441 (msg->srvid == CTDB_SRVID_RECONFIGURE)
442 ? "cluster reconfigure" : "SAMBA_NOTIFY"));
444 messaging_send(conn->msg_ctx,
445 messaging_server_id(conn->msg_ctx),
446 MSG_SMB_BRL_VALIDATE, &data_blob_null);
447 messaging_send(conn->msg_ctx,
448 messaging_server_id(conn->msg_ctx),
449 MSG_DBWRAP_G_LOCK_RETRY,
455 msg_state = talloc(NULL, struct deferred_msg_state);
456 if (msg_state == NULL) {
457 DEBUG(0, ("talloc failed\n"));
462 if (!(msg_state->rec = ctdb_pull_messaging_rec(
463 msg_state, state.req.length, msg))) {
464 DEBUG(0, ("ctdbd_pull_messaging_rec failed\n"));
465 TALLOC_FREE(msg_state);
472 msg_state->msg_ctx = conn->msg_ctx;
475 * We're waiting for a call reply, but an async message has
476 * crossed. Defer dispatching to the toplevel event loop.
478 evt = tevent_add_timer(conn->msg_ctx->event_ctx,
479 conn->msg_ctx->event_ctx,
481 deferred_message_dispatch,
484 DEBUG(0, ("event_add_timed failed\n"));
485 TALLOC_FREE(msg_state);
493 if ((reqid != 0) && (hdr->reqid != reqid)) {
494 /* we got the wrong reply */
495 DEBUG(0,("Discarding mismatched ctdb reqid %u should have "
496 "been %u\n", hdr->reqid, reqid));
501 *((void **)result) = talloc_move(mem_ctx, &hdr);
507 * Get us a ctdbd connection
510 static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
511 struct ctdbd_connection **pconn)
513 struct ctdbd_connection *conn;
516 if (!(conn = talloc_zero(mem_ctx, struct ctdbd_connection))) {
517 DEBUG(0, ("talloc failed\n"));
518 return NT_STATUS_NO_MEMORY;
521 status = ctdbd_connect(conn, &conn->pkt);
523 if (!NT_STATUS_IS_OK(status)) {
524 DEBUG(10, ("ctdbd_connect failed: %s\n", nt_errstr(status)));
528 status = get_cluster_vnn(conn, &conn->our_vnn);
530 if (!NT_STATUS_IS_OK(status)) {
531 DEBUG(10, ("get_cluster_vnn failed: %s\n", nt_errstr(status)));
535 if (!ctdbd_working(conn, conn->our_vnn)) {
536 DEBUG(2, ("Node is not working, can not connect\n"));
537 status = NT_STATUS_INTERNAL_DB_ERROR;
541 generate_random_buffer((unsigned char *)&conn->rand_srvid,
542 sizeof(conn->rand_srvid));
544 status = register_with_ctdbd(conn, conn->rand_srvid);
546 if (!NT_STATUS_IS_OK(status)) {
547 DEBUG(5, ("Could not register random srvid: %s\n",
561 * Get us a ctdbd connection and register us as a process
564 NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
565 struct ctdbd_connection **pconn)
567 struct ctdbd_connection *conn;
570 status = ctdbd_init_connection(mem_ctx, &conn);
572 if (!NT_STATUS_IS_OK(status)) {
576 status = register_with_ctdbd(conn, (uint64_t)getpid());
577 if (!NT_STATUS_IS_OK(status)) {
581 status = register_with_ctdbd(conn, MSG_SRVID_SAMBA);
582 if (!NT_STATUS_IS_OK(status)) {
586 status = register_with_ctdbd(conn, CTDB_SRVID_SAMBA_NOTIFY);
587 if (!NT_STATUS_IS_OK(status)) {
599 struct messaging_context *ctdb_conn_msg_ctx(struct ctdbd_connection *conn)
601 return conn->msg_ctx;
604 int ctdbd_conn_get_fd(struct ctdbd_connection *conn)
606 return ctdb_packet_get_fd(conn->pkt);
610 * Packet handler to receive and handle a ctdb message
612 static NTSTATUS ctdb_handle_message(uint8_t *buf, size_t length,
615 struct ctdbd_connection *conn = talloc_get_type_abort(
616 private_data, struct ctdbd_connection);
617 struct ctdb_req_message *msg;
618 struct messaging_rec *msg_rec;
620 msg = (struct ctdb_req_message *)buf;
622 if (msg->hdr.operation != CTDB_REQ_MESSAGE) {
623 DEBUG(0, ("Received async msg of type %u, discarding\n",
624 msg->hdr.operation));
626 return NT_STATUS_INVALID_PARAMETER;
629 if ((conn->release_ip_handler != NULL)
630 && (msg->srvid == CTDB_SRVID_RELEASE_IP)) {
631 /* must be dispatched immediately */
632 DEBUG(10, ("received CTDB_SRVID_RELEASE_IP\n"));
633 conn->release_ip_handler((const char *)msg->data,
634 conn->release_ip_priv);
639 SMB_ASSERT(conn->msg_ctx != NULL);
641 if ((msg->srvid == CTDB_SRVID_RECONFIGURE)
642 || (msg->srvid == CTDB_SRVID_SAMBA_NOTIFY)){
643 DEBUG(0,("Got cluster reconfigure message\n"));
645 * when the cluster is reconfigured or someone of the
646 * family has passed away (SAMBA_NOTIFY), we need to
647 * clean the brl database
649 messaging_send(conn->msg_ctx,
650 messaging_server_id(conn->msg_ctx),
651 MSG_SMB_BRL_VALIDATE, &data_blob_null);
653 messaging_send(conn->msg_ctx,
654 messaging_server_id(conn->msg_ctx),
655 MSG_DBWRAP_G_LOCK_RETRY,
662 /* only messages to our pid or the broadcast are valid here */
663 if (msg->srvid != getpid() && msg->srvid != MSG_SRVID_SAMBA) {
664 DEBUG(0,("Got unexpected message with srvid=%llu\n",
665 (unsigned long long)msg->srvid));
670 if (!(msg_rec = ctdb_pull_messaging_rec(NULL, length, msg))) {
671 DEBUG(10, ("ctdb_pull_messaging_rec failed\n"));
673 return NT_STATUS_NO_MEMORY;
676 messaging_dispatch_rec(conn->msg_ctx, msg_rec);
678 TALLOC_FREE(msg_rec);
684 * The ctdbd socket is readable asynchronuously
687 static void ctdbd_socket_handler(struct tevent_context *event_ctx,
688 struct tevent_fd *event,
692 struct ctdbd_connection *conn = talloc_get_type_abort(
693 private_data, struct ctdbd_connection);
697 status = ctdb_packet_fd_read(conn->pkt);
699 if (!NT_STATUS_IS_OK(status)) {
700 DEBUG(0, ("packet_fd_read failed: %s\n", nt_errstr(status)));
701 cluster_fatal("ctdbd died\n");
704 while (ctdb_packet_handler(conn->pkt, ctdb_req_complete,
705 ctdb_handle_message, conn, &status)) {
706 if (!NT_STATUS_IS_OK(status)) {
707 DEBUG(10, ("could not handle incoming message: %s\n",
714 * Prepare a ctdbd connection to receive messages
717 NTSTATUS ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
718 struct messaging_context *msg_ctx)
720 SMB_ASSERT(conn->msg_ctx == NULL);
721 SMB_ASSERT(conn->fde == NULL);
723 if (!(conn->fde = tevent_add_fd(msg_ctx->event_ctx, conn,
724 ctdb_packet_get_fd(conn->pkt),
726 ctdbd_socket_handler,
728 DEBUG(0, ("event_add_fd failed\n"));
729 return NT_STATUS_NO_MEMORY;
732 conn->msg_ctx = msg_ctx;
738 * Send a messaging message across a ctdbd
741 NTSTATUS ctdbd_messaging_send(struct ctdbd_connection *conn,
742 uint32_t dst_vnn, uint64_t dst_srvid,
743 struct messaging_rec *msg)
747 enum ndr_err_code ndr_err;
749 ndr_err = ndr_push_struct_blob(
750 &blob, talloc_tos(), msg,
751 (ndr_push_flags_fn_t)ndr_push_messaging_rec);
753 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
754 DEBUG(0, ("ndr_push_struct_blob failed: %s\n",
755 ndr_errstr(ndr_err)));
756 return ndr_map_error2ntstatus(ndr_err);
759 status = ctdbd_messaging_send_blob(conn, dst_vnn, dst_srvid,
760 blob.data, blob.length);
761 TALLOC_FREE(blob.data);
765 NTSTATUS ctdbd_messaging_send_blob(struct ctdbd_connection *conn,
766 uint32_t dst_vnn, uint64_t dst_srvid,
767 const uint8_t *buf, size_t buflen)
769 struct ctdb_req_message r;
772 r.hdr.length = offsetof(struct ctdb_req_message, data) + buflen;
773 r.hdr.ctdb_magic = CTDB_MAGIC;
774 r.hdr.ctdb_version = CTDB_VERSION;
775 r.hdr.generation = 1;
776 r.hdr.operation = CTDB_REQ_MESSAGE;
777 r.hdr.destnode = dst_vnn;
778 r.hdr.srcnode = conn->our_vnn;
783 DEBUG(10, ("ctdbd_messaging_send: Sending ctdb packet\n"));
784 ctdb_packet_dump(&r.hdr);
786 status = ctdb_packet_send(
788 data_blob_const(&r, offsetof(struct ctdb_req_message, data)),
789 data_blob_const(buf, buflen));
791 if (!NT_STATUS_IS_OK(status)) {
792 DEBUG(0, ("ctdb_packet_send failed: %s\n", nt_errstr(status)));
796 status = ctdb_packet_flush(conn->pkt);
797 if (!NT_STATUS_IS_OK(status)) {
798 DEBUG(3, ("write to ctdbd failed: %s\n", nt_errstr(status)));
799 cluster_fatal("cluster dispatch daemon msg write error\n");
805 * send/recv a generic ctdb control message
807 static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
808 uint32_t vnn, uint32_t opcode,
809 uint64_t srvid, uint32_t flags,
811 TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
814 struct ctdb_req_control req;
815 struct ctdb_reply_control *reply = NULL;
816 struct ctdbd_connection *new_conn = NULL;
820 status = ctdbd_init_connection(NULL, &new_conn);
822 if (!NT_STATUS_IS_OK(status)) {
823 DEBUG(10, ("Could not init temp connection: %s\n",
832 req.hdr.length = offsetof(struct ctdb_req_control, data) + data.dsize;
833 req.hdr.ctdb_magic = CTDB_MAGIC;
834 req.hdr.ctdb_version = CTDB_VERSION;
835 req.hdr.operation = CTDB_REQ_CONTROL;
836 req.hdr.reqid = ctdbd_next_reqid(conn);
837 req.hdr.destnode = vnn;
840 req.datalen = data.dsize;
843 DEBUG(10, ("ctdbd_control: Sending ctdb packet\n"));
844 ctdb_packet_dump(&req.hdr);
846 status = ctdb_packet_send(
848 data_blob_const(&req, offsetof(struct ctdb_req_control, data)),
849 data_blob_const(data.dptr, data.dsize));
851 if (!NT_STATUS_IS_OK(status)) {
852 DEBUG(3, ("ctdb_packet_send failed: %s\n", nt_errstr(status)));
856 status = ctdb_packet_flush(conn->pkt);
858 if (!NT_STATUS_IS_OK(status)) {
859 DEBUG(3, ("write to ctdbd failed: %s\n", nt_errstr(status)));
860 cluster_fatal("cluster dispatch daemon control write error\n");
863 if (flags & CTDB_CTRL_FLAG_NOREPLY) {
864 TALLOC_FREE(new_conn);
871 status = ctdb_read_req(conn, req.hdr.reqid, NULL, (void *)&reply);
873 if (!NT_STATUS_IS_OK(status)) {
874 DEBUG(10, ("ctdb_read_req failed: %s\n", nt_errstr(status)));
878 if (reply->hdr.operation != CTDB_REPLY_CONTROL) {
879 DEBUG(0, ("received invalid reply\n"));
884 if (!(outdata->dptr = (uint8 *)talloc_memdup(
885 mem_ctx, reply->data, reply->datalen))) {
887 return NT_STATUS_NO_MEMORY;
889 outdata->dsize = reply->datalen;
892 (*cstatus) = reply->status;
895 status = NT_STATUS_OK;
898 TALLOC_FREE(new_conn);
904 * see if a remote process exists
906 bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32_t vnn, pid_t pid)
914 if (!ctdb_processes_exist(conn, &id, 1, &result)) {
915 DEBUG(10, ("ctdb_processes_exist failed\n"));
921 bool ctdb_processes_exist(struct ctdbd_connection *conn,
922 const struct server_id *pids, int num_pids,
925 TALLOC_CTX *frame = talloc_stackframe();
931 reqids = talloc_array(talloc_tos(), uint32_t, num_pids);
932 if (reqids == NULL) {
936 for (i=0; i<num_pids; i++) {
937 struct ctdb_req_control req;
941 reqids[i] = ctdbd_next_reqid(conn);
946 * pids[i].pid is uint64_t, scale down to pid_t which
947 * is the wire protocol towards ctdb.
951 DEBUG(10, ("Requesting PID %d/%d, reqid=%d\n",
952 (int)pids[i].vnn, (int)pid,
955 req.hdr.length = offsetof(struct ctdb_req_control, data);
956 req.hdr.length += sizeof(pid);
957 req.hdr.ctdb_magic = CTDB_MAGIC;
958 req.hdr.ctdb_version = CTDB_VERSION;
959 req.hdr.operation = CTDB_REQ_CONTROL;
960 req.hdr.reqid = reqids[i];
961 req.hdr.destnode = pids[i].vnn;
962 req.opcode = CTDB_CONTROL_PROCESS_EXISTS;
964 req.datalen = sizeof(pid);
967 DEBUG(10, ("ctdbd_control: Sending ctdb packet\n"));
968 ctdb_packet_dump(&req.hdr);
970 status = ctdb_packet_send(
973 &req, offsetof(struct ctdb_req_control, data)),
974 data_blob_const(&pid, sizeof(pid)));
975 if (!NT_STATUS_IS_OK(status)) {
976 DEBUG(10, ("ctdb_packet_send failed: %s\n",
982 status = ctdb_packet_flush(conn->pkt);
983 if (!NT_STATUS_IS_OK(status)) {
984 DEBUG(10, ("ctdb_packet_flush failed: %s\n",
991 while (num_received < num_pids) {
992 struct ctdb_reply_control *reply = NULL;
995 status = ctdb_read_req(conn, 0, talloc_tos(), (void *)&reply);
996 if (!NT_STATUS_IS_OK(status)) {
997 DEBUG(10, ("ctdb_read_req failed: %s\n",
1002 if (reply->hdr.operation != CTDB_REPLY_CONTROL) {
1003 DEBUG(10, ("Received invalid reply\n"));
1007 reqid = reply->hdr.reqid;
1009 DEBUG(10, ("Received reqid %d\n", (int)reqid));
1011 for (i=0; i<num_pids; i++) {
1012 if (reqid == reqids[i]) {
1016 if (i == num_pids) {
1017 DEBUG(10, ("Received unknown record number %u\n",
1021 results[i] = ((reply->status) == 0);
1032 struct ctdb_vnn_list {
1035 unsigned num_srvids;
1036 unsigned num_filled;
1038 unsigned *pid_indexes;
1042 * Get a list of all vnns mentioned in a list of
1043 * server_ids. vnn_indexes tells where in the vnns array we have to
1046 static bool ctdb_collect_vnns(TALLOC_CTX *mem_ctx,
1047 const struct server_id *pids, unsigned num_pids,
1048 struct ctdb_vnn_list **pvnns,
1049 unsigned *pnum_vnns)
1051 struct ctdb_vnn_list *vnns = NULL;
1052 unsigned *vnn_indexes = NULL;
1053 unsigned i, num_vnns = 0;
1055 vnn_indexes = talloc_array(mem_ctx, unsigned, num_pids);
1056 if (vnn_indexes == NULL) {
1057 DEBUG(1, ("talloc_array failed\n"));
1061 for (i=0; i<num_pids; i++) {
1063 uint32_t vnn = pids[i].vnn;
1065 for (j=0; j<num_vnns; j++) {
1066 if (vnn == vnns[j].vnn) {
1074 * Already in the array
1076 vnns[j].num_srvids += 1;
1079 vnns = talloc_realloc(mem_ctx, vnns, struct ctdb_vnn_list,
1082 DEBUG(1, ("talloc_realloc failed\n"));
1085 vnns[num_vnns].vnn = vnn;
1086 vnns[num_vnns].num_srvids = 1;
1087 vnns[num_vnns].num_filled = 0;
1090 for (i=0; i<num_vnns; i++) {
1091 struct ctdb_vnn_list *vnn = &vnns[i];
1093 vnn->srvids = talloc_array(vnns, uint64_t, vnn->num_srvids);
1094 if (vnn->srvids == NULL) {
1095 DEBUG(1, ("talloc_array failed\n"));
1098 vnn->pid_indexes = talloc_array(vnns, unsigned,
1100 if (vnn->pid_indexes == NULL) {
1101 DEBUG(1, ("talloc_array failed\n"));
1105 for (i=0; i<num_pids; i++) {
1106 struct ctdb_vnn_list *vnn = &vnns[vnn_indexes[i]];
1107 vnn->srvids[vnn->num_filled] = pids[i].unique_id;
1108 vnn->pid_indexes[vnn->num_filled] = i;
1109 vnn->num_filled += 1;
1112 TALLOC_FREE(vnn_indexes);
1114 *pnum_vnns = num_vnns;
1118 TALLOC_FREE(vnn_indexes);
1122 #ifdef HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL
1124 bool ctdb_serverids_exist(struct ctdbd_connection *conn,
1125 const struct server_id *pids, unsigned num_pids,
1128 unsigned i, num_received;
1130 struct ctdb_vnn_list *vnns = NULL;
1132 bool result = false;
1134 if (!ctdb_collect_vnns(talloc_tos(), pids, num_pids,
1135 &vnns, &num_vnns)) {
1136 DEBUG(1, ("ctdb_collect_vnns failed\n"));
1140 for (i=0; i<num_vnns; i++) {
1141 struct ctdb_vnn_list *vnn = &vnns[i];
1142 struct ctdb_req_control req;
1144 vnn->reqid = ctdbd_next_reqid(conn);
1148 DEBUG(10, ("Requesting VNN %d, reqid=%d, num_srvids=%u\n",
1149 (int)vnn->vnn, (int)vnn->reqid, vnn->num_srvids));
1151 req.hdr.length = offsetof(struct ctdb_req_control, data);
1152 req.hdr.ctdb_magic = CTDB_MAGIC;
1153 req.hdr.ctdb_version = CTDB_VERSION;
1154 req.hdr.operation = CTDB_REQ_CONTROL;
1155 req.hdr.reqid = vnn->reqid;
1156 req.hdr.destnode = vnn->vnn;
1157 req.opcode = CTDB_CONTROL_CHECK_SRVIDS;
1159 req.datalen = sizeof(uint64_t) * vnn->num_srvids;
1160 req.hdr.length += req.datalen;
1163 DEBUG(10, ("ctdbd_control: Sending ctdb packet\n"));
1164 ctdb_packet_dump(&req.hdr);
1166 status = ctdb_packet_send(
1169 &req, offsetof(struct ctdb_req_control,
1171 data_blob_const(vnn->srvids, req.datalen));
1172 if (!NT_STATUS_IS_OK(status)) {
1173 DEBUG(1, ("ctdb_packet_send failed: %s\n",
1174 nt_errstr(status)));
1179 status = ctdb_packet_flush(conn->pkt);
1180 if (!NT_STATUS_IS_OK(status)) {
1181 DEBUG(1, ("ctdb_packet_flush failed: %s\n",
1182 nt_errstr(status)));
1188 while (num_received < num_vnns) {
1189 struct ctdb_reply_control *reply = NULL;
1190 struct ctdb_vnn_list *vnn;
1192 uint8_t *reply_data;
1194 status = ctdb_read_req(conn, 0, talloc_tos(), (void *)&reply);
1195 if (!NT_STATUS_IS_OK(status)) {
1196 DEBUG(1, ("ctdb_read_req failed: %s\n",
1197 nt_errstr(status)));
1201 if (reply->hdr.operation != CTDB_REPLY_CONTROL) {
1202 DEBUG(1, ("Received invalid reply %u\n",
1203 (unsigned)reply->hdr.operation));
1207 reqid = reply->hdr.reqid;
1209 DEBUG(10, ("Received reqid %d\n", (int)reqid));
1211 for (i=0; i<num_vnns; i++) {
1212 if (reqid == vnns[i].reqid) {
1216 if (i == num_vnns) {
1217 DEBUG(1, ("Received unknown reqid number %u\n",
1222 DEBUG(10, ("Found index %u\n", i));
1226 DEBUG(10, ("Received vnn %u, vnn->num_srvids %u, datalen %u\n",
1227 (unsigned)vnn->vnn, vnn->num_srvids,
1228 (unsigned)reply->datalen));
1230 if (reply->datalen >= ((vnn->num_srvids+7)/8)) {
1234 reply_data = reply->data;
1237 * Got an error reply
1239 DEBUG(5, ("Received short reply len %d, status %u, "
1241 (unsigned)reply->datalen,
1242 (unsigned)reply->status,
1243 (unsigned)reply->errorlen));
1244 dump_data(5, reply->data, reply->errorlen);
1247 * This will trigger everything set to false
1252 for (i=0; i<vnn->num_srvids; i++) {
1253 int idx = vnn->pid_indexes[i];
1255 if (pids[i].unique_id ==
1256 SERVERID_UNIQUE_ID_NOT_TO_VERIFY) {
1257 results[idx] = true;
1261 (reply_data != NULL) &&
1262 ((reply_data[i/8] & (1<<(i%8))) != 0);
1275 #endif /* HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL */
1280 char *ctdbd_dbpath(struct ctdbd_connection *conn,
1281 TALLOC_CTX *mem_ctx, uint32_t db_id)
1287 data.dptr = (uint8_t*)&db_id;
1288 data.dsize = sizeof(db_id);
1290 status = ctdbd_control(conn, CTDB_CURRENT_NODE,
1291 CTDB_CONTROL_GETDBPATH, 0, 0, data,
1292 mem_ctx, &data, &cstatus);
1293 if (!NT_STATUS_IS_OK(status) || cstatus != 0) {
1294 DEBUG(0,(__location__ " ctdb_control for getdbpath failed\n"));
1298 return (char *)data.dptr;
1302 * attach to a ctdb database
1304 NTSTATUS ctdbd_db_attach(struct ctdbd_connection *conn,
1305 const char *name, uint32_t *db_id, int tdb_flags)
1310 bool persistent = (tdb_flags & TDB_CLEAR_IF_FIRST) == 0;
1312 data = string_term_tdb_data(name);
1314 status = ctdbd_control(conn, CTDB_CURRENT_NODE,
1316 ? CTDB_CONTROL_DB_ATTACH_PERSISTENT
1317 : CTDB_CONTROL_DB_ATTACH,
1318 tdb_flags, 0, data, NULL, &data, &cstatus);
1319 if (!NT_STATUS_IS_OK(status)) {
1320 DEBUG(0, (__location__ " ctdb_control for db_attach "
1321 "failed: %s\n", nt_errstr(status)));
1325 if (cstatus != 0 || data.dsize != sizeof(uint32_t)) {
1326 DEBUG(0,(__location__ " ctdb_control for db_attach failed\n"));
1327 return NT_STATUS_INTERNAL_ERROR;
1330 *db_id = *(uint32_t *)data.dptr;
1331 talloc_free(data.dptr);
1333 if (!(tdb_flags & TDB_SEQNUM)) {
1334 return NT_STATUS_OK;
1337 data.dptr = (uint8_t *)db_id;
1338 data.dsize = sizeof(*db_id);
1340 status = ctdbd_control(conn, CTDB_CURRENT_NODE,
1341 CTDB_CONTROL_ENABLE_SEQNUM, 0, 0, data,
1342 NULL, NULL, &cstatus);
1343 if (!NT_STATUS_IS_OK(status) || cstatus != 0) {
1344 DEBUG(0,(__location__ " ctdb_control for enable seqnum "
1346 return NT_STATUS_IS_OK(status) ? NT_STATUS_INTERNAL_ERROR :
1350 return NT_STATUS_OK;
1354 * force the migration of a record to this node
1356 NTSTATUS ctdbd_migrate(struct ctdbd_connection *conn, uint32_t db_id,
1359 struct ctdb_req_call req;
1360 struct ctdb_reply_call *reply;
1365 req.hdr.length = offsetof(struct ctdb_req_call, data) + key.dsize;
1366 req.hdr.ctdb_magic = CTDB_MAGIC;
1367 req.hdr.ctdb_version = CTDB_VERSION;
1368 req.hdr.operation = CTDB_REQ_CALL;
1369 req.hdr.reqid = ctdbd_next_reqid(conn);
1370 req.flags = CTDB_IMMEDIATE_MIGRATION;
1371 req.callid = CTDB_NULL_FUNC;
1373 req.keylen = key.dsize;
1375 DEBUG(10, ("ctdbd_migrate: Sending ctdb packet\n"));
1376 ctdb_packet_dump(&req.hdr);
1378 status = ctdb_packet_send(
1380 data_blob_const(&req, offsetof(struct ctdb_req_call, data)),
1381 data_blob_const(key.dptr, key.dsize));
1383 if (!NT_STATUS_IS_OK(status)) {
1384 DEBUG(3, ("ctdb_packet_send failed: %s\n", nt_errstr(status)));
1388 status = ctdb_packet_flush(conn->pkt);
1390 if (!NT_STATUS_IS_OK(status)) {
1391 DEBUG(3, ("write to ctdbd failed: %s\n", nt_errstr(status)));
1392 cluster_fatal("cluster dispatch daemon control write error\n");
1395 status = ctdb_read_req(conn, req.hdr.reqid, NULL, (void *)&reply);
1397 if (!NT_STATUS_IS_OK(status)) {
1398 DEBUG(0, ("ctdb_read_req failed: %s\n", nt_errstr(status)));
1402 if (reply->hdr.operation != CTDB_REPLY_CALL) {
1403 DEBUG(0, ("received invalid reply\n"));
1404 status = NT_STATUS_INTERNAL_ERROR;
1408 status = NT_STATUS_OK;
1416 * Fetch a record and parse it
1418 NTSTATUS ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
1419 TDB_DATA key, bool local_copy,
1420 void (*parser)(TDB_DATA key, TDB_DATA data,
1421 void *private_data),
1424 struct ctdb_req_call req;
1425 struct ctdb_reply_call *reply;
1429 #ifdef HAVE_CTDB_WANT_READONLY_DECL
1430 flags = local_copy ? CTDB_WANT_READONLY : 0;
1437 req.hdr.length = offsetof(struct ctdb_req_call, data) + key.dsize;
1438 req.hdr.ctdb_magic = CTDB_MAGIC;
1439 req.hdr.ctdb_version = CTDB_VERSION;
1440 req.hdr.operation = CTDB_REQ_CALL;
1441 req.hdr.reqid = ctdbd_next_reqid(conn);
1443 req.callid = CTDB_FETCH_FUNC;
1445 req.keylen = key.dsize;
1447 status = ctdb_packet_send(
1449 data_blob_const(&req, offsetof(struct ctdb_req_call, data)),
1450 data_blob_const(key.dptr, key.dsize));
1452 if (!NT_STATUS_IS_OK(status)) {
1453 DEBUG(3, ("ctdb_packet_send failed: %s\n", nt_errstr(status)));
1457 status = ctdb_packet_flush(conn->pkt);
1459 if (!NT_STATUS_IS_OK(status)) {
1460 DEBUG(3, ("write to ctdbd failed: %s\n", nt_errstr(status)));
1461 cluster_fatal("cluster dispatch daemon control write error\n");
1464 status = ctdb_read_req(conn, req.hdr.reqid, NULL, (void *)&reply);
1466 if (!NT_STATUS_IS_OK(status)) {
1467 DEBUG(0, ("ctdb_read_req failed: %s\n", nt_errstr(status)));
1471 if (reply->hdr.operation != CTDB_REPLY_CALL) {
1472 DEBUG(0, ("received invalid reply\n"));
1473 status = NT_STATUS_INTERNAL_ERROR;
1477 if (reply->datalen == 0) {
1479 * Treat an empty record as non-existing
1481 status = NT_STATUS_NOT_FOUND;
1485 parser(key, make_tdb_data(&reply->data[0], reply->datalen),
1488 status = NT_STATUS_OK;
1494 struct ctdbd_traverse_state {
1495 void (*fn)(TDB_DATA key, TDB_DATA data, void *private_data);
1500 * Handle a traverse record coming in on the ctdbd connection
1503 static NTSTATUS ctdb_traverse_handler(uint8_t *buf, size_t length,
1506 struct ctdbd_traverse_state *state =
1507 (struct ctdbd_traverse_state *)private_data;
1509 struct ctdb_req_message *m;
1510 struct ctdb_rec_data *d;
1513 m = (struct ctdb_req_message *)buf;
1515 if (length < sizeof(*m) || m->hdr.length != length) {
1516 DEBUG(0, ("Got invalid message of length %d\n", (int)length));
1518 return NT_STATUS_UNEXPECTED_IO_ERROR;
1521 d = (struct ctdb_rec_data *)&m->data[0];
1522 if (m->datalen < sizeof(uint32_t) || m->datalen != d->length) {
1523 DEBUG(0, ("Got invalid traverse data of length %d\n",
1526 return NT_STATUS_UNEXPECTED_IO_ERROR;
1529 key.dsize = d->keylen;
1530 key.dptr = &d->data[0];
1531 data.dsize = d->datalen;
1532 data.dptr = &d->data[d->keylen];
1534 if (key.dsize == 0 && data.dsize == 0) {
1535 /* end of traverse */
1536 return NT_STATUS_END_OF_FILE;
1539 if (data.dsize < sizeof(struct ctdb_ltdb_header)) {
1540 DEBUG(0, ("Got invalid ltdb header length %d\n",
1543 return NT_STATUS_UNEXPECTED_IO_ERROR;
1545 data.dsize -= sizeof(struct ctdb_ltdb_header);
1546 data.dptr += sizeof(struct ctdb_ltdb_header);
1549 state->fn(key, data, state->private_data);
1553 return NT_STATUS_OK;
1557 Traverse a ctdb database. This uses a kind-of hackish way to open a second
1558 connection to ctdbd to avoid the hairy recursive and async problems with
1562 NTSTATUS ctdbd_traverse(uint32_t db_id,
1563 void (*fn)(TDB_DATA key, TDB_DATA data,
1564 void *private_data),
1567 struct ctdbd_connection *conn;
1571 struct ctdb_traverse_start t;
1573 struct ctdbd_traverse_state state;
1576 status = ctdbd_init_connection(NULL, &conn);
1578 if (!NT_STATUS_IS_OK(status)) {
1579 DEBUG(0, ("ctdbd_init_connection failed: %s\n",
1580 nt_errstr(status)));
1585 t.srvid = conn->rand_srvid;
1586 t.reqid = ctdbd_next_reqid(conn);
1588 data.dptr = (uint8_t *)&t;
1589 data.dsize = sizeof(t);
1591 status = ctdbd_control(conn, CTDB_CURRENT_NODE,
1592 CTDB_CONTROL_TRAVERSE_START, conn->rand_srvid, 0,
1593 data, NULL, NULL, &cstatus);
1595 if (!NT_STATUS_IS_OK(status) || (cstatus != 0)) {
1597 DEBUG(0,("ctdbd_control failed: %s, %d\n", nt_errstr(status),
1600 if (NT_STATUS_IS_OK(status)) {
1602 * We need a mapping here
1604 status = NT_STATUS_UNSUCCESSFUL;
1610 state.private_data = private_data;
1614 status = NT_STATUS_OK;
1616 if (ctdb_packet_handler(conn->pkt, ctdb_req_complete,
1617 ctdb_traverse_handler, &state, &status)) {
1619 if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
1620 status = NT_STATUS_OK;
1625 * There might be more in the queue
1630 if (!NT_STATUS_IS_OK(status)) {
1634 status = ctdb_packet_fd_read_sync(conn->pkt);
1636 if (NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {
1638 * There might be more in the queue
1643 if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
1644 status = NT_STATUS_OK;
1648 if (!NT_STATUS_IS_OK(status)) {
1649 DEBUG(0, ("ctdb_packet_fd_read_sync failed: %s\n", nt_errstr(status)));
1650 cluster_fatal("ctdbd died\n");
1660 This is used to canonicalize a ctdb_sock_addr structure.
1662 static void smbd_ctdb_canonicalize_ip(const struct sockaddr_storage *in,
1663 struct sockaddr_storage *out)
1665 memcpy(out, in, sizeof (*out));
1668 if (in->ss_family == AF_INET6) {
1669 const char prefix[12] = { 0,0,0,0,0,0,0,0,0,0,0xff,0xff };
1670 const struct sockaddr_in6 *in6 =
1671 (const struct sockaddr_in6 *)in;
1672 struct sockaddr_in *out4 = (struct sockaddr_in *)out;
1673 if (memcmp(&in6->sin6_addr, prefix, 12) == 0) {
1674 memset(out, 0, sizeof(*out));
1675 #ifdef HAVE_SOCK_SIN_LEN
1676 out4->sin_len = sizeof(*out);
1678 out4->sin_family = AF_INET;
1679 out4->sin_port = in6->sin6_port;
1680 memcpy(&out4->sin_addr, &in6->sin6_addr.s6_addr[12], 4);
1687 * Register us as a server for a particular tcp connection
1690 NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
1691 const struct sockaddr_storage *_server,
1692 const struct sockaddr_storage *_client,
1693 void (*release_ip_handler)(const char *ip_addr,
1694 void *private_data),
1698 * we still use ctdb_control_tcp for ipv4
1699 * because we want to work against older ctdb
1700 * versions at runtime
1702 struct ctdb_control_tcp p4;
1703 #ifdef HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR
1704 struct ctdb_control_tcp_addr p;
1708 struct sockaddr_storage client;
1709 struct sockaddr_storage server;
1712 * Only one connection so far
1714 SMB_ASSERT(conn->release_ip_handler == NULL);
1716 smbd_ctdb_canonicalize_ip(_client, &client);
1717 smbd_ctdb_canonicalize_ip(_server, &server);
1719 switch (client.ss_family) {
1721 memcpy(&p4.dest, &server, sizeof(p4.dest));
1722 memcpy(&p4.src, &client, sizeof(p4.src));
1723 data.dptr = (uint8_t *)&p4;
1724 data.dsize = sizeof(p4);
1726 #ifdef HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR
1728 memcpy(&p.dest.ip6, &server, sizeof(p.dest.ip6));
1729 memcpy(&p.src.ip6, &client, sizeof(p.src.ip6));
1730 data.dptr = (uint8_t *)&p;
1731 data.dsize = sizeof(p);
1735 return NT_STATUS_INTERNAL_ERROR;
1738 conn->release_ip_handler = release_ip_handler;
1739 conn->release_ip_priv = private_data;
1742 * We want to be told about IP releases
1745 status = register_with_ctdbd(conn, CTDB_SRVID_RELEASE_IP);
1746 if (!NT_STATUS_IS_OK(status)) {
1751 * inform ctdb of our tcp connection, so if IP takeover happens ctdb
1752 * can send an extra ack to trigger a reset for our client, so it
1753 * immediately reconnects
1755 return ctdbd_control(conn, CTDB_CURRENT_NODE,
1756 CTDB_CONTROL_TCP_CLIENT, 0,
1757 CTDB_CTRL_FLAG_NOREPLY, data, NULL, NULL, NULL);
1761 * We want to handle reconfigure events
1763 NTSTATUS ctdbd_register_reconfigure(struct ctdbd_connection *conn)
1765 return register_with_ctdbd(conn, CTDB_SRVID_RECONFIGURE);
1769 call a control on the local node
1771 NTSTATUS ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,
1772 uint64_t srvid, uint32_t flags, TDB_DATA data,
1773 TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
1776 return ctdbd_control(conn, CTDB_CURRENT_NODE, opcode, srvid, flags, data, mem_ctx, outdata, cstatus);
1779 NTSTATUS ctdb_watch_us(struct ctdbd_connection *conn)
1781 struct ctdb_client_notify_register reg_data;
1786 reg_data.srvid = CTDB_SRVID_SAMBA_NOTIFY;
1788 reg_data.notify_data[0] = 0;
1790 struct_len = offsetof(struct ctdb_client_notify_register,
1791 notify_data) + reg_data.len;
1793 status = ctdbd_control_local(
1794 conn, CTDB_CONTROL_REGISTER_NOTIFY, conn->rand_srvid, 0,
1795 make_tdb_data((uint8_t *)®_data, struct_len),
1796 NULL, NULL, &cstatus);
1797 if (!NT_STATUS_IS_OK(status)) {
1798 DEBUG(1, ("ctdbd_control_local failed: %s\n",
1799 nt_errstr(status)));
1804 NTSTATUS ctdb_unwatch(struct ctdbd_connection *conn)
1806 struct ctdb_client_notify_deregister dereg_data;
1810 dereg_data.srvid = CTDB_SRVID_SAMBA_NOTIFY;
1812 status = ctdbd_control_local(
1813 conn, CTDB_CONTROL_DEREGISTER_NOTIFY, conn->rand_srvid, 0,
1814 make_tdb_data((uint8_t *)&dereg_data, sizeof(dereg_data)),
1815 NULL, NULL, &cstatus);
1816 if (!NT_STATUS_IS_OK(status)) {
1817 DEBUG(1, ("ctdbd_control_local failed: %s\n",
1818 nt_errstr(status)));
1825 NTSTATUS ctdbd_messaging_send_blob(struct ctdbd_connection *conn,
1826 uint32_t dst_vnn, uint64_t dst_srvid,
1827 const uint8_t *buf, size_t buflen)
1829 return NT_STATUS_NOT_IMPLEMENTED;