summaryrefslogtreecommitdiff
path: root/ctdb/tcp
diff options
context:
space:
mode:
authorRonnie Sahlberg <sahlberg@ronnie>2007-11-26 10:52:55 +1100
committerRonnie Sahlberg <sahlberg@ronnie>2007-11-26 10:52:55 +1100
commit9e73dc87ccfbb148af4cd83ae1415fcb7b6e2f23 (patch)
tree92a0a21fb0c2443723d3587032a79c4656ed1837 /ctdb/tcp
parent0597be338660ce9d80e9011a7a7158dcb66be272 (diff)
downloadsamba-9e73dc87ccfbb148af4cd83ae1415fcb7b6e2f23.tar.gz
Add a --node-ip argument so that one can specify which ip address a
specific instance of ctdbd should bind to. This helps when running a "virtual" cluster on a single machine where all instcances bind to different alias interfaces. If --node-ip is specified, then we will only try to bind to this ip address only. Othervise we fall back to the original method trying the ip addresses in /etc/ctdb/nodes one by one until we find one we can bind to. No variable in /etc/sysconfig/ctdb added since this parameter only makes sense in a virtual test/debug cluster. (This used to be ctdb commit d96cb02c2c24f9eabbc53d3d38e90dea49cff3e0)
Diffstat (limited to 'ctdb/tcp')
-rw-r--r--ctdb/tcp/tcp_connect.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/ctdb/tcp/tcp_connect.c b/ctdb/tcp/tcp_connect.c
index 3548f82ed70..3c4e7bfb10d 100644
--- a/ctdb/tcp/tcp_connect.c
+++ b/ctdb/tcp/tcp_connect.c
@@ -214,13 +214,9 @@ static void ctdb_listen_event(struct event_context *ev, struct fd_event *fde,
if (fd == -1) return;
incoming_node = inet_ntoa(addr.sin_addr);
- for (nodeid=0;nodeid<ctdb->num_nodes;nodeid++) {
- if (!strcmp(incoming_node, ctdb->nodes[nodeid]->address.address)) {
- DEBUG(0, ("Incoming connection from node:%d %s\n",nodeid,incoming_node));
- break;
- }
- }
- if (nodeid>=ctdb->num_nodes) {
+ nodeid = ctdb_ip_to_nodeid(ctdb, incoming_node);
+
+ if (nodeid == -1) {
DEBUG(0, ("Refused connection from unknown node %s\n", incoming_node));
close(fd);
return;
@@ -275,17 +271,27 @@ static int ctdb_tcp_listen_automatic(struct ctdb_context *ctdb)
}
for (i=0;i<ctdb->num_nodes;i++) {
+ /* if node_ip is specified we will only try to bind to that
+ ip.
+ */
+ if (ctdb->node_ip != NULL) {
+ if (strcmp(ctdb->node_ip, ctdb->nodes[i]->address.address)) {
+ continue;
+ }
+ }
+
ZERO_STRUCT(sock);
#ifdef HAVE_SOCK_SIN_LEN
sock.sin_len = sizeof(sock);
#endif
sock.sin_port = htons(ctdb->nodes[i]->address.port);
sock.sin_family = PF_INET;
- if (ctdb_tcp_get_address(ctdb, ctdb->nodes[i]->address.address,
- &sock.sin_addr) != 0) {
+ if (ctdb_tcp_get_address(ctdb,
+ ctdb->nodes[i]->address.address,
+ &sock.sin_addr) != 0) {
continue;
}
-
+
if (bind(ctcp->listen_fd, (struct sockaddr * )&sock,
sizeof(sock)) == 0) {
break;