1f08c3bdfSopenharmony_ci#!/bin/sh
2f08c3bdfSopenharmony_ci# SPDX-License-Identifier: GPL-2.0-or-later
3f08c3bdfSopenharmony_ci# Copyright (c) 2020-2022 Petr Vorel <pvorel@suse.cz>
4f08c3bdfSopenharmony_ci#
5f08c3bdfSopenharmony_ci# Change route destination via netlink
6f08c3bdfSopenharmony_ci# rhost: 10.23.x.1
7f08c3bdfSopenharmony_ci# lhost (iface set, but not specified in Netlink API): 10.0.0.2
8f08c3bdfSopenharmony_ci
9f08c3bdfSopenharmony_ciTST_SETUP="setup"
10f08c3bdfSopenharmony_ciTST_CLEANUP="route_cleanup"
11f08c3bdfSopenharmony_ciTST_TESTFUNC="test_netlink"
12f08c3bdfSopenharmony_ci
13f08c3bdfSopenharmony_cisetup()
14f08c3bdfSopenharmony_ci{
15f08c3bdfSopenharmony_ci	tst_res TINFO "change IPv$TST_IPVER route destination $ROUTE_CHANGE_NETLINK times"
16f08c3bdfSopenharmony_ci
17f08c3bdfSopenharmony_ci	local cnt=0
18f08c3bdfSopenharmony_ci	local gw rhost rhost_all rt
19f08c3bdfSopenharmony_ci
20f08c3bdfSopenharmony_ci	check_max_ip
21f08c3bdfSopenharmony_ci
22f08c3bdfSopenharmony_ci	while [ $cnt -lt $ROUTE_MAX_IP ]; do
23f08c3bdfSopenharmony_ci		rt="$(tst_ipaddr_un -p $cnt)"
24f08c3bdfSopenharmony_ci		rhost="$(tst_ipaddr_un $cnt 1)"
25f08c3bdfSopenharmony_ci		rhost_all="$rhost$IP_ADDR_DELIM$rhost_all"
26f08c3bdfSopenharmony_ci
27f08c3bdfSopenharmony_ci		tst_add_ipaddr -s -q -a $rhost rhost
28f08c3bdfSopenharmony_ci		ROD ip route add $rt dev $(tst_iface)
29f08c3bdfSopenharmony_ci		cnt=$((cnt+1))
30f08c3bdfSopenharmony_ci	done
31f08c3bdfSopenharmony_ci
32f08c3bdfSopenharmony_ci	ROUTE_CHANGE_NETLINK_PARAMS="-d $(tst_iface) -r '$rhost_all'"
33f08c3bdfSopenharmony_ci}
34f08c3bdfSopenharmony_ci
35f08c3bdfSopenharmony_ci. route-lib.sh
36f08c3bdfSopenharmony_citst_run
37