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 DEBUG(1, ("ctdbd_control failed: %s\n", nt_errstr(status)));
134 *vnn = (uint32_t)cstatus;
139 * Are we active (i.e. not banned or stopped?)
141 static bool ctdbd_working(struct ctdbd_connection *conn, uint32_t vnn)
146 struct ctdb_node_map *m;
147 uint32_t failure_flags;
151 status = ctdbd_control(conn, CTDB_CURRENT_NODE,
152 CTDB_CONTROL_GET_NODEMAP, 0, 0,
153 tdb_null, talloc_tos(), &outdata, &cstatus);
154 if (!NT_STATUS_IS_OK(status)) {
155 DEBUG(1, ("ctdbd_control failed: %s\n", nt_errstr(status)));
158 if ((cstatus != 0) || (outdata.dptr == NULL)) {
159 DEBUG(2, ("Received invalid ctdb data\n"));
163 m = (struct ctdb_node_map *)outdata.dptr;
165 for (i=0; i<m->num; i++) {
166 if (vnn == m->nodes[i].pnn) {
172 DEBUG(2, ("Did not find ourselves (node %d) in nodemap\n",
177 failure_flags = NODE_FLAGS_BANNED | NODE_FLAGS_DISCONNECTED
178 | NODE_FLAGS_PERMANENTLY_DISABLED | NODE_FLAGS_STOPPED;
180 if ((m->nodes[i].flags & failure_flags) != 0) {
181 DEBUG(2, ("Node has status %x, not active\n",
182 (int)m->nodes[i].flags));
188 TALLOC_FREE(outdata.dptr);
192 uint32_t ctdbd_vnn(const struct ctdbd_connection *conn)
194 return conn->our_vnn;
198 * Get us a ctdb connection
201 static NTSTATUS ctdbd_connect(TALLOC_CTX *mem_ctx,
202 struct ctdb_packet_context **presult)
204 struct ctdb_packet_context *result;
205 const char *sockname = lp_ctdbd_socket();
206 struct sockaddr_un addr = { 0, };
210 fd = socket(AF_UNIX, SOCK_STREAM, 0);
212 DEBUG(3, ("Could not create socket: %s\n", strerror(errno)));
213 return map_nt_error_from_unix(errno);
216 addr.sun_family = AF_UNIX;
217 snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", sockname);
219 salen = sizeof(struct sockaddr_un);
220 if (connect(fd, (struct sockaddr *)(void *)&addr, salen) == -1) {
221 DEBUG(1, ("connect(%s) failed: %s\n", sockname,
224 return map_nt_error_from_unix(errno);
227 if (!(result = ctdb_packet_init(mem_ctx, fd))) {
229 return NT_STATUS_NO_MEMORY;
237 * Do we have a complete ctdb packet in the queue?
240 static bool ctdb_req_complete(const uint8_t *buf, size_t available,
246 if (available < sizeof(msglen)) {
250 msglen = *((const uint32_t *)buf);
252 DEBUG(11, ("msglen = %d\n", msglen));
254 if (msglen < sizeof(struct ctdb_req_header)) {
255 DEBUG(0, ("Got invalid msglen: %d, expected at least %d for "
256 "the req_header\n", (int)msglen,
257 (int)sizeof(struct ctdb_req_header)));
258 cluster_fatal("ctdbd protocol error\n");
261 if (available < msglen) {
270 * State necessary to defer an incoming message while we are waiting for a
274 struct deferred_msg_state {
275 struct messaging_context *msg_ctx;
276 struct messaging_rec *rec;
280 * Timed event handler for the deferred message
283 static void deferred_message_dispatch(struct tevent_context *event_ctx,
284 struct tevent_timer *te,
288 struct deferred_msg_state *state = talloc_get_type_abort(
289 private_data, struct deferred_msg_state);
291 messaging_dispatch_rec(state->msg_ctx, state->rec);
296 struct req_pull_state {
302 * Pull a ctdb request out of the incoming ctdb_packet queue
305 static NTSTATUS ctdb_req_pull(uint8_t *buf, size_t length,
308 struct req_pull_state *state = (struct req_pull_state *)private_data;
310 state->req.data = talloc_move(state->mem_ctx, &buf);
311 state->req.length = length;
316 * Fetch a messaging_rec from an incoming ctdb style message
319 static struct messaging_rec *ctdb_pull_messaging_rec(TALLOC_CTX *mem_ctx,
320 size_t overall_length,
321 struct ctdb_req_message *msg)
323 struct messaging_rec *result;
325 enum ndr_err_code ndr_err;
327 if ((overall_length < offsetof(struct ctdb_req_message, data))
329 < offsetof(struct ctdb_req_message, data) + msg->datalen)) {
331 cluster_fatal("got invalid msg length");
334 if (!(result = talloc(mem_ctx, struct messaging_rec))) {
335 DEBUG(0, ("talloc failed\n"));
339 blob = data_blob_const(msg->data, msg->datalen);
341 ndr_err = ndr_pull_struct_blob(
342 &blob, result, result,
343 (ndr_pull_flags_fn_t)ndr_pull_messaging_rec);
345 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
346 DEBUG(0, ("ndr_pull_struct_blob failed: %s\n",
347 ndr_errstr(ndr_err)));
352 if (DEBUGLEVEL >= 11) {
353 DEBUG(11, ("ctdb_pull_messaging_rec:\n"));
354 NDR_PRINT_DEBUG(messaging_rec, result);
360 static NTSTATUS ctdb_packet_fd_read_sync(struct ctdb_packet_context *ctx)
362 int timeout = lp_ctdb_timeout();
367 return ctdb_packet_fd_read_sync_timeout(ctx, timeout);
371 * Read a full ctdbd request. If we have a messaging context, defer incoming
372 * messages that might come in between.
375 static NTSTATUS ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid,
376 TALLOC_CTX *mem_ctx, void *result)
378 struct ctdb_req_header *hdr;
379 struct req_pull_state state;
384 state.mem_ctx = mem_ctx;
386 while (!ctdb_packet_handler(conn->pkt, ctdb_req_complete,
387 ctdb_req_pull, &state, &status)) {
391 status = ctdb_packet_fd_read_sync(conn->pkt);
393 if (NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_BUSY)) {
396 } else if (NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {
401 if (!NT_STATUS_IS_OK(status)) {
402 DEBUG(0, ("packet_fd_read failed: %s\n", nt_errstr(status)));
403 cluster_fatal("ctdbd died\n");
407 if (!NT_STATUS_IS_OK(status)) {
408 DEBUG(0, ("Could not read ctdb_packet: %s\n", nt_errstr(status)));
409 cluster_fatal("ctdbd died\n");
412 hdr = (struct ctdb_req_header *)state.req.data;
414 DEBUG(11, ("Received ctdb packet\n"));
415 ctdb_packet_dump(hdr);
417 if (hdr->operation == CTDB_REQ_MESSAGE) {
418 struct tevent_timer *evt;
419 struct deferred_msg_state *msg_state;
420 struct ctdb_req_message *msg = (struct ctdb_req_message *)hdr;
422 if (conn->msg_ctx == NULL) {
423 DEBUG(1, ("Got a message without having a msg ctx, "
424 "dropping msg %llu\n",
425 (long long unsigned)msg->srvid));
429 if ((conn->release_ip_handler != NULL)
430 && (msg->srvid == CTDB_SRVID_RELEASE_IP)) {
431 /* must be dispatched immediately */
432 DEBUG(10, ("received CTDB_SRVID_RELEASE_IP\n"));
433 conn->release_ip_handler((const char *)msg->data,
434 conn->release_ip_priv);
439 if ((msg->srvid == CTDB_SRVID_RECONFIGURE)
440 || (msg->srvid == CTDB_SRVID_SAMBA_NOTIFY)) {
442 DEBUG(1, ("ctdb_read_req: Got %s message\n",
443 (msg->srvid == CTDB_SRVID_RECONFIGURE)
444 ? "cluster reconfigure" : "SAMBA_NOTIFY"));
446 messaging_send(conn->msg_ctx,
447 messaging_server_id(conn->msg_ctx),
448 MSG_SMB_BRL_VALIDATE, &data_blob_null);
449 messaging_send(conn->msg_ctx,
450 messaging_server_id(conn->msg_ctx),
451 MSG_DBWRAP_G_LOCK_RETRY,
457 msg_state = talloc(NULL, struct deferred_msg_state);
458 if (msg_state == NULL) {
459 DEBUG(0, ("talloc failed\n"));
464 if (!(msg_state->rec = ctdb_pull_messaging_rec(
465 msg_state, state.req.length, msg))) {
466 DEBUG(0, ("ctdbd_pull_messaging_rec failed\n"));
467 TALLOC_FREE(msg_state);
474 msg_state->msg_ctx = conn->msg_ctx;
477 * We're waiting for a call reply, but an async message has
478 * crossed. Defer dispatching to the toplevel event loop.
480 evt = tevent_add_timer(conn->msg_ctx->event_ctx,
481 conn->msg_ctx->event_ctx,
483 deferred_message_dispatch,
486 DEBUG(0, ("event_add_timed failed\n"));
487 TALLOC_FREE(msg_state);
495 if ((reqid != 0) && (hdr->reqid != reqid)) {
496 /* we got the wrong reply */
497 DEBUG(0,("Discarding mismatched ctdb reqid %u should have "
498 "been %u\n", hdr->reqid, reqid));
503 *((void **)result) = talloc_move(mem_ctx, &hdr);
509 * Get us a ctdbd connection
512 static NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
513 struct ctdbd_connection **pconn)
515 struct ctdbd_connection *conn;
518 if (!(conn = talloc_zero(mem_ctx, struct ctdbd_connection))) {
519 DEBUG(0, ("talloc failed\n"));
520 return NT_STATUS_NO_MEMORY;
523 status = ctdbd_connect(conn, &conn->pkt);
525 if (!NT_STATUS_IS_OK(status)) {
526 DEBUG(10, ("ctdbd_connect failed: %s\n", nt_errstr(status)));
530 status = get_cluster_vnn(conn, &conn->our_vnn);
532 if (!NT_STATUS_IS_OK(status)) {
533 DEBUG(10, ("get_cluster_vnn failed: %s\n", nt_errstr(status)));
537 if (!ctdbd_working(conn, conn->our_vnn)) {
538 DEBUG(2, ("Node is not working, can not connect\n"));
539 status = NT_STATUS_INTERNAL_DB_ERROR;
543 generate_random_buffer((unsigned char *)&conn->rand_srvid,
544 sizeof(conn->rand_srvid));
546 status = register_with_ctdbd(conn, conn->rand_srvid);
548 if (!NT_STATUS_IS_OK(status)) {
549 DEBUG(5, ("Could not register random srvid: %s\n",
563 * Get us a ctdbd connection and register us as a process
566 NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
567 struct ctdbd_connection **pconn)
569 struct ctdbd_connection *conn;
572 status = ctdbd_init_connection(mem_ctx, &conn);
574 if (!NT_STATUS_IS_OK(status)) {
578 status = register_with_ctdbd(conn, (uint64_t)getpid());
579 if (!NT_STATUS_IS_OK(status)) {
583 status = register_with_ctdbd(conn, MSG_SRVID_SAMBA);
584 if (!NT_STATUS_IS_OK(status)) {
588 status = register_with_ctdbd(conn, CTDB_SRVID_SAMBA_NOTIFY);
589 if (!NT_STATUS_IS_OK(status)) {
601 struct messaging_context *ctdb_conn_msg_ctx(struct ctdbd_connection *conn)
603 return conn->msg_ctx;
606 int ctdbd_conn_get_fd(struct ctdbd_connection *conn)
608 return ctdb_packet_get_fd(conn->pkt);
612 * Packet handler to receive and handle a ctdb message
614 static NTSTATUS ctdb_handle_message(uint8_t *buf, size_t length,
617 struct ctdbd_connection *conn = talloc_get_type_abort(
618 private_data, struct ctdbd_connection);
619 struct ctdb_req_message *msg;
620 struct messaging_rec *msg_rec;
622 msg = (struct ctdb_req_message *)buf;
624 if (msg->hdr.operation != CTDB_REQ_MESSAGE) {
625 DEBUG(0, ("Received async msg of type %u, discarding\n",
626 msg->hdr.operation));
628 return NT_STATUS_INVALID_PARAMETER;
631 if ((conn->release_ip_handler != NULL)
632 && (msg->srvid == CTDB_SRVID_RELEASE_IP)) {
633 /* must be dispatched immediately */
634 DEBUG(10, ("received CTDB_SRVID_RELEASE_IP\n"));
635 conn->release_ip_handler((const char *)msg->data,
636 conn->release_ip_priv);
641 SMB_ASSERT(conn->msg_ctx != NULL);
643 if ((msg->srvid == CTDB_SRVID_RECONFIGURE)
644 || (msg->srvid == CTDB_SRVID_SAMBA_NOTIFY)){
645 DEBUG(0,("Got cluster reconfigure message\n"));
647 * when the cluster is reconfigured or someone of the
648 * family has passed away (SAMBA_NOTIFY), we need to
649 * clean the brl database
651 messaging_send(conn->msg_ctx,
652 messaging_server_id(conn->msg_ctx),
653 MSG_SMB_BRL_VALIDATE, &data_blob_null);
655 messaging_send(conn->msg_ctx,
656 messaging_server_id(conn->msg_ctx),
657 MSG_DBWRAP_G_LOCK_RETRY,
664 /* only messages to our pid or the broadcast are valid here */
665 if (msg->srvid != getpid() && msg->srvid != MSG_SRVID_SAMBA) {
666 DEBUG(0,("Got unexpected message with srvid=%llu\n",
667 (unsigned long long)msg->srvid));
672 if (!(msg_rec = ctdb_pull_messaging_rec(NULL, length, msg))) {
673 DEBUG(10, ("ctdb_pull_messaging_rec failed\n"));
675 return NT_STATUS_NO_MEMORY;
678 messaging_dispatch_rec(conn->msg_ctx, msg_rec);
680 TALLOC_FREE(msg_rec);
686 * The ctdbd socket is readable asynchronuously
689 static void ctdbd_socket_handler(struct tevent_context *event_ctx,
690 struct tevent_fd *event,
694 struct ctdbd_connection *conn = talloc_get_type_abort(
695 private_data, struct ctdbd_connection);
699 status = ctdb_packet_fd_read(conn->pkt);
701 if (!NT_STATUS_IS_OK(status)) {
702 DEBUG(0, ("packet_fd_read failed: %s\n", nt_errstr(status)));
703 cluster_fatal("ctdbd died\n");
706 while (ctdb_packet_handler(conn->pkt, ctdb_req_complete,
707 ctdb_handle_message, conn, &status)) {
708 if (!NT_STATUS_IS_OK(status)) {
709 DEBUG(10, ("could not handle incoming message: %s\n",
716 * Prepare a ctdbd connection to receive messages
719 NTSTATUS ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
720 struct messaging_context *msg_ctx)
722 SMB_ASSERT(conn->msg_ctx == NULL);
723 SMB_ASSERT(conn->fde == NULL);
725 if (!(conn->fde = tevent_add_fd(msg_ctx->event_ctx, conn,
726 ctdb_packet_get_fd(conn->pkt),
728 ctdbd_socket_handler,
730 DEBUG(0, ("event_add_fd failed\n"));
731 return NT_STATUS_NO_MEMORY;
734 conn->msg_ctx = msg_ctx;
740 * Send a messaging message across a ctdbd
743 NTSTATUS ctdbd_messaging_send(struct ctdbd_connection *conn,
744 uint32_t dst_vnn, uint64_t dst_srvid,
745 struct messaging_rec *msg)
749 enum ndr_err_code ndr_err;
751 ndr_err = ndr_push_struct_blob(
752 &blob, talloc_tos(), msg,
753 (ndr_push_flags_fn_t)ndr_push_messaging_rec);
755 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
756 DEBUG(0, ("ndr_push_struct_blob failed: %s\n",
757 ndr_errstr(ndr_err)));
758 return ndr_map_error2ntstatus(ndr_err);
761 status = ctdbd_messaging_send_blob(conn, dst_vnn, dst_srvid,
762 blob.data, blob.length);
763 TALLOC_FREE(blob.data);
767 NTSTATUS ctdbd_messaging_send_blob(struct ctdbd_connection *conn,
768 uint32_t dst_vnn, uint64_t dst_srvid,
769 const uint8_t *buf, size_t buflen)
771 struct ctdb_req_message r;
774 r.hdr.length = offsetof(struct ctdb_req_message, data) + buflen;
775 r.hdr.ctdb_magic = CTDB_MAGIC;
776 r.hdr.ctdb_version = CTDB_VERSION;
777 r.hdr.generation = 1;
778 r.hdr.operation = CTDB_REQ_MESSAGE;
779 r.hdr.destnode = dst_vnn;
780 r.hdr.srcnode = conn->our_vnn;
785 DEBUG(10, ("ctdbd_messaging_send: Sending ctdb packet\n"));
786 ctdb_packet_dump(&r.hdr);
788 status = ctdb_packet_send(
790 data_blob_const(&r, offsetof(struct ctdb_req_message, data)),
791 data_blob_const(buf, buflen));
793 if (!NT_STATUS_IS_OK(status)) {
794 DEBUG(0, ("ctdb_packet_send failed: %s\n", nt_errstr(status)));
798 status = ctdb_packet_flush(conn->pkt);
799 if (!NT_STATUS_IS_OK(status)) {
800 DEBUG(3, ("write to ctdbd failed: %s\n", nt_errstr(status)));
801 cluster_fatal("cluster dispatch daemon msg write error\n");
807 * send/recv a generic ctdb control message
809 static NTSTATUS ctdbd_control(struct ctdbd_connection *conn,
810 uint32_t vnn, uint32_t opcode,
811 uint64_t srvid, uint32_t flags,
813 TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
816 struct ctdb_req_control req;
817 struct ctdb_reply_control *reply = NULL;
818 struct ctdbd_connection *new_conn = NULL;
822 status = ctdbd_init_connection(NULL, &new_conn);
824 if (!NT_STATUS_IS_OK(status)) {
825 DEBUG(10, ("Could not init temp connection: %s\n",
834 req.hdr.length = offsetof(struct ctdb_req_control, data) + data.dsize;
835 req.hdr.ctdb_magic = CTDB_MAGIC;
836 req.hdr.ctdb_version = CTDB_VERSION;
837 req.hdr.operation = CTDB_REQ_CONTROL;
838 req.hdr.reqid = ctdbd_next_reqid(conn);
839 req.hdr.destnode = vnn;
842 req.datalen = data.dsize;
845 DEBUG(10, ("ctdbd_control: Sending ctdb packet\n"));
846 ctdb_packet_dump(&req.hdr);
848 status = ctdb_packet_send(
850 data_blob_const(&req, offsetof(struct ctdb_req_control, data)),
851 data_blob_const(data.dptr, data.dsize));
853 if (!NT_STATUS_IS_OK(status)) {
854 DEBUG(3, ("ctdb_packet_send failed: %s\n", nt_errstr(status)));
858 status = ctdb_packet_flush(conn->pkt);
860 if (!NT_STATUS_IS_OK(status)) {
861 DEBUG(3, ("write to ctdbd failed: %s\n", nt_errstr(status)));
862 cluster_fatal("cluster dispatch daemon control write error\n");
865 if (flags & CTDB_CTRL_FLAG_NOREPLY) {
866 TALLOC_FREE(new_conn);
873 status = ctdb_read_req(conn, req.hdr.reqid, NULL, (void *)&reply);
875 if (!NT_STATUS_IS_OK(status)) {
876 DEBUG(10, ("ctdb_read_req failed: %s\n", nt_errstr(status)));
880 if (reply->hdr.operation != CTDB_REPLY_CONTROL) {
881 DEBUG(0, ("received invalid reply\n"));
886 if (!(outdata->dptr = (uint8 *)talloc_memdup(
887 mem_ctx, reply->data, reply->datalen))) {
889 return NT_STATUS_NO_MEMORY;
891 outdata->dsize = reply->datalen;
894 (*cstatus) = reply->status;
897 status = NT_STATUS_OK;
900 TALLOC_FREE(new_conn);
906 * see if a remote process exists
908 bool ctdbd_process_exists(struct ctdbd_connection *conn, uint32_t vnn, pid_t pid)
916 if (!ctdb_processes_exist(conn, &id, 1, &result)) {
917 DEBUG(10, ("ctdb_processes_exist failed\n"));
923 bool ctdb_processes_exist(struct ctdbd_connection *conn,
924 const struct server_id *pids, int num_pids,
927 TALLOC_CTX *frame = talloc_stackframe();
933 reqids = talloc_array(talloc_tos(), uint32_t, num_pids);
934 if (reqids == NULL) {
938 for (i=0; i<num_pids; i++) {
939 struct ctdb_req_control req;
943 reqids[i] = ctdbd_next_reqid(conn);
948 * pids[i].pid is uint64_t, scale down to pid_t which
949 * is the wire protocol towards ctdb.
953 DEBUG(10, ("Requesting PID %d/%d, reqid=%d\n",
954 (int)pids[i].vnn, (int)pid,
957 req.hdr.length = offsetof(struct ctdb_req_control, data);
958 req.hdr.length += sizeof(pid);
959 req.hdr.ctdb_magic = CTDB_MAGIC;
960 req.hdr.ctdb_version = CTDB_VERSION;
961 req.hdr.operation = CTDB_REQ_CONTROL;
962 req.hdr.reqid = reqids[i];
963 req.hdr.destnode = pids[i].vnn;
964 req.opcode = CTDB_CONTROL_PROCESS_EXISTS;
966 req.datalen = sizeof(pid);
969 DEBUG(10, ("ctdbd_control: Sending ctdb packet\n"));
970 ctdb_packet_dump(&req.hdr);
972 status = ctdb_packet_send(
975 &req, offsetof(struct ctdb_req_control, data)),
976 data_blob_const(&pid, sizeof(pid)));
977 if (!NT_STATUS_IS_OK(status)) {
978 DEBUG(10, ("ctdb_packet_send failed: %s\n",
984 status = ctdb_packet_flush(conn->pkt);
985 if (!NT_STATUS_IS_OK(status)) {
986 DEBUG(10, ("ctdb_packet_flush failed: %s\n",
993 while (num_received < num_pids) {
994 struct ctdb_reply_control *reply = NULL;
997 status = ctdb_read_req(conn, 0, talloc_tos(), (void *)&reply);
998 if (!NT_STATUS_IS_OK(status)) {
999 DEBUG(10, ("ctdb_read_req failed: %s\n",
1000 nt_errstr(status)));
1004 if (reply->hdr.operation != CTDB_REPLY_CONTROL) {
1005 DEBUG(10, ("Received invalid reply\n"));
1009 reqid = reply->hdr.reqid;
1011 DEBUG(10, ("Received reqid %d\n", (int)reqid));
1013 for (i=0; i<num_pids; i++) {
1014 if (reqid == reqids[i]) {
1018 if (i == num_pids) {
1019 DEBUG(10, ("Received unknown record number %u\n",
1023 results[i] = ((reply->status) == 0);
1034 struct ctdb_vnn_list {
1037 unsigned num_srvids;
1038 unsigned num_filled;
1040 unsigned *pid_indexes;
1044 * Get a list of all vnns mentioned in a list of
1045 * server_ids. vnn_indexes tells where in the vnns array we have to
1048 static bool ctdb_collect_vnns(TALLOC_CTX *mem_ctx,
1049 const struct server_id *pids, unsigned num_pids,
1050 struct ctdb_vnn_list **pvnns,
1051 unsigned *pnum_vnns)
1053 struct ctdb_vnn_list *vnns = NULL;
1054 unsigned *vnn_indexes = NULL;
1055 unsigned i, num_vnns = 0;
1057 vnn_indexes = talloc_array(mem_ctx, unsigned, num_pids);
1058 if (vnn_indexes == NULL) {
1059 DEBUG(1, ("talloc_array failed\n"));
1063 for (i=0; i<num_pids; i++) {
1065 uint32_t vnn = pids[i].vnn;
1067 for (j=0; j<num_vnns; j++) {
1068 if (vnn == vnns[j].vnn) {
1076 * Already in the array
1078 vnns[j].num_srvids += 1;
1081 vnns = talloc_realloc(mem_ctx, vnns, struct ctdb_vnn_list,
1084 DEBUG(1, ("talloc_realloc failed\n"));
1087 vnns[num_vnns].vnn = vnn;
1088 vnns[num_vnns].num_srvids = 1;
1089 vnns[num_vnns].num_filled = 0;
1092 for (i=0; i<num_vnns; i++) {
1093 struct ctdb_vnn_list *vnn = &vnns[i];
1095 vnn->srvids = talloc_array(vnns, uint64_t, vnn->num_srvids);
1096 if (vnn->srvids == NULL) {
1097 DEBUG(1, ("talloc_array failed\n"));
1100 vnn->pid_indexes = talloc_array(vnns, unsigned,
1102 if (vnn->pid_indexes == NULL) {
1103 DEBUG(1, ("talloc_array failed\n"));
1107 for (i=0; i<num_pids; i++) {
1108 struct ctdb_vnn_list *vnn = &vnns[vnn_indexes[i]];
1109 vnn->srvids[vnn->num_filled] = pids[i].unique_id;
1110 vnn->pid_indexes[vnn->num_filled] = i;
1111 vnn->num_filled += 1;
1114 TALLOC_FREE(vnn_indexes);
1116 *pnum_vnns = num_vnns;
1120 TALLOC_FREE(vnn_indexes);
1124 #ifdef HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL
1126 bool ctdb_serverids_exist(struct ctdbd_connection *conn,
1127 const struct server_id *pids, unsigned num_pids,
1130 unsigned i, num_received;
1132 struct ctdb_vnn_list *vnns = NULL;
1134 bool result = false;
1136 if (!ctdb_collect_vnns(talloc_tos(), pids, num_pids,
1137 &vnns, &num_vnns)) {
1138 DEBUG(1, ("ctdb_collect_vnns failed\n"));
1142 for (i=0; i<num_vnns; i++) {
1143 struct ctdb_vnn_list *vnn = &vnns[i];
1144 struct ctdb_req_control req;
1146 vnn->reqid = ctdbd_next_reqid(conn);
1150 DEBUG(10, ("Requesting VNN %d, reqid=%d, num_srvids=%u\n",
1151 (int)vnn->vnn, (int)vnn->reqid, vnn->num_srvids));
1153 req.hdr.length = offsetof(struct ctdb_req_control, data);
1154 req.hdr.ctdb_magic = CTDB_MAGIC;
1155 req.hdr.ctdb_version = CTDB_VERSION;
1156 req.hdr.operation = CTDB_REQ_CONTROL;
1157 req.hdr.reqid = vnn->reqid;
1158 req.hdr.destnode = vnn->vnn;
1159 req.opcode = CTDB_CONTROL_CHECK_SRVIDS;
1161 req.datalen = sizeof(uint64_t) * vnn->num_srvids;
1162 req.hdr.length += req.datalen;
1165 DEBUG(10, ("ctdbd_control: Sending ctdb packet\n"));
1166 ctdb_packet_dump(&req.hdr);
1168 status = ctdb_packet_send(
1171 &req, offsetof(struct ctdb_req_control,
1173 data_blob_const(vnn->srvids, req.datalen));
1174 if (!NT_STATUS_IS_OK(status)) {
1175 DEBUG(1, ("ctdb_packet_send failed: %s\n",
1176 nt_errstr(status)));
1181 status = ctdb_packet_flush(conn->pkt);
1182 if (!NT_STATUS_IS_OK(status)) {
1183 DEBUG(1, ("ctdb_packet_flush failed: %s\n",
1184 nt_errstr(status)));
1190 while (num_received < num_vnns) {
1191 struct ctdb_reply_control *reply = NULL;
1192 struct ctdb_vnn_list *vnn;
1194 uint8_t *reply_data;
1196 status = ctdb_read_req(conn, 0, talloc_tos(), (void *)&reply);
1197 if (!NT_STATUS_IS_OK(status)) {
1198 DEBUG(1, ("ctdb_read_req failed: %s\n",
1199 nt_errstr(status)));
1203 if (reply->hdr.operation != CTDB_REPLY_CONTROL) {
1204 DEBUG(1, ("Received invalid reply %u\n",
1205 (unsigned)reply->hdr.operation));
1209 reqid = reply->hdr.reqid;
1211 DEBUG(10, ("Received reqid %d\n", (int)reqid));
1213 for (i=0; i<num_vnns; i++) {
1214 if (reqid == vnns[i].reqid) {
1218 if (i == num_vnns) {
1219 DEBUG(1, ("Received unknown reqid number %u\n",
1224 DEBUG(10, ("Found index %u\n", i));
1228 DEBUG(10, ("Received vnn %u, vnn->num_srvids %u, datalen %u\n",
1229 (unsigned)vnn->vnn, vnn->num_srvids,
1230 (unsigned)reply->datalen));
1232 if (reply->datalen >= ((vnn->num_srvids+7)/8)) {
1236 reply_data = reply->data;
1239 * Got an error reply
1241 DEBUG(5, ("Received short reply len %d, status %u, "
1243 (unsigned)reply->datalen,
1244 (unsigned)reply->status,
1245 (unsigned)reply->errorlen));
1246 dump_data(5, reply->data, reply->errorlen);
1249 * This will trigger everything set to false
1254 for (i=0; i<vnn->num_srvids; i++) {
1255 int idx = vnn->pid_indexes[i];
1257 if (pids[i].unique_id ==
1258 SERVERID_UNIQUE_ID_NOT_TO_VERIFY) {
1259 results[idx] = true;
1263 (reply_data != NULL) &&
1264 ((reply_data[i/8] & (1<<(i%8))) != 0);
1277 #endif /* HAVE_CTDB_CONTROL_CHECK_SRVIDS_DECL */
1282 char *ctdbd_dbpath(struct ctdbd_connection *conn,
1283 TALLOC_CTX *mem_ctx, uint32_t db_id)
1289 data.dptr = (uint8_t*)&db_id;
1290 data.dsize = sizeof(db_id);
1292 status = ctdbd_control(conn, CTDB_CURRENT_NODE,
1293 CTDB_CONTROL_GETDBPATH, 0, 0, data,
1294 mem_ctx, &data, &cstatus);
1295 if (!NT_STATUS_IS_OK(status) || cstatus != 0) {
1296 DEBUG(0,(__location__ " ctdb_control for getdbpath failed\n"));
1300 return (char *)data.dptr;
1304 * attach to a ctdb database
1306 NTSTATUS ctdbd_db_attach(struct ctdbd_connection *conn,
1307 const char *name, uint32_t *db_id, int tdb_flags)
1312 bool persistent = (tdb_flags & TDB_CLEAR_IF_FIRST) == 0;
1314 data = string_term_tdb_data(name);
1316 status = ctdbd_control(conn, CTDB_CURRENT_NODE,
1318 ? CTDB_CONTROL_DB_ATTACH_PERSISTENT
1319 : CTDB_CONTROL_DB_ATTACH,
1320 tdb_flags, 0, data, NULL, &data, &cstatus);
1321 if (!NT_STATUS_IS_OK(status)) {
1322 DEBUG(0, (__location__ " ctdb_control for db_attach "
1323 "failed: %s\n", nt_errstr(status)));
1327 if (cstatus != 0 || data.dsize != sizeof(uint32_t)) {
1328 DEBUG(0,(__location__ " ctdb_control for db_attach failed\n"));
1329 return NT_STATUS_INTERNAL_ERROR;
1332 *db_id = *(uint32_t *)data.dptr;
1333 talloc_free(data.dptr);
1335 if (!(tdb_flags & TDB_SEQNUM)) {
1336 return NT_STATUS_OK;
1339 data.dptr = (uint8_t *)db_id;
1340 data.dsize = sizeof(*db_id);
1342 status = ctdbd_control(conn, CTDB_CURRENT_NODE,
1343 CTDB_CONTROL_ENABLE_SEQNUM, 0, 0, data,
1344 NULL, NULL, &cstatus);
1345 if (!NT_STATUS_IS_OK(status) || cstatus != 0) {
1346 DEBUG(0,(__location__ " ctdb_control for enable seqnum "
1348 return NT_STATUS_IS_OK(status) ? NT_STATUS_INTERNAL_ERROR :
1352 return NT_STATUS_OK;
1356 * force the migration of a record to this node
1358 NTSTATUS ctdbd_migrate(struct ctdbd_connection *conn, uint32_t db_id,
1361 struct ctdb_req_call req;
1362 struct ctdb_reply_call *reply;
1367 req.hdr.length = offsetof(struct ctdb_req_call, data) + key.dsize;
1368 req.hdr.ctdb_magic = CTDB_MAGIC;
1369 req.hdr.ctdb_version = CTDB_VERSION;
1370 req.hdr.operation = CTDB_REQ_CALL;
1371 req.hdr.reqid = ctdbd_next_reqid(conn);
1372 req.flags = CTDB_IMMEDIATE_MIGRATION;
1373 req.callid = CTDB_NULL_FUNC;
1375 req.keylen = key.dsize;
1377 DEBUG(10, ("ctdbd_migrate: Sending ctdb packet\n"));
1378 ctdb_packet_dump(&req.hdr);
1380 status = ctdb_packet_send(
1382 data_blob_const(&req, offsetof(struct ctdb_req_call, data)),
1383 data_blob_const(key.dptr, key.dsize));
1385 if (!NT_STATUS_IS_OK(status)) {
1386 DEBUG(3, ("ctdb_packet_send failed: %s\n", nt_errstr(status)));
1390 status = ctdb_packet_flush(conn->pkt);
1392 if (!NT_STATUS_IS_OK(status)) {
1393 DEBUG(3, ("write to ctdbd failed: %s\n", nt_errstr(status)));
1394 cluster_fatal("cluster dispatch daemon control write error\n");
1397 status = ctdb_read_req(conn, req.hdr.reqid, NULL, (void *)&reply);
1399 if (!NT_STATUS_IS_OK(status)) {
1400 DEBUG(0, ("ctdb_read_req failed: %s\n", nt_errstr(status)));
1404 if (reply->hdr.operation != CTDB_REPLY_CALL) {
1405 DEBUG(0, ("received invalid reply\n"));
1406 status = NT_STATUS_INTERNAL_ERROR;
1410 status = NT_STATUS_OK;
1418 * Fetch a record and parse it
1420 NTSTATUS ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
1421 TDB_DATA key, bool local_copy,
1422 void (*parser)(TDB_DATA key, TDB_DATA data,
1423 void *private_data),
1426 struct ctdb_req_call req;
1427 struct ctdb_reply_call *reply;
1431 #ifdef HAVE_CTDB_WANT_READONLY_DECL
1432 flags = local_copy ? CTDB_WANT_READONLY : 0;
1439 req.hdr.length = offsetof(struct ctdb_req_call, data) + key.dsize;
1440 req.hdr.ctdb_magic = CTDB_MAGIC;
1441 req.hdr.ctdb_version = CTDB_VERSION;
1442 req.hdr.operation = CTDB_REQ_CALL;
1443 req.hdr.reqid = ctdbd_next_reqid(conn);
1445 req.callid = CTDB_FETCH_FUNC;
1447 req.keylen = key.dsize;
1449 status = ctdb_packet_send(
1451 data_blob_const(&req, offsetof(struct ctdb_req_call, data)),
1452 data_blob_const(key.dptr, key.dsize));
1454 if (!NT_STATUS_IS_OK(status)) {
1455 DEBUG(3, ("ctdb_packet_send failed: %s\n", nt_errstr(status)));
1459 status = ctdb_packet_flush(conn->pkt);
1461 if (!NT_STATUS_IS_OK(status)) {
1462 DEBUG(3, ("write to ctdbd failed: %s\n", nt_errstr(status)));
1463 cluster_fatal("cluster dispatch daemon control write error\n");
1466 status = ctdb_read_req(conn, req.hdr.reqid, NULL, (void *)&reply);
1468 if (!NT_STATUS_IS_OK(status)) {
1469 DEBUG(0, ("ctdb_read_req failed: %s\n", nt_errstr(status)));
1473 if (reply->hdr.operation != CTDB_REPLY_CALL) {
1474 DEBUG(0, ("received invalid reply\n"));
1475 status = NT_STATUS_INTERNAL_ERROR;
1479 if (reply->datalen == 0) {
1481 * Treat an empty record as non-existing
1483 status = NT_STATUS_NOT_FOUND;
1487 parser(key, make_tdb_data(&reply->data[0], reply->datalen),
1490 status = NT_STATUS_OK;
1496 struct ctdbd_traverse_state {
1497 void (*fn)(TDB_DATA key, TDB_DATA data, void *private_data);
1502 * Handle a traverse record coming in on the ctdbd connection
1505 static NTSTATUS ctdb_traverse_handler(uint8_t *buf, size_t length,
1508 struct ctdbd_traverse_state *state =
1509 (struct ctdbd_traverse_state *)private_data;
1511 struct ctdb_req_message *m;
1512 struct ctdb_rec_data *d;
1515 m = (struct ctdb_req_message *)buf;
1517 if (length < sizeof(*m) || m->hdr.length != length) {
1518 DEBUG(0, ("Got invalid message of length %d\n", (int)length));
1520 return NT_STATUS_UNEXPECTED_IO_ERROR;
1523 d = (struct ctdb_rec_data *)&m->data[0];
1524 if (m->datalen < sizeof(uint32_t) || m->datalen != d->length) {
1525 DEBUG(0, ("Got invalid traverse data of length %d\n",
1528 return NT_STATUS_UNEXPECTED_IO_ERROR;
1531 key.dsize = d->keylen;
1532 key.dptr = &d->data[0];
1533 data.dsize = d->datalen;
1534 data.dptr = &d->data[d->keylen];
1536 if (key.dsize == 0 && data.dsize == 0) {
1537 /* end of traverse */
1538 return NT_STATUS_END_OF_FILE;
1541 if (data.dsize < sizeof(struct ctdb_ltdb_header)) {
1542 DEBUG(0, ("Got invalid ltdb header length %d\n",
1545 return NT_STATUS_UNEXPECTED_IO_ERROR;
1547 data.dsize -= sizeof(struct ctdb_ltdb_header);
1548 data.dptr += sizeof(struct ctdb_ltdb_header);
1551 state->fn(key, data, state->private_data);
1555 return NT_STATUS_OK;
1559 Traverse a ctdb database. This uses a kind-of hackish way to open a second
1560 connection to ctdbd to avoid the hairy recursive and async problems with
1564 NTSTATUS ctdbd_traverse(uint32_t db_id,
1565 void (*fn)(TDB_DATA key, TDB_DATA data,
1566 void *private_data),
1569 struct ctdbd_connection *conn;
1573 struct ctdb_traverse_start t;
1575 struct ctdbd_traverse_state state;
1578 status = ctdbd_init_connection(NULL, &conn);
1580 if (!NT_STATUS_IS_OK(status)) {
1581 DEBUG(0, ("ctdbd_init_connection failed: %s\n",
1582 nt_errstr(status)));
1587 t.srvid = conn->rand_srvid;
1588 t.reqid = ctdbd_next_reqid(conn);
1590 data.dptr = (uint8_t *)&t;
1591 data.dsize = sizeof(t);
1593 status = ctdbd_control(conn, CTDB_CURRENT_NODE,
1594 CTDB_CONTROL_TRAVERSE_START, conn->rand_srvid, 0,
1595 data, NULL, NULL, &cstatus);
1597 if (!NT_STATUS_IS_OK(status) || (cstatus != 0)) {
1599 DEBUG(0,("ctdbd_control failed: %s, %d\n", nt_errstr(status),
1602 if (NT_STATUS_IS_OK(status)) {
1604 * We need a mapping here
1606 status = NT_STATUS_UNSUCCESSFUL;
1612 state.private_data = private_data;
1616 status = NT_STATUS_OK;
1618 if (ctdb_packet_handler(conn->pkt, ctdb_req_complete,
1619 ctdb_traverse_handler, &state, &status)) {
1621 if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
1622 status = NT_STATUS_OK;
1627 * There might be more in the queue
1632 if (!NT_STATUS_IS_OK(status)) {
1636 status = ctdb_packet_fd_read_sync(conn->pkt);
1638 if (NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {
1640 * There might be more in the queue
1645 if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
1646 status = NT_STATUS_OK;
1650 if (!NT_STATUS_IS_OK(status)) {
1651 DEBUG(0, ("ctdb_packet_fd_read_sync failed: %s\n", nt_errstr(status)));
1652 cluster_fatal("ctdbd died\n");
1662 This is used to canonicalize a ctdb_sock_addr structure.
1664 static void smbd_ctdb_canonicalize_ip(const struct sockaddr_storage *in,
1665 struct sockaddr_storage *out)
1667 memcpy(out, in, sizeof (*out));
1670 if (in->ss_family == AF_INET6) {
1671 const char prefix[12] = { 0,0,0,0,0,0,0,0,0,0,0xff,0xff };
1672 const struct sockaddr_in6 *in6 =
1673 (const struct sockaddr_in6 *)in;
1674 struct sockaddr_in *out4 = (struct sockaddr_in *)out;
1675 if (memcmp(&in6->sin6_addr, prefix, 12) == 0) {
1676 memset(out, 0, sizeof(*out));
1677 #ifdef HAVE_SOCK_SIN_LEN
1678 out4->sin_len = sizeof(*out);
1680 out4->sin_family = AF_INET;
1681 out4->sin_port = in6->sin6_port;
1682 memcpy(&out4->sin_addr, &in6->sin6_addr.s6_addr[12], 4);
1689 * Register us as a server for a particular tcp connection
1692 NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
1693 const struct sockaddr_storage *_server,
1694 const struct sockaddr_storage *_client,
1695 void (*release_ip_handler)(const char *ip_addr,
1696 void *private_data),
1700 * we still use ctdb_control_tcp for ipv4
1701 * because we want to work against older ctdb
1702 * versions at runtime
1704 struct ctdb_control_tcp p4;
1705 #ifdef HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR
1706 struct ctdb_control_tcp_addr p;
1710 struct sockaddr_storage client;
1711 struct sockaddr_storage server;
1714 * Only one connection so far
1716 SMB_ASSERT(conn->release_ip_handler == NULL);
1718 smbd_ctdb_canonicalize_ip(_client, &client);
1719 smbd_ctdb_canonicalize_ip(_server, &server);
1721 switch (client.ss_family) {
1723 memcpy(&p4.dest, &server, sizeof(p4.dest));
1724 memcpy(&p4.src, &client, sizeof(p4.src));
1725 data.dptr = (uint8_t *)&p4;
1726 data.dsize = sizeof(p4);
1728 #ifdef HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR
1730 memcpy(&p.dest.ip6, &server, sizeof(p.dest.ip6));
1731 memcpy(&p.src.ip6, &client, sizeof(p.src.ip6));
1732 data.dptr = (uint8_t *)&p;
1733 data.dsize = sizeof(p);
1737 return NT_STATUS_INTERNAL_ERROR;
1740 conn->release_ip_handler = release_ip_handler;
1741 conn->release_ip_priv = private_data;
1744 * We want to be told about IP releases
1747 status = register_with_ctdbd(conn, CTDB_SRVID_RELEASE_IP);
1748 if (!NT_STATUS_IS_OK(status)) {
1753 * inform ctdb of our tcp connection, so if IP takeover happens ctdb
1754 * can send an extra ack to trigger a reset for our client, so it
1755 * immediately reconnects
1757 return ctdbd_control(conn, CTDB_CURRENT_NODE,
1758 CTDB_CONTROL_TCP_CLIENT, 0,
1759 CTDB_CTRL_FLAG_NOREPLY, data, NULL, NULL, NULL);
1763 * We want to handle reconfigure events
1765 NTSTATUS ctdbd_register_reconfigure(struct ctdbd_connection *conn)
1767 return register_with_ctdbd(conn, CTDB_SRVID_RECONFIGURE);
1771 call a control on the local node
1773 NTSTATUS ctdbd_control_local(struct ctdbd_connection *conn, uint32_t opcode,
1774 uint64_t srvid, uint32_t flags, TDB_DATA data,
1775 TALLOC_CTX *mem_ctx, TDB_DATA *outdata,
1778 return ctdbd_control(conn, CTDB_CURRENT_NODE, opcode, srvid, flags, data, mem_ctx, outdata, cstatus);
1781 NTSTATUS ctdb_watch_us(struct ctdbd_connection *conn)
1783 struct ctdb_client_notify_register reg_data;
1788 reg_data.srvid = CTDB_SRVID_SAMBA_NOTIFY;
1790 reg_data.notify_data[0] = 0;
1792 struct_len = offsetof(struct ctdb_client_notify_register,
1793 notify_data) + reg_data.len;
1795 status = ctdbd_control_local(
1796 conn, CTDB_CONTROL_REGISTER_NOTIFY, conn->rand_srvid, 0,
1797 make_tdb_data((uint8_t *)®_data, struct_len),
1798 NULL, NULL, &cstatus);
1799 if (!NT_STATUS_IS_OK(status)) {
1800 DEBUG(1, ("ctdbd_control_local failed: %s\n",
1801 nt_errstr(status)));
1806 NTSTATUS ctdb_unwatch(struct ctdbd_connection *conn)
1808 struct ctdb_client_notify_deregister dereg_data;
1812 dereg_data.srvid = CTDB_SRVID_SAMBA_NOTIFY;
1814 status = ctdbd_control_local(
1815 conn, CTDB_CONTROL_DEREGISTER_NOTIFY, conn->rand_srvid, 0,
1816 make_tdb_data((uint8_t *)&dereg_data, sizeof(dereg_data)),
1817 NULL, NULL, &cstatus);
1818 if (!NT_STATUS_IS_OK(status)) {
1819 DEBUG(1, ("ctdbd_control_local failed: %s\n",
1820 nt_errstr(status)));
1827 NTSTATUS ctdbd_messaging_send_blob(struct ctdbd_connection *conn,
1828 uint32_t dst_vnn, uint64_t dst_srvid,
1829 const uint8_t *buf, size_t buflen)
1831 return NT_STATUS_NOT_IMPLEMENTED;