ctdb-tools: Drop support for setting and viewing NAT gateway capability
[ambi/samba-autobuild/.git] / ctdb / tools / ctdb.c
index 17fc258febaa50e4bc79080afd36ca64f7dfef55..61ab8960bc6055a50e607bbcf089dff8dda38d71 100644 (file)
@@ -37,7 +37,6 @@
 #include "lib/util/substitute.h"
 #include "lib/util/time.h"
 
-#include "ctdb_logging.h"
 #include "ctdb_version.h"
 #include "ctdb_private.h"
 #include "ctdb_client.h"
@@ -46,6 +45,7 @@
 #include "common/rb_tree.h"
 #include "common/system.h"
 #include "common/common.h"
+#include "common/logging.h"
 
 #define ERR_TIMEOUT    20      /* timed out trying to reach node */
 #define ERR_NONODE     21      /* node does not exist */
@@ -364,7 +364,7 @@ static bool db_exists(struct ctdb_context *ctdb, const char *dbarg,
                      uint32_t *dbid, const char **dbname, uint8_t *flags)
 {
        int i, ret;
-       struct ctdb_dbid_map *dbmap=NULL;
+       struct ctdb_dbid_map_old *dbmap=NULL;
        bool dbid_given = false, found = false;
        uint32_t id;
        TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
@@ -383,19 +383,19 @@ static bool db_exists(struct ctdb_context *ctdb, const char *dbarg,
 
        for(i=0; i<dbmap->num; i++) {
                if (dbid_given) {
-                       if (id == dbmap->dbs[i].dbid) {
+                       if (id == dbmap->dbs[i].db_id) {
                                found = true;
                                break;
                        }
                } else {
-                       ret = ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].dbid, tmp_ctx, &name);
+                       ret = ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].db_id, tmp_ctx, &name);
                        if (ret != 0) {
-                               DEBUG(DEBUG_ERR, ("Unable to get dbname from dbid %u\n", dbmap->dbs[i].dbid));
+                               DEBUG(DEBUG_ERR, ("Unable to get dbname from dbid %u\n", dbmap->dbs[i].db_id));
                                goto fail;
                        }
 
                        if (strcmp(name, dbarg) == 0) {
-                               id = dbmap->dbs[i].dbid;
+                               id = dbmap->dbs[i].db_id;
                                found = true;
                                break;
                        }
@@ -403,9 +403,9 @@ static bool db_exists(struct ctdb_context *ctdb, const char *dbarg,
        }
 
        if (found && dbid_given && dbname != NULL) {
-               ret = ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].dbid, tmp_ctx, &name);
+               ret = ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].db_id, tmp_ctx, &name);
                if (ret != 0) {
-                       DEBUG(DEBUG_ERR, ("Unable to get dbname from dbid %u\n", dbmap->dbs[i].dbid));
+                       DEBUG(DEBUG_ERR, ("Unable to get dbname from dbid %u\n", dbmap->dbs[i].db_id));
                        found = false;
                        goto fail;
                }
@@ -733,7 +733,7 @@ static int control_stats(struct ctdb_context *ctdb, int argc, const char **argv)
 static int control_dbstatistics(struct ctdb_context *ctdb, int argc, const char **argv)
 {
        TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
-       struct ctdb_db_statistics *dbstat;
+       struct ctdb_db_statistics_old *dbstat;
        int i;
        uint32_t db_id;
        int num_hot_keys;
@@ -961,7 +961,7 @@ static bool is_partially_online(struct ctdb_context *ctdb, struct ctdb_node_and_
        bool ret = false;
 
        if (node->flags == 0) {
-               struct ctdb_control_get_ifaces *ifaces;
+               struct ctdb_iface_list_old *ifaces;
 
                if (ctdb_ctrl_get_ifaces(ctdb, TIMELIMIT(), node->pnn,
                                         tmp_ctx, &ifaces) == 0) {
@@ -1150,31 +1150,6 @@ static int control_nodestatus(struct ctdb_context *ctdb, int argc, const char **
        return ret;
 }
 
-static struct ctdb_node_map_old *read_natgw_nodes_file(struct ctdb_context *ctdb,
-                                                  TALLOC_CTX *mem_ctx)
-{
-       const char *natgw_list;
-       struct ctdb_node_map_old *natgw_nodes = NULL;
-
-       natgw_list = getenv("CTDB_NATGW_NODES");
-       if (natgw_list == NULL) {
-               natgw_list = talloc_asprintf(mem_ctx, "%s/natgw_nodes",
-                                            getenv("CTDB_BASE"));
-               if (natgw_list == NULL) {
-                       DEBUG(DEBUG_ALERT,(__location__ " Out of memory\n"));
-                       exit(1);
-               }
-       }
-       /* The PNNs/flags will be junk but they're not used */
-       natgw_nodes = ctdb_read_nodes_file(mem_ctx, natgw_list);
-       if (natgw_nodes == NULL) {
-               DEBUG(DEBUG_ERR,
-                     ("Failed to load natgw node list '%s'\n", natgw_list));
-       }
-       return natgw_nodes;
-}
-
-
 /* talloc off the existing nodemap... */
 static struct ctdb_node_map_old *talloc_nodemap(struct ctdb_node_map_old *nodemap)
 {
@@ -1183,37 +1158,6 @@ static struct ctdb_node_map_old *talloc_nodemap(struct ctdb_node_map_old *nodema
                                nodemap->num * sizeof(struct ctdb_node_and_flags));
 }
 
-static struct ctdb_node_map_old *
-filter_nodemap_by_addrs(struct ctdb_context *ctdb,
-                       struct ctdb_node_map_old *nodemap,
-                       struct ctdb_node_map_old *natgw_nodes)
-{
-       int i, j;
-       struct ctdb_node_map_old *ret;
-
-       ret = talloc_nodemap(nodemap);
-       CTDB_NO_MEMORY_NULL(ctdb, ret);
-
-       ret->num = 0;
-
-       for (i = 0; i < nodemap->num; i++) {
-               for(j = 0; j < natgw_nodes->num ; j++) {
-                       if (nodemap->nodes[j].flags & NODE_FLAGS_DELETED) {
-                               continue;
-                       }
-                       if (ctdb_same_ip(&natgw_nodes->nodes[j].addr,
-                                        &nodemap->nodes[i].addr)) {
-
-                               ret->nodes[ret->num] = nodemap->nodes[i];
-                               ret->num++;
-                               break;
-                       }
-               }
-       }
-
-       return ret;
-}
-
 static struct ctdb_node_map_old *
 filter_nodemap_by_capabilities(struct ctdb_context *ctdb,
                               struct ctdb_node_map_old *nodemap,
@@ -1290,116 +1234,24 @@ filter_nodemap_by_flags(struct ctdb_context *ctdb,
  */
 static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **argv)
 {
-       TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
-       int i, ret;
-       struct ctdb_node_map_old *natgw_nodes = NULL;
-       struct ctdb_node_map_old *orig_nodemap=NULL;
-       struct ctdb_node_map_old *nodemap;
-       uint32_t mypnn, pnn;
-       const char *ip;
-
-       /* When we have some nodes that could be the NATGW, make a
-        * series of attempts to find the first node that doesn't have
-        * certain status flags set.
-        */
-       uint32_t exclude_flags[] = {
-               /* Look for a nice healthy node */
-               NODE_FLAGS_DISCONNECTED|NODE_FLAGS_STOPPED|NODE_FLAGS_DELETED|NODE_FLAGS_BANNED|NODE_FLAGS_UNHEALTHY,
-               /* If not found, an UNHEALTHY/BANNED node will do */
-               NODE_FLAGS_DISCONNECTED|NODE_FLAGS_STOPPED|NODE_FLAGS_DELETED,
-               /* If not found, a STOPPED node will do */
-               NODE_FLAGS_DISCONNECTED|NODE_FLAGS_DELETED,
-               0,
-       };
-
-       /* read the natgw nodes file into a linked list */
-       natgw_nodes = read_natgw_nodes_file(ctdb, tmp_ctx);
-       if (natgw_nodes == NULL) {
-               ret = -1;
-               goto done;
-       }
+       static char prog[PATH_MAX+1] = "";
 
-       ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE,
-                                  tmp_ctx, &orig_nodemap);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR, ("Unable to get nodemap from local node.\n"));
-               talloc_free(tmp_ctx);
-               return -1;
-       }
-
-       /* Get a nodemap that includes only the nodes in the NATGW
-        * group */
-       nodemap = filter_nodemap_by_addrs(ctdb, orig_nodemap, natgw_nodes);
-       if (nodemap == NULL) {
-               ret = -1;
-               goto done;
-       }
-
-       ret = 2; /* matches ENOENT */
-       pnn = -1;
-       ip = "0.0.0.0";
-       /* For each flag mask... */
-       for (i = 0; exclude_flags[i] != 0; i++) {
-               /* ... get a nodemap that excludes nodes with with
-                * masked flags... */
-               struct ctdb_node_map_old *t =
-                       filter_nodemap_by_flags(ctdb, nodemap,
-                                               exclude_flags[i]);
-               if (t == NULL) {
-                       /* No memory */
-                       ret = -1;
-                       goto done;
-               }
-               if (t->num > 0) {
-                       /* ... and find the first node with the NATGW
-                        * capability */
-                       struct ctdb_node_map_old *n;
-                       n = filter_nodemap_by_capabilities(ctdb, t,
-                                                          CTDB_CAP_NATGW,
-                                                          true);
-                       if (n == NULL) {
-                               /* No memory */
-                               ret = -1;
-                               goto done;
-                       }
-                       if (n->num > 0) {
-                               ret = 0;
-                               pnn = n->nodes[0].pnn;
-                               ip = ctdb_addr_to_str(&n->nodes[0].addr);
-                               break;
-                       }
-               }
-               talloc_free(t);
+       if (argc != 0) {
+               usage();
        }
 
-       if (options.machinereadable) {
-               printm(":Node:IP:\n");
-               printm(":%d:%s:\n", pnn, ip);
-       } else {
-               printf("%d %s\n", pnn, ip);
+       if (!ctdb_set_helper("NAT gateway helper", prog, sizeof(prog),
+                            "CTDB_NATGW_HELPER", CTDB_HELPER_BINDIR,
+                            "ctdb_natgw")) {
+               DEBUG(DEBUG_ERR, ("Unable to set NAT gateway helper\n"));
+               exit(1);
        }
 
-       /* print the pruned list of nodes belonging to this natgw list */
-       mypnn = getpnn(ctdb);
-       if (options.machinereadable) {
-               control_status_header_machine();
-       } else {
-               printf("Number of nodes:%d\n", nodemap->num);
-       }
-       for(i=0;i<nodemap->num;i++){
-               if (nodemap->nodes[i].flags & NODE_FLAGS_DELETED) {
-                       continue;
-               }
-               if (options.machinereadable) {
-                       control_status_1_machine(ctdb, mypnn, &(nodemap->nodes[i]));
-               } else {
-                       control_status_1_human(ctdb, mypnn, &(nodemap->nodes[i]));
-               }
-       }
+       execl(prog, prog, "natgwlist", NULL);
 
-done:
-       talloc_free(tmp_ctx);
-       return ret;
+       DEBUG(DEBUG_ERR,
+             ("Unable to run NAT gateway helper %s\n", strerror(errno)));
+       exit(1);
 }
 
 /*
@@ -1615,7 +1467,7 @@ static int control_recmaster(struct ctdb_context *ctdb, int argc, const char **a
  */
 static int control_add_tickle(struct ctdb_context *ctdb, int argc, const char **argv)
 {
-       struct ctdb_tcp_connection t;
+       struct ctdb_connection t;
        TDB_DATA data;
        int ret;
 
@@ -1625,11 +1477,11 @@ static int control_add_tickle(struct ctdb_context *ctdb, int argc, const char **
                usage();
        }
 
-       if (parse_ip_port(argv[0], &t.src_addr) == 0) {
+       if (parse_ip_port(argv[0], &t.src) == 0) {
                DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[0]));
                return -1;
        }
-       if (parse_ip_port(argv[1], &t.dst_addr) == 0) {
+       if (parse_ip_port(argv[1], &t.dst) == 0) {
                DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[1]));
                return -1;
        }
@@ -1654,7 +1506,7 @@ static int control_add_tickle(struct ctdb_context *ctdb, int argc, const char **
  */
 static int control_del_tickle(struct ctdb_context *ctdb, int argc, const char **argv)
 {
-       struct ctdb_tcp_connection t;
+       struct ctdb_connection t;
        TDB_DATA data;
        int ret;
 
@@ -1664,11 +1516,11 @@ static int control_del_tickle(struct ctdb_context *ctdb, int argc, const char **
                usage();
        }
 
-       if (parse_ip_port(argv[0], &t.src_addr) == 0) {
+       if (parse_ip_port(argv[0], &t.src) == 0) {
                DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[0]));
                return -1;
        }
-       if (parse_ip_port(argv[1], &t.dst_addr) == 0) {
+       if (parse_ip_port(argv[1], &t.dst) == 0) {
                DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[1]));
                return -1;
        }
@@ -1693,7 +1545,7 @@ static int control_del_tickle(struct ctdb_context *ctdb, int argc, const char **
  */
 static int control_get_tickles(struct ctdb_context *ctdb, int argc, const char **argv)
 {
-       struct ctdb_control_tcp_tickle_list *list;
+       struct ctdb_tickle_list_old *list;
        ctdb_sock_addr addr;
        int i, ret;
        unsigned port = 0;
@@ -1721,22 +1573,22 @@ static int control_get_tickles(struct ctdb_context *ctdb, int argc, const char *
 
        if (options.machinereadable){
                printm(":source ip:port:destination ip:port:\n");
-               for (i=0;i<list->tickles.num;i++) {
-                       if (port && port != ntohs(list->tickles.connections[i].dst_addr.ip.sin_port)) {
+               for (i=0;i<list->num;i++) {
+                       if (port && port != ntohs(list->connections[i].dst.ip.sin_port)) {
                                continue;
                        }
-                       printm(":%s:%u", ctdb_addr_to_str(&list->tickles.connections[i].src_addr), ntohs(list->tickles.connections[i].src_addr.ip.sin_port));
-                       printm(":%s:%u:\n", ctdb_addr_to_str(&list->tickles.connections[i].dst_addr), ntohs(list->tickles.connections[i].dst_addr.ip.sin_port));
+                       printm(":%s:%u", ctdb_addr_to_str(&list->connections[i].src), ntohs(list->connections[i].src.ip.sin_port));
+                       printm(":%s:%u:\n", ctdb_addr_to_str(&list->connections[i].dst), ntohs(list->connections[i].dst.ip.sin_port));
                }
        } else {
                printf("Tickles for ip:%s\n", ctdb_addr_to_str(&list->addr));
-               printf("Num tickles:%u\n", list->tickles.num);
-               for (i=0;i<list->tickles.num;i++) {
-                       if (port && port != ntohs(list->tickles.connections[i].dst_addr.ip.sin_port)) {
+               printf("Num tickles:%u\n", list->num);
+               for (i=0;i<list->num;i++) {
+                       if (port && port != ntohs(list->connections[i].dst.ip.sin_port)) {
                                continue;
                        }
-                       printf("SRC: %s:%u   ", ctdb_addr_to_str(&list->tickles.connections[i].src_addr), ntohs(list->tickles.connections[i].src_addr.ip.sin_port));
-                       printf("DST: %s:%u\n", ctdb_addr_to_str(&list->tickles.connections[i].dst_addr), ntohs(list->tickles.connections[i].dst_addr.ip.sin_port));
+                       printf("SRC: %s:%u   ", ctdb_addr_to_str(&list->connections[i].src), ntohs(list->connections[i].src.ip.sin_port));
+                       printf("DST: %s:%u\n", ctdb_addr_to_str(&list->connections[i].dst), ntohs(list->connections[i].dst.ip.sin_port));
                }
        }
 
@@ -2259,8 +2111,8 @@ static int srvid_broadcast(struct ctdb_context *ctdb,
        TDB_DATA data;
        uint32_t pnn;
        uint64_t reply_srvid;
-       struct srvid_request request;
-       struct srvid_request_data request_data;
+       struct ctdb_srvid_message request;
+       struct ctdb_disable_message request_data;
        struct srvid_reply_handler_data reply_data;
        struct timeval tv;
 
@@ -2282,7 +2134,7 @@ static int srvid_broadcast(struct ctdb_context *ctdb,
        } else {
                request_data.pnn = pnn;
                request_data.srvid = reply_srvid;
-               request_data.data = *arg;
+               request_data.timeout = *arg;
 
                data.dptr = (uint8_t *)&request_data;
                data.dsize = sizeof(request_data);
@@ -2376,7 +2228,7 @@ static int control_addip(struct ctdb_context *ctdb, int argc, const char **argv)
        int len, retries = 0;
        unsigned mask;
        ctdb_sock_addr addr;
-       struct ctdb_control_ip_iface *pub;
+       struct ctdb_addr_info_old *pub;
        TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
        struct ctdb_public_ip_list_old *ips;
 
@@ -2414,7 +2266,7 @@ static int control_addip(struct ctdb_context *ctdb, int argc, const char **argv)
        */
        alarm(0);
 
-       len = offsetof(struct ctdb_control_ip_iface, iface) + strlen(argv[1]) + 1;
+       len = offsetof(struct ctdb_addr_info_old, iface) + strlen(argv[1]) + 1;
        pub = talloc_size(tmp_ctx, len); 
        CTDB_NO_MEMORY(ctdb, pub);
 
@@ -2555,7 +2407,7 @@ static int control_delip(struct ctdb_context *ctdb, int argc, const char **argv)
 {
        int i, ret;
        ctdb_sock_addr addr;
-       struct ctdb_control_ip_iface pub;
+       struct ctdb_addr_info_old pub;
        TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
        struct ctdb_public_ip_list_old *ips;
 
@@ -2619,7 +2471,7 @@ static int control_delip(struct ctdb_context *ctdb, int argc, const char **argv)
 static int kill_tcp_from_file(struct ctdb_context *ctdb,
                              int argc, const char **argv)
 {
-       struct ctdb_tcp_connection *killtcp;
+       struct ctdb_connection *killtcp;
        int max_entries, current, i;
        struct timeval timeout;
        char line[128], src[128], dst[128];
@@ -2656,19 +2508,19 @@ static int kill_tcp_from_file(struct ctdb_context *ctdb,
                if (current >= max_entries) {
                        max_entries += 1024;
                        killtcp = talloc_realloc(ctdb, killtcp,
-                                                struct ctdb_tcp_connection,
+                                                struct ctdb_connection,
                                                 max_entries);
                        CTDB_NO_MEMORY(ctdb, killtcp);
                }
 
-               if (!parse_ip_port(src, &killtcp[current].src_addr)) {
+               if (!parse_ip_port(src, &killtcp[current].src)) {
                        DEBUG(DEBUG_ERR, ("Bad IP:port on line [%d]: '%s'\n",
                                          linenum, src));
                        talloc_free(killtcp);
                        return -1;
                }
 
-               if (!parse_ip_port(dst, &killtcp[current].dst_addr)) {
+               if (!parse_ip_port(dst, &killtcp[current].dst)) {
                        DEBUG(DEBUG_ERR, ("Bad IP:port on line [%d]: '%s'\n",
                                          linenum, dst));
                        talloc_free(killtcp);
@@ -2686,7 +2538,7 @@ static int kill_tcp_from_file(struct ctdb_context *ctdb,
 
        for (i = 0; i < current; i++) {
 
-               data.dsize = sizeof(struct ctdb_tcp_connection);
+               data.dsize = sizeof(struct ctdb_connection);
                data.dptr  = (unsigned char *)&killtcp[i];
 
                timeout = TIMELIMIT();
@@ -2722,7 +2574,7 @@ static int kill_tcp_from_file(struct ctdb_context *ctdb,
 static int kill_tcp(struct ctdb_context *ctdb, int argc, const char **argv)
 {
        int ret;
-       struct ctdb_tcp_connection killtcp;
+       struct ctdb_connection killtcp;
 
        assert_single_node_only();
 
@@ -2734,12 +2586,12 @@ static int kill_tcp(struct ctdb_context *ctdb, int argc, const char **argv)
                usage();
        }
 
-       if (!parse_ip_port(argv[0], &killtcp.src_addr)) {
+       if (!parse_ip_port(argv[0], &killtcp.src)) {
                DEBUG(DEBUG_ERR, ("Bad IP:port '%s'\n", argv[0]));
                return -1;
        }
 
-       if (!parse_ip_port(argv[1], &killtcp.dst_addr)) {
+       if (!parse_ip_port(argv[1], &killtcp.dst)) {
                DEBUG(DEBUG_ERR, ("Bad IP:port '%s'\n", argv[1]));
                return -1;
        }
@@ -2788,7 +2640,7 @@ static int control_gratious_arp(struct ctdb_context *ctdb, int argc, const char
 static int regsrvid(struct ctdb_context *ctdb, int argc, const char **argv)
 {
        int ret;
-       struct ctdb_server_id server_id;
+       struct ctdb_client_id server_id;
 
        if (argc < 3) {
                usage();
@@ -2814,7 +2666,7 @@ static int regsrvid(struct ctdb_context *ctdb, int argc, const char **argv)
 static int unregsrvid(struct ctdb_context *ctdb, int argc, const char **argv)
 {
        int ret;
-       struct ctdb_server_id server_id;
+       struct ctdb_client_id server_id;
 
        if (argc < 3) {
                usage();
@@ -2839,7 +2691,7 @@ static int chksrvid(struct ctdb_context *ctdb, int argc, const char **argv)
 {
        uint32_t status = 0;
        int ret;
-       struct ctdb_server_id server_id;
+       struct ctdb_client_id server_id;
 
        if (argc < 3) {
                usage();
@@ -2869,7 +2721,7 @@ static int chksrvid(struct ctdb_context *ctdb, int argc, const char **argv)
 static int getsrvids(struct ctdb_context *ctdb, int argc, const char **argv)
 {
        int i, ret;
-       struct ctdb_server_id_list *server_ids;
+       struct ctdb_client_id_list_old *server_ids;
 
        ret = ctdb_ctrl_get_server_id_list(ctdb, ctdb, TIMELIMIT(), options.pnn, &server_ids);
        if (ret != 0) {
@@ -2998,7 +2850,7 @@ static int control_ip(struct ctdb_context *ctdb, int argc, const char **argv)
        }
 
        for (i=1;i<=ips->num;i++) {
-               struct ctdb_control_public_ip_info *info = NULL;
+               struct ctdb_public_ip_info_old *info = NULL;
                int32_t pnn;
                char *aciface = NULL;
                char *avifaces = NULL;
@@ -3087,7 +2939,7 @@ static int control_ipinfo(struct ctdb_context *ctdb, int argc, const char **argv
        int i, ret;
        ctdb_sock_addr addr;
        TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
-       struct ctdb_control_public_ip_info *info;
+       struct ctdb_public_ip_info_old *info;
 
        if (argc != 1) {
                talloc_free(tmp_ctx);
@@ -3138,7 +2990,7 @@ static int control_ifaces(struct ctdb_context *ctdb, int argc, const char **argv
 {
        TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
        int i;
-       struct ctdb_control_get_ifaces *ifaces;
+       struct ctdb_iface_list_old *ifaces;
        int ret;
 
        /* read the public ip list from this node */
@@ -3182,7 +3034,7 @@ static int control_setifacelink(struct ctdb_context *ctdb, int argc, const char
 {
        int ret;
        TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
-       struct ctdb_control_iface_info info;
+       struct ctdb_iface info;
 
        ZERO_STRUCT(info);
 
@@ -3420,7 +3272,7 @@ static uint32_t get_generation(struct ctdb_context *ctdb)
 /* Ban a node */
 static bool update_state_banned(struct ctdb_context *ctdb, void *data)
 {
-       struct ctdb_ban_time *bantime = (struct ctdb_ban_time *)data;
+       struct ctdb_ban_state *bantime = (struct ctdb_ban_state *)data;
        int ret;
 
        ret = ctdb_ctrl_set_ban(ctdb, TIMELIMIT(), options.pnn, bantime);
@@ -3430,7 +3282,7 @@ static bool update_state_banned(struct ctdb_context *ctdb, void *data)
 
 static int control_ban(struct ctdb_context *ctdb, int argc, const char **argv)
 {
-       struct ctdb_ban_time bantime;
+       struct ctdb_ban_state bantime;
 
        if (argc < 1) {
                usage();
@@ -3455,7 +3307,7 @@ static int control_ban(struct ctdb_context *ctdb, int argc, const char **argv)
 /* Unban a node */
 static int control_unban(struct ctdb_context *ctdb, int argc, const char **argv)
 {
-       struct ctdb_ban_time bantime;
+       struct ctdb_ban_state bantime;
 
        bantime.pnn  = options.pnn;
        bantime.time = 0;
@@ -3474,7 +3326,7 @@ static int control_showban(struct ctdb_context *ctdb, int argc, const char **arg
 {
        int ret;
        struct ctdb_node_map_old *nodemap=NULL;
-       struct ctdb_ban_time *bantime;
+       struct ctdb_ban_state *bantime;
 
        /* verify the node exists */
        ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE, ctdb, &nodemap);
@@ -3581,19 +3433,17 @@ static int control_getcapabilities(struct ctdb_context *ctdb, int argc, const ch
                DEBUG(DEBUG_ERR, ("Unable to get capabilities from node %u\n", options.pnn));
                return -1;
        }
-       
+
        if (!options.machinereadable){
                printf("RECMASTER: %s\n", (capabilities&CTDB_CAP_RECMASTER)?"YES":"NO");
                printf("LMASTER: %s\n", (capabilities&CTDB_CAP_LMASTER)?"YES":"NO");
                printf("LVS: %s\n", (capabilities&CTDB_CAP_LVS)?"YES":"NO");
-               printf("NATGW: %s\n", (capabilities&CTDB_CAP_NATGW)?"YES":"NO");
        } else {
-               printm(":RECMASTER:LMASTER:LVS:NATGW:\n");
-               printm(":%d:%d:%d:%d:\n",
+               printm(":RECMASTER:LMASTER:LVS:\n");
+               printm(":%d:%d:%d:\n",
                        !!(capabilities&CTDB_CAP_RECMASTER),
                        !!(capabilities&CTDB_CAP_LMASTER),
-                       !!(capabilities&CTDB_CAP_LVS),
-                       !!(capabilities&CTDB_CAP_NATGW));
+                       !!(capabilities&CTDB_CAP_LVS));
        }
        return 0;
 }
@@ -4610,7 +4460,7 @@ done:
 static int control_getdbmap(struct ctdb_context *ctdb, int argc, const char **argv)
 {
        int i, ret;
-       struct ctdb_dbid_map *dbmap=NULL;
+       struct ctdb_dbid_map_old *dbmap=NULL;
 
        ret = ctdb_ctrl_getdbmap(ctdb, TIMELIMIT(), options.pnn, ctdb, &dbmap);
        if (ret != 0) {
@@ -4629,16 +4479,16 @@ static int control_getdbmap(struct ctdb_context *ctdb, int argc, const char **ar
                        bool sticky;
 
                        ctdb_ctrl_getdbpath(ctdb, TIMELIMIT(), options.pnn,
-                                           dbmap->dbs[i].dbid, ctdb, &path);
+                                           dbmap->dbs[i].db_id, ctdb, &path);
                        ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn,
-                                           dbmap->dbs[i].dbid, ctdb, &name);
+                                           dbmap->dbs[i].db_id, ctdb, &name);
                        ctdb_ctrl_getdbhealth(ctdb, TIMELIMIT(), options.pnn,
-                                             dbmap->dbs[i].dbid, ctdb, &health);
+                                             dbmap->dbs[i].db_id, ctdb, &health);
                        persistent = dbmap->dbs[i].flags & CTDB_DB_FLAGS_PERSISTENT;
                        readonly   = dbmap->dbs[i].flags & CTDB_DB_FLAGS_READONLY;
                        sticky     = dbmap->dbs[i].flags & CTDB_DB_FLAGS_STICKY;
                        printm(":0x%08X:%s:%s:%d:%d:%d:%d:\n",
-                              dbmap->dbs[i].dbid, name, path,
+                              dbmap->dbs[i].db_id, name, path,
                               !!(persistent), !!(sticky),
                               !!(health), !!(readonly));
                }
@@ -4654,14 +4504,14 @@ static int control_getdbmap(struct ctdb_context *ctdb, int argc, const char **ar
                bool readonly;
                bool sticky;
 
-               ctdb_ctrl_getdbpath(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].dbid, ctdb, &path);
-               ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].dbid, ctdb, &name);
-               ctdb_ctrl_getdbhealth(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].dbid, ctdb, &health);
+               ctdb_ctrl_getdbpath(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].db_id, ctdb, &path);
+               ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].db_id, ctdb, &name);
+               ctdb_ctrl_getdbhealth(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].db_id, ctdb, &health);
                persistent = dbmap->dbs[i].flags & CTDB_DB_FLAGS_PERSISTENT;
                readonly   = dbmap->dbs[i].flags & CTDB_DB_FLAGS_READONLY;
                sticky     = dbmap->dbs[i].flags & CTDB_DB_FLAGS_STICKY;
                printf("dbid:0x%08x name:%s path:%s%s%s%s%s\n",
-                      dbmap->dbs[i].dbid, name, path,
+                      dbmap->dbs[i].db_id, name, path,
                       persistent?" PERSISTENT":"",
                       sticky?" STICKY":"",
                       readonly?" READONLY":"",
@@ -4883,7 +4733,8 @@ static int control_getdebug(struct ctdb_context *ctdb, int argc, const char **ar
                DEBUG(DEBUG_ERR, ("Unable to get debuglevel response from node %u\n", options.pnn));
                return ret;
        } else {
-               const char *desc = get_debug_by_level(level);
+               enum debug_level log_level = debug_level_from_int(level);
+               const char *desc = debug_level_to_string(log_level);
                if (desc == NULL) {
                        /* This should never happen */
                        desc = "Unknown";
@@ -4951,35 +4802,6 @@ static int control_setreclock(struct ctdb_context *ctdb, int argc, const char **
        return 0;
 }
 
-/*
-  set the natgw state on/off
- */
-static int control_setnatgwstate(struct ctdb_context *ctdb, int argc, const char **argv)
-{
-       int ret;
-       uint32_t natgwstate = 0;
-
-       if (argc == 0) {
-               usage();
-       }
-
-       if (!strcmp(argv[0], "on")) {
-               natgwstate = 1;
-       } else if (!strcmp(argv[0], "off")) {
-               natgwstate = 0;
-       } else {
-               usage();
-       }
-
-       ret = ctdb_ctrl_setnatgwstate(ctdb, TIMELIMIT(), options.pnn, natgwstate);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR, ("Unable to set the natgw state for node %u\n", options.pnn));
-               return ret;
-       }
-
-       return 0;
-}
-
 /*
   set the lmaster role on/off
  */
@@ -5045,19 +4867,22 @@ static int control_setdebug(struct ctdb_context *ctdb, int argc, const char **ar
 {
        int ret;
        int32_t level;
+       enum debug_level log_level;
 
        if (argc == 0) {
                printf("You must specify the debug level. Valid levels are:\n");
-               print_debug_levels(stdout);
+               printf("\tERROR | WARNING | NOTICE | INFO | DEBUG\n");
                return 0;
        }
 
-       if (!parse_debug(argv[0], &level)) {
+       if (!debug_level_parse(argv[0], &log_level)) {
                printf("Invalid debug level, must be one of\n");
-               print_debug_levels(stdout);
+               printf("\tERROR | WARNING | NOTICE | INFO | DEBUG\n");
                return -1;
        }
 
+       level = debug_level_to_int(log_level);
+
        ret = ctdb_ctrl_set_debuglevel(ctdb, options.pnn, level);
        if (ret != 0) {
                DEBUG(DEBUG_ERR, ("Unable to set debug level on node %u\n", options.pnn));
@@ -5600,7 +5425,7 @@ static int control_restoredb(struct ctdb_context *ctdb, int argc, const char **a
        struct ctdb_node_map_old *nodemap=NULL;
        struct ctdb_vnn_map *vnnmap=NULL;
        int i, fh;
-       struct ctdb_control_transdb w;
+       struct ctdb_transdb w;
        uint32_t *nodes;
        uint32_t generation;
        struct tm *tm;
@@ -5706,7 +5531,7 @@ static int control_restoredb(struct ctdb_context *ctdb, int argc, const char **a
 
 
        w.db_id = ctdb_db->db_id;
-       w.transaction_id = generation;
+       w.tid = generation;
 
        data.dptr = (void *)&w;
        data.dsize = sizeof(w);
@@ -5881,7 +5706,7 @@ static int control_wipedb(struct ctdb_context *ctdb, int argc,
        struct ctdb_node_map_old *nodemap = NULL;
        struct ctdb_vnn_map *vnnmap = NULL;
        int i;
-       struct ctdb_control_transdb w;
+       struct ctdb_transdb w;
        uint32_t *nodes;
        uint32_t generation;
        uint8_t flags;
@@ -5959,7 +5784,7 @@ static int control_wipedb(struct ctdb_context *ctdb, int argc,
        }
 
        w.db_id = ctdb_db->db_id;
-       w.transaction_id = generation;
+       w.tid = generation;
 
        data.dptr = (void *)&w;
        data.dsize = sizeof(w);
@@ -6066,7 +5891,7 @@ static int control_rddumpmemory(struct ctdb_context *ctdb, int argc, const char
 {
        int ret;
        TDB_DATA data;
-       struct srvid_request rd;
+       struct ctdb_srvid_message rd;
 
        rd.pnn = ctdb_get_pnn(ctdb);
        rd.srvid = getpid();
@@ -6554,11 +6379,10 @@ static const struct {
        { "scriptstatus",     control_scriptstatus,     true,   false, "show the status of the monitoring scripts (or all scripts)", "[all]"},
        { "enablescript",     control_enablescript,  true,      false, "enable an eventscript", "<script>"},
        { "disablescript",    control_disablescript,  true,     false, "disable an eventscript", "<script>"},
-       { "natgwlist",        control_natgwlist,        true,   false, "show the nodes belonging to this natgw configuration"},
+       { "natgwlist",        control_natgwlist,        false,  true, "show the nodes belonging to this natgw configuration"},
        { "xpnn",             control_xpnn,             false,  true,  "find the pnn of the local node without talking to the daemon (unreliable)" },
        { "getreclock",       control_getreclock,       true,   false, "Show the reclock file of a node"},
        { "setreclock",       control_setreclock,       true,   false, "Set/clear the reclock file of a node", "[filename]"},
-       { "setnatgwstate",    control_setnatgwstate,    false,  false, "Set NATGW state to on/off", "{on|off}"},
        { "setlmasterrole",   control_setlmasterrole,   false,  false, "Set LMASTER role to on/off", "{on|off}"},
        { "setrecmasterrole", control_setrecmasterrole, false,  false, "Set RECMASTER role to on/off", "{on|off}"},
        { "setdbprio",        control_setdbprio,        false,  false, "Set DB priority", "<dbname|dbid> <prio:1-3>"},