]> git.proxmox.com Git - pve-cluster.git/commitdiff
ipv6 support for lookup_node_ip
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 8 May 2015 09:39:24 +0000 (11:39 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 8 May 2015 10:17:51 +0000 (12:17 +0200)
data/src/pmxcfs.c

index a4611657a2f4ef37bd664ea3e1fdf1794dca11fc..be90618d2adb039f6511bfbf5a956b6835b12997 100644 (file)
@@ -690,6 +690,7 @@ create_symlinks(cfs_plug_base_t *bplug, const char *nodename)
 static char *
 lookup_node_ip(const char *nodename) 
 {
+       char buf[INET6_ADDRSTRLEN];
        struct addrinfo *ainfo;
        struct addrinfo ahints;
        memset(&ahints, 0, sizeof(ahints));
@@ -698,7 +699,6 @@ lookup_node_ip(const char *nodename)
                return NULL;
 
        if (ainfo->ai_family == AF_INET) {
-               char buf[INET6_ADDRSTRLEN];
                struct sockaddr_in *sa = (struct sockaddr_in *)ainfo->ai_addr;
                inet_ntop(ainfo->ai_family, &sa->sin_addr, buf, sizeof(buf));
                if (strncmp(buf, "127.", 4) != 0) {
@@ -706,7 +706,13 @@ lookup_node_ip(const char *nodename)
                }
        }
 
-       // ipv6 support ?
+       if (ainfo->ai_family == AF_INET6) {
+               struct sockaddr_in6 *sa = (struct sockaddr_in6 *)ainfo->ai_addr;
+               inet_ntop(ainfo->ai_family, &sa->sin6_addr, buf, sizeof(buf));
+               if (strcmp(buf, "::1") != 0) {
+                       return g_strdup(buf);
+               }
+       }
 
        return NULL;
 }