[SCM] CTDB repository - branch master updated - ctdb-1.0.74-13-g857733a

Ronnie Sahlberg sahlberg at samba.org
Tue Mar 24 03:11:11 GMT 2009


The branch, master has been updated
       via  857733ae2bdfa0037af224abfabc020e2ac384c7 (commit)
       via  dc2f28f7c988364b5d45f3048be4db3e5ff113b3 (commit)
       via  292fff6eace39141591871e12f9a64e3441237be (commit)
       via  43fe18d86995744ba61c7a6405b70edcb265930a (commit)
      from  be50059c33845fec260ca53975d421a890303880 (commit)

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


- Log -----------------------------------------------------------------
commit 857733ae2bdfa0037af224abfabc020e2ac384c7
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Mar 24 14:08:57 2009 +1100

    new version 1.0.75

commit dc2f28f7c988364b5d45f3048be4db3e5ff113b3
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Mar 24 14:05:31 2009 +1100

    create a varient of kill_tcp_connections that only kills off the local side of a connection

commit 292fff6eace39141591871e12f9a64e3441237be
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Mar 24 13:51:32 2009 +1100

    set --single-public-ip when lvs is used

commit 43fe18d86995744ba61c7a6405b70edcb265930a
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Mar 24 13:45:11 2009 +1100

    we need to set the port properly in the parse_ip helper

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

Summary of changes:
 common/ctdb_util.c      |   25 ++++++++++++++++++++-----
 config/ctdb.init        |    2 +-
 config/events.d/91.lvs  |    2 +-
 config/functions        |   42 ++++++++++++++++++++++++++++++++++++++++++
 include/ctdb_private.h  |    3 ++-
 packaging/RPM/ctdb.spec |    6 +++++-
 server/ctdb_recover.c   |    1 +
 server/ctdbd.c          |    1 +
 tcp/tcp_connect.c       |    2 +-
 tcp/tcp_init.c          |    2 +-
 tools/ctdb.c            |    8 ++++----
 11 files changed, 79 insertions(+), 15 deletions(-)


Changeset truncated at 500 lines:

diff --git a/common/ctdb_util.c b/common/ctdb_util.c
index 33d30e2..a3f1731 100644
--- a/common/ctdb_util.c
+++ b/common/ctdb_util.c
@@ -435,7 +435,7 @@ bool parse_ip_port(const char *addr, ctdb_sock_addr *saddr)
 
 
 	/* now is this a ipv4 or ipv6 address ?*/
-	ret = parse_ip(s, NULL, addr);
+	ret = parse_ip(s, NULL, port, saddr);
 
 	talloc_free(tmp_ctx);
 	return ret;
@@ -444,7 +444,7 @@ bool parse_ip_port(const char *addr, ctdb_sock_addr *saddr)
 /*
   parse an ip
  */
-bool parse_ip(const char *addr, const char *iface, ctdb_sock_addr *saddr)
+bool parse_ip(const char *addr, const char *iface, unsigned port, ctdb_sock_addr *saddr)
 {
 	char *p;
 	bool ret;
@@ -452,9 +452,9 @@ bool parse_ip(const char *addr, const char *iface, ctdb_sock_addr *saddr)
 	/* now is this a ipv4 or ipv6 address ?*/
 	p = index(addr, ':');
 	if (p == NULL) {
-		ret = parse_ipv4(addr, 0, &saddr->ip);
+		ret = parse_ipv4(addr, port, &saddr->ip);
 	} else {
-		ret = parse_ipv6(addr, iface, 0, saddr);
+		ret = parse_ipv6(addr, iface, port, saddr);
 	}
 
 	return ret;
@@ -496,7 +496,7 @@ bool parse_ip_mask(const char *str, const char *iface, ctdb_sock_addr *addr, uns
 
 
 	/* now is this a ipv4 or ipv6 address ?*/
-	ret = parse_ip(s, iface, addr);
+	ret = parse_ip(s, iface, 0, addr);
 
 	talloc_free(tmp_ctx);
 	return ret;
@@ -575,6 +575,21 @@ char *ctdb_addr_to_str(ctdb_sock_addr *addr)
 	return cip;
 }
 
+unsigned ctdb_addr_to_port(ctdb_sock_addr *addr)
+{
+	switch (addr->sa.sa_family) {
+	case AF_INET:
+		return ntohs(addr->ip.sin_port);
+		break;
+	case AF_INET6:
+		return ntohs(addr->ip6.sin6_port);
+		break;
+	default:
+		DEBUG(DEBUG_ERR, (__location__ " ERROR, unknown family %u\n", addr->sa.sa_family));
+	}
+
+	return 0;
+}
 
 void ctdb_block_signal(int signum)
 {
diff --git a/config/ctdb.init b/config/ctdb.init
index 046bc52..e263855 100755
--- a/config/ctdb.init
+++ b/config/ctdb.init
@@ -74,7 +74,7 @@ CTDB_OPTIONS="$CTDB_OPTIONS --reclock=$CTDB_RECOVERY_LOCK"
 	CTDB_OPTIONS="$CTDB_OPTIONS --no-lmaster"
 }
 [ -z "$CTDB_LVS_PUBLIC_IP" ] || {
-	CTDB_OPTIONS="$CTDB_OPTIONS --lvs"
+	CTDB_OPTIONS="$CTDB_OPTIONS --lvs --single-public-ip=$CTDB_LVS_PUBLIC_IP"
 }
 [ -z "$CTDB_SCRIPT_LOG_LEVEL" ] || {
 	CTDB_OPTIONS="$CTDB_OPTIONS --script-log-level=$CTDB_SCRIPT_LOG_LEVEL"
diff --git a/config/events.d/91.lvs b/config/events.d/91.lvs
index 4860030..2411d1e 100755
--- a/config/events.d/91.lvs
+++ b/config/events.d/91.lvs
@@ -52,7 +52,7 @@ case $cmd in
 	# kill off any tcp connections
 	ipvsadm -D -t $CTDB_LVS_PUBLIC_IP:0
 	ipvsadm -D -u $CTDB_LVS_PUBLIC_IP:0
-	kill_tcp_connections $CTDB_LVS_PUBLIC_IP
+	kill_tcp_connections_local_only $CTDB_LVS_PUBLIC_IP
 
 	PNN=`ctdb pnn | sed -e "s/.*PNN://"`
 	LVSMASTER=`ctdb lvsmaster | sed -e "s/.*Node //" -e "s/ .*//"`
diff --git a/config/functions b/config/functions
index 1073055..2f0b01f 100644
--- a/config/functions
+++ b/config/functions
@@ -311,6 +311,48 @@ kill_tcp_connections() {
     echo "killed $_killcount TCP connections to released IP $_IP"
 }
 
+##################################################################
+# kill off the local end for any TCP connections with the given IP
+##################################################################
+kill_tcp_connections_local_only() {
+    _IP="$1"    
+    _failed=0
+
+    _killcount=0
+    connfile="$CTDB_BASE/state/connections.$_IP"
+    netstat -tn |egrep "^tcp.*[[:space:]]+$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' > $connfile
+    netstat -tn |egrep "^tcp.*[[:space:]]+::ffff:$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' >> $connfile
+
+    while read dest src; do
+	srcip=`echo $src | sed -e "s/:[^:]*$//"`
+	srcport=`echo $src | sed -e "s/^.*://"`
+	destip=`echo $dest | sed -e "s/:[^:]*$//"`
+	destport=`echo $dest | sed -e "s/^.*://"`
+	echo "Killing TCP connection $srcip:$srcport $destip:$destport"
+	ctdb killtcp $srcip:$srcport $destip:$destport >/dev/null 2>&1 || _failed=1
+	_killcount=`expr $_killcount + 1`
+     done < $connfile
+    /bin/rm -f $connfile
+
+    [ $_failed = 0 ] || {
+	echo "Failed to send killtcp control"
+	return;
+    }
+    [ $_killcount -gt 0 ] || {
+	return;
+    }
+    _count=0
+    while netstat -tn |egrep "^tcp.*[[:space:]]+$_IP:.*ESTABLISHED" > /dev/null; do
+	sleep 1
+	_count=`expr $_count + 1`
+	[ $_count -gt 3 ] && {
+	    echo "Timed out killing tcp connections for IP $_IP"
+	    return;
+	}
+    done
+    echo "killed $_killcount TCP connections to released IP $_IP"
+}
+
 ########################################################
 # start/stop the nfs service on different platforms
 ########################################################
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index 988b6d9..b6f44de 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -1290,7 +1290,7 @@ void ctdb_start_freeze(struct ctdb_context *ctdb);
 
 bool parse_ip_mask(const char *s, const char *iface, ctdb_sock_addr *addr, unsigned *mask);
 bool parse_ip_port(const char *s, ctdb_sock_addr *addr);
-bool parse_ip(const char *s, const char *iface, ctdb_sock_addr *addr);
+bool parse_ip(const char *s, const char *iface, unsigned port, ctdb_sock_addr *addr);
 bool parse_ipv4(const char *s, unsigned port, struct sockaddr_in *sin);
  
 
@@ -1401,6 +1401,7 @@ int32_t ctdb_control_trans2_error(struct ctdb_context *ctdb,
 				  struct ctdb_req_control *c);
 
 char *ctdb_addr_to_str(ctdb_sock_addr *addr);
+unsigned ctdb_addr_to_port(ctdb_sock_addr *addr);
 void ctdb_canonicalize_ip(const ctdb_sock_addr *ip, ctdb_sock_addr *cip);
 
 int32_t ctdb_control_recd_ping(struct ctdb_context *ctdb);
diff --git a/packaging/RPM/ctdb.spec b/packaging/RPM/ctdb.spec
index 1d83627..af1c6da 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.74
+Version: 1.0.75
 Release: 1
 Epoch: 0
 License: GNU GPL version 3
@@ -128,6 +128,10 @@ fi
 %{_includedir}/ctdb_private.h
 
 %changelog
+* 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
+ - add a new "ctdb scriptstatus" command that shows the status of the eventrscripts.
 * Mon Mar 16 2009 : Version 1.0.74
  - Fixes to AIX from C Cowan.
  - Fixes to ctdb_diagnostics so we collect correct GPFS data
diff --git a/server/ctdb_recover.c b/server/ctdb_recover.c
index 2d95b18..12b95de 100644
--- a/server/ctdb_recover.c
+++ b/server/ctdb_recover.c
@@ -165,6 +165,7 @@ ctdb_control_getnodemap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA ind
 	for (i=0; i<num_nodes; i++) {
 		if (parse_ip(ctdb->nodes[i]->address.address,
 			     NULL, /* TODO: pass in the correct interface here*/
+			     0,
 			     &node_map->nodes[i].addr) == 0)
 		{
 			DEBUG(DEBUG_ERR, (__location__ " Failed to parse %s into a sockaddr\n", ctdb->nodes[i]->address.address));
diff --git a/server/ctdbd.c b/server/ctdbd.c
index 1d3b22a..5670b93 100644
--- a/server/ctdbd.c
+++ b/server/ctdbd.c
@@ -281,6 +281,7 @@ int main(int argc, const char *argv[])
 
 		if (parse_ip(options.single_public_ip, 
 				svnn->iface,
+				0,
 				&svnn->public_address) == 0) {
 			DEBUG(DEBUG_ALERT,("Invalid --single-public-ip argument : %s . This is not a valid ip address. Exiting.\n", options.single_public_ip));
 			exit(10);
diff --git a/tcp/tcp_connect.c b/tcp/tcp_connect.c
index ac443d1..9d28d48 100644
--- a/tcp/tcp_connect.c
+++ b/tcp/tcp_connect.c
@@ -109,7 +109,7 @@ static void ctdb_node_connect_write(struct event_context *ev, struct fd_event *f
 static int ctdb_tcp_get_address(struct ctdb_context *ctdb,
 				const char *address, ctdb_sock_addr *addr)
 {
-	if (parse_ip(address, NULL, addr) == 0) {
+	if (parse_ip(address, NULL, 0, addr) == 0) {
 		DEBUG(DEBUG_CRIT, (__location__ " Unparsable address : %s.\n", address));
 		return -1;
 	}
diff --git a/tcp/tcp_init.c b/tcp/tcp_init.c
index 737bd8e..c0606f0 100644
--- a/tcp/tcp_init.c
+++ b/tcp/tcp_init.c
@@ -27,7 +27,7 @@
 
 static int tnode_destructor(struct ctdb_tcp_node *tnode)
 {
-	struct ctdb_node *node = talloc_find_parent_bytype(tnode, struct ctdb_node);
+  //	struct ctdb_node *node = talloc_find_parent_bytype(tnode, struct ctdb_node);
 
 	if (tnode->fd != -1) {
 		close(tnode->fd);
diff --git a/tools/ctdb.c b/tools/ctdb.c
index c48d587..8fcf95b 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -540,7 +540,7 @@ static int control_get_tickles(struct ctdb_context *ctdb, int argc, const char *
 		usage();
 	}
 
-	if (parse_ip(argv[0], NULL, &addr) == 0) {
+	if (parse_ip(argv[0], NULL, 0, &addr) == 0) {
 		DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[0]));
 		return -1;
 	}
@@ -612,7 +612,7 @@ static int control_moveip(struct ctdb_context *ctdb, int argc, const char **argv
 		usage();
 	}
 
-	if (parse_ip(argv[0], NULL,  &addr) == 0) {
+	if (parse_ip(argv[0], NULL, 0, &addr) == 0) {
 		DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[0]));
 		return -1;
 	}
@@ -988,7 +988,7 @@ static int control_delip(struct ctdb_context *ctdb, int argc, const char **argv)
 		usage();
 	}
 
-	if (parse_ip(argv[0], NULL, &addr) == 0) {
+	if (parse_ip(argv[0], NULL, 0, &addr) == 0) {
 		DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s'\n", argv[0]));
 		return -1;
 	}
@@ -1086,7 +1086,7 @@ static int control_gratious_arp(struct ctdb_context *ctdb, int argc, const char
 		usage();
 	}
 
-	if (!parse_ip(argv[0], NULL, &addr)) {
+	if (!parse_ip(argv[0], NULL, 0, &addr)) {
 		DEBUG(DEBUG_ERR, ("Bad IP '%s'\n", argv[0]));
 		return -1;
 	}


-- 
CTDB repository


More information about the samba-cvs mailing list