Home | History | Annotate | Download | only in interface
      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-route-addlarge
     22 
     23 . if-lib.sh
     24 
     25 TST_CLEANUP="do_cleanup"
     26 
     27 CHECK_INTERVAL=${CHECK_INTERVAL:-$(($ROUTE_TOTAL / 20))}
     28 
     29 do_cleanup()
     30 {
     31 	cleanup
     32 	restore_ipaddr
     33 }
     34 
     35 test_body()
     36 {
     37 	local cmd_type=$1
     38 
     39 	case $cmd_type in
     40 	rt_cmd) local cmd_name='route' ;;
     41 	ip_cmd) local cmd_name='ip' ;;
     42 	*) tst_brkm TBROK "Unknown test parameter '$cmd_type'"
     43 	esac
     44 
     45 	local iface=$(tst_iface)
     46 	local inet="inet$TST_IPV6"
     47 	local opt_rt=
     48 	if [ "$TST_IPV6" ]; then
     49 		opt_rt="/64"
     50 	else
     51 		case $cmd_type in
     52 		rt_cmd) ;;
     53 		ip_cmd) opt_rt='/32' ;;
     54 		esac
     55 	fi
     56 
     57 	tst_resm TINFO "'$cmd_name' add IPv$ipver $ROUTE_TOTAL routes"
     58 
     59 	if ! restore_ipaddr; then
     60 		tst_resm TBROK "Failed to set default IP addresses"
     61 		return
     62 	fi
     63 
     64 	make_background_tcp_traffic
     65 
     66 	local x=1
     67 	local y=1
     68 	local cnt=1
     69 
     70 	[ "$TST_IPV6" ] && local xymax=65535 || xymax=254
     71 
     72 	if [ $ROUTE_TOTAL -gt $((xymax * xymax)) ]; then
     73 		tst_resm TWARN "set ROUTE_TOTAL to $xymax * $xymax"
     74 		ROUTE_TOTAL=$((xymax * xymax))
     75 	fi
     76 
     77 	while [ $cnt -le $ROUTE_TOTAL ]; do
     78 
     79 		if [ "$TST_IPV6" ]; then
     80 			local hex_x=$(printf '%x' $x)
     81 			local hex_y=$(printf '%x' $y)
     82 			local new_rt=${IPV6_NET32_UNUSED}:$hex_x:$hex_y::
     83 		else
     84 			local new_rt=${IPV4_NET16_UNUSED}.$x.$y
     85 		fi
     86 
     87 		case $cmd_type in
     88 		rt_cmd) route -A $inet add ${new_rt}${opt_rt} dev $iface ;;
     89 		ip_cmd) ip route add ${new_rt}${opt_rt} dev $iface ;;
     90 		esac
     91 		if [ $? -ne 0 ]; then
     92 			tst_resm TFAIL "Can't add route $new_rt to $iface"
     93 			return
     94 		fi
     95 
     96 		check_connectivity $cnt || return
     97 
     98 		# Check the background TCP traffic
     99 		pgrep -x netstress > /dev/null || make_background_tcp_traffic
    100 
    101 		cnt=$(($cnt + 1))
    102 		y=$(($y + 1))
    103 		if [ $y -gt $xymax ]; then
    104 			y=1
    105 			x=$(($x + 1))
    106 			if [ $x -gt $xymax ]; then
    107 				tst_brkm TBROK "Too large $ROUTE_TOTAL"
    108 			fi
    109 		fi
    110 	done
    111 
    112 	tst_resm TPASS "Test is finished correctly"
    113 }
    114 
    115 setup
    116 
    117 tst_check_cmds route
    118 
    119 test_body 'rt_cmd'
    120 test_body 'ip_cmd'
    121 
    122 tst_exit
    123