2015-04-14 10:20:05 +03:00
/*
CTDB protocol marshalling
Copyright ( C ) Amitay Isaacs 2015
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 3 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , see < http : //www.gnu.org/licenses/>.
*/
# include "replace.h"
# include "system/network.h"
# include <talloc.h>
# include <tdb.h>
# include "protocol.h"
# include "protocol_api.h"
# include "protocol_private.h"
static size_t ctdb_req_control_data_len ( struct ctdb_req_control_data * cd )
{
size_t len = 0 ;
2017-06-29 15:14:23 +03:00
uint32_t u32 ;
2015-04-14 10:20:05 +03:00
if ( cd = = NULL ) {
return 0 ;
}
switch ( cd - > opcode ) {
case CTDB_CONTROL_PROCESS_EXISTS :
2017-06-29 15:18:27 +03:00
len = ctdb_pid_len ( & cd - > data . pid ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_STATISTICS :
break ;
case CTDB_CONTROL_PING :
break ;
case CTDB_CONTROL_GETDBPATH :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GETVNNMAP :
break ;
case CTDB_CONTROL_SETVNNMAP :
len = ctdb_vnn_map_len ( cd - > data . vnnmap ) ;
break ;
case CTDB_CONTROL_GET_DEBUG :
break ;
case CTDB_CONTROL_SET_DEBUG :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . loglevel ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DBMAP :
break ;
case CTDB_CONTROL_GET_RECMODE :
break ;
case CTDB_CONTROL_SET_RECMODE :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . recmode ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_STATISTICS_RESET :
break ;
case CTDB_CONTROL_DB_ATTACH :
2017-06-29 11:48:51 +03:00
len = ctdb_string_len ( & cd - > data . db_name ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_START :
len = ctdb_traverse_start_len ( cd - > data . traverse_start ) ;
break ;
case CTDB_CONTROL_TRAVERSE_ALL :
len = ctdb_traverse_all_len ( cd - > data . traverse_all ) ;
break ;
case CTDB_CONTROL_TRAVERSE_DATA :
len = ctdb_rec_data_len ( cd - > data . rec_data ) ;
break ;
case CTDB_CONTROL_REGISTER_SRVID :
break ;
case CTDB_CONTROL_DEREGISTER_SRVID :
break ;
case CTDB_CONTROL_GET_DBNAME :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_ENABLE_SEQNUM :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_UPDATE_SEQNUM :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DUMP_MEMORY :
break ;
case CTDB_CONTROL_GET_PID :
break ;
case CTDB_CONTROL_FREEZE :
break ;
case CTDB_CONTROL_GET_PNN :
break ;
case CTDB_CONTROL_SHUTDOWN :
break ;
case CTDB_CONTROL_TCP_CLIENT :
len = ctdb_connection_len ( cd - > data . conn ) ;
break ;
case CTDB_CONTROL_TCP_ADD :
len = ctdb_connection_len ( cd - > data . conn ) ;
break ;
case CTDB_CONTROL_TCP_REMOVE :
len = ctdb_connection_len ( cd - > data . conn ) ;
break ;
case CTDB_CONTROL_STARTUP :
break ;
case CTDB_CONTROL_SET_TUNABLE :
len = ctdb_tunable_len ( cd - > data . tunable ) ;
break ;
case CTDB_CONTROL_GET_TUNABLE :
2017-04-20 05:45:24 +03:00
len = ctdb_stringn_len ( & cd - > data . tun_var ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_LIST_TUNABLES :
break ;
case CTDB_CONTROL_MODIFY_FLAGS :
len = ctdb_node_flag_change_len ( cd - > data . flag_change ) ;
break ;
case CTDB_CONTROL_GET_ALL_TUNABLES :
break ;
case CTDB_CONTROL_GET_TCP_TICKLE_LIST :
len = ctdb_sock_addr_len ( cd - > data . addr ) ;
break ;
case CTDB_CONTROL_SET_TCP_TICKLE_LIST :
len = ctdb_tickle_list_len ( cd - > data . tickles ) ;
break ;
case CTDB_CONTROL_DB_ATTACH_PERSISTENT :
2017-06-29 11:48:51 +03:00
len = ctdb_string_len ( & cd - > data . db_name ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_UPDATE_RECORD :
len = ctdb_rec_buffer_len ( cd - > data . recbuf ) ;
break ;
case CTDB_CONTROL_SEND_GRATUITOUS_ARP :
len = ctdb_addr_info_len ( cd - > data . addr_info ) ;
break ;
case CTDB_CONTROL_WIPE_DATABASE :
len = ctdb_transdb_len ( cd - > data . transdb ) ;
break ;
case CTDB_CONTROL_UPTIME :
break ;
case CTDB_CONTROL_START_RECOVERY :
break ;
case CTDB_CONTROL_END_RECOVERY :
break ;
case CTDB_CONTROL_RELOAD_NODES_FILE :
break ;
case CTDB_CONTROL_TRY_DELETE_RECORDS :
len = ctdb_rec_buffer_len ( cd - > data . recbuf ) ;
break ;
case CTDB_CONTROL_ADD_PUBLIC_IP :
len = ctdb_addr_info_len ( cd - > data . addr_info ) ;
break ;
case CTDB_CONTROL_DEL_PUBLIC_IP :
len = ctdb_addr_info_len ( cd - > data . addr_info ) ;
break ;
case CTDB_CONTROL_GET_CAPABILITIES :
break ;
case CTDB_CONTROL_RECD_PING :
break ;
case CTDB_CONTROL_RELEASE_IP :
len = ctdb_public_ip_len ( cd - > data . pubip ) ;
break ;
case CTDB_CONTROL_TAKEOVER_IP :
len = ctdb_public_ip_len ( cd - > data . pubip ) ;
break ;
case CTDB_CONTROL_GET_PUBLIC_IPS :
break ;
case CTDB_CONTROL_GET_NODEMAP :
break ;
case CTDB_CONTROL_TRAVERSE_KILL :
len = ctdb_traverse_start_len ( cd - > data . traverse_start ) ;
break ;
case CTDB_CONTROL_RECD_RECLOCK_LATENCY :
2017-06-29 15:16:56 +03:00
len = ctdb_double_len ( & cd - > data . reclock_latency ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_RECLOCK_FILE :
break ;
case CTDB_CONTROL_STOP_NODE :
break ;
case CTDB_CONTROL_CONTINUE_NODE :
break ;
case CTDB_CONTROL_SET_LMASTERROLE :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . role ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_RECMASTERROLE :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . role ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_BAN_STATE :
len = ctdb_ban_state_len ( cd - > data . ban_state ) ;
break ;
case CTDB_CONTROL_GET_BAN_STATE :
break ;
case CTDB_CONTROL_REGISTER_NOTIFY :
len = ctdb_notify_data_len ( cd - > data . notify ) ;
break ;
case CTDB_CONTROL_DEREGISTER_NOTIFY :
2017-06-29 15:15:43 +03:00
len = ctdb_uint64_len ( & cd - > data . srvid ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRANS3_COMMIT :
len = ctdb_rec_buffer_len ( cd - > data . recbuf ) ;
break ;
case CTDB_CONTROL_GET_DB_SEQNUM :
2017-06-29 15:14:23 +03:00
u32 = 0 ;
len = ctdb_uint32_len ( & cd - > data . db_id ) + ctdb_uint32_len ( & u32 ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_SET_HEALTHY :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_GET_HEALTH :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PUBLIC_IP_INFO :
len = ctdb_sock_addr_len ( cd - > data . addr ) ;
break ;
case CTDB_CONTROL_GET_IFACES :
break ;
case CTDB_CONTROL_SET_IFACE_LINK_STATE :
len = ctdb_iface_len ( cd - > data . iface ) ;
break ;
case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE :
len = ctdb_connection_len ( cd - > data . conn ) ;
break ;
case CTDB_CONTROL_GET_STAT_HISTORY :
break ;
case CTDB_CONTROL_SCHEDULE_FOR_DELETION :
len = ctdb_key_data_len ( cd - > data . key ) ;
break ;
case CTDB_CONTROL_SET_DB_READONLY :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_START_EXT :
len = ctdb_traverse_start_ext_len ( cd - > data . traverse_start_ext ) ;
break ;
case CTDB_CONTROL_GET_DB_STATISTICS :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_DB_STICKY :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_RELOAD_PUBLIC_IPS :
break ;
case CTDB_CONTROL_TRAVERSE_ALL_EXT :
len = ctdb_traverse_all_ext_len ( cd - > data . traverse_all_ext ) ;
break ;
case CTDB_CONTROL_IPREALLOCATED :
break ;
case CTDB_CONTROL_GET_RUNSTATE :
break ;
case CTDB_CONTROL_DB_DETACH :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_NODES_FILE :
break ;
2015-07-31 18:47:22 +03:00
case CTDB_CONTROL_DB_FREEZE :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_THAW :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_TRANSACTION_START :
len = ctdb_transdb_len ( cd - > data . transdb ) ;
break ;
case CTDB_CONTROL_DB_TRANSACTION_COMMIT :
len = ctdb_transdb_len ( cd - > data . transdb ) ;
break ;
case CTDB_CONTROL_DB_TRANSACTION_CANCEL :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-07-31 18:47:22 +03:00
break ;
2016-02-19 02:54:15 +03:00
case CTDB_CONTROL_DB_PULL :
len = ctdb_pulldb_ext_len ( cd - > data . pulldb_ext ) ;
break ;
case CTDB_CONTROL_DB_PUSH_START :
len = ctdb_pulldb_ext_len ( cd - > data . pulldb_ext ) ;
break ;
case CTDB_CONTROL_DB_PUSH_CONFIRM :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2016-02-19 02:54:15 +03:00
break ;
2017-06-14 09:24:02 +03:00
case CTDB_CONTROL_DB_OPEN_FLAGS :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2017-06-14 09:24:02 +03:00
break ;
2017-03-02 09:07:13 +03:00
case CTDB_CONTROL_DB_ATTACH_REPLICATED :
2017-06-29 11:48:51 +03:00
len = ctdb_string_len ( & cd - > data . db_name ) ;
2017-03-02 09:07:13 +03:00
break ;
2017-08-30 08:13:53 +03:00
case CTDB_CONTROL_CHECK_PID_SRVID :
len = ctdb_pid_srvid_len ( cd - > data . pid_srvid ) ;
break ;
2017-04-06 11:58:01 +03:00
case CTDB_CONTROL_TUNNEL_REGISTER :
break ;
case CTDB_CONTROL_TUNNEL_DEREGISTER :
break ;
2018-02-15 03:57:44 +03:00
case CTDB_CONTROL_VACUUM_FETCH :
len = ctdb_rec_buffer_len ( cd - > data . recbuf ) ;
break ;
2019-07-30 03:52:05 +03:00
case CTDB_CONTROL_DB_VACUUM :
len = ctdb_db_vacuum_len ( cd - > data . db_vacuum ) ;
break ;
2020-04-07 18:26:26 +03:00
case CTDB_CONTROL_ECHO_DATA :
len = ctdb_echo_data_len ( cd - > data . echo_data ) ;
break ;
2021-07-09 05:10:12 +03:00
case CTDB_CONTROL_DISABLE_NODE :
break ;
case CTDB_CONTROL_ENABLE_NODE :
break ;
2023-11-15 18:31:53 +03:00
case CTDB_CONTROL_TCP_CLIENT_DISCONNECTED :
len = ctdb_connection_len ( cd - > data . conn ) ;
break ;
2023-11-17 17:59:57 +03:00
case CTDB_CONTROL_TCP_CLIENT_PASSED :
len = ctdb_connection_len ( cd - > data . conn ) ;
break ;
2023-10-25 12:14:24 +03:00
case CTDB_CONTROL_START_IPREALLOCATE :
break ;
2015-04-14 10:20:05 +03:00
}
return len ;
}
static void ctdb_req_control_data_push ( struct ctdb_req_control_data * cd ,
2017-07-26 19:20:03 +03:00
uint8_t * buf , size_t * npush )
2015-04-14 10:20:05 +03:00
{
2017-07-26 19:20:03 +03:00
size_t np = 0 , offset ;
2017-06-29 15:14:23 +03:00
uint32_t u32 ;
2015-04-14 10:20:05 +03:00
switch ( cd - > opcode ) {
case CTDB_CONTROL_PROCESS_EXISTS :
2017-06-29 15:18:27 +03:00
ctdb_pid_push ( & cd - > data . pid , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GETDBPATH :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SETVNNMAP :
2017-06-29 12:04:56 +03:00
ctdb_vnn_map_push ( cd - > data . vnnmap , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_DEBUG :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . loglevel , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_RECMODE :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . recmode , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_ATTACH :
2017-06-29 11:48:51 +03:00
ctdb_string_push ( & cd - > data . db_name , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_START :
2017-06-29 16:48:01 +03:00
ctdb_traverse_start_push ( cd - > data . traverse_start , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_ALL :
2017-06-29 16:56:02 +03:00
ctdb_traverse_all_push ( cd - > data . traverse_all , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_DATA :
2017-06-29 16:27:33 +03:00
ctdb_rec_data_push ( cd - > data . rec_data , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DBNAME :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_ENABLE_SEQNUM :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_UPDATE_SEQNUM :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TCP_CLIENT :
2017-06-29 17:31:21 +03:00
ctdb_connection_push ( cd - > data . conn , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TCP_ADD :
2017-06-29 17:31:21 +03:00
ctdb_connection_push ( cd - > data . conn , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TCP_REMOVE :
2017-06-29 17:31:21 +03:00
ctdb_connection_push ( cd - > data . conn , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_TUNABLE :
2017-06-29 17:36:18 +03:00
ctdb_tunable_push ( cd - > data . tunable , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_TUNABLE :
2017-04-20 05:45:24 +03:00
ctdb_stringn_push ( & cd - > data . tun_var , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_MODIFY_FLAGS :
2017-06-29 17:42:53 +03:00
ctdb_node_flag_change_push ( cd - > data . flag_change , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_TCP_TICKLE_LIST :
2017-07-18 10:12:37 +03:00
ctdb_sock_addr_push ( cd - > data . addr , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_TCP_TICKLE_LIST :
2017-07-04 10:56:12 +03:00
ctdb_tickle_list_push ( cd - > data . tickles , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_ATTACH_PERSISTENT :
2017-06-29 11:48:51 +03:00
ctdb_string_push ( & cd - > data . db_name , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_UPDATE_RECORD :
2017-06-29 16:41:08 +03:00
ctdb_rec_buffer_push ( cd - > data . recbuf , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SEND_GRATUITOUS_ARP :
2017-07-04 11:12:04 +03:00
ctdb_addr_info_push ( cd - > data . addr_info , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_WIPE_DATABASE :
2017-07-05 10:51:03 +03:00
ctdb_transdb_push ( cd - > data . transdb , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRY_DELETE_RECORDS :
2017-06-29 16:41:08 +03:00
ctdb_rec_buffer_push ( cd - > data . recbuf , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_ADD_PUBLIC_IP :
2017-07-04 11:12:04 +03:00
ctdb_addr_info_push ( cd - > data . addr_info , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DEL_PUBLIC_IP :
2017-07-04 11:12:04 +03:00
ctdb_addr_info_push ( cd - > data . addr_info , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_RELEASE_IP :
2017-07-06 07:04:51 +03:00
ctdb_public_ip_push ( cd - > data . pubip , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TAKEOVER_IP :
2017-07-06 07:04:51 +03:00
ctdb_public_ip_push ( cd - > data . pubip , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_KILL :
2017-06-29 16:48:01 +03:00
ctdb_traverse_start_push ( cd - > data . traverse_start , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_RECD_RECLOCK_LATENCY :
2017-06-29 15:16:56 +03:00
ctdb_double_push ( & cd - > data . reclock_latency , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_LMASTERROLE :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . role , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_RECMASTERROLE :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . role , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_BAN_STATE :
2017-07-12 11:24:34 +03:00
ctdb_ban_state_push ( cd - > data . ban_state , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_REGISTER_NOTIFY :
2017-07-12 11:29:12 +03:00
ctdb_notify_data_push ( cd - > data . notify , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DEREGISTER_NOTIFY :
2017-06-29 15:15:43 +03:00
ctdb_uint64_push ( & cd - > data . srvid , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRANS3_COMMIT :
2017-06-29 16:41:08 +03:00
ctdb_rec_buffer_push ( cd - > data . recbuf , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DB_SEQNUM :
2017-06-29 15:14:23 +03:00
u32 = 0 ;
offset = 0 ;
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
offset + = np ;
ctdb_uint32_push ( & u32 , buf + offset , & np ) ;
offset + = np ;
np = offset ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_SET_HEALTHY :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_GET_HEALTH :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PUBLIC_IP_INFO :
2017-07-18 10:12:37 +03:00
ctdb_sock_addr_push ( cd - > data . addr , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_IFACE_LINK_STATE :
2017-07-12 11:38:19 +03:00
ctdb_iface_push ( cd - > data . iface , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE :
2017-06-29 17:31:21 +03:00
ctdb_connection_push ( cd - > data . conn , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SCHEDULE_FOR_DELETION :
2017-07-12 12:05:13 +03:00
ctdb_key_data_push ( cd - > data . key , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_DB_READONLY :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_START_EXT :
2017-06-29 17:16:58 +03:00
ctdb_traverse_start_ext_push ( cd - > data . traverse_start_ext , buf ,
& np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DB_STATISTICS :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_DB_STICKY :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_ALL_EXT :
2017-06-29 17:24:40 +03:00
ctdb_traverse_all_ext_push ( cd - > data . traverse_all_ext , buf ,
& np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_DETACH :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
2015-07-31 18:47:22 +03:00
case CTDB_CONTROL_DB_FREEZE :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_THAW :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_TRANSACTION_START :
2017-07-05 10:51:03 +03:00
ctdb_transdb_push ( cd - > data . transdb , buf , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_TRANSACTION_COMMIT :
2017-07-05 10:51:03 +03:00
ctdb_transdb_push ( cd - > data . transdb , buf , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_TRANSACTION_CANCEL :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
2016-02-19 02:54:15 +03:00
case CTDB_CONTROL_DB_PULL :
2017-06-29 12:55:15 +03:00
ctdb_pulldb_ext_push ( cd - > data . pulldb_ext , buf , & np ) ;
2016-02-19 02:54:15 +03:00
break ;
case CTDB_CONTROL_DB_PUSH_START :
2017-06-29 12:55:15 +03:00
ctdb_pulldb_ext_push ( cd - > data . pulldb_ext , buf , & np ) ;
2016-02-19 02:54:15 +03:00
break ;
case CTDB_CONTROL_DB_PUSH_CONFIRM :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2016-02-19 02:54:15 +03:00
break ;
2017-06-14 09:24:02 +03:00
case CTDB_CONTROL_DB_OPEN_FLAGS :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2017-06-14 09:24:02 +03:00
break ;
2017-03-02 09:07:13 +03:00
case CTDB_CONTROL_DB_ATTACH_REPLICATED :
2017-06-29 11:48:51 +03:00
ctdb_string_push ( & cd - > data . db_name , buf , & np ) ;
2017-03-02 09:07:13 +03:00
break ;
2017-08-30 08:13:53 +03:00
case CTDB_CONTROL_CHECK_PID_SRVID :
ctdb_pid_srvid_push ( cd - > data . pid_srvid , buf , & np ) ;
break ;
2018-02-15 03:57:44 +03:00
case CTDB_CONTROL_VACUUM_FETCH :
ctdb_rec_buffer_push ( cd - > data . recbuf , buf , & np ) ;
break ;
2019-07-30 03:52:05 +03:00
case CTDB_CONTROL_DB_VACUUM :
ctdb_db_vacuum_push ( cd - > data . db_vacuum , buf , & np ) ;
break ;
2020-04-07 18:26:26 +03:00
case CTDB_CONTROL_ECHO_DATA :
ctdb_echo_data_push ( cd - > data . echo_data , buf , & np ) ;
break ;
2024-02-09 09:29:46 +03:00
case CTDB_CONTROL_TCP_CLIENT_DISCONNECTED :
ctdb_connection_push ( cd - > data . conn , buf , & np ) ;
break ;
case CTDB_CONTROL_TCP_CLIENT_PASSED :
ctdb_connection_push ( cd - > data . conn , buf , & np ) ;
break ;
2015-04-14 10:20:05 +03:00
}
2017-07-26 19:20:03 +03:00
* npush = np ;
2015-04-14 10:20:05 +03:00
}
static int ctdb_req_control_data_pull ( uint8_t * buf , size_t buflen ,
uint32_t opcode ,
TALLOC_CTX * mem_ctx ,
2017-07-26 19:20:03 +03:00
struct ctdb_req_control_data * cd ,
size_t * npull )
2015-04-14 10:20:05 +03:00
{
2017-07-26 19:20:03 +03:00
size_t np = 0 , offset ;
2017-07-26 18:15:34 +03:00
uint32_t u32 ;
2015-04-14 10:20:05 +03:00
int ret = 0 ;
cd - > opcode = opcode ;
switch ( opcode ) {
case CTDB_CONTROL_PROCESS_EXISTS :
2017-06-29 15:18:27 +03:00
ret = ctdb_pid_pull ( buf , buflen , & cd - > data . pid , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GETDBPATH :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SETVNNMAP :
ret = ctdb_vnn_map_pull ( buf , buflen , mem_ctx ,
2017-06-29 12:04:56 +03:00
& cd - > data . vnnmap , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_DEBUG :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . loglevel , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_RECMODE :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . recmode , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_ATTACH :
ret = ctdb_string_pull ( buf , buflen , mem_ctx ,
2017-06-29 11:48:51 +03:00
& cd - > data . db_name , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_START :
ret = ctdb_traverse_start_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:48:01 +03:00
& cd - > data . traverse_start , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_ALL :
ret = ctdb_traverse_all_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:56:02 +03:00
& cd - > data . traverse_all , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_DATA :
ret = ctdb_rec_data_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:27:33 +03:00
& cd - > data . rec_data , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DBNAME :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_ENABLE_SEQNUM :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_UPDATE_SEQNUM :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TCP_CLIENT :
ret = ctdb_connection_pull ( buf , buflen , mem_ctx ,
2017-06-29 17:31:21 +03:00
& cd - > data . conn , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TCP_ADD :
ret = ctdb_connection_pull ( buf , buflen , mem_ctx ,
2017-06-29 17:31:21 +03:00
& cd - > data . conn , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TCP_REMOVE :
ret = ctdb_connection_pull ( buf , buflen , mem_ctx ,
2017-06-29 17:31:21 +03:00
& cd - > data . conn , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_TUNABLE :
ret = ctdb_tunable_pull ( buf , buflen , mem_ctx ,
2017-06-29 17:36:18 +03:00
& cd - > data . tunable , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_TUNABLE :
ret = ctdb_stringn_pull ( buf , buflen , mem_ctx ,
2017-04-20 05:45:24 +03:00
& cd - > data . tun_var , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_MODIFY_FLAGS :
ret = ctdb_node_flag_change_pull ( buf , buflen , mem_ctx ,
2017-06-29 17:42:53 +03:00
& cd - > data . flag_change , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_TCP_TICKLE_LIST :
ret = ctdb_sock_addr_pull ( buf , buflen , mem_ctx ,
2017-07-18 10:12:37 +03:00
& cd - > data . addr , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_TCP_TICKLE_LIST :
ret = ctdb_tickle_list_pull ( buf , buflen , mem_ctx ,
2017-07-04 10:56:12 +03:00
& cd - > data . tickles , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_ATTACH_PERSISTENT :
ret = ctdb_string_pull ( buf , buflen , mem_ctx ,
2017-06-29 11:48:51 +03:00
& cd - > data . db_name , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_UPDATE_RECORD :
ret = ctdb_rec_buffer_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:41:08 +03:00
& cd - > data . recbuf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SEND_GRATUITOUS_ARP :
ret = ctdb_addr_info_pull ( buf , buflen , mem_ctx ,
2017-07-04 11:12:04 +03:00
& cd - > data . addr_info , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_WIPE_DATABASE :
ret = ctdb_transdb_pull ( buf , buflen , mem_ctx ,
2017-07-05 10:51:03 +03:00
& cd - > data . transdb , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRY_DELETE_RECORDS :
ret = ctdb_rec_buffer_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:41:08 +03:00
& cd - > data . recbuf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_ADD_PUBLIC_IP :
ret = ctdb_addr_info_pull ( buf , buflen , mem_ctx ,
2017-07-04 11:12:04 +03:00
& cd - > data . addr_info , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DEL_PUBLIC_IP :
ret = ctdb_addr_info_pull ( buf , buflen , mem_ctx ,
2017-07-04 11:12:04 +03:00
& cd - > data . addr_info , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_RELEASE_IP :
ret = ctdb_public_ip_pull ( buf , buflen , mem_ctx ,
2017-07-06 07:04:51 +03:00
& cd - > data . pubip , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TAKEOVER_IP :
ret = ctdb_public_ip_pull ( buf , buflen , mem_ctx ,
2017-07-06 07:04:51 +03:00
& cd - > data . pubip , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_KILL :
ret = ctdb_traverse_start_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:48:01 +03:00
& cd - > data . traverse_start , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_RECD_RECLOCK_LATENCY :
2017-06-29 15:16:56 +03:00
ret = ctdb_double_pull ( buf , buflen , & cd - > data . reclock_latency ,
& np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_LMASTERROLE :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . role , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_RECMASTERROLE :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . role , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_BAN_STATE :
ret = ctdb_ban_state_pull ( buf , buflen , mem_ctx ,
2017-07-12 11:24:34 +03:00
& cd - > data . ban_state , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_REGISTER_NOTIFY :
ret = ctdb_notify_data_pull ( buf , buflen , mem_ctx ,
2017-07-12 11:29:12 +03:00
& cd - > data . notify , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DEREGISTER_NOTIFY :
2017-09-05 09:33:58 +03:00
ret = ctdb_uint64_pull ( buf , buflen , & cd - > data . srvid , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRANS3_COMMIT :
ret = ctdb_rec_buffer_pull ( buf , buflen , mem_ctx ,
2017-06-29 16:41:08 +03:00
& cd - > data . recbuf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DB_SEQNUM :
2017-06-29 15:14:23 +03:00
offset = 0 ;
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2017-07-26 18:15:34 +03:00
if ( ret ! = 0 ) {
break ;
}
2017-06-29 15:14:23 +03:00
offset + = np ;
ret = ctdb_uint32_pull ( buf + offset , buflen - offset , & u32 , & np ) ;
offset + = np ;
np = offset ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_SET_HEALTHY :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_GET_HEALTH :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PUBLIC_IP_INFO :
ret = ctdb_sock_addr_pull ( buf , buflen , mem_ctx ,
2017-07-18 10:12:37 +03:00
& cd - > data . addr , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_IFACE_LINK_STATE :
ret = ctdb_iface_pull ( buf , buflen , mem_ctx ,
2017-07-12 11:38:19 +03:00
& cd - > data . iface , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE :
ret = ctdb_connection_pull ( buf , buflen , mem_ctx ,
2017-06-29 17:31:21 +03:00
& cd - > data . conn , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SCHEDULE_FOR_DELETION :
ret = ctdb_key_data_pull ( buf , buflen , mem_ctx ,
2017-07-12 12:05:13 +03:00
& cd - > data . key , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_DB_READONLY :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_START_EXT :
ret = ctdb_traverse_start_ext_pull ( buf , buflen , mem_ctx ,
2017-06-29 17:16:58 +03:00
& cd - > data . traverse_start_ext ,
& np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DB_STATISTICS :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_DB_STICKY :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_ALL_EXT :
ret = ctdb_traverse_all_ext_pull ( buf , buflen , mem_ctx ,
2017-06-29 17:24:40 +03:00
& cd - > data . traverse_all_ext ,
& np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_DETACH :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
2015-07-31 18:47:22 +03:00
case CTDB_CONTROL_DB_FREEZE :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_THAW :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_TRANSACTION_START :
ret = ctdb_transdb_pull ( buf , buflen , mem_ctx ,
2017-07-05 10:51:03 +03:00
& cd - > data . transdb , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_TRANSACTION_COMMIT :
ret = ctdb_transdb_pull ( buf , buflen , mem_ctx ,
2017-07-05 10:51:03 +03:00
& cd - > data . transdb , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
case CTDB_CONTROL_DB_TRANSACTION_CANCEL :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-07-31 18:47:22 +03:00
break ;
2016-02-19 02:54:15 +03:00
case CTDB_CONTROL_DB_PULL :
ret = ctdb_pulldb_ext_pull ( buf , buflen , mem_ctx ,
2017-06-29 12:55:15 +03:00
& cd - > data . pulldb_ext , & np ) ;
2016-02-19 02:54:15 +03:00
break ;
case CTDB_CONTROL_DB_PUSH_START :
ret = ctdb_pulldb_ext_pull ( buf , buflen , mem_ctx ,
2017-06-29 12:55:15 +03:00
& cd - > data . pulldb_ext , & np ) ;
2016-02-19 02:54:15 +03:00
break ;
case CTDB_CONTROL_DB_PUSH_CONFIRM :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2016-02-19 02:54:15 +03:00
break ;
2017-06-14 09:24:02 +03:00
case CTDB_CONTROL_DB_OPEN_FLAGS :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2017-06-14 09:24:02 +03:00
break ;
2017-03-02 09:07:13 +03:00
case CTDB_CONTROL_DB_ATTACH_REPLICATED :
ret = ctdb_string_pull ( buf , buflen , mem_ctx ,
2017-06-29 11:48:51 +03:00
& cd - > data . db_name , & np ) ;
2017-03-02 09:07:13 +03:00
break ;
2017-08-30 08:13:53 +03:00
case CTDB_CONTROL_CHECK_PID_SRVID :
ret = ctdb_pid_srvid_pull ( buf , buflen , mem_ctx ,
& cd - > data . pid_srvid , & np ) ;
break ;
2018-02-15 03:57:44 +03:00
case CTDB_CONTROL_VACUUM_FETCH :
ret = ctdb_rec_buffer_pull ( buf , buflen , mem_ctx ,
& cd - > data . recbuf , & np ) ;
break ;
2019-07-30 03:52:05 +03:00
case CTDB_CONTROL_DB_VACUUM :
ret = ctdb_db_vacuum_pull ( buf ,
buflen ,
mem_ctx ,
& cd - > data . db_vacuum ,
& np ) ;
break ;
2020-04-07 18:26:26 +03:00
case CTDB_CONTROL_ECHO_DATA :
ret = ctdb_echo_data_pull ( buf ,
buflen ,
mem_ctx ,
& cd - > data . echo_data ,
& np ) ;
break ;
2023-11-15 18:31:53 +03:00
case CTDB_CONTROL_TCP_CLIENT_DISCONNECTED :
ret = ctdb_connection_pull ( buf ,
buflen ,
mem_ctx ,
& cd - > data . conn ,
& np ) ;
break ;
2023-11-17 17:59:57 +03:00
case CTDB_CONTROL_TCP_CLIENT_PASSED :
ret = ctdb_connection_pull ( buf ,
buflen ,
mem_ctx ,
& cd - > data . conn ,
& np ) ;
break ;
2015-04-14 10:20:05 +03:00
}
2017-07-26 19:20:03 +03:00
if ( ret ! = 0 ) {
return ret ;
}
* npull = np ;
return 0 ;
2015-04-14 10:20:05 +03:00
}
static size_t ctdb_reply_control_data_len ( struct ctdb_reply_control_data * cd )
{
size_t len = 0 ;
if ( cd = = NULL ) {
return 0 ;
}
switch ( cd - > opcode ) {
case CTDB_CONTROL_PROCESS_EXISTS :
break ;
case CTDB_CONTROL_STATISTICS :
len = ctdb_statistics_len ( cd - > data . stats ) ;
break ;
case CTDB_CONTROL_PING :
break ;
case CTDB_CONTROL_GETDBPATH :
2017-06-29 11:48:51 +03:00
len = ctdb_string_len ( & cd - > data . db_path ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GETVNNMAP :
len = ctdb_vnn_map_len ( cd - > data . vnnmap ) ;
break ;
case CTDB_CONTROL_SETVNNMAP :
break ;
case CTDB_CONTROL_GET_DEBUG :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . loglevel ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_SET_DEBUG :
break ;
case CTDB_CONTROL_GET_DBMAP :
len = ctdb_dbid_map_len ( cd - > data . dbmap ) ;
break ;
case CTDB_CONTROL_GET_RECMODE :
break ;
case CTDB_CONTROL_SET_RECMODE :
break ;
case CTDB_CONTROL_STATISTICS_RESET :
break ;
case CTDB_CONTROL_DB_ATTACH :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRAVERSE_START :
break ;
case CTDB_CONTROL_TRAVERSE_ALL :
break ;
case CTDB_CONTROL_TRAVERSE_DATA :
break ;
case CTDB_CONTROL_REGISTER_SRVID :
break ;
case CTDB_CONTROL_DEREGISTER_SRVID :
break ;
case CTDB_CONTROL_GET_DBNAME :
2017-06-29 11:48:51 +03:00
len = ctdb_string_len ( & cd - > data . db_name ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_ENABLE_SEQNUM :
break ;
case CTDB_CONTROL_UPDATE_SEQNUM :
break ;
case CTDB_CONTROL_DUMP_MEMORY :
2017-06-29 11:48:51 +03:00
len = ctdb_string_len ( & cd - > data . mem_str ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PID :
break ;
case CTDB_CONTROL_FREEZE :
break ;
case CTDB_CONTROL_GET_PNN :
break ;
case CTDB_CONTROL_SHUTDOWN :
break ;
case CTDB_CONTROL_TCP_CLIENT :
break ;
case CTDB_CONTROL_TCP_ADD :
break ;
case CTDB_CONTROL_TCP_REMOVE :
break ;
case CTDB_CONTROL_STARTUP :
break ;
case CTDB_CONTROL_SET_TUNABLE :
break ;
case CTDB_CONTROL_GET_TUNABLE :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . tun_value ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_LIST_TUNABLES :
len = ctdb_var_list_len ( cd - > data . tun_var_list ) ;
break ;
case CTDB_CONTROL_MODIFY_FLAGS :
break ;
case CTDB_CONTROL_GET_ALL_TUNABLES :
len = ctdb_tunable_list_len ( cd - > data . tun_list ) ;
break ;
case CTDB_CONTROL_GET_TCP_TICKLE_LIST :
len = ctdb_tickle_list_len ( cd - > data . tickles ) ;
break ;
case CTDB_CONTROL_SET_TCP_TICKLE_LIST :
break ;
case CTDB_CONTROL_DB_ATTACH_PERSISTENT :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_UPDATE_RECORD :
break ;
case CTDB_CONTROL_SEND_GRATUITOUS_ARP :
break ;
case CTDB_CONTROL_WIPE_DATABASE :
break ;
case CTDB_CONTROL_UPTIME :
len = ctdb_uptime_len ( cd - > data . uptime ) ;
break ;
case CTDB_CONTROL_START_RECOVERY :
break ;
case CTDB_CONTROL_END_RECOVERY :
break ;
case CTDB_CONTROL_RELOAD_NODES_FILE :
break ;
case CTDB_CONTROL_TRY_DELETE_RECORDS :
len = ctdb_rec_buffer_len ( cd - > data . recbuf ) ;
break ;
case CTDB_CONTROL_ADD_PUBLIC_IP :
break ;
case CTDB_CONTROL_DEL_PUBLIC_IP :
break ;
case CTDB_CONTROL_GET_CAPABILITIES :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . caps ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_RECD_PING :
break ;
case CTDB_CONTROL_RELEASE_IP :
break ;
case CTDB_CONTROL_TAKEOVER_IP :
break ;
case CTDB_CONTROL_GET_PUBLIC_IPS :
len = ctdb_public_ip_list_len ( cd - > data . pubip_list ) ;
break ;
case CTDB_CONTROL_GET_NODEMAP :
len = ctdb_node_map_len ( cd - > data . nodemap ) ;
break ;
case CTDB_CONTROL_TRAVERSE_KILL :
break ;
case CTDB_CONTROL_RECD_RECLOCK_LATENCY :
break ;
case CTDB_CONTROL_GET_RECLOCK_FILE :
2017-06-29 11:48:51 +03:00
len = ctdb_string_len ( & cd - > data . reclock_file ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_STOP_NODE :
break ;
case CTDB_CONTROL_CONTINUE_NODE :
break ;
case CTDB_CONTROL_SET_LMASTERROLE :
break ;
case CTDB_CONTROL_SET_RECMASTERROLE :
break ;
case CTDB_CONTROL_SET_BAN_STATE :
break ;
case CTDB_CONTROL_GET_BAN_STATE :
len = ctdb_ban_state_len ( cd - > data . ban_state ) ;
break ;
case CTDB_CONTROL_REGISTER_NOTIFY :
break ;
case CTDB_CONTROL_DEREGISTER_NOTIFY :
break ;
case CTDB_CONTROL_TRANS3_COMMIT :
break ;
case CTDB_CONTROL_GET_DB_SEQNUM :
2017-06-29 15:15:43 +03:00
len = ctdb_uint64_len ( & cd - > data . seqnum ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_SET_HEALTHY :
break ;
case CTDB_CONTROL_DB_GET_HEALTH :
2017-06-29 11:48:51 +03:00
len = ctdb_string_len ( & cd - > data . reason ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PUBLIC_IP_INFO :
len = ctdb_public_ip_info_len ( cd - > data . ipinfo ) ;
break ;
case CTDB_CONTROL_GET_IFACES :
len = ctdb_iface_list_len ( cd - > data . iface_list ) ;
break ;
case CTDB_CONTROL_SET_IFACE_LINK_STATE :
break ;
case CTDB_CONTROL_TCP_ADD_DELAYED_UPDATE :
break ;
case CTDB_CONTROL_GET_STAT_HISTORY :
len = ctdb_statistics_list_len ( cd - > data . stats_list ) ;
break ;
case CTDB_CONTROL_SCHEDULE_FOR_DELETION :
break ;
case CTDB_CONTROL_SET_DB_READONLY :
break ;
case CTDB_CONTROL_TRAVERSE_START_EXT :
break ;
case CTDB_CONTROL_GET_DB_STATISTICS :
len = ctdb_db_statistics_len ( cd - > data . dbstats ) ;
break ;
case CTDB_CONTROL_SET_DB_STICKY :
break ;
case CTDB_CONTROL_RELOAD_PUBLIC_IPS :
break ;
case CTDB_CONTROL_TRAVERSE_ALL_EXT :
break ;
case CTDB_CONTROL_IPREALLOCATED :
break ;
case CTDB_CONTROL_GET_RUNSTATE :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . runstate ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_DETACH :
break ;
case CTDB_CONTROL_GET_NODES_FILE :
len = ctdb_node_map_len ( cd - > data . nodemap ) ;
break ;
2015-07-31 18:47:22 +03:00
case CTDB_CONTROL_DB_FREEZE :
break ;
case CTDB_CONTROL_DB_THAW :
break ;
case CTDB_CONTROL_DB_TRANSACTION_START :
break ;
case CTDB_CONTROL_DB_TRANSACTION_COMMIT :
break ;
case CTDB_CONTROL_DB_TRANSACTION_CANCEL :
break ;
2016-02-19 02:54:15 +03:00
case CTDB_CONTROL_DB_PULL :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . num_records ) ;
2016-02-19 02:54:15 +03:00
break ;
case CTDB_CONTROL_DB_PUSH_START :
break ;
case CTDB_CONTROL_DB_PUSH_CONFIRM :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . num_records ) ;
2016-02-19 02:54:15 +03:00
break ;
2017-06-14 09:24:02 +03:00
case CTDB_CONTROL_DB_OPEN_FLAGS :
2017-06-29 15:09:26 +03:00
len = ctdb_int32_len ( & cd - > data . tdb_flags ) ;
2017-06-14 09:24:02 +03:00
break ;
2017-03-02 09:07:13 +03:00
case CTDB_CONTROL_DB_ATTACH_REPLICATED :
2017-06-29 15:14:23 +03:00
len = ctdb_uint32_len ( & cd - > data . db_id ) ;
2017-03-02 09:07:13 +03:00
break ;
2017-08-30 08:13:53 +03:00
case CTDB_CONTROL_CHECK_PID_SRVID :
break ;
2017-04-06 11:58:01 +03:00
case CTDB_CONTROL_TUNNEL_REGISTER :
break ;
case CTDB_CONTROL_TUNNEL_DEREGISTER :
break ;
2018-02-15 03:57:44 +03:00
case CTDB_CONTROL_VACUUM_FETCH :
break ;
2019-07-30 03:52:05 +03:00
case CTDB_CONTROL_DB_VACUUM :
break ;
2020-04-07 18:26:26 +03:00
case CTDB_CONTROL_ECHO_DATA :
len = ctdb_echo_data_len ( cd - > data . echo_data ) ;
break ;
2021-07-09 05:10:12 +03:00
case CTDB_CONTROL_DISABLE_NODE :
break ;
case CTDB_CONTROL_ENABLE_NODE :
break ;
2023-11-15 18:31:53 +03:00
case CTDB_CONTROL_TCP_CLIENT_DISCONNECTED :
break ;
2023-11-17 17:59:57 +03:00
case CTDB_CONTROL_TCP_CLIENT_PASSED :
break ;
2023-10-25 12:14:24 +03:00
case CTDB_CONTROL_START_IPREALLOCATE :
break ;
2015-04-14 10:20:05 +03:00
}
return len ;
}
static void ctdb_reply_control_data_push ( struct ctdb_reply_control_data * cd ,
2017-08-03 09:32:55 +03:00
uint8_t * buf , size_t * npush )
2015-04-14 10:20:05 +03:00
{
2017-08-03 09:32:55 +03:00
size_t np = 0 ;
2017-06-29 15:09:26 +03:00
2015-04-14 10:20:05 +03:00
switch ( cd - > opcode ) {
case CTDB_CONTROL_STATISTICS :
2017-07-26 05:50:12 +03:00
ctdb_statistics_push ( cd - > data . stats , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GETDBPATH :
2017-06-29 11:48:51 +03:00
ctdb_string_push ( & cd - > data . db_path , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GETVNNMAP :
2017-06-29 12:04:56 +03:00
ctdb_vnn_map_push ( cd - > data . vnnmap , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DEBUG :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . loglevel , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DBMAP :
2017-06-29 12:33:04 +03:00
ctdb_dbid_map_push ( cd - > data . dbmap , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_ATTACH :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DBNAME :
2017-06-29 11:48:51 +03:00
ctdb_string_push ( & cd - > data . db_name , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DUMP_MEMORY :
2017-06-29 11:48:51 +03:00
ctdb_string_push ( & cd - > data . mem_str , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PID :
break ;
case CTDB_CONTROL_GET_TUNABLE :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . tun_value , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_LIST_TUNABLES :
2017-06-29 18:28:26 +03:00
ctdb_var_list_push ( cd - > data . tun_var_list , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_ALL_TUNABLES :
2017-07-26 08:30:19 +03:00
ctdb_tunable_list_push ( cd - > data . tun_list , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_TCP_TICKLE_LIST :
2017-07-04 10:56:12 +03:00
ctdb_tickle_list_push ( cd - > data . tickles , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_ATTACH_PERSISTENT :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_UPTIME :
2017-07-06 08:34:51 +03:00
ctdb_uptime_push ( cd - > data . uptime , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRY_DELETE_RECORDS :
2017-06-29 16:41:08 +03:00
ctdb_rec_buffer_push ( cd - > data . recbuf , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_CAPABILITIES :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . caps , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PUBLIC_IPS :
2017-07-06 07:12:57 +03:00
ctdb_public_ip_list_push ( cd - > data . pubip_list , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_NODEMAP :
2017-07-06 07:25:58 +03:00
ctdb_node_map_push ( cd - > data . nodemap , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_RECLOCK_FILE :
2017-06-29 11:48:51 +03:00
ctdb_string_push ( & cd - > data . reclock_file , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_BAN_STATE :
2017-07-12 11:24:34 +03:00
ctdb_ban_state_push ( cd - > data . ban_state , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DB_SEQNUM :
2017-06-29 15:15:43 +03:00
ctdb_uint64_push ( & cd - > data . seqnum , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_GET_HEALTH :
2017-06-29 11:48:51 +03:00
ctdb_string_push ( & cd - > data . reason , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PUBLIC_IP_INFO :
2017-07-12 11:52:56 +03:00
ctdb_public_ip_info_push ( cd - > data . ipinfo , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_IFACES :
2017-07-12 11:45:42 +03:00
ctdb_iface_list_push ( cd - > data . iface_list , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_STAT_HISTORY :
2017-07-26 07:43:02 +03:00
ctdb_statistics_list_push ( cd - > data . stats_list , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DB_STATISTICS :
2017-07-26 18:00:51 +03:00
ctdb_db_statistics_push ( cd - > data . dbstats , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_RUNSTATE :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . runstate , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_NODES_FILE :
2017-07-06 07:25:58 +03:00
ctdb_node_map_push ( cd - > data . nodemap , buf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
2016-02-19 02:54:15 +03:00
case CTDB_CONTROL_DB_PULL :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . num_records , buf , & np ) ;
2016-02-19 02:54:15 +03:00
break ;
case CTDB_CONTROL_DB_PUSH_CONFIRM :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . num_records , buf , & np ) ;
2016-02-19 02:54:15 +03:00
break ;
2017-06-14 09:24:02 +03:00
case CTDB_CONTROL_DB_OPEN_FLAGS :
2017-06-29 15:09:26 +03:00
ctdb_int32_push ( & cd - > data . tdb_flags , buf , & np ) ;
2017-06-14 09:24:02 +03:00
break ;
2017-03-02 09:07:13 +03:00
case CTDB_CONTROL_DB_ATTACH_REPLICATED :
2017-06-29 15:14:23 +03:00
ctdb_uint32_push ( & cd - > data . db_id , buf , & np ) ;
2017-03-02 09:07:13 +03:00
break ;
2017-08-30 08:13:53 +03:00
case CTDB_CONTROL_CHECK_PID_SRVID :
break ;
2018-02-15 03:57:44 +03:00
case CTDB_CONTROL_VACUUM_FETCH :
break ;
2019-07-30 03:52:05 +03:00
case CTDB_CONTROL_DB_VACUUM :
break ;
2020-04-07 18:26:26 +03:00
case CTDB_CONTROL_ECHO_DATA :
ctdb_echo_data_push ( cd - > data . echo_data , buf , & np ) ;
break ;
2015-04-14 10:20:05 +03:00
}
2017-08-03 09:32:55 +03:00
* npush = np ;
2015-04-14 10:20:05 +03:00
}
static int ctdb_reply_control_data_pull ( uint8_t * buf , size_t buflen ,
uint32_t opcode , TALLOC_CTX * mem_ctx ,
2017-08-03 09:32:55 +03:00
struct ctdb_reply_control_data * cd ,
size_t * npull )
2015-04-14 10:20:05 +03:00
{
2017-08-03 09:32:55 +03:00
size_t np = 0 ;
2015-04-14 10:20:05 +03:00
int ret = 0 ;
2017-06-29 15:09:26 +03:00
2015-04-14 10:20:05 +03:00
cd - > opcode = opcode ;
switch ( opcode ) {
case CTDB_CONTROL_STATISTICS :
ret = ctdb_statistics_pull ( buf , buflen , mem_ctx ,
2017-07-26 05:50:12 +03:00
& cd - > data . stats , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GETDBPATH :
ret = ctdb_string_pull ( buf , buflen , mem_ctx ,
2017-06-29 11:48:51 +03:00
& cd - > data . db_path , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GETVNNMAP :
ret = ctdb_vnn_map_pull ( buf , buflen , mem_ctx ,
2017-06-29 12:04:56 +03:00
& cd - > data . vnnmap , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DEBUG :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . loglevel , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DBMAP :
ret = ctdb_dbid_map_pull ( buf , buflen , mem_ctx ,
2017-06-29 12:33:04 +03:00
& cd - > data . dbmap , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_ATTACH :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DBNAME :
ret = ctdb_string_pull ( buf , buflen , mem_ctx ,
2017-06-29 11:48:51 +03:00
& cd - > data . db_name , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DUMP_MEMORY :
ret = ctdb_string_pull ( buf , buflen , mem_ctx ,
2017-06-29 11:48:51 +03:00
& cd - > data . mem_str , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PID :
break ;
case CTDB_CONTROL_GET_TUNABLE :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . tun_value ,
& np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_LIST_TUNABLES :
ret = ctdb_var_list_pull ( buf , buflen , mem_ctx ,
2017-06-29 18:28:26 +03:00
& cd - > data . tun_var_list , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_ALL_TUNABLES :
ret = ctdb_tunable_list_pull ( buf , buflen , mem_ctx ,
2017-07-26 08:30:19 +03:00
& cd - > data . tun_list , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_TCP_TICKLE_LIST :
ret = ctdb_tickle_list_pull ( buf , buflen , mem_ctx ,
2017-07-04 10:56:12 +03:00
& cd - > data . tickles , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_ATTACH_PERSISTENT :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_UPTIME :
ret = ctdb_uptime_pull ( buf , buflen , mem_ctx ,
2017-07-06 08:34:51 +03:00
& cd - > data . uptime , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_TRY_DELETE_RECORDS :
2017-09-05 09:34:27 +03:00
ret = ctdb_rec_buffer_pull ( buf , buflen , mem_ctx ,
& cd - > data . recbuf , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_CAPABILITIES :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . caps , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PUBLIC_IPS :
ret = ctdb_public_ip_list_pull ( buf , buflen , mem_ctx ,
2017-07-06 07:12:57 +03:00
& cd - > data . pubip_list , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_NODEMAP :
ret = ctdb_node_map_pull ( buf , buflen , mem_ctx ,
2017-07-06 07:25:58 +03:00
& cd - > data . nodemap , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_RECLOCK_FILE :
ret = ctdb_string_pull ( buf , buflen , mem_ctx ,
2017-06-29 11:48:51 +03:00
& cd - > data . reclock_file , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_BAN_STATE :
ret = ctdb_ban_state_pull ( buf , buflen , mem_ctx ,
2017-07-12 11:24:34 +03:00
& cd - > data . ban_state , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DB_SEQNUM :
2017-06-29 15:15:43 +03:00
ret = ctdb_uint64_pull ( buf , buflen , & cd - > data . seqnum , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_DB_GET_HEALTH :
ret = ctdb_string_pull ( buf , buflen , mem_ctx ,
2017-06-29 11:48:51 +03:00
& cd - > data . reason , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_PUBLIC_IP_INFO :
ret = ctdb_public_ip_info_pull ( buf , buflen , mem_ctx ,
2017-07-12 11:52:56 +03:00
& cd - > data . ipinfo , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_IFACES :
ret = ctdb_iface_list_pull ( buf , buflen , mem_ctx ,
2017-07-12 11:45:42 +03:00
& cd - > data . iface_list , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_STAT_HISTORY :
ret = ctdb_statistics_list_pull ( buf , buflen , mem_ctx ,
2017-07-26 07:43:02 +03:00
& cd - > data . stats_list , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_DB_STATISTICS :
ret = ctdb_db_statistics_pull ( buf , buflen , mem_ctx ,
2017-07-26 18:00:51 +03:00
& cd - > data . dbstats , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_RUNSTATE :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . runstate , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
case CTDB_CONTROL_GET_NODES_FILE :
ret = ctdb_node_map_pull ( buf , buflen , mem_ctx ,
2017-07-06 07:25:58 +03:00
& cd - > data . nodemap , & np ) ;
2015-04-14 10:20:05 +03:00
break ;
2016-02-19 02:54:15 +03:00
case CTDB_CONTROL_DB_PULL :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . num_records ,
& np ) ;
2016-02-19 02:54:15 +03:00
break ;
case CTDB_CONTROL_DB_PUSH_CONFIRM :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . num_records ,
& np ) ;
2016-02-19 02:54:15 +03:00
break ;
2017-06-14 09:24:02 +03:00
case CTDB_CONTROL_DB_OPEN_FLAGS :
2017-06-29 15:09:26 +03:00
ret = ctdb_int32_pull ( buf , buflen , & cd - > data . tdb_flags , & np ) ;
2017-06-14 09:24:02 +03:00
break ;
2017-03-02 09:07:13 +03:00
case CTDB_CONTROL_DB_ATTACH_REPLICATED :
2017-06-29 15:14:23 +03:00
ret = ctdb_uint32_pull ( buf , buflen , & cd - > data . db_id , & np ) ;
2017-03-02 09:07:13 +03:00
break ;
2017-08-30 08:13:53 +03:00
case CTDB_CONTROL_CHECK_PID_SRVID :
break ;
2018-02-15 03:57:44 +03:00
case CTDB_CONTROL_VACUUM_FETCH :
break ;
2019-07-30 03:52:05 +03:00
case CTDB_CONTROL_DB_VACUUM :
break ;
2020-04-07 18:26:26 +03:00
case CTDB_CONTROL_ECHO_DATA :
ret = ctdb_echo_data_pull ( buf ,
buflen ,
mem_ctx ,
& cd - > data . echo_data ,
& np ) ;
break ;
2015-04-14 10:20:05 +03:00
}
2017-08-03 09:32:55 +03:00
if ( ret ! = 0 ) {
return ret ;
}
* npull = np ;
return 0 ;
2015-04-14 10:20:05 +03:00
}
2016-04-21 17:45:01 +03:00
size_t ctdb_req_control_len ( struct ctdb_req_header * h ,
struct ctdb_req_control * c )
{
2017-08-03 11:00:24 +03:00
uint32_t u32 = 0 ;
return ctdb_req_header_len ( h ) +
ctdb_uint32_len ( & c - > opcode ) +
ctdb_uint32_len ( & c - > pad ) +
ctdb_uint64_len ( & c - > srvid ) +
ctdb_uint32_len ( & c - > client_id ) +
ctdb_uint32_len ( & c - > flags ) +
ctdb_uint32_len ( & u32 ) +
2016-04-21 17:45:01 +03:00
ctdb_req_control_data_len ( & c - > rdata ) ;
}
2015-04-14 10:20:05 +03:00
int ctdb_req_control_push ( struct ctdb_req_header * h ,
2017-08-03 11:00:24 +03:00
struct ctdb_req_control * c ,
2016-05-01 15:13:35 +03:00
uint8_t * buf , size_t * buflen )
2015-04-14 10:20:05 +03:00
{
2017-08-03 11:00:24 +03:00
size_t offset = 0 , np ;
size_t length ;
uint32_t u32 ;
2015-04-14 10:20:05 +03:00
2017-08-03 11:00:24 +03:00
length = ctdb_req_control_len ( h , c ) ;
2016-05-01 15:13:35 +03:00
if ( * buflen < length ) {
* buflen = length ;
2016-04-21 18:08:11 +03:00
return EMSGSIZE ;
2015-04-14 10:20:05 +03:00
}
2016-05-01 15:13:35 +03:00
h - > length = * buflen ;
2017-08-03 11:00:24 +03:00
ctdb_req_header_push ( h , buf + offset , & np ) ;
offset + = np ;
ctdb_uint32_push ( & c - > opcode , buf + offset , & np ) ;
offset + = np ;
2015-04-14 10:20:05 +03:00
2017-08-03 11:00:24 +03:00
ctdb_uint32_push ( & c - > pad , buf + offset , & np ) ;
offset + = np ;
2015-04-14 10:20:05 +03:00
2017-08-03 11:00:24 +03:00
ctdb_uint64_push ( & c - > srvid , buf + offset , & np ) ;
offset + = np ;
ctdb_uint32_push ( & c - > client_id , buf + offset , & np ) ;
offset + = np ;
ctdb_uint32_push ( & c - > flags , buf + offset , & np ) ;
offset + = np ;
u32 = ctdb_req_control_data_len ( & c - > rdata ) ;
ctdb_uint32_push ( & u32 , buf + offset , & np ) ;
offset + = np ;
ctdb_req_control_data_push ( & c - > rdata , buf + offset , & np ) ;
offset + = np ;
if ( offset > * buflen ) {
return EMSGSIZE ;
}
2015-04-14 10:20:05 +03:00
return 0 ;
}
2016-04-21 18:25:06 +03:00
int ctdb_req_control_pull ( uint8_t * buf , size_t buflen ,
2015-04-14 10:20:05 +03:00
struct ctdb_req_header * h ,
TALLOC_CTX * mem_ctx ,
2016-04-21 18:25:06 +03:00
struct ctdb_req_control * c )
2015-04-14 10:20:05 +03:00
{
2017-08-03 11:00:24 +03:00
struct ctdb_req_header header ;
size_t offset = 0 , np ;
uint32_t u32 ;
2015-04-14 10:20:05 +03:00
int ret ;
2017-08-03 11:00:24 +03:00
ret = ctdb_req_header_pull ( buf + offset , buflen - offset , & header , & np ) ;
if ( ret ! = 0 ) {
return ret ;
2015-04-14 10:20:05 +03:00
}
2017-08-03 11:00:24 +03:00
offset + = np ;
if ( h ! = NULL ) {
* h = header ;
2016-05-03 05:53:24 +03:00
}
2017-08-03 11:00:24 +03:00
ret = ctdb_uint32_pull ( buf + offset , buflen - offset , & c - > opcode , & np ) ;
if ( ret ! = 0 ) {
return ret ;
2016-05-03 05:53:24 +03:00
}
2017-08-03 11:00:24 +03:00
offset + = np ;
ret = ctdb_uint32_pull ( buf + offset , buflen - offset , & c - > pad , & np ) ;
if ( ret ! = 0 ) {
return ret ;
2015-04-14 10:20:05 +03:00
}
2017-08-03 11:00:24 +03:00
offset + = np ;
2015-04-14 10:20:05 +03:00
2017-08-03 11:00:24 +03:00
ret = ctdb_uint64_pull ( buf + offset , buflen - offset , & c - > srvid , & np ) ;
if ( ret ! = 0 ) {
return ret ;
}
offset + = np ;
ret = ctdb_uint32_pull ( buf + offset , buflen - offset , & c - > client_id , & np ) ;
if ( ret ! = 0 ) {
return ret ;
2016-03-10 07:43:37 +03:00
}
2017-08-03 11:00:24 +03:00
offset + = np ;
2015-04-14 10:20:05 +03:00
2017-08-03 11:00:24 +03:00
ret = ctdb_uint32_pull ( buf + offset , buflen - offset , & c - > flags , & np ) ;
if ( ret ! = 0 ) {
return ret ;
}
offset + = np ;
2015-04-14 10:20:05 +03:00
2017-08-03 11:00:24 +03:00
ret = ctdb_uint32_pull ( buf + offset , buflen - offset , & u32 , & np ) ;
2015-04-14 10:20:05 +03:00
if ( ret ! = 0 ) {
return ret ;
}
2017-08-03 11:00:24 +03:00
offset + = np ;
if ( u32 > buflen - offset ) {
return EMSGSIZE ;
}
ret = ctdb_req_control_data_pull ( buf + offset , u32 , c - > opcode , mem_ctx ,
& c - > rdata , & np ) ;
if ( ret ! = 0 ) {
return ret ;
}
offset + = np ;
if ( offset > buflen ) {
return EMSGSIZE ;
}
2015-04-14 10:20:05 +03:00
return 0 ;
}
2016-04-21 17:45:01 +03:00
size_t ctdb_reply_control_len ( struct ctdb_req_header * h ,
struct ctdb_reply_control * c )
{
2017-08-03 11:05:41 +03:00
uint32_t dsize , esize ;
if ( c - > status = = 0 ) {
dsize = ctdb_reply_control_data_len ( & c - > rdata ) ;
esize = 0 ;
} else {
dsize = 0 ;
esize = ctdb_string_len ( & c - > errmsg ) ;
}
return ctdb_req_header_len ( h ) +
ctdb_int32_len ( & c - > status ) +
ctdb_uint32_len ( & dsize ) +
ctdb_uint32_len ( & esize ) +
dsize + esize ;
2016-04-21 17:45:01 +03:00
}
2015-04-14 10:20:05 +03:00
int ctdb_reply_control_push ( struct ctdb_req_header * h ,
2017-08-03 11:05:41 +03:00
struct ctdb_reply_control * c ,
2016-05-01 15:13:35 +03:00
uint8_t * buf , size_t * buflen )
2015-04-14 10:20:05 +03:00
{
2017-08-03 11:05:41 +03:00
size_t offset = 0 , np ;
size_t length ;
uint32_t dsize , esize ;
2015-04-14 10:20:05 +03:00
2017-08-03 11:05:41 +03:00
length = ctdb_reply_control_len ( h , c ) ;
2016-05-01 15:13:35 +03:00
if ( * buflen < length ) {
* buflen = length ;
2016-04-21 18:08:11 +03:00
return EMSGSIZE ;
2015-04-14 10:20:05 +03:00
}
2016-05-01 15:13:35 +03:00
h - > length = * buflen ;
2017-08-03 11:05:41 +03:00
ctdb_req_header_push ( h , buf + offset , & np ) ;
offset + = np ;
2015-04-14 10:20:05 +03:00
2017-08-03 11:05:41 +03:00
ctdb_int32_push ( & c - > status , buf + offset , & np ) ;
offset + = np ;
2015-04-14 10:20:05 +03:00
2017-08-03 11:05:41 +03:00
if ( c - > status = = 0 ) {
dsize = ctdb_reply_control_data_len ( & c - > rdata ) ;
esize = 0 ;
2016-04-29 08:35:12 +03:00
} else {
2017-08-03 11:05:41 +03:00
dsize = 0 ;
esize = ctdb_string_len ( & c - > errmsg ) ;
2015-04-14 10:20:05 +03:00
}
2017-08-03 11:05:41 +03:00
ctdb_uint32_push ( & dsize , buf + offset , & np ) ;
offset + = np ;
ctdb_uint32_push ( & esize , buf + offset , & np ) ;
offset + = np ;
if ( c - > status = = 0 ) {
ctdb_reply_control_data_push ( & c - > rdata , buf + offset , & np ) ;
} else {
ctdb_string_push ( & c - > errmsg , buf + offset , & np ) ;
}
offset + = np ;
2015-04-14 10:20:05 +03:00
return 0 ;
}
2016-04-21 18:25:06 +03:00
int ctdb_reply_control_pull ( uint8_t * buf , size_t buflen , uint32_t opcode ,
2015-04-14 10:20:05 +03:00
struct ctdb_req_header * h ,
TALLOC_CTX * mem_ctx ,
2016-04-21 18:25:06 +03:00
struct ctdb_reply_control * c )
2015-04-14 10:20:05 +03:00
{
2017-08-03 11:05:41 +03:00
struct ctdb_req_header header ;
size_t offset = 0 , np ;
uint32_t dsize , esize ;
2015-04-14 10:20:05 +03:00
int ret ;
2017-08-03 11:05:41 +03:00
ret = ctdb_req_header_pull ( buf + offset , buflen - offset , & header , & np ) ;
if ( ret ! = 0 ) {
return ret ;
2015-04-14 10:20:05 +03:00
}
2017-08-03 11:05:41 +03:00
offset + = np ;
if ( h ! = NULL ) {
* h = header ;
2016-05-03 05:53:24 +03:00
}
2017-08-03 11:05:41 +03:00
ret = ctdb_int32_pull ( buf + offset , buflen - offset , & c - > status , & np ) ;
if ( ret ! = 0 ) {
return ret ;
2016-05-03 05:53:24 +03:00
}
2017-08-03 11:05:41 +03:00
offset + = np ;
ret = ctdb_uint32_pull ( buf + offset , buflen - offset , & dsize , & np ) ;
if ( ret ! = 0 ) {
return ret ;
2016-05-03 05:53:24 +03:00
}
2017-08-03 11:05:41 +03:00
offset + = np ;
ret = ctdb_uint32_pull ( buf + offset , buflen - offset , & esize , & np ) ;
if ( ret ! = 0 ) {
return ret ;
2015-04-14 10:20:05 +03:00
}
2017-08-03 11:05:41 +03:00
offset + = np ;
2015-04-14 10:20:05 +03:00
2017-08-03 11:05:41 +03:00
c - > errmsg = NULL ;
if ( c - > status = = 0 ) {
if ( buflen - offset < dsize ) {
return EMSGSIZE ;
}
ret = ctdb_reply_control_data_pull ( buf + offset , dsize ,
opcode , mem_ctx , & c - > rdata ,
& np ) ;
2016-04-21 17:19:49 +03:00
if ( ret ! = 0 ) {
return ret ;
}
2017-08-03 11:05:41 +03:00
offset + = np ;
2015-04-14 10:20:05 +03:00
2017-08-03 11:05:41 +03:00
} else {
if ( buflen - offset < esize ) {
return EMSGSIZE ;
}
2015-04-14 10:20:05 +03:00
2017-08-03 11:05:41 +03:00
ret = ctdb_string_pull ( buf + offset , esize , mem_ctx , & c - > errmsg ,
& np ) ;
2015-04-14 10:20:05 +03:00
if ( ret ! = 0 ) {
return ret ;
}
2017-08-03 11:05:41 +03:00
offset + = np ;
2015-04-14 10:20:05 +03:00
}
return 0 ;
}