Remove the structure ctdb_control_tcp_vnn since this is identical to the structure...
[metze/ctdb/wip.git] / include / ctdb_private.h
index 05b288a08a63fa3b346309541944d27eb379b7d6..8166e1515c8a3fcb1c508e6d2c2ce13c91c63791 100644 (file)
 #ifndef _CTDB_PRIVATE_H
 #define _CTDB_PRIVATE_H
 
-#include "ctdb.h"
+#include "ctdb_client.h"
 #include <sys/socket.h>
 
-/* location of daemon socket */
-#define CTDB_PATH      "/tmp/ctdb.socket"
-
-/* default ctdb port number */
-#define CTDB_PORT 4379
-
-/* we must align packets to ensure ctdb works on all architectures (eg. sparc) */
-#define CTDB_DS_ALIGNMENT 8
-
-
-#define CTDB_NULL_FUNC      0xFF000001
-#define CTDB_FETCH_FUNC     0xFF000002
-
-
 /*
   recovery daemon memdump reply address
  */
@@ -60,6 +46,7 @@ extern pid_t ctdbd_pid;
 
 /*
   a tcp connection description
+  also used by tcp_add and tcp_remove controls
  */
 struct ctdb_tcp_connection {
        ctdb_sock_addr src_addr;
@@ -103,8 +90,8 @@ struct ctdb_tunable {
        uint32_t monitor_interval;
        uint32_t tickle_update_interval;
        uint32_t script_timeout;
-       uint32_t script_ban_count; /* ban after this many consec timeouts*/
-       uint32_t script_unhealthy_on_timeout; /* don't ban on timeout; set node unhealthy */
+       uint32_t script_timeout_count; /* allow dodgy scripts to hang this many times in a row before we mark the node unhealthy */
+       uint32_t script_unhealthy_on_timeout; /* obsolete */
        uint32_t recovery_grace_period;
        uint32_t recovery_ban_period;
        uint32_t database_hash_size;
@@ -112,7 +99,6 @@ struct ctdb_tunable {
        uint32_t rerecovery_timeout;
        uint32_t enable_bans;
        uint32_t deterministic_public_ips;
-       uint32_t disable_when_unhealthy;
        uint32_t reclock_ping_period;
        uint32_t no_ip_failback;
        uint32_t verbose_memory_names;
@@ -130,6 +116,7 @@ struct ctdb_tunable {
        uint32_t vacuum_max_interval;
        uint32_t max_queue_depth_drop_msg;
        uint32_t use_status_events_for_monitoring;
+       uint32_t allow_unhealthy_db_read;
 };
 
 /*
@@ -181,12 +168,14 @@ struct ctdb_client {
        struct ctdb_client_notify_list *notify;
 };
 
+struct ctdb_iface;
 
 /* state associated with a public ip address */
 struct ctdb_vnn {
        struct ctdb_vnn *prev, *next;
 
-       const char *iface;
+       struct ctdb_iface *iface;
+       const char **ifaces;
        ctdb_sock_addr public_address;
        uint8_t public_netmask_bits;
 
@@ -244,7 +233,8 @@ struct ctdb_node {
           across the nodes.  it needs to know which public ip's can be handled
           by each node.
        */
-       struct ctdb_all_public_ips *public_ips;
+       struct ctdb_all_public_ips *known_public_ips;
+       struct ctdb_all_public_ips *available_public_ips;
        /* used by the recovery dameon to track when a node should be banned */
        struct ctdb_banning_state *ban_state; 
 };
@@ -283,7 +273,7 @@ struct ctdb_message_list {
        struct ctdb_context *ctdb;
        struct ctdb_message_list *next, *prev;
        uint64_t srvid;
-       ctdb_message_fn_t message_handler;
+       ctdb_msg_fn_t message_handler;
        void *message_private;
 };
 
@@ -343,6 +333,9 @@ struct ctdb_statistics {
        double max_call_latency;
        double max_lockwait_latency;
        double max_childwrite_latency;
+       uint32_t num_recoveries;
+       struct timeval statistics_start_time;
+       struct timeval statistics_current_time;
 };
 
 
@@ -390,7 +383,7 @@ enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN
 #define NUM_DB_PRIORITIES 3
 /* main state of the ctdb daemon */
 struct ctdb_context {
-       struct event_context *ev;
+       struct tevent_context *ev;
        struct timeval ctdbd_start_time;
        struct timeval last_recovery_started;
        struct timeval last_recovery_finished;
@@ -406,6 +399,11 @@ struct ctdb_context {
        const char *name;
        const char *db_directory;
        const char *db_directory_persistent;
+       const char *db_directory_state;
+       struct tdb_wrap *db_persistent_health;
+       uint32_t db_persistent_startup_generation;
+       uint64_t db_persistent_check_errors;
+       uint64_t max_persistent_check_errors;
        const char *transport;
        char *recovery_lock_file;
        int recovery_lock_fd;
@@ -415,10 +413,11 @@ struct ctdb_context {
        unsigned flags;
        uint32_t capabilities;
        struct idr_context *idr;
-       uint16_t idr_cnt;
+       int lastid;
        struct ctdb_node **nodes; /* array of nodes in the cluster - indexed by vnn */
        struct ctdb_vnn *vnn; /* list of public ip addresses and interfaces */
        struct ctdb_vnn *single_ip_vnn; /* a structure for the single ip */
+       struct ctdb_iface *ifaces; /* list of local interfaces */
        char *err_msg;
        const struct ctdb_methods *methods; /* transport methods */
        const struct ctdb_upcalls *upcalls; /* transport upcalls */
@@ -432,32 +431,37 @@ struct ctdb_context {
        uint32_t recovery_master;
        struct ctdb_call_state *pending_calls;
        struct ctdb_client_ip *client_ip_list;
-       bool do_setsched;
        bool do_checkpublicip;
-       void *saved_scheduler_param;
-       struct _trbt_tree_t *server_ids;        
+       struct trbt_tree *server_ids;   
        const char *event_script_dir;
        const char *notification_script;
        const char *default_public_interface;
        pid_t ctdbd_pid;
        pid_t recoverd_pid;
+       pid_t syslogd_pid;
        bool done_startup;
        const char *node_ip;
        struct ctdb_monitor_state *monitor;
        struct ctdb_log_state *log;
        int start_as_disabled;
        int start_as_stopped;
+       bool valgrinding;
        uint32_t event_script_timeouts; /* counting how many consecutive times an eventscript has timedout */
        uint32_t *recd_ping_count;
        TALLOC_CTX *release_ips_ctx; /* a context used to automatically drop all IPs if we fail to recover the node */
 
-       TALLOC_CTX *monitor_event_script_ctx;
-       TALLOC_CTX *other_event_script_ctx;
+       TALLOC_CTX *event_script_ctx;
 
-       struct ctdb_monitor_script_status_ctx *current_monitor_status_ctx;
-       struct ctdb_monitor_script_status_ctx *last_monitor_status_ctx;
+       struct ctdb_event_script_state *current_monitor;
+       struct ctdb_scripts_wire *last_status[CTDB_EVENT_MAX];
 
        TALLOC_CTX *banning_ctx;
+
+       /* mapping from pid to ctdb_client * */
+       struct ctdb_client_pid_list *client_pids;
+
+       /* used in the recovery daemon to remember the ip allocation */
+       struct trbt_tree *ip_tree;
 };
 
 struct ctdb_db_context {
@@ -471,10 +475,11 @@ struct ctdb_db_context {
        struct tdb_wrap *ltdb;
        struct ctdb_registered_call *calls; /* list of registered calls */
        uint32_t seqnum;
-       struct timed_event *te;
+       struct timed_event *seqnum_update;
        struct ctdb_traverse_local_handle *traverse;
        bool transaction_active;
        struct ctdb_vacuum_handle *vacuum_handle;
+       char *unhealthy_reason;
 };
 
 
@@ -498,135 +503,6 @@ struct ctdb_db_context {
           ctdb_fatal(ctdb, "Out of memory in " __location__ ); \
          }} while (0)
 
-/*
-  the extended header for records in the ltdb
-*/
-struct ctdb_ltdb_header {
-       uint64_t rsn;
-       uint32_t dmaster;
-       uint32_t laccessor;
-       uint32_t lacount;
-};
-
-enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0, 
-                   CTDB_CONTROL_STATISTICS              = 1, 
-                   /* #2 removed */
-                   CTDB_CONTROL_PING                    = 3,
-                   CTDB_CONTROL_GETDBPATH               = 4,
-                   CTDB_CONTROL_GETVNNMAP               = 5,
-                   CTDB_CONTROL_SETVNNMAP               = 6,
-                   CTDB_CONTROL_GET_DEBUG               = 7,
-                   CTDB_CONTROL_SET_DEBUG               = 8,
-                   CTDB_CONTROL_GET_DBMAP               = 9,
-                   CTDB_CONTROL_GET_NODEMAPv4           = 10, /* obsolete */
-                   CTDB_CONTROL_SET_DMASTER             = 11,
-                   /* #12 removed */
-                   CTDB_CONTROL_PULL_DB                 = 13,
-                   CTDB_CONTROL_PUSH_DB                 = 14,
-                   CTDB_CONTROL_GET_RECMODE             = 15,
-                   CTDB_CONTROL_SET_RECMODE             = 16,
-                   CTDB_CONTROL_STATISTICS_RESET        = 17,
-                   CTDB_CONTROL_DB_ATTACH               = 18,
-                   CTDB_CONTROL_SET_CALL                = 19,
-                   CTDB_CONTROL_TRAVERSE_START          = 20,
-                   CTDB_CONTROL_TRAVERSE_ALL            = 21,
-                   CTDB_CONTROL_TRAVERSE_DATA           = 22,
-                   CTDB_CONTROL_REGISTER_SRVID          = 23,
-                   CTDB_CONTROL_DEREGISTER_SRVID        = 24,
-                   CTDB_CONTROL_GET_DBNAME              = 25,
-                   CTDB_CONTROL_ENABLE_SEQNUM           = 26,
-                   CTDB_CONTROL_UPDATE_SEQNUM           = 27,
-                   /* #28 removed */
-                   CTDB_CONTROL_DUMP_MEMORY             = 29,
-                   CTDB_CONTROL_GET_PID                 = 30,
-                   CTDB_CONTROL_GET_RECMASTER           = 31,
-                   CTDB_CONTROL_SET_RECMASTER           = 32,
-                   CTDB_CONTROL_FREEZE                  = 33,
-                   CTDB_CONTROL_THAW                    = 34,
-                   CTDB_CONTROL_GET_PNN                 = 35,
-                   CTDB_CONTROL_SHUTDOWN                = 36,
-                   CTDB_CONTROL_GET_MONMODE             = 37,
-                   /* #38 removed */
-                   /* #39 removed */
-                   /* #40 removed */
-                   /* #41 removed */
-                   CTDB_CONTROL_TAKEOVER_IPv4           = 42, /* obsolete */
-                   CTDB_CONTROL_RELEASE_IPv4            = 43, /* obsolete */
-                   CTDB_CONTROL_TCP_CLIENT              = 44,
-                   CTDB_CONTROL_TCP_ADD                 = 45,
-                   CTDB_CONTROL_TCP_REMOVE              = 46,
-                   CTDB_CONTROL_STARTUP                 = 47,
-                   CTDB_CONTROL_SET_TUNABLE             = 48,
-                   CTDB_CONTROL_GET_TUNABLE             = 49,
-                   CTDB_CONTROL_LIST_TUNABLES           = 50,
-                   CTDB_CONTROL_GET_PUBLIC_IPSv4        = 51, /* obsolete */
-                   CTDB_CONTROL_MODIFY_FLAGS            = 52,
-                   CTDB_CONTROL_GET_ALL_TUNABLES        = 53,
-                   CTDB_CONTROL_KILL_TCP                = 54,
-                   CTDB_CONTROL_GET_TCP_TICKLE_LIST     = 55,
-                   CTDB_CONTROL_SET_TCP_TICKLE_LIST     = 56,
-                   CTDB_CONTROL_REGISTER_SERVER_ID      = 57,
-                   CTDB_CONTROL_UNREGISTER_SERVER_ID    = 58,
-                   CTDB_CONTROL_CHECK_SERVER_ID         = 59,
-                   CTDB_CONTROL_GET_SERVER_ID_LIST      = 60,
-                   CTDB_CONTROL_DB_ATTACH_PERSISTENT    = 61,
-                   CTDB_CONTROL_PERSISTENT_STORE        = 62,
-                   CTDB_CONTROL_UPDATE_RECORD           = 63,
-                   CTDB_CONTROL_SEND_GRATIOUS_ARP       = 64,
-                   CTDB_CONTROL_TRANSACTION_START       = 65,
-                   CTDB_CONTROL_TRANSACTION_COMMIT      = 66,
-                   CTDB_CONTROL_WIPE_DATABASE           = 67,
-                   /* #68 removed */
-                   CTDB_CONTROL_UPTIME                  = 69,
-                   CTDB_CONTROL_START_RECOVERY          = 70,
-                   CTDB_CONTROL_END_RECOVERY            = 71,
-                   CTDB_CONTROL_RELOAD_NODES_FILE       = 72,
-                   /* #73 removed */
-                   CTDB_CONTROL_TRY_DELETE_RECORDS      = 74,
-                   CTDB_CONTROL_ENABLE_MONITOR          = 75,
-                   CTDB_CONTROL_DISABLE_MONITOR         = 76,
-                   CTDB_CONTROL_ADD_PUBLIC_IP           = 77,
-                   CTDB_CONTROL_DEL_PUBLIC_IP           = 78,
-                   CTDB_CONTROL_RUN_EVENTSCRIPTS        = 79,
-                   CTDB_CONTROL_GET_CAPABILITIES        = 80,
-                   CTDB_CONTROL_START_PERSISTENT_UPDATE = 81,
-                   CTDB_CONTROL_CANCEL_PERSISTENT_UPDATE= 82,
-                   CTDB_CONTROL_TRANS2_COMMIT           = 83,
-                   CTDB_CONTROL_TRANS2_FINISHED         = 84,
-                   CTDB_CONTROL_TRANS2_ERROR            = 85,
-                   CTDB_CONTROL_TRANS2_COMMIT_RETRY     = 86,
-                   CTDB_CONTROL_RECD_PING               = 87,
-                   CTDB_CONTROL_RELEASE_IP              = 88,
-                   CTDB_CONTROL_TAKEOVER_IP             = 89,
-                   CTDB_CONTROL_GET_PUBLIC_IPS          = 90,
-                   CTDB_CONTROL_GET_NODEMAP             = 91,
-                   CTDB_CONTROL_EVENT_SCRIPT_INIT       = 92,
-                   CTDB_CONTROL_EVENT_SCRIPT_START      = 93,
-                   CTDB_CONTROL_EVENT_SCRIPT_STOP       = 94,
-                   CTDB_CONTROL_EVENT_SCRIPT_FINISHED   = 95,
-                   CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS = 96,
-                   CTDB_CONTROL_TRAVERSE_KILL           = 97,
-                   CTDB_CONTROL_RECD_RECLOCK_LATENCY    = 98,
-                   CTDB_CONTROL_GET_RECLOCK_FILE        = 99,
-                   CTDB_CONTROL_SET_RECLOCK_FILE        = 100,
-                   CTDB_CONTROL_STOP_NODE               = 101,
-                   CTDB_CONTROL_CONTINUE_NODE           = 102,
-                   CTDB_CONTROL_SET_NATGWSTATE          = 103,
-                   CTDB_CONTROL_SET_LMASTERROLE         = 104,
-                   CTDB_CONTROL_SET_RECMASTERROLE       = 105,
-                   CTDB_CONTROL_EVENT_SCRIPT_DISABLED   = 106,
-                   CTDB_CONTROL_ENABLE_SCRIPT           = 107,
-                   CTDB_CONTROL_DISABLE_SCRIPT          = 108,
-                   CTDB_CONTROL_SET_BAN_STATE           = 109,
-                   CTDB_CONTROL_GET_BAN_STATE           = 110,
-                   CTDB_CONTROL_SET_DB_PRIORITY         = 111,
-                   CTDB_CONTROL_GET_DB_PRIORITY         = 112,
-                   CTDB_CONTROL_TRANSACTION_CANCEL      = 113,
-                   CTDB_CONTROL_REGISTER_NOTIFY         = 114,
-                   CTDB_CONTROL_DEREGISTER_NOTIFY       = 115,
-                   CTDB_CONTROL_TRANS2_ACTIVE           = 116,
-};     
-
 /*
   structure passed in set_call control
  */
@@ -666,14 +542,6 @@ struct ctdb_control_gratious_arp {
        char iface[1];
 };
 
-/*
-  struct for tcp_add and tcp_remove controls
- */
-struct ctdb_control_tcp_vnn {
-       ctdb_sock_addr src;
-       ctdb_sock_addr dest;
-};
-
 /*
   persistent store control - update this record on all other nodes
  */
@@ -731,146 +599,6 @@ struct ctdb_fetch_handle {
        struct ctdb_ltdb_header header;
 };
 
-/*
-  operation IDs
-*/
-enum ctdb_operation {
-       CTDB_REQ_CALL           = 0,
-       CTDB_REPLY_CALL         = 1,
-       CTDB_REQ_DMASTER        = 2,
-       CTDB_REPLY_DMASTER      = 3,
-       CTDB_REPLY_ERROR        = 4,
-       CTDB_REQ_MESSAGE        = 5,
-       /* #6 removed */
-       CTDB_REQ_CONTROL        = 7,
-       CTDB_REPLY_CONTROL      = 8,
-       CTDB_REQ_KEEPALIVE      = 9,
-};
-
-#define CTDB_MAGIC 0x43544442 /* CTDB */
-#define CTDB_VERSION 1
-
-/*
-  packet structures
-*/
-struct ctdb_req_header {
-       uint32_t length;
-       uint32_t ctdb_magic;
-       uint32_t ctdb_version;
-       uint32_t generation;
-       uint32_t operation;
-       uint32_t destnode;
-       uint32_t srcnode;
-       uint32_t reqid;
-};
-
-struct ctdb_req_call {
-       struct ctdb_req_header hdr;
-       uint32_t flags;
-       uint32_t db_id;
-       uint32_t callid;
-       uint32_t hopcount;
-       uint32_t keylen;
-       uint32_t calldatalen;
-       uint8_t data[1]; /* key[] followed by calldata[] */
-};
-
-struct ctdb_reply_call {
-       struct ctdb_req_header hdr;
-       uint32_t status;
-       uint32_t datalen;
-       uint8_t  data[1];
-};
-
-struct ctdb_reply_error {
-       struct ctdb_req_header hdr;
-       uint32_t status;
-       uint32_t msglen;
-       uint8_t  msg[1];
-};
-
-struct ctdb_req_dmaster {
-       struct ctdb_req_header hdr;
-       uint32_t db_id;
-       uint64_t rsn;
-       uint32_t dmaster;
-       uint32_t keylen;
-       uint32_t datalen;
-       uint8_t  data[1];
-};
-
-struct ctdb_reply_dmaster {
-       struct ctdb_req_header hdr;
-       uint32_t db_id;
-       uint64_t rsn;
-       uint32_t keylen;
-       uint32_t datalen;
-       uint8_t  data[1];
-};
-
-struct ctdb_req_message {
-       struct ctdb_req_header hdr;
-       uint64_t srvid;
-       uint32_t datalen;
-       uint8_t data[1];
-};
-
-struct ctdb_req_getdbpath {
-       struct ctdb_req_header hdr;
-       uint32_t db_id;
-};
-
-struct ctdb_reply_getdbpath {
-       struct ctdb_req_header hdr;
-       uint32_t datalen;
-       uint8_t data[1];
-};
-
-struct ctdb_req_control {
-       struct ctdb_req_header hdr;
-       uint32_t opcode;
-       uint64_t srvid;
-       uint32_t client_id;
-#define CTDB_CTRL_FLAG_NOREPLY   1
-       uint32_t flags;
-       uint32_t datalen;
-       uint8_t data[1];
-};
-
-struct ctdb_reply_control {
-       struct ctdb_req_header hdr;
-       int32_t  status;
-       uint32_t datalen;
-       uint32_t errorlen;
-       uint8_t data[1];
-};
-
-struct ctdb_req_keepalive {
-       struct ctdb_req_header hdr;
-};
-
-
-/* types of failures possible from TRANS2_COMMIT */
-enum ctdb_trans2_commit_error {
-       CTDB_TRANS2_COMMIT_SUCCESS=0, /* all nodes committed successfully */
-       CTDB_TRANS2_COMMIT_TIMEOUT=1, /* at least one node timed out */
-       CTDB_TRANS2_COMMIT_ALLFAIL=2, /* all nodes failed the commit */
-       CTDB_TRANS2_COMMIT_SOMEFAIL=3 /* some nodes failed the commit, some allowed it */
-};
-
-/* different calls to event scripts. */
-enum ctdb_eventscript_call {
-       CTDB_EVENT_STARTUP,             /* CTDB starting up: no args. */
-       CTDB_EVENT_START_RECOVERY,      /* CTDB recovery starting: no args. */
-       CTDB_EVENT_RECOVERED,           /* CTDB recovery finished: no args. */
-       CTDB_EVENT_TAKE_IP,             /* IP taken: interface, IP address, netmask bits. */
-       CTDB_EVENT_RELEASE_IP,          /* IP released: interface, IP address, netmask bits. */
-       CTDB_EVENT_STOPPED,             /* This node is stopped: no args. */
-       CTDB_EVENT_MONITOR,             /* Please check if service is healthy: no args. */
-       CTDB_EVENT_STATUS,              /* Report service status: no args. */
-       CTDB_EVENT_SHUTDOWN             /* CTDB shutting down: no args. */
-};
-
 /* internal prototypes */
 void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
 void ctdb_fatal(struct ctdb_context *ctdb, const char *msg);
@@ -941,7 +669,8 @@ struct ctdb_queue *ctdb_queue_setup(struct ctdb_context *ctdb,
                                    TALLOC_CTX *mem_ctx, int fd, int alignment,
                                    
                                    ctdb_queue_cb_fn_t callback,
-                                   void *private_data);
+                                   void *private_data, const char *fmt, ...)
+       PRINTF_ATTRIBUTE(7,8);
 
 /*
   allocate a packet for use in client<->daemon communication
@@ -992,10 +721,6 @@ struct ctdb_call_state *ctdb_client_call_send(struct ctdb_db_context *ctdb_db,
 */
 int ctdb_client_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
 
-int ctdb_daemon_set_message_handler(struct ctdb_context *ctdb, uint64_t srvid, 
-                            ctdb_message_fn_t handler,
-                            void *private_data);
-
 int ctdb_client_send_message(struct ctdb_context *ctdb, uint32_t vnn,
                             uint64_t srvid, TDB_DATA data);
 
@@ -1032,6 +757,7 @@ int ctdb_socket_connect(struct ctdb_context *ctdb);
 void ctdb_latency(struct ctdb_db_context *ctdb_db, const char *name, double *latency, struct timeval t);
 void ctdb_reclock_latency(struct ctdb_context *ctdb, const char *name, double *latency, double l);
 
+#define CTDB_BAD_REQID ((uint32_t)-1)
 uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state);
 void *_ctdb_reqid_find(struct ctdb_context *ctdb, uint32_t reqid, const char *type, const char *location);
 void ctdb_reqid_remove(struct ctdb_context *ctdb, uint32_t reqid);
@@ -1255,8 +981,8 @@ void ctdb_call_resend_all(struct ctdb_context *ctdb);
 void ctdb_node_dead(struct ctdb_node *node);
 void ctdb_node_connected(struct ctdb_node *node);
 bool ctdb_blocking_freeze(struct ctdb_context *ctdb);
-void ctdb_set_scheduler(struct ctdb_context *ctdb);
-void ctdb_restore_scheduler(struct ctdb_context *ctdb);
+void ctdb_high_priority(struct ctdb_context *ctdb);
+void ctdb_reduce_priority(struct ctdb_context *ctdb);
 int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb, 
                                 struct ctdb_req_control *c,
                                 TDB_DATA indata, 
@@ -1306,12 +1032,67 @@ struct ctdb_all_public_ips {
 int32_t ctdb_control_get_public_ipsv4(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA *outdata);
 int32_t ctdb_control_get_public_ips(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA *outdata);
 int ctdb_ctrl_get_public_ips(struct ctdb_context *ctdb, 
-                       struct timeval timeout, uint32_t destnode, 
-                       TALLOC_CTX *mem_ctx, struct ctdb_all_public_ips **ips);
+                            struct timeval timeout,
+                            uint32_t destnode,
+                            TALLOC_CTX *mem_ctx,
+                            struct ctdb_all_public_ips **ips);
+#define CTDB_PUBLIC_IP_FLAGS_ONLY_AVAILABLE 0x00010000
+int ctdb_ctrl_get_public_ips_flags(struct ctdb_context *ctdb,
+                                  struct timeval timeout, uint32_t destnode,
+                                  TALLOC_CTX *mem_ctx,
+                                  uint32_t flags,
+                                  struct ctdb_all_public_ips **ips);
 int ctdb_ctrl_get_public_ipsv4(struct ctdb_context *ctdb, 
                        struct timeval timeout, uint32_t destnode, 
                        TALLOC_CTX *mem_ctx, struct ctdb_all_public_ips **ips);
 
+#ifdef IFNAMSIZ
+#define CTDB_IFACE_SIZE IFNAMSIZ
+#else
+#define CTDB_IFACE_SIZE 16
+#endif
+
+struct ctdb_control_iface_info {
+       char name[CTDB_IFACE_SIZE+2];
+       uint16_t link_state;
+       uint32_t references;
+};
+
+struct ctdb_control_public_ip_info {
+       struct ctdb_public_ip ip;
+       uint32_t active_idx;
+       uint32_t num;
+       struct ctdb_control_iface_info ifaces[1];
+};
+
+struct ctdb_control_get_ifaces {
+       uint32_t num;
+       struct ctdb_control_iface_info ifaces[1];
+};
+
+int32_t ctdb_control_get_public_ip_info(struct ctdb_context *ctdb,
+                                       struct ctdb_req_control *c,
+                                       TDB_DATA indata,
+                                       TDB_DATA *outdata);
+int32_t ctdb_control_get_ifaces(struct ctdb_context *ctdb,
+                               struct ctdb_req_control *c,
+                               TDB_DATA *outdata);
+int32_t ctdb_control_set_iface_link(struct ctdb_context *ctdb,
+                                   struct ctdb_req_control *c,
+                                   TDB_DATA indata);
+int ctdb_ctrl_get_public_ip_info(struct ctdb_context *ctdb,
+                                struct timeval timeout, uint32_t destnode,
+                                TALLOC_CTX *mem_ctx,
+                                const ctdb_sock_addr *addr,
+                                struct ctdb_control_public_ip_info **info);
+int ctdb_ctrl_get_ifaces(struct ctdb_context *ctdb,
+                        struct timeval timeout, uint32_t destnode,
+                        TALLOC_CTX *mem_ctx,
+                        struct ctdb_control_get_ifaces **ifaces);
+int ctdb_ctrl_set_iface_link(struct ctdb_context *ctdb,
+                            struct timeval timeout, uint32_t destnode,
+                            TALLOC_CTX *mem_ctx,
+                            const struct ctdb_control_iface_info *info);
 
 /* from takeover/system.c */
 uint32_t uint16_checksum(uint16_t *data, size_t n);
@@ -1322,6 +1103,9 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
                      uint32_t seq, uint32_t ack, int rst);
 
 int ctdb_set_public_addresses(struct ctdb_context *ctdb, const char *alist);
+int ctdb_set_single_public_ip(struct ctdb_context *ctdb,
+                             const char *iface,
+                             const char *ip);
 int ctdb_set_event_script(struct ctdb_context *ctdb, const char *script);
 int ctdb_set_event_script_dir(struct ctdb_context *ctdb, const char *script_dir);
 int ctdb_set_notification_script(struct ctdb_context *ctdb, const char *script);
@@ -1329,7 +1113,7 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap);
 
 int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id, 
                                TDB_DATA indata);
-int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata);
+int32_t ctdb_control_tcp_add(struct ctdb_context *ctdb, TDB_DATA indata, bool tcp_update_needed);
 int32_t ctdb_control_tcp_remove(struct ctdb_context *ctdb, TDB_DATA indata);
 int32_t ctdb_control_startup(struct ctdb_context *ctdb, uint32_t vnn);
 int32_t ctdb_control_kill_tcp(struct ctdb_context *ctdb, TDB_DATA indata);
@@ -1345,8 +1129,9 @@ int ctdb_event_script_callback(struct ctdb_context *ctdb,
                               TALLOC_CTX *mem_ctx,
                               void (*callback)(struct ctdb_context *, int, void *),
                               void *private_data,
+                              bool from_user,
                               enum ctdb_eventscript_call call,
-                              const char *fmt, ...) PRINTF_ATTRIBUTE(6,7);
+                              const char *fmt, ...) PRINTF_ATTRIBUTE(7,8);
 void ctdb_release_all_ips(struct ctdb_context *ctdb);
 
 void set_nonblocking(int fd);
@@ -1426,7 +1211,7 @@ int32_t ctdb_control_get_server_id_list(struct ctdb_context *ctdb,
 int32_t ctdb_control_uptime(struct ctdb_context *ctdb, 
                      TDB_DATA *outdata);
 
-int ctdb_attach_persistent(struct ctdb_context *ctdb);
+int ctdb_attach_databases(struct ctdb_context *ctdb);
 
 int32_t ctdb_control_persistent_store(struct ctdb_context *ctdb, 
                                      struct ctdb_req_control *c, 
@@ -1438,10 +1223,18 @@ int32_t ctdb_control_trans2_commit(struct ctdb_context *ctdb,
                                   struct ctdb_req_control *c, 
                                   TDB_DATA recdata, bool *async_reply);
 
+int32_t ctdb_control_trans3_commit(struct ctdb_context *ctdb,
+                                  struct ctdb_req_control *c,
+                                  TDB_DATA recdata, bool *async_reply);
+
 int32_t ctdb_control_transaction_start(struct ctdb_context *ctdb, uint32_t id);
 int32_t ctdb_control_transaction_commit(struct ctdb_context *ctdb, uint32_t id);
 int32_t ctdb_control_transaction_cancel(struct ctdb_context *ctdb);
 int32_t ctdb_control_wipe_database(struct ctdb_context *ctdb, TDB_DATA indata);
+int32_t ctdb_control_db_set_healthy(struct ctdb_context *ctdb, TDB_DATA indata);
+int32_t ctdb_control_db_get_health(struct ctdb_context *ctdb,
+                                  TDB_DATA indata,
+                                  TDB_DATA *outdata);
 
 
 int ctdb_vacuum(struct ctdb_context *ctdb, int argc, const char **argv);
@@ -1451,7 +1244,7 @@ void ctdb_block_signal(int signum);
 void ctdb_unblock_signal(int signum);
 int32_t ctdb_monitoring_mode(struct ctdb_context *ctdb);
 int ctdb_set_child_logging(struct ctdb_context *ctdb);
-
+void ctdb_lockdown_memory(struct ctdb_context *ctdb);
 
 typedef void (*client_async_callback)(struct ctdb_context *ctdb, uint32_t node_pnn, int32_t res, TDB_DATA outdata, void *callback_data);
 
@@ -1500,21 +1293,11 @@ int32_t ctdb_control_recd_ping(struct ctdb_context *ctdb);
 int32_t ctdb_control_set_recmaster(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata);
 
 extern int script_log_level;
+extern bool fast_start;
 
-int ctdb_ctrl_event_script_init(struct ctdb_context *ctdb);
-int ctdb_ctrl_event_script_start(struct ctdb_context *ctdb, const char *name);
-int ctdb_ctrl_event_script_stop(struct ctdb_context *ctdb, int32_t res);
-int ctdb_ctrl_event_script_finished(struct ctdb_context *ctdb);
-int ctdb_ctrl_event_script_disabled(struct ctdb_context *ctdb, const char *name);
-
-int32_t ctdb_control_event_script_init(struct ctdb_context *ctdb);
-int32_t ctdb_control_event_script_start(struct ctdb_context *ctdb, TDB_DATA indata);
-int32_t ctdb_control_event_script_stop(struct ctdb_context *ctdb, TDB_DATA indata);
-int32_t ctdb_control_event_script_disabled(struct ctdb_context *ctdb, TDB_DATA indata);
-int32_t ctdb_control_event_script_finished(struct ctdb_context *ctdb);
-
-
-int32_t ctdb_control_get_event_script_status(struct ctdb_context *ctdb, TDB_DATA *outdata);
+int32_t ctdb_control_get_event_script_status(struct ctdb_context *ctdb,
+                                            uint32_t call_type,
+                                            TDB_DATA *outdata);
 
 int ctdb_log_event_script_output(struct ctdb_context *ctdb, char *str, uint16_t len);
 int ctdb_ctrl_report_recd_lock_latency(struct ctdb_context *ctdb, struct timeval timeout, double latency);
@@ -1530,6 +1313,7 @@ int32_t ctdb_control_disable_script(struct ctdb_context *ctdb, TDB_DATA indata);
 int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata);
 int32_t ctdb_control_get_ban_state(struct ctdb_context *ctdb, TDB_DATA *outdata);
 int32_t ctdb_control_set_db_priority(struct ctdb_context *ctdb, TDB_DATA indata);
+void ctdb_ban_self(struct ctdb_context *ctdb);
 
 int32_t ctdb_control_register_notify(struct ctdb_context *ctdb, uint32_t client_id, TDB_DATA indata);
 
@@ -1537,4 +1321,46 @@ int32_t ctdb_control_deregister_notify(struct ctdb_context *ctdb, uint32_t clien
 
 int start_syslog_daemon(struct ctdb_context *ctdb);
 
+/* Where to send the log messages back to */
+struct ctdb_get_log_addr {
+       uint32_t pnn;
+       uint64_t srvid;
+       int32_t level;
+};
+
+extern int log_ringbuf_size;
+
+int32_t ctdb_control_get_log(struct ctdb_context *ctdb, TDB_DATA addr);
+int32_t ctdb_control_clear_log(struct ctdb_context *ctdb);
+
+
+struct ctdb_log_state *ctdb_fork_with_logging(TALLOC_CTX *mem_ctx,
+                                             struct ctdb_context *ctdb,
+                                             void (*logfn)(const char *, uint16_t, void *),
+                                             void *logfn_private, pid_t *pid);
+
+int32_t ctdb_control_process_exists(struct ctdb_context *ctdb, pid_t pid);
+struct ctdb_client *ctdb_find_client_by_pid(struct ctdb_context *ctdb, pid_t pid);
+
+int32_t ctdb_control_get_db_seqnum(struct ctdb_context *ctdb,
+                                  TDB_DATA indata,
+                                  TDB_DATA *outdata);
+
+int ctdb_load_persistent_health(struct ctdb_context *ctdb,
+                               struct ctdb_db_context *ctdb_db);
+int ctdb_update_persistent_health(struct ctdb_context *ctdb,
+                                 struct ctdb_db_context *ctdb_db,
+                                 const char *reason,/* NULL means healthy */
+                                 int num_healthy_nodes);
+int ctdb_recheck_persistent_health(struct ctdb_context *ctdb);
+
+void ctdb_run_notification_script(struct ctdb_context *ctdb, const char *event);
+
+void ctdb_fault_setup(void);
+
+int verify_remote_ip_allocation(struct ctdb_context *ctdb, 
+                               struct ctdb_all_public_ips *ips);
+int update_ip_assignment_tree(struct ctdb_context *ctdb,
+                               struct ctdb_public_ip *ip);
+
 #endif