[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Cluster-devel] [PATCH] ccs_tool: readd IPv6 support to update operations



This is a new patch based on Patrick comments on IRC.

Remove the #ifdef DEBUG.
Add -verbose option.
print the information when -verbose is selected.
update usage.

Example:

root diapolon:/etc/cluster# ccs_tool update cluster.conf.new
Config file updated from version 9 to 10

Update complete.
root diapolon:/etc/cluster# vi cluster.conf.new
root diapolon:/etc/cluster# ccs_tool -verbose update cluster.conf.new
Processing node: diapolon.fabbione.net
 family: ipv4
 address: 192.168.1.3
Processing node: golion.fabbione.net
 family: ipv4
 address: 192.168.1.8
Processing node: diapolon.fabbione.net
 family: ipv4
 address: 192.168.1.3
Processing node: golion.fabbione.net
 family: ipv4
 address: 192.168.1.8
Config file updated from version 10 to 11

Update complete.


Fabio Massimo Di Nitto wrote:
> A couple of days ago i submitted (and applied with Patrick ACK) a patch to fix
> ccs daemon cluster_base_port to listen and accept connections on IPv6.
> https://www.redhat.com/archives/cluster-devel/2007-May/msg00052.html
> 
> This is the ccs_tool counter part to make everything working.
> 
> Please apply or acknowledge and I will apply.
> 
> Thanks
> Fabio



-- 
I'm going to make him an offer he can't refuse.
#! /bin/sh /usr/share/dpatch/dpatch-run
## 001_ccs.dpatch by  <fabbione gordian int fabbione net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad redhat-cluster-suite-2.20070502~/ccs/ccs_tool/ccs_tool.c redhat-cluster-suite-2.20070502/ccs/ccs_tool/ccs_tool.c
--- redhat-cluster-suite-2.20070502~/ccs/ccs_tool/ccs_tool.c	2006-09-19 15:17:04.000000000 +0200
+++ redhat-cluster-suite-2.20070502/ccs/ccs_tool/ccs_tool.c	2007-05-03 10:29:58.000000000 +0200
@@ -10,6 +10,8 @@
 
 static void print_usage(FILE *stream);
 
+int globalverbose=0;
+
 int main(int argc, char *argv[])
 {
   optind = 1;
@@ -26,6 +28,10 @@
   }
 
   if(optind < argc){
+    if(!strcmp(argv[optind], "-verbose")){
+      optind++;
+      globalverbose=1;
+    }
     if(!strcmp(argv[optind], "help")){
       print_usage(stdout);
       exit(EXIT_SUCCESS);
@@ -106,6 +112,7 @@
 	  "  ccs_tool [options] <command>\n"
 	  "\n"
 	  "Options:\n"
+	  "  -verbose            Make some operations print more details.\n"
 	  "  -h                  Print this usage and exit.\n"
 	  "  -V                  Print version information and exit.\n"
 	  "\n"
diff -urNad redhat-cluster-suite-2.20070502~/ccs/ccs_tool/update.c redhat-cluster-suite-2.20070502/ccs/ccs_tool/update.c
--- redhat-cluster-suite-2.20070502~/ccs/ccs_tool/update.c	2007-05-03 07:29:48.000000000 +0200
+++ redhat-cluster-suite-2.20070502/ccs/ccs_tool/update.c	2007-05-03 10:29:58.000000000 +0200
@@ -19,6 +19,9 @@
 #include <libxml/tree.h>
 #include <libxml/xpath.h>
 #include <libxml/xpathInternals.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
 
 #include "comm_headers.h"
 #include "ccs.h"
@@ -49,6 +52,8 @@
 static int ipv6_connect(struct in6_addr *addr, uint16_t port, int timeout);
 static int connect_nb(int fd, struct sockaddr *addr, socklen_t len, int timeout);
 
+extern int globalverbose;
+
 int cluster_base_port = 50008;
 
 static int get_doc_version(xmlDocPtr ldoc)
@@ -659,12 +664,43 @@
 static int ccs_open(cman_node_t node, uint16_t port, int timeout)
 {
   struct in_addr *addr;
-  int fd;
+  struct in6_addr *addr6;
+  int fd, family;
+  char buf[INET6_ADDRSTRLEN];
 
-  addr = &(((struct sockaddr_in *)&(node.cn_address.cna_address))->sin_addr);
+  if (globalverbose) {
+    memset(buf, 0, sizeof(buf));
+    printf("Processing node: %s\n", node.cn_name);
+  }
+
+  family = ((struct sockaddr *)&(node.cn_address.cna_address))->sa_family;
+
+  if (family == AF_INET6) {
+
+    addr6 = &(((struct sockaddr_in6 *)&(node.cn_address.cna_address))->sin6_addr);
+
+    if (globalverbose) {
+      inet_ntop(family, addr6, buf, sizeof(buf));
+      printf(" family: ipv6\n address: %s\n", buf);
+    }
+
+    if ((fd = ipv6_connect(addr6, port, timeout)) < 0) {
+      return -1;
+    }
+
+  } else {
+
+    addr = &(((struct sockaddr_in *)&(node.cn_address.cna_address))->sin_addr);
+
+    if (globalverbose) {
+      inet_ntop(family, addr, buf, sizeof(buf));
+      printf(" family: ipv4\n address: %s\n", buf);
+    }
+
+    if ((fd = ipv4_connect(addr, port, timeout)) < 0) {
+      return -1;
+    }
 
-  if ((fd = ipv4_connect(addr, port, timeout)) < 0) {
-    return -1;
   }
 
   return fd;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]