• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2019 Petr Vorel <pvorel@suse.cz>
4# Copyright (c) International Business Machines Corp., 2006
5# Author: Mitsuru Chinen <mitch@jp.ibm.com>
6# Rewrite into new shell API: Petr Vorel
7#
8# Change route gateway
9# lhost: 10.23.x.2, gw (on rhost): 10.23.x.1, rhost: 10.23.0.1
10
11TST_TESTFUNC="test_gw"
12. route-lib.sh
13
14setup()
15{
16	tst_res TINFO "change IPv$TST_IPVER route gateway $NS_TIMES times"
17
18	rt="$(tst_ipaddr_un -p 0 0)"
19	lhost="$(tst_ipaddr_un 1 1)"
20	rhost="$(tst_ipaddr_un 0 1)"
21	tst_add_ipaddr -s -q -a $lhost
22	tst_add_ipaddr -s -q -a $rhost rhost
23}
24
25test_gw()
26{
27	local gw="$(tst_ipaddr_un -h 2,254 1 $(($1 + 1)))"
28	local iface="$(tst_iface)"
29
30	tst_res TINFO "testing route over gateway '$gw'"
31
32	tst_add_ipaddr -s -q -a $gw rhost
33	ROD ip route add $rt dev $iface via $gw
34	EXPECT_PASS_BRK ping$TST_IPV6 -c1 -I $lhost $rhost \>/dev/null
35	ROD ip route del $rt dev $iface via $gw
36	tst_del_ipaddr -s -q -a $gw rhost
37}
38
39tst_run
40