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_PULL_DB
:
72 len
= ctdb_pulldb_len(cd
->data
.pulldb
);
75 case CTDB_CONTROL_PUSH_DB
:
76 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
79 case CTDB_CONTROL_GET_RECMODE
:
82 case CTDB_CONTROL_SET_RECMODE
:
83 len
= ctdb_uint32_len(&cd
->data
.recmode
);
86 case CTDB_CONTROL_STATISTICS_RESET
:
89 case CTDB_CONTROL_DB_ATTACH
:
90 len
= ctdb_string_len(&cd
->data
.db_name
);
93 case CTDB_CONTROL_SET_CALL
:
96 case CTDB_CONTROL_TRAVERSE_START
:
97 len
= ctdb_traverse_start_len(cd
->data
.traverse_start
);
100 case CTDB_CONTROL_TRAVERSE_ALL
:
101 len
= ctdb_traverse_all_len(cd
->data
.traverse_all
);
104 case CTDB_CONTROL_TRAVERSE_DATA
:
105 len
= ctdb_rec_data_len(cd
->data
.rec_data
);
108 case CTDB_CONTROL_REGISTER_SRVID
:
111 case CTDB_CONTROL_DEREGISTER_SRVID
:
114 case CTDB_CONTROL_GET_DBNAME
:
115 len
= ctdb_uint32_len(&cd
->data
.db_id
);
118 case CTDB_CONTROL_ENABLE_SEQNUM
:
119 len
= ctdb_uint32_len(&cd
->data
.db_id
);
122 case CTDB_CONTROL_UPDATE_SEQNUM
:
123 len
= ctdb_uint32_len(&cd
->data
.db_id
);
126 case CTDB_CONTROL_DUMP_MEMORY
:
129 case CTDB_CONTROL_GET_PID
:
132 case CTDB_CONTROL_GET_RECMASTER
:
135 case CTDB_CONTROL_SET_RECMASTER
:
136 len
= ctdb_uint32_len(&cd
->data
.recmaster
);
139 case CTDB_CONTROL_FREEZE
:
142 case CTDB_CONTROL_GET_PNN
:
145 case CTDB_CONTROL_SHUTDOWN
:
148 case CTDB_CONTROL_GET_MONMODE
:
151 case CTDB_CONTROL_TCP_CLIENT
:
152 len
= ctdb_connection_len(cd
->data
.conn
);
155 case CTDB_CONTROL_TCP_ADD
:
156 len
= ctdb_connection_len(cd
->data
.conn
);
159 case CTDB_CONTROL_TCP_REMOVE
:
160 len
= ctdb_connection_len(cd
->data
.conn
);
163 case CTDB_CONTROL_STARTUP
:
166 case CTDB_CONTROL_SET_TUNABLE
:
167 len
= ctdb_tunable_len(cd
->data
.tunable
);
170 case CTDB_CONTROL_GET_TUNABLE
:
171 len
= ctdb_stringn_len(&cd
->data
.tun_var
);
174 case CTDB_CONTROL_LIST_TUNABLES
:
177 case CTDB_CONTROL_MODIFY_FLAGS
:
178 len
= ctdb_node_flag_change_len(cd
->data
.flag_change
);
181 case CTDB_CONTROL_GET_ALL_TUNABLES
:
184 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
185 len
= ctdb_sock_addr_len(cd
->data
.addr
);
188 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
189 len
= ctdb_tickle_list_len(cd
->data
.tickles
);
192 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
193 len
= ctdb_string_len(&cd
->data
.db_name
);
196 case CTDB_CONTROL_UPDATE_RECORD
:
197 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
200 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
201 len
= ctdb_addr_info_len(cd
->data
.addr_info
);
204 case CTDB_CONTROL_WIPE_DATABASE
:
205 len
= ctdb_transdb_len(cd
->data
.transdb
);
208 case CTDB_CONTROL_UPTIME
:
211 case CTDB_CONTROL_START_RECOVERY
:
214 case CTDB_CONTROL_END_RECOVERY
:
217 case CTDB_CONTROL_RELOAD_NODES_FILE
:
220 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
221 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
224 case CTDB_CONTROL_ENABLE_MONITOR
:
227 case CTDB_CONTROL_DISABLE_MONITOR
:
230 case CTDB_CONTROL_ADD_PUBLIC_IP
:
231 len
= ctdb_addr_info_len(cd
->data
.addr_info
);
234 case CTDB_CONTROL_DEL_PUBLIC_IP
:
235 len
= ctdb_addr_info_len(cd
->data
.addr_info
);
238 case CTDB_CONTROL_GET_CAPABILITIES
:
241 case CTDB_CONTROL_RECD_PING
:
244 case CTDB_CONTROL_RELEASE_IP
:
245 len
= ctdb_public_ip_len(cd
->data
.pubip
);
248 case CTDB_CONTROL_TAKEOVER_IP
:
249 len
= ctdb_public_ip_len(cd
->data
.pubip
);
252 case CTDB_CONTROL_GET_PUBLIC_IPS
:
255 case CTDB_CONTROL_GET_NODEMAP
:
258 case CTDB_CONTROL_TRAVERSE_KILL
:
259 len
= ctdb_traverse_start_len(cd
->data
.traverse_start
);
262 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
263 len
= ctdb_double_len(&cd
->data
.reclock_latency
);
266 case CTDB_CONTROL_GET_RECLOCK_FILE
:
269 case CTDB_CONTROL_STOP_NODE
:
272 case CTDB_CONTROL_CONTINUE_NODE
:
275 case CTDB_CONTROL_SET_LMASTERROLE
:
276 len
= ctdb_uint32_len(&cd
->data
.role
);
279 case CTDB_CONTROL_SET_RECMASTERROLE
:
280 len
= ctdb_uint32_len(&cd
->data
.role
);
283 case CTDB_CONTROL_SET_BAN_STATE
:
284 len
= ctdb_ban_state_len(cd
->data
.ban_state
);
287 case CTDB_CONTROL_GET_BAN_STATE
:
290 case CTDB_CONTROL_REGISTER_NOTIFY
:
291 len
= ctdb_notify_data_len(cd
->data
.notify
);
294 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
295 len
= ctdb_uint64_len(&cd
->data
.srvid
);
298 case CTDB_CONTROL_TRANS3_COMMIT
:
299 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
302 case CTDB_CONTROL_GET_DB_SEQNUM
:
304 len
= ctdb_uint32_len(&cd
->data
.db_id
) + ctdb_uint32_len(&u32
);
307 case CTDB_CONTROL_DB_SET_HEALTHY
:
308 len
= ctdb_uint32_len(&cd
->data
.db_id
);
311 case CTDB_CONTROL_DB_GET_HEALTH
:
312 len
= ctdb_uint32_len(&cd
->data
.db_id
);
315 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
316 len
= ctdb_sock_addr_len(cd
->data
.addr
);
319 case CTDB_CONTROL_GET_IFACES
:
322 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
323 len
= ctdb_iface_len(cd
->data
.iface
);
326 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
327 len
= ctdb_connection_len(cd
->data
.conn
);
330 case CTDB_CONTROL_GET_STAT_HISTORY
:
333 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
334 len
= ctdb_key_data_len(cd
->data
.key
);
337 case CTDB_CONTROL_SET_DB_READONLY
:
338 len
= ctdb_uint32_len(&cd
->data
.db_id
);
341 case CTDB_CONTROL_CHECK_SRVIDS
:
344 case CTDB_CONTROL_TRAVERSE_START_EXT
:
345 len
= ctdb_traverse_start_ext_len(cd
->data
.traverse_start_ext
);
348 case CTDB_CONTROL_GET_DB_STATISTICS
:
349 len
= ctdb_uint32_len(&cd
->data
.db_id
);
352 case CTDB_CONTROL_SET_DB_STICKY
:
353 len
= ctdb_uint32_len(&cd
->data
.db_id
);
356 case CTDB_CONTROL_RELOAD_PUBLIC_IPS
:
359 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
360 len
= ctdb_traverse_all_ext_len(cd
->data
.traverse_all_ext
);
363 case CTDB_CONTROL_RECEIVE_RECORDS
:
364 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
367 case CTDB_CONTROL_IPREALLOCATED
:
370 case CTDB_CONTROL_GET_RUNSTATE
:
373 case CTDB_CONTROL_DB_DETACH
:
374 len
= ctdb_uint32_len(&cd
->data
.db_id
);
377 case CTDB_CONTROL_GET_NODES_FILE
:
380 case CTDB_CONTROL_DB_FREEZE
:
381 len
= ctdb_uint32_len(&cd
->data
.db_id
);
384 case CTDB_CONTROL_DB_THAW
:
385 len
= ctdb_uint32_len(&cd
->data
.db_id
);
388 case CTDB_CONTROL_DB_TRANSACTION_START
:
389 len
= ctdb_transdb_len(cd
->data
.transdb
);
392 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
393 len
= ctdb_transdb_len(cd
->data
.transdb
);
396 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
397 len
= ctdb_uint32_len(&cd
->data
.db_id
);
400 case CTDB_CONTROL_DB_PULL
:
401 len
= ctdb_pulldb_ext_len(cd
->data
.pulldb_ext
);
404 case CTDB_CONTROL_DB_PUSH_START
:
405 len
= ctdb_pulldb_ext_len(cd
->data
.pulldb_ext
);
408 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
409 len
= ctdb_uint32_len(&cd
->data
.db_id
);
412 case CTDB_CONTROL_DB_OPEN_FLAGS
:
413 len
= ctdb_uint32_len(&cd
->data
.db_id
);
416 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
417 len
= ctdb_string_len(&cd
->data
.db_name
);
420 case CTDB_CONTROL_CHECK_PID_SRVID
:
421 len
= ctdb_pid_srvid_len(cd
->data
.pid_srvid
);
424 case CTDB_CONTROL_TUNNEL_REGISTER
:
427 case CTDB_CONTROL_TUNNEL_DEREGISTER
:
434 static void ctdb_req_control_data_push(struct ctdb_req_control_data
*cd
,
435 uint8_t *buf
, size_t *npush
)
437 size_t np
= 0, offset
;
440 switch (cd
->opcode
) {
441 case CTDB_CONTROL_PROCESS_EXISTS
:
442 ctdb_pid_push(&cd
->data
.pid
, buf
, &np
);
445 case CTDB_CONTROL_GETDBPATH
:
446 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
449 case CTDB_CONTROL_SETVNNMAP
:
450 ctdb_vnn_map_push(cd
->data
.vnnmap
, buf
, &np
);
453 case CTDB_CONTROL_SET_DEBUG
:
454 ctdb_uint32_push(&cd
->data
.loglevel
, buf
, &np
);
457 case CTDB_CONTROL_PULL_DB
:
458 ctdb_pulldb_push(cd
->data
.pulldb
, buf
, &np
);
461 case CTDB_CONTROL_PUSH_DB
:
462 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
465 case CTDB_CONTROL_SET_RECMODE
:
466 ctdb_uint32_push(&cd
->data
.recmode
, buf
, &np
);
469 case CTDB_CONTROL_DB_ATTACH
:
470 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
473 case CTDB_CONTROL_SET_CALL
:
476 case CTDB_CONTROL_TRAVERSE_START
:
477 ctdb_traverse_start_push(cd
->data
.traverse_start
, buf
, &np
);
480 case CTDB_CONTROL_TRAVERSE_ALL
:
481 ctdb_traverse_all_push(cd
->data
.traverse_all
, buf
, &np
);
484 case CTDB_CONTROL_TRAVERSE_DATA
:
485 ctdb_rec_data_push(cd
->data
.rec_data
, buf
, &np
);
488 case CTDB_CONTROL_GET_DBNAME
:
489 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
492 case CTDB_CONTROL_ENABLE_SEQNUM
:
493 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
496 case CTDB_CONTROL_UPDATE_SEQNUM
:
497 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
500 case CTDB_CONTROL_SET_RECMASTER
:
501 ctdb_uint32_push(&cd
->data
.recmaster
, buf
, &np
);
504 case CTDB_CONTROL_TCP_CLIENT
:
505 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
508 case CTDB_CONTROL_TCP_ADD
:
509 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
512 case CTDB_CONTROL_TCP_REMOVE
:
513 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
516 case CTDB_CONTROL_SET_TUNABLE
:
517 ctdb_tunable_push(cd
->data
.tunable
, buf
, &np
);
520 case CTDB_CONTROL_GET_TUNABLE
:
521 ctdb_stringn_push(&cd
->data
.tun_var
, buf
, &np
);
524 case CTDB_CONTROL_MODIFY_FLAGS
:
525 ctdb_node_flag_change_push(cd
->data
.flag_change
, buf
, &np
);
528 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
529 ctdb_sock_addr_push(cd
->data
.addr
, buf
, &np
);
532 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
533 ctdb_tickle_list_push(cd
->data
.tickles
, buf
, &np
);
536 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
537 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
540 case CTDB_CONTROL_UPDATE_RECORD
:
541 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
544 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
545 ctdb_addr_info_push(cd
->data
.addr_info
, buf
, &np
);
548 case CTDB_CONTROL_WIPE_DATABASE
:
549 ctdb_transdb_push(cd
->data
.transdb
, buf
, &np
);
552 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
553 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
556 case CTDB_CONTROL_ADD_PUBLIC_IP
:
557 ctdb_addr_info_push(cd
->data
.addr_info
, buf
, &np
);
560 case CTDB_CONTROL_DEL_PUBLIC_IP
:
561 ctdb_addr_info_push(cd
->data
.addr_info
, buf
, &np
);
564 case CTDB_CONTROL_RELEASE_IP
:
565 ctdb_public_ip_push(cd
->data
.pubip
, buf
, &np
);
568 case CTDB_CONTROL_TAKEOVER_IP
:
569 ctdb_public_ip_push(cd
->data
.pubip
, buf
, &np
);
572 case CTDB_CONTROL_TRAVERSE_KILL
:
573 ctdb_traverse_start_push(cd
->data
.traverse_start
, buf
, &np
);
576 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
577 ctdb_double_push(&cd
->data
.reclock_latency
, buf
, &np
);
580 case CTDB_CONTROL_SET_LMASTERROLE
:
581 ctdb_uint32_push(&cd
->data
.role
, buf
, &np
);
584 case CTDB_CONTROL_SET_RECMASTERROLE
:
585 ctdb_uint32_push(&cd
->data
.role
, buf
, &np
);
588 case CTDB_CONTROL_SET_BAN_STATE
:
589 ctdb_ban_state_push(cd
->data
.ban_state
, buf
, &np
);
592 case CTDB_CONTROL_REGISTER_NOTIFY
:
593 ctdb_notify_data_push(cd
->data
.notify
, buf
, &np
);
596 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
597 ctdb_uint64_push(&cd
->data
.srvid
, buf
, &np
);
600 case CTDB_CONTROL_TRANS3_COMMIT
:
601 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
604 case CTDB_CONTROL_GET_DB_SEQNUM
:
607 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
609 ctdb_uint32_push(&u32
, buf
+offset
, &np
);
614 case CTDB_CONTROL_DB_SET_HEALTHY
:
615 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
618 case CTDB_CONTROL_DB_GET_HEALTH
:
619 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
622 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
623 ctdb_sock_addr_push(cd
->data
.addr
, buf
, &np
);
626 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
627 ctdb_iface_push(cd
->data
.iface
, buf
, &np
);
630 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
631 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
634 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
635 ctdb_key_data_push(cd
->data
.key
, buf
, &np
);
638 case CTDB_CONTROL_SET_DB_READONLY
:
639 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
642 case CTDB_CONTROL_CHECK_SRVIDS
:
645 case CTDB_CONTROL_TRAVERSE_START_EXT
:
646 ctdb_traverse_start_ext_push(cd
->data
.traverse_start_ext
, buf
,
650 case CTDB_CONTROL_GET_DB_STATISTICS
:
651 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
654 case CTDB_CONTROL_SET_DB_STICKY
:
655 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
658 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
659 ctdb_traverse_all_ext_push(cd
->data
.traverse_all_ext
, buf
,
663 case CTDB_CONTROL_RECEIVE_RECORDS
:
664 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
667 case CTDB_CONTROL_DB_DETACH
:
668 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
671 case CTDB_CONTROL_DB_FREEZE
:
672 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
675 case CTDB_CONTROL_DB_THAW
:
676 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
679 case CTDB_CONTROL_DB_TRANSACTION_START
:
680 ctdb_transdb_push(cd
->data
.transdb
, buf
, &np
);
683 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
684 ctdb_transdb_push(cd
->data
.transdb
, buf
, &np
);
687 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
688 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
691 case CTDB_CONTROL_DB_PULL
:
692 ctdb_pulldb_ext_push(cd
->data
.pulldb_ext
, buf
, &np
);
695 case CTDB_CONTROL_DB_PUSH_START
:
696 ctdb_pulldb_ext_push(cd
->data
.pulldb_ext
, buf
, &np
);
699 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
700 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
703 case CTDB_CONTROL_DB_OPEN_FLAGS
:
704 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
707 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
708 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
711 case CTDB_CONTROL_CHECK_PID_SRVID
:
712 ctdb_pid_srvid_push(cd
->data
.pid_srvid
, buf
, &np
);
719 static int ctdb_req_control_data_pull(uint8_t *buf
, size_t buflen
,
722 struct ctdb_req_control_data
*cd
,
725 size_t np
= 0, offset
;
732 case CTDB_CONTROL_PROCESS_EXISTS
:
733 ret
= ctdb_pid_pull(buf
, buflen
, &cd
->data
.pid
, &np
);
736 case CTDB_CONTROL_GETDBPATH
:
737 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
740 case CTDB_CONTROL_SETVNNMAP
:
741 ret
= ctdb_vnn_map_pull(buf
, buflen
, mem_ctx
,
742 &cd
->data
.vnnmap
, &np
);
745 case CTDB_CONTROL_SET_DEBUG
:
746 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.loglevel
, &np
);
749 case CTDB_CONTROL_PULL_DB
:
750 ret
= ctdb_pulldb_pull(buf
, buflen
, mem_ctx
,
751 &cd
->data
.pulldb
, &np
);
754 case CTDB_CONTROL_PUSH_DB
:
755 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
756 &cd
->data
.recbuf
, &np
);
759 case CTDB_CONTROL_SET_RECMODE
:
760 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.recmode
, &np
);
763 case CTDB_CONTROL_DB_ATTACH
:
764 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
765 &cd
->data
.db_name
, &np
);
768 case CTDB_CONTROL_SET_CALL
:
771 case CTDB_CONTROL_TRAVERSE_START
:
772 ret
= ctdb_traverse_start_pull(buf
, buflen
, mem_ctx
,
773 &cd
->data
.traverse_start
, &np
);
776 case CTDB_CONTROL_TRAVERSE_ALL
:
777 ret
= ctdb_traverse_all_pull(buf
, buflen
, mem_ctx
,
778 &cd
->data
.traverse_all
, &np
);
781 case CTDB_CONTROL_TRAVERSE_DATA
:
782 ret
= ctdb_rec_data_pull(buf
, buflen
, mem_ctx
,
783 &cd
->data
.rec_data
, &np
);
786 case CTDB_CONTROL_GET_DBNAME
:
787 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
790 case CTDB_CONTROL_ENABLE_SEQNUM
:
791 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
794 case CTDB_CONTROL_UPDATE_SEQNUM
:
795 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
798 case CTDB_CONTROL_SET_RECMASTER
:
799 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.recmaster
, &np
);
802 case CTDB_CONTROL_TCP_CLIENT
:
803 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
804 &cd
->data
.conn
, &np
);
807 case CTDB_CONTROL_TCP_ADD
:
808 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
809 &cd
->data
.conn
, &np
);
812 case CTDB_CONTROL_TCP_REMOVE
:
813 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
814 &cd
->data
.conn
, &np
);
817 case CTDB_CONTROL_SET_TUNABLE
:
818 ret
= ctdb_tunable_pull(buf
, buflen
, mem_ctx
,
819 &cd
->data
.tunable
, &np
);
822 case CTDB_CONTROL_GET_TUNABLE
:
823 ret
= ctdb_stringn_pull(buf
, buflen
, mem_ctx
,
824 &cd
->data
.tun_var
, &np
);
827 case CTDB_CONTROL_MODIFY_FLAGS
:
828 ret
= ctdb_node_flag_change_pull(buf
, buflen
, mem_ctx
,
829 &cd
->data
.flag_change
, &np
);
832 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
833 ret
= ctdb_sock_addr_pull(buf
, buflen
, mem_ctx
,
834 &cd
->data
.addr
, &np
);
837 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
838 ret
= ctdb_tickle_list_pull(buf
, buflen
, mem_ctx
,
839 &cd
->data
.tickles
, &np
);
842 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
843 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
844 &cd
->data
.db_name
, &np
);
847 case CTDB_CONTROL_UPDATE_RECORD
:
848 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
849 &cd
->data
.recbuf
, &np
);
852 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
853 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
854 &cd
->data
.addr_info
, &np
);
857 case CTDB_CONTROL_WIPE_DATABASE
:
858 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
859 &cd
->data
.transdb
, &np
);
862 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
863 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
864 &cd
->data
.recbuf
, &np
);
867 case CTDB_CONTROL_ADD_PUBLIC_IP
:
868 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
869 &cd
->data
.addr_info
, &np
);
872 case CTDB_CONTROL_DEL_PUBLIC_IP
:
873 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
874 &cd
->data
.addr_info
, &np
);
877 case CTDB_CONTROL_RELEASE_IP
:
878 ret
= ctdb_public_ip_pull(buf
, buflen
, mem_ctx
,
879 &cd
->data
.pubip
, &np
);
882 case CTDB_CONTROL_TAKEOVER_IP
:
883 ret
= ctdb_public_ip_pull(buf
, buflen
, mem_ctx
,
884 &cd
->data
.pubip
, &np
);
887 case CTDB_CONTROL_TRAVERSE_KILL
:
888 ret
= ctdb_traverse_start_pull(buf
, buflen
, mem_ctx
,
889 &cd
->data
.traverse_start
, &np
);
892 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
893 ret
= ctdb_double_pull(buf
, buflen
, &cd
->data
.reclock_latency
,
897 case CTDB_CONTROL_SET_LMASTERROLE
:
898 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.role
, &np
);
901 case CTDB_CONTROL_SET_RECMASTERROLE
:
902 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.role
, &np
);
905 case CTDB_CONTROL_SET_BAN_STATE
:
906 ret
= ctdb_ban_state_pull(buf
, buflen
, mem_ctx
,
907 &cd
->data
.ban_state
, &np
);
910 case CTDB_CONTROL_REGISTER_NOTIFY
:
911 ret
= ctdb_notify_data_pull(buf
, buflen
, mem_ctx
,
912 &cd
->data
.notify
, &np
);
915 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
916 ret
= ctdb_uint64_pull(buf
, buflen
, &cd
->data
.srvid
, &np
);
919 case CTDB_CONTROL_TRANS3_COMMIT
:
920 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
921 &cd
->data
.recbuf
, &np
);
924 case CTDB_CONTROL_GET_DB_SEQNUM
:
926 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
931 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &u32
, &np
);
936 case CTDB_CONTROL_DB_SET_HEALTHY
:
937 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
940 case CTDB_CONTROL_DB_GET_HEALTH
:
941 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
944 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
945 ret
= ctdb_sock_addr_pull(buf
, buflen
, mem_ctx
,
946 &cd
->data
.addr
, &np
);
949 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
950 ret
= ctdb_iface_pull(buf
, buflen
, mem_ctx
,
951 &cd
->data
.iface
, &np
);
954 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
955 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
956 &cd
->data
.conn
, &np
);
959 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
960 ret
= ctdb_key_data_pull(buf
, buflen
, mem_ctx
,
964 case CTDB_CONTROL_SET_DB_READONLY
:
965 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
968 case CTDB_CONTROL_CHECK_SRVIDS
:
971 case CTDB_CONTROL_TRAVERSE_START_EXT
:
972 ret
= ctdb_traverse_start_ext_pull(buf
, buflen
, mem_ctx
,
973 &cd
->data
.traverse_start_ext
,
977 case CTDB_CONTROL_GET_DB_STATISTICS
:
978 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
981 case CTDB_CONTROL_SET_DB_STICKY
:
982 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
985 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
986 ret
= ctdb_traverse_all_ext_pull(buf
, buflen
, mem_ctx
,
987 &cd
->data
.traverse_all_ext
,
991 case CTDB_CONTROL_RECEIVE_RECORDS
:
992 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
993 &cd
->data
.recbuf
, &np
);
996 case CTDB_CONTROL_DB_DETACH
:
997 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1000 case CTDB_CONTROL_DB_FREEZE
:
1001 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1004 case CTDB_CONTROL_DB_THAW
:
1005 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1008 case CTDB_CONTROL_DB_TRANSACTION_START
:
1009 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
1010 &cd
->data
.transdb
, &np
);
1013 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
1014 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
1015 &cd
->data
.transdb
, &np
);
1018 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
1019 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1022 case CTDB_CONTROL_DB_PULL
:
1023 ret
= ctdb_pulldb_ext_pull(buf
, buflen
, mem_ctx
,
1024 &cd
->data
.pulldb_ext
, &np
);
1027 case CTDB_CONTROL_DB_PUSH_START
:
1028 ret
= ctdb_pulldb_ext_pull(buf
, buflen
, mem_ctx
,
1029 &cd
->data
.pulldb_ext
, &np
);
1032 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1033 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1036 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1037 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1040 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1041 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1042 &cd
->data
.db_name
, &np
);
1045 case CTDB_CONTROL_CHECK_PID_SRVID
:
1046 ret
= ctdb_pid_srvid_pull(buf
, buflen
, mem_ctx
,
1047 &cd
->data
.pid_srvid
, &np
);
1059 static size_t ctdb_reply_control_data_len(struct ctdb_reply_control_data
*cd
)
1067 switch (cd
->opcode
) {
1068 case CTDB_CONTROL_PROCESS_EXISTS
:
1071 case CTDB_CONTROL_STATISTICS
:
1072 len
= ctdb_statistics_len(cd
->data
.stats
);
1075 case CTDB_CONTROL_PING
:
1078 case CTDB_CONTROL_GETDBPATH
:
1079 len
= ctdb_string_len(&cd
->data
.db_path
);
1082 case CTDB_CONTROL_GETVNNMAP
:
1083 len
= ctdb_vnn_map_len(cd
->data
.vnnmap
);
1086 case CTDB_CONTROL_SETVNNMAP
:
1089 case CTDB_CONTROL_GET_DEBUG
:
1090 len
= ctdb_uint32_len(&cd
->data
.loglevel
);
1093 case CTDB_CONTROL_SET_DEBUG
:
1096 case CTDB_CONTROL_GET_DBMAP
:
1097 len
= ctdb_dbid_map_len(cd
->data
.dbmap
);
1100 case CTDB_CONTROL_PULL_DB
:
1101 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
1104 case CTDB_CONTROL_PUSH_DB
:
1107 case CTDB_CONTROL_GET_RECMODE
:
1110 case CTDB_CONTROL_SET_RECMODE
:
1113 case CTDB_CONTROL_STATISTICS_RESET
:
1116 case CTDB_CONTROL_DB_ATTACH
:
1117 len
= ctdb_uint32_len(&cd
->data
.db_id
);
1120 case CTDB_CONTROL_SET_CALL
:
1123 case CTDB_CONTROL_TRAVERSE_START
:
1126 case CTDB_CONTROL_TRAVERSE_ALL
:
1129 case CTDB_CONTROL_TRAVERSE_DATA
:
1132 case CTDB_CONTROL_REGISTER_SRVID
:
1135 case CTDB_CONTROL_DEREGISTER_SRVID
:
1138 case CTDB_CONTROL_GET_DBNAME
:
1139 len
= ctdb_string_len(&cd
->data
.db_name
);
1142 case CTDB_CONTROL_ENABLE_SEQNUM
:
1145 case CTDB_CONTROL_UPDATE_SEQNUM
:
1148 case CTDB_CONTROL_DUMP_MEMORY
:
1149 len
= ctdb_string_len(&cd
->data
.mem_str
);
1152 case CTDB_CONTROL_GET_PID
:
1155 case CTDB_CONTROL_GET_RECMASTER
:
1158 case CTDB_CONTROL_SET_RECMASTER
:
1161 case CTDB_CONTROL_FREEZE
:
1164 case CTDB_CONTROL_GET_PNN
:
1167 case CTDB_CONTROL_SHUTDOWN
:
1170 case CTDB_CONTROL_GET_MONMODE
:
1173 case CTDB_CONTROL_TCP_CLIENT
:
1176 case CTDB_CONTROL_TCP_ADD
:
1179 case CTDB_CONTROL_TCP_REMOVE
:
1182 case CTDB_CONTROL_STARTUP
:
1185 case CTDB_CONTROL_SET_TUNABLE
:
1188 case CTDB_CONTROL_GET_TUNABLE
:
1189 len
= ctdb_uint32_len(&cd
->data
.tun_value
);
1192 case CTDB_CONTROL_LIST_TUNABLES
:
1193 len
= ctdb_var_list_len(cd
->data
.tun_var_list
);
1196 case CTDB_CONTROL_MODIFY_FLAGS
:
1199 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1200 len
= ctdb_tunable_list_len(cd
->data
.tun_list
);
1203 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1204 len
= ctdb_tickle_list_len(cd
->data
.tickles
);
1207 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
1210 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1211 len
= ctdb_uint32_len(&cd
->data
.db_id
);
1214 case CTDB_CONTROL_UPDATE_RECORD
:
1217 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
1220 case CTDB_CONTROL_WIPE_DATABASE
:
1223 case CTDB_CONTROL_UPTIME
:
1224 len
= ctdb_uptime_len(cd
->data
.uptime
);
1227 case CTDB_CONTROL_START_RECOVERY
:
1230 case CTDB_CONTROL_END_RECOVERY
:
1233 case CTDB_CONTROL_RELOAD_NODES_FILE
:
1236 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1237 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
1240 case CTDB_CONTROL_ENABLE_MONITOR
:
1243 case CTDB_CONTROL_DISABLE_MONITOR
:
1246 case CTDB_CONTROL_ADD_PUBLIC_IP
:
1249 case CTDB_CONTROL_DEL_PUBLIC_IP
:
1252 case CTDB_CONTROL_GET_CAPABILITIES
:
1253 len
= ctdb_uint32_len(&cd
->data
.caps
);
1256 case CTDB_CONTROL_RECD_PING
:
1259 case CTDB_CONTROL_RELEASE_IP
:
1262 case CTDB_CONTROL_TAKEOVER_IP
:
1265 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1266 len
= ctdb_public_ip_list_len(cd
->data
.pubip_list
);
1269 case CTDB_CONTROL_GET_NODEMAP
:
1270 len
= ctdb_node_map_len(cd
->data
.nodemap
);
1273 case CTDB_CONTROL_TRAVERSE_KILL
:
1276 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
1279 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1280 len
= ctdb_string_len(&cd
->data
.reclock_file
);
1283 case CTDB_CONTROL_STOP_NODE
:
1286 case CTDB_CONTROL_CONTINUE_NODE
:
1289 case CTDB_CONTROL_SET_LMASTERROLE
:
1292 case CTDB_CONTROL_SET_RECMASTERROLE
:
1295 case CTDB_CONTROL_SET_BAN_STATE
:
1298 case CTDB_CONTROL_GET_BAN_STATE
:
1299 len
= ctdb_ban_state_len(cd
->data
.ban_state
);
1302 case CTDB_CONTROL_SET_DB_PRIORITY
:
1305 case CTDB_CONTROL_GET_DB_PRIORITY
:
1308 case CTDB_CONTROL_REGISTER_NOTIFY
:
1311 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
1314 case CTDB_CONTROL_TRANS3_COMMIT
:
1317 case CTDB_CONTROL_GET_DB_SEQNUM
:
1318 len
= ctdb_uint64_len(&cd
->data
.seqnum
);
1321 case CTDB_CONTROL_DB_SET_HEALTHY
:
1324 case CTDB_CONTROL_DB_GET_HEALTH
:
1325 len
= ctdb_string_len(&cd
->data
.reason
);
1328 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1329 len
= ctdb_public_ip_info_len(cd
->data
.ipinfo
);
1332 case CTDB_CONTROL_GET_IFACES
:
1333 len
= ctdb_iface_list_len(cd
->data
.iface_list
);
1336 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
1339 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
1342 case CTDB_CONTROL_GET_STAT_HISTORY
:
1343 len
= ctdb_statistics_list_len(cd
->data
.stats_list
);
1346 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
1349 case CTDB_CONTROL_SET_DB_READONLY
:
1352 case CTDB_CONTROL_CHECK_SRVIDS
:
1355 case CTDB_CONTROL_TRAVERSE_START_EXT
:
1358 case CTDB_CONTROL_GET_DB_STATISTICS
:
1359 len
= ctdb_db_statistics_len(cd
->data
.dbstats
);
1362 case CTDB_CONTROL_SET_DB_STICKY
:
1365 case CTDB_CONTROL_RELOAD_PUBLIC_IPS
:
1368 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
1371 case CTDB_CONTROL_RECEIVE_RECORDS
:
1372 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
1375 case CTDB_CONTROL_IPREALLOCATED
:
1378 case CTDB_CONTROL_GET_RUNSTATE
:
1379 len
= ctdb_uint32_len(&cd
->data
.runstate
);
1382 case CTDB_CONTROL_DB_DETACH
:
1385 case CTDB_CONTROL_GET_NODES_FILE
:
1386 len
= ctdb_node_map_len(cd
->data
.nodemap
);
1389 case CTDB_CONTROL_DB_FREEZE
:
1392 case CTDB_CONTROL_DB_THAW
:
1395 case CTDB_CONTROL_DB_TRANSACTION_START
:
1398 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
1401 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
1404 case CTDB_CONTROL_DB_PULL
:
1405 len
= ctdb_uint32_len(&cd
->data
.num_records
);
1408 case CTDB_CONTROL_DB_PUSH_START
:
1411 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1412 len
= ctdb_uint32_len(&cd
->data
.num_records
);
1415 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1416 len
= ctdb_int32_len(&cd
->data
.tdb_flags
);
1419 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1420 len
= ctdb_uint32_len(&cd
->data
.db_id
);
1423 case CTDB_CONTROL_CHECK_PID_SRVID
:
1426 case CTDB_CONTROL_TUNNEL_REGISTER
:
1429 case CTDB_CONTROL_TUNNEL_DEREGISTER
:
1436 static void ctdb_reply_control_data_push(struct ctdb_reply_control_data
*cd
,
1437 uint8_t *buf
, size_t *npush
)
1441 switch (cd
->opcode
) {
1442 case CTDB_CONTROL_STATISTICS
:
1443 ctdb_statistics_push(cd
->data
.stats
, buf
, &np
);
1446 case CTDB_CONTROL_GETDBPATH
:
1447 ctdb_string_push(&cd
->data
.db_path
, buf
, &np
);
1450 case CTDB_CONTROL_GETVNNMAP
:
1451 ctdb_vnn_map_push(cd
->data
.vnnmap
, buf
, &np
);
1454 case CTDB_CONTROL_GET_DEBUG
:
1455 ctdb_uint32_push(&cd
->data
.loglevel
, buf
, &np
);
1458 case CTDB_CONTROL_GET_DBMAP
:
1459 ctdb_dbid_map_push(cd
->data
.dbmap
, buf
, &np
);
1462 case CTDB_CONTROL_PULL_DB
:
1463 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
1466 case CTDB_CONTROL_PUSH_DB
:
1469 case CTDB_CONTROL_DB_ATTACH
:
1470 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
1473 case CTDB_CONTROL_GET_DBNAME
:
1474 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
1477 case CTDB_CONTROL_DUMP_MEMORY
:
1478 ctdb_string_push(&cd
->data
.mem_str
, buf
, &np
);
1481 case CTDB_CONTROL_GET_PID
:
1484 case CTDB_CONTROL_GET_RECMASTER
:
1487 case CTDB_CONTROL_GET_TUNABLE
:
1488 ctdb_uint32_push(&cd
->data
.tun_value
, buf
, &np
);
1491 case CTDB_CONTROL_LIST_TUNABLES
:
1492 ctdb_var_list_push(cd
->data
.tun_var_list
, buf
, &np
);
1495 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1496 ctdb_tunable_list_push(cd
->data
.tun_list
, buf
, &np
);
1499 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1500 ctdb_tickle_list_push(cd
->data
.tickles
, buf
, &np
);
1503 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1504 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
1507 case CTDB_CONTROL_UPTIME
:
1508 ctdb_uptime_push(cd
->data
.uptime
, buf
, &np
);
1511 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1512 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
1515 case CTDB_CONTROL_GET_CAPABILITIES
:
1516 ctdb_uint32_push(&cd
->data
.caps
, buf
, &np
);
1519 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1520 ctdb_public_ip_list_push(cd
->data
.pubip_list
, buf
, &np
);
1523 case CTDB_CONTROL_GET_NODEMAP
:
1524 ctdb_node_map_push(cd
->data
.nodemap
, buf
, &np
);
1527 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1528 ctdb_string_push(&cd
->data
.reclock_file
, buf
, &np
);
1531 case CTDB_CONTROL_GET_BAN_STATE
:
1532 ctdb_ban_state_push(cd
->data
.ban_state
, buf
, &np
);
1535 case CTDB_CONTROL_GET_DB_PRIORITY
:
1538 case CTDB_CONTROL_GET_DB_SEQNUM
:
1539 ctdb_uint64_push(&cd
->data
.seqnum
, buf
, &np
);
1542 case CTDB_CONTROL_DB_GET_HEALTH
:
1543 ctdb_string_push(&cd
->data
.reason
, buf
, &np
);
1546 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1547 ctdb_public_ip_info_push(cd
->data
.ipinfo
, buf
, &np
);
1550 case CTDB_CONTROL_GET_IFACES
:
1551 ctdb_iface_list_push(cd
->data
.iface_list
, buf
, &np
);
1554 case CTDB_CONTROL_GET_STAT_HISTORY
:
1555 ctdb_statistics_list_push(cd
->data
.stats_list
, buf
, &np
);
1558 case CTDB_CONTROL_CHECK_SRVIDS
:
1561 case CTDB_CONTROL_GET_DB_STATISTICS
:
1562 ctdb_db_statistics_push(cd
->data
.dbstats
, buf
, &np
);
1565 case CTDB_CONTROL_RECEIVE_RECORDS
:
1566 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
1569 case CTDB_CONTROL_GET_RUNSTATE
:
1570 ctdb_uint32_push(&cd
->data
.runstate
, buf
, &np
);
1573 case CTDB_CONTROL_GET_NODES_FILE
:
1574 ctdb_node_map_push(cd
->data
.nodemap
, buf
, &np
);
1577 case CTDB_CONTROL_DB_PULL
:
1578 ctdb_uint32_push(&cd
->data
.num_records
, buf
, &np
);
1581 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1582 ctdb_uint32_push(&cd
->data
.num_records
, buf
, &np
);
1585 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1586 ctdb_int32_push(&cd
->data
.tdb_flags
, buf
, &np
);
1589 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1590 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
1593 case CTDB_CONTROL_CHECK_PID_SRVID
:
1600 static int ctdb_reply_control_data_pull(uint8_t *buf
, size_t buflen
,
1601 uint32_t opcode
, TALLOC_CTX
*mem_ctx
,
1602 struct ctdb_reply_control_data
*cd
,
1608 cd
->opcode
= opcode
;
1611 case CTDB_CONTROL_STATISTICS
:
1612 ret
= ctdb_statistics_pull(buf
, buflen
, mem_ctx
,
1613 &cd
->data
.stats
, &np
);
1616 case CTDB_CONTROL_GETDBPATH
:
1617 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1618 &cd
->data
.db_path
, &np
);
1621 case CTDB_CONTROL_GETVNNMAP
:
1622 ret
= ctdb_vnn_map_pull(buf
, buflen
, mem_ctx
,
1623 &cd
->data
.vnnmap
, &np
);
1626 case CTDB_CONTROL_GET_DEBUG
:
1627 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.loglevel
, &np
);
1630 case CTDB_CONTROL_GET_DBMAP
:
1631 ret
= ctdb_dbid_map_pull(buf
, buflen
, mem_ctx
,
1632 &cd
->data
.dbmap
, &np
);
1635 case CTDB_CONTROL_PULL_DB
:
1636 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
1637 &cd
->data
.recbuf
, &np
);
1640 case CTDB_CONTROL_PUSH_DB
:
1643 case CTDB_CONTROL_DB_ATTACH
:
1644 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1647 case CTDB_CONTROL_GET_DBNAME
:
1648 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1649 &cd
->data
.db_name
, &np
);
1652 case CTDB_CONTROL_DUMP_MEMORY
:
1653 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1654 &cd
->data
.mem_str
, &np
);
1657 case CTDB_CONTROL_GET_PID
:
1660 case CTDB_CONTROL_GET_RECMASTER
:
1663 case CTDB_CONTROL_GET_TUNABLE
:
1664 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.tun_value
,
1668 case CTDB_CONTROL_LIST_TUNABLES
:
1669 ret
= ctdb_var_list_pull(buf
, buflen
, mem_ctx
,
1670 &cd
->data
.tun_var_list
, &np
);
1673 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1674 ret
= ctdb_tunable_list_pull(buf
, buflen
, mem_ctx
,
1675 &cd
->data
.tun_list
, &np
);
1678 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1679 ret
= ctdb_tickle_list_pull(buf
, buflen
, mem_ctx
,
1680 &cd
->data
.tickles
, &np
);
1683 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1684 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1687 case CTDB_CONTROL_UPTIME
:
1688 ret
= ctdb_uptime_pull(buf
, buflen
, mem_ctx
,
1689 &cd
->data
.uptime
, &np
);
1692 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1693 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
1694 &cd
->data
.recbuf
, &np
);
1697 case CTDB_CONTROL_GET_CAPABILITIES
:
1698 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.caps
, &np
);
1701 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1702 ret
= ctdb_public_ip_list_pull(buf
, buflen
, mem_ctx
,
1703 &cd
->data
.pubip_list
, &np
);
1706 case CTDB_CONTROL_GET_NODEMAP
:
1707 ret
= ctdb_node_map_pull(buf
, buflen
, mem_ctx
,
1708 &cd
->data
.nodemap
, &np
);
1711 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1712 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1713 &cd
->data
.reclock_file
, &np
);
1716 case CTDB_CONTROL_GET_BAN_STATE
:
1717 ret
= ctdb_ban_state_pull(buf
, buflen
, mem_ctx
,
1718 &cd
->data
.ban_state
, &np
);
1721 case CTDB_CONTROL_GET_DB_PRIORITY
:
1724 case CTDB_CONTROL_GET_DB_SEQNUM
:
1725 ret
= ctdb_uint64_pull(buf
, buflen
, &cd
->data
.seqnum
, &np
);
1728 case CTDB_CONTROL_DB_GET_HEALTH
:
1729 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1730 &cd
->data
.reason
, &np
);
1733 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1734 ret
= ctdb_public_ip_info_pull(buf
, buflen
, mem_ctx
,
1735 &cd
->data
.ipinfo
, &np
);
1738 case CTDB_CONTROL_GET_IFACES
:
1739 ret
= ctdb_iface_list_pull(buf
, buflen
, mem_ctx
,
1740 &cd
->data
.iface_list
, &np
);
1743 case CTDB_CONTROL_GET_STAT_HISTORY
:
1744 ret
= ctdb_statistics_list_pull(buf
, buflen
, mem_ctx
,
1745 &cd
->data
.stats_list
, &np
);
1748 case CTDB_CONTROL_CHECK_SRVIDS
:
1751 case CTDB_CONTROL_GET_DB_STATISTICS
:
1752 ret
= ctdb_db_statistics_pull(buf
, buflen
, mem_ctx
,
1753 &cd
->data
.dbstats
, &np
);
1756 case CTDB_CONTROL_RECEIVE_RECORDS
:
1757 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
1758 &cd
->data
.recbuf
, &np
);
1761 case CTDB_CONTROL_GET_RUNSTATE
:
1762 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.runstate
, &np
);
1765 case CTDB_CONTROL_GET_NODES_FILE
:
1766 ret
= ctdb_node_map_pull(buf
, buflen
, mem_ctx
,
1767 &cd
->data
.nodemap
, &np
);
1770 case CTDB_CONTROL_DB_PULL
:
1771 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.num_records
,
1775 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1776 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.num_records
,
1780 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1781 ret
= ctdb_int32_pull(buf
, buflen
, &cd
->data
.tdb_flags
, &np
);
1784 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1785 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1788 case CTDB_CONTROL_CHECK_PID_SRVID
:
1800 size_t ctdb_req_control_len(struct ctdb_req_header
*h
,
1801 struct ctdb_req_control
*c
)
1805 return ctdb_req_header_len(h
) +
1806 ctdb_uint32_len(&c
->opcode
) +
1807 ctdb_uint32_len(&c
->pad
) +
1808 ctdb_uint64_len(&c
->srvid
) +
1809 ctdb_uint32_len(&c
->client_id
) +
1810 ctdb_uint32_len(&c
->flags
) +
1811 ctdb_uint32_len(&u32
) +
1812 ctdb_req_control_data_len(&c
->rdata
);
1815 int ctdb_req_control_push(struct ctdb_req_header
*h
,
1816 struct ctdb_req_control
*c
,
1817 uint8_t *buf
, size_t *buflen
)
1819 size_t offset
= 0, np
;
1823 length
= ctdb_req_control_len(h
, c
);
1824 if (*buflen
< length
) {
1829 h
->length
= *buflen
;
1830 ctdb_req_header_push(h
, buf
+offset
, &np
);
1833 ctdb_uint32_push(&c
->opcode
, buf
+offset
, &np
);
1836 ctdb_uint32_push(&c
->pad
, buf
+offset
, &np
);
1839 ctdb_uint64_push(&c
->srvid
, buf
+offset
, &np
);
1842 ctdb_uint32_push(&c
->client_id
, buf
+offset
, &np
);
1845 ctdb_uint32_push(&c
->flags
, buf
+offset
, &np
);
1848 u32
= ctdb_req_control_data_len(&c
->rdata
);
1849 ctdb_uint32_push(&u32
, buf
+offset
, &np
);
1852 ctdb_req_control_data_push(&c
->rdata
, buf
+offset
, &np
);
1855 if (offset
> *buflen
) {
1862 int ctdb_req_control_pull(uint8_t *buf
, size_t buflen
,
1863 struct ctdb_req_header
*h
,
1864 TALLOC_CTX
*mem_ctx
,
1865 struct ctdb_req_control
*c
)
1867 struct ctdb_req_header header
;
1868 size_t offset
= 0, np
;
1872 ret
= ctdb_req_header_pull(buf
+offset
, buflen
-offset
, &header
, &np
);
1882 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->opcode
, &np
);
1888 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->pad
, &np
);
1894 ret
= ctdb_uint64_pull(buf
+offset
, buflen
-offset
, &c
->srvid
, &np
);
1900 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->client_id
, &np
);
1906 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &c
->flags
, &np
);
1912 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &u32
, &np
);
1918 if (u32
> buflen
-offset
) {
1922 ret
= ctdb_req_control_data_pull(buf
+offset
, u32
, c
->opcode
, mem_ctx
,
1929 if (offset
> buflen
) {
1936 size_t ctdb_reply_control_len(struct ctdb_req_header
*h
,
1937 struct ctdb_reply_control
*c
)
1939 uint32_t dsize
, esize
;
1941 if (c
->status
== 0) {
1942 dsize
= ctdb_reply_control_data_len(&c
->rdata
);
1946 esize
= ctdb_string_len(&c
->errmsg
);
1949 return ctdb_req_header_len(h
) +
1950 ctdb_int32_len(&c
->status
) +
1951 ctdb_uint32_len(&dsize
) +
1952 ctdb_uint32_len(&esize
) +
1956 int ctdb_reply_control_push(struct ctdb_req_header
*h
,
1957 struct ctdb_reply_control
*c
,
1958 uint8_t *buf
, size_t *buflen
)
1960 size_t offset
= 0, np
;
1962 uint32_t dsize
, esize
;
1964 length
= ctdb_reply_control_len(h
, c
);
1965 if (*buflen
< length
) {
1970 h
->length
= *buflen
;
1971 ctdb_req_header_push(h
, buf
+offset
, &np
);
1974 ctdb_int32_push(&c
->status
, buf
+offset
, &np
);
1977 if (c
->status
== 0) {
1978 dsize
= ctdb_reply_control_data_len(&c
->rdata
);
1982 esize
= ctdb_string_len(&c
->errmsg
);
1985 ctdb_uint32_push(&dsize
, buf
+offset
, &np
);
1988 ctdb_uint32_push(&esize
, buf
+offset
, &np
);
1991 if (c
->status
== 0) {
1992 ctdb_reply_control_data_push(&c
->rdata
, buf
+offset
, &np
);
1994 ctdb_string_push(&c
->errmsg
, buf
+offset
, &np
);
2001 int ctdb_reply_control_pull(uint8_t *buf
, size_t buflen
, uint32_t opcode
,
2002 struct ctdb_req_header
*h
,
2003 TALLOC_CTX
*mem_ctx
,
2004 struct ctdb_reply_control
*c
)
2006 struct ctdb_req_header header
;
2007 size_t offset
= 0, np
;
2008 uint32_t dsize
, esize
;
2011 ret
= ctdb_req_header_pull(buf
+offset
, buflen
-offset
, &header
, &np
);
2021 ret
= ctdb_int32_pull(buf
+offset
, buflen
-offset
, &c
->status
, &np
);
2027 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &dsize
, &np
);
2033 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &esize
, &np
);
2041 if (c
->status
== 0) {
2042 if (buflen
-offset
< dsize
) {
2046 ret
= ctdb_reply_control_data_pull(buf
+offset
, dsize
,
2047 opcode
, mem_ctx
, &c
->rdata
,
2055 if (buflen
-offset
< esize
) {
2059 ret
= ctdb_string_pull(buf
+offset
, esize
, mem_ctx
, &c
->errmsg
,