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@jp.ibm.com> 21# 22 23TCID="ssh_stress03_rmt" 24TST_TOTAL=1 25 26. test.sh 27 28# Check the arguments 29if [ $# -ne 5 ]; then 30 tst_brkm TBROK "Usage: $0 ipver rhost config port requests" 31fi 32 33ip_ver="$1" 34server_ipaddr="$2" 35ssh_config="$3" 36rport="$4" 37requests="$5" 38 39ssh -$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 43lport=$(tst_get_unused_port ipv${ip_ver} stream) 44 45# Set the ssh port-forwarding 46case $ip_ver in 474) 48 localhost="127.0.0.1" 49 ssh -4 -f -N -L $lport:$server_ipaddr:$rport \ 50 root@$server_ipaddr -F $ssh_config 51;; 526) 53 localhost="::1" 54 ssh -6 -f -N -L $lport:[$server_ipaddr]:$rport \ 55 root@$server_ipaddr -F $ssh_config 56;; 57esac 58 59# Start the TCP traffic clients 60netstress -r $requests -l -H $localhost -g $lport > /dev/null 61ret=$? 62 63# Stop the ssh port forwarding 64all_conn=$(ps auxw | grep -Fv grep | \ 65 grep "ssh[[:blank:]].*${ssh_config}" | awk '{print $2}') 66for ssh_pid in $all_conn ; do 67 kill $ssh_pid 68done 69 70[ $ret -ne 0 ] && tst_brkm TBROK "TCP traffic client is dead" 71 72# Check the connectivity again 73ssh -$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 77tst_exit 78