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_NEEDS_TMPDIR=1 11TST_NEEDS_ROOT=1 12TST_NEEDS_CMDS="tc" 13TST_NEEDS_DRIVERS="sch_netem" 14TST_OPTS="R:" 15TST_USAGE=tcp_fastopen_usage 16TST_PARSE_ARGS=tcp_fastopen_parse_args 17 18srv_replies=3 19 20tcp_fastopen_usage() 21{ 22 echo "-R x Number of requests, after which connection is closed" 23} 24 25tcp_fastopen_parse_args() 26{ 27 case "$1" in 28 R) srv_replies=$2 ;; 29 esac 30} 31 32 33cleanup() 34{ 35 tc qdisc del dev $(tst_iface) root netem delay 100 >/dev/null 36} 37 38setup() 39{ 40 ROD tc qdisc add dev $(tst_iface) root netem delay 100 41} 42 43test1() 44{ 45 tst_res TINFO "using old TCP API and set tcp_fastopen to '0'" 46 tst_netload -H $(tst_ipaddr rhost) -t 0 -R $srv_replies 47 time_tfo_off=$(cat tst_netload.res) 48 49 tst_res TINFO "using new TCP API and set tcp_fastopen to '3'" 50 tst_netload -H $(tst_ipaddr rhost) -f -t 3 -R $srv_replies 51 time_tfo_on=$(cat tst_netload.res) 52 53 tst_netload_compare $time_tfo_off $time_tfo_on 3 54} 55 56test2() 57{ 58 tst_kvcmp -lt "4.11" && \ 59 tst_brk TCONF "next test must be run with kernel 4.11 or newer" 60 61 tst_res TINFO "using connect() and TCP_FASTOPEN_CONNECT socket option" 62 tst_netload -H $(tst_ipaddr rhost) -F -t 3 -R $srv_replies 63 time_tfo_on=$(cat tst_netload.res) 64 65 tst_netload_compare $time_tfo_off $time_tfo_on 3 66} 67 68. tst_net.sh 69tst_run 70