• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2020 Petr Vorel <pvorel@suse.cz>
4#
5# Change route interface
6# gw (on rhost): 10.23.x.1, rhost: 10.23.0.1, switching ifaces on lhost
7# lhost (iface set, but not specified in Netlink API): 10.23.x.2
8
9TST_SETUP="setup"
10TST_CLEANUP="cleanup_if"
11TST_TESTFUNC="test_netlink"
12. route-lib.sh
13
14setup()
15{
16	local gw gw_all iface iface_all
17	local cnt=0
18
19	tst_res TINFO "change IPv$TST_IPVER route interface $ROUTE_CHANGE_NETLINK times"
20	setup_if
21
22	while [ $cnt -lt $(tst_get_ifaces_cnt) ]; do
23		gw="$(tst_ipaddr_un -n1 $cnt 1)"
24		iface="$(tst_iface lhost $cnt)"
25		lhost="$(tst_ipaddr_un -n1 $cnt 2)"
26
27		tst_add_ipaddr -s -q -a $lhost lhost $cnt
28		tst_add_ipaddr -s -q -a $gw rhost $cnt
29
30		gw_all="$gw$IP_ADDR_DELIM$gw_all"
31		iface_all="$iface$IP_ADDR_DELIM$iface_all"
32
33		cnt=$((cnt+1))
34	done
35
36	ROUTE_CHANGE_NETLINK_PARAMS="-d '$iface_all' -g '$gw_all' -r $rhost"
37}
38
39tst_run
40