1 #!/bin/sh 2 # Copyright (c) 2017-2018 Petr Vorel <pvorel (at] suse.cz> 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, see <http://www.gnu.org/licenses/>. 18 # 19 # Author: Mitsuru Chinen <mitch (at] jp.ibm.com> 20 21 IF_CMD='route' 22 . if-lib.sh 23 24 CHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 20))} 25 26 test_body() 27 { 28 local cmd="$CMD" 29 local iface=$(tst_iface) 30 local inet="inet$TST_IPV6" 31 local new_rt= 32 local opt_rt= 33 if [ "$TST_IPV6" ]; then 34 new_rt="$(TST_IPV6=6 tst_ipaddr_un 0)" 35 opt_rt="/64" 36 else 37 new_rt="$(tst_ipaddr_un 23)" 38 if [ "$cmd" = "ip" ]; then 39 opt_rt='/24' 40 fi 41 fi 42 43 tst_res TINFO "'$cmd' add/del ${new_rt}${opt_rt} $NS_TIMES times" 44 45 if ! restore_ipaddr; then 46 tst_res TBROK "Failed to set default IP addresses" 47 return 48 fi 49 50 local cnt=1 51 while [ $cnt -le $NS_TIMES ]; do 52 make_background_tcp_traffic 53 54 case $cmd in 55 route) route -A $inet add ${new_rt}${opt_rt} dev $iface ;; 56 ip) ip route add ${new_rt}${opt_rt} dev $iface ;; 57 esac 58 if [ $? -ne 0 ]; then 59 tst_res TFAIL "Can't add route $new_rt to $iface" 60 return 61 fi 62 63 case $cmd in 64 route) route -A $inet del ${new_rt}${opt_rt} dev $iface ;; 65 ip) ip route del ${new_rt}${opt_rt} dev $iface ;; 66 esac 67 if [ $? -ne 0 ]; then 68 tst_res TFAIL "Can't del route $new_rt from $iface" 69 return 70 fi 71 72 check_connectivity_interval $cnt || return 73 74 cnt=$(($cnt + 1)) 75 done 76 77 tst_res TPASS "Test is finished correctly" 78 } 79 80 tst_run 81