1 #!/bin/sh 2 # Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. 3 # Copyright (c) International Business Machines Corp., 2005 4 # 5 # This program is free software; you can redistribute it and/or 6 # modify it under the terms of the GNU General Public License as 7 # published by the Free Software Foundation; either version 2 of 8 # the License, or (at your option) any later version. 9 # 10 # This program is distributed in the hope that it would be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program. If not, see <http://www.gnu.org/licenses/>. 17 # 18 # Author: Mitsuru Chinen <mitch (at] jp.ibm.com> 19 20 TST_TOTAL=2 21 22 TST_CLEANUP="netstress_cleanup" 23 24 . test_net_stress.sh 25 26 CHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 20))} 27 28 test_body() 29 { 30 local cmd_type=$1 31 32 case $cmd_type in 33 rt_cmd) local cmd_name='route' ;; 34 ip_cmd) local cmd_name='ip' ;; 35 *) tst_brkm TBROK "Unknown test parameter '$cmd_type'" 36 esac 37 38 local iface=$(tst_iface) 39 local inet="inet$TST_IPV6" 40 local new_rt= 41 local opt_rt= 42 if [ "$TST_IPV6" ]; then 43 new_rt="$(TST_IPV6=6 tst_ipaddr_un 0)" 44 opt_rt="/64" 45 else 46 new_rt="$(tst_ipaddr_un 23)" 47 case $cmd_type in 48 rt_cmd) ;; 49 ip_cmd) opt_rt='/24' ;; 50 esac 51 fi 52 53 tst_resm TINFO "'$cmd_name' add/del ${new_rt}${opt_rt} $NS_TIMES times" 54 55 if ! restore_ipaddr; then 56 tst_resm TBROK "Failed to set default IP addresses" 57 return 58 fi 59 60 local cnt=1 61 while [ $cnt -le $NS_TIMES ]; do 62 make_background_tcp_traffic 63 64 case $cmd_type in 65 rt_cmd) route -A $inet add ${new_rt}${opt_rt} dev $iface ;; 66 ip_cmd) ip route add ${new_rt}${opt_rt} dev $iface ;; 67 esac 68 if [ $? -ne 0 ]; then 69 tst_resm TFAIL "Can't add route $new_rt to $iface" 70 return 71 fi 72 73 case $cmd_type in 74 rt_cmd) route -A $inet del ${new_rt}${opt_rt} dev $iface ;; 75 ip_cmd) ip route del ${new_rt}${opt_rt} dev $iface ;; 76 esac 77 if [ $? -ne 0 ]; then 78 tst_resm TFAIL "Can't del route $new_rt from $iface" 79 return 80 fi 81 82 check_connectivity_interval $cnt || return 83 84 cnt=$(($cnt + 1)) 85 done 86 87 tst_resm TPASS "Test is finished correctly" 88 } 89 90 netstress_setup 91 92 tst_check_cmds route 93 94 test_body 'rt_cmd' 95 test_body 'ip_cmd' 96 97 tst_exit 98