1f08c3bdfSopenharmony_ci#!/bin/sh 2f08c3bdfSopenharmony_ci# SPDX-License-Identifier: GPL-2.0-or-later 3f08c3bdfSopenharmony_ci# Copyright (c) 2019-2022 Petr Vorel <pvorel@suse.cz> 4f08c3bdfSopenharmony_ci# Copyright (c) International Business Machines Corp., 2006 5f08c3bdfSopenharmony_ci# Author: Mitsuru Chinen <mitch@jp.ibm.com> 6f08c3bdfSopenharmony_ci# Rewrite into new shell API: Petr Vorel 7f08c3bdfSopenharmony_ci# 8f08c3bdfSopenharmony_ci# Change route interface 9f08c3bdfSopenharmony_ci# lhost: 10.23.x.2, gw (on rhost): 10.23.x.1, rhost: 10.23.0.1, switching ifaces on lhost 10f08c3bdfSopenharmony_ci 11f08c3bdfSopenharmony_ciTST_SETUP="setup" 12f08c3bdfSopenharmony_ciTST_CLEANUP="cleanup_if" 13f08c3bdfSopenharmony_ciTST_TESTFUNC="test_if" 14f08c3bdfSopenharmony_ci 15f08c3bdfSopenharmony_cisetup() 16f08c3bdfSopenharmony_ci{ 17f08c3bdfSopenharmony_ci tst_res TINFO "change IPv$TST_IPVER route interface $ROUTE_CHANGE_IP times" 18f08c3bdfSopenharmony_ci setup_if 19f08c3bdfSopenharmony_ci} 20f08c3bdfSopenharmony_ci 21f08c3bdfSopenharmony_citest_if() 22f08c3bdfSopenharmony_ci{ 23f08c3bdfSopenharmony_ci local gw="$(tst_ipaddr_un -n1 $1 1)" 24f08c3bdfSopenharmony_ci local lhost="$(tst_ipaddr_un -n1 $1 2)" 25f08c3bdfSopenharmony_ci local link_num="$(($1 % $(tst_get_ifaces_cnt)))" 26f08c3bdfSopenharmony_ci local iface="$(tst_iface lhost $link_num)" 27f08c3bdfSopenharmony_ci 28f08c3bdfSopenharmony_ci tst_res TINFO "testing route over interface '$iface' with gateway '$gw'" 29f08c3bdfSopenharmony_ci 30f08c3bdfSopenharmony_ci tst_add_ipaddr -s -q -a $lhost lhost $link_num 31f08c3bdfSopenharmony_ci tst_add_ipaddr -s -q -a $gw rhost $link_num 32f08c3bdfSopenharmony_ci ROD ip route add $rt dev $iface via $gw 33f08c3bdfSopenharmony_ci EXPECT_PASS_BRK ping$TST_IPV6 -c1 -I $lhost $rhost \>/dev/null 34f08c3bdfSopenharmony_ci ROD ip route del $rt dev $iface via $gw 35f08c3bdfSopenharmony_ci tst_del_ipaddr -s -q -a $lhost lhost $link_num 36f08c3bdfSopenharmony_ci tst_del_ipaddr -s -q -a $gw rhost $link_num 37f08c3bdfSopenharmony_ci} 38f08c3bdfSopenharmony_ci 39f08c3bdfSopenharmony_ci. route-lib.sh 40f08c3bdfSopenharmony_ciTST_CNT=$ROUTE_CHANGE_IP 41f08c3bdfSopenharmony_citst_run 42