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
);
422 case CTDB_CONTROL_START_IPREALLOCATE
:
429 static void ctdb_req_control_data_push(struct ctdb_req_control_data
*cd
,
430 uint8_t *buf
, size_t *npush
)
432 size_t np
= 0, offset
;
435 switch (cd
->opcode
) {
436 case CTDB_CONTROL_PROCESS_EXISTS
:
437 ctdb_pid_push(&cd
->data
.pid
, buf
, &np
);
440 case CTDB_CONTROL_GETDBPATH
:
441 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
444 case CTDB_CONTROL_SETVNNMAP
:
445 ctdb_vnn_map_push(cd
->data
.vnnmap
, buf
, &np
);
448 case CTDB_CONTROL_SET_DEBUG
:
449 ctdb_uint32_push(&cd
->data
.loglevel
, buf
, &np
);
452 case CTDB_CONTROL_SET_RECMODE
:
453 ctdb_uint32_push(&cd
->data
.recmode
, buf
, &np
);
456 case CTDB_CONTROL_DB_ATTACH
:
457 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
460 case CTDB_CONTROL_TRAVERSE_START
:
461 ctdb_traverse_start_push(cd
->data
.traverse_start
, buf
, &np
);
464 case CTDB_CONTROL_TRAVERSE_ALL
:
465 ctdb_traverse_all_push(cd
->data
.traverse_all
, buf
, &np
);
468 case CTDB_CONTROL_TRAVERSE_DATA
:
469 ctdb_rec_data_push(cd
->data
.rec_data
, buf
, &np
);
472 case CTDB_CONTROL_GET_DBNAME
:
473 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
476 case CTDB_CONTROL_ENABLE_SEQNUM
:
477 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
480 case CTDB_CONTROL_UPDATE_SEQNUM
:
481 ctdb_uint32_push(&cd
->data
.db_id
, 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
);
700 case CTDB_CONTROL_TCP_CLIENT_DISCONNECTED
:
701 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
704 case CTDB_CONTROL_TCP_CLIENT_PASSED
:
705 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
712 static int ctdb_req_control_data_pull(uint8_t *buf
, size_t buflen
,
715 struct ctdb_req_control_data
*cd
,
718 size_t np
= 0, offset
;
725 case CTDB_CONTROL_PROCESS_EXISTS
:
726 ret
= ctdb_pid_pull(buf
, buflen
, &cd
->data
.pid
, &np
);
729 case CTDB_CONTROL_GETDBPATH
:
730 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
733 case CTDB_CONTROL_SETVNNMAP
:
734 ret
= ctdb_vnn_map_pull(buf
, buflen
, mem_ctx
,
735 &cd
->data
.vnnmap
, &np
);
738 case CTDB_CONTROL_SET_DEBUG
:
739 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.loglevel
, &np
);
742 case CTDB_CONTROL_SET_RECMODE
:
743 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.recmode
, &np
);
746 case CTDB_CONTROL_DB_ATTACH
:
747 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
748 &cd
->data
.db_name
, &np
);
751 case CTDB_CONTROL_TRAVERSE_START
:
752 ret
= ctdb_traverse_start_pull(buf
, buflen
, mem_ctx
,
753 &cd
->data
.traverse_start
, &np
);
756 case CTDB_CONTROL_TRAVERSE_ALL
:
757 ret
= ctdb_traverse_all_pull(buf
, buflen
, mem_ctx
,
758 &cd
->data
.traverse_all
, &np
);
761 case CTDB_CONTROL_TRAVERSE_DATA
:
762 ret
= ctdb_rec_data_pull(buf
, buflen
, mem_ctx
,
763 &cd
->data
.rec_data
, &np
);
766 case CTDB_CONTROL_GET_DBNAME
:
767 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
770 case CTDB_CONTROL_ENABLE_SEQNUM
:
771 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
774 case CTDB_CONTROL_UPDATE_SEQNUM
:
775 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
778 case CTDB_CONTROL_TCP_CLIENT
:
779 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
780 &cd
->data
.conn
, &np
);
783 case CTDB_CONTROL_TCP_ADD
:
784 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
785 &cd
->data
.conn
, &np
);
788 case CTDB_CONTROL_TCP_REMOVE
:
789 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
790 &cd
->data
.conn
, &np
);
793 case CTDB_CONTROL_SET_TUNABLE
:
794 ret
= ctdb_tunable_pull(buf
, buflen
, mem_ctx
,
795 &cd
->data
.tunable
, &np
);
798 case CTDB_CONTROL_GET_TUNABLE
:
799 ret
= ctdb_stringn_pull(buf
, buflen
, mem_ctx
,
800 &cd
->data
.tun_var
, &np
);
803 case CTDB_CONTROL_MODIFY_FLAGS
:
804 ret
= ctdb_node_flag_change_pull(buf
, buflen
, mem_ctx
,
805 &cd
->data
.flag_change
, &np
);
808 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
809 ret
= ctdb_sock_addr_pull(buf
, buflen
, mem_ctx
,
810 &cd
->data
.addr
, &np
);
813 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
814 ret
= ctdb_tickle_list_pull(buf
, buflen
, mem_ctx
,
815 &cd
->data
.tickles
, &np
);
818 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
819 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
820 &cd
->data
.db_name
, &np
);
823 case CTDB_CONTROL_UPDATE_RECORD
:
824 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
825 &cd
->data
.recbuf
, &np
);
828 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
829 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
830 &cd
->data
.addr_info
, &np
);
833 case CTDB_CONTROL_WIPE_DATABASE
:
834 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
835 &cd
->data
.transdb
, &np
);
838 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
839 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
840 &cd
->data
.recbuf
, &np
);
843 case CTDB_CONTROL_ADD_PUBLIC_IP
:
844 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
845 &cd
->data
.addr_info
, &np
);
848 case CTDB_CONTROL_DEL_PUBLIC_IP
:
849 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
850 &cd
->data
.addr_info
, &np
);
853 case CTDB_CONTROL_RELEASE_IP
:
854 ret
= ctdb_public_ip_pull(buf
, buflen
, mem_ctx
,
855 &cd
->data
.pubip
, &np
);
858 case CTDB_CONTROL_TAKEOVER_IP
:
859 ret
= ctdb_public_ip_pull(buf
, buflen
, mem_ctx
,
860 &cd
->data
.pubip
, &np
);
863 case CTDB_CONTROL_TRAVERSE_KILL
:
864 ret
= ctdb_traverse_start_pull(buf
, buflen
, mem_ctx
,
865 &cd
->data
.traverse_start
, &np
);
868 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
869 ret
= ctdb_double_pull(buf
, buflen
, &cd
->data
.reclock_latency
,
873 case CTDB_CONTROL_SET_LMASTERROLE
:
874 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.role
, &np
);
877 case CTDB_CONTROL_SET_RECMASTERROLE
:
878 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.role
, &np
);
881 case CTDB_CONTROL_SET_BAN_STATE
:
882 ret
= ctdb_ban_state_pull(buf
, buflen
, mem_ctx
,
883 &cd
->data
.ban_state
, &np
);
886 case CTDB_CONTROL_REGISTER_NOTIFY
:
887 ret
= ctdb_notify_data_pull(buf
, buflen
, mem_ctx
,
888 &cd
->data
.notify
, &np
);
891 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
892 ret
= ctdb_uint64_pull(buf
, buflen
, &cd
->data
.srvid
, &np
);
895 case CTDB_CONTROL_TRANS3_COMMIT
:
896 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
897 &cd
->data
.recbuf
, &np
);
900 case CTDB_CONTROL_GET_DB_SEQNUM
:
902 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
907 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &u32
, &np
);
912 case CTDB_CONTROL_DB_SET_HEALTHY
:
913 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
916 case CTDB_CONTROL_DB_GET_HEALTH
:
917 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
920 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
921 ret
= ctdb_sock_addr_pull(buf
, buflen
, mem_ctx
,
922 &cd
->data
.addr
, &np
);
925 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
926 ret
= ctdb_iface_pull(buf
, buflen
, mem_ctx
,
927 &cd
->data
.iface
, &np
);
930 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
931 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
932 &cd
->data
.conn
, &np
);
935 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
936 ret
= ctdb_key_data_pull(buf
, buflen
, mem_ctx
,
940 case CTDB_CONTROL_SET_DB_READONLY
:
941 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
944 case CTDB_CONTROL_TRAVERSE_START_EXT
:
945 ret
= ctdb_traverse_start_ext_pull(buf
, buflen
, mem_ctx
,
946 &cd
->data
.traverse_start_ext
,
950 case CTDB_CONTROL_GET_DB_STATISTICS
:
951 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
954 case CTDB_CONTROL_SET_DB_STICKY
:
955 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
958 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
959 ret
= ctdb_traverse_all_ext_pull(buf
, buflen
, mem_ctx
,
960 &cd
->data
.traverse_all_ext
,
964 case CTDB_CONTROL_DB_DETACH
:
965 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
968 case CTDB_CONTROL_DB_FREEZE
:
969 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
972 case CTDB_CONTROL_DB_THAW
:
973 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
976 case CTDB_CONTROL_DB_TRANSACTION_START
:
977 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
978 &cd
->data
.transdb
, &np
);
981 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
982 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
983 &cd
->data
.transdb
, &np
);
986 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
987 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
990 case CTDB_CONTROL_DB_PULL
:
991 ret
= ctdb_pulldb_ext_pull(buf
, buflen
, mem_ctx
,
992 &cd
->data
.pulldb_ext
, &np
);
995 case CTDB_CONTROL_DB_PUSH_START
:
996 ret
= ctdb_pulldb_ext_pull(buf
, buflen
, mem_ctx
,
997 &cd
->data
.pulldb_ext
, &np
);
1000 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1001 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1004 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1005 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1008 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1009 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1010 &cd
->data
.db_name
, &np
);
1013 case CTDB_CONTROL_CHECK_PID_SRVID
:
1014 ret
= ctdb_pid_srvid_pull(buf
, buflen
, mem_ctx
,
1015 &cd
->data
.pid_srvid
, &np
);
1018 case CTDB_CONTROL_VACUUM_FETCH
:
1019 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
1020 &cd
->data
.recbuf
, &np
);
1023 case CTDB_CONTROL_DB_VACUUM
:
1024 ret
= ctdb_db_vacuum_pull(buf
,
1027 &cd
->data
.db_vacuum
,
1031 case CTDB_CONTROL_ECHO_DATA
:
1032 ret
= ctdb_echo_data_pull(buf
,
1035 &cd
->data
.echo_data
,
1039 case CTDB_CONTROL_TCP_CLIENT_DISCONNECTED
:
1040 ret
= ctdb_connection_pull(buf
,
1047 case CTDB_CONTROL_TCP_CLIENT_PASSED
:
1048 ret
= ctdb_connection_pull(buf
,
1064 static size_t ctdb_reply_control_data_len(struct ctdb_reply_control_data
*cd
)
1072 switch (cd
->opcode
) {
1073 case CTDB_CONTROL_PROCESS_EXISTS
:
1076 case CTDB_CONTROL_STATISTICS
:
1077 len
= ctdb_statistics_len(cd
->data
.stats
);
1080 case CTDB_CONTROL_PING
:
1083 case CTDB_CONTROL_GETDBPATH
:
1084 len
= ctdb_string_len(&cd
->data
.db_path
);
1087 case CTDB_CONTROL_GETVNNMAP
:
1088 len
= ctdb_vnn_map_len(cd
->data
.vnnmap
);
1091 case CTDB_CONTROL_SETVNNMAP
:
1094 case CTDB_CONTROL_GET_DEBUG
:
1095 len
= ctdb_uint32_len(&cd
->data
.loglevel
);
1098 case CTDB_CONTROL_SET_DEBUG
:
1101 case CTDB_CONTROL_GET_DBMAP
:
1102 len
= ctdb_dbid_map_len(cd
->data
.dbmap
);
1105 case CTDB_CONTROL_GET_RECMODE
:
1108 case CTDB_CONTROL_SET_RECMODE
:
1111 case CTDB_CONTROL_STATISTICS_RESET
:
1114 case CTDB_CONTROL_DB_ATTACH
:
1115 len
= ctdb_uint32_len(&cd
->data
.db_id
);
1118 case CTDB_CONTROL_TRAVERSE_START
:
1121 case CTDB_CONTROL_TRAVERSE_ALL
:
1124 case CTDB_CONTROL_TRAVERSE_DATA
:
1127 case CTDB_CONTROL_REGISTER_SRVID
:
1130 case CTDB_CONTROL_DEREGISTER_SRVID
:
1133 case CTDB_CONTROL_GET_DBNAME
:
1134 len
= ctdb_string_len(&cd
->data
.db_name
);
1137 case CTDB_CONTROL_ENABLE_SEQNUM
:
1140 case CTDB_CONTROL_UPDATE_SEQNUM
:
1143 case CTDB_CONTROL_DUMP_MEMORY
:
1144 len
= ctdb_string_len(&cd
->data
.mem_str
);
1147 case CTDB_CONTROL_GET_PID
:
1150 case CTDB_CONTROL_FREEZE
:
1153 case CTDB_CONTROL_GET_PNN
:
1156 case CTDB_CONTROL_SHUTDOWN
:
1159 case CTDB_CONTROL_TCP_CLIENT
:
1162 case CTDB_CONTROL_TCP_ADD
:
1165 case CTDB_CONTROL_TCP_REMOVE
:
1168 case CTDB_CONTROL_STARTUP
:
1171 case CTDB_CONTROL_SET_TUNABLE
:
1174 case CTDB_CONTROL_GET_TUNABLE
:
1175 len
= ctdb_uint32_len(&cd
->data
.tun_value
);
1178 case CTDB_CONTROL_LIST_TUNABLES
:
1179 len
= ctdb_var_list_len(cd
->data
.tun_var_list
);
1182 case CTDB_CONTROL_MODIFY_FLAGS
:
1185 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1186 len
= ctdb_tunable_list_len(cd
->data
.tun_list
);
1189 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1190 len
= ctdb_tickle_list_len(cd
->data
.tickles
);
1193 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
1196 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1197 len
= ctdb_uint32_len(&cd
->data
.db_id
);
1200 case CTDB_CONTROL_UPDATE_RECORD
:
1203 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
1206 case CTDB_CONTROL_WIPE_DATABASE
:
1209 case CTDB_CONTROL_UPTIME
:
1210 len
= ctdb_uptime_len(cd
->data
.uptime
);
1213 case CTDB_CONTROL_START_RECOVERY
:
1216 case CTDB_CONTROL_END_RECOVERY
:
1219 case CTDB_CONTROL_RELOAD_NODES_FILE
:
1222 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1223 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
1226 case CTDB_CONTROL_ADD_PUBLIC_IP
:
1229 case CTDB_CONTROL_DEL_PUBLIC_IP
:
1232 case CTDB_CONTROL_GET_CAPABILITIES
:
1233 len
= ctdb_uint32_len(&cd
->data
.caps
);
1236 case CTDB_CONTROL_RECD_PING
:
1239 case CTDB_CONTROL_RELEASE_IP
:
1242 case CTDB_CONTROL_TAKEOVER_IP
:
1245 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1246 len
= ctdb_public_ip_list_len(cd
->data
.pubip_list
);
1249 case CTDB_CONTROL_GET_NODEMAP
:
1250 len
= ctdb_node_map_len(cd
->data
.nodemap
);
1253 case CTDB_CONTROL_TRAVERSE_KILL
:
1256 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
1259 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1260 len
= ctdb_string_len(&cd
->data
.reclock_file
);
1263 case CTDB_CONTROL_STOP_NODE
:
1266 case CTDB_CONTROL_CONTINUE_NODE
:
1269 case CTDB_CONTROL_SET_LMASTERROLE
:
1272 case CTDB_CONTROL_SET_RECMASTERROLE
:
1275 case CTDB_CONTROL_SET_BAN_STATE
:
1278 case CTDB_CONTROL_GET_BAN_STATE
:
1279 len
= ctdb_ban_state_len(cd
->data
.ban_state
);
1282 case CTDB_CONTROL_REGISTER_NOTIFY
:
1285 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
1288 case CTDB_CONTROL_TRANS3_COMMIT
:
1291 case CTDB_CONTROL_GET_DB_SEQNUM
:
1292 len
= ctdb_uint64_len(&cd
->data
.seqnum
);
1295 case CTDB_CONTROL_DB_SET_HEALTHY
:
1298 case CTDB_CONTROL_DB_GET_HEALTH
:
1299 len
= ctdb_string_len(&cd
->data
.reason
);
1302 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1303 len
= ctdb_public_ip_info_len(cd
->data
.ipinfo
);
1306 case CTDB_CONTROL_GET_IFACES
:
1307 len
= ctdb_iface_list_len(cd
->data
.iface_list
);
1310 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
1313 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
1316 case CTDB_CONTROL_GET_STAT_HISTORY
:
1317 len
= ctdb_statistics_list_len(cd
->data
.stats_list
);
1320 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
1323 case CTDB_CONTROL_SET_DB_READONLY
:
1326 case CTDB_CONTROL_TRAVERSE_START_EXT
:
1329 case CTDB_CONTROL_GET_DB_STATISTICS
:
1330 len
= ctdb_db_statistics_len(cd
->data
.dbstats
);
1333 case CTDB_CONTROL_SET_DB_STICKY
:
1336 case CTDB_CONTROL_RELOAD_PUBLIC_IPS
:
1339 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
1342 case CTDB_CONTROL_IPREALLOCATED
:
1345 case CTDB_CONTROL_GET_RUNSTATE
:
1346 len
= ctdb_uint32_len(&cd
->data
.runstate
);
1349 case CTDB_CONTROL_DB_DETACH
:
1352 case CTDB_CONTROL_GET_NODES_FILE
:
1353 len
= ctdb_node_map_len(cd
->data
.nodemap
);
1356 case CTDB_CONTROL_DB_FREEZE
:
1359 case CTDB_CONTROL_DB_THAW
:
1362 case CTDB_CONTROL_DB_TRANSACTION_START
:
1365 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
1368 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
1371 case CTDB_CONTROL_DB_PULL
:
1372 len
= ctdb_uint32_len(&cd
->data
.num_records
);
1375 case CTDB_CONTROL_DB_PUSH_START
:
1378 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1379 len
= ctdb_uint32_len(&cd
->data
.num_records
);
1382 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1383 len
= ctdb_int32_len(&cd
->data
.tdb_flags
);
1386 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1387 len
= ctdb_uint32_len(&cd
->data
.db_id
);
1390 case CTDB_CONTROL_CHECK_PID_SRVID
:
1393 case CTDB_CONTROL_TUNNEL_REGISTER
:
1396 case CTDB_CONTROL_TUNNEL_DEREGISTER
:
1399 case CTDB_CONTROL_VACUUM_FETCH
:
1402 case CTDB_CONTROL_DB_VACUUM
:
1405 case CTDB_CONTROL_ECHO_DATA
:
1406 len
= ctdb_echo_data_len(cd
->data
.echo_data
);
1409 case CTDB_CONTROL_DISABLE_NODE
:
1412 case CTDB_CONTROL_ENABLE_NODE
:
1415 case CTDB_CONTROL_TCP_CLIENT_DISCONNECTED
:
1418 case CTDB_CONTROL_TCP_CLIENT_PASSED
:
1421 case CTDB_CONTROL_START_IPREALLOCATE
:
1428 static void ctdb_reply_control_data_push(struct ctdb_reply_control_data
*cd
,
1429 uint8_t *buf
, size_t *npush
)
1433 switch (cd
->opcode
) {
1434 case CTDB_CONTROL_STATISTICS
:
1435 ctdb_statistics_push(cd
->data
.stats
, buf
, &np
);
1438 case CTDB_CONTROL_GETDBPATH
:
1439 ctdb_string_push(&cd
->data
.db_path
, buf
, &np
);
1442 case CTDB_CONTROL_GETVNNMAP
:
1443 ctdb_vnn_map_push(cd
->data
.vnnmap
, buf
, &np
);
1446 case CTDB_CONTROL_GET_DEBUG
:
1447 ctdb_uint32_push(&cd
->data
.loglevel
, buf
, &np
);
1450 case CTDB_CONTROL_GET_DBMAP
:
1451 ctdb_dbid_map_push(cd
->data
.dbmap
, buf
, &np
);
1454 case CTDB_CONTROL_DB_ATTACH
:
1455 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
1458 case CTDB_CONTROL_GET_DBNAME
:
1459 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
1462 case CTDB_CONTROL_DUMP_MEMORY
:
1463 ctdb_string_push(&cd
->data
.mem_str
, buf
, &np
);
1466 case CTDB_CONTROL_GET_PID
:
1469 case CTDB_CONTROL_GET_TUNABLE
:
1470 ctdb_uint32_push(&cd
->data
.tun_value
, buf
, &np
);
1473 case CTDB_CONTROL_LIST_TUNABLES
:
1474 ctdb_var_list_push(cd
->data
.tun_var_list
, buf
, &np
);
1477 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1478 ctdb_tunable_list_push(cd
->data
.tun_list
, buf
, &np
);
1481 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1482 ctdb_tickle_list_push(cd
->data
.tickles
, buf
, &np
);
1485 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1486 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
1489 case CTDB_CONTROL_UPTIME
:
1490 ctdb_uptime_push(cd
->data
.uptime
, buf
, &np
);
1493 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1494 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
1497 case CTDB_CONTROL_GET_CAPABILITIES
:
1498 ctdb_uint32_push(&cd
->data
.caps
, buf
, &np
);
1501 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1502 ctdb_public_ip_list_push(cd
->data
.pubip_list
, buf
, &np
);
1505 case CTDB_CONTROL_GET_NODEMAP
:
1506 ctdb_node_map_push(cd
->data
.nodemap
, buf
, &np
);
1509 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1510 ctdb_string_push(&cd
->data
.reclock_file
, buf
, &np
);
1513 case CTDB_CONTROL_GET_BAN_STATE
:
1514 ctdb_ban_state_push(cd
->data
.ban_state
, buf
, &np
);
1517 case CTDB_CONTROL_GET_DB_SEQNUM
:
1518 ctdb_uint64_push(&cd
->data
.seqnum
, buf
, &np
);
1521 case CTDB_CONTROL_DB_GET_HEALTH
:
1522 ctdb_string_push(&cd
->data
.reason
, buf
, &np
);
1525 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1526 ctdb_public_ip_info_push(cd
->data
.ipinfo
, buf
, &np
);
1529 case CTDB_CONTROL_GET_IFACES
:
1530 ctdb_iface_list_push(cd
->data
.iface_list
, buf
, &np
);
1533 case CTDB_CONTROL_GET_STAT_HISTORY
:
1534 ctdb_statistics_list_push(cd
->data
.stats_list
, buf
, &np
);
1537 case CTDB_CONTROL_GET_DB_STATISTICS
:
1538 ctdb_db_statistics_push(cd
->data
.dbstats
, buf
, &np
);
1541 case CTDB_CONTROL_GET_RUNSTATE
:
1542 ctdb_uint32_push(&cd
->data
.runstate
, buf
, &np
);
1545 case CTDB_CONTROL_GET_NODES_FILE
:
1546 ctdb_node_map_push(cd
->data
.nodemap
, buf
, &np
);
1549 case CTDB_CONTROL_DB_PULL
:
1550 ctdb_uint32_push(&cd
->data
.num_records
, buf
, &np
);
1553 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1554 ctdb_uint32_push(&cd
->data
.num_records
, buf
, &np
);
1557 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1558 ctdb_int32_push(&cd
->data
.tdb_flags
, buf
, &np
);
1561 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1562 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
1565 case CTDB_CONTROL_CHECK_PID_SRVID
:
1568 case CTDB_CONTROL_VACUUM_FETCH
:
1571 case CTDB_CONTROL_DB_VACUUM
:
1574 case CTDB_CONTROL_ECHO_DATA
:
1575 ctdb_echo_data_push(cd
->data
.echo_data
, buf
, &np
);
1582 static int ctdb_reply_control_data_pull(uint8_t *buf
, size_t buflen
,
1583 uint32_t opcode
, TALLOC_CTX
*mem_ctx
,
1584 struct ctdb_reply_control_data
*cd
,
1590 cd
->opcode
= opcode
;
1593 case CTDB_CONTROL_STATISTICS
:
1594 ret
= ctdb_statistics_pull(buf
, buflen
, mem_ctx
,
1595 &cd
->data
.stats
, &np
);
1598 case CTDB_CONTROL_GETDBPATH
:
1599 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1600 &cd
->data
.db_path
, &np
);
1603 case CTDB_CONTROL_GETVNNMAP
:
1604 ret
= ctdb_vnn_map_pull(buf
, buflen
, mem_ctx
,
1605 &cd
->data
.vnnmap
, &np
);
1608 case CTDB_CONTROL_GET_DEBUG
:
1609 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.loglevel
, &np
);
1612 case CTDB_CONTROL_GET_DBMAP
:
1613 ret
= ctdb_dbid_map_pull(buf
, buflen
, mem_ctx
,
1614 &cd
->data
.dbmap
, &np
);
1617 case CTDB_CONTROL_DB_ATTACH
:
1618 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1621 case CTDB_CONTROL_GET_DBNAME
:
1622 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1623 &cd
->data
.db_name
, &np
);
1626 case CTDB_CONTROL_DUMP_MEMORY
:
1627 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1628 &cd
->data
.mem_str
, &np
);
1631 case CTDB_CONTROL_GET_PID
:
1634 case CTDB_CONTROL_GET_TUNABLE
:
1635 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.tun_value
,
1639 case CTDB_CONTROL_LIST_TUNABLES
:
1640 ret
= ctdb_var_list_pull(buf
, buflen
, mem_ctx
,
1641 &cd
->data
.tun_var_list
, &np
);
1644 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1645 ret
= ctdb_tunable_list_pull(buf
, buflen
, mem_ctx
,
1646 &cd
->data
.tun_list
, &np
);
1649 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1650 ret
= ctdb_tickle_list_pull(buf
, buflen
, mem_ctx
,
1651 &cd
->data
.tickles
, &np
);
1654 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1655 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1658 case CTDB_CONTROL_UPTIME
:
1659 ret
= ctdb_uptime_pull(buf
, buflen
, mem_ctx
,
1660 &cd
->data
.uptime
, &np
);
1663 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1664 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
1665 &cd
->data
.recbuf
, &np
);
1668 case CTDB_CONTROL_GET_CAPABILITIES
:
1669 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.caps
, &np
);
1672 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1673 ret
= ctdb_public_ip_list_pull(buf
, buflen
, mem_ctx
,
1674 &cd
->data
.pubip_list
, &np
);
1677 case CTDB_CONTROL_GET_NODEMAP
:
1678 ret
= ctdb_node_map_pull(buf
, buflen
, mem_ctx
,
1679 &cd
->data
.nodemap
, &np
);
1682 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1683 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1684 &cd
->data
.reclock_file
, &np
);
1687 case CTDB_CONTROL_GET_BAN_STATE
:
1688 ret
= ctdb_ban_state_pull(buf
, buflen
, mem_ctx
,
1689 &cd
->data
.ban_state
, &np
);
1692 case CTDB_CONTROL_GET_DB_SEQNUM
:
1693 ret
= ctdb_uint64_pull(buf
, buflen
, &cd
->data
.seqnum
, &np
);
1696 case CTDB_CONTROL_DB_GET_HEALTH
:
1697 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1698 &cd
->data
.reason
, &np
);
1701 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1702 ret
= ctdb_public_ip_info_pull(buf
, buflen
, mem_ctx
,
1703 &cd
->data
.ipinfo
, &np
);
1706 case CTDB_CONTROL_GET_IFACES
:
1707 ret
= ctdb_iface_list_pull(buf
, buflen
, mem_ctx
,
1708 &cd
->data
.iface_list
, &np
);
1711 case CTDB_CONTROL_GET_STAT_HISTORY
:
1712 ret
= ctdb_statistics_list_pull(buf
, buflen
, mem_ctx
,
1713 &cd
->data
.stats_list
, &np
);
1716 case CTDB_CONTROL_GET_DB_STATISTICS
:
1717 ret
= ctdb_db_statistics_pull(buf
, buflen
, mem_ctx
,
1718 &cd
->data
.dbstats
, &np
);
1721 case CTDB_CONTROL_GET_RUNSTATE
:
1722 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.runstate
, &np
);
1725 case CTDB_CONTROL_GET_NODES_FILE
:
1726 ret
= ctdb_node_map_pull(buf
, buflen
, mem_ctx
,
1727 &cd
->data
.nodemap
, &np
);
1730 case CTDB_CONTROL_DB_PULL
:
1731 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.num_records
,
1735 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1736 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.num_records
,
1740 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1741 ret
= ctdb_int32_pull(buf
, buflen
, &cd
->data
.tdb_flags
, &np
);
1744 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1745 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1748 case CTDB_CONTROL_CHECK_PID_SRVID
:
1751 case CTDB_CONTROL_VACUUM_FETCH
:
1754 case CTDB_CONTROL_DB_VACUUM
:
1757 case CTDB_CONTROL_ECHO_DATA
:
1758 ret
= ctdb_echo_data_pull(buf
,
1761 &cd
->data
.echo_data
,
1774 size_t ctdb_req_control_len(struct ctdb_req_header
*h
,
1775 struct ctdb_req_control
*c
)
1779 return ctdb_req_header_len(h
) +
1780 ctdb_uint32_len(&c
->opcode
) +
1781 ctdb_uint32_len(&c
->pad
) +
1782 ctdb_uint64_len(&c
->srvid
) +
1783 ctdb_uint32_len(&c
->client_id
) +
1784 ctdb_uint32_len(&c
->flags
) +
1785 ctdb_uint32_len(&u32
) +
1786 ctdb_req_control_data_len(&c
->rdata
);
1789 int ctdb_req_control_push(struct ctdb_req_header
*h
,
1790 struct ctdb_req_control
*c
,
1791 uint8_t *buf
, size_t *buflen
)
1793 size_t offset
= 0, np
;
1797 length
= ctdb_req_control_len(h
, c
);
1798 if (*buflen
< length
) {
1803 h
->length
= *buflen
;
1804 ctdb_req_header_push(h
, buf
+offset
, &np
);
1807 ctdb_uint32_push(&c
->opcode
, buf
+offset
, &np
);
1810 ctdb_uint32_push(&c
->pad
, buf
+offset
, &np
);
1813 ctdb_uint64_push(&c
->srvid
, buf
+offset
, &np
);
1816 ctdb_uint32_push(&c
->client_id
, buf
+offset
, &np
);
1819 ctdb_uint32_push(&c
->flags
, buf
+offset
, &np
);
1822 u32
= ctdb_req_control_data_len(&c
->rdata
);
1823 ctdb_uint32_push(&u32
, buf
+offset
, &np
);
1826 ctdb_req_control_data_push(&c
->rdata
, buf
+offset
, &np
);
1829 if (offset
> *buflen
) {
1836 int ctdb_req_control_pull(uint8_t *buf
, size_t buflen
,
1837 struct ctdb_req_header
*h
,
1838 TALLOC_CTX
*mem_ctx
,
1839 struct ctdb_req_control
*c
)
1841 struct ctdb_req_header header
;
1842 size_t offset
= 0, np
;
1846 ret
= ctdb_req_header_pull(buf
+offset
, buflen
-offset
, &header
, &np
);
1856 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->opcode
, &np
);
1862 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->pad
, &np
);
1868 ret
= ctdb_uint64_pull(buf
+offset
, buflen
-offset
, &c
->srvid
, &np
);
1874 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->client_id
, &np
);
1880 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->flags
, &np
);
1886 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &u32
, &np
);
1892 if (u32
> buflen
-offset
) {
1896 ret
= ctdb_req_control_data_pull(buf
+offset
, u32
, c
->opcode
, mem_ctx
,
1903 if (offset
> buflen
) {
1910 size_t ctdb_reply_control_len(struct ctdb_req_header
*h
,
1911 struct ctdb_reply_control
*c
)
1913 uint32_t dsize
, esize
;
1915 if (c
->status
== 0) {
1916 dsize
= ctdb_reply_control_data_len(&c
->rdata
);
1920 esize
= ctdb_string_len(&c
->errmsg
);
1923 return ctdb_req_header_len(h
) +
1924 ctdb_int32_len(&c
->status
) +
1925 ctdb_uint32_len(&dsize
) +
1926 ctdb_uint32_len(&esize
) +
1930 int ctdb_reply_control_push(struct ctdb_req_header
*h
,
1931 struct ctdb_reply_control
*c
,
1932 uint8_t *buf
, size_t *buflen
)
1934 size_t offset
= 0, np
;
1936 uint32_t dsize
, esize
;
1938 length
= ctdb_reply_control_len(h
, c
);
1939 if (*buflen
< length
) {
1944 h
->length
= *buflen
;
1945 ctdb_req_header_push(h
, buf
+offset
, &np
);
1948 ctdb_int32_push(&c
->status
, buf
+offset
, &np
);
1951 if (c
->status
== 0) {
1952 dsize
= ctdb_reply_control_data_len(&c
->rdata
);
1956 esize
= ctdb_string_len(&c
->errmsg
);
1959 ctdb_uint32_push(&dsize
, buf
+offset
, &np
);
1962 ctdb_uint32_push(&esize
, buf
+offset
, &np
);
1965 if (c
->status
== 0) {
1966 ctdb_reply_control_data_push(&c
->rdata
, buf
+offset
, &np
);
1968 ctdb_string_push(&c
->errmsg
, buf
+offset
, &np
);
1975 int ctdb_reply_control_pull(uint8_t *buf
, size_t buflen
, uint32_t opcode
,
1976 struct ctdb_req_header
*h
,
1977 TALLOC_CTX
*mem_ctx
,
1978 struct ctdb_reply_control
*c
)
1980 struct ctdb_req_header header
;
1981 size_t offset
= 0, np
;
1982 uint32_t dsize
, esize
;
1985 ret
= ctdb_req_header_pull(buf
+offset
, buflen
-offset
, &header
, &np
);
1995 ret
= ctdb_int32_pull(buf
+offset
, buflen
-offset
, &c
->status
, &np
);
2001 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &dsize
, &np
);
2007 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &esize
, &np
);
2015 if (c
->status
== 0) {
2016 if (buflen
-offset
< dsize
) {
2020 ret
= ctdb_reply_control_data_pull(buf
+offset
, dsize
,
2021 opcode
, mem_ctx
, &c
->rdata
,
2029 if (buflen
-offset
< esize
) {
2033 ret
= ctdb_string_pull(buf
+offset
, esize
, mem_ctx
, &c
->errmsg
,