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 new_rt= 16 local opt_rt= 17 if [ "$TST_IPV6" ]; then 18 new_rt="$(TST_IPV6=6 tst_ipaddr_un 0)" 19 opt_rt="/64" 20 else 21 new_rt="$(tst_ipaddr_un 23)" 22 if [ "$cmd" = "ip" ]; then 23 opt_rt='/24' 24 fi 25 fi 26 27 tst_res TINFO "'$cmd' add/del ${new_rt}${opt_rt} $NS_TIMES times" 28 29 if ! restore_ipaddr; then 30 tst_res TBROK "Failed to set default IP addresses" 31 return 32 fi 33 34 local cnt=1 35 while [ $cnt -le $NS_TIMES ]; do 36 make_background_tcp_traffic 37 38 case $cmd in 39 route) route -A $inet add ${new_rt}${opt_rt} dev $iface ;; 40 ip) ip route add ${new_rt}${opt_rt} dev $iface ;; 41 esac 42 if [ $? -ne 0 ]; then 43 tst_res TFAIL "Can't add route $new_rt to $iface" 44 return 45 fi 46 47 case $cmd in 48 route) route -A $inet del ${new_rt}${opt_rt} dev $iface ;; 49 ip) ip route del ${new_rt}${opt_rt} dev $iface ;; 50 esac 51 if [ $? -ne 0 ]; then 52 tst_res TFAIL "Can't del route $new_rt from $iface" 53 return 54 fi 55 56 check_connectivity_interval $cnt || return 57 58 cnt=$(($cnt + 1)) 59 done 60 61 tst_res TPASS "Test is finished correctly" 62} 63 64. if-lib.sh 65 66CHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 20))} 67 68tst_run 69