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 tcp_fastopen 39 tst_rhost_run -c "pkill -13 -x tcp_fastopen" 40 tst_restore_ipaddr 41} 42 43make_background_tcp_traffic() 44{ 45 port=$(tst_get_unused_port ipv${ipver} stream) 46 tcp_fastopen -R 3 -g $port > /dev/null 2>&1 & 47 tst_rhost_run -b -c "tcp_fastopen -l -H $(tst_ipaddr) -g $port" 48} 49 50check_connectivity() 51{ 52 local cnt=$1 53 [ $CHECK_INTERVAL -eq 0 ] && return 54 [ $(($cnt % $CHECK_INTERVAL)) -ne 0 ] && return 55 56 tst_resm TINFO "check connectivity through $(tst_iface) on step $cnt" 57 check_icmpv${ipver}_connectivity $(tst_iface) $(tst_ipaddr rhost) 58 if [ $? -ne 0 ]; then 59 tst_resm TFAIL "$(tst_iface) is broken" 60 return 1 61 fi 62 return 0 63} 64