1 # Hey Emacs, this is a -*- shell-script -*- !!! :-)
10 local pat
="^${proto}6?[[:space:]]+[[:digit:]]+[[:space:]]+[[:digit:]]+[[:space:]]+[^[:space:]]+[[:space:]]+${dst_socket//./\\.}[[:space:]]+ESTABLISHED[[:space:]]+${pid}/${prog}[[:space:]]*\$"
18 wait_until_get_src_socket
()
25 echo "Waiting for ${prog} to establish connection to ${dst_socket}..."
27 wait_until
5 get_src_socket
"$@"
30 #######################################
38 try_command_on_node
$node ctdb gettickles
$test_ip $test_port
39 # SRC: 10.0.2.45:49091 DST: 10.0.2.143:445
40 [ "${out/SRC: ${src_socket} /}" != "$out" ]
50 try_command_on_node all ctdb gettickles
$test_ip $test_port
51 # SRC: 10.0.2.45:49091 DST: 10.0.2.143:445
52 local t
="${src_socket//./\\.}"
53 local count
=$
(grep -E -c "SRC: ${t} " <<<"$out" || true
)
54 [ $count -eq $numnodes ]
59 #######################################
61 # filename will be in $tcpdump_filename, pid in $tcpdump_pid
64 tcpdump_filter
="$1" # global
66 echo "Running tcpdump..."
67 tcpdump_filename
=$
(mktemp
)
68 ctdb_test_exit_hook_add
"rm -f $tcpdump_filename"
70 # The only way of being sure that tcpdump is listening is to send
71 # some packets that it will see. So we use dummy pings - the -U
72 # option to tcpdump ensures that packets are flushed to the file
73 # as they are captured.
74 local dummy_addr
="127.3.2.1"
75 local dummy
="icmp and dst host ${dummy_addr} and icmp[icmptype] == icmp-echo"
76 tcpdump
-n -p -s 0 -e -U -w $tcpdump_filename -i any
"($tcpdump_filter) or ($dummy)" &
77 ctdb_test_exit_hook_add
"kill $! >/dev/null 2>&1"
79 echo "Waiting for tcpdump output file to be ready..."
80 ping -q "$dummy_addr" >/dev
/null
2>&1 &
81 ctdb_test_exit_hook_add
"kill $! >/dev/null 2>&1"
83 tcpdump_listen_for_dummy
()
85 tcpdump
-n -r $tcpdump_filename -c 1 "$dummy" >/dev
/null
2>&1
88 wait_until
10 tcpdump_listen_for_dummy
91 # By default, wait for 1 matching packet.
95 local filter
="${2:-${tcpdump_filter}}"
99 local found
=$
(tcpdump
-n -r $tcpdump_filename "$filter" 2>/dev
/null |
wc -l)
100 [ $found -ge $count ]
103 echo "Waiting for tcpdump to capture some packets..."
104 if ! wait_until
30 tcpdump_check
; then
105 echo "DEBUG AT $(date '+%F %T'):"
107 for i
in "onnode -q 0 $CTDB status" "netstat -tanp" "tcpdump -n -e -r $tcpdump_filename" ; do
117 local filter
="${1:-${tcpdump_filter}}"
119 tcpdump
-n -r $tcpdump_filename "$filter" 2>/dev
/null
122 tcptickle_sniff_start
()
127 local in="src host ${dst%:*} and tcp src port ${dst##*:} and dst host ${src%:*} and tcp dst port ${src##*:}"
128 local out
="src host ${src%:*} and tcp src port ${src##*:} and dst host ${dst%:*} and tcp dst port ${dst##*:}"
129 local tickle_ack
="${in} and (tcp[tcpflags] & tcp-ack != 0) and (tcp[14] == 4) and (tcp[15] == 210)" # win == 1234
130 local ack_ack
="${out} and (tcp[tcpflags] & tcp-ack != 0)"
131 tcptickle_reset
="${in} and tcp[tcpflags] & tcp-rst != 0"
132 local filter
="(${tickle_ack}) or (${ack_ack}) or (${tcptickle_reset})"
134 tcpdump_start
"$filter"
137 tcptickle_sniff_wait_show
()
139 tcpdump_wait
1 "$tcptickle_reset"
141 echo "GOOD: here are some TCP tickle packets:"
145 gratarp_sniff_start
()
147 tcpdump_start
"arp host ${test_ip}"
150 gratarp_sniff_wait_show
()
154 echo "GOOD: this should be the some gratuitous ARPs:"
159 ctdb_test_check_real_cluster
()
161 [ -z "$TEST_LOCAL_DAEMONS" ] || \
162 die
"ERROR: This test must be run against a real/virtual cluster, not local daemons."
167 for i
in $
(onnode
-q all hostname
) ; do
168 [ "$h" != "$i" ] || \
169 die
"ERROR: This test must not be run from a cluster node."