1 #!/bin/sh 2 3 # Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. 4 # Copyright (c) International Business Machines Corp., 2005 5 # 6 # This program is free software; you can redistribute it and/or 7 # modify it under the terms of the GNU General Public License as 8 # published by the Free Software Foundation; either version 2 of 9 # the License, or (at your option) any later version. 10 # 11 # This program is distributed in the hope that it would be useful, 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 # GNU General Public License for more details. 15 # 16 # You should have received a copy of the GNU General Public License 17 # along with this program; if not, write the Free Software Foundation, 18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 # 20 # Author: Mitsuru Chinen <mitch (at] jp.ibm.com> 21 # 22 23 TCID="ssh_stress03_rmt" 24 TST_TOTAL=1 25 26 . test.sh 27 28 # Check the arguments 29 if [ $# -ne 5 ]; then 30 tst_brkm TBROK "Usage: $0 ipver rhost config port requests" 31 fi 32 33 ip_ver="$1" 34 server_ipaddr="$2" 35 ssh_config="$3" 36 rport="$4" 37 requests="$5" 38 39 ssh -$ip_ver -F $ssh_config $server_ipaddr \ 40 "true < /dev/null > /dev/null 2>&1" > /dev/null 41 [ $? -ne 0 ] && tst_brkm TBROK "Failed to connect '$server_ipaddr'" 42 43 lport=$(tst_get_unused_port ipv${ip_ver} stream) 44 45 # Set the ssh port-forwarding 46 case $ip_ver in 47 4) 48 localhost="127.0.0.1" 49 ssh -4 -f -N -L $lport:$server_ipaddr:$rport \ 50 root@$server_ipaddr -F $ssh_config 51 ;; 52 6) 53 localhost="::1" 54 ssh -6 -f -N -L $lport/[$server_ipaddr]/$rport \ 55 root@$server_ipaddr -F $ssh_config 56 ;; 57 esac 58 59 # Start the TCP traffic clients 60 netstress -r $requests -l -H $localhost -g $lport > /dev/null 61 ret=$? 62 63 # Stop the ssh port forwarding 64 all_conn=$(ps auxw | grep -Fv grep | \ 65 grep "ssh[[:blank:]].*${ssh_config}" | awk '{print $2}') 66 for ssh_pid in $all_conn ; do 67 kill $ssh_pid 68 done 69 70 [ $ret -ne 0 ] && tst_brkm TBROK "TCP traffic client is dead" 71 72 # Check the connectivity again 73 ssh -$ip_ver -F $ssh_config $server_ipaddr \ 74 "true < /dev/null > /dev/null 2>&1" > /dev/null 75 [ $? -ne 0 ] && tst_brkm TBROK "Failed to connect '$server_ipaddr'" 76 77 tst_exit 78