xref: /aosp_15_r20/external/ltp/testcases/network/stress/route/route-change-netlink-gw.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 gateway via netlink
6# gw (on rhost): 10.23.1.x, rhost: 10.23.0.1
7# lhost (iface set, but not specified in Netlink API): 10.23.1.1
8
9TST_SETUP="setup"
10TST_CLEANUP="route_cleanup"
11TST_TESTFUNC="test_netlink"
12
13setup()
14{
15	local cnt=0
16
17	tst_res TINFO "change IPv$TST_IPVER route gateway $ROUTE_CHANGE_NETLINK times"
18
19	check_max_ip
20	setup_gw
21
22	while [ $cnt -lt $ROUTE_MAX_IP ]; do
23		gw="$(tst_ipaddr_un -h 2,$max_ip_limit 1 $(($cnt + 1)))"
24		gw_all="$gw$IP_ADDR_DELIM$gw_all"
25		tst_add_ipaddr -s -q -a $gw rhost
26		cnt=$((cnt+1))
27	done
28
29	ROUTE_CHANGE_NETLINK_PARAMS="-d $(tst_iface) -g "$gw_all" -r $rhost"
30}
31
32. route-lib.sh
33tst_run
34