From: Alexey Kodanev <alexey.kodanev@oracle.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 2/3] network/stress: add ipsec lib
Date: Wed, 09 Mar 2016 15:42:06 +0300 [thread overview]
Message-ID: <56E01A1E.4070401@oracle.com> (raw)
In-Reply-To: <1457334883-11086-3-git-send-email-haliu@redhat.com>
On 03/07/2016 10:14 AM, Hangbin Liu wrote:
> Signed-off-by: Hangbin Liu <haliu@redhat.com>
> ---
> testcases/network/stress/ipsec/Makefile | 31 +++++++
> testcases/network/stress/ipsec/ipsec_lib.sh | 134 ++++++++++++++++++++++++++++
> 2 files changed, 165 insertions(+)
> create mode 100644 testcases/network/stress/ipsec/Makefile
> create mode 100644 testcases/network/stress/ipsec/ipsec_lib.sh
>
> diff --git a/testcases/network/stress/ipsec/Makefile b/testcases/network/stress/ipsec/Makefile
> new file mode 100644
> index 0000000..b3a1657
> --- /dev/null
> +++ b/testcases/network/stress/ipsec/Makefile
> @@ -0,0 +1,31 @@
> +#!/bin/sh
> +# Copyright (c) 2016 Red Hat Inc., 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, write the Free Software Foundation,
> +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> +#
> +# Author: Hangbin Liu <haliu@redhat.com>
> +#
> +#######################################################################
> +
> +
> +top_srcdir ?= ../../../..
> +
> +include $(top_srcdir)/include/mk/env_pre.mk
> +
> +INSTALL_TARGETS := *.sh
> +
> +MAKE_TARGETS :=
It can be removed.
> +
> +include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/network/stress/ipsec/ipsec_lib.sh b/testcases/network/stress/ipsec/ipsec_lib.sh
> new file mode 100644
> index 0000000..feeecf9
> --- /dev/null
> +++ b/testcases/network/stress/ipsec/ipsec_lib.sh
> @@ -0,0 +1,134 @@
> +#!/bin/sh
> +# Copyright (c) 2016 Red Hat Inc., 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, write the Free Software Foundation,
> +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> +#
> +# Author: Hangbin Liu <haliu@redhat.com>
> +#
> +#######################################################################
> +
> +#Uncomment line below for debug output.
> +#trace_logic=${trace_logic:-"set -x"}
> +$trace_logic
> +
Not used anymore, can be removed.
> +# Make sure the value of LTPROOT
> +LTPROOT=${LTPROOT:-`(cd ../../../../ ; pwd)`}
> +export LTPROOT
It's not needed, test.sh (which included by test_net.sh) has all checksfor
LTPROOT
> +. test_net.sh
> +
> +# c2x: convert charactor to hex
> +c2x()
> +{
> + for str in $@; do
> + for (( i=0; i<${#str}; i++ )); do
Not portable "for (());", could be changed to "for i in $(seq 0
${#str}); do.
> + c=${str:$i:1}
> + printf '%x' "'$c"
c var is redundant, we can substitute "$c" with "${str:$i:1}"
> + done
> + done
> +}
> +
> +# tst_ipsec flush: flush the ipsec state and policy
> +# tst_ipsec target protocol mode first_spi src_addr dst_addr: config ipsec
> +#
> +# target: target of the configuration file ( src / dst )
> +# protocol: ah / esp / ipcomp
> +# mode: transport / tunnel
> +# first_spi: the first spi value
> +# src_addr: source IP address
> +# dst_addr: destination IP address
> +tst_ipsec()
> +{
> + if [ x$1 = x"flush" ]; then
if [ "$1" = "flush"]; then
> + ip xfrm state flush && ip xfrm policy flush
> + tst_rhost_run -c "ip xfrm state flush && ip xfrm policy flush"
> + return 0
I would run each ip commands with ROD "ip ..." and tst_rhost_run with -s
option.
In that way, if command fails, test will exit with TBROK.
Thanks,
Alexey
next prev parent reply other threads:[~2016-03-09 12:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-07 7:14 [LTP] [PATCH 0/3] networking/stress: add ip xfrm ipsec support Hangbin Liu
2016-03-07 7:14 ` [LTP] [PATCH 1/3] lib/test_net.sh: add tst_ping() to check icmp connectivity Hangbin Liu
2016-03-07 7:14 ` [LTP] [PATCH 2/3] network/stress: add ipsec lib Hangbin Liu
2016-03-09 12:42 ` Alexey Kodanev [this message]
2016-03-10 6:43 ` Hangbin Liu
2016-03-11 5:34 ` Hangbin Liu
2016-03-11 11:20 ` Alexey Kodanev
2016-03-11 14:10 ` Hangbin Liu
2016-03-07 7:14 ` [LTP] [PATCH 3/3] network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing Hangbin Liu
2016-03-09 12:53 ` Alexey Kodanev
2016-03-10 6:50 ` Hangbin Liu
2016-03-10 7:32 ` Alexey Kodanev
2016-03-11 3:08 ` Hangbin Liu
2016-03-11 11:41 ` Alexey Kodanev
2016-03-11 14:33 ` Hangbin Liu
2016-03-14 7:33 ` Alexey Kodanev
2016-03-15 9:41 ` Hangbin Liu
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=56E01A1E.4070401@oracle.com \
--to=alexey.kodanev@oracle.com \
--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