From patchwork Mon May 21 11:48:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kodanev X-Patchwork-Id: 917557 X-Patchwork-Delegate: akodanev@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="ggrKnpVT"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40qGyS1NqSz9s2k for ; Mon, 21 May 2018 21:39:11 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 2988A3E6448 for ; Mon, 21 May 2018 13:39:09 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) by picard.linux.it (Postfix) with ESMTP id E92D23E63D0 for ; Mon, 21 May 2018 13:39:02 +0200 (CEST) Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 029611401328 for ; Mon, 21 May 2018 13:39:01 +0200 (CEST) Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w4LBV6VA122206 for ; Mon, 21 May 2018 11:39:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=YAD9gX72v+H+YnOemMOrI3IAmzGyRCxvxbLYDXXImQ4=; b=ggrKnpVT+ZDkeUW8x0bM2ImZ4M5PmlTTeQFMEpK3Q5M3Ib5GAGpdPjgPje8+c1iIGzxG F4/h71YCUePRnP0UZAlEuvAddaWd64bu0LJvSShYFDTEGj5Zetrd0FpqDrvo/EqIVeVi cRzY+gL7l8Cw/76xUI7NmbFMUqMwK+xCacc7VeVfifLg5O/fCQTKgWbNZ93YJqKXa/Ur upM/GWIS71As9w8bm7q/PtwVEF5ScZQOM6L/J3pWUni1JQFdDiLHqzJYJNcfeCazf1jT kVp4akuwy5fAXV2F8RR5BsE9Y+H5+Pphp+wV1sYNTneoqnZZXMOlz4k59K71IRB/zlAR Yg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2j2bcdbub1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 21 May 2018 11:39:00 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w4LBcxUN027239 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 21 May 2018 11:38:59 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w4LBcxmv013633 for ; Mon, 21 May 2018 11:38:59 GMT Received: from ak.ru.oracle.com (/10.162.80.29) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 21 May 2018 04:38:59 -0700 From: Alexey Kodanev To: ltp@lists.linux.it Date: Mon, 21 May 2018 14:48:26 +0300 Message-Id: <1526903310-2833-3-git-send-email-alexey.kodanev@oracle.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1526903310-2833-1-git-send-email-alexey.kodanev@oracle.com> References: <1526903310-2833-1-git-send-email-alexey.kodanev@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8899 signatures=668700 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=812 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805210139 X-Virus-Scanned: clamav-milter 0.99.2 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH 2/6] dctcp01: convert to new API and move common code to a library X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Alexey Kodanev Acked-by: Petr Vorel --- testcases/network/tcp_cc/Makefile | 2 +- testcases/network/tcp_cc/dctcp01.sh | 80 +++++-------------------------- testcases/network/tcp_cc/tcp_cc_lib.sh | 57 ++++++++++++++++++++++ 3 files changed, 71 insertions(+), 68 deletions(-) create mode 100755 testcases/network/tcp_cc/tcp_cc_lib.sh diff --git a/testcases/network/tcp_cc/Makefile b/testcases/network/tcp_cc/Makefile index 82a6262..a564eb4 100644 --- a/testcases/network/tcp_cc/Makefile +++ b/testcases/network/tcp_cc/Makefile @@ -17,6 +17,6 @@ top_srcdir ?= ../../.. include $(top_srcdir)/include/mk/env_pre.mk -INSTALL_TARGETS := dctcp01.sh +INSTALL_TARGETS := *.sh include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/network/tcp_cc/dctcp01.sh b/testcases/network/tcp_cc/dctcp01.sh index 92ac97d..02b27cf 100755 --- a/testcases/network/tcp_cc/dctcp01.sh +++ b/testcases/network/tcp_cc/dctcp01.sh @@ -1,91 +1,37 @@ #!/bin/sh -# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it would be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2015-2018 Oracle and/or its affiliates. All Rights Reserved. # # Author: Alexey Kodanev -TCID=dctcp01 -TST_TOTAL=1 +TST_SETUP="setup" +TST_TESTFUNC="do_test" TST_CLEANUP="cleanup" -TST_NEEDS_TMPDIR=1 -def_alg="cubic" -prev_alg= +TST_MIN_KVER="3.18" -TST_USE_LEGACY_API=1 -. tst_net.sh - -set_cong_alg() -{ - local alg=$1 - tst_resm TINFO "setting $alg" - - tst_set_sysctl net.ipv4.tcp_congestion_control $alg safe -} +. tcp_cc_lib.sh cleanup() { - if [ "$prev_cong_ctl" ]; then - tst_set_sysctl net.ipv4.tcp_congestion_control $prev_alg - fi - tst_rmdir tc qdisc del dev $(tst_iface) root netem loss 0.03% ecn + + tcp_cc_cleanup } setup() { - if tst_kvcmp -lt "3.18"; then - tst_brkm TCONF "test requires kernel 3.18 or newer" - fi - - tst_require_root - tst_check_cmds sysctl tc + tcp_cc_setup - tst_resm TINFO "emulate congestion with packet loss 0.03% and ECN" + tst_res TINFO "emulate congestion with packet loss 0.03% and ECN" tc qdisc add dev $(tst_iface) root netem loss 0.03% ecn > /dev/null 2>&1 if [ $? -ne 0 ]; then tst_brkm TCONF "netem doesn't support ECN" fi - - prev_alg="$(sysctl -n net.ipv4.tcp_congestion_control)" } -test_run() +do_test() { - tst_resm TINFO "compare '$def_alg' and 'dctcp' congestion alg. results" - - set_cong_alg "$def_alg" - - tst_netload -H $(tst_ipaddr rhost) - local res0="$(cat tst_netload.res)" - - set_cong_alg "dctcp" - - tst_netload -H $(tst_ipaddr rhost) - local res1="$(cat tst_netload.res)" - - local per=$(( $res0 * 100 / $res1 - 100 )) - - if [ "$per" -lt "10" ]; then - tst_resm TFAIL "dctcp performance $per %" - else - tst_resm TPASS "dctcp performance $per %" - fi + tcp_cc_test01 dctcp 10 } -setup - -test_run - -tst_exit +tst_run diff --git a/testcases/network/tcp_cc/tcp_cc_lib.sh b/testcases/network/tcp_cc/tcp_cc_lib.sh new file mode 100755 index 0000000..b96c8af --- /dev/null +++ b/testcases/network/tcp_cc/tcp_cc_lib.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2018 Oracle and/or its affiliates. All Rights Reserved. + +TST_NEEDS_TMPDIR=1 +TST_NEEDS_ROOT=1 +TST_NEEDS_CMDS="sysctl tc" + +. tst_net.sh + +def_alg="cubic" +prev_alg= + +set_cong_alg() +{ + local alg=$1 + tst_res TINFO "setting $alg" + + tst_set_sysctl net.ipv4.tcp_congestion_control $alg safe +} + +tcp_cc_cleanup() +{ + [ "$prev_cong_ctl" ] && \ + tst_set_sysctl net.ipv4.tcp_congestion_control $prev_alg +} + +tcp_cc_setup() +{ + prev_alg="$(sysctl -n net.ipv4.tcp_congestion_control)" +} + +tcp_cc_test01() +{ + local alg=$1 + local threshold=${2:-10} + + tst_res TINFO "compare '$def_alg' and '$alg' congestion alg. results" + + set_cong_alg "$def_alg" + + tst_netload -H $(tst_ipaddr rhost) -A 15000 + local res0="$(cat tst_netload.res)" + + set_cong_alg "$alg" + + tst_netload -H $(tst_ipaddr rhost) -A 15000 + local res1="$(cat tst_netload.res)" + + local per=$(( $res0 * 100 / $res1 - 100 )) + + if [ "$per" -lt "$threshold" ]; then + tst_res TFAIL "$alg performance $per %" + else + tst_res TPASS "$alg performance $per %" + fi +}