1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0-or-later 3# Copyright (c) 2020 Petr Vorel <pvorel@suse.cz> 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. route-lib.sh 13 14setup() 15{ 16 tst_res TINFO "change IPv$TST_IPVER route destination $ROUTE_CHANGE_NETLINK times" 17 18 local cnt=0 19 local gw rhost rhost_all rt 20 21 check_max_ip 22 23 while [ $cnt -lt $ROUTE_MAX_IP ]; do 24 rt="$(tst_ipaddr_un -p $cnt)" 25 rhost="$(tst_ipaddr_un $cnt 1)" 26 rhost_all="$rhost$IP_ADDR_DELIM$rhost_all" 27 28 tst_add_ipaddr -s -q -a $rhost rhost 29 ROD ip route add $rt dev $(tst_iface) 30 cnt=$((cnt+1)) 31 done 32 33 ROUTE_CHANGE_NETLINK_PARAMS="-d $(tst_iface) -r '$rhost_all'" 34} 35 36tst_run 37