• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2014-2018 Oracle and/or its affiliates. All Rights Reserved.
4# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
5
6TST_SETUP="setup"
7TST_TESTFUNC="test"
8TST_CNT=2
9TST_CLEANUP="cleanup"
10TST_MIN_KVER="3.7"
11TST_NEEDS_TMPDIR=1
12TST_NEEDS_ROOT=1
13TST_NEEDS_CMDS="tc"
14TST_NEEDS_DRIVERS="sch_netem"
15TST_OPTS="R:"
16TST_USAGE=tcp_fastopen_usage
17TST_PARSE_ARGS=tcp_fastopen_parse_args
18
19srv_replies=3
20
21tcp_fastopen_usage()
22{
23	echo "-R x    Number of requests, after which connection is closed"
24}
25
26tcp_fastopen_parse_args()
27{
28	case "$1" in
29	R) srv_replies=$2 ;;
30	esac
31}
32
33. tst_net.sh
34
35cleanup()
36{
37	tc qdisc del dev $(tst_iface) root netem delay 100 >/dev/null
38}
39
40setup()
41{
42	if tst_kvcmp -lt "3.16" && [ "$TST_IPV6" ]; then
43		tst_brk TCONF "test must be run with kernel 3.16 or newer"
44	fi
45
46	ROD tc qdisc add dev $(tst_iface) root netem delay 100
47}
48
49test1()
50{
51	tst_res TINFO "using old TCP API and set tcp_fastopen to '0'"
52	tst_netload -H $(tst_ipaddr rhost) -t 0 -R $srv_replies
53	time_tfo_off=$(cat tst_netload.res)
54
55	tst_res TINFO "using new TCP API and set tcp_fastopen to '3'"
56	tst_netload -H $(tst_ipaddr rhost) -f -t 3 -R $srv_replies
57	time_tfo_on=$(cat tst_netload.res)
58
59	tst_netload_compare $time_tfo_off $time_tfo_on 3
60}
61
62test2()
63{
64	tst_kvcmp -lt "4.11" && \
65		tst_brk TCONF "next test must be run with kernel 4.11 or newer"
66
67	tst_res TINFO "using connect() and TCP_FASTOPEN_CONNECT socket option"
68	tst_netload -H $(tst_ipaddr rhost) -F -t 3 -R $srv_replies
69	time_tfo_on=$(cat tst_netload.res)
70
71	tst_netload_compare $time_tfo_off $time_tfo_on 3
72}
73
74tst_run
75