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 interface 6f08c3bdfSopenharmony_ci# gw (on rhost): 10.23.x.1, rhost: 10.23.0.1, switching ifaces on lhost 7f08c3bdfSopenharmony_ci# lhost (iface set, but not specified in Netlink API): 10.23.x.2 8f08c3bdfSopenharmony_ci 9f08c3bdfSopenharmony_ciTST_SETUP="setup" 10f08c3bdfSopenharmony_ciTST_CLEANUP="cleanup_if" 11f08c3bdfSopenharmony_ciTST_TESTFUNC="test_netlink" 12f08c3bdfSopenharmony_ci 13f08c3bdfSopenharmony_cisetup() 14f08c3bdfSopenharmony_ci{ 15f08c3bdfSopenharmony_ci local gw gw_all iface iface_all 16f08c3bdfSopenharmony_ci local cnt=0 17f08c3bdfSopenharmony_ci 18f08c3bdfSopenharmony_ci tst_res TINFO "change IPv$TST_IPVER route interface $ROUTE_CHANGE_NETLINK times" 19f08c3bdfSopenharmony_ci setup_if 20f08c3bdfSopenharmony_ci 21f08c3bdfSopenharmony_ci while [ $cnt -lt $(tst_get_ifaces_cnt) ]; do 22f08c3bdfSopenharmony_ci gw="$(tst_ipaddr_un -n1 $cnt 1)" 23f08c3bdfSopenharmony_ci iface="$(tst_iface lhost $cnt)" 24f08c3bdfSopenharmony_ci lhost="$(tst_ipaddr_un -n1 $cnt 2)" 25f08c3bdfSopenharmony_ci 26f08c3bdfSopenharmony_ci tst_add_ipaddr -s -q -a $lhost lhost $cnt 27f08c3bdfSopenharmony_ci tst_add_ipaddr -s -q -a $gw rhost $cnt 28f08c3bdfSopenharmony_ci 29f08c3bdfSopenharmony_ci gw_all="$gw$IP_ADDR_DELIM$gw_all" 30f08c3bdfSopenharmony_ci iface_all="$iface$IP_ADDR_DELIM$iface_all" 31f08c3bdfSopenharmony_ci 32f08c3bdfSopenharmony_ci cnt=$((cnt+1)) 33f08c3bdfSopenharmony_ci done 34f08c3bdfSopenharmony_ci 35f08c3bdfSopenharmony_ci ROUTE_CHANGE_NETLINK_PARAMS="-d '$iface_all' -g '$gw_all' -r $rhost" 36f08c3bdfSopenharmony_ci} 37f08c3bdfSopenharmony_ci 38f08c3bdfSopenharmony_ci. route-lib.sh 39f08c3bdfSopenharmony_citst_run 40