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