1f08c3bdfSopenharmony_ci#!/bin/sh 2f08c3bdfSopenharmony_ci# SPDX-License-Identifier: GPL-2.0-or-later 3f08c3bdfSopenharmony_ci# Copyright (c) 2017-2022 Petr Vorel <pvorel@suse.cz> 4f08c3bdfSopenharmony_ci# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. 5f08c3bdfSopenharmony_ci# Copyright (c) International Business Machines Corp., 2005 6f08c3bdfSopenharmony_ci# Author: Mitsuru Chinen <mitch@jp.ibm.com> 7f08c3bdfSopenharmony_ci 8f08c3bdfSopenharmony_ciIF_CMD='route' 9f08c3bdfSopenharmony_ci 10f08c3bdfSopenharmony_citest_body() 11f08c3bdfSopenharmony_ci{ 12f08c3bdfSopenharmony_ci local cmd="$CMD" 13f08c3bdfSopenharmony_ci local iface=$(tst_iface) 14f08c3bdfSopenharmony_ci local inet="inet$TST_IPV6" 15f08c3bdfSopenharmony_ci local new_rt= 16f08c3bdfSopenharmony_ci local opt_rt= 17f08c3bdfSopenharmony_ci if [ "$TST_IPV6" ]; then 18f08c3bdfSopenharmony_ci new_rt="$(TST_IPV6=6 tst_ipaddr_un 0)" 19f08c3bdfSopenharmony_ci opt_rt="/64" 20f08c3bdfSopenharmony_ci else 21f08c3bdfSopenharmony_ci new_rt="$(tst_ipaddr_un 23)" 22f08c3bdfSopenharmony_ci if [ "$cmd" = "ip" ]; then 23f08c3bdfSopenharmony_ci opt_rt='/24' 24f08c3bdfSopenharmony_ci fi 25f08c3bdfSopenharmony_ci fi 26f08c3bdfSopenharmony_ci 27f08c3bdfSopenharmony_ci tst_res TINFO "'$cmd' add/del ${new_rt}${opt_rt} $NS_TIMES times" 28f08c3bdfSopenharmony_ci 29f08c3bdfSopenharmony_ci if ! restore_ipaddr; then 30f08c3bdfSopenharmony_ci tst_res TBROK "Failed to set default IP addresses" 31f08c3bdfSopenharmony_ci return 32f08c3bdfSopenharmony_ci fi 33f08c3bdfSopenharmony_ci 34f08c3bdfSopenharmony_ci local cnt=1 35f08c3bdfSopenharmony_ci while [ $cnt -le $NS_TIMES ]; do 36f08c3bdfSopenharmony_ci make_background_tcp_traffic 37f08c3bdfSopenharmony_ci 38f08c3bdfSopenharmony_ci case $cmd in 39f08c3bdfSopenharmony_ci route) route -A $inet add ${new_rt}${opt_rt} dev $iface ;; 40f08c3bdfSopenharmony_ci ip) ip route add ${new_rt}${opt_rt} dev $iface ;; 41f08c3bdfSopenharmony_ci esac 42f08c3bdfSopenharmony_ci if [ $? -ne 0 ]; then 43f08c3bdfSopenharmony_ci tst_res TFAIL "Can't add route $new_rt to $iface" 44f08c3bdfSopenharmony_ci return 45f08c3bdfSopenharmony_ci fi 46f08c3bdfSopenharmony_ci 47f08c3bdfSopenharmony_ci case $cmd in 48f08c3bdfSopenharmony_ci route) route -A $inet del ${new_rt}${opt_rt} dev $iface ;; 49f08c3bdfSopenharmony_ci ip) ip route del ${new_rt}${opt_rt} dev $iface ;; 50f08c3bdfSopenharmony_ci esac 51f08c3bdfSopenharmony_ci if [ $? -ne 0 ]; then 52f08c3bdfSopenharmony_ci tst_res TFAIL "Can't del route $new_rt from $iface" 53f08c3bdfSopenharmony_ci return 54f08c3bdfSopenharmony_ci fi 55f08c3bdfSopenharmony_ci 56f08c3bdfSopenharmony_ci check_connectivity_interval $cnt || return 57f08c3bdfSopenharmony_ci 58f08c3bdfSopenharmony_ci cnt=$(($cnt + 1)) 59f08c3bdfSopenharmony_ci done 60f08c3bdfSopenharmony_ci 61f08c3bdfSopenharmony_ci tst_res TPASS "Test is finished correctly" 62f08c3bdfSopenharmony_ci} 63f08c3bdfSopenharmony_ci 64f08c3bdfSopenharmony_ci. if-lib.sh 65f08c3bdfSopenharmony_ci 66f08c3bdfSopenharmony_ciCHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 20))} 67f08c3bdfSopenharmony_ci 68f08c3bdfSopenharmony_citst_run 69