1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0-or-later 3# Copyright (c) 2017-2018 Petr Vorel <pvorel@suse.cz> 4# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. 5# Copyright (c) International Business Machines Corp., 2005 6# Author: Mitsuru Chinen <mitch@jp.ibm.com> 7 8IF_CMD='route' 9. if-lib.sh 10 11CHECK_INTERVAL=${CHECK_INTERVAL:-$(($ROUTE_TOTAL / 20))} 12 13test_body() 14{ 15 local cmd="$CMD" 16 local iface=$(tst_iface) 17 local inet="inet$TST_IPV6" 18 local opt_rt= 19 if [ "$TST_IPV6" ]; then 20 opt_rt="/64" 21 elif [ "$cmd" = "ip" ]; then 22 opt_rt='/32' 23 fi 24 25 tst_res TINFO "'$cmd' add IPv$TST_IPVER $ROUTE_TOTAL routes" 26 27 if ! restore_ipaddr; then 28 tst_res TBROK "Failed to set default IP addresses" 29 return 30 fi 31 32 local x=1 33 local y=1 34 local cnt=1 35 36 [ "$TST_IPV6" ] && local xymax=65535 || xymax=254 37 38 if [ $ROUTE_TOTAL -gt $((xymax * xymax)) ]; then 39 tst_res TWARN "set ROUTE_TOTAL to $xymax * $xymax" 40 ROUTE_TOTAL=$((xymax * xymax)) 41 fi 42 43 while [ $cnt -le $ROUTE_TOTAL ]; do 44 make_background_tcp_traffic 45 46 if [ "$TST_IPV6" ]; then 47 local hex_x=$(printf '%x' $x) 48 local hex_y=$(printf '%x' $y) 49 local new_rt=${IPV6_NET32_UNUSED}:$hex_x:$hex_y:: 50 else 51 local new_rt=${IPV4_NET16_UNUSED}.$x.$y 52 fi 53 54 case $cmd in 55 route) route -A $inet add ${new_rt}${opt_rt} dev $iface ;; 56 ip) ip route add ${new_rt}${opt_rt} dev $iface ;; 57 esac 58 if [ $? -ne 0 ]; then 59 tst_res TFAIL "Can't add route $new_rt to $iface" 60 return 61 fi 62 63 check_connectivity_interval $cnt || return 64 65 cnt=$(($cnt + 1)) 66 y=$(($y + 1)) 67 if [ $y -gt $xymax ]; then 68 y=1 69 x=$(($x + 1)) 70 if [ $x -gt $xymax ]; then 71 tst_brk TBROK "Too large $ROUTE_TOTAL" 72 fi 73 fi 74 done 75 76 tst_res TPASS "Test is finished correctly" 77} 78 79tst_run 80