1 #!/bin/sh 2 # Copyright (c) 2015-2017 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="do_cleanup" 23 24 . test_net_stress.sh 25 26 # The interval of the mtu change [second] 27 CHANGE_INTERVAL=${CHANGE_INTERVAL:-5} 28 29 # The array of the value which MTU is changed into sequentially 30 # 552 - net.ipv4.route.min_pmtu 31 CHANGE_VALUES="784 1142 552 1500 552 1500 552 748 552 1142 1500" 32 CHANGE6_VALUES="1280 1445 1335 1390 1500 1280 1500 1280 1335 1500" 33 [ "$TST_IPV6" ] && CHANGE_VALUES=$CHANGE6_VALUES 34 saved_mtu= 35 36 do_cleanup() 37 { 38 netstress_cleanup 39 if [ "$saved_mtu" ]; then 40 ip li set $(tst_iface) mtu $saved_mtu 41 tst_rhost_run -c "ip li set $(tst_iface rhost) mtu $saved_mtu" 42 fi 43 tst_restore_ipaddr 44 tst_restore_ipaddr rhost 45 tst_wait_ipv6_dad 46 } 47 48 test_body() 49 { 50 local cmd_type=$1 51 52 case $cmd_type in 53 if_cmd) local cmd_name='ifconfig' ;; 54 ip_cmd) local cmd_name='ip' ;; 55 *) tst_brkm TBROK "Unknown test parameter '$cmd_type'" 56 esac 57 58 local iface=$(tst_iface) 59 local iface_rmt=$(tst_iface rhost) 60 [ "$TST_IPV6" ] && local netmask=64 || local netmask=16 61 62 tst_resm TINFO "'$cmd_name changes MTU $MTU_CHANGE_TIMES times" \ 63 "every $CHANGE_INTERVAL seconds" 64 65 mtu_array_len=$(echo $CHANGE_VALUES | wc -w) 66 local cnt=0 67 while [ $cnt -lt $MTU_CHANGE_TIMES ]; do 68 local nth=$(($cnt % $mtu_array_len)) 69 field=$(($nth + 1)) 70 cnt=$(($cnt + 1)) 71 mtu=$(echo $CHANGE_VALUES | cut -d ' ' -f $field) 72 [ $cnt -eq $MTU_CHANGE_TIMES ] && mtu="$saved_mtu" 73 74 make_background_tcp_traffic 75 76 tst_resm TINFO "set MTU to $mtu $cnt/$MTU_CHANGE_TIMES" 77 local ret=0 78 case $cmd_type in 79 if_cmd) ifconfig $iface mtu $mtu || ret=1 80 tst_rhost_run -c "ifconfig $iface_rmt mtu $mtu" 81 ;; 82 ip_cmd) ip link set $iface mtu $mtu || ret=1 83 tst_rhost_run -c "ip link set $iface_rmt mtu $mtu" 84 ;; 85 esac 86 87 if [ $? -ne 0 -o $ret -ne 0 ]; then 88 tst_resm TFAIL "Failed to change the mtu at $cnt time" 89 return 90 fi 91 92 tst_sleep $CHANGE_INTERVAL 93 94 tst_ping $(tst_ipaddr) $(tst_ipaddr rhost) "1 1000 65507" 95 done 96 } 97 98 netstress_setup 99 100 tst_check_cmds ifconfig 101 102 saved_mtu="$(cat /sys/class/net/$(tst_iface)/mtu)" 103 104 test_body 'if_cmd' 105 test_body 'ip_cmd' 106 107 tst_exit 108