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 TCID=if-mtu-change 22 23 . if-lib.sh 24 25 # The interval of the mtu change [second] 26 CHANGE_INTERVAL=${CHANGE_INTERVAL:-5} 27 CHECK_INTERVAL=${CHECK_INTERVAL:-$(($MTU_CHANGE_TIMES / 100))} 28 # The array of the value which MTU is changed into sequentially 29 CHANGE_VALUES="784 1142 426 1500 68 1500 68 748 68 1142 1500" 30 CHANGE6_VALUES="1280 1445 1335 1390 1500 1280 1500 1280 1335 1500" 31 [ "$TST_IPV6" ] && CHANGE_VALUES=$CHANGE6_VALUES 32 33 test_body() 34 { 35 local cmd_type=$1 36 37 case $cmd_type in 38 if_cmd) local cmd_name='ifconfig' ;; 39 ip_cmd) local cmd_name='ip' ;; 40 *) tst_brkm TBROK "Unknown test parameter '$cmd_type'" 41 esac 42 43 local iface=$(tst_iface) 44 [ "$TST_IPV6" ] && local netmask=64 || local netmask=16 45 46 tst_resm TINFO "'$cmd_name changes MTU $MTU_CHANGE_TIMES times " \ 47 "every $CHANGE_INTERVAL seconds" 48 49 tst_restore_ipaddr || \ 50 tst_resm TBROK "Failed to set default IP addresses" 51 52 make_background_tcp_traffic 53 54 mtu_array_len=$(echo $CHANGE_VALUES | wc -w) 55 local cnt=0 56 while [ $cnt -lt $MTU_CHANGE_TIMES ]; do 57 sleep $CHANGE_INTERVAL 58 local nth=$(($cnt % $mtu_array_len)) 59 field=$(($nth + 1)) 60 cnt=$(($cnt + 1)) 61 mtu=$(echo $CHANGE_VALUES | cut -d ' ' -f $field) 62 [ $cnt -eq $MTU_CHANGE_TIMES ] && mtu=1500 63 64 tst_resm TINFO "set MTU to $mtu $cnt/$MTU_CHANGE_TIMES" 65 case $cmd_type in 66 if_cmd) ifconfig $iface mtu $mtu ;; 67 ip_cmd) ip link set $iface mtu $mtu ;; 68 esac 69 70 if [ $? -ne 0 ]; then 71 tst_resm TFAIL "Failed to change the mtu at $cnt time" 72 return 73 fi 74 75 check_connectivity $cnt || return 76 77 # Check the background TCP traffic 78 pgrep -x tcp_fastopen > /dev/null || make_background_tcp_traffic 79 done 80 81 tst_resm TINFO "check connectivity through $iface" 82 check_icmpv${ipver}_connectivity $iface $(tst_ipaddr rhost) 83 if [ $? -ne 0 ]; then 84 tst_resm TFAIL "$iface is broken" 85 return 86 fi 87 88 tst_resm TPASS "Test is finished correctly" 89 } 90 91 setup 92 93 tst_check_cmds ifconfig 94 95 test_body 'if_cmd' 96 test_body 'ip_cmd' 97 98 tst_exit 99