From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 8/8] net/virt: Introduce macsec_lib.sh to reduce duplicity
Date: Fri, 22 Jun 2018 17:10:47 +0200 [thread overview]
Message-ID: <20180622151047.13002-9-pvorel@suse.cz> (raw)
In-Reply-To: <20180622151047.13002-1-pvorel@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/network/virt/macsec01.sh | 27 +------------
testcases/network/virt/macsec02.sh | 28 +------------
testcases/network/virt/macsec_lib.sh | 60 ++++++++++++++++++++++++++++
testcases/network/virt/virt_lib.sh | 27 -------------
4 files changed, 63 insertions(+), 79 deletions(-)
create mode 100755 testcases/network/virt/macsec_lib.sh
diff --git a/testcases/network/virt/macsec01.sh b/testcases/network/virt/macsec01.sh
index 725d469e7..d9d6e73a6 100755
--- a/testcases/network/virt/macsec01.sh
+++ b/testcases/network/virt/macsec01.sh
@@ -8,33 +8,8 @@
# with default MACsec configuration, compare performance with similar
# IPsec configuration on master interface.
-virt_type="macsec"
-VIRT_PERF_THRESHOLD=${VIRT_PERF_THRESHOLD:-100}
-IPSEC_MODE="transport"
IPSEC_PROTO="ah"
-TST_NEEDS_TMPDIR=1
-TST_TESTFUNC=virt_netperf_msg_sizes
-TST_SETUP=do_setup
-TST_CLEANUP=do_cleanup
-. ipsec_lib.sh
-. virt_lib.sh
-
-do_setup()
-{
- ipsec_lib_setup
-
- tst_res TINFO "setup IPsec $IPSEC_MODE/$IPSEC_PROTO $EALGO"
- tst_ipsec lhost $(tst_ipaddr) $(tst_ipaddr rhost)
- tst_ipsec rhost $(tst_ipaddr rhost) $(tst_ipaddr)
-
- virt_macsec_setup
-}
-
-do_cleanup()
-{
- virt_cleanup
- tst_ipsec_cleanup
-}
+. macsec_lib.sh
tst_run
diff --git a/testcases/network/virt/macsec02.sh b/testcases/network/virt/macsec02.sh
index 575b5c4e0..0c40b25a1 100755
--- a/testcases/network/virt/macsec02.sh
+++ b/testcases/network/virt/macsec02.sh
@@ -8,34 +8,10 @@
# with enabled frame encryption and replay protection, compare
# performance with similar IPsec configuration on master interface.
-virt_type="macsec"
-VIRT_PERF_THRESHOLD=${VIRT_PERF_THRESHOLD:-100}
-IPSEC_MODE="transport"
IPSEC_PROTO="esp_aead"
EALGO="aes"
+MACSEC_LIB_SETUP="replay on window 300 encrypt on protect on"
-TST_NEEDS_TMPDIR=1
-TST_TESTFUNC=virt_netperf_msg_sizes
-TST_SETUP=do_setup
-TST_CLEANUP=do_cleanup
-. ipsec_lib.sh
-. virt_lib.sh
-
-do_setup()
-{
- ipsec_lib_setup
-
- tst_res TINFO "setup IPsec $IPSEC_MODE/$IPSEC_PROTO $EALGO"
- tst_ipsec lhost $(tst_ipaddr) $(tst_ipaddr rhost)
- tst_ipsec rhost $(tst_ipaddr rhost) $(tst_ipaddr)
-
- virt_macsec_setup "replay on window 300 encrypt on protect on"
-}
-
-do_cleanup()
-{
- virt_cleanup
- tst_ipsec_cleanup
-}
+. macsec_lib.sh
tst_run
diff --git a/testcases/network/virt/macsec_lib.sh b/testcases/network/virt/macsec_lib.sh
new file mode 100755
index 000000000..c7bdca342
--- /dev/null
+++ b/testcases/network/virt/macsec_lib.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2018 Petr Vorel <pvorel@suse.cz>
+# Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
+# Author: Alexey Kodanev <alexey.kodanev@oracle.com>
+
+virt_type="macsec"
+VIRT_PERF_THRESHOLD=${VIRT_PERF_THRESHOLD:-100}
+IPSEC_MODE="transport"
+
+TST_NEEDS_TMPDIR=1
+TST_TESTFUNC=virt_netperf_msg_sizes
+TST_SETUP=macsec_lib_setup
+TST_CLEANUP=macsec_lib_cleanup
+. ipsec_lib.sh
+. virt_lib.sh
+
+macsec_lib_setup()
+{
+ ipsec_lib_setup
+
+ tst_res TINFO "setup IPsec $IPSEC_MODE/$IPSEC_PROTO $EALGO"
+ tst_ipsec lhost $(tst_ipaddr) $(tst_ipaddr rhost)
+ tst_ipsec rhost $(tst_ipaddr rhost) $(tst_ipaddr)
+
+ virt_macsec_setup
+}
+
+macsec_lib_cleanup()
+{
+ virt_cleanup
+ tst_ipsec_cleanup
+}
+
+# virt_macsec_setup [OPTIONS]
+# OPTIONS - [ cipher { default | gcm-aes-128 } ] [ encrypt { on | off } ]
+# [ protect { on | off } ] [ replay { on | off } ] [ window WINDOW ]
+# [ validate { strict | check | disabled } ]
+virt_macsec_setup()
+{
+ local keyid0=01
+ local keyid1=02
+ local sa=0
+ local h0=$(tst_hwaddr)
+ local h1=$(tst_hwaddr rhost)
+ local cmd="ip macsec add ltp_v0"
+ local key0="01234567890123456789012345678901"
+ local key1="98765432109876543210987612343434"
+
+ virt_setup "icvlen 16 encodingsa $sa $MACSEC_LIB_SETUP"
+
+ ROD $cmd tx sa $sa pn 100 on key $keyid0 $key0
+ ROD $cmd rx address $h1 port 1
+ ROD $cmd rx address $h1 port 1 sa $sa pn 100 on key $keyid1 $key1
+
+ tst_rhost_run -s -c "$cmd tx sa $sa pn 100 on key $keyid1 $key1"
+ tst_rhost_run -s -c "$cmd rx address $h0 port 1"
+ tst_rhost_run -s -c \
+ "$cmd rx address $h0 port 1 sa $sa pn 100 on key $keyid0 $key0"
+}
diff --git a/testcases/network/virt/virt_lib.sh b/testcases/network/virt/virt_lib.sh
index 9960b9553..c939417c1 100644
--- a/testcases/network/virt/virt_lib.sh
+++ b/testcases/network/virt/virt_lib.sh
@@ -320,33 +320,6 @@ virt_check_cmd()
return 0
}
-# virt_macsec_setup [OPTIONS]
-# OPTIONS - [ cipher { default | gcm-aes-128 } ] [ encrypt { on | off } ]
-# [ protect { on | off } ] [ replay { on | off } ] [ window WINDOW ]
-# [ validate { strict | check | disabled } ]
-virt_macsec_setup()
-{
- local keyid0=01
- local keyid1=02
- local sa=0
- local h0=$(tst_hwaddr)
- local h1=$(tst_hwaddr rhost)
- local cmd="ip macsec add ltp_v0"
- local key0="01234567890123456789012345678901"
- local key1="98765432109876543210987612343434"
-
- virt_setup "icvlen 16 encodingsa $sa $@"
-
- ROD $cmd tx sa $sa pn 100 on key $keyid0 $key0
- ROD $cmd rx address $h1 port 1
- ROD $cmd rx address $h1 port 1 sa $sa pn 100 on key $keyid1 $key1
-
- tst_rhost_run -s -c "$cmd tx sa $sa pn 100 on key $keyid1 $key1"
- tst_rhost_run -s -c "$cmd rx address $h0 port 1"
- tst_rhost_run -s -c \
- "$cmd rx address $h0 port 1 sa $sa pn 100 on key $keyid0 $key0"
-}
-
virt_netperf_msg_sizes()
{
local sizes="100 1000 2000 10000"
--
2.17.1
next prev parent reply other threads:[~2018-06-22 15:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-22 15:10 [LTP] [PATCH v2 0/8] Migrate tests using virt_lib.sh and ipsec_lib.sh to new API Petr Vorel
2018-06-22 15:10 ` [LTP] [PATCH v2 1/8] net/ipsec: Improve log info messages Petr Vorel
2018-06-22 15:10 ` [LTP] [PATCH v2 2/8] tst_test.sh: Introduce TST_LIB_LOADED Petr Vorel
2018-06-26 12:38 ` Cyril Hrubis
2018-06-22 15:10 ` [LTP] [PATCH v2 3/8] tst_net.sh: Harden against multiple loading Petr Vorel
2018-06-27 10:47 ` Alexey Kodanev
2018-06-22 15:10 ` [LTP] [PATCH v2 4/8] net/ipsec: Use ':' as array separator for -s parameter Petr Vorel
2018-06-22 15:10 ` [LTP] [PATCH v2 5/8] net/{stress, virt}: Use SPDX-License-Identifier GPL-2.0-or-later Petr Vorel
2018-06-22 15:10 ` [LTP] [PATCH v2 6/8] net/virt_lib.sh: Remove possibility to pass custom sizes Petr Vorel
2018-06-27 11:35 ` Alexey Kodanev
2018-06-22 15:10 ` [LTP] [PATCH v2 7/8] net/{stress, virt}: Migrate virt_lib.sh, ipsec_lib.sh + tests using them Petr Vorel
2018-06-22 15:10 ` Petr Vorel [this message]
2018-06-27 11:54 ` [LTP] [PATCH v2 8/8] net/virt: Introduce macsec_lib.sh to reduce duplicity Alexey Kodanev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180622151047.13002-9-pvorel@suse.cz \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox