2 CTDB protocol marshalling
4 Copyright (C) Amitay Isaacs 2015
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "system/network.h"
27 #include "protocol_api.h"
28 #include "protocol_private.h"
30 static size_t ctdb_req_control_data_len(struct ctdb_req_control_data
*cd
)
40 case CTDB_CONTROL_PROCESS_EXISTS
:
41 len
= ctdb_pid_len(&cd
->data
.pid
);
44 case CTDB_CONTROL_STATISTICS
:
47 case CTDB_CONTROL_PING
:
50 case CTDB_CONTROL_GETDBPATH
:
51 len
= ctdb_uint32_len(&cd
->data
.db_id
);
54 case CTDB_CONTROL_GETVNNMAP
:
57 case CTDB_CONTROL_SETVNNMAP
:
58 len
= ctdb_vnn_map_len(cd
->data
.vnnmap
);
61 case CTDB_CONTROL_GET_DEBUG
:
64 case CTDB_CONTROL_SET_DEBUG
:
65 len
= ctdb_uint32_len(&cd
->data
.loglevel
);
68 case CTDB_CONTROL_GET_DBMAP
:
71 case CTDB_CONTROL_GET_RECMODE
:
74 case CTDB_CONTROL_SET_RECMODE
:
75 len
= ctdb_uint32_len(&cd
->data
.recmode
);
78 case CTDB_CONTROL_STATISTICS_RESET
:
81 case CTDB_CONTROL_DB_ATTACH
:
82 len
= ctdb_string_len(&cd
->data
.db_name
);
85 case CTDB_CONTROL_TRAVERSE_START
:
86 len
= ctdb_traverse_start_len(cd
->data
.traverse_start
);
89 case CTDB_CONTROL_TRAVERSE_ALL
:
90 len
= ctdb_traverse_all_len(cd
->data
.traverse_all
);
93 case CTDB_CONTROL_TRAVERSE_DATA
:
94 len
= ctdb_rec_data_len(cd
->data
.rec_data
);
97 case CTDB_CONTROL_REGISTER_SRVID
:
100 case CTDB_CONTROL_DEREGISTER_SRVID
:
103 case CTDB_CONTROL_GET_DBNAME
:
104 len
= ctdb_uint32_len(&cd
->data
.db_id
);
107 case CTDB_CONTROL_ENABLE_SEQNUM
:
108 len
= ctdb_uint32_len(&cd
->data
.db_id
);
111 case CTDB_CONTROL_UPDATE_SEQNUM
:
112 len
= ctdb_uint32_len(&cd
->data
.db_id
);
115 case CTDB_CONTROL_DUMP_MEMORY
:
118 case CTDB_CONTROL_GET_PID
:
121 case CTDB_CONTROL_GET_RECMASTER
:
124 case CTDB_CONTROL_SET_RECMASTER
:
125 len
= ctdb_uint32_len(&cd
->data
.recmaster
);
128 case CTDB_CONTROL_FREEZE
:
131 case CTDB_CONTROL_GET_PNN
:
134 case CTDB_CONTROL_SHUTDOWN
:
137 case CTDB_CONTROL_TCP_CLIENT
:
138 len
= ctdb_connection_len(cd
->data
.conn
);
141 case CTDB_CONTROL_TCP_ADD
:
142 len
= ctdb_connection_len(cd
->data
.conn
);
145 case CTDB_CONTROL_TCP_REMOVE
:
146 len
= ctdb_connection_len(cd
->data
.conn
);
149 case CTDB_CONTROL_STARTUP
:
152 case CTDB_CONTROL_SET_TUNABLE
:
153 len
= ctdb_tunable_len(cd
->data
.tunable
);
156 case CTDB_CONTROL_GET_TUNABLE
:
157 len
= ctdb_stringn_len(&cd
->data
.tun_var
);
160 case CTDB_CONTROL_LIST_TUNABLES
:
163 case CTDB_CONTROL_MODIFY_FLAGS
:
164 len
= ctdb_node_flag_change_len(cd
->data
.flag_change
);
167 case CTDB_CONTROL_GET_ALL_TUNABLES
:
170 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
171 len
= ctdb_sock_addr_len(cd
->data
.addr
);
174 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
175 len
= ctdb_tickle_list_len(cd
->data
.tickles
);
178 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
179 len
= ctdb_string_len(&cd
->data
.db_name
);
182 case CTDB_CONTROL_UPDATE_RECORD
:
183 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
186 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
187 len
= ctdb_addr_info_len(cd
->data
.addr_info
);
190 case CTDB_CONTROL_WIPE_DATABASE
:
191 len
= ctdb_transdb_len(cd
->data
.transdb
);
194 case CTDB_CONTROL_UPTIME
:
197 case CTDB_CONTROL_START_RECOVERY
:
200 case CTDB_CONTROL_END_RECOVERY
:
203 case CTDB_CONTROL_RELOAD_NODES_FILE
:
206 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
207 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
210 case CTDB_CONTROL_ADD_PUBLIC_IP
:
211 len
= ctdb_addr_info_len(cd
->data
.addr_info
);
214 case CTDB_CONTROL_DEL_PUBLIC_IP
:
215 len
= ctdb_addr_info_len(cd
->data
.addr_info
);
218 case CTDB_CONTROL_GET_CAPABILITIES
:
221 case CTDB_CONTROL_RECD_PING
:
224 case CTDB_CONTROL_RELEASE_IP
:
225 len
= ctdb_public_ip_len(cd
->data
.pubip
);
228 case CTDB_CONTROL_TAKEOVER_IP
:
229 len
= ctdb_public_ip_len(cd
->data
.pubip
);
232 case CTDB_CONTROL_GET_PUBLIC_IPS
:
235 case CTDB_CONTROL_GET_NODEMAP
:
238 case CTDB_CONTROL_TRAVERSE_KILL
:
239 len
= ctdb_traverse_start_len(cd
->data
.traverse_start
);
242 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
243 len
= ctdb_double_len(&cd
->data
.reclock_latency
);
246 case CTDB_CONTROL_GET_RECLOCK_FILE
:
249 case CTDB_CONTROL_STOP_NODE
:
252 case CTDB_CONTROL_CONTINUE_NODE
:
255 case CTDB_CONTROL_SET_LMASTERROLE
:
256 len
= ctdb_uint32_len(&cd
->data
.role
);
259 case CTDB_CONTROL_SET_RECMASTERROLE
:
260 len
= ctdb_uint32_len(&cd
->data
.role
);
263 case CTDB_CONTROL_SET_BAN_STATE
:
264 len
= ctdb_ban_state_len(cd
->data
.ban_state
);
267 case CTDB_CONTROL_GET_BAN_STATE
:
270 case CTDB_CONTROL_REGISTER_NOTIFY
:
271 len
= ctdb_notify_data_len(cd
->data
.notify
);
274 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
275 len
= ctdb_uint64_len(&cd
->data
.srvid
);
278 case CTDB_CONTROL_TRANS3_COMMIT
:
279 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
282 case CTDB_CONTROL_GET_DB_SEQNUM
:
284 len
= ctdb_uint32_len(&cd
->data
.db_id
) + ctdb_uint32_len(&u32
);
287 case CTDB_CONTROL_DB_SET_HEALTHY
:
288 len
= ctdb_uint32_len(&cd
->data
.db_id
);
291 case CTDB_CONTROL_DB_GET_HEALTH
:
292 len
= ctdb_uint32_len(&cd
->data
.db_id
);
295 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
296 len
= ctdb_sock_addr_len(cd
->data
.addr
);
299 case CTDB_CONTROL_GET_IFACES
:
302 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
303 len
= ctdb_iface_len(cd
->data
.iface
);
306 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
307 len
= ctdb_connection_len(cd
->data
.conn
);
310 case CTDB_CONTROL_GET_STAT_HISTORY
:
313 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
314 len
= ctdb_key_data_len(cd
->data
.key
);
317 case CTDB_CONTROL_SET_DB_READONLY
:
318 len
= ctdb_uint32_len(&cd
->data
.db_id
);
321 case CTDB_CONTROL_TRAVERSE_START_EXT
:
322 len
= ctdb_traverse_start_ext_len(cd
->data
.traverse_start_ext
);
325 case CTDB_CONTROL_GET_DB_STATISTICS
:
326 len
= ctdb_uint32_len(&cd
->data
.db_id
);
329 case CTDB_CONTROL_SET_DB_STICKY
:
330 len
= ctdb_uint32_len(&cd
->data
.db_id
);
333 case CTDB_CONTROL_RELOAD_PUBLIC_IPS
:
336 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
337 len
= ctdb_traverse_all_ext_len(cd
->data
.traverse_all_ext
);
340 case CTDB_CONTROL_IPREALLOCATED
:
343 case CTDB_CONTROL_GET_RUNSTATE
:
346 case CTDB_CONTROL_DB_DETACH
:
347 len
= ctdb_uint32_len(&cd
->data
.db_id
);
350 case CTDB_CONTROL_GET_NODES_FILE
:
353 case CTDB_CONTROL_DB_FREEZE
:
354 len
= ctdb_uint32_len(&cd
->data
.db_id
);
357 case CTDB_CONTROL_DB_THAW
:
358 len
= ctdb_uint32_len(&cd
->data
.db_id
);
361 case CTDB_CONTROL_DB_TRANSACTION_START
:
362 len
= ctdb_transdb_len(cd
->data
.transdb
);
365 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
366 len
= ctdb_transdb_len(cd
->data
.transdb
);
369 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
370 len
= ctdb_uint32_len(&cd
->data
.db_id
);
373 case CTDB_CONTROL_DB_PULL
:
374 len
= ctdb_pulldb_ext_len(cd
->data
.pulldb_ext
);
377 case CTDB_CONTROL_DB_PUSH_START
:
378 len
= ctdb_pulldb_ext_len(cd
->data
.pulldb_ext
);
381 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
382 len
= ctdb_uint32_len(&cd
->data
.db_id
);
385 case CTDB_CONTROL_DB_OPEN_FLAGS
:
386 len
= ctdb_uint32_len(&cd
->data
.db_id
);
389 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
390 len
= ctdb_string_len(&cd
->data
.db_name
);
393 case CTDB_CONTROL_CHECK_PID_SRVID
:
394 len
= ctdb_pid_srvid_len(cd
->data
.pid_srvid
);
397 case CTDB_CONTROL_TUNNEL_REGISTER
:
400 case CTDB_CONTROL_TUNNEL_DEREGISTER
:
403 case CTDB_CONTROL_VACUUM_FETCH
:
404 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
407 case CTDB_CONTROL_DB_VACUUM
:
408 len
= ctdb_db_vacuum_len(cd
->data
.db_vacuum
);
411 case CTDB_CONTROL_ECHO_DATA
:
412 len
= ctdb_echo_data_len(cd
->data
.echo_data
);
415 case CTDB_CONTROL_DISABLE_NODE
:
418 case CTDB_CONTROL_ENABLE_NODE
:
425 static void ctdb_req_control_data_push(struct ctdb_req_control_data
*cd
,
426 uint8_t *buf
, size_t *npush
)
428 size_t np
= 0, offset
;
431 switch (cd
->opcode
) {
432 case CTDB_CONTROL_PROCESS_EXISTS
:
433 ctdb_pid_push(&cd
->data
.pid
, buf
, &np
);
436 case CTDB_CONTROL_GETDBPATH
:
437 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
440 case CTDB_CONTROL_SETVNNMAP
:
441 ctdb_vnn_map_push(cd
->data
.vnnmap
, buf
, &np
);
444 case CTDB_CONTROL_SET_DEBUG
:
445 ctdb_uint32_push(&cd
->data
.loglevel
, buf
, &np
);
448 case CTDB_CONTROL_SET_RECMODE
:
449 ctdb_uint32_push(&cd
->data
.recmode
, buf
, &np
);
452 case CTDB_CONTROL_DB_ATTACH
:
453 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
456 case CTDB_CONTROL_TRAVERSE_START
:
457 ctdb_traverse_start_push(cd
->data
.traverse_start
, buf
, &np
);
460 case CTDB_CONTROL_TRAVERSE_ALL
:
461 ctdb_traverse_all_push(cd
->data
.traverse_all
, buf
, &np
);
464 case CTDB_CONTROL_TRAVERSE_DATA
:
465 ctdb_rec_data_push(cd
->data
.rec_data
, buf
, &np
);
468 case CTDB_CONTROL_GET_DBNAME
:
469 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
472 case CTDB_CONTROL_ENABLE_SEQNUM
:
473 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
476 case CTDB_CONTROL_UPDATE_SEQNUM
:
477 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
480 case CTDB_CONTROL_SET_RECMASTER
:
481 ctdb_uint32_push(&cd
->data
.recmaster
, buf
, &np
);
484 case CTDB_CONTROL_TCP_CLIENT
:
485 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
488 case CTDB_CONTROL_TCP_ADD
:
489 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
492 case CTDB_CONTROL_TCP_REMOVE
:
493 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
496 case CTDB_CONTROL_SET_TUNABLE
:
497 ctdb_tunable_push(cd
->data
.tunable
, buf
, &np
);
500 case CTDB_CONTROL_GET_TUNABLE
:
501 ctdb_stringn_push(&cd
->data
.tun_var
, buf
, &np
);
504 case CTDB_CONTROL_MODIFY_FLAGS
:
505 ctdb_node_flag_change_push(cd
->data
.flag_change
, buf
, &np
);
508 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
509 ctdb_sock_addr_push(cd
->data
.addr
, buf
, &np
);
512 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
513 ctdb_tickle_list_push(cd
->data
.tickles
, buf
, &np
);
516 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
517 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
520 case CTDB_CONTROL_UPDATE_RECORD
:
521 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
524 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
525 ctdb_addr_info_push(cd
->data
.addr_info
, buf
, &np
);
528 case CTDB_CONTROL_WIPE_DATABASE
:
529 ctdb_transdb_push(cd
->data
.transdb
, buf
, &np
);
532 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
533 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
536 case CTDB_CONTROL_ADD_PUBLIC_IP
:
537 ctdb_addr_info_push(cd
->data
.addr_info
, buf
, &np
);
540 case CTDB_CONTROL_DEL_PUBLIC_IP
:
541 ctdb_addr_info_push(cd
->data
.addr_info
, buf
, &np
);
544 case CTDB_CONTROL_RELEASE_IP
:
545 ctdb_public_ip_push(cd
->data
.pubip
, buf
, &np
);
548 case CTDB_CONTROL_TAKEOVER_IP
:
549 ctdb_public_ip_push(cd
->data
.pubip
, buf
, &np
);
552 case CTDB_CONTROL_TRAVERSE_KILL
:
553 ctdb_traverse_start_push(cd
->data
.traverse_start
, buf
, &np
);
556 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
557 ctdb_double_push(&cd
->data
.reclock_latency
, buf
, &np
);
560 case CTDB_CONTROL_SET_LMASTERROLE
:
561 ctdb_uint32_push(&cd
->data
.role
, buf
, &np
);
564 case CTDB_CONTROL_SET_RECMASTERROLE
:
565 ctdb_uint32_push(&cd
->data
.role
, buf
, &np
);
568 case CTDB_CONTROL_SET_BAN_STATE
:
569 ctdb_ban_state_push(cd
->data
.ban_state
, buf
, &np
);
572 case CTDB_CONTROL_REGISTER_NOTIFY
:
573 ctdb_notify_data_push(cd
->data
.notify
, buf
, &np
);
576 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
577 ctdb_uint64_push(&cd
->data
.srvid
, buf
, &np
);
580 case CTDB_CONTROL_TRANS3_COMMIT
:
581 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
584 case CTDB_CONTROL_GET_DB_SEQNUM
:
587 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
589 ctdb_uint32_push(&u32
, buf
+offset
, &np
);
594 case CTDB_CONTROL_DB_SET_HEALTHY
:
595 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
598 case CTDB_CONTROL_DB_GET_HEALTH
:
599 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
602 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
603 ctdb_sock_addr_push(cd
->data
.addr
, buf
, &np
);
606 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
607 ctdb_iface_push(cd
->data
.iface
, buf
, &np
);
610 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
611 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
614 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
615 ctdb_key_data_push(cd
->data
.key
, buf
, &np
);
618 case CTDB_CONTROL_SET_DB_READONLY
:
619 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
622 case CTDB_CONTROL_TRAVERSE_START_EXT
:
623 ctdb_traverse_start_ext_push(cd
->data
.traverse_start_ext
, buf
,
627 case CTDB_CONTROL_GET_DB_STATISTICS
:
628 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
631 case CTDB_CONTROL_SET_DB_STICKY
:
632 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
635 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
636 ctdb_traverse_all_ext_push(cd
->data
.traverse_all_ext
, buf
,
640 case CTDB_CONTROL_DB_DETACH
:
641 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
644 case CTDB_CONTROL_DB_FREEZE
:
645 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
648 case CTDB_CONTROL_DB_THAW
:
649 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
652 case CTDB_CONTROL_DB_TRANSACTION_START
:
653 ctdb_transdb_push(cd
->data
.transdb
, buf
, &np
);
656 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
657 ctdb_transdb_push(cd
->data
.transdb
, buf
, &np
);
660 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
661 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
664 case CTDB_CONTROL_DB_PULL
:
665 ctdb_pulldb_ext_push(cd
->data
.pulldb_ext
, buf
, &np
);
668 case CTDB_CONTROL_DB_PUSH_START
:
669 ctdb_pulldb_ext_push(cd
->data
.pulldb_ext
, buf
, &np
);
672 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
673 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
676 case CTDB_CONTROL_DB_OPEN_FLAGS
:
677 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
680 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
681 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
684 case CTDB_CONTROL_CHECK_PID_SRVID
:
685 ctdb_pid_srvid_push(cd
->data
.pid_srvid
, buf
, &np
);
688 case CTDB_CONTROL_VACUUM_FETCH
:
689 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
692 case CTDB_CONTROL_DB_VACUUM
:
693 ctdb_db_vacuum_push(cd
->data
.db_vacuum
, buf
, &np
);
696 case CTDB_CONTROL_ECHO_DATA
:
697 ctdb_echo_data_push(cd
->data
.echo_data
, buf
, &np
);
704 static int ctdb_req_control_data_pull(uint8_t *buf
, size_t buflen
,
707 struct ctdb_req_control_data
*cd
,
710 size_t np
= 0, offset
;
717 case CTDB_CONTROL_PROCESS_EXISTS
:
718 ret
= ctdb_pid_pull(buf
, buflen
, &cd
->data
.pid
, &np
);
721 case CTDB_CONTROL_GETDBPATH
:
722 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
725 case CTDB_CONTROL_SETVNNMAP
:
726 ret
= ctdb_vnn_map_pull(buf
, buflen
, mem_ctx
,
727 &cd
->data
.vnnmap
, &np
);
730 case CTDB_CONTROL_SET_DEBUG
:
731 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.loglevel
, &np
);
734 case CTDB_CONTROL_SET_RECMODE
:
735 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.recmode
, &np
);
738 case CTDB_CONTROL_DB_ATTACH
:
739 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
740 &cd
->data
.db_name
, &np
);
743 case CTDB_CONTROL_TRAVERSE_START
:
744 ret
= ctdb_traverse_start_pull(buf
, buflen
, mem_ctx
,
745 &cd
->data
.traverse_start
, &np
);
748 case CTDB_CONTROL_TRAVERSE_ALL
:
749 ret
= ctdb_traverse_all_pull(buf
, buflen
, mem_ctx
,
750 &cd
->data
.traverse_all
, &np
);
753 case CTDB_CONTROL_TRAVERSE_DATA
:
754 ret
= ctdb_rec_data_pull(buf
, buflen
, mem_ctx
,
755 &cd
->data
.rec_data
, &np
);
758 case CTDB_CONTROL_GET_DBNAME
:
759 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
762 case CTDB_CONTROL_ENABLE_SEQNUM
:
763 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
766 case CTDB_CONTROL_UPDATE_SEQNUM
:
767 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
770 case CTDB_CONTROL_SET_RECMASTER
:
771 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.recmaster
, &np
);
774 case CTDB_CONTROL_TCP_CLIENT
:
775 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
776 &cd
->data
.conn
, &np
);
779 case CTDB_CONTROL_TCP_ADD
:
780 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
781 &cd
->data
.conn
, &np
);
784 case CTDB_CONTROL_TCP_REMOVE
:
785 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
786 &cd
->data
.conn
, &np
);
789 case CTDB_CONTROL_SET_TUNABLE
:
790 ret
= ctdb_tunable_pull(buf
, buflen
, mem_ctx
,
791 &cd
->data
.tunable
, &np
);
794 case CTDB_CONTROL_GET_TUNABLE
:
795 ret
= ctdb_stringn_pull(buf
, buflen
, mem_ctx
,
796 &cd
->data
.tun_var
, &np
);
799 case CTDB_CONTROL_MODIFY_FLAGS
:
800 ret
= ctdb_node_flag_change_pull(buf
, buflen
, mem_ctx
,
801 &cd
->data
.flag_change
, &np
);
804 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
805 ret
= ctdb_sock_addr_pull(buf
, buflen
, mem_ctx
,
806 &cd
->data
.addr
, &np
);
809 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
810 ret
= ctdb_tickle_list_pull(buf
, buflen
, mem_ctx
,
811 &cd
->data
.tickles
, &np
);
814 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
815 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
816 &cd
->data
.db_name
, &np
);
819 case CTDB_CONTROL_UPDATE_RECORD
:
820 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
821 &cd
->data
.recbuf
, &np
);
824 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
825 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
826 &cd
->data
.addr_info
, &np
);
829 case CTDB_CONTROL_WIPE_DATABASE
:
830 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
831 &cd
->data
.transdb
, &np
);
834 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
835 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
836 &cd
->data
.recbuf
, &np
);
839 case CTDB_CONTROL_ADD_PUBLIC_IP
:
840 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
841 &cd
->data
.addr_info
, &np
);
844 case CTDB_CONTROL_DEL_PUBLIC_IP
:
845 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
846 &cd
->data
.addr_info
, &np
);
849 case CTDB_CONTROL_RELEASE_IP
:
850 ret
= ctdb_public_ip_pull(buf
, buflen
, mem_ctx
,
851 &cd
->data
.pubip
, &np
);
854 case CTDB_CONTROL_TAKEOVER_IP
:
855 ret
= ctdb_public_ip_pull(buf
, buflen
, mem_ctx
,
856 &cd
->data
.pubip
, &np
);
859 case CTDB_CONTROL_TRAVERSE_KILL
:
860 ret
= ctdb_traverse_start_pull(buf
, buflen
, mem_ctx
,
861 &cd
->data
.traverse_start
, &np
);
864 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
865 ret
= ctdb_double_pull(buf
, buflen
, &cd
->data
.reclock_latency
,
869 case CTDB_CONTROL_SET_LMASTERROLE
:
870 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.role
, &np
);
873 case CTDB_CONTROL_SET_RECMASTERROLE
:
874 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.role
, &np
);
877 case CTDB_CONTROL_SET_BAN_STATE
:
878 ret
= ctdb_ban_state_pull(buf
, buflen
, mem_ctx
,
879 &cd
->data
.ban_state
, &np
);
882 case CTDB_CONTROL_REGISTER_NOTIFY
:
883 ret
= ctdb_notify_data_pull(buf
, buflen
, mem_ctx
,
884 &cd
->data
.notify
, &np
);
887 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
888 ret
= ctdb_uint64_pull(buf
, buflen
, &cd
->data
.srvid
, &np
);
891 case CTDB_CONTROL_TRANS3_COMMIT
:
892 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
893 &cd
->data
.recbuf
, &np
);
896 case CTDB_CONTROL_GET_DB_SEQNUM
:
898 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
903 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &u32
, &np
);
908 case CTDB_CONTROL_DB_SET_HEALTHY
:
909 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
912 case CTDB_CONTROL_DB_GET_HEALTH
:
913 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
916 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
917 ret
= ctdb_sock_addr_pull(buf
, buflen
, mem_ctx
,
918 &cd
->data
.addr
, &np
);
921 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
922 ret
= ctdb_iface_pull(buf
, buflen
, mem_ctx
,
923 &cd
->data
.iface
, &np
);
926 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
927 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
928 &cd
->data
.conn
, &np
);
931 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
932 ret
= ctdb_key_data_pull(buf
, buflen
, mem_ctx
,
936 case CTDB_CONTROL_SET_DB_READONLY
:
937 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
940 case CTDB_CONTROL_TRAVERSE_START_EXT
:
941 ret
= ctdb_traverse_start_ext_pull(buf
, buflen
, mem_ctx
,
942 &cd
->data
.traverse_start_ext
,
946 case CTDB_CONTROL_GET_DB_STATISTICS
:
947 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
950 case CTDB_CONTROL_SET_DB_STICKY
:
951 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
954 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
955 ret
= ctdb_traverse_all_ext_pull(buf
, buflen
, mem_ctx
,
956 &cd
->data
.traverse_all_ext
,
960 case CTDB_CONTROL_DB_DETACH
:
961 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
964 case CTDB_CONTROL_DB_FREEZE
:
965 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
968 case CTDB_CONTROL_DB_THAW
:
969 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
972 case CTDB_CONTROL_DB_TRANSACTION_START
:
973 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
974 &cd
->data
.transdb
, &np
);
977 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
978 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
979 &cd
->data
.transdb
, &np
);
982 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
983 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
986 case CTDB_CONTROL_DB_PULL
:
987 ret
= ctdb_pulldb_ext_pull(buf
, buflen
, mem_ctx
,
988 &cd
->data
.pulldb_ext
, &np
);
991 case CTDB_CONTROL_DB_PUSH_START
:
992 ret
= ctdb_pulldb_ext_pull(buf
, buflen
, mem_ctx
,
993 &cd
->data
.pulldb_ext
, &np
);
996 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
997 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1000 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1001 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1004 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1005 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1006 &cd
->data
.db_name
, &np
);
1009 case CTDB_CONTROL_CHECK_PID_SRVID
:
1010 ret
= ctdb_pid_srvid_pull(buf
, buflen
, mem_ctx
,
1011 &cd
->data
.pid_srvid
, &np
);
1014 case CTDB_CONTROL_VACUUM_FETCH
:
1015 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
1016 &cd
->data
.recbuf
, &np
);
1019 case CTDB_CONTROL_DB_VACUUM
:
1020 ret
= ctdb_db_vacuum_pull(buf
,
1023 &cd
->data
.db_vacuum
,
1027 case CTDB_CONTROL_ECHO_DATA
:
1028 ret
= ctdb_echo_data_pull(buf
,
1031 &cd
->data
.echo_data
,
1044 static size_t ctdb_reply_control_data_len(struct ctdb_reply_control_data
*cd
)
1052 switch (cd
->opcode
) {
1053 case CTDB_CONTROL_PROCESS_EXISTS
:
1056 case CTDB_CONTROL_STATISTICS
:
1057 len
= ctdb_statistics_len(cd
->data
.stats
);
1060 case CTDB_CONTROL_PING
:
1063 case CTDB_CONTROL_GETDBPATH
:
1064 len
= ctdb_string_len(&cd
->data
.db_path
);
1067 case CTDB_CONTROL_GETVNNMAP
:
1068 len
= ctdb_vnn_map_len(cd
->data
.vnnmap
);
1071 case CTDB_CONTROL_SETVNNMAP
:
1074 case CTDB_CONTROL_GET_DEBUG
:
1075 len
= ctdb_uint32_len(&cd
->data
.loglevel
);
1078 case CTDB_CONTROL_SET_DEBUG
:
1081 case CTDB_CONTROL_GET_DBMAP
:
1082 len
= ctdb_dbid_map_len(cd
->data
.dbmap
);
1085 case CTDB_CONTROL_GET_RECMODE
:
1088 case CTDB_CONTROL_SET_RECMODE
:
1091 case CTDB_CONTROL_STATISTICS_RESET
:
1094 case CTDB_CONTROL_DB_ATTACH
:
1095 len
= ctdb_uint32_len(&cd
->data
.db_id
);
1098 case CTDB_CONTROL_TRAVERSE_START
:
1101 case CTDB_CONTROL_TRAVERSE_ALL
:
1104 case CTDB_CONTROL_TRAVERSE_DATA
:
1107 case CTDB_CONTROL_REGISTER_SRVID
:
1110 case CTDB_CONTROL_DEREGISTER_SRVID
:
1113 case CTDB_CONTROL_GET_DBNAME
:
1114 len
= ctdb_string_len(&cd
->data
.db_name
);
1117 case CTDB_CONTROL_ENABLE_SEQNUM
:
1120 case CTDB_CONTROL_UPDATE_SEQNUM
:
1123 case CTDB_CONTROL_DUMP_MEMORY
:
1124 len
= ctdb_string_len(&cd
->data
.mem_str
);
1127 case CTDB_CONTROL_GET_PID
:
1130 case CTDB_CONTROL_GET_RECMASTER
:
1133 case CTDB_CONTROL_SET_RECMASTER
:
1136 case CTDB_CONTROL_FREEZE
:
1139 case CTDB_CONTROL_GET_PNN
:
1142 case CTDB_CONTROL_SHUTDOWN
:
1145 case CTDB_CONTROL_TCP_CLIENT
:
1148 case CTDB_CONTROL_TCP_ADD
:
1151 case CTDB_CONTROL_TCP_REMOVE
:
1154 case CTDB_CONTROL_STARTUP
:
1157 case CTDB_CONTROL_SET_TUNABLE
:
1160 case CTDB_CONTROL_GET_TUNABLE
:
1161 len
= ctdb_uint32_len(&cd
->data
.tun_value
);
1164 case CTDB_CONTROL_LIST_TUNABLES
:
1165 len
= ctdb_var_list_len(cd
->data
.tun_var_list
);
1168 case CTDB_CONTROL_MODIFY_FLAGS
:
1171 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1172 len
= ctdb_tunable_list_len(cd
->data
.tun_list
);
1175 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1176 len
= ctdb_tickle_list_len(cd
->data
.tickles
);
1179 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
1182 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1183 len
= ctdb_uint32_len(&cd
->data
.db_id
);
1186 case CTDB_CONTROL_UPDATE_RECORD
:
1189 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
1192 case CTDB_CONTROL_WIPE_DATABASE
:
1195 case CTDB_CONTROL_UPTIME
:
1196 len
= ctdb_uptime_len(cd
->data
.uptime
);
1199 case CTDB_CONTROL_START_RECOVERY
:
1202 case CTDB_CONTROL_END_RECOVERY
:
1205 case CTDB_CONTROL_RELOAD_NODES_FILE
:
1208 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1209 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
1212 case CTDB_CONTROL_ADD_PUBLIC_IP
:
1215 case CTDB_CONTROL_DEL_PUBLIC_IP
:
1218 case CTDB_CONTROL_GET_CAPABILITIES
:
1219 len
= ctdb_uint32_len(&cd
->data
.caps
);
1222 case CTDB_CONTROL_RECD_PING
:
1225 case CTDB_CONTROL_RELEASE_IP
:
1228 case CTDB_CONTROL_TAKEOVER_IP
:
1231 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1232 len
= ctdb_public_ip_list_len(cd
->data
.pubip_list
);
1235 case CTDB_CONTROL_GET_NODEMAP
:
1236 len
= ctdb_node_map_len(cd
->data
.nodemap
);
1239 case CTDB_CONTROL_TRAVERSE_KILL
:
1242 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
1245 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1246 len
= ctdb_string_len(&cd
->data
.reclock_file
);
1249 case CTDB_CONTROL_STOP_NODE
:
1252 case CTDB_CONTROL_CONTINUE_NODE
:
1255 case CTDB_CONTROL_SET_LMASTERROLE
:
1258 case CTDB_CONTROL_SET_RECMASTERROLE
:
1261 case CTDB_CONTROL_SET_BAN_STATE
:
1264 case CTDB_CONTROL_GET_BAN_STATE
:
1265 len
= ctdb_ban_state_len(cd
->data
.ban_state
);
1268 case CTDB_CONTROL_REGISTER_NOTIFY
:
1271 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
1274 case CTDB_CONTROL_TRANS3_COMMIT
:
1277 case CTDB_CONTROL_GET_DB_SEQNUM
:
1278 len
= ctdb_uint64_len(&cd
->data
.seqnum
);
1281 case CTDB_CONTROL_DB_SET_HEALTHY
:
1284 case CTDB_CONTROL_DB_GET_HEALTH
:
1285 len
= ctdb_string_len(&cd
->data
.reason
);
1288 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1289 len
= ctdb_public_ip_info_len(cd
->data
.ipinfo
);
1292 case CTDB_CONTROL_GET_IFACES
:
1293 len
= ctdb_iface_list_len(cd
->data
.iface_list
);
1296 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
1299 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
1302 case CTDB_CONTROL_GET_STAT_HISTORY
:
1303 len
= ctdb_statistics_list_len(cd
->data
.stats_list
);
1306 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
1309 case CTDB_CONTROL_SET_DB_READONLY
:
1312 case CTDB_CONTROL_TRAVERSE_START_EXT
:
1315 case CTDB_CONTROL_GET_DB_STATISTICS
:
1316 len
= ctdb_db_statistics_len(cd
->data
.dbstats
);
1319 case CTDB_CONTROL_SET_DB_STICKY
:
1322 case CTDB_CONTROL_RELOAD_PUBLIC_IPS
:
1325 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
1328 case CTDB_CONTROL_IPREALLOCATED
:
1331 case CTDB_CONTROL_GET_RUNSTATE
:
1332 len
= ctdb_uint32_len(&cd
->data
.runstate
);
1335 case CTDB_CONTROL_DB_DETACH
:
1338 case CTDB_CONTROL_GET_NODES_FILE
:
1339 len
= ctdb_node_map_len(cd
->data
.nodemap
);
1342 case CTDB_CONTROL_DB_FREEZE
:
1345 case CTDB_CONTROL_DB_THAW
:
1348 case CTDB_CONTROL_DB_TRANSACTION_START
:
1351 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
1354 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
1357 case CTDB_CONTROL_DB_PULL
:
1358 len
= ctdb_uint32_len(&cd
->data
.num_records
);
1361 case CTDB_CONTROL_DB_PUSH_START
:
1364 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1365 len
= ctdb_uint32_len(&cd
->data
.num_records
);
1368 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1369 len
= ctdb_int32_len(&cd
->data
.tdb_flags
);
1372 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1373 len
= ctdb_uint32_len(&cd
->data
.db_id
);
1376 case CTDB_CONTROL_CHECK_PID_SRVID
:
1379 case CTDB_CONTROL_TUNNEL_REGISTER
:
1382 case CTDB_CONTROL_TUNNEL_DEREGISTER
:
1385 case CTDB_CONTROL_VACUUM_FETCH
:
1388 case CTDB_CONTROL_DB_VACUUM
:
1391 case CTDB_CONTROL_ECHO_DATA
:
1392 len
= ctdb_echo_data_len(cd
->data
.echo_data
);
1395 case CTDB_CONTROL_DISABLE_NODE
:
1398 case CTDB_CONTROL_ENABLE_NODE
:
1405 static void ctdb_reply_control_data_push(struct ctdb_reply_control_data
*cd
,
1406 uint8_t *buf
, size_t *npush
)
1410 switch (cd
->opcode
) {
1411 case CTDB_CONTROL_STATISTICS
:
1412 ctdb_statistics_push(cd
->data
.stats
, buf
, &np
);
1415 case CTDB_CONTROL_GETDBPATH
:
1416 ctdb_string_push(&cd
->data
.db_path
, buf
, &np
);
1419 case CTDB_CONTROL_GETVNNMAP
:
1420 ctdb_vnn_map_push(cd
->data
.vnnmap
, buf
, &np
);
1423 case CTDB_CONTROL_GET_DEBUG
:
1424 ctdb_uint32_push(&cd
->data
.loglevel
, buf
, &np
);
1427 case CTDB_CONTROL_GET_DBMAP
:
1428 ctdb_dbid_map_push(cd
->data
.dbmap
, buf
, &np
);
1431 case CTDB_CONTROL_DB_ATTACH
:
1432 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
1435 case CTDB_CONTROL_GET_DBNAME
:
1436 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
1439 case CTDB_CONTROL_DUMP_MEMORY
:
1440 ctdb_string_push(&cd
->data
.mem_str
, buf
, &np
);
1443 case CTDB_CONTROL_GET_PID
:
1446 case CTDB_CONTROL_GET_RECMASTER
:
1449 case CTDB_CONTROL_GET_TUNABLE
:
1450 ctdb_uint32_push(&cd
->data
.tun_value
, buf
, &np
);
1453 case CTDB_CONTROL_LIST_TUNABLES
:
1454 ctdb_var_list_push(cd
->data
.tun_var_list
, buf
, &np
);
1457 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1458 ctdb_tunable_list_push(cd
->data
.tun_list
, buf
, &np
);
1461 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1462 ctdb_tickle_list_push(cd
->data
.tickles
, buf
, &np
);
1465 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1466 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
1469 case CTDB_CONTROL_UPTIME
:
1470 ctdb_uptime_push(cd
->data
.uptime
, buf
, &np
);
1473 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1474 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
1477 case CTDB_CONTROL_GET_CAPABILITIES
:
1478 ctdb_uint32_push(&cd
->data
.caps
, buf
, &np
);
1481 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1482 ctdb_public_ip_list_push(cd
->data
.pubip_list
, buf
, &np
);
1485 case CTDB_CONTROL_GET_NODEMAP
:
1486 ctdb_node_map_push(cd
->data
.nodemap
, buf
, &np
);
1489 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1490 ctdb_string_push(&cd
->data
.reclock_file
, buf
, &np
);
1493 case CTDB_CONTROL_GET_BAN_STATE
:
1494 ctdb_ban_state_push(cd
->data
.ban_state
, buf
, &np
);
1497 case CTDB_CONTROL_GET_DB_SEQNUM
:
1498 ctdb_uint64_push(&cd
->data
.seqnum
, buf
, &np
);
1501 case CTDB_CONTROL_DB_GET_HEALTH
:
1502 ctdb_string_push(&cd
->data
.reason
, buf
, &np
);
1505 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1506 ctdb_public_ip_info_push(cd
->data
.ipinfo
, buf
, &np
);
1509 case CTDB_CONTROL_GET_IFACES
:
1510 ctdb_iface_list_push(cd
->data
.iface_list
, buf
, &np
);
1513 case CTDB_CONTROL_GET_STAT_HISTORY
:
1514 ctdb_statistics_list_push(cd
->data
.stats_list
, buf
, &np
);
1517 case CTDB_CONTROL_GET_DB_STATISTICS
:
1518 ctdb_db_statistics_push(cd
->data
.dbstats
, buf
, &np
);
1521 case CTDB_CONTROL_GET_RUNSTATE
:
1522 ctdb_uint32_push(&cd
->data
.runstate
, buf
, &np
);
1525 case CTDB_CONTROL_GET_NODES_FILE
:
1526 ctdb_node_map_push(cd
->data
.nodemap
, buf
, &np
);
1529 case CTDB_CONTROL_DB_PULL
:
1530 ctdb_uint32_push(&cd
->data
.num_records
, buf
, &np
);
1533 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1534 ctdb_uint32_push(&cd
->data
.num_records
, buf
, &np
);
1537 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1538 ctdb_int32_push(&cd
->data
.tdb_flags
, buf
, &np
);
1541 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1542 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
1545 case CTDB_CONTROL_CHECK_PID_SRVID
:
1548 case CTDB_CONTROL_VACUUM_FETCH
:
1551 case CTDB_CONTROL_DB_VACUUM
:
1554 case CTDB_CONTROL_ECHO_DATA
:
1555 ctdb_echo_data_push(cd
->data
.echo_data
, buf
, &np
);
1562 static int ctdb_reply_control_data_pull(uint8_t *buf
, size_t buflen
,
1563 uint32_t opcode
, TALLOC_CTX
*mem_ctx
,
1564 struct ctdb_reply_control_data
*cd
,
1570 cd
->opcode
= opcode
;
1573 case CTDB_CONTROL_STATISTICS
:
1574 ret
= ctdb_statistics_pull(buf
, buflen
, mem_ctx
,
1575 &cd
->data
.stats
, &np
);
1578 case CTDB_CONTROL_GETDBPATH
:
1579 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1580 &cd
->data
.db_path
, &np
);
1583 case CTDB_CONTROL_GETVNNMAP
:
1584 ret
= ctdb_vnn_map_pull(buf
, buflen
, mem_ctx
,
1585 &cd
->data
.vnnmap
, &np
);
1588 case CTDB_CONTROL_GET_DEBUG
:
1589 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.loglevel
, &np
);
1592 case CTDB_CONTROL_GET_DBMAP
:
1593 ret
= ctdb_dbid_map_pull(buf
, buflen
, mem_ctx
,
1594 &cd
->data
.dbmap
, &np
);
1597 case CTDB_CONTROL_DB_ATTACH
:
1598 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1601 case CTDB_CONTROL_GET_DBNAME
:
1602 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1603 &cd
->data
.db_name
, &np
);
1606 case CTDB_CONTROL_DUMP_MEMORY
:
1607 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1608 &cd
->data
.mem_str
, &np
);
1611 case CTDB_CONTROL_GET_PID
:
1614 case CTDB_CONTROL_GET_RECMASTER
:
1617 case CTDB_CONTROL_GET_TUNABLE
:
1618 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.tun_value
,
1622 case CTDB_CONTROL_LIST_TUNABLES
:
1623 ret
= ctdb_var_list_pull(buf
, buflen
, mem_ctx
,
1624 &cd
->data
.tun_var_list
, &np
);
1627 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1628 ret
= ctdb_tunable_list_pull(buf
, buflen
, mem_ctx
,
1629 &cd
->data
.tun_list
, &np
);
1632 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1633 ret
= ctdb_tickle_list_pull(buf
, buflen
, mem_ctx
,
1634 &cd
->data
.tickles
, &np
);
1637 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1638 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1641 case CTDB_CONTROL_UPTIME
:
1642 ret
= ctdb_uptime_pull(buf
, buflen
, mem_ctx
,
1643 &cd
->data
.uptime
, &np
);
1646 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1647 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
1648 &cd
->data
.recbuf
, &np
);
1651 case CTDB_CONTROL_GET_CAPABILITIES
:
1652 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.caps
, &np
);
1655 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1656 ret
= ctdb_public_ip_list_pull(buf
, buflen
, mem_ctx
,
1657 &cd
->data
.pubip_list
, &np
);
1660 case CTDB_CONTROL_GET_NODEMAP
:
1661 ret
= ctdb_node_map_pull(buf
, buflen
, mem_ctx
,
1662 &cd
->data
.nodemap
, &np
);
1665 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1666 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1667 &cd
->data
.reclock_file
, &np
);
1670 case CTDB_CONTROL_GET_BAN_STATE
:
1671 ret
= ctdb_ban_state_pull(buf
, buflen
, mem_ctx
,
1672 &cd
->data
.ban_state
, &np
);
1675 case CTDB_CONTROL_GET_DB_SEQNUM
:
1676 ret
= ctdb_uint64_pull(buf
, buflen
, &cd
->data
.seqnum
, &np
);
1679 case CTDB_CONTROL_DB_GET_HEALTH
:
1680 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1681 &cd
->data
.reason
, &np
);
1684 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1685 ret
= ctdb_public_ip_info_pull(buf
, buflen
, mem_ctx
,
1686 &cd
->data
.ipinfo
, &np
);
1689 case CTDB_CONTROL_GET_IFACES
:
1690 ret
= ctdb_iface_list_pull(buf
, buflen
, mem_ctx
,
1691 &cd
->data
.iface_list
, &np
);
1694 case CTDB_CONTROL_GET_STAT_HISTORY
:
1695 ret
= ctdb_statistics_list_pull(buf
, buflen
, mem_ctx
,
1696 &cd
->data
.stats_list
, &np
);
1699 case CTDB_CONTROL_GET_DB_STATISTICS
:
1700 ret
= ctdb_db_statistics_pull(buf
, buflen
, mem_ctx
,
1701 &cd
->data
.dbstats
, &np
);
1704 case CTDB_CONTROL_GET_RUNSTATE
:
1705 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.runstate
, &np
);
1708 case CTDB_CONTROL_GET_NODES_FILE
:
1709 ret
= ctdb_node_map_pull(buf
, buflen
, mem_ctx
,
1710 &cd
->data
.nodemap
, &np
);
1713 case CTDB_CONTROL_DB_PULL
:
1714 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.num_records
,
1718 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1719 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.num_records
,
1723 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1724 ret
= ctdb_int32_pull(buf
, buflen
, &cd
->data
.tdb_flags
, &np
);
1727 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1728 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1731 case CTDB_CONTROL_CHECK_PID_SRVID
:
1734 case CTDB_CONTROL_VACUUM_FETCH
:
1737 case CTDB_CONTROL_DB_VACUUM
:
1740 case CTDB_CONTROL_ECHO_DATA
:
1741 ret
= ctdb_echo_data_pull(buf
,
1744 &cd
->data
.echo_data
,
1757 size_t ctdb_req_control_len(struct ctdb_req_header
*h
,
1758 struct ctdb_req_control
*c
)
1762 return ctdb_req_header_len(h
) +
1763 ctdb_uint32_len(&c
->opcode
) +
1764 ctdb_uint32_len(&c
->pad
) +
1765 ctdb_uint64_len(&c
->srvid
) +
1766 ctdb_uint32_len(&c
->client_id
) +
1767 ctdb_uint32_len(&c
->flags
) +
1768 ctdb_uint32_len(&u32
) +
1769 ctdb_req_control_data_len(&c
->rdata
);
1772 int ctdb_req_control_push(struct ctdb_req_header
*h
,
1773 struct ctdb_req_control
*c
,
1774 uint8_t *buf
, size_t *buflen
)
1776 size_t offset
= 0, np
;
1780 length
= ctdb_req_control_len(h
, c
);
1781 if (*buflen
< length
) {
1786 h
->length
= *buflen
;
1787 ctdb_req_header_push(h
, buf
+offset
, &np
);
1790 ctdb_uint32_push(&c
->opcode
, buf
+offset
, &np
);
1793 ctdb_uint32_push(&c
->pad
, buf
+offset
, &np
);
1796 ctdb_uint64_push(&c
->srvid
, buf
+offset
, &np
);
1799 ctdb_uint32_push(&c
->client_id
, buf
+offset
, &np
);
1802 ctdb_uint32_push(&c
->flags
, buf
+offset
, &np
);
1805 u32
= ctdb_req_control_data_len(&c
->rdata
);
1806 ctdb_uint32_push(&u32
, buf
+offset
, &np
);
1809 ctdb_req_control_data_push(&c
->rdata
, buf
+offset
, &np
);
1812 if (offset
> *buflen
) {
1819 int ctdb_req_control_pull(uint8_t *buf
, size_t buflen
,
1820 struct ctdb_req_header
*h
,
1821 TALLOC_CTX
*mem_ctx
,
1822 struct ctdb_req_control
*c
)
1824 struct ctdb_req_header header
;
1825 size_t offset
= 0, np
;
1829 ret
= ctdb_req_header_pull(buf
+offset
, buflen
-offset
, &header
, &np
);
1839 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->opcode
, &np
);
1845 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->pad
, &np
);
1851 ret
= ctdb_uint64_pull(buf
+offset
, buflen
-offset
, &c
->srvid
, &np
);
1857 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->client_id
, &np
);
1863 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->flags
, &np
);
1869 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &u32
, &np
);
1875 if (u32
> buflen
-offset
) {
1879 ret
= ctdb_req_control_data_pull(buf
+offset
, u32
, c
->opcode
, mem_ctx
,
1886 if (offset
> buflen
) {
1893 size_t ctdb_reply_control_len(struct ctdb_req_header
*h
,
1894 struct ctdb_reply_control
*c
)
1896 uint32_t dsize
, esize
;
1898 if (c
->status
== 0) {
1899 dsize
= ctdb_reply_control_data_len(&c
->rdata
);
1903 esize
= ctdb_string_len(&c
->errmsg
);
1906 return ctdb_req_header_len(h
) +
1907 ctdb_int32_len(&c
->status
) +
1908 ctdb_uint32_len(&dsize
) +
1909 ctdb_uint32_len(&esize
) +
1913 int ctdb_reply_control_push(struct ctdb_req_header
*h
,
1914 struct ctdb_reply_control
*c
,
1915 uint8_t *buf
, size_t *buflen
)
1917 size_t offset
= 0, np
;
1919 uint32_t dsize
, esize
;
1921 length
= ctdb_reply_control_len(h
, c
);
1922 if (*buflen
< length
) {
1927 h
->length
= *buflen
;
1928 ctdb_req_header_push(h
, buf
+offset
, &np
);
1931 ctdb_int32_push(&c
->status
, buf
+offset
, &np
);
1934 if (c
->status
== 0) {
1935 dsize
= ctdb_reply_control_data_len(&c
->rdata
);
1939 esize
= ctdb_string_len(&c
->errmsg
);
1942 ctdb_uint32_push(&dsize
, buf
+offset
, &np
);
1945 ctdb_uint32_push(&esize
, buf
+offset
, &np
);
1948 if (c
->status
== 0) {
1949 ctdb_reply_control_data_push(&c
->rdata
, buf
+offset
, &np
);
1951 ctdb_string_push(&c
->errmsg
, buf
+offset
, &np
);
1958 int ctdb_reply_control_pull(uint8_t *buf
, size_t buflen
, uint32_t opcode
,
1959 struct ctdb_req_header
*h
,
1960 TALLOC_CTX
*mem_ctx
,
1961 struct ctdb_reply_control
*c
)
1963 struct ctdb_req_header header
;
1964 size_t offset
= 0, np
;
1965 uint32_t dsize
, esize
;
1968 ret
= ctdb_req_header_pull(buf
+offset
, buflen
-offset
, &header
, &np
);
1978 ret
= ctdb_int32_pull(buf
+offset
, buflen
-offset
, &c
->status
, &np
);
1984 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &dsize
, &np
);
1990 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &esize
, &np
);
1998 if (c
->status
== 0) {
1999 if (buflen
-offset
< dsize
) {
2003 ret
= ctdb_reply_control_data_pull(buf
+offset
, dsize
,
2004 opcode
, mem_ctx
, &c
->rdata
,
2012 if (buflen
-offset
< esize
) {
2016 ret
= ctdb_string_pull(buf
+offset
, esize
, mem_ctx
, &c
->errmsg
,