[SCM] CTDB repository - branch master updated - ctdb-1.0.76

Ronnie Sahlberg sahlberg at samba.org
Wed Mar 25 05:45:26 GMT 2009


The branch, master has been updated
       via  56b7095994d1de95e40a223ed503b5572ea9d1b9 (commit)
       via  cd78765f9400d7abce7929a2dd199f65226e7664 (commit)
       via  e059df6d3cd81c67e5505e8ef2d6d0ef9a287b31 (commit)
       via  1046885cd22b5001e0251de2e536b5f6793459be (commit)
      from  95d22e4cf265d2119f72200ab0ec708f095853df (commit)

http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 56b7095994d1de95e40a223ed503b5572ea9d1b9
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Mar 25 14:52:08 2009 +1100

    new version 1.0.76

commit cd78765f9400d7abce7929a2dd199f65226e7664
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Mar 25 14:46:05 2009 +1100

    change the ctdb command table to allow us to describe commands which can be run independtly of the ctdb daemon.
    
    create a new debugging command xpnn which discovers the pnn of the local node and which works even if the local daemon is not running

commit e059df6d3cd81c67e5505e8ef2d6d0ef9a287b31
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Mar 25 13:46:41 2009 +1100

    iupdate the documentation for NATGW to reflect that you can now use
    multiple natgw groups in one cluster

commit 1046885cd22b5001e0251de2e536b5f6793459be
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Mar 25 13:37:57 2009 +1100

    update how the NATGW configuration works.
    
    allow the cluster to be partitioned into multiple disjoint natgw subsets

-----------------------------------------------------------------------

Summary of changes:
 config/ctdb.sysconfig    |    5 +
 config/events.d/11.natgw |   20 +--
 doc/ctdbd.1              |   24 +++-
 doc/ctdbd.1.html         |   55 +++++---
 doc/ctdbd.1.xml          |   40 ++++--
 packaging/RPM/ctdb.spec  |    5 +-
 tools/ctdb.c             |  330 ++++++++++++++++++++++++++++++++++++----------
 7 files changed, 354 insertions(+), 125 deletions(-)


Changeset truncated at 500 lines:

diff --git a/config/ctdb.sysconfig b/config/ctdb.sysconfig
index c3b5f16..ef3b0dc 100644
--- a/config/ctdb.sysconfig
+++ b/config/ctdb.sysconfig
@@ -172,11 +172,16 @@
 # and thus no proper routes to the external world it will instead
 # route all packets through the nat-gw node.
 #
+# NATGW_NODES is the list of nodes that belong to this natgw group.
+# You can have multiple natgw groups in one cluster but each node
+# can only belong to one single natgw group.
+#
 # NATGW_PUBLIC_IP=10.0.0.227/24
 # NATGW_PUBLIC_IFACE=eth0
 # NATGW_DEFAULT_GATEWAY=10.0.0.1
 # NATGW_PRIVATE_IFACE=eth1
 # NATGW_PRIVATE_NETWORK=10.1.1.0/24
+# NATGW_NODES=/etc/ctdb/natgw_nodes
 
 # where to log messages
 # the default is /var/log/log.ctdb
diff --git a/config/events.d/11.natgw b/config/events.d/11.natgw
index 254a8c1..2d256ba 100644
--- a/config/events.d/11.natgw
+++ b/config/events.d/11.natgw
@@ -29,16 +29,14 @@ delete_all() {
 case $cmd in 
      recovered)
 	MYPNN=`ctdb pnn | cut -d: -f2`
+	NATGWMASTER=`ctdb natgwlist | head -1`
+	NATGWIP=`ctdb natgwlist | tail --lines=+2 | head -1 | cut -d: -f3`
 
-	# Find the first connected node
-	FIRST=`ctdb status -Y | grep ":0:$" | head -1`
-	FIRSTNODE=`echo $FIRST | cut -d: -f2`
-	FIRSTIP=`echo $FIRST | cut -d: -f3`
 	NATGW_PUBLIC_IP_HOST=`echo $NATGW_PUBLIC_IP | sed -e "s/\/.*/\/32/"`
 
 	delete_all
 
-	if [ "$FIRSTNODE" == "$MYPNN" ]; then
+	if [ "$MYPNN" == "$NATGWMASTER" ]; then
 		# This is the first node, set it up as the NAT GW
 		echo 1 >/proc/sys/net/ipv4/ip_forward
 		iptables -A POSTROUTING -t nat -s $NATGW_PRIVATE_NETWORK -d ! $NATGW_PRIVATE_NETWORK -j MASQUERADE
@@ -51,14 +49,12 @@ case $cmd in
 		# We do this so that the ip address will exist on a
 		# non-loopback interface so that samba may send it along in the
 		# KDC requests.
-
-		# Set the scope up as host and make sure we dont respond to ARP
-		# for this ip
-		echo 3 > /proc/sys/net/ipv4/conf/all/arp_ignore
-		ip addr add $NATGW_PUBLIC_IP_HOST dev $NATGW_PRIVATE_IFACE scope host
-		
-		ip route add 0.0.0.0/0 via $FIRSTIP metric 10
+		ip addr add $NATGW_PUBLIC_IP_HOST dev $NATGW_PRIVATE_IFACE
+		ip route add 0.0.0.0/0 via $NATGWIP metric 10
 	fi
+
+	# flush our route cache
+	echo 1 > /proc/sys/net/ipv4/route/flush
 	;;
 
      shutdown)
diff --git a/doc/ctdbd.1 b/doc/ctdbd.1
index e379128..13e4a6b 100644
--- a/doc/ctdbd.1
+++ b/doc/ctdbd.1
@@ -1,11 +1,11 @@
 .\"     Title: ctdbd
 .\"    Author: 
 .\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/>
-.\"      Date: 03/19/2009
+.\"      Date: 03/25/2009
 .\"    Manual: 
 .\"    Source: 
 .\"
-.TH "CTDBD" "1" "03/19/2009" "" ""
+.TH "CTDBD" "1" "03/25/2009" "" ""
 .\" disable hyphenation
 .nh
 .\" disable justification (adjust text to left margin only)
@@ -427,12 +427,14 @@ If then the service status of CTDB depends on such services being able to always
 There are two ways to solve this problem\. The first is by assigning a static ip address for one public interface on every node which will allow every node to be able to route traffic to the public network even if there are no public addresses assigned to the node\. This is the simplest way but it uses up a lot of ip addresses since you have to assign both static and also public addresses to each node\.
 .SS "NAT\-GW"
 .PP
-A second way is to use the built in NAT\-GW feature in CTDB\. With NAT\-GW only one extra address is required for the entire cluster instead of one address per node\. This extra address is dedicated to traffic that originates from the cluster and is destined for the external network\.
+A second way is to use the built in NAT\-GW feature in CTDB\. With NAT\-GW you assign one public NATGW address for each natgw group\. Each NATGW group is a set of nodes in the cluster that shares the same NATGW address to talk to the outside world\. Normally there would only be one NATGW group spanning the entire cluster, but in situations where one ctdb cluster spans multiple physical sites it is useful to have one NATGW group for each of the two sites\.
 .PP
-In NAT\-GW one of the nodes in the cluster is designated the NAT Gateway through which all traffic that is originated in the cluster will be routed through if the public addresses are not available\.
+There can be multiple NATGW groups in one cluster but each node can only be member of one NATGW group\.
+.PP
+In each NATGW group, one of the nodes is designated the NAT Gateway through which all traffic that is originated by nodes in this group will be routed through if a public addresses are not available\.
 .SS "Configuration"
 .PP
-NAT\-GW is configured in /etc/sysconfig/ctdb by setting the following variables:
+NAT\-GW is configured in /etc/sysconfigctdb by setting the following variables:
 .sp
 .RS 4
 .nf
@@ -462,11 +464,16 @@ NAT\-GW is configured in /etc/sysconfig/ctdb by setting the following variables:
 # and thus no proper routes to the external world it will instead
 # route all packets through the nat\-gw node\.
 #
+# NATGW_NODES is the list of nodes that belong to this natgw group\.
+# You can have multiple natgw groups in one cluster but each node
+# can only belong to one single natgw group\.
+#
 # NATGW_PUBLIC_IP=10\.0\.0\.227/24
 # NATGW_PUBLIC_IFACE=eth0
 # NATGW_DEFAULT_GATEWAY=10\.0\.0\.1
 # NATGW_PRIVATE_IFACE=eth1
 # NATGW_PRIVATE_NETWORK=10\.1\.1\.0/24
+# NATGW_NODES=/etc/ctdb/natgw_nodes
     
 .fi
 .RE
@@ -495,13 +502,16 @@ Format of this parameter is INTERFACE
 This is the network/netmask used for the interal private network\.
 .PP
 Format of this parameter is IPADDRESS/NETMASK
+.SS "NATGW_NODES"
+.PP
+This is the list of all nodes that belong to the same NATGW group as this node\. The default is /etc/ctdb/natgw_nodes\.
 .SS "Operation"
 .PP
-When the NAT\-GW fiunctionality is used, one of the nodes is elected to act as a NAT router for all the other nodes in the cluster when they need to originate traffic to the external public network\.
+When the NAT\-GW fiunctionality is used, one of the nodes is elected to act as a NAT router for all the other nodes in the group when they need to originate traffic to the external public network\.
 .PP
 The NAT\-GW node is assigned the NATGW_PUBLIC_IP to the designated interface and the provided default route\. The NAT\-GW is configured to act as a router and to masquerade all traffic it receives from the internal private network and which is destined to the external network(s)\.
 .PP
-All other nodes are configured with a default route of metric 10 pointing to the designated NAT GW node\.
+All other nodes in the group are configured with a default route of metric 10 pointing to the designated NAT GW node\.
 .PP
 This is implemented in the 11\.natgw eventscript\. Please see the eventscript for further information\.
 .SH "SEE ALSO"
diff --git a/doc/ctdbd.1.html b/doc/ctdbd.1.html
index 61d3d93..6781477 100644
--- a/doc/ctdbd.1.html
+++ b/doc/ctdbd.1.html
@@ -440,16 +440,21 @@ CTDB_CAPABILITY_RECMASTER=no
       have to assign both static and also public addresses to each node.
     </p><div class="refsect2" lang="en"><a name="id2529493"></a><h3>NAT-GW</h3><p>
       A second way is to use the built in NAT-GW feature in CTDB.
-      With NAT-GW only one extra address is required for the entire cluster
-      instead of one address per node. This extra address is dedicated 
-      to traffic that originates from the cluster and is destined for the
-      external network.
-    </p><p>
-      In NAT-GW one of the nodes in the cluster is designated the NAT Gateway
-      through which all traffic that is originated in the cluster will be
-      routed through if the public addresses are not available. 
-    </p></div><div class="refsect2" lang="en"><a name="id2529514"></a><h3>Configuration</h3><p>
-      NAT-GW is configured in /etc/sysconfig/ctdb by setting the following
+      With NAT-GW you assign one public NATGW address for each natgw group.
+      Each NATGW group is a set of nodes in the cluster that shares the same
+      NATGW address to talk to the outside world. Normally there would only be
+      one NATGW group spanning the entire cluster, but in situations where one
+      ctdb cluster spans multiple physical sites it is useful to have one
+      NATGW group for each of the two sites.
+    </p><p>
+      There can be multiple NATGW groups in one cluster but each node can only
+      be member of one NATGW group.
+    </p><p>
+      In each NATGW group, one of the nodes is designated the NAT Gateway
+      through which all traffic that is originated by nodes in this group
+      will be routed through if a public addresses are not available. 
+    </p></div><div class="refsect2" lang="en"><a name="id2529523"></a><h3>Configuration</h3><p>
+      NAT-GW is configured in /etc/sysconfigctdb by setting the following
       variables:
     </p><pre class="screen">
 # NAT-GW configuration
@@ -478,39 +483,47 @@ CTDB_CAPABILITY_RECMASTER=no
 # and thus no proper routes to the external world it will instead
 # route all packets through the nat-gw node.
 #
+# NATGW_NODES is the list of nodes that belong to this natgw group.
+# You can have multiple natgw groups in one cluster but each node
+# can only belong to one single natgw group.
+#
 # NATGW_PUBLIC_IP=10.0.0.227/24
 # NATGW_PUBLIC_IFACE=eth0
 # NATGW_DEFAULT_GATEWAY=10.0.0.1
 # NATGW_PRIVATE_IFACE=eth1
 # NATGW_PRIVATE_NETWORK=10.1.1.0/24
-    </pre></div><div class="refsect2" lang="en"><a name="id2529555"></a><h3>NATGW_PUBLIC_IP</h3><p>
+# NATGW_NODES=/etc/ctdb/natgw_nodes
+    </pre></div><div class="refsect2" lang="en"><a name="id2476123"></a><h3>NATGW_PUBLIC_IP</h3><p>
       This is an ip address in the public network that is used for all outgoing
       traffic when the public addresses are not assigned.
       This address will be assigned to one of the nodes in the cluster which
       will masquerade all traffic for the other nodes.
     </p><p>
       Format of this parameter is IPADDRESS/NETMASK
-    </p></div><div class="refsect2" lang="en"><a name="id2476128"></a><h3>NATGW_PUBLIC_IFACE</h3><p>
+    </p></div><div class="refsect2" lang="en"><a name="id2476141"></a><h3>NATGW_PUBLIC_IFACE</h3><p>
       This is the physical interface where the NATGW_PUBLIC_IP will be
       assigned to. This should be an interface connected to the public network.
     </p><p>
       Format of this parameter is INTERFACE
-    </p></div><div class="refsect2" lang="en"><a name="id2476144"></a><h3>NATGW_DEFAULT_GATEWAY</h3><p>
+    </p></div><div class="refsect2" lang="en"><a name="id2476157"></a><h3>NATGW_DEFAULT_GATEWAY</h3><p>
       This is the default gateway to use on the node that is elected to host
       the NATGW_PUBLIC_IP. This is the default gateway on the public network.
     </p><p>
       Format of this parameter is IPADDRESS
-    </p></div><div class="refsect2" lang="en"><a name="id2476160"></a><h3>NATGW_PRIVATE_IFACE</h3><p>
+    </p></div><div class="refsect2" lang="en"><a name="id2476172"></a><h3>NATGW_PRIVATE_IFACE</h3><p>
       This is the interface used for the interal private network.
     </p><p>
       Format of this parameter is INTERFACE
-    </p></div><div class="refsect2" lang="en"><a name="id2476174"></a><h3>NATGW_PRIVATE_NETWORK</h3><p>
+    </p></div><div class="refsect2" lang="en"><a name="id2476187"></a><h3>NATGW_PRIVATE_NETWORK</h3><p>
       This is the network/netmask used for the interal private network.
     </p><p>
       Format of this parameter is IPADDRESS/NETMASK
-    </p></div><div class="refsect2" lang="en"><a name="id2476188"></a><h3>Operation</h3><p>
+    </p></div><div class="refsect2" lang="en"><a name="id2476201"></a><h3>NATGW_NODES</h3><p>
+      This is the list of all nodes that belong to the same NATGW group
+      as this node. The default is /etc/ctdb/natgw_nodes.
+    </p></div><div class="refsect2" lang="en"><a name="id2476212"></a><h3>Operation</h3><p>
       When the NAT-GW fiunctionality is used, one of the nodes is elected
-      to act as a NAT router for all the other nodes in the cluster when
+      to act as a NAT router for all the other nodes in the group when
       they need to originate traffic to the external public network.
     </p><p>
       The NAT-GW node is assigned the NATGW_PUBLIC_IP to the designated
@@ -518,15 +531,15 @@ CTDB_CAPABILITY_RECMASTER=no
       to act as a router and to masquerade all traffic it receives from the
       internal private network and which is destined to the external network(s).
     </p><p>
-      All other nodes are configured with a default route of metric 10 pointing
-      to the designated NAT GW node.
+      All other nodes in the group are configured with a default route of
+      metric 10 pointing to the designated NAT GW node.
     </p><p>
       This is implemented in the 11.natgw eventscript. Please see the
       eventscript for further information.
-    </p></div></div><div class="refsect1" lang="en"><a name="id2476221"></a><h2>SEE ALSO</h2><p>
+    </p></div></div><div class="refsect1" lang="en"><a name="id2476245"></a><h2>SEE ALSO</h2><p>
       ctdb(1), onnode(1)
       <a class="ulink" href="http://ctdb.samba.org/" target="_top">http://ctdb.samba.org/</a>
-    </p></div><div class="refsect1" lang="en"><a name="id2476234"></a><h2>COPYRIGHT/LICENSE</h2><div class="literallayout"><p><br>
+    </p></div><div class="refsect1" lang="en"><a name="id2476258"></a><h2>COPYRIGHT/LICENSE</h2><div class="literallayout"><p><br>
 Copyright (C) Andrew Tridgell 2007<br>
 Copyright (C) Ronnie sahlberg 2007<br>
 <br>
diff --git a/doc/ctdbd.1.xml b/doc/ctdbd.1.xml
index d5e3824..f90b671 100644
--- a/doc/ctdbd.1.xml
+++ b/doc/ctdbd.1.xml
@@ -811,21 +811,27 @@ CTDB_CAPABILITY_RECMASTER=no
     <refsect2><title>NAT-GW</title>
     <para>
       A second way is to use the built in NAT-GW feature in CTDB.
-      With NAT-GW only one extra address is required for the entire cluster
-      instead of one address per node. This extra address is dedicated 
-      to traffic that originates from the cluster and is destined for the
-      external network.
+      With NAT-GW you assign one public NATGW address for each natgw group.
+      Each NATGW group is a set of nodes in the cluster that shares the same
+      NATGW address to talk to the outside world. Normally there would only be
+      one NATGW group spanning the entire cluster, but in situations where one
+      ctdb cluster spans multiple physical sites it is useful to have one
+      NATGW group for each of the two sites.
     </para>
     <para>
-      In NAT-GW one of the nodes in the cluster is designated the NAT Gateway
-      through which all traffic that is originated in the cluster will be
-      routed through if the public addresses are not available. 
+      There can be multiple NATGW groups in one cluster but each node can only
+      be member of one NATGW group.
+    </para>
+    <para>
+      In each NATGW group, one of the nodes is designated the NAT Gateway
+      through which all traffic that is originated by nodes in this group
+      will be routed through if a public addresses are not available. 
     </para>
     </refsect2>
 
     <refsect2><title>Configuration</title>
     <para>
-      NAT-GW is configured in /etc/sysconfig/ctdb by setting the following
+      NAT-GW is configured in /etc/sysconfigctdb by setting the following
       variables:
     </para>
     <screen format="linespecific">
@@ -855,11 +861,16 @@ CTDB_CAPABILITY_RECMASTER=no
 # and thus no proper routes to the external world it will instead
 # route all packets through the nat-gw node.
 #
+# NATGW_NODES is the list of nodes that belong to this natgw group.
+# You can have multiple natgw groups in one cluster but each node
+# can only belong to one single natgw group.
+#
 # NATGW_PUBLIC_IP=10.0.0.227/24
 # NATGW_PUBLIC_IFACE=eth0
 # NATGW_DEFAULT_GATEWAY=10.0.0.1
 # NATGW_PRIVATE_IFACE=eth1
 # NATGW_PRIVATE_NETWORK=10.1.1.0/24
+# NATGW_NODES=/etc/ctdb/natgw_nodes
     </screen>
     </refsect2>
 
@@ -913,10 +924,17 @@ CTDB_CAPABILITY_RECMASTER=no
     </para>
     </refsect2>
 
+    <refsect2><title>NATGW_NODES</title>
+    <para>
+      This is the list of all nodes that belong to the same NATGW group
+      as this node. The default is /etc/ctdb/natgw_nodes.
+    </para>
+    </refsect2>
+
     <refsect2><title>Operation</title>
     <para>
       When the NAT-GW fiunctionality is used, one of the nodes is elected
-      to act as a NAT router for all the other nodes in the cluster when
+      to act as a NAT router for all the other nodes in the group when
       they need to originate traffic to the external public network.
     </para>
     <para>
@@ -926,8 +944,8 @@ CTDB_CAPABILITY_RECMASTER=no
       internal private network and which is destined to the external network(s).
     </para>
     <para>
-      All other nodes are configured with a default route of metric 10 pointing
-      to the designated NAT GW node.
+      All other nodes in the group are configured with a default route of
+      metric 10 pointing to the designated NAT GW node.
     </para>
     <para>
       This is implemented in the 11.natgw eventscript. Please see the
diff --git a/packaging/RPM/ctdb.spec b/packaging/RPM/ctdb.spec
index af1c6da..66c3647 100644
--- a/packaging/RPM/ctdb.spec
+++ b/packaging/RPM/ctdb.spec
@@ -4,7 +4,7 @@ Summary: Clustered TDB
 Vendor: Samba Team
 Packager: Samba Team <samba at samba.org>
 Name: ctdb
-Version: 1.0.75
+Version: 1.0.76
 Release: 1
 Epoch: 0
 License: GNU GPL version 3
@@ -128,6 +128,9 @@ fi
 %{_includedir}/ctdb_private.h
 
 %changelog
+* Wed Mar 24 2009 : Version 1.0.76
+ - Add a debugging command "xpnn" which can print the pnn of the node even when ctdbd is not running.
+ - Redo the NATGW implementation to allow multiple disjoing NATGW groups in the same cluster.
 * Tue Mar 24 2009 : Version 1.0.75
  - Various updates to LVS
  - Fix a bug in the killtcp control where we did not set the port correctly
diff --git a/tools/ctdb.c b/tools/ctdb.c
index 8fcf95b..a4120e8 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -369,6 +369,80 @@ static int control_pnn(struct ctdb_context *ctdb, int argc, const char **argv)
 	return 0;
 }
 
+
+struct pnn_node {
+	struct pnn_node *next;
+	const char *addr;
+	int pnn;
+};
+
+/*
+  show the PNN of the current node
+  discover the pnn by loading the nodes file and try to bind to all
+  addresses one at a time until the ip address is found.
+ */
+static int control_xpnn(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+	TALLOC_CTX *mem_ctx = talloc_new(NULL);
+	const char *nodes_list;
+	int nlines;
+	char **lines;
+	struct pnn_node *pnn_nodes = NULL;
+	struct pnn_node *pnn_node;
+	int i, pnn;
+
+	/* read the nodes file */
+	nodes_list = getenv("CTDB_NODES");
+	if (nodes_list == NULL) {
+		nodes_list = "/etc/ctdb/nodes";
+	}
+	lines = file_lines_load(nodes_list, &nlines, mem_ctx);
+	if (lines == NULL) {
+		ctdb_set_error(ctdb, "Failed to load nodes list '%s'\n", nodes_list);
+		return -1;
+	}
+	while (nlines > 0 && strcmp(lines[nlines-1], "") == 0) {
+		nlines--;
+	}
+	for (i=0, pnn=0; i<nlines; i++) {
+		char *node;
+
+		node = lines[i];
+		/* strip leading spaces */
+		while((*node == ' ') || (*node == '\t')) {
+			node++;
+		}
+		if (*node == '#') {
+			continue;
+		}
+		if (strcmp(node, "") == 0) {
+			continue;
+		}
+		pnn_node = talloc(mem_ctx, struct pnn_node);
+		pnn_node->pnn = pnn++;
+		pnn_node->addr = talloc_strdup(pnn_node, node);
+		pnn_node->next = pnn_nodes;
+		pnn_nodes = pnn_node;
+	}
+
+	for(pnn_node=pnn_nodes;pnn_node;pnn_node=pnn_node->next) {
+		ctdb_sock_addr addr;
+
+		if (parse_ip(pnn_node->addr, NULL, 63999, &addr) == 0) {
+			DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s' in nodes file %s\n", pnn_node->addr, nodes_list));
+			return -1;
+		}
+
+		if (ctdb_sys_have_ip(&addr)) {
+			printf("PNN:%d\n", pnn_node->pnn);
+			return 0;
+		}
+	}
+
+	printf("Failed to detect which PNN this node is\n");
+	return -1;
+}
+
 /*
   display remote ctdb status
  */
@@ -472,6 +546,111 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv
 }
 
 
+struct natgw_node {
+	struct natgw_node *next;
+	const char *addr;
+};
+
+/*
+  display the list of nodes belonging to this natgw configuration
+ */
+static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+	int i, ret;
+	const char *natgw_list;
+	int nlines;
+	char **lines;
+	struct natgw_node *natgw_nodes = NULL;
+	struct natgw_node *natgw_node;
+	struct ctdb_node_map *nodemap=NULL;
+
+
+	/* read the natgw nodes file into a linked list */
+	natgw_list = getenv("NATGW_NODES");
+	if (natgw_list == NULL) {
+		natgw_list = "/etc/ctdb/natgw_nodes";
+	}
+	lines = file_lines_load(natgw_list, &nlines, ctdb);
+	if (lines == NULL) {
+		ctdb_set_error(ctdb, "Failed to load natgw node list '%s'\n", natgw_list);
+		return -1;
+	}
+	while (nlines > 0 && strcmp(lines[nlines-1], "") == 0) {
+		nlines--;
+	}
+	for (i=0;i<nlines;i++) {
+		char *node;
+
+		node = lines[i];
+		/* strip leading spaces */
+		while((*node == ' ') || (*node == '\t')) {
+			node++;
+		}
+		if (*node == '#') {
+			continue;
+		}
+		if (strcmp(node, "") == 0) {
+			continue;
+		}
+		natgw_node = talloc(ctdb, struct natgw_node);
+		natgw_node->addr = talloc_strdup(natgw_node, node);
+		natgw_node->next = natgw_nodes;
+		natgw_nodes = natgw_node;
+	}
+
+	ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE, ctdb, &nodemap);


-- 
CTDB repository


More information about the samba-cvs mailing list