1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
$NetBSD: patch-bq,v 1.2 2011/06/07 07:27:11 manu Exp $
Make sur glusterfsd uses the same address family as glusterd.
glusterfsd uses getaddrinfo and picks the first entry for its
listening address. The first entry is of inet6 family on
NetBSD. Even if glusterd was started with option
transport.address-family inet, we ended with glusterfsd
using inet6. Since the client assumes glusterd and glusterfsd
use the same address family, it could not reach glusterfsd.
--- xlators/mgmt/glusterd/src/glusterd-utils.c.orig 2011-06-06 10:28:42.000000000 +0200
+++ xlators/mgmt/glusterd/src/glusterd-utils.c 2011-06-06 16:17:30.000000000 +0200
@@ -88,8 +88,52 @@
//TODO: set timestamp
return 0;
}
+static const char *
+glusterd_listener_family_name(void)
+{
+ xlator_t *this = NULL;
+ glusterd_conf_t *conf = NULL;
+ rpcsvc_listener_t *listener = NULL;
+ struct sockaddr_storage ss;
+
+ this = THIS;
+ GF_ASSERT (this);
+ conf = this->private;
+ GF_ASSERT (conf);
+ GF_ASSERT (conf->rpc);
+
+ list_for_each_entry (listener, &conf->rpc->listeners, list)
+ break; /* grab first one */
+
+ GF_ASSERT (listener->trans);
+
+ if (rpc_transport_get_myaddr(listener->trans, NULL, 0,
+ &ss, sizeof(ss)) != 0) {
+ gf_log ("glusterd", GF_LOG_ERROR,
+ "rpc_transport_get_myname failed: %s",
+ strerror(errno));
+ return NULL;
+ }
+
+ switch (ss.ss_family) {
+ case AF_INET:
+ return "inet";
+ break;
+ case AF_INET6:
+ return "inet6";
+ break;
+ default:
+ gf_log ("glusterd", GF_LOG_ERROR,
+ "unknown address family %d",
+ ss.ss_family);
+ break;
+ }
+
+ return NULL;
+}
+
gf_boolean_t
glusterd_is_loopback_localhost (const struct sockaddr *sa, char *hostname)
{
GF_ASSERT (sa);
@@ -1026,8 +1070,10 @@
int port = 0;
FILE *file = NULL;
gf_boolean_t is_locked = _gf_false;
char socketpath[PATH_MAX] = {0};
+ const char *family_name;
+ char *family_option[8192] = {0,};
GF_ASSERT (volinfo);
GF_ASSERT (brickinfo);
@@ -1106,14 +1152,19 @@
port = brickinfo->port;
if (!port)
port = pmap_registry_alloc (THIS);
+ if ((family_name = glusterd_listener_family_name()) != NULL)
+ snprintf (family_option, 8192,
+ "--xlator-option %s-server.transport.address-family=%s ",
+ volinfo->volname, family_name);
+
snprintf (cmd_str, 8192,
"%s/sbin/glusterfsd --xlator-option %s-server.listen-port=%d "
- "-s localhost --volfile-id %s -p %s -S %s --brick-name %s "
- "--brick-port %d -l %s", GFS_PREFIX, volinfo->volname,
- port, volfile, pidfile, socketpath, brickinfo->path, port,
- brickinfo->logfile);
+ "%s -s localhost --volfile-id %s -p %s -S %s --brick-name %s "
+ "--brick-port %d -l %s", GFS_PREFIX, volinfo->volname, port,
+ family_option, volfile, pidfile, socketpath, brickinfo->path,
+ port, brickinfo->logfile);
gf_log ("",GF_LOG_DEBUG,"Starting GlusterFS Command Executed: \n %s \n", cmd_str);
ret = gf_system (cmd_str);
|