cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: fabbione@sourceware.org <fabbione@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/ccs/daemon cluster_mgr.c
Date: 2 May 2007 12:42:20 -0000	[thread overview]
Message-ID: <20070502124220.20040.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	fabbione at sourceware.org	2007-05-02 12:42:20

Modified files:
	ccs/daemon     : cluster_mgr.c 

Log message:
	When the project switched away from magma, we forgot to enable IPv6 for
	cluster_base_port.
	The patch fix that and add some checks that were marked as TODO in the code.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/ccs/daemon/cluster_mgr.c.diff?cvsroot=cluster&r1=1.24&r2=1.25

--- cluster/ccs/daemon/cluster_mgr.c	2006/12/14 21:00:10	1.24
+++ cluster/ccs/daemon/cluster_mgr.c	2007/05/02 12:42:19	1.25
@@ -375,35 +375,62 @@
   fd_set rset;
   cman_handle_t handle = NULL;
 
-  struct sockaddr_in sin;
+  struct sockaddr_storage addr;
+  struct sockaddr_in *addr4 = (struct sockaddr_in *)&addr;
+  struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&addr;
+  int addr_size=0;
 
   ENTER("cluster_communicator");
 
-  if ((ccsd_fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
-    log_err("Unable to create socket.\n");
-    exit(EXIT_FAILURE);
+  memset(&addr, 0, sizeof(struct sockaddr_storage));
+
+  if (IPv6) {
+    if ((ccsd_fd = socket(PF_INET6, SOCK_STREAM, 0)) < 0) {
+      if(IPv6 == -1) {
+	log_dbg("Unable to create IPv6 socket:: %s\n", strerror(errno));
+	IPv6=0;
+     }
+    }
   }
 
-  sin.sin_family = AF_INET;
-  sin.sin_port = htons(cluster_base_port);
-  sin.sin_addr.s_addr = htonl(INADDR_ANY);
+  if (!IPv6) {
+    if ((ccsd_fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
+      log_err("Unable to create IPv4 socket.\n");
+      exit(EXIT_FAILURE);
+    }
+  }
 
   if (setsockopt(ccsd_fd, SOL_SOCKET, SO_REUSEADDR, (void *)&opt, sizeof(opt)) < 0) {
-    /* Check the errno and exit ? */
+    log_sys_err("Unable to set socket option");
+    exit(EXIT_FAILURE);
+  }
+
+  if(IPv6){
+    addr_size = sizeof(struct sockaddr_in6);
+    addr6->sin6_family = AF_INET6;
+    addr6->sin6_addr = in6addr_any;
+    addr6->sin6_port = htons(cluster_base_port);
+  } else {
+    addr_size = sizeof(struct sockaddr_in);
+    addr4->sin_family = AF_INET;
+    addr4->sin_addr.s_addr = INADDR_ANY;
+    addr4->sin_port = htons(cluster_base_port);
   }
 
   flags = fcntl(ccsd_fd, F_GETFD, 0);
   flags |= FD_CLOEXEC;
   fcntl(ccsd_fd, F_SETFD, flags);
 
-  if (bind(ccsd_fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
+  if (bind(ccsd_fd, (struct sockaddr *)&addr, addr_size) < 0) {
     log_err("Unable to bind to socket.\n");
     close(ccsd_fd);
     exit(EXIT_FAILURE);
   }
 
   if (listen(ccsd_fd, 15) < 0) {
-    /* Check the errno and exit ? */
+    log_err("Unable to listen to socket.\n");
+    close(ccsd_fd);
+    exit(EXIT_FAILURE);
   }
 
 restart:



             reply	other threads:[~2007-05-02 12:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-02 12:42 fabbione [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-05-02 12:42 [Cluster-devel] cluster/ccs/daemon cluster_mgr.c fabbione
2006-12-14 21:01 teigland
2006-12-14 21:01 teigland
2006-12-14 21:00 teigland
2006-10-17 16:46 pcaulfield

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070502124220.20040.qmail@sourceware.org \
    --to=fabbione@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).