xref: /aosp_15_r20/external/ltp/testcases/network/stress/route/route-change-netlink-if.sh (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2020-2022 Petr Vorel <[email protected]>
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
13setup()
14{
15	local gw gw_all iface iface_all
16	local cnt=0
17
18	tst_res TINFO "change IPv$TST_IPVER route interface $ROUTE_CHANGE_NETLINK times"
19	setup_if
20
21	while [ $cnt -lt $(tst_get_ifaces_cnt) ]; do
22		gw="$(tst_ipaddr_un -n1 $cnt 1)"
23		iface="$(tst_iface lhost $cnt)"
24		lhost="$(tst_ipaddr_un -n1 $cnt 2)"
25
26		tst_add_ipaddr -s -q -a $lhost lhost $cnt
27		tst_add_ipaddr -s -q -a $gw rhost $cnt
28
29		gw_all="$gw$IP_ADDR_DELIM$gw_all"
30		iface_all="$iface$IP_ADDR_DELIM$iface_all"
31
32		cnt=$((cnt+1))
33	done
34
35	ROUTE_CHANGE_NETLINK_PARAMS="-d '$iface_all' -g '$gw_all' -r $rhost"
36}
37
38. route-lib.sh
39tst_run
40