• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
3#
4# This program is free software; you can redistribute it and/or
5# modify it under the terms of the GNU General Public License as
6# published by the Free Software Foundation; either version 2 of
7# the License, or (at your option) any later version.
8#
9# This program is distributed in the hope that it would be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16#
17# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
18
19TST_CLEANUP="cleanup"
20
21. test_net.sh
22
23ipver=${TST_IPV6:-4}
24
25IPV4_NET16_UNUSED=${IPV4_NET16_UNUSED:-"10.23"}
26IPV6_NET32_UNUSED=${IPV6_NET32_UNUSED:-"fd00:23"}
27
28setup()
29{
30	tst_require_root
31	tst_check_cmds ip pgrep pkill
32	trap "tst_brkm TBROK 'test interrupted'" INT
33}
34
35cleanup()
36{
37	# Stop the background TCP traffic
38	pkill -13 -x netstress
39	tst_rhost_run -c "pkill -13 -x netstress"
40}
41
42make_background_tcp_traffic()
43{
44	port=$(tst_get_unused_port ipv${ipver} stream)
45	netstress -R 3 -g $port > /dev/null 2>&1 &
46	tst_rhost_run -b -c "netstress -l -H $(tst_ipaddr) -g $port"
47}
48
49check_connectivity()
50{
51	local cnt="$1"
52	local restore="$2"
53
54	[ $CHECK_INTERVAL -eq 0 ] && return
55	[ $(($cnt % $CHECK_INTERVAL)) -ne 0 ] && return
56
57	tst_resm TINFO "check connectivity through $(tst_iface) on step $cnt"
58
59	[ -n "$restore" ] && restore_ipaddr
60
61	tst_ping
62	if [ $? -ne 0 ]; then
63		tst_resm TFAIL "$(tst_iface) is broken"
64		return 1
65	fi
66	return 0
67}
68
69restore_ipaddr()
70{
71	tst_restore_ipaddr || return $?
72	tst_wait_ipv6_dad
73}
74