ctdb-daemon: Fix IP address comparisons for IPv6 addresses
authorAmitay Isaacs <amitay@gmail.com>
Tue, 25 Nov 2014 01:38:23 +0000 (12:38 +1100)
committerMartin Schwenke <martins@samba.org>
Fri, 5 Dec 2014 20:02:40 +0000 (21:02 +0100)
Before storing node IP address, convert into the correct abbreviated
string form for IPv6 addresses.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/common/ctdb_util.c

index bdff4255eb58b669da63677f05ecec43eb838220..137e0a8a095d2146fd383f45729b0770aa2afdc0 100644 (file)
@@ -100,12 +100,20 @@ int ctdb_parse_address(struct ctdb_context *ctdb,
                       struct ctdb_address *address)
 {
        struct servent *se;
+       ctdb_sock_addr addr;
 
        setservent(0);
        se = getservbyname("ctdb", "tcp");
        endservent();
-       
-       address->address = talloc_strdup(mem_ctx, str);
+
+       /* Parse IP address and re-convert to string.  This ensure correct
+        * string form for IPv6 addresses.
+        */
+       if (! parse_ip(str, NULL, 0, &addr)) {
+               return -1;
+       }
+
+       address->address = talloc_strdup(mem_ctx, ctdb_addr_to_str(&addr));
        CTDB_NO_MEMORY(ctdb, address->address);
 
        if (se == NULL) {