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_FREEZE
:
124 case CTDB_CONTROL_GET_PNN
:
127 case CTDB_CONTROL_SHUTDOWN
:
130 case CTDB_CONTROL_TCP_CLIENT
:
131 len
= ctdb_connection_len(cd
->data
.conn
);
134 case CTDB_CONTROL_TCP_ADD
:
135 len
= ctdb_connection_len(cd
->data
.conn
);
138 case CTDB_CONTROL_TCP_REMOVE
:
139 len
= ctdb_connection_len(cd
->data
.conn
);
142 case CTDB_CONTROL_STARTUP
:
145 case CTDB_CONTROL_SET_TUNABLE
:
146 len
= ctdb_tunable_len(cd
->data
.tunable
);
149 case CTDB_CONTROL_GET_TUNABLE
:
150 len
= ctdb_stringn_len(&cd
->data
.tun_var
);
153 case CTDB_CONTROL_LIST_TUNABLES
:
156 case CTDB_CONTROL_MODIFY_FLAGS
:
157 len
= ctdb_node_flag_change_len(cd
->data
.flag_change
);
160 case CTDB_CONTROL_GET_ALL_TUNABLES
:
163 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
164 len
= ctdb_sock_addr_len(cd
->data
.addr
);
167 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
168 len
= ctdb_tickle_list_len(cd
->data
.tickles
);
171 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
172 len
= ctdb_string_len(&cd
->data
.db_name
);
175 case CTDB_CONTROL_UPDATE_RECORD
:
176 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
179 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
180 len
= ctdb_addr_info_len(cd
->data
.addr_info
);
183 case CTDB_CONTROL_WIPE_DATABASE
:
184 len
= ctdb_transdb_len(cd
->data
.transdb
);
187 case CTDB_CONTROL_UPTIME
:
190 case CTDB_CONTROL_START_RECOVERY
:
193 case CTDB_CONTROL_END_RECOVERY
:
196 case CTDB_CONTROL_RELOAD_NODES_FILE
:
199 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
200 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
203 case CTDB_CONTROL_ADD_PUBLIC_IP
:
204 len
= ctdb_addr_info_len(cd
->data
.addr_info
);
207 case CTDB_CONTROL_DEL_PUBLIC_IP
:
208 len
= ctdb_addr_info_len(cd
->data
.addr_info
);
211 case CTDB_CONTROL_GET_CAPABILITIES
:
214 case CTDB_CONTROL_RECD_PING
:
217 case CTDB_CONTROL_RELEASE_IP
:
218 len
= ctdb_public_ip_len(cd
->data
.pubip
);
221 case CTDB_CONTROL_TAKEOVER_IP
:
222 len
= ctdb_public_ip_len(cd
->data
.pubip
);
225 case CTDB_CONTROL_GET_PUBLIC_IPS
:
228 case CTDB_CONTROL_GET_NODEMAP
:
231 case CTDB_CONTROL_TRAVERSE_KILL
:
232 len
= ctdb_traverse_start_len(cd
->data
.traverse_start
);
235 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
236 len
= ctdb_double_len(&cd
->data
.reclock_latency
);
239 case CTDB_CONTROL_GET_RECLOCK_FILE
:
242 case CTDB_CONTROL_STOP_NODE
:
245 case CTDB_CONTROL_CONTINUE_NODE
:
248 case CTDB_CONTROL_SET_LMASTERROLE
:
249 len
= ctdb_uint32_len(&cd
->data
.role
);
252 case CTDB_CONTROL_SET_RECMASTERROLE
:
253 len
= ctdb_uint32_len(&cd
->data
.role
);
256 case CTDB_CONTROL_SET_BAN_STATE
:
257 len
= ctdb_ban_state_len(cd
->data
.ban_state
);
260 case CTDB_CONTROL_GET_BAN_STATE
:
263 case CTDB_CONTROL_REGISTER_NOTIFY
:
264 len
= ctdb_notify_data_len(cd
->data
.notify
);
267 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
268 len
= ctdb_uint64_len(&cd
->data
.srvid
);
271 case CTDB_CONTROL_TRANS3_COMMIT
:
272 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
275 case CTDB_CONTROL_GET_DB_SEQNUM
:
277 len
= ctdb_uint32_len(&cd
->data
.db_id
) + ctdb_uint32_len(&u32
);
280 case CTDB_CONTROL_DB_SET_HEALTHY
:
281 len
= ctdb_uint32_len(&cd
->data
.db_id
);
284 case CTDB_CONTROL_DB_GET_HEALTH
:
285 len
= ctdb_uint32_len(&cd
->data
.db_id
);
288 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
289 len
= ctdb_sock_addr_len(cd
->data
.addr
);
292 case CTDB_CONTROL_GET_IFACES
:
295 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
296 len
= ctdb_iface_len(cd
->data
.iface
);
299 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
300 len
= ctdb_connection_len(cd
->data
.conn
);
303 case CTDB_CONTROL_GET_STAT_HISTORY
:
306 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
307 len
= ctdb_key_data_len(cd
->data
.key
);
310 case CTDB_CONTROL_SET_DB_READONLY
:
311 len
= ctdb_uint32_len(&cd
->data
.db_id
);
314 case CTDB_CONTROL_TRAVERSE_START_EXT
:
315 len
= ctdb_traverse_start_ext_len(cd
->data
.traverse_start_ext
);
318 case CTDB_CONTROL_GET_DB_STATISTICS
:
319 len
= ctdb_uint32_len(&cd
->data
.db_id
);
322 case CTDB_CONTROL_SET_DB_STICKY
:
323 len
= ctdb_uint32_len(&cd
->data
.db_id
);
326 case CTDB_CONTROL_RELOAD_PUBLIC_IPS
:
329 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
330 len
= ctdb_traverse_all_ext_len(cd
->data
.traverse_all_ext
);
333 case CTDB_CONTROL_IPREALLOCATED
:
336 case CTDB_CONTROL_GET_RUNSTATE
:
339 case CTDB_CONTROL_DB_DETACH
:
340 len
= ctdb_uint32_len(&cd
->data
.db_id
);
343 case CTDB_CONTROL_GET_NODES_FILE
:
346 case CTDB_CONTROL_DB_FREEZE
:
347 len
= ctdb_uint32_len(&cd
->data
.db_id
);
350 case CTDB_CONTROL_DB_THAW
:
351 len
= ctdb_uint32_len(&cd
->data
.db_id
);
354 case CTDB_CONTROL_DB_TRANSACTION_START
:
355 len
= ctdb_transdb_len(cd
->data
.transdb
);
358 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
359 len
= ctdb_transdb_len(cd
->data
.transdb
);
362 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
363 len
= ctdb_uint32_len(&cd
->data
.db_id
);
366 case CTDB_CONTROL_DB_PULL
:
367 len
= ctdb_pulldb_ext_len(cd
->data
.pulldb_ext
);
370 case CTDB_CONTROL_DB_PUSH_START
:
371 len
= ctdb_pulldb_ext_len(cd
->data
.pulldb_ext
);
374 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
375 len
= ctdb_uint32_len(&cd
->data
.db_id
);
378 case CTDB_CONTROL_DB_OPEN_FLAGS
:
379 len
= ctdb_uint32_len(&cd
->data
.db_id
);
382 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
383 len
= ctdb_string_len(&cd
->data
.db_name
);
386 case CTDB_CONTROL_CHECK_PID_SRVID
:
387 len
= ctdb_pid_srvid_len(cd
->data
.pid_srvid
);
390 case CTDB_CONTROL_TUNNEL_REGISTER
:
393 case CTDB_CONTROL_TUNNEL_DEREGISTER
:
396 case CTDB_CONTROL_VACUUM_FETCH
:
397 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
400 case CTDB_CONTROL_DB_VACUUM
:
401 len
= ctdb_db_vacuum_len(cd
->data
.db_vacuum
);
404 case CTDB_CONTROL_ECHO_DATA
:
405 len
= ctdb_echo_data_len(cd
->data
.echo_data
);
408 case CTDB_CONTROL_DISABLE_NODE
:
411 case CTDB_CONTROL_ENABLE_NODE
:
414 case CTDB_CONTROL_TCP_CLIENT_DISCONNECTED
:
415 len
= ctdb_connection_len(cd
->data
.conn
);
418 case CTDB_CONTROL_TCP_CLIENT_PASSED
:
419 len
= ctdb_connection_len(cd
->data
.conn
);
426 static void ctdb_req_control_data_push(struct ctdb_req_control_data
*cd
,
427 uint8_t *buf
, size_t *npush
)
429 size_t np
= 0, offset
;
432 switch (cd
->opcode
) {
433 case CTDB_CONTROL_PROCESS_EXISTS
:
434 ctdb_pid_push(&cd
->data
.pid
, buf
, &np
);
437 case CTDB_CONTROL_GETDBPATH
:
438 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
441 case CTDB_CONTROL_SETVNNMAP
:
442 ctdb_vnn_map_push(cd
->data
.vnnmap
, buf
, &np
);
445 case CTDB_CONTROL_SET_DEBUG
:
446 ctdb_uint32_push(&cd
->data
.loglevel
, buf
, &np
);
449 case CTDB_CONTROL_SET_RECMODE
:
450 ctdb_uint32_push(&cd
->data
.recmode
, buf
, &np
);
453 case CTDB_CONTROL_DB_ATTACH
:
454 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
457 case CTDB_CONTROL_TRAVERSE_START
:
458 ctdb_traverse_start_push(cd
->data
.traverse_start
, buf
, &np
);
461 case CTDB_CONTROL_TRAVERSE_ALL
:
462 ctdb_traverse_all_push(cd
->data
.traverse_all
, buf
, &np
);
465 case CTDB_CONTROL_TRAVERSE_DATA
:
466 ctdb_rec_data_push(cd
->data
.rec_data
, buf
, &np
);
469 case CTDB_CONTROL_GET_DBNAME
:
470 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
473 case CTDB_CONTROL_ENABLE_SEQNUM
:
474 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
477 case CTDB_CONTROL_UPDATE_SEQNUM
:
478 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
481 case CTDB_CONTROL_TCP_CLIENT
:
482 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
485 case CTDB_CONTROL_TCP_ADD
:
486 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
489 case CTDB_CONTROL_TCP_REMOVE
:
490 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
493 case CTDB_CONTROL_SET_TUNABLE
:
494 ctdb_tunable_push(cd
->data
.tunable
, buf
, &np
);
497 case CTDB_CONTROL_GET_TUNABLE
:
498 ctdb_stringn_push(&cd
->data
.tun_var
, buf
, &np
);
501 case CTDB_CONTROL_MODIFY_FLAGS
:
502 ctdb_node_flag_change_push(cd
->data
.flag_change
, buf
, &np
);
505 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
506 ctdb_sock_addr_push(cd
->data
.addr
, buf
, &np
);
509 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
510 ctdb_tickle_list_push(cd
->data
.tickles
, buf
, &np
);
513 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
514 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
517 case CTDB_CONTROL_UPDATE_RECORD
:
518 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
521 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
522 ctdb_addr_info_push(cd
->data
.addr_info
, buf
, &np
);
525 case CTDB_CONTROL_WIPE_DATABASE
:
526 ctdb_transdb_push(cd
->data
.transdb
, buf
, &np
);
529 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
530 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
533 case CTDB_CONTROL_ADD_PUBLIC_IP
:
534 ctdb_addr_info_push(cd
->data
.addr_info
, buf
, &np
);
537 case CTDB_CONTROL_DEL_PUBLIC_IP
:
538 ctdb_addr_info_push(cd
->data
.addr_info
, buf
, &np
);
541 case CTDB_CONTROL_RELEASE_IP
:
542 ctdb_public_ip_push(cd
->data
.pubip
, buf
, &np
);
545 case CTDB_CONTROL_TAKEOVER_IP
:
546 ctdb_public_ip_push(cd
->data
.pubip
, buf
, &np
);
549 case CTDB_CONTROL_TRAVERSE_KILL
:
550 ctdb_traverse_start_push(cd
->data
.traverse_start
, buf
, &np
);
553 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
554 ctdb_double_push(&cd
->data
.reclock_latency
, buf
, &np
);
557 case CTDB_CONTROL_SET_LMASTERROLE
:
558 ctdb_uint32_push(&cd
->data
.role
, buf
, &np
);
561 case CTDB_CONTROL_SET_RECMASTERROLE
:
562 ctdb_uint32_push(&cd
->data
.role
, buf
, &np
);
565 case CTDB_CONTROL_SET_BAN_STATE
:
566 ctdb_ban_state_push(cd
->data
.ban_state
, buf
, &np
);
569 case CTDB_CONTROL_REGISTER_NOTIFY
:
570 ctdb_notify_data_push(cd
->data
.notify
, buf
, &np
);
573 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
574 ctdb_uint64_push(&cd
->data
.srvid
, buf
, &np
);
577 case CTDB_CONTROL_TRANS3_COMMIT
:
578 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
581 case CTDB_CONTROL_GET_DB_SEQNUM
:
584 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
586 ctdb_uint32_push(&u32
, buf
+offset
, &np
);
591 case CTDB_CONTROL_DB_SET_HEALTHY
:
592 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
595 case CTDB_CONTROL_DB_GET_HEALTH
:
596 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
599 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
600 ctdb_sock_addr_push(cd
->data
.addr
, buf
, &np
);
603 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
604 ctdb_iface_push(cd
->data
.iface
, buf
, &np
);
607 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
608 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
611 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
612 ctdb_key_data_push(cd
->data
.key
, buf
, &np
);
615 case CTDB_CONTROL_SET_DB_READONLY
:
616 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
619 case CTDB_CONTROL_TRAVERSE_START_EXT
:
620 ctdb_traverse_start_ext_push(cd
->data
.traverse_start_ext
, buf
,
624 case CTDB_CONTROL_GET_DB_STATISTICS
:
625 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
628 case CTDB_CONTROL_SET_DB_STICKY
:
629 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
632 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
633 ctdb_traverse_all_ext_push(cd
->data
.traverse_all_ext
, buf
,
637 case CTDB_CONTROL_DB_DETACH
:
638 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
641 case CTDB_CONTROL_DB_FREEZE
:
642 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
645 case CTDB_CONTROL_DB_THAW
:
646 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
649 case CTDB_CONTROL_DB_TRANSACTION_START
:
650 ctdb_transdb_push(cd
->data
.transdb
, buf
, &np
);
653 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
654 ctdb_transdb_push(cd
->data
.transdb
, buf
, &np
);
657 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
658 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
661 case CTDB_CONTROL_DB_PULL
:
662 ctdb_pulldb_ext_push(cd
->data
.pulldb_ext
, buf
, &np
);
665 case CTDB_CONTROL_DB_PUSH_START
:
666 ctdb_pulldb_ext_push(cd
->data
.pulldb_ext
, buf
, &np
);
669 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
670 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
673 case CTDB_CONTROL_DB_OPEN_FLAGS
:
674 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
677 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
678 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
681 case CTDB_CONTROL_CHECK_PID_SRVID
:
682 ctdb_pid_srvid_push(cd
->data
.pid_srvid
, buf
, &np
);
685 case CTDB_CONTROL_VACUUM_FETCH
:
686 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
689 case CTDB_CONTROL_DB_VACUUM
:
690 ctdb_db_vacuum_push(cd
->data
.db_vacuum
, buf
, &np
);
693 case CTDB_CONTROL_ECHO_DATA
:
694 ctdb_echo_data_push(cd
->data
.echo_data
, buf
, &np
);
697 case CTDB_CONTROL_TCP_CLIENT_DISCONNECTED
:
698 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
701 case CTDB_CONTROL_TCP_CLIENT_PASSED
:
702 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
709 static int ctdb_req_control_data_pull(uint8_t *buf
, size_t buflen
,
712 struct ctdb_req_control_data
*cd
,
715 size_t np
= 0, offset
;
722 case CTDB_CONTROL_PROCESS_EXISTS
:
723 ret
= ctdb_pid_pull(buf
, buflen
, &cd
->data
.pid
, &np
);
726 case CTDB_CONTROL_GETDBPATH
:
727 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
730 case CTDB_CONTROL_SETVNNMAP
:
731 ret
= ctdb_vnn_map_pull(buf
, buflen
, mem_ctx
,
732 &cd
->data
.vnnmap
, &np
);
735 case CTDB_CONTROL_SET_DEBUG
:
736 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.loglevel
, &np
);
739 case CTDB_CONTROL_SET_RECMODE
:
740 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.recmode
, &np
);
743 case CTDB_CONTROL_DB_ATTACH
:
744 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
745 &cd
->data
.db_name
, &np
);
748 case CTDB_CONTROL_TRAVERSE_START
:
749 ret
= ctdb_traverse_start_pull(buf
, buflen
, mem_ctx
,
750 &cd
->data
.traverse_start
, &np
);
753 case CTDB_CONTROL_TRAVERSE_ALL
:
754 ret
= ctdb_traverse_all_pull(buf
, buflen
, mem_ctx
,
755 &cd
->data
.traverse_all
, &np
);
758 case CTDB_CONTROL_TRAVERSE_DATA
:
759 ret
= ctdb_rec_data_pull(buf
, buflen
, mem_ctx
,
760 &cd
->data
.rec_data
, &np
);
763 case CTDB_CONTROL_GET_DBNAME
:
764 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
767 case CTDB_CONTROL_ENABLE_SEQNUM
:
768 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
771 case CTDB_CONTROL_UPDATE_SEQNUM
:
772 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
775 case CTDB_CONTROL_TCP_CLIENT
:
776 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
777 &cd
->data
.conn
, &np
);
780 case CTDB_CONTROL_TCP_ADD
:
781 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
782 &cd
->data
.conn
, &np
);
785 case CTDB_CONTROL_TCP_REMOVE
:
786 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
787 &cd
->data
.conn
, &np
);
790 case CTDB_CONTROL_SET_TUNABLE
:
791 ret
= ctdb_tunable_pull(buf
, buflen
, mem_ctx
,
792 &cd
->data
.tunable
, &np
);
795 case CTDB_CONTROL_GET_TUNABLE
:
796 ret
= ctdb_stringn_pull(buf
, buflen
, mem_ctx
,
797 &cd
->data
.tun_var
, &np
);
800 case CTDB_CONTROL_MODIFY_FLAGS
:
801 ret
= ctdb_node_flag_change_pull(buf
, buflen
, mem_ctx
,
802 &cd
->data
.flag_change
, &np
);
805 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
806 ret
= ctdb_sock_addr_pull(buf
, buflen
, mem_ctx
,
807 &cd
->data
.addr
, &np
);
810 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
811 ret
= ctdb_tickle_list_pull(buf
, buflen
, mem_ctx
,
812 &cd
->data
.tickles
, &np
);
815 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
816 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
817 &cd
->data
.db_name
, &np
);
820 case CTDB_CONTROL_UPDATE_RECORD
:
821 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
822 &cd
->data
.recbuf
, &np
);
825 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
826 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
827 &cd
->data
.addr_info
, &np
);
830 case CTDB_CONTROL_WIPE_DATABASE
:
831 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
832 &cd
->data
.transdb
, &np
);
835 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
836 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
837 &cd
->data
.recbuf
, &np
);
840 case CTDB_CONTROL_ADD_PUBLIC_IP
:
841 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
842 &cd
->data
.addr_info
, &np
);
845 case CTDB_CONTROL_DEL_PUBLIC_IP
:
846 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
847 &cd
->data
.addr_info
, &np
);
850 case CTDB_CONTROL_RELEASE_IP
:
851 ret
= ctdb_public_ip_pull(buf
, buflen
, mem_ctx
,
852 &cd
->data
.pubip
, &np
);
855 case CTDB_CONTROL_TAKEOVER_IP
:
856 ret
= ctdb_public_ip_pull(buf
, buflen
, mem_ctx
,
857 &cd
->data
.pubip
, &np
);
860 case CTDB_CONTROL_TRAVERSE_KILL
:
861 ret
= ctdb_traverse_start_pull(buf
, buflen
, mem_ctx
,
862 &cd
->data
.traverse_start
, &np
);
865 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
866 ret
= ctdb_double_pull(buf
, buflen
, &cd
->data
.reclock_latency
,
870 case CTDB_CONTROL_SET_LMASTERROLE
:
871 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.role
, &np
);
874 case CTDB_CONTROL_SET_RECMASTERROLE
:
875 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.role
, &np
);
878 case CTDB_CONTROL_SET_BAN_STATE
:
879 ret
= ctdb_ban_state_pull(buf
, buflen
, mem_ctx
,
880 &cd
->data
.ban_state
, &np
);
883 case CTDB_CONTROL_REGISTER_NOTIFY
:
884 ret
= ctdb_notify_data_pull(buf
, buflen
, mem_ctx
,
885 &cd
->data
.notify
, &np
);
888 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
889 ret
= ctdb_uint64_pull(buf
, buflen
, &cd
->data
.srvid
, &np
);
892 case CTDB_CONTROL_TRANS3_COMMIT
:
893 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
894 &cd
->data
.recbuf
, &np
);
897 case CTDB_CONTROL_GET_DB_SEQNUM
:
899 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
904 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &u32
, &np
);
909 case CTDB_CONTROL_DB_SET_HEALTHY
:
910 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
913 case CTDB_CONTROL_DB_GET_HEALTH
:
914 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
917 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
918 ret
= ctdb_sock_addr_pull(buf
, buflen
, mem_ctx
,
919 &cd
->data
.addr
, &np
);
922 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
923 ret
= ctdb_iface_pull(buf
, buflen
, mem_ctx
,
924 &cd
->data
.iface
, &np
);
927 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
928 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
929 &cd
->data
.conn
, &np
);
932 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
933 ret
= ctdb_key_data_pull(buf
, buflen
, mem_ctx
,
937 case CTDB_CONTROL_SET_DB_READONLY
:
938 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
941 case CTDB_CONTROL_TRAVERSE_START_EXT
:
942 ret
= ctdb_traverse_start_ext_pull(buf
, buflen
, mem_ctx
,
943 &cd
->data
.traverse_start_ext
,
947 case CTDB_CONTROL_GET_DB_STATISTICS
:
948 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
951 case CTDB_CONTROL_SET_DB_STICKY
:
952 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
955 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
956 ret
= ctdb_traverse_all_ext_pull(buf
, buflen
, mem_ctx
,
957 &cd
->data
.traverse_all_ext
,
961 case CTDB_CONTROL_DB_DETACH
:
962 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
965 case CTDB_CONTROL_DB_FREEZE
:
966 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
969 case CTDB_CONTROL_DB_THAW
:
970 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
973 case CTDB_CONTROL_DB_TRANSACTION_START
:
974 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
975 &cd
->data
.transdb
, &np
);
978 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
979 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
980 &cd
->data
.transdb
, &np
);
983 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
984 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
987 case CTDB_CONTROL_DB_PULL
:
988 ret
= ctdb_pulldb_ext_pull(buf
, buflen
, mem_ctx
,
989 &cd
->data
.pulldb_ext
, &np
);
992 case CTDB_CONTROL_DB_PUSH_START
:
993 ret
= ctdb_pulldb_ext_pull(buf
, buflen
, mem_ctx
,
994 &cd
->data
.pulldb_ext
, &np
);
997 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
998 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1001 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1002 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1005 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1006 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1007 &cd
->data
.db_name
, &np
);
1010 case CTDB_CONTROL_CHECK_PID_SRVID
:
1011 ret
= ctdb_pid_srvid_pull(buf
, buflen
, mem_ctx
,
1012 &cd
->data
.pid_srvid
, &np
);
1015 case CTDB_CONTROL_VACUUM_FETCH
:
1016 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
1017 &cd
->data
.recbuf
, &np
);
1020 case CTDB_CONTROL_DB_VACUUM
:
1021 ret
= ctdb_db_vacuum_pull(buf
,
1024 &cd
->data
.db_vacuum
,
1028 case CTDB_CONTROL_ECHO_DATA
:
1029 ret
= ctdb_echo_data_pull(buf
,
1032 &cd
->data
.echo_data
,
1036 case CTDB_CONTROL_TCP_CLIENT_DISCONNECTED
:
1037 ret
= ctdb_connection_pull(buf
,
1044 case CTDB_CONTROL_TCP_CLIENT_PASSED
:
1045 ret
= ctdb_connection_pull(buf
,
1061 static size_t ctdb_reply_control_data_len(struct ctdb_reply_control_data
*cd
)
1069 switch (cd
->opcode
) {
1070 case CTDB_CONTROL_PROCESS_EXISTS
:
1073 case CTDB_CONTROL_STATISTICS
:
1074 len
= ctdb_statistics_len(cd
->data
.stats
);
1077 case CTDB_CONTROL_PING
:
1080 case CTDB_CONTROL_GETDBPATH
:
1081 len
= ctdb_string_len(&cd
->data
.db_path
);
1084 case CTDB_CONTROL_GETVNNMAP
:
1085 len
= ctdb_vnn_map_len(cd
->data
.vnnmap
);
1088 case CTDB_CONTROL_SETVNNMAP
:
1091 case CTDB_CONTROL_GET_DEBUG
:
1092 len
= ctdb_uint32_len(&cd
->data
.loglevel
);
1095 case CTDB_CONTROL_SET_DEBUG
:
1098 case CTDB_CONTROL_GET_DBMAP
:
1099 len
= ctdb_dbid_map_len(cd
->data
.dbmap
);
1102 case CTDB_CONTROL_GET_RECMODE
:
1105 case CTDB_CONTROL_SET_RECMODE
:
1108 case CTDB_CONTROL_STATISTICS_RESET
:
1111 case CTDB_CONTROL_DB_ATTACH
:
1112 len
= ctdb_uint32_len(&cd
->data
.db_id
);
1115 case CTDB_CONTROL_TRAVERSE_START
:
1118 case CTDB_CONTROL_TRAVERSE_ALL
:
1121 case CTDB_CONTROL_TRAVERSE_DATA
:
1124 case CTDB_CONTROL_REGISTER_SRVID
:
1127 case CTDB_CONTROL_DEREGISTER_SRVID
:
1130 case CTDB_CONTROL_GET_DBNAME
:
1131 len
= ctdb_string_len(&cd
->data
.db_name
);
1134 case CTDB_CONTROL_ENABLE_SEQNUM
:
1137 case CTDB_CONTROL_UPDATE_SEQNUM
:
1140 case CTDB_CONTROL_DUMP_MEMORY
:
1141 len
= ctdb_string_len(&cd
->data
.mem_str
);
1144 case CTDB_CONTROL_GET_PID
:
1147 case CTDB_CONTROL_FREEZE
:
1150 case CTDB_CONTROL_GET_PNN
:
1153 case CTDB_CONTROL_SHUTDOWN
:
1156 case CTDB_CONTROL_TCP_CLIENT
:
1159 case CTDB_CONTROL_TCP_ADD
:
1162 case CTDB_CONTROL_TCP_REMOVE
:
1165 case CTDB_CONTROL_STARTUP
:
1168 case CTDB_CONTROL_SET_TUNABLE
:
1171 case CTDB_CONTROL_GET_TUNABLE
:
1172 len
= ctdb_uint32_len(&cd
->data
.tun_value
);
1175 case CTDB_CONTROL_LIST_TUNABLES
:
1176 len
= ctdb_var_list_len(cd
->data
.tun_var_list
);
1179 case CTDB_CONTROL_MODIFY_FLAGS
:
1182 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1183 len
= ctdb_tunable_list_len(cd
->data
.tun_list
);
1186 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1187 len
= ctdb_tickle_list_len(cd
->data
.tickles
);
1190 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
1193 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1194 len
= ctdb_uint32_len(&cd
->data
.db_id
);
1197 case CTDB_CONTROL_UPDATE_RECORD
:
1200 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
1203 case CTDB_CONTROL_WIPE_DATABASE
:
1206 case CTDB_CONTROL_UPTIME
:
1207 len
= ctdb_uptime_len(cd
->data
.uptime
);
1210 case CTDB_CONTROL_START_RECOVERY
:
1213 case CTDB_CONTROL_END_RECOVERY
:
1216 case CTDB_CONTROL_RELOAD_NODES_FILE
:
1219 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1220 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
1223 case CTDB_CONTROL_ADD_PUBLIC_IP
:
1226 case CTDB_CONTROL_DEL_PUBLIC_IP
:
1229 case CTDB_CONTROL_GET_CAPABILITIES
:
1230 len
= ctdb_uint32_len(&cd
->data
.caps
);
1233 case CTDB_CONTROL_RECD_PING
:
1236 case CTDB_CONTROL_RELEASE_IP
:
1239 case CTDB_CONTROL_TAKEOVER_IP
:
1242 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1243 len
= ctdb_public_ip_list_len(cd
->data
.pubip_list
);
1246 case CTDB_CONTROL_GET_NODEMAP
:
1247 len
= ctdb_node_map_len(cd
->data
.nodemap
);
1250 case CTDB_CONTROL_TRAVERSE_KILL
:
1253 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
1256 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1257 len
= ctdb_string_len(&cd
->data
.reclock_file
);
1260 case CTDB_CONTROL_STOP_NODE
:
1263 case CTDB_CONTROL_CONTINUE_NODE
:
1266 case CTDB_CONTROL_SET_LMASTERROLE
:
1269 case CTDB_CONTROL_SET_RECMASTERROLE
:
1272 case CTDB_CONTROL_SET_BAN_STATE
:
1275 case CTDB_CONTROL_GET_BAN_STATE
:
1276 len
= ctdb_ban_state_len(cd
->data
.ban_state
);
1279 case CTDB_CONTROL_REGISTER_NOTIFY
:
1282 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
1285 case CTDB_CONTROL_TRANS3_COMMIT
:
1288 case CTDB_CONTROL_GET_DB_SEQNUM
:
1289 len
= ctdb_uint64_len(&cd
->data
.seqnum
);
1292 case CTDB_CONTROL_DB_SET_HEALTHY
:
1295 case CTDB_CONTROL_DB_GET_HEALTH
:
1296 len
= ctdb_string_len(&cd
->data
.reason
);
1299 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1300 len
= ctdb_public_ip_info_len(cd
->data
.ipinfo
);
1303 case CTDB_CONTROL_GET_IFACES
:
1304 len
= ctdb_iface_list_len(cd
->data
.iface_list
);
1307 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
1310 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
1313 case CTDB_CONTROL_GET_STAT_HISTORY
:
1314 len
= ctdb_statistics_list_len(cd
->data
.stats_list
);
1317 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
1320 case CTDB_CONTROL_SET_DB_READONLY
:
1323 case CTDB_CONTROL_TRAVERSE_START_EXT
:
1326 case CTDB_CONTROL_GET_DB_STATISTICS
:
1327 len
= ctdb_db_statistics_len(cd
->data
.dbstats
);
1330 case CTDB_CONTROL_SET_DB_STICKY
:
1333 case CTDB_CONTROL_RELOAD_PUBLIC_IPS
:
1336 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
1339 case CTDB_CONTROL_IPREALLOCATED
:
1342 case CTDB_CONTROL_GET_RUNSTATE
:
1343 len
= ctdb_uint32_len(&cd
->data
.runstate
);
1346 case CTDB_CONTROL_DB_DETACH
:
1349 case CTDB_CONTROL_GET_NODES_FILE
:
1350 len
= ctdb_node_map_len(cd
->data
.nodemap
);
1353 case CTDB_CONTROL_DB_FREEZE
:
1356 case CTDB_CONTROL_DB_THAW
:
1359 case CTDB_CONTROL_DB_TRANSACTION_START
:
1362 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
1365 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
1368 case CTDB_CONTROL_DB_PULL
:
1369 len
= ctdb_uint32_len(&cd
->data
.num_records
);
1372 case CTDB_CONTROL_DB_PUSH_START
:
1375 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1376 len
= ctdb_uint32_len(&cd
->data
.num_records
);
1379 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1380 len
= ctdb_int32_len(&cd
->data
.tdb_flags
);
1383 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1384 len
= ctdb_uint32_len(&cd
->data
.db_id
);
1387 case CTDB_CONTROL_CHECK_PID_SRVID
:
1390 case CTDB_CONTROL_TUNNEL_REGISTER
:
1393 case CTDB_CONTROL_TUNNEL_DEREGISTER
:
1396 case CTDB_CONTROL_VACUUM_FETCH
:
1399 case CTDB_CONTROL_DB_VACUUM
:
1402 case CTDB_CONTROL_ECHO_DATA
:
1403 len
= ctdb_echo_data_len(cd
->data
.echo_data
);
1406 case CTDB_CONTROL_DISABLE_NODE
:
1409 case CTDB_CONTROL_ENABLE_NODE
:
1412 case CTDB_CONTROL_TCP_CLIENT_DISCONNECTED
:
1415 case CTDB_CONTROL_TCP_CLIENT_PASSED
:
1422 static void ctdb_reply_control_data_push(struct ctdb_reply_control_data
*cd
,
1423 uint8_t *buf
, size_t *npush
)
1427 switch (cd
->opcode
) {
1428 case CTDB_CONTROL_STATISTICS
:
1429 ctdb_statistics_push(cd
->data
.stats
, buf
, &np
);
1432 case CTDB_CONTROL_GETDBPATH
:
1433 ctdb_string_push(&cd
->data
.db_path
, buf
, &np
);
1436 case CTDB_CONTROL_GETVNNMAP
:
1437 ctdb_vnn_map_push(cd
->data
.vnnmap
, buf
, &np
);
1440 case CTDB_CONTROL_GET_DEBUG
:
1441 ctdb_uint32_push(&cd
->data
.loglevel
, buf
, &np
);
1444 case CTDB_CONTROL_GET_DBMAP
:
1445 ctdb_dbid_map_push(cd
->data
.dbmap
, buf
, &np
);
1448 case CTDB_CONTROL_DB_ATTACH
:
1449 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
1452 case CTDB_CONTROL_GET_DBNAME
:
1453 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
1456 case CTDB_CONTROL_DUMP_MEMORY
:
1457 ctdb_string_push(&cd
->data
.mem_str
, buf
, &np
);
1460 case CTDB_CONTROL_GET_PID
:
1463 case CTDB_CONTROL_GET_TUNABLE
:
1464 ctdb_uint32_push(&cd
->data
.tun_value
, buf
, &np
);
1467 case CTDB_CONTROL_LIST_TUNABLES
:
1468 ctdb_var_list_push(cd
->data
.tun_var_list
, buf
, &np
);
1471 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1472 ctdb_tunable_list_push(cd
->data
.tun_list
, buf
, &np
);
1475 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1476 ctdb_tickle_list_push(cd
->data
.tickles
, buf
, &np
);
1479 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1480 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
1483 case CTDB_CONTROL_UPTIME
:
1484 ctdb_uptime_push(cd
->data
.uptime
, buf
, &np
);
1487 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1488 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
1491 case CTDB_CONTROL_GET_CAPABILITIES
:
1492 ctdb_uint32_push(&cd
->data
.caps
, buf
, &np
);
1495 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1496 ctdb_public_ip_list_push(cd
->data
.pubip_list
, buf
, &np
);
1499 case CTDB_CONTROL_GET_NODEMAP
:
1500 ctdb_node_map_push(cd
->data
.nodemap
, buf
, &np
);
1503 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1504 ctdb_string_push(&cd
->data
.reclock_file
, buf
, &np
);
1507 case CTDB_CONTROL_GET_BAN_STATE
:
1508 ctdb_ban_state_push(cd
->data
.ban_state
, buf
, &np
);
1511 case CTDB_CONTROL_GET_DB_SEQNUM
:
1512 ctdb_uint64_push(&cd
->data
.seqnum
, buf
, &np
);
1515 case CTDB_CONTROL_DB_GET_HEALTH
:
1516 ctdb_string_push(&cd
->data
.reason
, buf
, &np
);
1519 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1520 ctdb_public_ip_info_push(cd
->data
.ipinfo
, buf
, &np
);
1523 case CTDB_CONTROL_GET_IFACES
:
1524 ctdb_iface_list_push(cd
->data
.iface_list
, buf
, &np
);
1527 case CTDB_CONTROL_GET_STAT_HISTORY
:
1528 ctdb_statistics_list_push(cd
->data
.stats_list
, buf
, &np
);
1531 case CTDB_CONTROL_GET_DB_STATISTICS
:
1532 ctdb_db_statistics_push(cd
->data
.dbstats
, buf
, &np
);
1535 case CTDB_CONTROL_GET_RUNSTATE
:
1536 ctdb_uint32_push(&cd
->data
.runstate
, buf
, &np
);
1539 case CTDB_CONTROL_GET_NODES_FILE
:
1540 ctdb_node_map_push(cd
->data
.nodemap
, buf
, &np
);
1543 case CTDB_CONTROL_DB_PULL
:
1544 ctdb_uint32_push(&cd
->data
.num_records
, buf
, &np
);
1547 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1548 ctdb_uint32_push(&cd
->data
.num_records
, buf
, &np
);
1551 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1552 ctdb_int32_push(&cd
->data
.tdb_flags
, buf
, &np
);
1555 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1556 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
1559 case CTDB_CONTROL_CHECK_PID_SRVID
:
1562 case CTDB_CONTROL_VACUUM_FETCH
:
1565 case CTDB_CONTROL_DB_VACUUM
:
1568 case CTDB_CONTROL_ECHO_DATA
:
1569 ctdb_echo_data_push(cd
->data
.echo_data
, buf
, &np
);
1576 static int ctdb_reply_control_data_pull(uint8_t *buf
, size_t buflen
,
1577 uint32_t opcode
, TALLOC_CTX
*mem_ctx
,
1578 struct ctdb_reply_control_data
*cd
,
1584 cd
->opcode
= opcode
;
1587 case CTDB_CONTROL_STATISTICS
:
1588 ret
= ctdb_statistics_pull(buf
, buflen
, mem_ctx
,
1589 &cd
->data
.stats
, &np
);
1592 case CTDB_CONTROL_GETDBPATH
:
1593 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1594 &cd
->data
.db_path
, &np
);
1597 case CTDB_CONTROL_GETVNNMAP
:
1598 ret
= ctdb_vnn_map_pull(buf
, buflen
, mem_ctx
,
1599 &cd
->data
.vnnmap
, &np
);
1602 case CTDB_CONTROL_GET_DEBUG
:
1603 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.loglevel
, &np
);
1606 case CTDB_CONTROL_GET_DBMAP
:
1607 ret
= ctdb_dbid_map_pull(buf
, buflen
, mem_ctx
,
1608 &cd
->data
.dbmap
, &np
);
1611 case CTDB_CONTROL_DB_ATTACH
:
1612 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1615 case CTDB_CONTROL_GET_DBNAME
:
1616 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1617 &cd
->data
.db_name
, &np
);
1620 case CTDB_CONTROL_DUMP_MEMORY
:
1621 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1622 &cd
->data
.mem_str
, &np
);
1625 case CTDB_CONTROL_GET_PID
:
1628 case CTDB_CONTROL_GET_TUNABLE
:
1629 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.tun_value
,
1633 case CTDB_CONTROL_LIST_TUNABLES
:
1634 ret
= ctdb_var_list_pull(buf
, buflen
, mem_ctx
,
1635 &cd
->data
.tun_var_list
, &np
);
1638 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1639 ret
= ctdb_tunable_list_pull(buf
, buflen
, mem_ctx
,
1640 &cd
->data
.tun_list
, &np
);
1643 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1644 ret
= ctdb_tickle_list_pull(buf
, buflen
, mem_ctx
,
1645 &cd
->data
.tickles
, &np
);
1648 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1649 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1652 case CTDB_CONTROL_UPTIME
:
1653 ret
= ctdb_uptime_pull(buf
, buflen
, mem_ctx
,
1654 &cd
->data
.uptime
, &np
);
1657 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1658 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
1659 &cd
->data
.recbuf
, &np
);
1662 case CTDB_CONTROL_GET_CAPABILITIES
:
1663 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.caps
, &np
);
1666 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1667 ret
= ctdb_public_ip_list_pull(buf
, buflen
, mem_ctx
,
1668 &cd
->data
.pubip_list
, &np
);
1671 case CTDB_CONTROL_GET_NODEMAP
:
1672 ret
= ctdb_node_map_pull(buf
, buflen
, mem_ctx
,
1673 &cd
->data
.nodemap
, &np
);
1676 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1677 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1678 &cd
->data
.reclock_file
, &np
);
1681 case CTDB_CONTROL_GET_BAN_STATE
:
1682 ret
= ctdb_ban_state_pull(buf
, buflen
, mem_ctx
,
1683 &cd
->data
.ban_state
, &np
);
1686 case CTDB_CONTROL_GET_DB_SEQNUM
:
1687 ret
= ctdb_uint64_pull(buf
, buflen
, &cd
->data
.seqnum
, &np
);
1690 case CTDB_CONTROL_DB_GET_HEALTH
:
1691 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1692 &cd
->data
.reason
, &np
);
1695 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1696 ret
= ctdb_public_ip_info_pull(buf
, buflen
, mem_ctx
,
1697 &cd
->data
.ipinfo
, &np
);
1700 case CTDB_CONTROL_GET_IFACES
:
1701 ret
= ctdb_iface_list_pull(buf
, buflen
, mem_ctx
,
1702 &cd
->data
.iface_list
, &np
);
1705 case CTDB_CONTROL_GET_STAT_HISTORY
:
1706 ret
= ctdb_statistics_list_pull(buf
, buflen
, mem_ctx
,
1707 &cd
->data
.stats_list
, &np
);
1710 case CTDB_CONTROL_GET_DB_STATISTICS
:
1711 ret
= ctdb_db_statistics_pull(buf
, buflen
, mem_ctx
,
1712 &cd
->data
.dbstats
, &np
);
1715 case CTDB_CONTROL_GET_RUNSTATE
:
1716 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.runstate
, &np
);
1719 case CTDB_CONTROL_GET_NODES_FILE
:
1720 ret
= ctdb_node_map_pull(buf
, buflen
, mem_ctx
,
1721 &cd
->data
.nodemap
, &np
);
1724 case CTDB_CONTROL_DB_PULL
:
1725 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.num_records
,
1729 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1730 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.num_records
,
1734 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1735 ret
= ctdb_int32_pull(buf
, buflen
, &cd
->data
.tdb_flags
, &np
);
1738 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1739 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1742 case CTDB_CONTROL_CHECK_PID_SRVID
:
1745 case CTDB_CONTROL_VACUUM_FETCH
:
1748 case CTDB_CONTROL_DB_VACUUM
:
1751 case CTDB_CONTROL_ECHO_DATA
:
1752 ret
= ctdb_echo_data_pull(buf
,
1755 &cd
->data
.echo_data
,
1768 size_t ctdb_req_control_len(struct ctdb_req_header
*h
,
1769 struct ctdb_req_control
*c
)
1773 return ctdb_req_header_len(h
) +
1774 ctdb_uint32_len(&c
->opcode
) +
1775 ctdb_uint32_len(&c
->pad
) +
1776 ctdb_uint64_len(&c
->srvid
) +
1777 ctdb_uint32_len(&c
->client_id
) +
1778 ctdb_uint32_len(&c
->flags
) +
1779 ctdb_uint32_len(&u32
) +
1780 ctdb_req_control_data_len(&c
->rdata
);
1783 int ctdb_req_control_push(struct ctdb_req_header
*h
,
1784 struct ctdb_req_control
*c
,
1785 uint8_t *buf
, size_t *buflen
)
1787 size_t offset
= 0, np
;
1791 length
= ctdb_req_control_len(h
, c
);
1792 if (*buflen
< length
) {
1797 h
->length
= *buflen
;
1798 ctdb_req_header_push(h
, buf
+offset
, &np
);
1801 ctdb_uint32_push(&c
->opcode
, buf
+offset
, &np
);
1804 ctdb_uint32_push(&c
->pad
, buf
+offset
, &np
);
1807 ctdb_uint64_push(&c
->srvid
, buf
+offset
, &np
);
1810 ctdb_uint32_push(&c
->client_id
, buf
+offset
, &np
);
1813 ctdb_uint32_push(&c
->flags
, buf
+offset
, &np
);
1816 u32
= ctdb_req_control_data_len(&c
->rdata
);
1817 ctdb_uint32_push(&u32
, buf
+offset
, &np
);
1820 ctdb_req_control_data_push(&c
->rdata
, buf
+offset
, &np
);
1823 if (offset
> *buflen
) {
1830 int ctdb_req_control_pull(uint8_t *buf
, size_t buflen
,
1831 struct ctdb_req_header
*h
,
1832 TALLOC_CTX
*mem_ctx
,
1833 struct ctdb_req_control
*c
)
1835 struct ctdb_req_header header
;
1836 size_t offset
= 0, np
;
1840 ret
= ctdb_req_header_pull(buf
+offset
, buflen
-offset
, &header
, &np
);
1850 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->opcode
, &np
);
1856 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->pad
, &np
);
1862 ret
= ctdb_uint64_pull(buf
+offset
, buflen
-offset
, &c
->srvid
, &np
);
1868 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->client_id
, &np
);
1874 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->flags
, &np
);
1880 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &u32
, &np
);
1886 if (u32
> buflen
-offset
) {
1890 ret
= ctdb_req_control_data_pull(buf
+offset
, u32
, c
->opcode
, mem_ctx
,
1897 if (offset
> buflen
) {
1904 size_t ctdb_reply_control_len(struct ctdb_req_header
*h
,
1905 struct ctdb_reply_control
*c
)
1907 uint32_t dsize
, esize
;
1909 if (c
->status
== 0) {
1910 dsize
= ctdb_reply_control_data_len(&c
->rdata
);
1914 esize
= ctdb_string_len(&c
->errmsg
);
1917 return ctdb_req_header_len(h
) +
1918 ctdb_int32_len(&c
->status
) +
1919 ctdb_uint32_len(&dsize
) +
1920 ctdb_uint32_len(&esize
) +
1924 int ctdb_reply_control_push(struct ctdb_req_header
*h
,
1925 struct ctdb_reply_control
*c
,
1926 uint8_t *buf
, size_t *buflen
)
1928 size_t offset
= 0, np
;
1930 uint32_t dsize
, esize
;
1932 length
= ctdb_reply_control_len(h
, c
);
1933 if (*buflen
< length
) {
1938 h
->length
= *buflen
;
1939 ctdb_req_header_push(h
, buf
+offset
, &np
);
1942 ctdb_int32_push(&c
->status
, buf
+offset
, &np
);
1945 if (c
->status
== 0) {
1946 dsize
= ctdb_reply_control_data_len(&c
->rdata
);
1950 esize
= ctdb_string_len(&c
->errmsg
);
1953 ctdb_uint32_push(&dsize
, buf
+offset
, &np
);
1956 ctdb_uint32_push(&esize
, buf
+offset
, &np
);
1959 if (c
->status
== 0) {
1960 ctdb_reply_control_data_push(&c
->rdata
, buf
+offset
, &np
);
1962 ctdb_string_push(&c
->errmsg
, buf
+offset
, &np
);
1969 int ctdb_reply_control_pull(uint8_t *buf
, size_t buflen
, uint32_t opcode
,
1970 struct ctdb_req_header
*h
,
1971 TALLOC_CTX
*mem_ctx
,
1972 struct ctdb_reply_control
*c
)
1974 struct ctdb_req_header header
;
1975 size_t offset
= 0, np
;
1976 uint32_t dsize
, esize
;
1979 ret
= ctdb_req_header_pull(buf
+offset
, buflen
-offset
, &header
, &np
);
1989 ret
= ctdb_int32_pull(buf
+offset
, buflen
-offset
, &c
->status
, &np
);
1995 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &dsize
, &np
);
2001 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &esize
, &np
);
2009 if (c
->status
== 0) {
2010 if (buflen
-offset
< dsize
) {
2014 ret
= ctdb_reply_control_data_pull(buf
+offset
, dsize
,
2015 opcode
, mem_ctx
, &c
->rdata
,
2023 if (buflen
-offset
< esize
) {
2027 ret
= ctdb_string_pull(buf
+offset
, esize
, mem_ctx
, &c
->errmsg
,