summaryrefslogtreecommitdiff
path: root/ctdb/tests
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2017-09-19 23:38:31 +1000
committerMartin Schwenke <martins@samba.org>2017-10-05 05:19:21 +0200
commit330436bd6ca4ec2700fd3b493bfd569c4ec81e4e (patch)
treed688dcad411eacf1186ecc375787f7cb74eb10b5 /ctdb/tests
parenta0051b80d5126cca879bb1add24212020f9d5810 (diff)
downloadsamba-330436bd6ca4ec2700fd3b493bfd569c4ec81e4e.tar.gz
ctdb-tests: Replace parse_ip() -> ctdb_sock_addr_from_string()
... and ctdb_sock_addr_set_port() where required. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/tests')
-rw-r--r--ctdb/tests/src/fake_ctdbd.c17
-rw-r--r--ctdb/tests/src/ipalloc_read_known_ips.c6
2 files changed, 16 insertions, 7 deletions
diff --git a/ctdb/tests/src/fake_ctdbd.c b/ctdb/tests/src/fake_ctdbd.c
index 98aacbe37df..06b5b2265c9 100644
--- a/ctdb/tests/src/fake_ctdbd.c
+++ b/ctdb/tests/src/fake_ctdbd.c
@@ -37,7 +37,6 @@
#include "protocol/protocol_util.h"
#include "common/comm.h"
-#include "common/system.h"
#include "common/logging.h"
#include "common/tunable.h"
#include "common/srvid.h"
@@ -170,6 +169,7 @@ static bool nodemap_parse(struct node_map *node_map)
char *ip;
ctdb_sock_addr saddr;
struct node *node;
+ int ret;
if (line[0] == '\n') {
break;
@@ -194,10 +194,12 @@ static bool nodemap_parse(struct node_map *node_map)
fprintf(stderr, "bad line (%s) - missing IP\n", line);
continue;
}
- if (!parse_ip(tok, NULL, CTDB_PORT, &saddr)) {
+ ret = ctdb_sock_addr_from_string(tok, &saddr, false);
+ if (ret != 0) {
fprintf(stderr, "bad line (%s) - invalid IP\n", line);
continue;
}
+ ctdb_sock_addr_set_port(&saddr, CTDB_PORT);
ip = talloc_strdup(node_map, tok);
if (ip == NULL) {
goto fail;
@@ -249,7 +251,8 @@ static bool nodemap_parse(struct node_map *node_map)
}
node = &node_map->node[node_map->num_nodes];
- parse_ip(ip, NULL, CTDB_PORT, &node->addr);
+ ctdb_sock_addr_from_string(ip, &node->addr, false);
+ ctdb_sock_addr_set_port(&node->addr, CTDB_PORT);
node->pnn = pnn;
node->flags = flags;
node->capabilities = capabilities;
@@ -275,11 +278,14 @@ static bool node_map_add(struct ctdb_node_map *nodemap,
ctdb_sock_addr addr;
uint32_t num;
struct ctdb_node_and_flags *n;
+ int ret;
- if (! parse_ip(nstr, NULL, CTDB_PORT, &addr)) {
+ ret = ctdb_sock_addr_from_string(nstr, &addr, false);
+ if (ret != 0) {
fprintf(stderr, "Invalid IP address %s\n", nstr);
return false;
}
+ ctdb_sock_addr_set_port(&addr, CTDB_PORT);
num = nodemap->num;
nodemap->node = talloc_realloc(nodemap, nodemap->node,
@@ -1959,7 +1965,8 @@ static void control_reload_nodes_file(TALLOC_CTX *mem_ctx,
node = &node_map->node[i];
node->flags |= NODE_FLAGS_DELETED;
- parse_ip("0.0.0.0", NULL, 0, &node->addr);
+ ctdb_sock_addr_from_string("0.0.0.0", &node->addr,
+ false);
continue;
}
diff --git a/ctdb/tests/src/ipalloc_read_known_ips.c b/ctdb/tests/src/ipalloc_read_known_ips.c
index 5725d6dc523..354f7ec4fcd 100644
--- a/ctdb/tests/src/ipalloc_read_known_ips.c
+++ b/ctdb/tests/src/ipalloc_read_known_ips.c
@@ -25,8 +25,8 @@
#include "lib/util/debug.h"
#include "protocol/protocol.h"
+#include "protocol/protocol_util.h"
#include "common/logging.h"
-#include "common/system.h"
#include "ipalloc_read_known_ips.h"
@@ -69,6 +69,7 @@ static bool read_ctdb_public_ip_info_node(bool multi,
}
while (fgets(line, sizeof(line), stdin) != NULL) {
+ int ret;
/* Get rid of pesky newline */
if ((t = strchr(line, '\n')) != NULL) {
@@ -87,7 +88,8 @@ static bool read_ctdb_public_ip_info_node(bool multi,
continue;
}
- if (!parse_ip(tok, NULL, 0, &addr)) {
+ ret = ctdb_sock_addr_from_string(tok, &addr, false);
+ if (ret != 0) {
D_ERR("ERROR, bad address :%s\n", tok);
continue;
}