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