1f08c3bdfSopenharmony_ci#!/bin/sh 2f08c3bdfSopenharmony_ci# SPDX-License-Identifier: GPL-2.0-or-later 3f08c3bdfSopenharmony_ci# Copyright (c) 2017-2019 Petr Vorel <pvorel@suse.cz> 4f08c3bdfSopenharmony_ci# Copyright (c) 2015-2016 Oracle and/or its affiliates. All Rights Reserved. 5f08c3bdfSopenharmony_ci# Copyright (c) International Business Machines Corp., 2005 6f08c3bdfSopenharmony_ci# Author: Mitsuru Chinen <mitch@jp.ibm.com> 7f08c3bdfSopenharmony_ci 8f08c3bdfSopenharmony_ciTST_CLEANUP="do_cleanup" 9f08c3bdfSopenharmony_ciTST_TESTFUNC="test_body" 10f08c3bdfSopenharmony_ciTST_NEEDS_CMDS="ifconfig" 11f08c3bdfSopenharmony_ci 12f08c3bdfSopenharmony_ci# Maximum host portion of the IPv4 address on the local host 13f08c3bdfSopenharmony_ciLHOST_IPV4_HOST_MAX="254" 14f08c3bdfSopenharmony_ci 15f08c3bdfSopenharmony_cido_cleanup() 16f08c3bdfSopenharmony_ci{ 17f08c3bdfSopenharmony_ci tst_restore_ipaddr 18f08c3bdfSopenharmony_ci tst_wait_ipv6_dad 19f08c3bdfSopenharmony_ci} 20f08c3bdfSopenharmony_ci 21f08c3bdfSopenharmony_citest_body() 22f08c3bdfSopenharmony_ci{ 23f08c3bdfSopenharmony_ci local cnt=0 24f08c3bdfSopenharmony_ci local num=1 25f08c3bdfSopenharmony_ci local add_to_net 26f08c3bdfSopenharmony_ci 27f08c3bdfSopenharmony_ci tst_res TINFO "ifconfig changes IPv4 address $NS_TIMES times" 28f08c3bdfSopenharmony_ci 29f08c3bdfSopenharmony_ci while [ $cnt -lt $NS_TIMES ]; do 30f08c3bdfSopenharmony_ci # Define the network portion 31f08c3bdfSopenharmony_ci num=$(($num + 1)) 32f08c3bdfSopenharmony_ci [ $num -gt $LHOST_IPV4_HOST_MAX ] && num=1 33f08c3bdfSopenharmony_ci 34f08c3bdfSopenharmony_ci [ $num -eq $RHOST_IPV4_HOST ] && continue 35f08c3bdfSopenharmony_ci 36f08c3bdfSopenharmony_ci # check prefix and fix values for prefix != 24 37f08c3bdfSopenharmony_ci add_to_net= 38f08c3bdfSopenharmony_ci if [ $IPV4_LPREFIX -lt 8 -o $IPV4_LPREFIX -ge 32 ] ; then 39f08c3bdfSopenharmony_ci tst_brk TCONF "test must be with prefix >= 8 and prefix < 32 ($IPV4_LPREFIX)" 40f08c3bdfSopenharmony_ci elif [ $IPV4_LPREFIX -lt 16 ]; then # N.x.x.num 41f08c3bdfSopenharmony_ci add_to_net=".0.1" 42f08c3bdfSopenharmony_ci elif [ $IPV4_LPREFIX -lt 24 ]; then # N.N.x.num 43f08c3bdfSopenharmony_ci add_to_net=".1" 44f08c3bdfSopenharmony_ci fi 45f08c3bdfSopenharmony_ci 46f08c3bdfSopenharmony_ci # Change IPv4 address 47f08c3bdfSopenharmony_ci ROD ifconfig $(tst_iface) ${IPV4_LNETWORK}${add_to_net}.${num} netmask \ 48f08c3bdfSopenharmony_ci $IPV4_LNETMASK broadcast $IPV4_LBROADCAST 49f08c3bdfSopenharmony_ci 50f08c3bdfSopenharmony_ci cnt=$(($cnt + 1)) 51f08c3bdfSopenharmony_ci 52f08c3bdfSopenharmony_ci [ $CHECK_INTERVAL -eq 0 ] && continue 53f08c3bdfSopenharmony_ci [ $(($cnt % $CHECK_INTERVAL)) -ne 0 ] && continue 54f08c3bdfSopenharmony_ci 55f08c3bdfSopenharmony_ci tst_res TINFO "ping $(tst_ipaddr):$(tst_ipaddr rhost) ${cnt}/$NS_TIMES" 56f08c3bdfSopenharmony_ci tst_ping 57f08c3bdfSopenharmony_ci done 58f08c3bdfSopenharmony_ci 59f08c3bdfSopenharmony_ci tst_ping 60f08c3bdfSopenharmony_ci} 61f08c3bdfSopenharmony_ci 62f08c3bdfSopenharmony_ci. tst_net.sh 63f08c3bdfSopenharmony_ci 64f08c3bdfSopenharmony_ciCHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 20))} 65f08c3bdfSopenharmony_ci 66f08c3bdfSopenharmony_citst_run 67