xref: /aosp_15_r20/external/ltp/testcases/network/stress/route/route-change-gw.sh (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
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 gateway
9# lhost: 10.23.1.1, gw (on rhost): 10.23.1.x, rhost: 10.23.0.1
10
11TST_SETUP="setup"
12TST_CLEANUP="route_cleanup"
13TST_TESTFUNC="test_gw"
14
15setup()
16{
17	tst_res TINFO "change IPv$TST_IPVER route gateway $ROUTE_CHANGE_IP times"
18	setup_gw
19}
20
21test_gw()
22{
23	local gw="$(tst_ipaddr_un -h 2,254 1 $(($1 + 1)))"
24	local iface="$(tst_iface)"
25
26	tst_res TINFO "testing route over gateway '$gw'"
27
28	tst_add_ipaddr -s -q -a $gw rhost
29	ROD ip route add $rt dev $iface via $gw
30	EXPECT_PASS_BRK ping$TST_IPV6 -c1 -I $lhost $rhost \>/dev/null
31	ROD ip route del $rt dev $iface via $gw
32	tst_del_ipaddr -s -q -a $gw rhost
33}
34
35. route-lib.sh
36TST_CNT=$ROUTE_CHANGE_IP
37tst_run
38