• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# Copyright (c) 2015-2016 Oracle and/or its affiliates. All Rights Reserved.
3# Copyright (c) International Business Machines  Corp., 2005
4#
5# This program is free software; you can redistribute it and/or
6# modify it under the terms of the GNU General Public License as
7# published by the Free Software Foundation; either version 2 of
8# the License, or (at your option) any later version.
9#
10# This program is distributed in the hope that it would be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17#
18# Author: Mitsuru Chinen <mitch@jp.ibm.com>
19
20TST_TOTAL=1
21TCID=if4-addr-change
22TST_CLEANUP="do_cleanup"
23
24. test_net.sh
25
26CHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 20))}
27# Maximum host portion of the IPv4 address on the local host
28LHOST_IPV4_HOST_MAX="254"
29
30do_cleanup()
31{
32	tst_restore_ipaddr
33	tst_wait_ipv6_dad
34}
35
36trap "tst_brkm TBROK 'test interrupted'" INT
37
38tst_check_cmds ifconfig
39
40tst_resm TINFO "ifconfig changes IPv4 address $NS_TIMES times"
41
42cnt=0
43num=1
44while [ $cnt -lt $NS_TIMES ]; do
45	# Define the network portion
46	num=$(($num + 1))
47	[ $num -gt $LHOST_IPV4_HOST_MAX ] && num=1
48
49	[ $num -eq $RHOST_IPV4_HOST ] && continue
50
51	# Change IPv4 address
52	lhost_ipv4addr="${IPV4_NETWORK}.${num}"
53
54	ifconfig $(tst_iface) $lhost_ipv4addr netmask 255.255.255.0 \
55		broadcast 255.255.255.255 || \
56		tst_brkm TFAIL "Failed to change into ${lhost_ipv4addr}"
57
58	cnt=$(($cnt + 1))
59
60	[ $CHECK_INTERVAL -eq 0 ] && continue
61	[ $(($cnt % $CHECK_INTERVAL)) -ne 0 ] && continue
62
63	tst_resm TINFO "ping $(tst_ipaddr):$(tst_ipaddr rhost) ${cnt}/$NS_TIMES"
64	EXPECT_PASS tst_ping
65done
66
67EXPECT_PASS tst_ping
68
69tst_exit
70