summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/common-utils.c35
-rw-r--r--libglusterfs/src/common-utils.h6
2 files changed, 30 insertions, 11 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index cf5b524dc12..a1b67596c6e 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -55,11 +55,6 @@
typedef int32_t (*rw_op_t)(int32_t fd, char *buf, int32_t size);
typedef int32_t (*rwv_op_t)(int32_t fd, const struct iovec *buf, int32_t size);
-struct dnscache6 {
- struct addrinfo *first;
- struct addrinfo *next;
-};
-
void
md5_wrapper(const unsigned char *data, size_t len, char *md5)
{
@@ -288,9 +283,6 @@ gf_resolve_ip6 (const char *hostname,
memset(&hints, 0, sizeof(hints));
hints.ai_family = family;
hints.ai_socktype = SOCK_STREAM;
-#ifndef __NetBSD__
- hints.ai_flags = AI_ADDRCONFIG;
-#endif
ret = gf_asprintf (&port_str, "%d", port);
if (-1 == ret) {
@@ -2321,6 +2313,14 @@ valid_ipv6_address (char *address, int length, gf_boolean_t wildcard_acc)
tmp = gf_strdup (address);
+ /* Check for '%' for link local addresses */
+ endptr = strchr(tmp, '%');
+ if (endptr) {
+ *endptr = '\0';
+ length = strlen(tmp);
+ endptr = NULL;
+ }
+
/* Check for compressed form */
if (length <= 0 || tmp[length - 1] == ':') {
ret = 0;
@@ -3247,9 +3247,18 @@ gf_is_local_addr (char *hostname)
gf_boolean_t found = _gf_false;
char *ip = NULL;
xlator_t *this = NULL;
+ struct addrinfo hints;
this = THIS;
- ret = getaddrinfo (hostname, NULL, NULL, &result);
+
+ memset (&hints, 0, sizeof (hints));
+ /*
+ * Removing AI_ADDRCONFIG from default_hints
+ * for being able to use link local ipv6 addresses
+ */
+ hints.ai_family = AF_UNSPEC;
+
+ ret = getaddrinfo (hostname, NULL, &hints, &result);
if (ret != 0) {
gf_msg (this->name, GF_LOG_ERROR, 0, LG_MSG_GETADDRINFO_FAILED,
@@ -3289,15 +3298,19 @@ gf_is_same_address (char *name1, char *name2)
struct addrinfo *q = NULL;
gf_boolean_t ret = _gf_false;
int gai_err = 0;
+ struct addrinfo hints;
+
+ memset (&hints, 0, sizeof (hints));
+ hints.ai_family = AF_UNSPEC;
- gai_err = getaddrinfo(name1,NULL,NULL,&addr1);
+ gai_err = getaddrinfo(name1, NULL, &hints, &addr1);
if (gai_err != 0) {
gf_msg (name1, GF_LOG_WARNING, 0, LG_MSG_GETADDRINFO_FAILED,
"error in getaddrinfo: %s\n", gai_strerror(gai_err));
goto out;
}
- gai_err = getaddrinfo(name2,NULL,NULL,&addr2);
+ gai_err = getaddrinfo(name2, NULL, &hints, &addr2);
if (gai_err != 0) {
gf_msg (name2, GF_LOG_WARNING, 0, LG_MSG_GETADDRINFO_FAILED,
"error in getaddrinfo: %s\n", gai_strerror(gai_err));
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index f5f4493e21b..bd1a491f1a9 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -176,6 +176,12 @@ struct dnscache_entry {
time_t timestamp;
};
+struct dnscache6 {
+ struct addrinfo *first;
+ struct addrinfo *next;
+};
+
+
struct dnscache *gf_dnscache_init (time_t ttl);
struct dnscache_entry *gf_dnscache_entry_init ();