1#!/bin/sh 2# Copyright (c) 2017-2018 Petr Vorel <pvorel@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@jp.ibm.com> 20 21IF_CMD='route' 22. if-lib.sh 23 24CHECK_INTERVAL=${CHECK_INTERVAL:-$(($ROUTE_TOTAL / 20))} 25 26test_body() 27{ 28 local cmd="$CMD" 29 local iface=$(tst_iface) 30 local inet="inet$TST_IPV6" 31 local opt_rt= 32 if [ "$TST_IPV6" ]; then 33 opt_rt="/64" 34 elif [ "$cmd" = "ip" ]; then 35 opt_rt='/32' 36 fi 37 38 tst_res TINFO "'$cmd' add IPv$TST_IPVER $ROUTE_TOTAL routes" 39 40 if ! restore_ipaddr; then 41 tst_res TBROK "Failed to set default IP addresses" 42 return 43 fi 44 45 local x=1 46 local y=1 47 local cnt=1 48 49 [ "$TST_IPV6" ] && local xymax=65535 || xymax=254 50 51 if [ $ROUTE_TOTAL -gt $((xymax * xymax)) ]; then 52 tst_res TWARN "set ROUTE_TOTAL to $xymax * $xymax" 53 ROUTE_TOTAL=$((xymax * xymax)) 54 fi 55 56 while [ $cnt -le $ROUTE_TOTAL ]; do 57 make_background_tcp_traffic 58 59 if [ "$TST_IPV6" ]; then 60 local hex_x=$(printf '%x' $x) 61 local hex_y=$(printf '%x' $y) 62 local new_rt=${IPV6_NET32_UNUSED}:$hex_x:$hex_y:: 63 else 64 local new_rt=${IPV4_NET16_UNUSED}.$x.$y 65 fi 66 67 case $cmd in 68 route) route -A $inet add ${new_rt}${opt_rt} dev $iface ;; 69 ip) ip route add ${new_rt}${opt_rt} dev $iface ;; 70 esac 71 if [ $? -ne 0 ]; then 72 tst_res TFAIL "Can't add route $new_rt to $iface" 73 return 74 fi 75 76 check_connectivity_interval $cnt || return 77 78 cnt=$(($cnt + 1)) 79 y=$(($y + 1)) 80 if [ $y -gt $xymax ]; then 81 y=1 82 x=$(($x + 1)) 83 if [ $x -gt $xymax ]; then 84 tst_brk TBROK "Too large $ROUTE_TOTAL" 85 fi 86 fi 87 done 88 89 tst_res TPASS "Test is finished correctly" 90} 91 92tst_run 93