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
:
418 static void ctdb_req_control_data_push(struct ctdb_req_control_data
*cd
,
419 uint8_t *buf
, size_t *npush
)
421 size_t np
= 0, offset
;
424 switch (cd
->opcode
) {
425 case CTDB_CONTROL_PROCESS_EXISTS
:
426 ctdb_pid_push(&cd
->data
.pid
, buf
, &np
);
429 case CTDB_CONTROL_GETDBPATH
:
430 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
433 case CTDB_CONTROL_SETVNNMAP
:
434 ctdb_vnn_map_push(cd
->data
.vnnmap
, buf
, &np
);
437 case CTDB_CONTROL_SET_DEBUG
:
438 ctdb_uint32_push(&cd
->data
.loglevel
, buf
, &np
);
441 case CTDB_CONTROL_SET_RECMODE
:
442 ctdb_uint32_push(&cd
->data
.recmode
, buf
, &np
);
445 case CTDB_CONTROL_DB_ATTACH
:
446 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
449 case CTDB_CONTROL_TRAVERSE_START
:
450 ctdb_traverse_start_push(cd
->data
.traverse_start
, buf
, &np
);
453 case CTDB_CONTROL_TRAVERSE_ALL
:
454 ctdb_traverse_all_push(cd
->data
.traverse_all
, buf
, &np
);
457 case CTDB_CONTROL_TRAVERSE_DATA
:
458 ctdb_rec_data_push(cd
->data
.rec_data
, buf
, &np
);
461 case CTDB_CONTROL_GET_DBNAME
:
462 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
465 case CTDB_CONTROL_ENABLE_SEQNUM
:
466 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
469 case CTDB_CONTROL_UPDATE_SEQNUM
:
470 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
473 case CTDB_CONTROL_TCP_CLIENT
:
474 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
477 case CTDB_CONTROL_TCP_ADD
:
478 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
481 case CTDB_CONTROL_TCP_REMOVE
:
482 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
485 case CTDB_CONTROL_SET_TUNABLE
:
486 ctdb_tunable_push(cd
->data
.tunable
, buf
, &np
);
489 case CTDB_CONTROL_GET_TUNABLE
:
490 ctdb_stringn_push(&cd
->data
.tun_var
, buf
, &np
);
493 case CTDB_CONTROL_MODIFY_FLAGS
:
494 ctdb_node_flag_change_push(cd
->data
.flag_change
, buf
, &np
);
497 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
498 ctdb_sock_addr_push(cd
->data
.addr
, buf
, &np
);
501 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
502 ctdb_tickle_list_push(cd
->data
.tickles
, buf
, &np
);
505 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
506 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
509 case CTDB_CONTROL_UPDATE_RECORD
:
510 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
513 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
514 ctdb_addr_info_push(cd
->data
.addr_info
, buf
, &np
);
517 case CTDB_CONTROL_WIPE_DATABASE
:
518 ctdb_transdb_push(cd
->data
.transdb
, buf
, &np
);
521 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
522 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
525 case CTDB_CONTROL_ADD_PUBLIC_IP
:
526 ctdb_addr_info_push(cd
->data
.addr_info
, buf
, &np
);
529 case CTDB_CONTROL_DEL_PUBLIC_IP
:
530 ctdb_addr_info_push(cd
->data
.addr_info
, buf
, &np
);
533 case CTDB_CONTROL_RELEASE_IP
:
534 ctdb_public_ip_push(cd
->data
.pubip
, buf
, &np
);
537 case CTDB_CONTROL_TAKEOVER_IP
:
538 ctdb_public_ip_push(cd
->data
.pubip
, buf
, &np
);
541 case CTDB_CONTROL_TRAVERSE_KILL
:
542 ctdb_traverse_start_push(cd
->data
.traverse_start
, buf
, &np
);
545 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
546 ctdb_double_push(&cd
->data
.reclock_latency
, buf
, &np
);
549 case CTDB_CONTROL_SET_LMASTERROLE
:
550 ctdb_uint32_push(&cd
->data
.role
, buf
, &np
);
553 case CTDB_CONTROL_SET_RECMASTERROLE
:
554 ctdb_uint32_push(&cd
->data
.role
, buf
, &np
);
557 case CTDB_CONTROL_SET_BAN_STATE
:
558 ctdb_ban_state_push(cd
->data
.ban_state
, buf
, &np
);
561 case CTDB_CONTROL_REGISTER_NOTIFY
:
562 ctdb_notify_data_push(cd
->data
.notify
, buf
, &np
);
565 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
566 ctdb_uint64_push(&cd
->data
.srvid
, buf
, &np
);
569 case CTDB_CONTROL_TRANS3_COMMIT
:
570 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
573 case CTDB_CONTROL_GET_DB_SEQNUM
:
576 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
578 ctdb_uint32_push(&u32
, buf
+offset
, &np
);
583 case CTDB_CONTROL_DB_SET_HEALTHY
:
584 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
587 case CTDB_CONTROL_DB_GET_HEALTH
:
588 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
591 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
592 ctdb_sock_addr_push(cd
->data
.addr
, buf
, &np
);
595 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
596 ctdb_iface_push(cd
->data
.iface
, buf
, &np
);
599 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
600 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
603 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
604 ctdb_key_data_push(cd
->data
.key
, buf
, &np
);
607 case CTDB_CONTROL_SET_DB_READONLY
:
608 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
611 case CTDB_CONTROL_TRAVERSE_START_EXT
:
612 ctdb_traverse_start_ext_push(cd
->data
.traverse_start_ext
, buf
,
616 case CTDB_CONTROL_GET_DB_STATISTICS
:
617 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
620 case CTDB_CONTROL_SET_DB_STICKY
:
621 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
624 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
625 ctdb_traverse_all_ext_push(cd
->data
.traverse_all_ext
, buf
,
629 case CTDB_CONTROL_DB_DETACH
:
630 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
633 case CTDB_CONTROL_DB_FREEZE
:
634 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
637 case CTDB_CONTROL_DB_THAW
:
638 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
641 case CTDB_CONTROL_DB_TRANSACTION_START
:
642 ctdb_transdb_push(cd
->data
.transdb
, buf
, &np
);
645 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
646 ctdb_transdb_push(cd
->data
.transdb
, buf
, &np
);
649 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
650 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
653 case CTDB_CONTROL_DB_PULL
:
654 ctdb_pulldb_ext_push(cd
->data
.pulldb_ext
, buf
, &np
);
657 case CTDB_CONTROL_DB_PUSH_START
:
658 ctdb_pulldb_ext_push(cd
->data
.pulldb_ext
, buf
, &np
);
661 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
662 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
665 case CTDB_CONTROL_DB_OPEN_FLAGS
:
666 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
669 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
670 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
673 case CTDB_CONTROL_CHECK_PID_SRVID
:
674 ctdb_pid_srvid_push(cd
->data
.pid_srvid
, buf
, &np
);
677 case CTDB_CONTROL_VACUUM_FETCH
:
678 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
681 case CTDB_CONTROL_DB_VACUUM
:
682 ctdb_db_vacuum_push(cd
->data
.db_vacuum
, buf
, &np
);
685 case CTDB_CONTROL_ECHO_DATA
:
686 ctdb_echo_data_push(cd
->data
.echo_data
, buf
, &np
);
693 static int ctdb_req_control_data_pull(uint8_t *buf
, size_t buflen
,
696 struct ctdb_req_control_data
*cd
,
699 size_t np
= 0, offset
;
706 case CTDB_CONTROL_PROCESS_EXISTS
:
707 ret
= ctdb_pid_pull(buf
, buflen
, &cd
->data
.pid
, &np
);
710 case CTDB_CONTROL_GETDBPATH
:
711 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
714 case CTDB_CONTROL_SETVNNMAP
:
715 ret
= ctdb_vnn_map_pull(buf
, buflen
, mem_ctx
,
716 &cd
->data
.vnnmap
, &np
);
719 case CTDB_CONTROL_SET_DEBUG
:
720 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.loglevel
, &np
);
723 case CTDB_CONTROL_SET_RECMODE
:
724 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.recmode
, &np
);
727 case CTDB_CONTROL_DB_ATTACH
:
728 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
729 &cd
->data
.db_name
, &np
);
732 case CTDB_CONTROL_TRAVERSE_START
:
733 ret
= ctdb_traverse_start_pull(buf
, buflen
, mem_ctx
,
734 &cd
->data
.traverse_start
, &np
);
737 case CTDB_CONTROL_TRAVERSE_ALL
:
738 ret
= ctdb_traverse_all_pull(buf
, buflen
, mem_ctx
,
739 &cd
->data
.traverse_all
, &np
);
742 case CTDB_CONTROL_TRAVERSE_DATA
:
743 ret
= ctdb_rec_data_pull(buf
, buflen
, mem_ctx
,
744 &cd
->data
.rec_data
, &np
);
747 case CTDB_CONTROL_GET_DBNAME
:
748 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
751 case CTDB_CONTROL_ENABLE_SEQNUM
:
752 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
755 case CTDB_CONTROL_UPDATE_SEQNUM
:
756 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
759 case CTDB_CONTROL_TCP_CLIENT
:
760 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
761 &cd
->data
.conn
, &np
);
764 case CTDB_CONTROL_TCP_ADD
:
765 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
766 &cd
->data
.conn
, &np
);
769 case CTDB_CONTROL_TCP_REMOVE
:
770 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
771 &cd
->data
.conn
, &np
);
774 case CTDB_CONTROL_SET_TUNABLE
:
775 ret
= ctdb_tunable_pull(buf
, buflen
, mem_ctx
,
776 &cd
->data
.tunable
, &np
);
779 case CTDB_CONTROL_GET_TUNABLE
:
780 ret
= ctdb_stringn_pull(buf
, buflen
, mem_ctx
,
781 &cd
->data
.tun_var
, &np
);
784 case CTDB_CONTROL_MODIFY_FLAGS
:
785 ret
= ctdb_node_flag_change_pull(buf
, buflen
, mem_ctx
,
786 &cd
->data
.flag_change
, &np
);
789 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
790 ret
= ctdb_sock_addr_pull(buf
, buflen
, mem_ctx
,
791 &cd
->data
.addr
, &np
);
794 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
795 ret
= ctdb_tickle_list_pull(buf
, buflen
, mem_ctx
,
796 &cd
->data
.tickles
, &np
);
799 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
800 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
801 &cd
->data
.db_name
, &np
);
804 case CTDB_CONTROL_UPDATE_RECORD
:
805 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
806 &cd
->data
.recbuf
, &np
);
809 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
810 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
811 &cd
->data
.addr_info
, &np
);
814 case CTDB_CONTROL_WIPE_DATABASE
:
815 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
816 &cd
->data
.transdb
, &np
);
819 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
820 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
821 &cd
->data
.recbuf
, &np
);
824 case CTDB_CONTROL_ADD_PUBLIC_IP
:
825 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
826 &cd
->data
.addr_info
, &np
);
829 case CTDB_CONTROL_DEL_PUBLIC_IP
:
830 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
831 &cd
->data
.addr_info
, &np
);
834 case CTDB_CONTROL_RELEASE_IP
:
835 ret
= ctdb_public_ip_pull(buf
, buflen
, mem_ctx
,
836 &cd
->data
.pubip
, &np
);
839 case CTDB_CONTROL_TAKEOVER_IP
:
840 ret
= ctdb_public_ip_pull(buf
, buflen
, mem_ctx
,
841 &cd
->data
.pubip
, &np
);
844 case CTDB_CONTROL_TRAVERSE_KILL
:
845 ret
= ctdb_traverse_start_pull(buf
, buflen
, mem_ctx
,
846 &cd
->data
.traverse_start
, &np
);
849 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
850 ret
= ctdb_double_pull(buf
, buflen
, &cd
->data
.reclock_latency
,
854 case CTDB_CONTROL_SET_LMASTERROLE
:
855 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.role
, &np
);
858 case CTDB_CONTROL_SET_RECMASTERROLE
:
859 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.role
, &np
);
862 case CTDB_CONTROL_SET_BAN_STATE
:
863 ret
= ctdb_ban_state_pull(buf
, buflen
, mem_ctx
,
864 &cd
->data
.ban_state
, &np
);
867 case CTDB_CONTROL_REGISTER_NOTIFY
:
868 ret
= ctdb_notify_data_pull(buf
, buflen
, mem_ctx
,
869 &cd
->data
.notify
, &np
);
872 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
873 ret
= ctdb_uint64_pull(buf
, buflen
, &cd
->data
.srvid
, &np
);
876 case CTDB_CONTROL_TRANS3_COMMIT
:
877 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
878 &cd
->data
.recbuf
, &np
);
881 case CTDB_CONTROL_GET_DB_SEQNUM
:
883 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
888 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &u32
, &np
);
893 case CTDB_CONTROL_DB_SET_HEALTHY
:
894 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
897 case CTDB_CONTROL_DB_GET_HEALTH
:
898 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
901 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
902 ret
= ctdb_sock_addr_pull(buf
, buflen
, mem_ctx
,
903 &cd
->data
.addr
, &np
);
906 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
907 ret
= ctdb_iface_pull(buf
, buflen
, mem_ctx
,
908 &cd
->data
.iface
, &np
);
911 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
912 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
913 &cd
->data
.conn
, &np
);
916 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
917 ret
= ctdb_key_data_pull(buf
, buflen
, mem_ctx
,
921 case CTDB_CONTROL_SET_DB_READONLY
:
922 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
925 case CTDB_CONTROL_TRAVERSE_START_EXT
:
926 ret
= ctdb_traverse_start_ext_pull(buf
, buflen
, mem_ctx
,
927 &cd
->data
.traverse_start_ext
,
931 case CTDB_CONTROL_GET_DB_STATISTICS
:
932 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
935 case CTDB_CONTROL_SET_DB_STICKY
:
936 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
939 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
940 ret
= ctdb_traverse_all_ext_pull(buf
, buflen
, mem_ctx
,
941 &cd
->data
.traverse_all_ext
,
945 case CTDB_CONTROL_DB_DETACH
:
946 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
949 case CTDB_CONTROL_DB_FREEZE
:
950 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
953 case CTDB_CONTROL_DB_THAW
:
954 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
957 case CTDB_CONTROL_DB_TRANSACTION_START
:
958 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
959 &cd
->data
.transdb
, &np
);
962 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
963 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
964 &cd
->data
.transdb
, &np
);
967 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
968 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
971 case CTDB_CONTROL_DB_PULL
:
972 ret
= ctdb_pulldb_ext_pull(buf
, buflen
, mem_ctx
,
973 &cd
->data
.pulldb_ext
, &np
);
976 case CTDB_CONTROL_DB_PUSH_START
:
977 ret
= ctdb_pulldb_ext_pull(buf
, buflen
, mem_ctx
,
978 &cd
->data
.pulldb_ext
, &np
);
981 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
982 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
985 case CTDB_CONTROL_DB_OPEN_FLAGS
:
986 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
989 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
990 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
991 &cd
->data
.db_name
, &np
);
994 case CTDB_CONTROL_CHECK_PID_SRVID
:
995 ret
= ctdb_pid_srvid_pull(buf
, buflen
, mem_ctx
,
996 &cd
->data
.pid_srvid
, &np
);
999 case CTDB_CONTROL_VACUUM_FETCH
:
1000 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
1001 &cd
->data
.recbuf
, &np
);
1004 case CTDB_CONTROL_DB_VACUUM
:
1005 ret
= ctdb_db_vacuum_pull(buf
,
1008 &cd
->data
.db_vacuum
,
1012 case CTDB_CONTROL_ECHO_DATA
:
1013 ret
= ctdb_echo_data_pull(buf
,
1016 &cd
->data
.echo_data
,
1029 static size_t ctdb_reply_control_data_len(struct ctdb_reply_control_data
*cd
)
1037 switch (cd
->opcode
) {
1038 case CTDB_CONTROL_PROCESS_EXISTS
:
1041 case CTDB_CONTROL_STATISTICS
:
1042 len
= ctdb_statistics_len(cd
->data
.stats
);
1045 case CTDB_CONTROL_PING
:
1048 case CTDB_CONTROL_GETDBPATH
:
1049 len
= ctdb_string_len(&cd
->data
.db_path
);
1052 case CTDB_CONTROL_GETVNNMAP
:
1053 len
= ctdb_vnn_map_len(cd
->data
.vnnmap
);
1056 case CTDB_CONTROL_SETVNNMAP
:
1059 case CTDB_CONTROL_GET_DEBUG
:
1060 len
= ctdb_uint32_len(&cd
->data
.loglevel
);
1063 case CTDB_CONTROL_SET_DEBUG
:
1066 case CTDB_CONTROL_GET_DBMAP
:
1067 len
= ctdb_dbid_map_len(cd
->data
.dbmap
);
1070 case CTDB_CONTROL_GET_RECMODE
:
1073 case CTDB_CONTROL_SET_RECMODE
:
1076 case CTDB_CONTROL_STATISTICS_RESET
:
1079 case CTDB_CONTROL_DB_ATTACH
:
1080 len
= ctdb_uint32_len(&cd
->data
.db_id
);
1083 case CTDB_CONTROL_TRAVERSE_START
:
1086 case CTDB_CONTROL_TRAVERSE_ALL
:
1089 case CTDB_CONTROL_TRAVERSE_DATA
:
1092 case CTDB_CONTROL_REGISTER_SRVID
:
1095 case CTDB_CONTROL_DEREGISTER_SRVID
:
1098 case CTDB_CONTROL_GET_DBNAME
:
1099 len
= ctdb_string_len(&cd
->data
.db_name
);
1102 case CTDB_CONTROL_ENABLE_SEQNUM
:
1105 case CTDB_CONTROL_UPDATE_SEQNUM
:
1108 case CTDB_CONTROL_DUMP_MEMORY
:
1109 len
= ctdb_string_len(&cd
->data
.mem_str
);
1112 case CTDB_CONTROL_GET_PID
:
1115 case CTDB_CONTROL_FREEZE
:
1118 case CTDB_CONTROL_GET_PNN
:
1121 case CTDB_CONTROL_SHUTDOWN
:
1124 case CTDB_CONTROL_TCP_CLIENT
:
1127 case CTDB_CONTROL_TCP_ADD
:
1130 case CTDB_CONTROL_TCP_REMOVE
:
1133 case CTDB_CONTROL_STARTUP
:
1136 case CTDB_CONTROL_SET_TUNABLE
:
1139 case CTDB_CONTROL_GET_TUNABLE
:
1140 len
= ctdb_uint32_len(&cd
->data
.tun_value
);
1143 case CTDB_CONTROL_LIST_TUNABLES
:
1144 len
= ctdb_var_list_len(cd
->data
.tun_var_list
);
1147 case CTDB_CONTROL_MODIFY_FLAGS
:
1150 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1151 len
= ctdb_tunable_list_len(cd
->data
.tun_list
);
1154 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1155 len
= ctdb_tickle_list_len(cd
->data
.tickles
);
1158 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
1161 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1162 len
= ctdb_uint32_len(&cd
->data
.db_id
);
1165 case CTDB_CONTROL_UPDATE_RECORD
:
1168 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
1171 case CTDB_CONTROL_WIPE_DATABASE
:
1174 case CTDB_CONTROL_UPTIME
:
1175 len
= ctdb_uptime_len(cd
->data
.uptime
);
1178 case CTDB_CONTROL_START_RECOVERY
:
1181 case CTDB_CONTROL_END_RECOVERY
:
1184 case CTDB_CONTROL_RELOAD_NODES_FILE
:
1187 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1188 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
1191 case CTDB_CONTROL_ADD_PUBLIC_IP
:
1194 case CTDB_CONTROL_DEL_PUBLIC_IP
:
1197 case CTDB_CONTROL_GET_CAPABILITIES
:
1198 len
= ctdb_uint32_len(&cd
->data
.caps
);
1201 case CTDB_CONTROL_RECD_PING
:
1204 case CTDB_CONTROL_RELEASE_IP
:
1207 case CTDB_CONTROL_TAKEOVER_IP
:
1210 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1211 len
= ctdb_public_ip_list_len(cd
->data
.pubip_list
);
1214 case CTDB_CONTROL_GET_NODEMAP
:
1215 len
= ctdb_node_map_len(cd
->data
.nodemap
);
1218 case CTDB_CONTROL_TRAVERSE_KILL
:
1221 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
1224 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1225 len
= ctdb_string_len(&cd
->data
.reclock_file
);
1228 case CTDB_CONTROL_STOP_NODE
:
1231 case CTDB_CONTROL_CONTINUE_NODE
:
1234 case CTDB_CONTROL_SET_LMASTERROLE
:
1237 case CTDB_CONTROL_SET_RECMASTERROLE
:
1240 case CTDB_CONTROL_SET_BAN_STATE
:
1243 case CTDB_CONTROL_GET_BAN_STATE
:
1244 len
= ctdb_ban_state_len(cd
->data
.ban_state
);
1247 case CTDB_CONTROL_REGISTER_NOTIFY
:
1250 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
1253 case CTDB_CONTROL_TRANS3_COMMIT
:
1256 case CTDB_CONTROL_GET_DB_SEQNUM
:
1257 len
= ctdb_uint64_len(&cd
->data
.seqnum
);
1260 case CTDB_CONTROL_DB_SET_HEALTHY
:
1263 case CTDB_CONTROL_DB_GET_HEALTH
:
1264 len
= ctdb_string_len(&cd
->data
.reason
);
1267 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1268 len
= ctdb_public_ip_info_len(cd
->data
.ipinfo
);
1271 case CTDB_CONTROL_GET_IFACES
:
1272 len
= ctdb_iface_list_len(cd
->data
.iface_list
);
1275 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
1278 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
1281 case CTDB_CONTROL_GET_STAT_HISTORY
:
1282 len
= ctdb_statistics_list_len(cd
->data
.stats_list
);
1285 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
1288 case CTDB_CONTROL_SET_DB_READONLY
:
1291 case CTDB_CONTROL_TRAVERSE_START_EXT
:
1294 case CTDB_CONTROL_GET_DB_STATISTICS
:
1295 len
= ctdb_db_statistics_len(cd
->data
.dbstats
);
1298 case CTDB_CONTROL_SET_DB_STICKY
:
1301 case CTDB_CONTROL_RELOAD_PUBLIC_IPS
:
1304 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
1307 case CTDB_CONTROL_IPREALLOCATED
:
1310 case CTDB_CONTROL_GET_RUNSTATE
:
1311 len
= ctdb_uint32_len(&cd
->data
.runstate
);
1314 case CTDB_CONTROL_DB_DETACH
:
1317 case CTDB_CONTROL_GET_NODES_FILE
:
1318 len
= ctdb_node_map_len(cd
->data
.nodemap
);
1321 case CTDB_CONTROL_DB_FREEZE
:
1324 case CTDB_CONTROL_DB_THAW
:
1327 case CTDB_CONTROL_DB_TRANSACTION_START
:
1330 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
1333 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
1336 case CTDB_CONTROL_DB_PULL
:
1337 len
= ctdb_uint32_len(&cd
->data
.num_records
);
1340 case CTDB_CONTROL_DB_PUSH_START
:
1343 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1344 len
= ctdb_uint32_len(&cd
->data
.num_records
);
1347 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1348 len
= ctdb_int32_len(&cd
->data
.tdb_flags
);
1351 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1352 len
= ctdb_uint32_len(&cd
->data
.db_id
);
1355 case CTDB_CONTROL_CHECK_PID_SRVID
:
1358 case CTDB_CONTROL_TUNNEL_REGISTER
:
1361 case CTDB_CONTROL_TUNNEL_DEREGISTER
:
1364 case CTDB_CONTROL_VACUUM_FETCH
:
1367 case CTDB_CONTROL_DB_VACUUM
:
1370 case CTDB_CONTROL_ECHO_DATA
:
1371 len
= ctdb_echo_data_len(cd
->data
.echo_data
);
1374 case CTDB_CONTROL_DISABLE_NODE
:
1377 case CTDB_CONTROL_ENABLE_NODE
:
1384 static void ctdb_reply_control_data_push(struct ctdb_reply_control_data
*cd
,
1385 uint8_t *buf
, size_t *npush
)
1389 switch (cd
->opcode
) {
1390 case CTDB_CONTROL_STATISTICS
:
1391 ctdb_statistics_push(cd
->data
.stats
, buf
, &np
);
1394 case CTDB_CONTROL_GETDBPATH
:
1395 ctdb_string_push(&cd
->data
.db_path
, buf
, &np
);
1398 case CTDB_CONTROL_GETVNNMAP
:
1399 ctdb_vnn_map_push(cd
->data
.vnnmap
, buf
, &np
);
1402 case CTDB_CONTROL_GET_DEBUG
:
1403 ctdb_uint32_push(&cd
->data
.loglevel
, buf
, &np
);
1406 case CTDB_CONTROL_GET_DBMAP
:
1407 ctdb_dbid_map_push(cd
->data
.dbmap
, buf
, &np
);
1410 case CTDB_CONTROL_DB_ATTACH
:
1411 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
1414 case CTDB_CONTROL_GET_DBNAME
:
1415 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
1418 case CTDB_CONTROL_DUMP_MEMORY
:
1419 ctdb_string_push(&cd
->data
.mem_str
, buf
, &np
);
1422 case CTDB_CONTROL_GET_PID
:
1425 case CTDB_CONTROL_GET_TUNABLE
:
1426 ctdb_uint32_push(&cd
->data
.tun_value
, buf
, &np
);
1429 case CTDB_CONTROL_LIST_TUNABLES
:
1430 ctdb_var_list_push(cd
->data
.tun_var_list
, buf
, &np
);
1433 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1434 ctdb_tunable_list_push(cd
->data
.tun_list
, buf
, &np
);
1437 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1438 ctdb_tickle_list_push(cd
->data
.tickles
, buf
, &np
);
1441 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1442 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
1445 case CTDB_CONTROL_UPTIME
:
1446 ctdb_uptime_push(cd
->data
.uptime
, buf
, &np
);
1449 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1450 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
1453 case CTDB_CONTROL_GET_CAPABILITIES
:
1454 ctdb_uint32_push(&cd
->data
.caps
, buf
, &np
);
1457 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1458 ctdb_public_ip_list_push(cd
->data
.pubip_list
, buf
, &np
);
1461 case CTDB_CONTROL_GET_NODEMAP
:
1462 ctdb_node_map_push(cd
->data
.nodemap
, buf
, &np
);
1465 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1466 ctdb_string_push(&cd
->data
.reclock_file
, buf
, &np
);
1469 case CTDB_CONTROL_GET_BAN_STATE
:
1470 ctdb_ban_state_push(cd
->data
.ban_state
, buf
, &np
);
1473 case CTDB_CONTROL_GET_DB_SEQNUM
:
1474 ctdb_uint64_push(&cd
->data
.seqnum
, buf
, &np
);
1477 case CTDB_CONTROL_DB_GET_HEALTH
:
1478 ctdb_string_push(&cd
->data
.reason
, buf
, &np
);
1481 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1482 ctdb_public_ip_info_push(cd
->data
.ipinfo
, buf
, &np
);
1485 case CTDB_CONTROL_GET_IFACES
:
1486 ctdb_iface_list_push(cd
->data
.iface_list
, buf
, &np
);
1489 case CTDB_CONTROL_GET_STAT_HISTORY
:
1490 ctdb_statistics_list_push(cd
->data
.stats_list
, buf
, &np
);
1493 case CTDB_CONTROL_GET_DB_STATISTICS
:
1494 ctdb_db_statistics_push(cd
->data
.dbstats
, buf
, &np
);
1497 case CTDB_CONTROL_GET_RUNSTATE
:
1498 ctdb_uint32_push(&cd
->data
.runstate
, buf
, &np
);
1501 case CTDB_CONTROL_GET_NODES_FILE
:
1502 ctdb_node_map_push(cd
->data
.nodemap
, buf
, &np
);
1505 case CTDB_CONTROL_DB_PULL
:
1506 ctdb_uint32_push(&cd
->data
.num_records
, buf
, &np
);
1509 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1510 ctdb_uint32_push(&cd
->data
.num_records
, buf
, &np
);
1513 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1514 ctdb_int32_push(&cd
->data
.tdb_flags
, buf
, &np
);
1517 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1518 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
1521 case CTDB_CONTROL_CHECK_PID_SRVID
:
1524 case CTDB_CONTROL_VACUUM_FETCH
:
1527 case CTDB_CONTROL_DB_VACUUM
:
1530 case CTDB_CONTROL_ECHO_DATA
:
1531 ctdb_echo_data_push(cd
->data
.echo_data
, buf
, &np
);
1538 static int ctdb_reply_control_data_pull(uint8_t *buf
, size_t buflen
,
1539 uint32_t opcode
, TALLOC_CTX
*mem_ctx
,
1540 struct ctdb_reply_control_data
*cd
,
1546 cd
->opcode
= opcode
;
1549 case CTDB_CONTROL_STATISTICS
:
1550 ret
= ctdb_statistics_pull(buf
, buflen
, mem_ctx
,
1551 &cd
->data
.stats
, &np
);
1554 case CTDB_CONTROL_GETDBPATH
:
1555 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1556 &cd
->data
.db_path
, &np
);
1559 case CTDB_CONTROL_GETVNNMAP
:
1560 ret
= ctdb_vnn_map_pull(buf
, buflen
, mem_ctx
,
1561 &cd
->data
.vnnmap
, &np
);
1564 case CTDB_CONTROL_GET_DEBUG
:
1565 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.loglevel
, &np
);
1568 case CTDB_CONTROL_GET_DBMAP
:
1569 ret
= ctdb_dbid_map_pull(buf
, buflen
, mem_ctx
,
1570 &cd
->data
.dbmap
, &np
);
1573 case CTDB_CONTROL_DB_ATTACH
:
1574 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1577 case CTDB_CONTROL_GET_DBNAME
:
1578 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1579 &cd
->data
.db_name
, &np
);
1582 case CTDB_CONTROL_DUMP_MEMORY
:
1583 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1584 &cd
->data
.mem_str
, &np
);
1587 case CTDB_CONTROL_GET_PID
:
1590 case CTDB_CONTROL_GET_TUNABLE
:
1591 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.tun_value
,
1595 case CTDB_CONTROL_LIST_TUNABLES
:
1596 ret
= ctdb_var_list_pull(buf
, buflen
, mem_ctx
,
1597 &cd
->data
.tun_var_list
, &np
);
1600 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1601 ret
= ctdb_tunable_list_pull(buf
, buflen
, mem_ctx
,
1602 &cd
->data
.tun_list
, &np
);
1605 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1606 ret
= ctdb_tickle_list_pull(buf
, buflen
, mem_ctx
,
1607 &cd
->data
.tickles
, &np
);
1610 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1611 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1614 case CTDB_CONTROL_UPTIME
:
1615 ret
= ctdb_uptime_pull(buf
, buflen
, mem_ctx
,
1616 &cd
->data
.uptime
, &np
);
1619 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1620 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
1621 &cd
->data
.recbuf
, &np
);
1624 case CTDB_CONTROL_GET_CAPABILITIES
:
1625 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.caps
, &np
);
1628 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1629 ret
= ctdb_public_ip_list_pull(buf
, buflen
, mem_ctx
,
1630 &cd
->data
.pubip_list
, &np
);
1633 case CTDB_CONTROL_GET_NODEMAP
:
1634 ret
= ctdb_node_map_pull(buf
, buflen
, mem_ctx
,
1635 &cd
->data
.nodemap
, &np
);
1638 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1639 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1640 &cd
->data
.reclock_file
, &np
);
1643 case CTDB_CONTROL_GET_BAN_STATE
:
1644 ret
= ctdb_ban_state_pull(buf
, buflen
, mem_ctx
,
1645 &cd
->data
.ban_state
, &np
);
1648 case CTDB_CONTROL_GET_DB_SEQNUM
:
1649 ret
= ctdb_uint64_pull(buf
, buflen
, &cd
->data
.seqnum
, &np
);
1652 case CTDB_CONTROL_DB_GET_HEALTH
:
1653 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1654 &cd
->data
.reason
, &np
);
1657 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1658 ret
= ctdb_public_ip_info_pull(buf
, buflen
, mem_ctx
,
1659 &cd
->data
.ipinfo
, &np
);
1662 case CTDB_CONTROL_GET_IFACES
:
1663 ret
= ctdb_iface_list_pull(buf
, buflen
, mem_ctx
,
1664 &cd
->data
.iface_list
, &np
);
1667 case CTDB_CONTROL_GET_STAT_HISTORY
:
1668 ret
= ctdb_statistics_list_pull(buf
, buflen
, mem_ctx
,
1669 &cd
->data
.stats_list
, &np
);
1672 case CTDB_CONTROL_GET_DB_STATISTICS
:
1673 ret
= ctdb_db_statistics_pull(buf
, buflen
, mem_ctx
,
1674 &cd
->data
.dbstats
, &np
);
1677 case CTDB_CONTROL_GET_RUNSTATE
:
1678 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.runstate
, &np
);
1681 case CTDB_CONTROL_GET_NODES_FILE
:
1682 ret
= ctdb_node_map_pull(buf
, buflen
, mem_ctx
,
1683 &cd
->data
.nodemap
, &np
);
1686 case CTDB_CONTROL_DB_PULL
:
1687 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.num_records
,
1691 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1692 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.num_records
,
1696 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1697 ret
= ctdb_int32_pull(buf
, buflen
, &cd
->data
.tdb_flags
, &np
);
1700 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1701 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1704 case CTDB_CONTROL_CHECK_PID_SRVID
:
1707 case CTDB_CONTROL_VACUUM_FETCH
:
1710 case CTDB_CONTROL_DB_VACUUM
:
1713 case CTDB_CONTROL_ECHO_DATA
:
1714 ret
= ctdb_echo_data_pull(buf
,
1717 &cd
->data
.echo_data
,
1730 size_t ctdb_req_control_len(struct ctdb_req_header
*h
,
1731 struct ctdb_req_control
*c
)
1735 return ctdb_req_header_len(h
) +
1736 ctdb_uint32_len(&c
->opcode
) +
1737 ctdb_uint32_len(&c
->pad
) +
1738 ctdb_uint64_len(&c
->srvid
) +
1739 ctdb_uint32_len(&c
->client_id
) +
1740 ctdb_uint32_len(&c
->flags
) +
1741 ctdb_uint32_len(&u32
) +
1742 ctdb_req_control_data_len(&c
->rdata
);
1745 int ctdb_req_control_push(struct ctdb_req_header
*h
,
1746 struct ctdb_req_control
*c
,
1747 uint8_t *buf
, size_t *buflen
)
1749 size_t offset
= 0, np
;
1753 length
= ctdb_req_control_len(h
, c
);
1754 if (*buflen
< length
) {
1759 h
->length
= *buflen
;
1760 ctdb_req_header_push(h
, buf
+offset
, &np
);
1763 ctdb_uint32_push(&c
->opcode
, buf
+offset
, &np
);
1766 ctdb_uint32_push(&c
->pad
, buf
+offset
, &np
);
1769 ctdb_uint64_push(&c
->srvid
, buf
+offset
, &np
);
1772 ctdb_uint32_push(&c
->client_id
, buf
+offset
, &np
);
1775 ctdb_uint32_push(&c
->flags
, buf
+offset
, &np
);
1778 u32
= ctdb_req_control_data_len(&c
->rdata
);
1779 ctdb_uint32_push(&u32
, buf
+offset
, &np
);
1782 ctdb_req_control_data_push(&c
->rdata
, buf
+offset
, &np
);
1785 if (offset
> *buflen
) {
1792 int ctdb_req_control_pull(uint8_t *buf
, size_t buflen
,
1793 struct ctdb_req_header
*h
,
1794 TALLOC_CTX
*mem_ctx
,
1795 struct ctdb_req_control
*c
)
1797 struct ctdb_req_header header
;
1798 size_t offset
= 0, np
;
1802 ret
= ctdb_req_header_pull(buf
+offset
, buflen
-offset
, &header
, &np
);
1812 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->opcode
, &np
);
1818 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->pad
, &np
);
1824 ret
= ctdb_uint64_pull(buf
+offset
, buflen
-offset
, &c
->srvid
, &np
);
1830 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->client_id
, &np
);
1836 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->flags
, &np
);
1842 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &u32
, &np
);
1848 if (u32
> buflen
-offset
) {
1852 ret
= ctdb_req_control_data_pull(buf
+offset
, u32
, c
->opcode
, mem_ctx
,
1859 if (offset
> buflen
) {
1866 size_t ctdb_reply_control_len(struct ctdb_req_header
*h
,
1867 struct ctdb_reply_control
*c
)
1869 uint32_t dsize
, esize
;
1871 if (c
->status
== 0) {
1872 dsize
= ctdb_reply_control_data_len(&c
->rdata
);
1876 esize
= ctdb_string_len(&c
->errmsg
);
1879 return ctdb_req_header_len(h
) +
1880 ctdb_int32_len(&c
->status
) +
1881 ctdb_uint32_len(&dsize
) +
1882 ctdb_uint32_len(&esize
) +
1886 int ctdb_reply_control_push(struct ctdb_req_header
*h
,
1887 struct ctdb_reply_control
*c
,
1888 uint8_t *buf
, size_t *buflen
)
1890 size_t offset
= 0, np
;
1892 uint32_t dsize
, esize
;
1894 length
= ctdb_reply_control_len(h
, c
);
1895 if (*buflen
< length
) {
1900 h
->length
= *buflen
;
1901 ctdb_req_header_push(h
, buf
+offset
, &np
);
1904 ctdb_int32_push(&c
->status
, buf
+offset
, &np
);
1907 if (c
->status
== 0) {
1908 dsize
= ctdb_reply_control_data_len(&c
->rdata
);
1912 esize
= ctdb_string_len(&c
->errmsg
);
1915 ctdb_uint32_push(&dsize
, buf
+offset
, &np
);
1918 ctdb_uint32_push(&esize
, buf
+offset
, &np
);
1921 if (c
->status
== 0) {
1922 ctdb_reply_control_data_push(&c
->rdata
, buf
+offset
, &np
);
1924 ctdb_string_push(&c
->errmsg
, buf
+offset
, &np
);
1931 int ctdb_reply_control_pull(uint8_t *buf
, size_t buflen
, uint32_t opcode
,
1932 struct ctdb_req_header
*h
,
1933 TALLOC_CTX
*mem_ctx
,
1934 struct ctdb_reply_control
*c
)
1936 struct ctdb_req_header header
;
1937 size_t offset
= 0, np
;
1938 uint32_t dsize
, esize
;
1941 ret
= ctdb_req_header_pull(buf
+offset
, buflen
-offset
, &header
, &np
);
1951 ret
= ctdb_int32_pull(buf
+offset
, buflen
-offset
, &c
->status
, &np
);
1957 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &dsize
, &np
);
1963 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &esize
, &np
);
1971 if (c
->status
== 0) {
1972 if (buflen
-offset
< dsize
) {
1976 ret
= ctdb_reply_control_data_pull(buf
+offset
, dsize
,
1977 opcode
, mem_ctx
, &c
->rdata
,
1985 if (buflen
-offset
< esize
) {
1989 ret
= ctdb_string_pull(buf
+offset
, esize
, mem_ctx
, &c
->errmsg
,