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