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-addr-addlarge 22 23 . if-lib.sh 24 25 # The interval of the check interface activity (check ten times) 26 CHECK_INTERVAL=${CHECK_INTERVAL:-$(($IP_TOTAL / 100))} 27 28 test_body() 29 { 30 local cmd_type=$1 31 32 case $cmd_type in 33 if_cmd) local cmd_name='ifconfig' ;; 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 [ "$TST_IPV6" ] && local netmask=64 || local netmask=16 40 41 tst_resm TINFO "'$cmd_name' add $IP_TOTAL IPv$ipver addresses" 42 tst_resm TINFO "check interval that $iface is working: $CHECK_INTERVAL" 43 44 tst_restore_ipaddr || \ 45 tst_resm TBROK "Failed to set default IP addresses" 46 47 make_background_tcp_traffic 48 49 local x=1 50 local y=1 51 local cnt=1 52 53 [ "$TST_IPV6" ] && local xymax=65535 || xymax=254 54 55 if [ $IP_TOTAL -gt $((xymax * xymax)) ]; then 56 tst_resm TWARN "set IP_TOTAL to $xymax * $xymax" 57 IP_TOTAL=$((xymax * xymax)) 58 fi 59 60 while [ $cnt -le $IP_TOTAL ]; do 61 62 if [ "$TST_IPV6" ]; then 63 local hex_x=$(printf '%x' $x) 64 local hex_y=$(printf '%x' $y) 65 local new_ip=${IPV6_NET32_UNUSED}:1:1:1:$hex_x:$hex_y:1 66 else 67 local new_ip=${IPV4_NET16_UNUSED}.$x.$y 68 fi 69 70 tst_resm TINFO "set new ip $new_ip" 71 72 case $cmd_type in 73 if_cmd) 74 if [ "$TST_IPV6" ]; then 75 ifconfig $iface add $new_ip/$netmask 76 else 77 ifconfig $iface:$x:$y $new_ip netmask 255.255.0.0 78 fi 79 ;; 80 ip_cmd) ip addr add $new_ip/$netmask dev $iface ;; 81 esac 82 83 if [ $? -ne 0 ]; then 84 tst_resm TFAIL "command failed to add $new_ip to $iface" 85 return 86 fi 87 88 ip addr show $iface | grep -q $new_ip 89 if [ $? -ne 0 ]; then 90 ip addr show $iface 91 tst_resm TFAIL "$new_ip not configured" 92 return 93 fi 94 95 # Check the connectivity 96 check_connectivity $cnt || return 97 98 # Check the background TCP traffic 99 pgrep -x tcp_fastopen > /dev/null || make_background_tcp_traffic 100 101 case $cmd_type in 102 if_cmd) 103 if [ "$TST_IPV6" ]; then 104 ifconfig $iface del $new_ip/$netmask 105 else 106 ifconfig $iface:$x:$y down 107 fi 108 ;; 109 ip_cmd) ip addr del $new_ip/$netmask dev $iface ;; 110 esac 111 112 if [ $? -ne 0 ]; then 113 tst_resm TFAIL " delete command failed". 114 return 115 fi 116 117 ip addr show $iface | grep -q $new_ip 118 if [ $? -eq 0 ]; then 119 ip addr show $iface 120 tst_resm TFAIL "Failed to remove '$new_ip' address" 121 return 122 fi 123 124 cnt=$(($cnt + 1)) 125 y=$(($y + 1)) 126 if [ $y -gt $xymax ]; then 127 y=1 128 x=$(($x + 1)) 129 if [ $x -gt $xymax ]; then 130 tst_brkm TBROK "Too large $IP_TOTAL" 131 fi 132 fi 133 done 134 135 tst_resm TPASS "Test is finished correctly" 136 } 137 138 setup 139 140 tst_check_cmds ifconfig 141 142 test_body 'if_cmd' 143 test_body 'ip_cmd' 144 145 tst_exit 146