• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# Copyright (c) 2014-2016 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, write the Free Software Foundation,
16# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17#
18# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
19#
20
21# default command-line options
22user_name="root"
23use_ssh=0
24clients_num=2
25client_requests=2000000
26max_requests=3
27
28TST_TOTAL=1
29TCID="tcp_fastopen"
30
31. test_net.sh
32
33while getopts :hu:sr:p:n:R:6 opt; do
34	case "$opt" in
35	h)
36		echo "Usage:"
37		echo "h        help"
38		echo "u x      server user name"
39		echo "s        use ssh to run remote cmds"
40		echo "n x      num of clients running in parallel"
41		echo "r x      the number of client requests"
42		echo "R x      num of requests, after which conn. closed"
43		echo "6        run over IPv6"
44		exit 0
45	;;
46	u) user_name=$OPTARG ;;
47	s) export TST_USE_SSH=1 ;;
48	n) clients_num=$OPTARG ;;
49	r) client_requests=$OPTARG ;;
50	R) max_requests=$OPTARG ;;
51	6) # skip, test_net library already processed it
52	;;
53	*) tst_brkm TBROK "unknown option: $opt" ;;
54	esac
55done
56
57cleanup()
58{
59	tst_rmdir
60}
61
62tst_require_root
63
64if tst_kvcmp -lt "3.7"; then
65	tst_brkm TCONF "test must be run with kernel 3.7 or newer"
66fi
67
68if tst_kvcmp -lt "3.16" && [ "$TST_IPV6" ]; then
69	tst_brkm TCONF "test must be run with kernel 3.16 or newer"
70fi
71
72trap "tst_brkm TBROK 'test interrupted'" INT
73TST_CLEANUP="cleanup"
74tst_tmpdir
75
76tst_resm TINFO "using old TCP API and set tcp_fastopen to '0'"
77tst_netload -H $(tst_ipaddr rhost) -a $clients_num -r $client_requests \
78	-R $max_requests -t 0
79time_tfo_off=$(cat tst_netload.res)
80
81tst_resm TINFO "using new TCP API and set tcp_fastopen to '3'"
82tst_netload -H $(tst_ipaddr rhost)  -a $clients_num -r $client_requests \
83	-R $max_requests -f -t 3
84time_tfo_on=$(cat tst_netload.res)
85
86tfo_cmp=$(( 100 - ($time_tfo_on * 100) / $time_tfo_off ))
87
88if [ "$tfo_cmp" -lt 3 ]; then
89	tst_resm TFAIL "TFO performance result is '$tfo_cmp' percent"
90else
91	tst_resm TPASS "TFO performance result is '$tfo_cmp' percent"
92fi
93
94tst_exit
95