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_IPREALLOCATED
:
366 case CTDB_CONTROL_GET_RUNSTATE
:
369 case CTDB_CONTROL_DB_DETACH
:
370 len
= ctdb_uint32_len(&cd
->data
.db_id
);
373 case CTDB_CONTROL_GET_NODES_FILE
:
376 case CTDB_CONTROL_DB_FREEZE
:
377 len
= ctdb_uint32_len(&cd
->data
.db_id
);
380 case CTDB_CONTROL_DB_THAW
:
381 len
= ctdb_uint32_len(&cd
->data
.db_id
);
384 case CTDB_CONTROL_DB_TRANSACTION_START
:
385 len
= ctdb_transdb_len(cd
->data
.transdb
);
388 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
389 len
= ctdb_transdb_len(cd
->data
.transdb
);
392 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
393 len
= ctdb_uint32_len(&cd
->data
.db_id
);
396 case CTDB_CONTROL_DB_PULL
:
397 len
= ctdb_pulldb_ext_len(cd
->data
.pulldb_ext
);
400 case CTDB_CONTROL_DB_PUSH_START
:
401 len
= ctdb_pulldb_ext_len(cd
->data
.pulldb_ext
);
404 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
405 len
= ctdb_uint32_len(&cd
->data
.db_id
);
408 case CTDB_CONTROL_DB_OPEN_FLAGS
:
409 len
= ctdb_uint32_len(&cd
->data
.db_id
);
412 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
413 len
= ctdb_string_len(&cd
->data
.db_name
);
416 case CTDB_CONTROL_CHECK_PID_SRVID
:
417 len
= ctdb_pid_srvid_len(cd
->data
.pid_srvid
);
420 case CTDB_CONTROL_TUNNEL_REGISTER
:
423 case CTDB_CONTROL_TUNNEL_DEREGISTER
:
430 static void ctdb_req_control_data_push(struct ctdb_req_control_data
*cd
,
431 uint8_t *buf
, size_t *npush
)
433 size_t np
= 0, offset
;
436 switch (cd
->opcode
) {
437 case CTDB_CONTROL_PROCESS_EXISTS
:
438 ctdb_pid_push(&cd
->data
.pid
, buf
, &np
);
441 case CTDB_CONTROL_GETDBPATH
:
442 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
445 case CTDB_CONTROL_SETVNNMAP
:
446 ctdb_vnn_map_push(cd
->data
.vnnmap
, buf
, &np
);
449 case CTDB_CONTROL_SET_DEBUG
:
450 ctdb_uint32_push(&cd
->data
.loglevel
, buf
, &np
);
453 case CTDB_CONTROL_PULL_DB
:
454 ctdb_pulldb_push(cd
->data
.pulldb
, buf
, &np
);
457 case CTDB_CONTROL_PUSH_DB
:
458 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
461 case CTDB_CONTROL_SET_RECMODE
:
462 ctdb_uint32_push(&cd
->data
.recmode
, buf
, &np
);
465 case CTDB_CONTROL_DB_ATTACH
:
466 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
469 case CTDB_CONTROL_SET_CALL
:
472 case CTDB_CONTROL_TRAVERSE_START
:
473 ctdb_traverse_start_push(cd
->data
.traverse_start
, buf
, &np
);
476 case CTDB_CONTROL_TRAVERSE_ALL
:
477 ctdb_traverse_all_push(cd
->data
.traverse_all
, buf
, &np
);
480 case CTDB_CONTROL_TRAVERSE_DATA
:
481 ctdb_rec_data_push(cd
->data
.rec_data
, buf
, &np
);
484 case CTDB_CONTROL_GET_DBNAME
:
485 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
488 case CTDB_CONTROL_ENABLE_SEQNUM
:
489 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
492 case CTDB_CONTROL_UPDATE_SEQNUM
:
493 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
496 case CTDB_CONTROL_SET_RECMASTER
:
497 ctdb_uint32_push(&cd
->data
.recmaster
, buf
, &np
);
500 case CTDB_CONTROL_TCP_CLIENT
:
501 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
504 case CTDB_CONTROL_TCP_ADD
:
505 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
508 case CTDB_CONTROL_TCP_REMOVE
:
509 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
512 case CTDB_CONTROL_SET_TUNABLE
:
513 ctdb_tunable_push(cd
->data
.tunable
, buf
, &np
);
516 case CTDB_CONTROL_GET_TUNABLE
:
517 ctdb_stringn_push(&cd
->data
.tun_var
, buf
, &np
);
520 case CTDB_CONTROL_MODIFY_FLAGS
:
521 ctdb_node_flag_change_push(cd
->data
.flag_change
, buf
, &np
);
524 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
525 ctdb_sock_addr_push(cd
->data
.addr
, buf
, &np
);
528 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
529 ctdb_tickle_list_push(cd
->data
.tickles
, buf
, &np
);
532 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
533 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
536 case CTDB_CONTROL_UPDATE_RECORD
:
537 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
540 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
541 ctdb_addr_info_push(cd
->data
.addr_info
, buf
, &np
);
544 case CTDB_CONTROL_WIPE_DATABASE
:
545 ctdb_transdb_push(cd
->data
.transdb
, buf
, &np
);
548 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
549 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
552 case CTDB_CONTROL_ADD_PUBLIC_IP
:
553 ctdb_addr_info_push(cd
->data
.addr_info
, buf
, &np
);
556 case CTDB_CONTROL_DEL_PUBLIC_IP
:
557 ctdb_addr_info_push(cd
->data
.addr_info
, buf
, &np
);
560 case CTDB_CONTROL_RELEASE_IP
:
561 ctdb_public_ip_push(cd
->data
.pubip
, buf
, &np
);
564 case CTDB_CONTROL_TAKEOVER_IP
:
565 ctdb_public_ip_push(cd
->data
.pubip
, buf
, &np
);
568 case CTDB_CONTROL_TRAVERSE_KILL
:
569 ctdb_traverse_start_push(cd
->data
.traverse_start
, buf
, &np
);
572 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
573 ctdb_double_push(&cd
->data
.reclock_latency
, buf
, &np
);
576 case CTDB_CONTROL_SET_LMASTERROLE
:
577 ctdb_uint32_push(&cd
->data
.role
, buf
, &np
);
580 case CTDB_CONTROL_SET_RECMASTERROLE
:
581 ctdb_uint32_push(&cd
->data
.role
, buf
, &np
);
584 case CTDB_CONTROL_SET_BAN_STATE
:
585 ctdb_ban_state_push(cd
->data
.ban_state
, buf
, &np
);
588 case CTDB_CONTROL_REGISTER_NOTIFY
:
589 ctdb_notify_data_push(cd
->data
.notify
, buf
, &np
);
592 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
593 ctdb_uint64_push(&cd
->data
.srvid
, buf
, &np
);
596 case CTDB_CONTROL_TRANS3_COMMIT
:
597 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
600 case CTDB_CONTROL_GET_DB_SEQNUM
:
603 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
605 ctdb_uint32_push(&u32
, buf
+offset
, &np
);
610 case CTDB_CONTROL_DB_SET_HEALTHY
:
611 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
614 case CTDB_CONTROL_DB_GET_HEALTH
:
615 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
618 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
619 ctdb_sock_addr_push(cd
->data
.addr
, buf
, &np
);
622 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
623 ctdb_iface_push(cd
->data
.iface
, buf
, &np
);
626 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
627 ctdb_connection_push(cd
->data
.conn
, buf
, &np
);
630 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
631 ctdb_key_data_push(cd
->data
.key
, buf
, &np
);
634 case CTDB_CONTROL_SET_DB_READONLY
:
635 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
638 case CTDB_CONTROL_CHECK_SRVIDS
:
641 case CTDB_CONTROL_TRAVERSE_START_EXT
:
642 ctdb_traverse_start_ext_push(cd
->data
.traverse_start_ext
, buf
,
646 case CTDB_CONTROL_GET_DB_STATISTICS
:
647 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
650 case CTDB_CONTROL_SET_DB_STICKY
:
651 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
654 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
655 ctdb_traverse_all_ext_push(cd
->data
.traverse_all_ext
, buf
,
659 case CTDB_CONTROL_DB_DETACH
:
660 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
663 case CTDB_CONTROL_DB_FREEZE
:
664 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
667 case CTDB_CONTROL_DB_THAW
:
668 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
671 case CTDB_CONTROL_DB_TRANSACTION_START
:
672 ctdb_transdb_push(cd
->data
.transdb
, buf
, &np
);
675 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
676 ctdb_transdb_push(cd
->data
.transdb
, buf
, &np
);
679 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
680 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
683 case CTDB_CONTROL_DB_PULL
:
684 ctdb_pulldb_ext_push(cd
->data
.pulldb_ext
, buf
, &np
);
687 case CTDB_CONTROL_DB_PUSH_START
:
688 ctdb_pulldb_ext_push(cd
->data
.pulldb_ext
, buf
, &np
);
691 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
692 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
695 case CTDB_CONTROL_DB_OPEN_FLAGS
:
696 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
699 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
700 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
703 case CTDB_CONTROL_CHECK_PID_SRVID
:
704 ctdb_pid_srvid_push(cd
->data
.pid_srvid
, buf
, &np
);
711 static int ctdb_req_control_data_pull(uint8_t *buf
, size_t buflen
,
714 struct ctdb_req_control_data
*cd
,
717 size_t np
= 0, offset
;
724 case CTDB_CONTROL_PROCESS_EXISTS
:
725 ret
= ctdb_pid_pull(buf
, buflen
, &cd
->data
.pid
, &np
);
728 case CTDB_CONTROL_GETDBPATH
:
729 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
732 case CTDB_CONTROL_SETVNNMAP
:
733 ret
= ctdb_vnn_map_pull(buf
, buflen
, mem_ctx
,
734 &cd
->data
.vnnmap
, &np
);
737 case CTDB_CONTROL_SET_DEBUG
:
738 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.loglevel
, &np
);
741 case CTDB_CONTROL_PULL_DB
:
742 ret
= ctdb_pulldb_pull(buf
, buflen
, mem_ctx
,
743 &cd
->data
.pulldb
, &np
);
746 case CTDB_CONTROL_PUSH_DB
:
747 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
748 &cd
->data
.recbuf
, &np
);
751 case CTDB_CONTROL_SET_RECMODE
:
752 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.recmode
, &np
);
755 case CTDB_CONTROL_DB_ATTACH
:
756 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
757 &cd
->data
.db_name
, &np
);
760 case CTDB_CONTROL_SET_CALL
:
763 case CTDB_CONTROL_TRAVERSE_START
:
764 ret
= ctdb_traverse_start_pull(buf
, buflen
, mem_ctx
,
765 &cd
->data
.traverse_start
, &np
);
768 case CTDB_CONTROL_TRAVERSE_ALL
:
769 ret
= ctdb_traverse_all_pull(buf
, buflen
, mem_ctx
,
770 &cd
->data
.traverse_all
, &np
);
773 case CTDB_CONTROL_TRAVERSE_DATA
:
774 ret
= ctdb_rec_data_pull(buf
, buflen
, mem_ctx
,
775 &cd
->data
.rec_data
, &np
);
778 case CTDB_CONTROL_GET_DBNAME
:
779 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
782 case CTDB_CONTROL_ENABLE_SEQNUM
:
783 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
786 case CTDB_CONTROL_UPDATE_SEQNUM
:
787 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
790 case CTDB_CONTROL_SET_RECMASTER
:
791 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.recmaster
, &np
);
794 case CTDB_CONTROL_TCP_CLIENT
:
795 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
796 &cd
->data
.conn
, &np
);
799 case CTDB_CONTROL_TCP_ADD
:
800 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
801 &cd
->data
.conn
, &np
);
804 case CTDB_CONTROL_TCP_REMOVE
:
805 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
806 &cd
->data
.conn
, &np
);
809 case CTDB_CONTROL_SET_TUNABLE
:
810 ret
= ctdb_tunable_pull(buf
, buflen
, mem_ctx
,
811 &cd
->data
.tunable
, &np
);
814 case CTDB_CONTROL_GET_TUNABLE
:
815 ret
= ctdb_stringn_pull(buf
, buflen
, mem_ctx
,
816 &cd
->data
.tun_var
, &np
);
819 case CTDB_CONTROL_MODIFY_FLAGS
:
820 ret
= ctdb_node_flag_change_pull(buf
, buflen
, mem_ctx
,
821 &cd
->data
.flag_change
, &np
);
824 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
825 ret
= ctdb_sock_addr_pull(buf
, buflen
, mem_ctx
,
826 &cd
->data
.addr
, &np
);
829 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
830 ret
= ctdb_tickle_list_pull(buf
, buflen
, mem_ctx
,
831 &cd
->data
.tickles
, &np
);
834 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
835 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
836 &cd
->data
.db_name
, &np
);
839 case CTDB_CONTROL_UPDATE_RECORD
:
840 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
841 &cd
->data
.recbuf
, &np
);
844 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
845 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
846 &cd
->data
.addr_info
, &np
);
849 case CTDB_CONTROL_WIPE_DATABASE
:
850 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
851 &cd
->data
.transdb
, &np
);
854 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
855 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
856 &cd
->data
.recbuf
, &np
);
859 case CTDB_CONTROL_ADD_PUBLIC_IP
:
860 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
861 &cd
->data
.addr_info
, &np
);
864 case CTDB_CONTROL_DEL_PUBLIC_IP
:
865 ret
= ctdb_addr_info_pull(buf
, buflen
, mem_ctx
,
866 &cd
->data
.addr_info
, &np
);
869 case CTDB_CONTROL_RELEASE_IP
:
870 ret
= ctdb_public_ip_pull(buf
, buflen
, mem_ctx
,
871 &cd
->data
.pubip
, &np
);
874 case CTDB_CONTROL_TAKEOVER_IP
:
875 ret
= ctdb_public_ip_pull(buf
, buflen
, mem_ctx
,
876 &cd
->data
.pubip
, &np
);
879 case CTDB_CONTROL_TRAVERSE_KILL
:
880 ret
= ctdb_traverse_start_pull(buf
, buflen
, mem_ctx
,
881 &cd
->data
.traverse_start
, &np
);
884 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
885 ret
= ctdb_double_pull(buf
, buflen
, &cd
->data
.reclock_latency
,
889 case CTDB_CONTROL_SET_LMASTERROLE
:
890 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.role
, &np
);
893 case CTDB_CONTROL_SET_RECMASTERROLE
:
894 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.role
, &np
);
897 case CTDB_CONTROL_SET_BAN_STATE
:
898 ret
= ctdb_ban_state_pull(buf
, buflen
, mem_ctx
,
899 &cd
->data
.ban_state
, &np
);
902 case CTDB_CONTROL_REGISTER_NOTIFY
:
903 ret
= ctdb_notify_data_pull(buf
, buflen
, mem_ctx
,
904 &cd
->data
.notify
, &np
);
907 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
908 ret
= ctdb_uint64_pull(buf
, buflen
, &cd
->data
.srvid
, &np
);
911 case CTDB_CONTROL_TRANS3_COMMIT
:
912 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
913 &cd
->data
.recbuf
, &np
);
916 case CTDB_CONTROL_GET_DB_SEQNUM
:
918 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
923 ret
= ctdb_uint32_pull(buf
+offset
, buflen
-offset
, &u32
, &np
);
928 case CTDB_CONTROL_DB_SET_HEALTHY
:
929 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
932 case CTDB_CONTROL_DB_GET_HEALTH
:
933 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
936 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
937 ret
= ctdb_sock_addr_pull(buf
, buflen
, mem_ctx
,
938 &cd
->data
.addr
, &np
);
941 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
942 ret
= ctdb_iface_pull(buf
, buflen
, mem_ctx
,
943 &cd
->data
.iface
, &np
);
946 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
947 ret
= ctdb_connection_pull(buf
, buflen
, mem_ctx
,
948 &cd
->data
.conn
, &np
);
951 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
952 ret
= ctdb_key_data_pull(buf
, buflen
, mem_ctx
,
956 case CTDB_CONTROL_SET_DB_READONLY
:
957 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
960 case CTDB_CONTROL_CHECK_SRVIDS
:
963 case CTDB_CONTROL_TRAVERSE_START_EXT
:
964 ret
= ctdb_traverse_start_ext_pull(buf
, buflen
, mem_ctx
,
965 &cd
->data
.traverse_start_ext
,
969 case CTDB_CONTROL_GET_DB_STATISTICS
:
970 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
973 case CTDB_CONTROL_SET_DB_STICKY
:
974 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
977 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
978 ret
= ctdb_traverse_all_ext_pull(buf
, buflen
, mem_ctx
,
979 &cd
->data
.traverse_all_ext
,
983 case CTDB_CONTROL_DB_DETACH
:
984 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
987 case CTDB_CONTROL_DB_FREEZE
:
988 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
991 case CTDB_CONTROL_DB_THAW
:
992 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
995 case CTDB_CONTROL_DB_TRANSACTION_START
:
996 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
997 &cd
->data
.transdb
, &np
);
1000 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
1001 ret
= ctdb_transdb_pull(buf
, buflen
, mem_ctx
,
1002 &cd
->data
.transdb
, &np
);
1005 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
1006 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1009 case CTDB_CONTROL_DB_PULL
:
1010 ret
= ctdb_pulldb_ext_pull(buf
, buflen
, mem_ctx
,
1011 &cd
->data
.pulldb_ext
, &np
);
1014 case CTDB_CONTROL_DB_PUSH_START
:
1015 ret
= ctdb_pulldb_ext_pull(buf
, buflen
, mem_ctx
,
1016 &cd
->data
.pulldb_ext
, &np
);
1019 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1020 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1023 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1024 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1027 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1028 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1029 &cd
->data
.db_name
, &np
);
1032 case CTDB_CONTROL_CHECK_PID_SRVID
:
1033 ret
= ctdb_pid_srvid_pull(buf
, buflen
, mem_ctx
,
1034 &cd
->data
.pid_srvid
, &np
);
1046 static size_t ctdb_reply_control_data_len(struct ctdb_reply_control_data
*cd
)
1054 switch (cd
->opcode
) {
1055 case CTDB_CONTROL_PROCESS_EXISTS
:
1058 case CTDB_CONTROL_STATISTICS
:
1059 len
= ctdb_statistics_len(cd
->data
.stats
);
1062 case CTDB_CONTROL_PING
:
1065 case CTDB_CONTROL_GETDBPATH
:
1066 len
= ctdb_string_len(&cd
->data
.db_path
);
1069 case CTDB_CONTROL_GETVNNMAP
:
1070 len
= ctdb_vnn_map_len(cd
->data
.vnnmap
);
1073 case CTDB_CONTROL_SETVNNMAP
:
1076 case CTDB_CONTROL_GET_DEBUG
:
1077 len
= ctdb_uint32_len(&cd
->data
.loglevel
);
1080 case CTDB_CONTROL_SET_DEBUG
:
1083 case CTDB_CONTROL_GET_DBMAP
:
1084 len
= ctdb_dbid_map_len(cd
->data
.dbmap
);
1087 case CTDB_CONTROL_PULL_DB
:
1088 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
1091 case CTDB_CONTROL_PUSH_DB
:
1094 case CTDB_CONTROL_GET_RECMODE
:
1097 case CTDB_CONTROL_SET_RECMODE
:
1100 case CTDB_CONTROL_STATISTICS_RESET
:
1103 case CTDB_CONTROL_DB_ATTACH
:
1104 len
= ctdb_uint32_len(&cd
->data
.db_id
);
1107 case CTDB_CONTROL_SET_CALL
:
1110 case CTDB_CONTROL_TRAVERSE_START
:
1113 case CTDB_CONTROL_TRAVERSE_ALL
:
1116 case CTDB_CONTROL_TRAVERSE_DATA
:
1119 case CTDB_CONTROL_REGISTER_SRVID
:
1122 case CTDB_CONTROL_DEREGISTER_SRVID
:
1125 case CTDB_CONTROL_GET_DBNAME
:
1126 len
= ctdb_string_len(&cd
->data
.db_name
);
1129 case CTDB_CONTROL_ENABLE_SEQNUM
:
1132 case CTDB_CONTROL_UPDATE_SEQNUM
:
1135 case CTDB_CONTROL_DUMP_MEMORY
:
1136 len
= ctdb_string_len(&cd
->data
.mem_str
);
1139 case CTDB_CONTROL_GET_PID
:
1142 case CTDB_CONTROL_GET_RECMASTER
:
1145 case CTDB_CONTROL_SET_RECMASTER
:
1148 case CTDB_CONTROL_FREEZE
:
1151 case CTDB_CONTROL_GET_PNN
:
1154 case CTDB_CONTROL_SHUTDOWN
:
1157 case CTDB_CONTROL_GET_MONMODE
:
1160 case CTDB_CONTROL_TCP_CLIENT
:
1163 case CTDB_CONTROL_TCP_ADD
:
1166 case CTDB_CONTROL_TCP_REMOVE
:
1169 case CTDB_CONTROL_STARTUP
:
1172 case CTDB_CONTROL_SET_TUNABLE
:
1175 case CTDB_CONTROL_GET_TUNABLE
:
1176 len
= ctdb_uint32_len(&cd
->data
.tun_value
);
1179 case CTDB_CONTROL_LIST_TUNABLES
:
1180 len
= ctdb_var_list_len(cd
->data
.tun_var_list
);
1183 case CTDB_CONTROL_MODIFY_FLAGS
:
1186 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1187 len
= ctdb_tunable_list_len(cd
->data
.tun_list
);
1190 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1191 len
= ctdb_tickle_list_len(cd
->data
.tickles
);
1194 case CTDB_CONTROL_SET_TCP_TICKLE_LIST
:
1197 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1198 len
= ctdb_uint32_len(&cd
->data
.db_id
);
1201 case CTDB_CONTROL_UPDATE_RECORD
:
1204 case CTDB_CONTROL_SEND_GRATUITOUS_ARP
:
1207 case CTDB_CONTROL_WIPE_DATABASE
:
1210 case CTDB_CONTROL_UPTIME
:
1211 len
= ctdb_uptime_len(cd
->data
.uptime
);
1214 case CTDB_CONTROL_START_RECOVERY
:
1217 case CTDB_CONTROL_END_RECOVERY
:
1220 case CTDB_CONTROL_RELOAD_NODES_FILE
:
1223 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1224 len
= ctdb_rec_buffer_len(cd
->data
.recbuf
);
1227 case CTDB_CONTROL_ENABLE_MONITOR
:
1230 case CTDB_CONTROL_DISABLE_MONITOR
:
1233 case CTDB_CONTROL_ADD_PUBLIC_IP
:
1236 case CTDB_CONTROL_DEL_PUBLIC_IP
:
1239 case CTDB_CONTROL_GET_CAPABILITIES
:
1240 len
= ctdb_uint32_len(&cd
->data
.caps
);
1243 case CTDB_CONTROL_RECD_PING
:
1246 case CTDB_CONTROL_RELEASE_IP
:
1249 case CTDB_CONTROL_TAKEOVER_IP
:
1252 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1253 len
= ctdb_public_ip_list_len(cd
->data
.pubip_list
);
1256 case CTDB_CONTROL_GET_NODEMAP
:
1257 len
= ctdb_node_map_len(cd
->data
.nodemap
);
1260 case CTDB_CONTROL_TRAVERSE_KILL
:
1263 case CTDB_CONTROL_RECD_RECLOCK_LATENCY
:
1266 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1267 len
= ctdb_string_len(&cd
->data
.reclock_file
);
1270 case CTDB_CONTROL_STOP_NODE
:
1273 case CTDB_CONTROL_CONTINUE_NODE
:
1276 case CTDB_CONTROL_SET_LMASTERROLE
:
1279 case CTDB_CONTROL_SET_RECMASTERROLE
:
1282 case CTDB_CONTROL_SET_BAN_STATE
:
1285 case CTDB_CONTROL_GET_BAN_STATE
:
1286 len
= ctdb_ban_state_len(cd
->data
.ban_state
);
1289 case CTDB_CONTROL_SET_DB_PRIORITY
:
1292 case CTDB_CONTROL_GET_DB_PRIORITY
:
1295 case CTDB_CONTROL_REGISTER_NOTIFY
:
1298 case CTDB_CONTROL_DEREGISTER_NOTIFY
:
1301 case CTDB_CONTROL_TRANS3_COMMIT
:
1304 case CTDB_CONTROL_GET_DB_SEQNUM
:
1305 len
= ctdb_uint64_len(&cd
->data
.seqnum
);
1308 case CTDB_CONTROL_DB_SET_HEALTHY
:
1311 case CTDB_CONTROL_DB_GET_HEALTH
:
1312 len
= ctdb_string_len(&cd
->data
.reason
);
1315 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1316 len
= ctdb_public_ip_info_len(cd
->data
.ipinfo
);
1319 case CTDB_CONTROL_GET_IFACES
:
1320 len
= ctdb_iface_list_len(cd
->data
.iface_list
);
1323 case CTDB_CONTROL_SET_IFACE_LINK_STATE
:
1326 case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE
:
1329 case CTDB_CONTROL_GET_STAT_HISTORY
:
1330 len
= ctdb_statistics_list_len(cd
->data
.stats_list
);
1333 case CTDB_CONTROL_SCHEDULE_FOR_DELETION
:
1336 case CTDB_CONTROL_SET_DB_READONLY
:
1339 case CTDB_CONTROL_CHECK_SRVIDS
:
1342 case CTDB_CONTROL_TRAVERSE_START_EXT
:
1345 case CTDB_CONTROL_GET_DB_STATISTICS
:
1346 len
= ctdb_db_statistics_len(cd
->data
.dbstats
);
1349 case CTDB_CONTROL_SET_DB_STICKY
:
1352 case CTDB_CONTROL_RELOAD_PUBLIC_IPS
:
1355 case CTDB_CONTROL_TRAVERSE_ALL_EXT
:
1358 case CTDB_CONTROL_IPREALLOCATED
:
1361 case CTDB_CONTROL_GET_RUNSTATE
:
1362 len
= ctdb_uint32_len(&cd
->data
.runstate
);
1365 case CTDB_CONTROL_DB_DETACH
:
1368 case CTDB_CONTROL_GET_NODES_FILE
:
1369 len
= ctdb_node_map_len(cd
->data
.nodemap
);
1372 case CTDB_CONTROL_DB_FREEZE
:
1375 case CTDB_CONTROL_DB_THAW
:
1378 case CTDB_CONTROL_DB_TRANSACTION_START
:
1381 case CTDB_CONTROL_DB_TRANSACTION_COMMIT
:
1384 case CTDB_CONTROL_DB_TRANSACTION_CANCEL
:
1387 case CTDB_CONTROL_DB_PULL
:
1388 len
= ctdb_uint32_len(&cd
->data
.num_records
);
1391 case CTDB_CONTROL_DB_PUSH_START
:
1394 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1395 len
= ctdb_uint32_len(&cd
->data
.num_records
);
1398 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1399 len
= ctdb_int32_len(&cd
->data
.tdb_flags
);
1402 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1403 len
= ctdb_uint32_len(&cd
->data
.db_id
);
1406 case CTDB_CONTROL_CHECK_PID_SRVID
:
1409 case CTDB_CONTROL_TUNNEL_REGISTER
:
1412 case CTDB_CONTROL_TUNNEL_DEREGISTER
:
1419 static void ctdb_reply_control_data_push(struct ctdb_reply_control_data
*cd
,
1420 uint8_t *buf
, size_t *npush
)
1424 switch (cd
->opcode
) {
1425 case CTDB_CONTROL_STATISTICS
:
1426 ctdb_statistics_push(cd
->data
.stats
, buf
, &np
);
1429 case CTDB_CONTROL_GETDBPATH
:
1430 ctdb_string_push(&cd
->data
.db_path
, buf
, &np
);
1433 case CTDB_CONTROL_GETVNNMAP
:
1434 ctdb_vnn_map_push(cd
->data
.vnnmap
, buf
, &np
);
1437 case CTDB_CONTROL_GET_DEBUG
:
1438 ctdb_uint32_push(&cd
->data
.loglevel
, buf
, &np
);
1441 case CTDB_CONTROL_GET_DBMAP
:
1442 ctdb_dbid_map_push(cd
->data
.dbmap
, buf
, &np
);
1445 case CTDB_CONTROL_PULL_DB
:
1446 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
1449 case CTDB_CONTROL_PUSH_DB
:
1452 case CTDB_CONTROL_DB_ATTACH
:
1453 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
1456 case CTDB_CONTROL_GET_DBNAME
:
1457 ctdb_string_push(&cd
->data
.db_name
, buf
, &np
);
1460 case CTDB_CONTROL_DUMP_MEMORY
:
1461 ctdb_string_push(&cd
->data
.mem_str
, buf
, &np
);
1464 case CTDB_CONTROL_GET_PID
:
1467 case CTDB_CONTROL_GET_RECMASTER
:
1470 case CTDB_CONTROL_GET_TUNABLE
:
1471 ctdb_uint32_push(&cd
->data
.tun_value
, buf
, &np
);
1474 case CTDB_CONTROL_LIST_TUNABLES
:
1475 ctdb_var_list_push(cd
->data
.tun_var_list
, buf
, &np
);
1478 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1479 ctdb_tunable_list_push(cd
->data
.tun_list
, buf
, &np
);
1482 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1483 ctdb_tickle_list_push(cd
->data
.tickles
, buf
, &np
);
1486 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1487 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
1490 case CTDB_CONTROL_UPTIME
:
1491 ctdb_uptime_push(cd
->data
.uptime
, buf
, &np
);
1494 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1495 ctdb_rec_buffer_push(cd
->data
.recbuf
, buf
, &np
);
1498 case CTDB_CONTROL_GET_CAPABILITIES
:
1499 ctdb_uint32_push(&cd
->data
.caps
, buf
, &np
);
1502 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1503 ctdb_public_ip_list_push(cd
->data
.pubip_list
, buf
, &np
);
1506 case CTDB_CONTROL_GET_NODEMAP
:
1507 ctdb_node_map_push(cd
->data
.nodemap
, buf
, &np
);
1510 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1511 ctdb_string_push(&cd
->data
.reclock_file
, buf
, &np
);
1514 case CTDB_CONTROL_GET_BAN_STATE
:
1515 ctdb_ban_state_push(cd
->data
.ban_state
, buf
, &np
);
1518 case CTDB_CONTROL_GET_DB_PRIORITY
:
1521 case CTDB_CONTROL_GET_DB_SEQNUM
:
1522 ctdb_uint64_push(&cd
->data
.seqnum
, buf
, &np
);
1525 case CTDB_CONTROL_DB_GET_HEALTH
:
1526 ctdb_string_push(&cd
->data
.reason
, buf
, &np
);
1529 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1530 ctdb_public_ip_info_push(cd
->data
.ipinfo
, buf
, &np
);
1533 case CTDB_CONTROL_GET_IFACES
:
1534 ctdb_iface_list_push(cd
->data
.iface_list
, buf
, &np
);
1537 case CTDB_CONTROL_GET_STAT_HISTORY
:
1538 ctdb_statistics_list_push(cd
->data
.stats_list
, buf
, &np
);
1541 case CTDB_CONTROL_CHECK_SRVIDS
:
1544 case CTDB_CONTROL_GET_DB_STATISTICS
:
1545 ctdb_db_statistics_push(cd
->data
.dbstats
, buf
, &np
);
1548 case CTDB_CONTROL_GET_RUNSTATE
:
1549 ctdb_uint32_push(&cd
->data
.runstate
, buf
, &np
);
1552 case CTDB_CONTROL_GET_NODES_FILE
:
1553 ctdb_node_map_push(cd
->data
.nodemap
, buf
, &np
);
1556 case CTDB_CONTROL_DB_PULL
:
1557 ctdb_uint32_push(&cd
->data
.num_records
, buf
, &np
);
1560 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1561 ctdb_uint32_push(&cd
->data
.num_records
, buf
, &np
);
1564 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1565 ctdb_int32_push(&cd
->data
.tdb_flags
, buf
, &np
);
1568 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1569 ctdb_uint32_push(&cd
->data
.db_id
, buf
, &np
);
1572 case CTDB_CONTROL_CHECK_PID_SRVID
:
1579 static int ctdb_reply_control_data_pull(uint8_t *buf
, size_t buflen
,
1580 uint32_t opcode
, TALLOC_CTX
*mem_ctx
,
1581 struct ctdb_reply_control_data
*cd
,
1587 cd
->opcode
= opcode
;
1590 case CTDB_CONTROL_STATISTICS
:
1591 ret
= ctdb_statistics_pull(buf
, buflen
, mem_ctx
,
1592 &cd
->data
.stats
, &np
);
1595 case CTDB_CONTROL_GETDBPATH
:
1596 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1597 &cd
->data
.db_path
, &np
);
1600 case CTDB_CONTROL_GETVNNMAP
:
1601 ret
= ctdb_vnn_map_pull(buf
, buflen
, mem_ctx
,
1602 &cd
->data
.vnnmap
, &np
);
1605 case CTDB_CONTROL_GET_DEBUG
:
1606 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.loglevel
, &np
);
1609 case CTDB_CONTROL_GET_DBMAP
:
1610 ret
= ctdb_dbid_map_pull(buf
, buflen
, mem_ctx
,
1611 &cd
->data
.dbmap
, &np
);
1614 case CTDB_CONTROL_PULL_DB
:
1615 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
1616 &cd
->data
.recbuf
, &np
);
1619 case CTDB_CONTROL_PUSH_DB
:
1622 case CTDB_CONTROL_DB_ATTACH
:
1623 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1626 case CTDB_CONTROL_GET_DBNAME
:
1627 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1628 &cd
->data
.db_name
, &np
);
1631 case CTDB_CONTROL_DUMP_MEMORY
:
1632 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1633 &cd
->data
.mem_str
, &np
);
1636 case CTDB_CONTROL_GET_PID
:
1639 case CTDB_CONTROL_GET_RECMASTER
:
1642 case CTDB_CONTROL_GET_TUNABLE
:
1643 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.tun_value
,
1647 case CTDB_CONTROL_LIST_TUNABLES
:
1648 ret
= ctdb_var_list_pull(buf
, buflen
, mem_ctx
,
1649 &cd
->data
.tun_var_list
, &np
);
1652 case CTDB_CONTROL_GET_ALL_TUNABLES
:
1653 ret
= ctdb_tunable_list_pull(buf
, buflen
, mem_ctx
,
1654 &cd
->data
.tun_list
, &np
);
1657 case CTDB_CONTROL_GET_TCP_TICKLE_LIST
:
1658 ret
= ctdb_tickle_list_pull(buf
, buflen
, mem_ctx
,
1659 &cd
->data
.tickles
, &np
);
1662 case CTDB_CONTROL_DB_ATTACH_PERSISTENT
:
1663 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1666 case CTDB_CONTROL_UPTIME
:
1667 ret
= ctdb_uptime_pull(buf
, buflen
, mem_ctx
,
1668 &cd
->data
.uptime
, &np
);
1671 case CTDB_CONTROL_TRY_DELETE_RECORDS
:
1672 ret
= ctdb_rec_buffer_pull(buf
, buflen
, mem_ctx
,
1673 &cd
->data
.recbuf
, &np
);
1676 case CTDB_CONTROL_GET_CAPABILITIES
:
1677 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.caps
, &np
);
1680 case CTDB_CONTROL_GET_PUBLIC_IPS
:
1681 ret
= ctdb_public_ip_list_pull(buf
, buflen
, mem_ctx
,
1682 &cd
->data
.pubip_list
, &np
);
1685 case CTDB_CONTROL_GET_NODEMAP
:
1686 ret
= ctdb_node_map_pull(buf
, buflen
, mem_ctx
,
1687 &cd
->data
.nodemap
, &np
);
1690 case CTDB_CONTROL_GET_RECLOCK_FILE
:
1691 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1692 &cd
->data
.reclock_file
, &np
);
1695 case CTDB_CONTROL_GET_BAN_STATE
:
1696 ret
= ctdb_ban_state_pull(buf
, buflen
, mem_ctx
,
1697 &cd
->data
.ban_state
, &np
);
1700 case CTDB_CONTROL_GET_DB_PRIORITY
:
1703 case CTDB_CONTROL_GET_DB_SEQNUM
:
1704 ret
= ctdb_uint64_pull(buf
, buflen
, &cd
->data
.seqnum
, &np
);
1707 case CTDB_CONTROL_DB_GET_HEALTH
:
1708 ret
= ctdb_string_pull(buf
, buflen
, mem_ctx
,
1709 &cd
->data
.reason
, &np
);
1712 case CTDB_CONTROL_GET_PUBLIC_IP_INFO
:
1713 ret
= ctdb_public_ip_info_pull(buf
, buflen
, mem_ctx
,
1714 &cd
->data
.ipinfo
, &np
);
1717 case CTDB_CONTROL_GET_IFACES
:
1718 ret
= ctdb_iface_list_pull(buf
, buflen
, mem_ctx
,
1719 &cd
->data
.iface_list
, &np
);
1722 case CTDB_CONTROL_GET_STAT_HISTORY
:
1723 ret
= ctdb_statistics_list_pull(buf
, buflen
, mem_ctx
,
1724 &cd
->data
.stats_list
, &np
);
1727 case CTDB_CONTROL_CHECK_SRVIDS
:
1730 case CTDB_CONTROL_GET_DB_STATISTICS
:
1731 ret
= ctdb_db_statistics_pull(buf
, buflen
, mem_ctx
,
1732 &cd
->data
.dbstats
, &np
);
1735 case CTDB_CONTROL_GET_RUNSTATE
:
1736 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.runstate
, &np
);
1739 case CTDB_CONTROL_GET_NODES_FILE
:
1740 ret
= ctdb_node_map_pull(buf
, buflen
, mem_ctx
,
1741 &cd
->data
.nodemap
, &np
);
1744 case CTDB_CONTROL_DB_PULL
:
1745 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.num_records
,
1749 case CTDB_CONTROL_DB_PUSH_CONFIRM
:
1750 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.num_records
,
1754 case CTDB_CONTROL_DB_OPEN_FLAGS
:
1755 ret
= ctdb_int32_pull(buf
, buflen
, &cd
->data
.tdb_flags
, &np
);
1758 case CTDB_CONTROL_DB_ATTACH_REPLICATED
:
1759 ret
= ctdb_uint32_pull(buf
, buflen
, &cd
->data
.db_id
, &np
);
1762 case CTDB_CONTROL_CHECK_PID_SRVID
:
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
,