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