[SCM] Samba Shared Repository - branch master updated

Martin Schwenke martins at samba.org
Fri Sep 1 02:07:02 UTC 2017


The branch, master has been updated
       via  15c9177 ctdb-common: Parse IPv4-mapped IPv6 addresses into IPv4 addresses
       via  e78d2cb ctdb-tests: Improve releaseip connection resetting tests
       via  0dce39e ctdb-tests: Add tests to ensure reset of server end of connections
       via  d6b77c3 ctdb-tools: Remove broken natgwlist command
       via  ef46d35 ctdb-tests: Drop onnode test README file and buggy onnode example
       via  fc49378 ctdb-tests: Shutdown local daemons unconditionally
      from  981e674 pthreadpool: Test fork with an active thread

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 15c91774d943fba1985f33d10e24030264ce64c8
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 1 17:22:22 2017 +1100

    ctdb-common: Parse IPv4-mapped IPv6 addresses into IPv4 addresses
    
    Tools like ctdb_killtcp can't route packets to IPv4-mapped IPv6
    addresses so this works around that.
    
    Add a test case to confirm that this works.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Fri Sep  1 04:06:32 CEST 2017 on sn-devel-144

commit e78d2cbff2e30dbea4a7d05bab8f8a5fedfebd79
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Aug 22 16:37:30 2017 +1000

    ctdb-tests: Improve releaseip connection resetting tests
    
    Make the tests more general by setting up the IP address using a
    "takeip" event.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 0dce39e27857ba70c085b5ba7476abd9a710ac11
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jul 27 17:15:58 2017 +1000

    ctdb-tests: Add tests to ensure reset of server end of connections
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit d6b77c3033ac9445d76b0f2fdd8ab661d01f21cb
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 30 14:48:19 2017 +1000

    ctdb-tools: Remove broken natgwlist command
    
    The replacement was documented for Samba 4.5, so this is not worth fixing.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit ef46d352e4e6c41d47c3e41394428e1e88c1ead5
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 31 17:00:03 2017 +1000

    ctdb-tests: Drop onnode test README file and buggy onnode example
    
    These are of no value.  The test system is documented elsewhere.  An
    old version of onnode can always be retrieved from git.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit fc493780cf1ccd8b164cd3606a8c64715d33cf2f
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Aug 18 21:33:33 2017 +1000

    ctdb-tests: Shutdown local daemons unconditionally
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

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

Summary of changes:
 ctdb/common/system_util.c                          |  27 +-
 .../{32_cifs_tickle.sh => 36_smb_reset_server.sh}  |  49 +--
 ctdb/tests/complex/37_nfs_reset_server.sh          |  90 +++++
 ...erface.releaseip.010.sh => 10.interface.010.sh} |   5 +-
 ...erface.releaseip.011.sh => 10.interface.011.sh} |   5 +-
 ...erface.releaseip.012.sh => 10.interface.012.sh} |   5 +-
 ...erface.releaseip.013.sh => 10.interface.013.sh} |   5 +-
 ctdb/tests/onnode/README                           |  36 --
 ctdb/tests/onnode/stubs/onnode-buggy-001           | 376 ---------------------
 ctdb/tests/simple/99_daemons_shutdown.sh           |   2 +-
 ctdb/tests/simple/scripts/local_daemons.bash       |   4 +-
 ctdb/tests/src/protocol_util_test.c                |   1 +
 ctdb/tools/ctdb.c                                  |  29 --
 13 files changed, 159 insertions(+), 475 deletions(-)
 copy ctdb/tests/complex/{32_cifs_tickle.sh => 36_smb_reset_server.sh} (62%)
 create mode 100755 ctdb/tests/complex/37_nfs_reset_server.sh
 rename ctdb/tests/eventscripts/{10.interface.releaseip.010.sh => 10.interface.010.sh} (76%)
 rename ctdb/tests/eventscripts/{10.interface.releaseip.011.sh => 10.interface.011.sh} (82%)
 rename ctdb/tests/eventscripts/{10.interface.releaseip.012.sh => 10.interface.012.sh} (84%)
 rename ctdb/tests/eventscripts/{10.interface.releaseip.013.sh => 10.interface.013.sh} (87%)
 delete mode 100644 ctdb/tests/onnode/README
 delete mode 100755 ctdb/tests/onnode/stubs/onnode-buggy-001


Changeset truncated at 500 lines:

diff --git a/ctdb/common/system_util.c b/ctdb/common/system_util.c
index 57452aa..96ea71d 100644
--- a/ctdb/common/system_util.c
+++ b/ctdb/common/system_util.c
@@ -168,12 +168,35 @@ bool parse_ip(const char *addr, const char *ifaces, unsigned port, ctdb_sock_add
 
 	ZERO_STRUCTP(saddr); /* valgrind :-) */
 
-	/* now is this a ipv4 or ipv6 address ?*/
-	p = index(addr, ':');
+	/* IPv4 or IPv6 address?
+	 *
+	 * Use rindex() because we need the right-most ':' below for
+	 * IPv4-mapped IPv6 addresses anyway...
+	 */
+	p = rindex(addr, ':');
 	if (p == NULL) {
 		ret = parse_ipv4(addr, port, &saddr->ip);
 	} else {
+		uint8_t ipv4_mapped_prefix[12] = {
+			0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff
+		};
+
 		ret = parse_ipv6(addr, ifaces, port, saddr);
+		if (! ret) {
+			return ret;
+		}
+
+		/*
+		 * Check for IPv4-mapped IPv6 address
+		 * (e.g. ::ffff:192.0.2.128) - reparse as IPv4 if
+		 * necessary
+		 */
+		if (memcmp(&saddr->ip6.sin6_addr.s6_addr[0],
+			   ipv4_mapped_prefix,
+			   sizeof(ipv4_mapped_prefix)) == 0) {
+			/* Reparse as IPv4 */
+			ret = parse_ipv4(p+1, port, &saddr->ip);
+		}
 	}
 
 	return ret;
diff --git a/ctdb/tests/complex/32_cifs_tickle.sh b/ctdb/tests/complex/36_smb_reset_server.sh
similarity index 62%
copy from ctdb/tests/complex/32_cifs_tickle.sh
copy to ctdb/tests/complex/36_smb_reset_server.sh
index da369b9..5723ac7 100755
--- a/ctdb/tests/complex/32_cifs_tickle.sh
+++ b/ctdb/tests/complex/36_smb_reset_server.sh
@@ -3,12 +3,7 @@
 test_info()
 {
     cat <<EOF
-Verify that CIFS connections are monitored and that CIFS tickles are sent.
-
-We create a connection to the CIFS server on a node and confirm that
-this connection is registered by CTDB.  Then disable the relevant CIFS
-server node and ensure that the takeover node sends an appropriate
-reset packet.
+Verify that the server end of an SMB connection is correctly reset
 
 Prerequisites:
 
@@ -23,8 +18,8 @@ Prerequisites:
 
 Expected results:
 
-* CTDB should correctly record the connection and the takeover node
-  should send a reset packet.
+* CTDB should correctly record the connection and the releasing node
+  should reset the server end of the connection.
 EOF
 }
 
@@ -44,13 +39,18 @@ ctdb_restart_when_done
 # We need this for later, so we know how long to sleep.
 try_command_on_node 0 $CTDB getvar MonitorInterval
 monitor_interval="${out#*= }"
-#echo "Monitor interval on node $test_node is $monitor_interval seconds."
 
 select_test_node_and_ips
 
 test_port=445
 
-echo "Connecting to node ${test_node} on IP ${test_ip}:${test_port} with netcat..."
+echo "Set NoIPTakeover=1 on all nodes"
+try_command_on_node all $CTDB setvar NoIPTakeover 1
+
+echo "Give the recovery daemon some time to reload tunables"
+sleep_for 5
+
+echo "Connecting to node ${test_node} on IP ${test_ip}:${test_port} with nc..."
 
 nc -d -w $(($monitor_interval * 4)) $test_ip $test_port &
 nc_pid=$!
@@ -70,20 +70,29 @@ if [ "${out/SRC: ${src_socket} /}" != "$out" ] ; then
     echo "GOOD: CIFS connection tracked OK by CTDB."
 else
     echo "BAD: Socket not tracked by CTDB."
-    testfailures=1
+    exit 1
 fi
 
-# This is almost immediate.  However, it is sent between nodes
-# asynchonously, so it is worth checking...
-echo "Wait until CIFS connection is tracked by CTDB on all nodes..."
-try_command_on_node $test_node "$CTDB listnodes | wc -l"
-numnodes="$out"
-wait_until 5 \
-    check_tickles_all $numnodes  $test_ip $test_port $src_socket
-tcptickle_sniff_start $src_socket "${test_ip}:${test_port}"
+# It would be nice if ss consistently used local/peer instead of src/dst
+ss_filter="src ${test_ip}:${test_port} dst ${src_socket}"
+
+try_command_on_node $test_node \
+		    "ss -tn state established '${ss_filter}' | tail -n +2"
+if [ -z "$out" ] ; then
+	echo "BAD: ss did not list the socket"
+	exit 1
+fi
+echo "GOOD: ss lists the socket:"
+echo "$out"
 
 echo "Disabling node $test_node"
 try_command_on_node 1 $CTDB disable -n $test_node
 wait_until_node_has_status $test_node disabled
 
-tcptickle_sniff_wait_show
+try_command_on_node $test_node \
+		    "ss -tn state established '${ss_filter}' | tail -n +2"
+if [ -n "$out" ] ; then
+	echo "BAD: ss listed the socket after failover"
+	exit 1
+fi
+echo "GOOD: ss no longer lists the socket"
diff --git a/ctdb/tests/complex/37_nfs_reset_server.sh b/ctdb/tests/complex/37_nfs_reset_server.sh
new file mode 100755
index 0000000..d6dd0f0
--- /dev/null
+++ b/ctdb/tests/complex/37_nfs_reset_server.sh
@@ -0,0 +1,90 @@
+#!/bin/bash
+
+test_info()
+{
+    cat <<EOF
+Verify that the server end of an NFS connection is correctly reset
+
+Prerequisites:
+
+* An active CTDB cluster with at least 2 nodes with public addresses.
+
+* Test must be run on a real or virtual cluster rather than against
+  local daemons.
+
+* Test must not be run from a cluster node.
+
+* Cluster nodes must be listening on the NFS TCP port (2049).
+
+Expected results:
+
+* CTDB should correctly record the connection and the releasing node
+  should reset the server end of the connection.
+EOF
+}
+
+. "${TEST_SCRIPTS_DIR}/integration.bash"
+
+set -e
+
+ctdb_test_init "$@"
+
+ctdb_test_check_real_cluster
+
+cluster_is_healthy
+
+# Reset configuration
+ctdb_restart_when_done
+
+# We need this for later, so we know how long to sleep.
+try_command_on_node 0 $CTDB getvar MonitorInterval
+monitor_interval="${out#*= }"
+
+select_test_node_and_ips
+
+test_port=2049
+
+echo "Set NoIPTakeover=1 on all nodes"
+try_command_on_node all $CTDB setvar NoIPTakeover 1
+
+echo "Give the recovery daemon some time to reload tunables"
+sleep_for 5
+
+echo "Connecting to node ${test_node} on IP ${test_ip}:${test_port} with nc..."
+
+nc -d -w $(($monitor_interval * 4)) $test_ip $test_port &
+nc_pid=$!
+ctdb_test_exit_hook_add "kill $nc_pid >/dev/null 2>&1"
+
+wait_until_get_src_socket "tcp" "${test_ip}:${test_port}" $nc_pid "nc"
+src_socket="$out"
+echo "Source socket is $src_socket"
+
+echo "Wait until NFS connection is tracked by CTDB on test node ..."
+wait_until $((monitor_interval * 2)) \
+	   check_tickles $test_node $test_ip $test_port $src_socket
+echo "$out"
+
+# It would be nice if ss consistently used local/peer instead of src/dst
+ss_filter="src ${test_ip}:${test_port} dst ${src_socket}"
+
+try_command_on_node $test_node \
+		    "ss -tn state established '${ss_filter}' | tail -n +2"
+if [ -z "$out" ] ; then
+	echo "BAD: ss did not list the socket"
+	exit 1
+fi
+echo "GOOD: ss lists the socket:"
+echo "$out"
+
+echo "Disabling node $test_node"
+try_command_on_node 1 $CTDB disable -n $test_node
+wait_until_node_has_status $test_node disabled
+
+try_command_on_node $test_node \
+		    "ss -tn state established '${ss_filter}' | tail -n +2"
+if [ -n "$out" ] ; then
+	echo "BAD: ss listed the socket after failover"
+	exit 1
+fi
+echo "GOOD: ss no longer lists the socket"
diff --git a/ctdb/tests/eventscripts/10.interface.releaseip.010.sh b/ctdb/tests/eventscripts/10.interface.010.sh
similarity index 76%
rename from ctdb/tests/eventscripts/10.interface.releaseip.010.sh
rename to ctdb/tests/eventscripts/10.interface.010.sh
index 095e85c..f5fa062 100755
--- a/ctdb/tests/eventscripts/10.interface.releaseip.010.sh
+++ b/ctdb/tests/eventscripts/10.interface.010.sh
@@ -8,7 +8,8 @@ setup_ctdb
 
 ctdb_get_1_public_address |
 while read dev ip bits ; do
-	ip addr add "${ip}/${bits}" dev "$dev"
+	ok_null
+	simple_test_event "takeip" $dev $ip $bits
 
 	count=10
 	setup_tcp_connections $count \
@@ -18,5 +19,5 @@ while read dev ip bits ; do
 Killed ${count}/${count} TCP connections to released IP $ip
 EOF
 
-	simple_test $dev $ip $bits
+	simple_test_event "releaseip" $dev $ip $bits
 done
diff --git a/ctdb/tests/eventscripts/10.interface.releaseip.011.sh b/ctdb/tests/eventscripts/10.interface.011.sh
similarity index 82%
rename from ctdb/tests/eventscripts/10.interface.releaseip.011.sh
rename to ctdb/tests/eventscripts/10.interface.011.sh
index c129346..1b85cea 100755
--- a/ctdb/tests/eventscripts/10.interface.releaseip.011.sh
+++ b/ctdb/tests/eventscripts/10.interface.011.sh
@@ -8,7 +8,8 @@ setup_ctdb
 
 ctdb_get_1_public_address |
 while read dev ip bits ; do
-	ip addr add "${ip}/${bits}" dev "$dev"
+	ok_null
+	simple_test_event "takeip" $dev $ip $bits
 
 	count=10
 	setup_tcp_connections $count \
@@ -23,5 +24,5 @@ Remaining connections:
   10.0.0.3:445 10.254.254.1:43211
 EOF
 
-	simple_test $dev $ip $bits
+	simple_test_event "releaseip" $dev $ip $bits
 done
diff --git a/ctdb/tests/eventscripts/10.interface.releaseip.012.sh b/ctdb/tests/eventscripts/10.interface.012.sh
similarity index 84%
rename from ctdb/tests/eventscripts/10.interface.releaseip.012.sh
rename to ctdb/tests/eventscripts/10.interface.012.sh
index 53971fe..03c6c79 100755
--- a/ctdb/tests/eventscripts/10.interface.releaseip.012.sh
+++ b/ctdb/tests/eventscripts/10.interface.012.sh
@@ -8,7 +8,8 @@ setup_ctdb
 
 ctdb_get_1_public_address |
 while read dev ip bits ; do
-	ip addr add "${ip}/${bits}" dev "$dev"
+	ok_null
+	simple_test_event "takeip" $dev $ip $bits
 
 	count=10
 
@@ -26,5 +27,5 @@ Remaining connections:
   10.0.0.3:445 10.254.254.3:43213
 EOF
 
-	simple_test $dev $ip $bits
+	simple_test_event "releaseip"  $dev $ip $bits
 done
diff --git a/ctdb/tests/eventscripts/10.interface.releaseip.013.sh b/ctdb/tests/eventscripts/10.interface.013.sh
similarity index 87%
rename from ctdb/tests/eventscripts/10.interface.releaseip.013.sh
rename to ctdb/tests/eventscripts/10.interface.013.sh
index 91393d2..eb4c280 100755
--- a/ctdb/tests/eventscripts/10.interface.releaseip.013.sh
+++ b/ctdb/tests/eventscripts/10.interface.013.sh
@@ -8,7 +8,8 @@ setup_ctdb
 
 ctdb_get_1_public_address |
 while read dev ip bits ; do
-	ip addr add "${ip}/${bits}" dev "$dev"
+	ok_null
+	simple_test_event "takeip" $dev $ip $bits
 
 	setup_tcp_connections 0
 
@@ -31,5 +32,5 @@ Remaining connections:
   10.0.0.3:445 10.254.254.10:43220
 EOF
 
-    simple_test $dev $ip $bits
+    simple_test_event "releaseip"  $dev $ip $bits
 done
diff --git a/ctdb/tests/onnode/README b/ctdb/tests/onnode/README
deleted file mode 100644
index 5bb6952..0000000
--- a/ctdb/tests/onnode/README
+++ /dev/null
@@ -1,36 +0,0 @@
-onnode unit tests
-=================
-
-Examples:
-
-* ../run_tests.sh .
-
-  Run all tests, displaying output.
-
-* ../run_tests.sh -s .
-
-  Run all tests, displaying output and a summary.
-
-* ../run_tests.sh -sq .
-
-  Run all tests, displaying only a summary.
-
-* ONNODE=onnode-buggy-001 ../run_tests.sh -s .
-
-  Run against stubs/onnode-buggy-001 instead of default onnode version.
-
-  Add more buggy versions of onnode to this directory as bugs are
-  fixed to enable test validation using this feature.
-
-* ../run_tests.sh ./009*.sh
-
-  Run only the specified tests.
-
-* ONNODE="stubs/onnode-buggy-001" ../run_tests.sh -X ./0090.sh
-  ../run_tests.sh -X ./0090.sh
-
-  Debug the specified test or test failure by tracing onnode with
-  "bash -x".  The test will fail because the bash trace output will be
-  included in the test output.
-
-  To see if the test pases, the -X can be dropped...
diff --git a/ctdb/tests/onnode/stubs/onnode-buggy-001 b/ctdb/tests/onnode/stubs/onnode-buggy-001
deleted file mode 100755
index e044ee3..0000000
--- a/ctdb/tests/onnode/stubs/onnode-buggy-001
+++ /dev/null
@@ -1,376 +0,0 @@
-#!/bin/bash
-
-# Run commands on CTDB nodes.
-
-# See http://ctdb.samba.org/ for more information about CTDB.
-
-# Copyright (C) Martin Schwenke  2008
-
-# Based on an earlier script by Andrew Tridgell and Ronnie Sahlberg.
-
-# Copyright (C) Andrew Tridgell  2007
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-   
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-   
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
-
-prog=$(basename $0)
-
-usage ()
-{
-    cat >&2 <<EOF
-Usage: onnode [OPTION] ... <NODES> <COMMAND> ...
-  options:
-    -c          Run in current working directory on specified nodes.
-    -o <prefix> Save standard output from each node to file <prefix>.<ip>
-    -p          Run command in parallel on specified nodes.
-    -q          Do not print node addresses (overrides -v).
-    -n          Allow nodes to be specified by name.
-    -f          Specify nodes file, overrides CTDB_NODES_FILE.
-    -v          Print node address even for a single node.
-  <NODES>       "all", "any", "ok" (or "healthy"), "con" (or "connected"),
-                "rm" (or "recmaster"), "lvs" (or "lvsmaster"),
-                "natgw" (or "natgwlist"); or
-                a node number (0 base); or
-                a hostname (if -n is specified); or
-                list (comma separated) of <NODES>; or
-                range (hyphen separated) of node numbers.
-EOF
-    exit 1
-
-}
-
-invalid_nodespec ()
-{
-    echo "Invalid <nodespec>" >&2 ; echo >&2
-    usage
-}
-
-# Defaults.
-current=false
-parallel=false
-verbose=false
-quiet=false
-prefix=""
-names_ok=false
-
-ctdb_base="${CTDB_BASE:-/etc/ctdb}"
-
-parse_options ()
-{
-    # $POSIXLY_CORRECT means that the command passed to onnode can
-    # take options and getopt won't reorder things to make them
-    # options ot onnode.
-    local temp
-    # Not on the previous line - local returns 0!
-    temp=$(POSIXLY_CORRECT=1 getopt -n "$prog" -o "cf:hno:pqv" -l help -- "$@")
-
-    [ $? != 0 ] && usage
-
-    eval set -- "$temp"
-
-    while true ; do
-	case "$1" in
-	    -c) current=true ; shift ;;
-	    -f) CTDB_NODES_FILE="$2" ; shift 2 ;;
-	    -n) names_ok=true ; shift ;;
-	    -o) prefix="$2" ; shift 2 ;;
-	    -p) parallel=true ; shift ;;
-	    -q) quiet=true ; shift ;;
-	    -v) verbose=true ; shift ;;
-	    --) shift ; break ;;
-	    -h|--help|*) usage ;; # Shouldn't happen, so this is reasonable.
-	esac
-    done
-
-    [ $# -lt 2 ] && usage
-
-    nodespec="$1" ; shift
-    command="$@"
-}
-
-echo_nth ()
-{
-    local n="$1" ; shift
-
-    shift $n
-    local node="$1"
-
-    if [ -n "$node" -a "$node" != "#DEAD" ] ; then
-	echo $node
-    else
-	echo "${prog}: \"node ${n}\" does not exist" >&2
-	exit 1
-    fi
-}
-
-parse_nodespec ()
-{
-    # Subshell avoids hacks to restore $IFS.
-    (
-	IFS=","
-	for i in $1 ; do
-	    case "$i" in
-		*-*) seq "${i%-*}" "${i#*-}" 2>/dev/null || invalid_nodespec ;;
-		# Separate lines for readability.
-		all|any|ok|healthy|con|connected) echo "$i" ;;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list