ctdb-protocol: Fix marshalling for ctdb_tunable_list
authorAmitay Isaacs <amitay@gmail.com>
Wed, 26 Jul 2017 05:30:19 +0000 (15:30 +1000)
committerMartin Schwenke <martins@samba.org>
Wed, 30 Aug 2017 12:59:23 +0000 (14:59 +0200)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/protocol/protocol_control.c
ctdb/protocol/protocol_private.h
ctdb/protocol/protocol_types.c
ctdb/tests/src/protocol_common.c
ctdb/tests/src/protocol_types_compat_test.c
ctdb/tests/src/protocol_types_test.c

index 9122fcbf117b507f6c414ce16a8ec5f5cec3a600..eaaf471b2f8d05c98521d5df36b6a0e2f90a5b42 100644 (file)
@@ -1476,7 +1476,7 @@ static void ctdb_reply_control_data_push(struct ctdb_reply_control_data *cd,
                break;
 
        case CTDB_CONTROL_GET_ALL_TUNABLES:
-               ctdb_tunable_list_push(cd->data.tun_list, buf);
+               ctdb_tunable_list_push(cd->data.tun_list, buf, &np);
                break;
 
        case CTDB_CONTROL_GET_TCP_TICKLE_LIST:
@@ -1649,7 +1649,7 @@ static int ctdb_reply_control_data_pull(uint8_t *buf, size_t buflen,
 
        case CTDB_CONTROL_GET_ALL_TUNABLES:
                ret = ctdb_tunable_list_pull(buf, buflen, mem_ctx,
-                                            &cd->data.tun_list);
+                                            &cd->data.tun_list, &np);
                break;
 
        case CTDB_CONTROL_GET_TCP_TICKLE_LIST:
index 1a01322ac307f2af5ed756179f9986f0d3aa3dcd..84f2650146131e75495740517d5e3cacfc45c7c1 100644 (file)
@@ -203,10 +203,11 @@ void ctdb_var_list_push(struct ctdb_var_list *in, uint8_t *buf, size_t *npush);
 int ctdb_var_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
                       struct ctdb_var_list **out, size_t *npull);
 
-size_t ctdb_tunable_list_len(struct ctdb_tunable_list *tun_list);
-void ctdb_tunable_list_push(struct ctdb_tunable_list *tun_list, uint8_t *buf);
+size_t ctdb_tunable_list_len(struct ctdb_tunable_list *in);
+void ctdb_tunable_list_push(struct ctdb_tunable_list *in, uint8_t *buf,
+                           size_t *npush);
 int ctdb_tunable_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
-                          struct ctdb_tunable_list **out);
+                          struct ctdb_tunable_list **out, size_t *npull);
 
 size_t ctdb_tickle_list_len(struct ctdb_tickle_list *tickles);
 void ctdb_tickle_list_push(struct ctdb_tickle_list *tickles, uint8_t *buf);
index c33c9495c900d1b353a9aba4e63cd55d3e81453e..285de5fb6fbfbd65cd4e22da137b2e1de746a06a 100644 (file)
@@ -2376,31 +2376,732 @@ fail:
        return ret;
 }
 
-size_t ctdb_tunable_list_len(struct ctdb_tunable_list *tun_list)
+size_t ctdb_tunable_list_len(struct ctdb_tunable_list *in)
+{
+       return ctdb_uint32_len(&in->max_redirect_count) +
+               ctdb_uint32_len(&in->seqnum_interval) +
+               ctdb_uint32_len(&in->control_timeout) +
+               ctdb_uint32_len(&in->traverse_timeout) +
+               ctdb_uint32_len(&in->keepalive_interval) +
+               ctdb_uint32_len(&in->keepalive_limit) +
+               ctdb_uint32_len(&in->recover_timeout) +
+               ctdb_uint32_len(&in->recover_interval) +
+               ctdb_uint32_len(&in->election_timeout) +
+               ctdb_uint32_len(&in->takeover_timeout) +
+               ctdb_uint32_len(&in->monitor_interval) +
+               ctdb_uint32_len(&in->tickle_update_interval) +
+               ctdb_uint32_len(&in->script_timeout) +
+               ctdb_uint32_len(&in->monitor_timeout_count) +
+               ctdb_uint32_len(&in->script_unhealthy_on_timeout) +
+               ctdb_uint32_len(&in->recovery_grace_period) +
+               ctdb_uint32_len(&in->recovery_ban_period) +
+               ctdb_uint32_len(&in->database_hash_size) +
+               ctdb_uint32_len(&in->database_max_dead) +
+               ctdb_uint32_len(&in->rerecovery_timeout) +
+               ctdb_uint32_len(&in->enable_bans) +
+               ctdb_uint32_len(&in->deterministic_public_ips) +
+               ctdb_uint32_len(&in->reclock_ping_period) +
+               ctdb_uint32_len(&in->no_ip_failback) +
+               ctdb_uint32_len(&in->disable_ip_failover) +
+               ctdb_uint32_len(&in->verbose_memory_names) +
+               ctdb_uint32_len(&in->recd_ping_timeout) +
+               ctdb_uint32_len(&in->recd_ping_failcount) +
+               ctdb_uint32_len(&in->log_latency_ms) +
+               ctdb_uint32_len(&in->reclock_latency_ms) +
+               ctdb_uint32_len(&in->recovery_drop_all_ips) +
+               ctdb_uint32_len(&in->verify_recovery_lock) +
+               ctdb_uint32_len(&in->vacuum_interval) +
+               ctdb_uint32_len(&in->vacuum_max_run_time) +
+               ctdb_uint32_len(&in->repack_limit) +
+               ctdb_uint32_len(&in->vacuum_limit) +
+               ctdb_uint32_len(&in->max_queue_depth_drop_msg) +
+               ctdb_uint32_len(&in->allow_unhealthy_db_read) +
+               ctdb_uint32_len(&in->stat_history_interval) +
+               ctdb_uint32_len(&in->deferred_attach_timeout) +
+               ctdb_uint32_len(&in->vacuum_fast_path_count) +
+               ctdb_uint32_len(&in->lcp2_public_ip_assignment) +
+               ctdb_uint32_len(&in->allow_client_db_attach) +
+               ctdb_uint32_len(&in->recover_pdb_by_seqnum) +
+               ctdb_uint32_len(&in->deferred_rebalance_on_node_add) +
+               ctdb_uint32_len(&in->fetch_collapse) +
+               ctdb_uint32_len(&in->hopcount_make_sticky) +
+               ctdb_uint32_len(&in->sticky_duration) +
+               ctdb_uint32_len(&in->sticky_pindown) +
+               ctdb_uint32_len(&in->no_ip_takeover) +
+               ctdb_uint32_len(&in->db_record_count_warn) +
+               ctdb_uint32_len(&in->db_record_size_warn) +
+               ctdb_uint32_len(&in->db_size_warn) +
+               ctdb_uint32_len(&in->pulldb_preallocation_size) +
+               ctdb_uint32_len(&in->no_ip_host_on_all_disabled) +
+               ctdb_uint32_len(&in->samba3_hack) +
+               ctdb_uint32_len(&in->mutex_enabled) +
+               ctdb_uint32_len(&in->lock_processes_per_db) +
+               ctdb_uint32_len(&in->rec_buffer_size_limit) +
+               ctdb_uint32_len(&in->queue_buffer_size) +
+               ctdb_uint32_len(&in->ip_alloc_algorithm) +
+               ctdb_uint32_len(&in->allow_mixed_versions);
+}
+
+void ctdb_tunable_list_push(struct ctdb_tunable_list *in, uint8_t *buf,
+                           size_t *npush)
 {
-       return sizeof(struct ctdb_tunable_list);
+       size_t offset = 0, np;
+
+       ctdb_uint32_push(&in->max_redirect_count, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->seqnum_interval, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->control_timeout, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->traverse_timeout, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->keepalive_interval, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->keepalive_limit, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->recover_timeout, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->recover_interval, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->election_timeout, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->takeover_timeout, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->monitor_interval, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->tickle_update_interval, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->script_timeout, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->monitor_timeout_count, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->script_unhealthy_on_timeout, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->recovery_grace_period, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->recovery_ban_period, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->database_hash_size, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->database_max_dead, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->rerecovery_timeout, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->enable_bans, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->deterministic_public_ips, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->reclock_ping_period, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->no_ip_failback, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->disable_ip_failover, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->verbose_memory_names, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->recd_ping_timeout, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->recd_ping_failcount, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->log_latency_ms, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->reclock_latency_ms, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->recovery_drop_all_ips, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->verify_recovery_lock, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->vacuum_interval, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->vacuum_max_run_time, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->repack_limit, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->vacuum_limit, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->max_queue_depth_drop_msg, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->allow_unhealthy_db_read, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->stat_history_interval, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->deferred_attach_timeout, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->vacuum_fast_path_count, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->lcp2_public_ip_assignment, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->allow_client_db_attach, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->recover_pdb_by_seqnum, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->deferred_rebalance_on_node_add, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->fetch_collapse, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->hopcount_make_sticky, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->sticky_duration, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->sticky_pindown, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->no_ip_takeover, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->db_record_count_warn, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->db_record_size_warn, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->db_size_warn, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->pulldb_preallocation_size, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->no_ip_host_on_all_disabled, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->samba3_hack, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->mutex_enabled, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->lock_processes_per_db, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->rec_buffer_size_limit, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->queue_buffer_size, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->ip_alloc_algorithm, buf+offset, &np);
+       offset += np;
+
+       ctdb_uint32_push(&in->allow_mixed_versions, buf+offset, &np);
+       offset += np;
+
+       *npush = offset;
 }
 
-void ctdb_tunable_list_push(struct ctdb_tunable_list *tun_list, uint8_t *buf)
-{
-       memcpy(buf, tun_list, sizeof(struct ctdb_tunable_list));
+static int ctdb_tunable_list_pull_elems(uint8_t *buf, size_t buflen,
+                                       TALLOC_CTX *mem_ctx,
+                                       struct ctdb_tunable_list *out,
+                                       size_t *npull)
+{
+       size_t offset = 0, np;
+       int ret;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->max_redirect_count, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->seqnum_interval, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->control_timeout, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->traverse_timeout, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->keepalive_interval, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->keepalive_limit, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->recover_timeout, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->recover_interval, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->election_timeout, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->takeover_timeout, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->monitor_interval, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->tickle_update_interval, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->script_timeout, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->monitor_timeout_count, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->script_unhealthy_on_timeout, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->recovery_grace_period, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->recovery_ban_period, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->database_hash_size, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->database_max_dead, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->rerecovery_timeout, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->enable_bans, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->deterministic_public_ips, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->reclock_ping_period, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->no_ip_failback, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->disable_ip_failover, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->verbose_memory_names, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->recd_ping_timeout, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->recd_ping_failcount, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->log_latency_ms, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->reclock_latency_ms, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->recovery_drop_all_ips, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->verify_recovery_lock, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->vacuum_interval, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->vacuum_max_run_time, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->repack_limit, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->vacuum_limit, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->max_queue_depth_drop_msg, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->allow_unhealthy_db_read, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->stat_history_interval, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->deferred_attach_timeout, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->vacuum_fast_path_count, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->lcp2_public_ip_assignment, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->allow_client_db_attach, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->recover_pdb_by_seqnum, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->deferred_rebalance_on_node_add, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->fetch_collapse, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->hopcount_make_sticky, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->sticky_duration, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->sticky_pindown, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->no_ip_takeover, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->db_record_count_warn, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->db_record_size_warn, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->db_size_warn, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->pulldb_preallocation_size, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->no_ip_host_on_all_disabled, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->samba3_hack, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->mutex_enabled, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->lock_processes_per_db, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->rec_buffer_size_limit, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->queue_buffer_size, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->ip_alloc_algorithm, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       ret = ctdb_uint32_pull(buf+offset, buflen-offset,
+                              &out->allow_mixed_versions, &np);
+       if (ret != 0) {
+               return ret;
+       }
+       offset += np;
+
+       *npull = offset;
+       return 0;
 }
 
 int ctdb_tunable_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
-                          struct ctdb_tunable_list **out)
+                          struct ctdb_tunable_list **out, size_t *npull)
 {
-       struct ctdb_tunable_list *tun_list;
+       struct ctdb_tunable_list *val;
+       size_t np;
+       int ret;
 
-       if (buflen < sizeof(struct ctdb_tunable_list)) {
-               return EMSGSIZE;
+       val = talloc(mem_ctx, struct ctdb_tunable_list);
+       if (val == NULL) {
+               return ENOMEM;
        }
 
-       tun_list = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_tunable_list));
-       if (tun_list == NULL) {
-               return ENOMEM;
+       ret = ctdb_tunable_list_pull_elems(buf, buflen, val, val, &np);
+       if (ret != 0) {
+               talloc_free(val);
+               return ret;
        }
 
-       *out = tun_list;
+       *out = val;
+       *npull = np;
        return 0;
 }
 
index ce71ca10a7c0713e028b9d572a77ac45fa6ad275..6aa9720027a9ed1bddc23f9817446bad8f29fd0e 100644 (file)
@@ -758,13 +758,135 @@ void verify_ctdb_var_list(struct ctdb_var_list *p1, struct ctdb_var_list *p2)
 
 void fill_ctdb_tunable_list(TALLOC_CTX *mem_ctx, struct ctdb_tunable_list *p)
 {
-       fill_buffer(p, sizeof(struct ctdb_tunable_list));
+       p->max_redirect_count = rand32();
+       p->seqnum_interval = rand32();
+       p->control_timeout = rand32();
+       p->traverse_timeout = rand32();
+       p->keepalive_interval = rand32();
+       p->keepalive_limit = rand32();
+       p->recover_timeout = rand32();
+       p->recover_interval = rand32();
+       p->election_timeout = rand32();
+       p->takeover_timeout = rand32();
+       p->monitor_interval = rand32();
+       p->tickle_update_interval = rand32();
+       p->script_timeout = rand32();
+       p->monitor_timeout_count = rand32();
+       p->script_unhealthy_on_timeout = rand32();
+       p->recovery_grace_period = rand32();
+       p->recovery_ban_period = rand32();
+       p->database_hash_size = rand32();
+       p->database_max_dead = rand32();
+       p->rerecovery_timeout = rand32();
+       p->enable_bans = rand32();
+       p->deterministic_public_ips = rand32();
+       p->reclock_ping_period = rand32();
+       p->no_ip_failback = rand32();
+       p->disable_ip_failover = rand32();
+       p->verbose_memory_names = rand32();
+       p->recd_ping_timeout = rand32();
+       p->recd_ping_failcount = rand32();
+       p->log_latency_ms = rand32();
+       p->reclock_latency_ms = rand32();
+       p->recovery_drop_all_ips = rand32();
+       p->verify_recovery_lock = rand32();
+       p->vacuum_interval = rand32();
+       p->vacuum_max_run_time = rand32();
+       p->repack_limit = rand32();
+       p->vacuum_limit = rand32();
+       p->max_queue_depth_drop_msg = rand32();
+       p->allow_unhealthy_db_read = rand32();
+       p->stat_history_interval = rand32();
+       p->deferred_attach_timeout = rand32();
+       p->vacuum_fast_path_count = rand32();
+       p->lcp2_public_ip_assignment = rand32();
+       p->allow_client_db_attach = rand32();
+       p->recover_pdb_by_seqnum = rand32();
+       p->deferred_rebalance_on_node_add = rand32();
+       p->fetch_collapse = rand32();
+       p->hopcount_make_sticky = rand32();
+       p->sticky_duration = rand32();
+       p->sticky_pindown = rand32();
+       p->no_ip_takeover = rand32();
+       p->db_record_count_warn = rand32();
+       p->db_record_size_warn = rand32();
+       p->db_size_warn = rand32();
+       p->pulldb_preallocation_size = rand32();
+       p->no_ip_host_on_all_disabled = rand32();
+       p->samba3_hack = rand32();
+       p->mutex_enabled = rand32();
+       p->lock_processes_per_db = rand32();
+       p->rec_buffer_size_limit = rand32();
+       p->queue_buffer_size = rand32();
+       p->ip_alloc_algorithm = rand32();
+       p->allow_mixed_versions = rand32();
 }
 
 void verify_ctdb_tunable_list(struct ctdb_tunable_list *p1,
                              struct ctdb_tunable_list *p2)
 {
-       verify_buffer(p1, p2, sizeof(struct ctdb_tunable_list));
+       assert(p1->max_redirect_count == p2->max_redirect_count);
+       assert(p1->seqnum_interval == p2->seqnum_interval);
+       assert(p1->control_timeout == p2->control_timeout);
+       assert(p1->traverse_timeout == p2->traverse_timeout);
+       assert(p1->keepalive_interval == p2->keepalive_interval);
+       assert(p1->keepalive_limit == p2->keepalive_limit);
+       assert(p1->recover_timeout == p2->recover_timeout);
+       assert(p1->recover_interval == p2->recover_interval);
+       assert(p1->election_timeout == p2->election_timeout);
+       assert(p1->takeover_timeout == p2->takeover_timeout);
+       assert(p1->monitor_interval == p2->monitor_interval);
+       assert(p1->tickle_update_interval == p2->tickle_update_interval);
+       assert(p1->script_timeout == p2->script_timeout);
+       assert(p1->monitor_timeout_count == p2->monitor_timeout_count);
+       assert(p1->script_unhealthy_on_timeout == p2->script_unhealthy_on_timeout);
+       assert(p1->recovery_grace_period == p2->recovery_grace_period);
+       assert(p1->recovery_ban_period == p2->recovery_ban_period);
+       assert(p1->database_hash_size == p2->database_hash_size);
+       assert(p1->database_max_dead == p2->database_max_dead);
+       assert(p1->rerecovery_timeout == p2->rerecovery_timeout);
+       assert(p1->enable_bans == p2->enable_bans);
+       assert(p1->deterministic_public_ips == p2->deterministic_public_ips);
+       assert(p1->reclock_ping_period == p2->reclock_ping_period);
+       assert(p1->no_ip_failback == p2->no_ip_failback);
+       assert(p1->disable_ip_failover == p2->disable_ip_failover);
+       assert(p1->verbose_memory_names == p2->verbose_memory_names);
+       assert(p1->recd_ping_timeout == p2->recd_ping_timeout);
+       assert(p1->recd_ping_failcount == p2->recd_ping_failcount);
+       assert(p1->log_latency_ms == p2->log_latency_ms);
+       assert(p1->reclock_latency_ms == p2->reclock_latency_ms);
+       assert(p1->recovery_drop_all_ips == p2->recovery_drop_all_ips);
+       assert(p1->verify_recovery_lock == p2->verify_recovery_lock);
+       assert(p1->vacuum_interval == p2->vacuum_interval);
+       assert(p1->vacuum_max_run_time == p2->vacuum_max_run_time);
+       assert(p1->repack_limit == p2->repack_limit);
+       assert(p1->vacuum_limit == p2->vacuum_limit);
+       assert(p1->max_queue_depth_drop_msg == p2->max_queue_depth_drop_msg);
+       assert(p1->allow_unhealthy_db_read == p2->allow_unhealthy_db_read);
+       assert(p1->stat_history_interval == p2->stat_history_interval);
+       assert(p1->deferred_attach_timeout == p2->deferred_attach_timeout);
+       assert(p1->vacuum_fast_path_count == p2->vacuum_fast_path_count);
+       assert(p1->lcp2_public_ip_assignment == p2->lcp2_public_ip_assignment);
+       assert(p1->allow_client_db_attach == p2->allow_client_db_attach);
+       assert(p1->recover_pdb_by_seqnum == p2->recover_pdb_by_seqnum);
+       assert(p1->deferred_rebalance_on_node_add == p2->deferred_rebalance_on_node_add);
+       assert(p1->fetch_collapse == p2->fetch_collapse);
+       assert(p1->hopcount_make_sticky == p2->hopcount_make_sticky);
+       assert(p1->sticky_duration == p2->sticky_duration);
+       assert(p1->sticky_pindown == p2->sticky_pindown);
+       assert(p1->no_ip_takeover == p2->no_ip_takeover);
+       assert(p1->db_record_count_warn == p2->db_record_count_warn);
+       assert(p1->db_record_size_warn == p2->db_record_size_warn);
+       assert(p1->db_size_warn == p2->db_size_warn);
+       assert(p1->pulldb_preallocation_size == p2->pulldb_preallocation_size);
+       assert(p1->no_ip_host_on_all_disabled == p2->no_ip_host_on_all_disabled);
+       assert(p1->samba3_hack == p2->samba3_hack);
+       assert(p1->mutex_enabled == p2->mutex_enabled);
+       assert(p1->lock_processes_per_db == p2->lock_processes_per_db);
+       assert(p1->rec_buffer_size_limit == p2->rec_buffer_size_limit);
+       assert(p1->queue_buffer_size == p2->queue_buffer_size);
+       assert(p1->ip_alloc_algorithm == p2->ip_alloc_algorithm);
+       assert(p1->allow_mixed_versions == p2->allow_mixed_versions);
 }
 
 void fill_ctdb_tickle_list(TALLOC_CTX *mem_ctx, struct ctdb_tickle_list *p)
index e58c93067094d5c61c0691f07d801604e42140ba..215757a77ffecd64869c5978b50ab5991458276f 100644 (file)
@@ -917,6 +917,36 @@ fail:
        return ENOMEM;
 }
 
+static size_t ctdb_tunable_list_len_old(struct ctdb_tunable_list *in)
+{
+       return sizeof(struct ctdb_tunable_list);
+}
+
+static void ctdb_tunable_list_push_old(struct ctdb_tunable_list *in,
+                                      uint8_t *buf)
+{
+       memcpy(buf, in, sizeof(struct ctdb_tunable_list));
+}
+
+static int ctdb_tunable_list_pull_old(uint8_t *buf, size_t buflen,
+                                     TALLOC_CTX *mem_ctx,
+                                     struct ctdb_tunable_list **out)
+{
+       struct ctdb_tunable_list *val;
+
+       if (buflen < sizeof(struct ctdb_tunable_list)) {
+               return EMSGSIZE;
+       }
+
+       val = talloc_memdup(mem_ctx, buf, sizeof(struct ctdb_tunable_list));
+       if (val == NULL) {
+               return ENOMEM;
+       }
+
+       *out = val;
+       return 0;
+}
+
 
 COMPAT_TYPE3_TEST(struct ctdb_statistics, ctdb_statistics);
 COMPAT_TYPE3_TEST(struct ctdb_vnn_map, ctdb_vnn_map);
@@ -937,6 +967,7 @@ COMPAT_TYPE3_TEST(struct ctdb_connection, ctdb_connection);
 COMPAT_TYPE3_TEST(struct ctdb_tunable, ctdb_tunable);
 COMPAT_TYPE3_TEST(struct ctdb_node_flag_change, ctdb_node_flag_change);
 COMPAT_TYPE3_TEST(struct ctdb_var_list, ctdb_var_list);
+COMPAT_TYPE3_TEST(struct ctdb_tunable_list, ctdb_tunable_list);
 
 int main(int argc, char *argv[])
 {
@@ -962,6 +993,7 @@ int main(int argc, char *argv[])
        COMPAT_TEST_FUNC(ctdb_tunable)();
        COMPAT_TEST_FUNC(ctdb_node_flag_change)();
        COMPAT_TEST_FUNC(ctdb_var_list)();
+       COMPAT_TEST_FUNC(ctdb_tunable_list)();
 
        return 0;
 }
index 6961c5704871d4a77d81ef1b32197e5d537d07bd..695a591e57e467fc7b42ea361913ff62c1dcf189 100644 (file)
@@ -65,7 +65,7 @@ PROTOCOL_TYPE3_TEST(struct ctdb_connection, ctdb_connection);
 PROTOCOL_TYPE3_TEST(struct ctdb_tunable, ctdb_tunable);
 PROTOCOL_TYPE3_TEST(struct ctdb_node_flag_change, ctdb_node_flag_change);
 PROTOCOL_TYPE3_TEST(struct ctdb_var_list, ctdb_var_list);
-DEFINE_TEST(struct ctdb_tunable_list, ctdb_tunable_list);
+PROTOCOL_TYPE3_TEST(struct ctdb_tunable_list, ctdb_tunable_list);
 DEFINE_TEST(struct ctdb_tickle_list, ctdb_tickle_list);
 DEFINE_TEST(struct ctdb_addr_info, ctdb_addr_info);
 DEFINE_TEST(struct ctdb_transdb, ctdb_transdb);