Skip to contentSkip to conversation

networking/stress: add ip xfrm ipsec support

PATCH Superseded Hangbin Liu 2 participants 16 messages Mar 17, 2016 – Apr 6, 2016

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v3 cover networking/stress: add ip xfrm ipsec support

As we know, most of the network stress tests have IPsec testing, and we use setkey for configuration. But setkey[1] hasn't updated for a long time. And some distros, RHEL7 for example, even don't have ipset-tools package. On other hand, iproute2 is recommend for network configuration. And ip xfrm is more powerful than setkey. So let's use ip xfrm for ipsec testing.

[1] http://ipsec-tools.sourceforge.net/

Change from V2:
1. remove c2x and use hexdump directly.
2. remove indent after "case".
3. remove useless export and old scripts like check_env.
4. remove tst_init_iface.
5. remove return value check after setup ipsec env.
6. remove addr config as Alexey said, we assume the address already added.

Change from V1:
1. update tst_ping() to use default iface and addr. make ping from local side.
2. remove unused variables. add -s option when use tst_rhost_run. Use ROD before normal commands.
3. change all "tst_resm TBROK && exit" to "tst_brkm TBROK"
3. still keep tst_init_iface in test icmp4-uni-basic01 because we will set_ipv4/6addr each time.

Hangbin Liu (3):
lib/test_net.sh: add tst_ping() to check icmp connectivity network/stress: add ipsec lib
network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing

 testcases/lib/test_net.sh                          |  19 +++
 .../stress/icmp/uni-basic/icmp4-uni-basic01        | 160 ++++-----------------
 testcases/network/stress/ipsec/Makefile            |  29 ++++
 testcases/network/stress/ipsec/ipsec_lib.sh        | 111 ++++++++++++++
 4 files changed, 183 insertions(+), 136 deletions(-)
 create mode 100644 testcases/network/stress/ipsec/Makefile
 create mode 100644 testcases/network/stress/ipsec/ipsec_lib.sh
Signature · 1 line
2.5.0
#1 lore raw

PATCH v3 1/3 lib/test_net.sh: add tst_ping() to check icmp connectivity

---
 testcases/lib/test_net.sh | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
testcases/lib/test_net.sh +19 -0
index 418fed3..da82ed9 100644
@@ -314,3 +314,22 @@ tst_netload()
 
 	return $ret
 }
+
+# tst_ping [IFACE] [ADDR] [SIZE]
+# Check icmp connectivity
+# IFACE: source interface name
+# ADDR: destination IPv4 or IPv6 address
+# SIZE: message size
+tst_ping()
+{
+	# The max number of ICMP echo request
+	PING_MAX=${PING_MAX:-"10"}
+
+	local src_iface=${1:-"$(tst_iface)"}
+	local dst_addr=${2:-"$(tst_ipaddr rhost)"}
+	# ping cmd use 56 as default message size
+	local msg_size=${3:-"56"}
+
+	ping$TST_IPV6 -I $src_iface -c $PING_MAX $dst_addr -s $msg_size > \
+		/dev/null 2>&1
+}
Signature · 1 line
2.5.0
#2 lore raw

PATCH v3 2/3 network/stress: add ipsec lib

In reply to Hangbin Liu
---
 testcases/network/stress/ipsec/Makefile     |  29 ++++++++
 testcases/network/stress/ipsec/ipsec_lib.sh | 111 ++++++++++++++++++++++++++++
 2 files changed, 140 insertions(+)
 create mode 100644 testcases/network/stress/ipsec/Makefile
 create mode 100644 testcases/network/stress/ipsec/ipsec_lib.sh
testcases/network/stress/ipsec/Makefile new file +29 -0
new file mode 100644
index 0000000..0d7f1b6
@@ -0,0 +1,29 @@
+#!/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 <[email protected]>
+#
+#######################################################################
+
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= *.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/network/stress/ipsec/ipsec_lib.sh new file +111 -0

111 lines not on this page · raw message

Signature · 1 line
2.5.0
#3 lore raw

PATCH v3 2/3 network/stress: add ipsec lib

Hi,

Quoted 21 lines · Hangbin Liu
---
  testcases/network/stress/ipsec/Makefile     |  29 ++++++++
  testcases/network/stress/ipsec/ipsec_lib.sh | 111 ++++++++++++++++++++++++++++
  2 files changed, 140 insertions(+)

create mode 100644 testcases/network/stress/ipsec/Makefile create mode 100644 testcases/network/stress/ipsec/ipsec_lib.sh

testcases/network/stress/ipsec/Makefile new file +7 -0
new file mode 100644
index 0000000..0d7f1b6
@@ -0,0 +1,29 @@
+#!/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.

testcases/network/stress/ipsec/Makefile line 17

Quoted 10 lines
testcases/network/stress/ipsec/Makefile new file +10 -0
+#
+# 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
+#

Forgot to change it here?

Quoted 47 lines
testcases/network/stress/ipsec/Makefile new file +12 -0
+# Author: Hangbin Liu <[email protected]>
+#
+#######################################################################
+
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= *.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/network/stress/ipsec/ipsec_lib.sh new file +29 -0
new file mode 100644
index 0000000..33716ce
@@ -0,0 +1,111 @@
+#!/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, see <http://www.gnu.org/licenses/>.
+#
+# Author: Hangbin Liu <[email protected]>
+#
+#######################################################################
+
+. test_net.sh
+
+# tst_ipsec flush: flush the ipsec state and policy
+# tst_ipsec target protocol mode spi src_addr dst_addr: config ipsec
+#
+# target: target of the configuration file ( src / dst )
+# protocol: ah / esp / ipcomp
+# mode: transport / tunnel
+# spi: the first spi value

testcases/network/stress/ipsec/ipsec_lib.sh line 39

Quoted 10 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +10 -0
+# src_addr: source IP address
+# dst_addr: destination IP address
+tst_ipsec()
+{
+	if [ "$1" = "flush" ]; then
+		ROD ip xfrm state flush
+		ROD ip xfrm policy flush
+		tst_rhost_run -s -c "ip xfrm state flush && ip xfrm policy flush"
+		return 0
+	fi

I'd move it to another function, we could name ittst_ipsec_cleanup(). And tst_ipsec() needs some general description like what it actually does.

testcases/network/stress/ipsec/ipsec_lib.sh line 43

Quoted 4 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +4 -0
+	if [ $# -ne 6 ]; then
+		tst_resm TINFO "tst_ipsec parameter mismatch"
+		return 1
+	fi

Why not just tst_brkm() here?

testcases/network/stress/ipsec/ipsec_lib.sh line 50

Quoted 7 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +7 -0
+
+	target=$1
+	protocol=$2
+	mode=$3
+	spi=$4
+	src=$5
+	dst=$6

It's better to make these variables to be defined in function scope (as local) and other variables which used only inside the function.

testcases/network/stress/ipsec/ipsec_lib.sh line 58

Quoted 8 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +8 -0
+
+	# Encryption algorithm
+	EALGO="des3_ede"
+	EALGO_KEY=0x$(printf _I_want_to_have_chicken_ | hexdump -ve '/1 "%x"')
+
+	# Authentication algorithm
+	AALGO="sha1"
+	AALGO_KEY=0x$(printf beef_fish_pork_salad | hexdump -ve '/1 "%x"')

if we use hexdump, we should verify it with tst_check_cmds() (e.g. when we source the library).

Quoted 12 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +12 -0
+
+	# Compression algorithm
+	CALGO="deflate"
+	# Algorithm options for each protocol
+	case $protocol in
+	ah)
+		algo_line="auth $AALGO $AALGO_KEY"
+		proto="ah"
+		;;
+	esp)
+		algo_line="enc $EALGO $EALGO_KEY auth $AALGO $AALGO_KEY"
+		proto="esp"

testcases/network/stress/ipsec/ipsec_lib.sh line 80

Quoted 10 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +10 -0
+		;;
+	ipcomp)
+		algo_line="comp $CALGO"
+		proto="comp"
+		;;
+	*)
+		tst_resm TINFO "tst_ipsec protocol mismatch"
+		return 1
+		;;
+	esac

I would add tst_brkm() here as well.

Quoted 21 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +21 -0
+
+	if [ $target = src ]; then
+		spi_1="0x$spi"
+		spi_2="0x$(( $spi + 1 ))"
+		ROD ip xfrm state add src $src dst $dst spi $spi_1 proto $proto \
+			$algo_line mode $mode sel src $src dst $dst
+		ROD ip xfrm policy add src $src dst $dst dir out tmpl src $src \
+			dst $dst proto $proto mode $mode
+
+		ROD ip xfrm state add src $dst dst $src spi $spi_2 proto $proto \
+			$algo_line mode $mode sel src $dst dst $src
+		ROD ip xfrm policy add src $dst dst $src dir in tmpl src $dst \
+			dst $src proto $proto mode $mode level use
+		ROD ip xfrm state
+		ROD ip xfrm policy
+	elif [ $target = dst ]; then
+		spi_1="0x$(( $spi + 1 ))"
+		spi_2="0x$spi"
+		tst_rhost_run -s -c "ip xfrm state add src $src dst $dst spi $spi_1 \
+			proto $proto $algo_line mode $mode sel src $src dst $dst"
+		tst_rhost_run -s -c "ip xfrm policy add src $src dst $dst dir out \

testcases/network/stress/ipsec/ipsec_lib.sh line 111

Quoted 10 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +10 -0
+			tmpl src $src dst $dst proto $proto mode $mode"
+
+		tst_rhost_run -s -c "ip xfrm state add src $dst dst $src spi $spi_2 \
+			proto $proto $algo_line mode $mode sel src $dst dst $src"
+		tst_rhost_run -s -c "ip xfrm policy add src $dst dst $src dir in \
+			tmpl src $dst dst $src proto $proto mode $mode level use"
+		tst_rhost_run -s -c "ip xfrm state"
+		tst_rhost_run -s -c "ip xfrm policy"
+	fi
+}

Can we stick with lhost/rhost naming, and lhost to be default value? So it would be similar to test_net.sh...

Best regards,
Alexey

#4 lore raw

PATCH v3 2/3 network/stress: add ipsec lib

Hi Alexey,

Thanks for all the advise. I will fix them soon.

Regards
Hangbin

Quoted 192 lines · Alexey Kodanev

Hi,

Quoted 21 lines · Hangbin Liu
---
 testcases/network/stress/ipsec/Makefile     |  29 ++++++++
 testcases/network/stress/ipsec/ipsec_lib.sh | 111 ++++++++++++++++++++++++++++
 2 files changed, 140 insertions(+)
 create mode 100644 testcases/network/stress/ipsec/Makefile
 create mode 100644 testcases/network/stress/ipsec/ipsec_lib.sh
testcases/network/stress/ipsec/Makefile new file +7 -0
new file mode 100644
index 0000000..0d7f1b6
@@ -0,0 +1,29 @@
+#!/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.

testcases/network/stress/ipsec/Makefile line 17

Quoted 10 lines
testcases/network/stress/ipsec/Makefile new file +10 -0
+#
+# 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
+#

Forgot to change it here?

Quoted 47 lines
testcases/network/stress/ipsec/Makefile new file +12 -0
+# Author: Hangbin Liu <[email protected]>
+#
+#######################################################################
+
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= *.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/network/stress/ipsec/ipsec_lib.sh new file +29 -0
new file mode 100644
index 0000000..33716ce
@@ -0,0 +1,111 @@
+#!/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, see <http://www.gnu.org/licenses/>.
+#
+# Author: Hangbin Liu <[email protected]>
+#
+#######################################################################
+
+. test_net.sh
+
+# tst_ipsec flush: flush the ipsec state and policy
+# tst_ipsec target protocol mode spi src_addr dst_addr: config ipsec
+#
+# target: target of the configuration file ( src / dst )
+# protocol: ah / esp / ipcomp
+# mode: transport / tunnel
+# spi: the first spi value

testcases/network/stress/ipsec/ipsec_lib.sh line 39

Quoted 10 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +10 -0
+# src_addr: source IP address
+# dst_addr: destination IP address
+tst_ipsec()
+{
+	if [ "$1" = "flush" ]; then
+		ROD ip xfrm state flush
+		ROD ip xfrm policy flush
+		tst_rhost_run -s -c "ip xfrm state flush && ip xfrm policy flush"
+		return 0
+	fi

I'd move it to another function, we could name ittst_ipsec_cleanup(). And tst_ipsec() needs some general description like what it actually does.

testcases/network/stress/ipsec/ipsec_lib.sh line 43

Quoted 4 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +4 -0
+	if [ $# -ne 6 ]; then
+		tst_resm TINFO "tst_ipsec parameter mismatch"
+		return 1
+	fi

Why not just tst_brkm() here?

testcases/network/stress/ipsec/ipsec_lib.sh line 50

Quoted 7 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +7 -0
+
+	target=$1
+	protocol=$2
+	mode=$3
+	spi=$4
+	src=$5
+	dst=$6

It's better to make these variables to be defined in function scope (as local) and other variables which used only inside the function.

testcases/network/stress/ipsec/ipsec_lib.sh line 58

Quoted 8 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +8 -0
+
+	# Encryption algorithm
+	EALGO="des3_ede"
+	EALGO_KEY=0x$(printf _I_want_to_have_chicken_ | hexdump -ve '/1 "%x"')
+
+	# Authentication algorithm
+	AALGO="sha1"
+	AALGO_KEY=0x$(printf beef_fish_pork_salad | hexdump -ve '/1 "%x"')

if we use hexdump, we should verify it with tst_check_cmds() (e.g. when we source the library).

Quoted 12 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +12 -0
+
+	# Compression algorithm
+	CALGO="deflate"
+	# Algorithm options for each protocol
+	case $protocol in
+	ah)
+		algo_line="auth $AALGO $AALGO_KEY"
+		proto="ah"
+		;;
+	esp)
+		algo_line="enc $EALGO $EALGO_KEY auth $AALGO $AALGO_KEY"
+		proto="esp"

testcases/network/stress/ipsec/ipsec_lib.sh line 80

Quoted 10 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +10 -0
+		;;
+	ipcomp)
+		algo_line="comp $CALGO"
+		proto="comp"
+		;;
+	*)
+		tst_resm TINFO "tst_ipsec protocol mismatch"
+		return 1
+		;;
+	esac

I would add tst_brkm() here as well.

Quoted 21 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +21 -0
+
+	if [ $target = src ]; then
+		spi_1="0x$spi"
+		spi_2="0x$(( $spi + 1 ))"
+		ROD ip xfrm state add src $src dst $dst spi $spi_1 proto $proto \
+			$algo_line mode $mode sel src $src dst $dst
+		ROD ip xfrm policy add src $src dst $dst dir out tmpl src $src \
+			dst $dst proto $proto mode $mode
+
+		ROD ip xfrm state add src $dst dst $src spi $spi_2 proto $proto \
+			$algo_line mode $mode sel src $dst dst $src
+		ROD ip xfrm policy add src $dst dst $src dir in tmpl src $dst \
+			dst $src proto $proto mode $mode level use
+		ROD ip xfrm state
+		ROD ip xfrm policy
+	elif [ $target = dst ]; then
+		spi_1="0x$(( $spi + 1 ))"
+		spi_2="0x$spi"
+		tst_rhost_run -s -c "ip xfrm state add src $src dst $dst spi $spi_1 \
+			proto $proto $algo_line mode $mode sel src $src dst $dst"
+		tst_rhost_run -s -c "ip xfrm policy add src $src dst $dst dir out \

testcases/network/stress/ipsec/ipsec_lib.sh line 111

Quoted 10 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +10 -0
+			tmpl src $src dst $dst proto $proto mode $mode"
+
+		tst_rhost_run -s -c "ip xfrm state add src $dst dst $src spi $spi_2 \
+			proto $proto $algo_line mode $mode sel src $dst dst $src"
+		tst_rhost_run -s -c "ip xfrm policy add src $dst dst $src dir in \
+			tmpl src $dst dst $src proto $proto mode $mode level use"
+		tst_rhost_run -s -c "ip xfrm state"
+		tst_rhost_run -s -c "ip xfrm policy"
+	fi
+}

Can we stick with lhost/rhost naming, and lhost to be default value? So it would be similar to test_net.sh...

Best regards,
Alexey

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 3 lines
Thanks & Best Regards
Hangbin Liu <[email protected]>
Leo on #kernel-qe, #kernel, #eng-china
#5 lore raw

PATCH v3 3/3 network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing

In reply to Hangbin Liu

Also check each msg_size in $ICMP_SIZE_ARRAY to make sure the connectvity.

---
 .../stress/icmp/uni-basic/icmp4-uni-basic01        | 160 ++++-----------------
 1 file changed, 24 insertions(+), 136 deletions(-)
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +24 -136
index b78ac8f..7c23cc7 100644
@@ -42,17 +42,13 @@
 #	Oct 19 2005 - Created (Mitsuru Chinen)
 #
 #-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
 # The test case ID, the test case count and the total number of test case
 TCID=${TCID:-icmp4-uni-basic01}
 TST_TOTAL=1
 TST_COUNT=1
-export TCID
-export TST_COUNT
-export TST_TOTAL
+TST_CLEANUP="do_cleanup"
+
+. ipsec_lib.sh
 
 # Test description
 tst_resm TINFO "Verify that the kernel is not crashed with receiving and sending various size of ICMP message with the following conditions"
@@ -61,9 +57,6 @@ tst_resm TINFO "Verify that the kernel is not crashed with receiving and sending
 LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
 export LTPROOT
 
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
 # Dulation of the test [sec]
 NS_DURATION=${NS_DURATION:-3600}      # 1 hour
 
@@ -72,6 +65,7 @@ LINK_NUM=${LINK_NUM:-0}
 
 # The version of IP
 IP_VER=${IP_VER:-4}
+[ $IP_VER -eq 6 ] && TST_IPV6=6
 
 # true, if ipsec is used
 DO_IPSEC=${DO_IPSEC:-false}
@@ -100,16 +94,8 @@ ICMP_SIZE_ARRAY=${ICMP_SIZE_ARRAY:-"10 100 1000 10000 65507"}
 #-----------------------------------------------------------------------
 do_cleanup()
 {
-    # Kill the icmp traffic server
-    killall_icmp_traffic
-
     # Unset SAD/SPD
-    output_ipsec_conf flush | setkey -c >/dev/null 2>&1
-    $LTP_RSH $RHOST ${LTPROOT}/'testcases/bin/output_ipsec_conf flush | PATH=/sbin:/usr/sbin:$PATH setkey -c' >/dev/null 2>&1
-
-    # Clean up each interface
-    initialize_if lhost ${LINK_NUM}
-    initialize_if rhost ${LINK_NUM}
+    tst_ipsec flush
 }
 
 
@@ -127,10 +113,9 @@ tst_resm TINFO "- Version of IP is IPv${IP_VER}"
 tst_resm TINFO "- Size of packets are ( $ICMP_SIZE_ARRAY )"
 
 if $DO_IPSEC ; then
-    message=`check_setkey`
+    message=`ip xfrm state`
     if [ $? -ne 0 ]; then
-	tst_resm TBROK "$message"
-	exit 1
+	tst_brkm TBROK "$message"
     fi
 
     case $IPSEC_PROTO in
@@ -147,16 +132,14 @@ if $DO_IPSEC ; then
 fi
 
 # name of interface of the local/remote host
-lhost_ifname=`get_ifname lhost $LINK_NUM`
+lhost_ifname=`tst_iface lhost $LINK_NUM`
 if [ $? -ne 0 ]; then
-    tst_resm TBROK "Failed to get the interface name at the local host"
-    exit $TST_TOTAL
+    tst_brkm TBROK "Failed to get the interface name at the local host"
 fi
 
-rhost_ifname=`get_ifname rhost $LINK_NUM`
+rhost_ifname=`tst_iface rhost $LINK_NUM`
 if [ $? -ne 0 ]; then
-    tst_resm TBROK "Failed to get the interface name at the remote host"
-    exit $TST_TOTAL
+    tst_brkm TBROK "Failed to get the interface name at the remote host"
 fi
 
 # Initialize the system configuration
@@ -165,125 +148,30 @@ do_cleanup
 # Call do_cleanup function before exit
 trap do_cleanup 0
 
-# Configurate IP addresses
-case $IP_VER in
-    4)
-    # Network portion of the IPv4 address
-    network_part=${IPV4_NETWORK:-"10.0.0"}
-
-    # Netmask of the IPv4 network
-    network_mask=24
-
-    # Host portion of the IPv4 address
-    lhost_host_part=${LHOST_IPV4_HOST:-"2"}     # local host
-    rhost_host_part=${RHOST_IPV4_HOST:-"1"}     # remote host
-
-    # Set IPv4 addresses to the interfaces
-    set_ipv4addr lhost $LINK_NUM $network_part $lhost_host_part
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the local host"
-	exit 1
-    fi
-
-    set_ipv4addr rhost $LINK_NUM $network_part $rhost_host_part
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the remote host"
-	exit 1
-    fi
-
-    # IPv4 address of the local/remote host
-    lhost_addr="${network_part}.${lhost_host_part}"
-    rhost_addr="${network_part}.${rhost_host_part}"
-    ;;
-
-    6)
-    # Network portion of the IPv6 address
-    network_part="fd00:1:1:1"
-
-    # Netmask of the IPv6 network
-    network_mask=64
-
-    # Host portion of the IPv6 address
-    lhost_host_part=":2"     # local host
-    rhost_host_part=":1"     # remote host
-
-    # Set IPv6 addresses to the interfaces
-    add_ipv6addr lhost $LINK_NUM $network_part $lhost_host_part
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the local host"
-	exit 1
-    fi
-
-    add_ipv6addr rhost $LINK_NUM $network_part $rhost_host_part
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the remote host"
-	exit 1
-    fi
-
-    # IPv6 address of the local/remote host
-    lhost_addr="${network_part}:${lhost_host_part}"
-    rhost_addr="${network_part}:${rhost_host_part}"
-    ;;
-
-    *)
-    tst_resm TBROK "Unknown IP version"
-    ;;
-esac
+lhost_addr=$(tst_ipaddr)
+rhost_addr=$(tst_ipaddr rhost)
 
 # Configure SAD/SPD
 if $DO_IPSEC ; then
-    ipsec_log=`mktemp -p $TMPDIR`
-
-    output_ipsec_conf src \
-	$IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr \
-	    |  setkey -c 2>&1 | tee $ipsec_log
-    if [ $? -ne 0 -o -s $ipsec_log ]; then
-	tst_resm TBROK "Failed to configure SAD/SPD on the local host."
-	rm -f $ipsec_log
-	exit 1
-    fi
-
-    $LTP_RSH $RHOST ${LTPROOT}/testcases/bin/output_ipsec_conf dst $IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr' | PATH=/sbin:/usr/sbin:$PATH setkey -c' 2>&1 | tee $ipsec_log
-    if [ $? -ne 0 -o -s $ipsec_log ]; then
-	tst_resm TBROK "Failed to configure SAD/SPD on the remote host."
-	rm -f $ipsec_log
-	exit 1
-    fi
-    rm -f $ipsec_log
+    tst_ipsec src $IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr
+    tst_ipsec dst $IPSEC_PROTO $IPSEC_MODE $SPI $rhost_addr $lhost_addr
 fi
 
-# Make sure the connectvity
-case $IP_VER in
-    4)
-    ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/check_icmpv4_connectivity $rhost_ifname $lhost_addr' ; echo $?'`
-    if [ $ret -ne 0 ]; then
-	tst_resm TBROK "There is no IPv4 connectivity."
-	exit 1
-    fi
-    ;;
-
-    6)
-    ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/check_icmpv6_connectivity $rhost_ifname $lhost_addr' ; echo $?'`
-    if [ $ret -ne 0 ]; then
-	tst_resm TBROK "There is no IPv6 connectivity."
-	exit 1
-    fi
-    ;;
-esac
-
-
 #-----------------------------------------------------------------------
 #
 # Main
 #
 #
 
-# Run a client
-$LTP_RSH $RHOST "${LTPROOT}/testcases/bin/ns-echoclient -S $lhost_addr -f $IP_VER -s \"$ICMP_SIZE_ARRAY\"" &
-
-sleep $NS_DURATION
-killall_icmp_traffic
-wait
+# Make sure the connectvity
+for msg_size in $ICMP_SIZE_ARRAY; do
+    tst_ping $lhost_ifname $rhost_addr $msg_size
+    if [ $? -ne 0 ]; then
+        tst_brkm TBROK "There is no IPv$IP_VER connectivity with msg_size $msg_size"
+    else
+        tst_resm TPASS "There has IPv$IP_VER connectivity with msg_size $msg_size"
+    fi
+done
 
 #-----------------------------------------------------------------------
 #
Signature · 1 line
2.5.0
#6 lore raw

PATCH v3 3/3 network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing

Quoted 33 lines · Hangbin Liu

Also check each msg_size in $ICMP_SIZE_ARRAY to make sure the connectvity.

---
  .../stress/icmp/uni-basic/icmp4-uni-basic01        | 160 ++++-----------------
  1 file changed, 24 insertions(+), 136 deletions(-)
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +3 -7
index b78ac8f..7c23cc7 100644
@@ -42,17 +42,13 @@
  #	Oct 19 2005 - Created (Mitsuru Chinen)
  #
  #-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
  # The test case ID, the test case count and the total number of test case
  TCID=${TCID:-icmp4-uni-basic01}
  TST_TOTAL=1
  TST_COUNT=1
-export TCID
-export TST_COUNT
-export TST_TOTAL
+TST_CLEANUP="do_cleanup"
+
+. ipsec_lib.sh
 
  # Test description
  tst_resm TINFO "Verify that the kernel is not crashed with receiving and sending various size of ICMP message with the following conditions"

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 tst_resm TINFO "Verify that the kernel is not crashed with receiving and sending · line 62

Quoted 9 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +0 -3
@@ -61,9 +57,6 @@ tst_resm TINFO "Verify that the kernel is not crashed with receiving and sending
  LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
  export LTPROOT
 
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
  # Dulation of the test [sec]
  NS_DURATION=${NS_DURATION:-3600}      # 1 hour
 

I'd remove defining these variables here... in the test. Weshouldhave them already
defined in network.sh or it could be done in test_net.sh in case we're not going to
runnetwork.sh.

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 LINK_NUM=${LINK_NUM:-0} · line 69

Quoted 6 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +1 -0
@@ -72,6 +65,7 @@ LINK_NUM=${LINK_NUM:-0}
 
  # The version of IP
  IP_VER=${IP_VER:-4}
+[ $IP_VER -eq 6 ] && TST_IPV6=6
 

just "ipv=${TST_IPV6:-4}" instead of two lines.

Quoted 8 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +0 -2
  # true, if ipsec is used
  DO_IPSEC=${DO_IPSEC:-false}
@@ -100,16 +94,8 @@ ICMP_SIZE_ARRAY=${ICMP_SIZE_ARRAY:-"10 100 1000 10000 65507"}
  #-----------------------------------------------------------------------
  do_cleanup()
  {
-    # Kill the icmp traffic server
-    killall_icmp_traffic

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 ICMP_SIZE_ARRAY=${ICMP_SIZE_ARRAY:-"10 100 1000 10000 65507"} · line 99

Quoted 10 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +1 -7
-
      # Unset SAD/SPD
-    output_ipsec_conf flush | setkey -c >/dev/null 2>&1
-    $LTP_RSH $RHOST ${LTPROOT}/'testcases/bin/output_ipsec_conf flush | PATH=/sbin:/usr/sbin:$PATH setkey -c' >/dev/null 2>&1
-
-    # Clean up each interface
-    initialize_if lhost ${LINK_NUM}
-    initialize_if rhost ${LINK_NUM}
+    tst_ipsec flush
 }

TST_CLEANUP=tst_ipsec_cleanup

Quoted 14 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +0 -0
  @@ -127,10 +113,9 @@ tst_resm TINFO "- Version of IP is IPv${IP_VER}"
  tst_resm TINFO "- Size of packets are ( $ICMP_SIZE_ARRAY )"

if $DO_IPSEC ; then

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +2 -3
-    message=`check_setkey`
+    message=`ip xfrm state`
      if [ $? -ne 0 ]; then
-	tst_resm TBROK "$message"
-	exit 1
+	tst_brkm TBROK "$message"
      fi
 
      case $IPSEC_PROTO in

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 if $DO_IPSEC ; then · line 137

Quoted 9 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +2 -3
@@ -147,16 +132,14 @@ if $DO_IPSEC ; then
  fi
 
  # name of interface of the local/remote host
-lhost_ifname=`get_ifname lhost $LINK_NUM`
+lhost_ifname=`tst_iface lhost $LINK_NUM`
  if [ $? -ne 0 ]; then
-    tst_resm TBROK "Failed to get the interface name at the local host"
-    exit $TST_TOTAL
+    tst_brkm TBROK "Failed to get the interface name at the local host"

These checks seems useless.

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 if $DO_IPSEC ; then · line 143

Quoted 9 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +2 -3
  fi
 
-rhost_ifname=`get_ifname rhost $LINK_NUM`
+rhost_ifname=`tst_iface rhost $LINK_NUM`
  if [ $? -ne 0 ]; then
-    tst_resm TBROK "Failed to get the interface name at the remote host"
-    exit $TST_TOTAL
+    tst_brkm TBROK "Failed to get the interface name at the remote host"
  fi

Here as well.

Quoted 128 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +4 -107
  # Initialize the system configuration
@@ -165,125 +148,30 @@ do_cleanup
  # Call do_cleanup function before exit
  trap do_cleanup 0
 
-# Configurate IP addresses
-case $IP_VER in
-    4)
-    # Network portion of the IPv4 address
-    network_part=${IPV4_NETWORK:-"10.0.0"}
-
-    # Netmask of the IPv4 network
-    network_mask=24
-
-    # Host portion of the IPv4 address
-    lhost_host_part=${LHOST_IPV4_HOST:-"2"}     # local host
-    rhost_host_part=${RHOST_IPV4_HOST:-"1"}     # remote host
-
-    # Set IPv4 addresses to the interfaces
-    set_ipv4addr lhost $LINK_NUM $network_part $lhost_host_part
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the local host"
-	exit 1
-    fi
-
-    set_ipv4addr rhost $LINK_NUM $network_part $rhost_host_part
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the remote host"
-	exit 1
-    fi
-
-    # IPv4 address of the local/remote host
-    lhost_addr="${network_part}.${lhost_host_part}"
-    rhost_addr="${network_part}.${rhost_host_part}"
-    ;;
-
-    6)
-    # Network portion of the IPv6 address
-    network_part="fd00:1:1:1"
-
-    # Netmask of the IPv6 network
-    network_mask=64
-
-    # Host portion of the IPv6 address
-    lhost_host_part=":2"     # local host
-    rhost_host_part=":1"     # remote host
-
-    # Set IPv6 addresses to the interfaces
-    add_ipv6addr lhost $LINK_NUM $network_part $lhost_host_part
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the local host"
-	exit 1
-    fi
-
-    add_ipv6addr rhost $LINK_NUM $network_part $rhost_host_part
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the remote host"
-	exit 1
-    fi
-
-    # IPv6 address of the local/remote host
-    lhost_addr="${network_part}:${lhost_host_part}"
-    rhost_addr="${network_part}:${rhost_host_part}"
-    ;;
-
-    *)
-    tst_resm TBROK "Unknown IP version"
-    ;;
-esac
+lhost_addr=$(tst_ipaddr)
+rhost_addr=$(tst_ipaddr rhost)
 
  # Configure SAD/SPD
  if $DO_IPSEC ; then
-    ipsec_log=`mktemp -p $TMPDIR`
-
-    output_ipsec_conf src \
-	$IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr \
-	    |  setkey -c 2>&1 | tee $ipsec_log
-    if [ $? -ne 0 -o -s $ipsec_log ]; then
-	tst_resm TBROK "Failed to configure SAD/SPD on the local host."
-	rm -f $ipsec_log
-	exit 1
-    fi
-
-    $LTP_RSH $RHOST ${LTPROOT}/testcases/bin/output_ipsec_conf dst $IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr' | PATH=/sbin:/usr/sbin:$PATH setkey -c' 2>&1 | tee $ipsec_log
-    if [ $? -ne 0 -o -s $ipsec_log ]; then
-	tst_resm TBROK "Failed to configure SAD/SPD on the remote host."
-	rm -f $ipsec_log
-	exit 1
-    fi
-    rm -f $ipsec_log
+    tst_ipsec src $IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr
+    tst_ipsec dst $IPSEC_PROTO $IPSEC_MODE $SPI $rhost_addr $lhost_addr
  fi
 
-# Make sure the connectvity
-case $IP_VER in
-    4)
-    ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/check_icmpv4_connectivity $rhost_ifname $lhost_addr' ; echo $?'`
-    if [ $ret -ne 0 ]; then
-	tst_resm TBROK "There is no IPv4 connectivity."
-	exit 1
-    fi
-    ;;
-
-    6)
-    ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/check_icmpv6_connectivity $rhost_ifname $lhost_addr' ; echo $?'`
-    if [ $ret -ne 0 ]; then
-	tst_resm TBROK "There is no IPv6 connectivity."
-	exit 1
-    fi
-    ;;
-esac
-
-
  #-----------------------------------------------------------------------
  #
  # Main
  #
  #
 
-# Run a client
-$LTP_RSH $RHOST "${LTPROOT}/testcases/bin/ns-echoclient -S $lhost_addr -f $IP_VER -s \"$ICMP_SIZE_ARRAY\"" &
-
-sleep $NS_DURATION
-killall_icmp_traffic

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 do_cleanup · line 174

Quoted 10 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +9 -1
-wait
+# Make sure the connectvity
+for msg_size in $ICMP_SIZE_ARRAY; do
+    tst_ping $lhost_ifname $rhost_addr $msg_size
+    if [ $? -ne 0 ]; then
+        tst_brkm TBROK "There is no IPv$IP_VER connectivity with msg_size $msg_size"
+    else
+        tst_resm TPASS "There has IPv$IP_VER connectivity with msg_size $msg_size"
+    fi
+done

Is it really needed to ping with different message sizes? if yes, we couldadd this
functionality to tst_ping().

Best regards,
Alexey

#7 lore raw

PATCH v3 3/3 network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing

Hi,

Quoted 39 lines · Alexey Kodanev
Quoted 37 lines · Hangbin Liu

Also check each msg_size in $ICMP_SIZE_ARRAY to make sure the connectvity.

---
 .../stress/icmp/uni-basic/icmp4-uni-basic01        | 160 ++++-----------------
 1 file changed, 24 insertions(+), 136 deletions(-)
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +3 -10
index b78ac8f..7c23cc7 100644
@@ -42,17 +42,13 @@
 #	Oct 19 2005 - Created (Mitsuru Chinen)
 #
 #-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
 # The test case ID, the test case count and the total number of test case
 TCID=${TCID:-icmp4-uni-basic01}
 TST_TOTAL=1
 TST_COUNT=1
-export TCID
-export TST_COUNT
-export TST_TOTAL
+TST_CLEANUP="do_cleanup"
+
+. ipsec_lib.sh
 # Test description
 tst_resm TINFO "Verify that the kernel is not crashed with receiving and sending various size of ICMP message with the following conditions"
@@ -61,9 +57,6 @@ tst_resm TINFO "Verify that the kernel is not crashed with receiving and sending
 LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
 export LTPROOT
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
-
Quoted 8 lines

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 tst_resm TINFO "Verify that the kernel is not crashed with receiving and sending · line 61

Quoted 2 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +0 -0
 # Dulation of the test [sec]
 NS_DURATION=${NS_DURATION:-3600}      # 1 hour

I'd remove defining these variables here... in the test. Weshouldhave them already
defined in network.sh or it could be done in test_net.sh in case we're not going to
runnetwork.sh.

OK, I will remove this

Quoted 7 lines

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 LINK_NUM=${LINK_NUM:-0} · line 67

Quoted 5 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +1 -0
@@ -72,6 +65,7 @@ LINK_NUM=${LINK_NUM:-0}
 # The version of IP
 IP_VER=${IP_VER:-4}
+[ $IP_VER -eq 6 ] && TST_IPV6=6

just "ipv=${TST_IPV6:-4}" instead of two lines.

This is not work. Because test_net.sh will set TST_IPV6= , and icmp4-uni-basic01 need source it before test. The relation looks like

icmp6-uni-basic01
. icmp4-uni-basic01
. ipsec_lib.sh
. test_net.sh

If we want to use like ipv=${TST_IPV6:-4}, we need source test_net.sh in all sub-testcases instead of in ipsec_lib.sh. Which will like

icmp6-uni-basic01
. test_net.sh
. icmp4-uni-basic01
. ipsec_lib.sh

Quoted 45 lines
Quoted 9 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +0 -2
 # true, if ipsec is used
 DO_IPSEC=${DO_IPSEC:-false}
@@ -100,16 +94,8 @@ ICMP_SIZE_ARRAY=${ICMP_SIZE_ARRAY:-"10 100 1000 10000 65507"}
 #-----------------------------------------------------------------------
 do_cleanup()
 {
-    # Kill the icmp traffic server
-    killall_icmp_traffic

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 ICMP_SIZE_ARRAY=${ICMP_SIZE_ARRAY:-"10 100 1000 10000 65507"} · line 99

Quoted 10 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +1 -7
-
     # Unset SAD/SPD
-    output_ipsec_conf flush | setkey -c >/dev/null 2>&1
-    $LTP_RSH $RHOST ${LTPROOT}/'testcases/bin/output_ipsec_conf flush | PATH=/sbin:/usr/sbin:$PATH setkey -c' >/dev/null 2>&1
-
-    # Clean up each interface
-    initialize_if lhost ${LINK_NUM}
-    initialize_if rhost ${LINK_NUM}
+    tst_ipsec flush
 }

TST_CLEANUP=tst_ipsec_cleanup

Quoted 12 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +0 -0
 @@ -127,10 +113,9 @@ tst_resm TINFO "- Version of IP is IPv${IP_VER}"
 tst_resm TINFO "- Size of packets are ( $ICMP_SIZE_ARRAY )"

if $DO_IPSEC ; then

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +2 -3
-    message=`check_setkey`
+    message=`ip xfrm state`
     if [ $? -ne 0 ]; then
-	tst_resm TBROK "$message"
-	exit 1
+	tst_brkm TBROK "$message"
     fi
     case $IPSEC_PROTO in

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 if $DO_IPSEC ; then · line 136

Quoted 8 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +2 -3
@@ -147,16 +132,14 @@ if $DO_IPSEC ; then
 fi
 # name of interface of the local/remote host
-lhost_ifname=`get_ifname lhost $LINK_NUM`
+lhost_ifname=`tst_iface lhost $LINK_NUM`
 if [ $? -ne 0 ]; then
-    tst_resm TBROK "Failed to get the interface name at the local host"
-    exit $TST_TOTAL
+    tst_brkm TBROK "Failed to get the interface name at the local host"

These checks seems useless.

Quoted 10 lines

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 if $DO_IPSEC ; then · line 143

Quoted 8 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +2 -3
 fi
-rhost_ifname=`get_ifname rhost $LINK_NUM`
+rhost_ifname=`tst_iface rhost $LINK_NUM`
 if [ $? -ne 0 ]; then
-    tst_resm TBROK "Failed to get the interface name at the remote host"
-    exit $TST_TOTAL
+    tst_brkm TBROK "Failed to get the interface name at the remote host"
 fi

Here as well.

OK, will remove these checks.

Quoted 131 lines
Quoted 131 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +10 -108
 # Initialize the system configuration
@@ -165,125 +148,30 @@ do_cleanup
 # Call do_cleanup function before exit
 trap do_cleanup 0
-# Configurate IP addresses
-case $IP_VER in
-    4)
-    # Network portion of the IPv4 address
-    network_part=${IPV4_NETWORK:-"10.0.0"}
-
-    # Netmask of the IPv4 network
-    network_mask=24
-
-    # Host portion of the IPv4 address
-    lhost_host_part=${LHOST_IPV4_HOST:-"2"}     # local host
-    rhost_host_part=${RHOST_IPV4_HOST:-"1"}     # remote host
-
-    # Set IPv4 addresses to the interfaces
-    set_ipv4addr lhost $LINK_NUM $network_part $lhost_host_part
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the local host"
-	exit 1
-    fi
-
-    set_ipv4addr rhost $LINK_NUM $network_part $rhost_host_part
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the remote host"
-	exit 1
-    fi
-
-    # IPv4 address of the local/remote host
-    lhost_addr="${network_part}.${lhost_host_part}"
-    rhost_addr="${network_part}.${rhost_host_part}"
-    ;;
-
-    6)
-    # Network portion of the IPv6 address
-    network_part="fd00:1:1:1"
-
-    # Netmask of the IPv6 network
-    network_mask=64
-
-    # Host portion of the IPv6 address
-    lhost_host_part=":2"     # local host
-    rhost_host_part=":1"     # remote host
-
-    # Set IPv6 addresses to the interfaces
-    add_ipv6addr lhost $LINK_NUM $network_part $lhost_host_part
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the local host"
-	exit 1
-    fi
-
-    add_ipv6addr rhost $LINK_NUM $network_part $rhost_host_part
-    if [ $? -ne 0 ]; then
-	tst_resm TBROK "Failed to add any IP address at the remote host"
-	exit 1
-    fi
-
-    # IPv6 address of the local/remote host
-    lhost_addr="${network_part}:${lhost_host_part}"
-    rhost_addr="${network_part}:${rhost_host_part}"
-    ;;
-
-    *)
-    tst_resm TBROK "Unknown IP version"
-    ;;
-esac
+lhost_addr=$(tst_ipaddr)
+rhost_addr=$(tst_ipaddr rhost)
 # Configure SAD/SPD
 if $DO_IPSEC ; then
-    ipsec_log=`mktemp -p $TMPDIR`
-
-    output_ipsec_conf src \
-	$IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr \
-	    |  setkey -c 2>&1 | tee $ipsec_log
-    if [ $? -ne 0 -o -s $ipsec_log ]; then
-	tst_resm TBROK "Failed to configure SAD/SPD on the local host."
-	rm -f $ipsec_log
-	exit 1
-    fi
-
-    $LTP_RSH $RHOST ${LTPROOT}/testcases/bin/output_ipsec_conf dst $IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr' | PATH=/sbin:/usr/sbin:$PATH setkey -c' 2>&1 | tee $ipsec_log
-    if [ $? -ne 0 -o -s $ipsec_log ]; then
-	tst_resm TBROK "Failed to configure SAD/SPD on the remote host."
-	rm -f $ipsec_log
-	exit 1
-    fi
-    rm -f $ipsec_log
+    tst_ipsec src $IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr
+    tst_ipsec dst $IPSEC_PROTO $IPSEC_MODE $SPI $rhost_addr $lhost_addr
 fi
-# Make sure the connectvity
-case $IP_VER in
-    4)
-    ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/check_icmpv4_connectivity $rhost_ifname $lhost_addr' ; echo $?'`
-    if [ $ret -ne 0 ]; then
-	tst_resm TBROK "There is no IPv4 connectivity."
-	exit 1
-    fi
-    ;;
-
-    6)
-    ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/check_icmpv6_connectivity $rhost_ifname $lhost_addr' ; echo $?'`
-    if [ $ret -ne 0 ]; then
-	tst_resm TBROK "There is no IPv6 connectivity."
-	exit 1
-    fi
-    ;;
-esac
-
-
 #-----------------------------------------------------------------------
 #
 # Main
 #
 #
-# Run a client
-$LTP_RSH $RHOST "${LTPROOT}/testcases/bin/ns-echoclient -S $lhost_addr -f $IP_VER -s \"$ICMP_SIZE_ARRAY\"" &
-
-sleep $NS_DURATION
-killall_icmp_traffic
-wait
+# Make sure the connectvity
+for msg_size in $ICMP_SIZE_ARRAY; do
+    tst_ping $lhost_ifname $rhost_addr $msg_size
+    if [ $? -ne 0 ]; then
+        tst_brkm TBROK "There is no IPv$IP_VER connectivity with msg_size $msg_size"
+    else
Quoted 8 lines

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 do_cleanup · line 174

Quoted 3 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +3 -0
+        tst_resm TPASS "There has IPv$IP_VER connectivity with msg_size $msg_size"
+    fi
+done

Is it really needed to ping with different message sizes? if yes, we couldadd this
functionality to tst_ping().

Yes, we need to make sure ipsec can handle all kinds of message size. But we could not make it in tst_ping because ah/esp and tunnel/transport have different header length. e.g. when there is no ipsec, the max playload is 65507. If we test ah + transport, the max playload is 65483. etc. It's hard to make tst_ping to handle all these scenarios.

Thanks
Hangbin

#8 lore raw

PATCH v3 3/3 network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing

Hi,

Quoted 62 lines · Hangbin Liu

Hi,

Quoted 37 lines · Alexey Kodanev
Quoted 36 lines · Hangbin Liu

Also check each msg_size in $ICMP_SIZE_ARRAY to make sure the connectvity.

---
  .../stress/icmp/uni-basic/icmp4-uni-basic01        | 160 ++++-----------------
  1 file changed, 24 insertions(+), 136 deletions(-)
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +3 -9
index b78ac8f..7c23cc7 100644
@@ -42,17 +42,13 @@
  #	Oct 19 2005 - Created (Mitsuru Chinen)
  #
  #-----------------------------------------------------------------------
-# Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
  # The test case ID, the test case count and the total number of test case
  TCID=${TCID:-icmp4-uni-basic01}
  TST_TOTAL=1
  TST_COUNT=1
-export TCID
-export TST_COUNT
-export TST_TOTAL
+TST_CLEANUP="do_cleanup"
+
+. ipsec_lib.sh
  # Test description
  tst_resm TINFO "Verify that the kernel is not crashed with receiving and sending various size of ICMP message with the following conditions"
@@ -61,9 +57,6 @@ tst_resm TINFO "Verify that the kernel is not crashed with receiving and sending
  LTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`}
  export LTPROOT
-# Check the environmanet variable
-. check_envval || exit $TST_TOTAL
Quoted 8 lines

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 tst_resm TINFO "Verify that the kernel is not crashed with receiving and sending · line 61

Quoted 3 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +0 -1
-
  # Dulation of the test [sec]
  NS_DURATION=${NS_DURATION:-3600}      # 1 hour

I'd remove defining these variables here... in the test. Weshouldhave them already
defined in network.sh or it could be done in test_net.sh in case we're not going to
runnetwork.sh.

OK, I will remove this

Quoted 5 lines

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 LINK_NUM=${LINK_NUM:-0} · line 67

Quoted 4 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +1 -0
@@ -72,6 +65,7 @@ LINK_NUM=${LINK_NUM:-0}
  # The version of IP
  IP_VER=${IP_VER:-4}
+[ $IP_VER -eq 6 ] && TST_IPV6=6

just "ipv=${TST_IPV6:-4}" instead of two lines.

This is not work. Because test_net.sh will set TST_IPV6= , and icmp4-uni-basic01 need source it before test. The relation looks like

icmp6-uni-basic01
. icmp4-uni-basic01
. ipsec_lib.sh
. test_net.sh

Quoted 7 lines

If we want to use like ipv=${TST_IPV6:-4}, we need source test_net.sh in all sub-testcases instead of in ipsec_lib.sh. Which will like

icmp6-uni-basic01
. test_net.sh
. icmp4-uni-basic01
. ipsec_lib.sh

Could you add "ipv=..." to ipsec_lib.sh and we wouldn't set it in every test-case?

BTW, does the attached patch help in the first case (added export to TST_IPV6)?

Quoted 16 lines
Quoted 16 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +9 -6
-# Run a client
-$LTP_RSH $RHOST "${LTPROOT}/testcases/bin/ns-echoclient -S $lhost_addr -f $IP_VER -s \"$ICMP_SIZE_ARRAY\"" &
-
-sleep $NS_DURATION
-killall_icmp_traffic
-wait
+# Make sure the connectvity
+for msg_size in $ICMP_SIZE_ARRAY; do
+    tst_ping $lhost_ifname $rhost_addr $msg_size
+    if [ $? -ne 0 ]; then
+        tst_brkm TBROK "There is no IPv$IP_VER connectivity with msg_size $msg_size"
+    else
+        tst_resm TPASS "There has IPv$IP_VER connectivity with msg_size $msg_size"
+    fi
+done
Quoted 8 lines
Quoted 3 lines

Is it really needed to ping with different message sizes? if yes, we couldadd this
functionality to tst_ping().

Yes, we need to make sure ipsec can handle all kinds of message size. But we could not make it in tst_ping because ah/esp and tunnel/transport have different header length. e.g. when there is no ipsec, the max playload is 65507. If we test ah + transport, the max playload is 65483. etc. It's hard to make tst_ping to handle all these scenarios.

I thought we could add variable length parameters, something like this

tst_ping p1 ... pN $ICMP_SIZE_ARRAY

tst_ping()

{
     local msg_sizes=${@:N+1}

     for size in msg_sizes; do
     ...
}

Best regards,
Alexey

Quoted 2 lines

Thanks
Hangbin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-testcases-lib-test_net.sh-export-TST_IPV6-var.patch
Type: text/x-patch
Size: 702 bytes
Desc: not available
URL: <http://lists.linux.it/pipermail/ltp/attachments/20160323/29814bb0/attachment-0001.bin>

#9 lore raw

PATCH v3 3/3 network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing

Hi,

Quoted 17 lines · Alexey Kodanev

Hi,

Quoted 16 lines
Quoted 5 lines

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 LINK_NUM=${LINK_NUM:-0} · line 67

Quoted 4 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +1 -0
@@ -72,6 +65,7 @@ LINK_NUM=${LINK_NUM:-0}
 # The version of IP
 IP_VER=${IP_VER:-4}
+[ $IP_VER -eq 6 ] && TST_IPV6=6

just "ipv=${TST_IPV6:-4}" instead of two lines.

This is not work. Because test_net.sh will set TST_IPV6= , and icmp4-uni-basic01 need source it before test. The relation looks like

icmp6-uni-basic01
. icmp4-uni-basic01
. ipsec_lib.sh
. test_net.sh

If we want to use like ipv=${TST_IPV6:-4}, we need source test_net.sh in all sub-testcases instead of in ipsec_lib.sh. Which will like

Quoted 7 lines
Quoted 4 lines

icmp6-uni-basic01
. test_net.sh
. icmp4-uni-basic01
. ipsec_lib.sh

Could you add "ipv=..." to ipsec_lib.sh and we wouldn't set it in every test-case?

the IP_VER is to describe what the test run for. We shouldn't add it in ipsec_lib.sh. There is no relations between them.

Quoted 3 lines

BTW, does the attached patch help in the first case (added export to TST_IPV6)?

I'm afraid not. I'd tried to use like

icmp4-uni-basic01 icmp4-uni-basic01
icmp6-uni-basic01 icmp4-uni-basic01 -6

Then I find this is not only different of IP version, ipsec protocol, mode. But also different message sizes. So I give up to use like that.

Quoted 31 lines
Quoted 18 lines
Quoted 18 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +9 -6
-# Run a client
-$LTP_RSH $RHOST "${LTPROOT}/testcases/bin/ns-echoclient -S $lhost_addr -f $IP_VER -s \"$ICMP_SIZE_ARRAY\"" &
-
-sleep $NS_DURATION
-killall_icmp_traffic
-wait
+# Make sure the connectvity
+for msg_size in $ICMP_SIZE_ARRAY; do
+    tst_ping $lhost_ifname $rhost_addr $msg_size
+    if [ $? -ne 0 ]; then
+        tst_brkm TBROK "There is no IPv$IP_VER connectivity with msg_size $msg_size"
+    else
+        tst_resm TPASS "There has IPv$IP_VER connectivity with msg_size $msg_size"
+    fi
+done
Quoted 8 lines
Quoted 3 lines

Is it really needed to ping with different message sizes? if yes, we couldadd this
functionality to tst_ping().

Yes, we need to make sure ipsec can handle all kinds of message size. But we could not make it in tst_ping because ah/esp and tunnel/transport have different header length. e.g. when there is no ipsec, the max playload is 65507. If we test ah + transport, the max playload is 65483. etc. It's hard to make tst_ping to handle all these scenarios.

I thought we could add variable length parameters, something like this

tst_ping p1 ... pN $ICMP_SIZE_ARRAY

Quoted 7 lines

tst_ping()

{
    local msg_sizes=${@:N+1}

    for size in msg_sizes; do
    ...
}

I think tst_ping() is a unit test to check the connectivity, we do not need to add everything inside. Most time we only need to make sure the rhost is online. Let's make the test case deside what message size they want to test.

How to you think?

Thanks
Hangbin

Quoted 39 lines

Best regards,
Alexey

Quoted 2 lines

Thanks
Hangbin

From 99f1c6eadacd6b03180fe08fc36eae3725a57341 Mon Sep 17 00:00:00 2001
From: Alexey Kodanev <[email protected]>
Date: Wed, 23 Mar 2016 11:11:29 +0300
Subject: [PATCH] testcases/lib/test_net.sh: export TST_IPV6 var

---
 testcases/lib/test_net.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
testcases/lib/test_net.sh +1 -1
index 418fed3..1227265 100644
@@ -154,7 +154,7 @@ tst_read_opts()
 	while getopts ":6" opt; do
 		case "$opt" in
 		6)
-			TST_IPV6=6;;
+			export TST_IPV6=6;;
 		esac
 	done
 	OPTIND=0
Signature · 6 lines
1.7.1



-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 3 lines
Thanks & Best Regards
Hangbin Liu <[email protected]>
Leo on #kernel-qe, #kernel, #eng-china
#10 lore raw

PATCH v3 3/3 network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing

Hi,

Quoted 19 lines · Hangbin Liu

Hi,

Quoted 17 lines · Alexey Kodanev

Hi,

Quoted 16 lines
Quoted 5 lines

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 LINK_NUM=${LINK_NUM:-0} · line 67

Quoted 4 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +1 -0
@@ -72,6 +65,7 @@ LINK_NUM=${LINK_NUM:-0}
  # The version of IP
  IP_VER=${IP_VER:-4}
+[ $IP_VER -eq 6 ] && TST_IPV6=6

just "ipv=${TST_IPV6:-4}" instead of two lines.

This is not work. Because test_net.sh will set TST_IPV6= , and icmp4-uni-basic01 need source it before test. The relation looks like

icmp6-uni-basic01
. icmp4-uni-basic01
. ipsec_lib.sh
. test_net.sh

If we want to use like ipv=${TST_IPV6:-4}, we need source test_net.sh in all sub-testcases instead of in ipsec_lib.sh. Which will like

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

icmp6-uni-basic01
. test_net.sh
. icmp4-uni-basic01
. ipsec_lib.sh

Could you add "ipv=..." to ipsec_lib.sh and we wouldn't set it in every test-case?

the IP_VER is to describe what the test run for. We shouldn't add it in ipsec_lib.sh. There is no relations between them.

Looking at the tests structure there... basically, one file implements test-cases
and the rest scripts source the first one along with changing a few parameters.
I think it's better to leave only one file there and remove the rest.

icmp4-uni-basic01 -> icmp-uni-basic.

May be moving them all to the upper directory, so in the end we should have only 3 tests:
icmp_multi_diffip.sh
icmp_multi_diffnic.sh
icmp_uni_basic.sh

Then, we could define each test-case in "runtests/", using env vars and parameters.

Quoted 44 lines
Quoted 3 lines

BTW, does the attached patch help in the first case (added export to TST_IPV6)?

I'm afraid not. I'd tried to use like

icmp4-uni-basic01 icmp4-uni-basic01
icmp6-uni-basic01 icmp4-uni-basic01 -6

Then I find this is not only different of IP version, ipsec protocol, mode. But also different message sizes. So I give up to use like that.

Quoted 33 lines
Quoted 17 lines
Quoted 17 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +9 -6
-# Run a client
-$LTP_RSH $RHOST "${LTPROOT}/testcases/bin/ns-echoclient -S $lhost_addr -f $IP_VER -s \"$ICMP_SIZE_ARRAY\"" &
-
-sleep $NS_DURATION
-killall_icmp_traffic
-wait
+# Make sure the connectvity
+for msg_size in $ICMP_SIZE_ARRAY; do
+    tst_ping $lhost_ifname $rhost_addr $msg_size
+    if [ $? -ne 0 ]; then
+        tst_brkm TBROK "There is no IPv$IP_VER connectivity with msg_size $msg_size"
+    else
+        tst_resm TPASS "There has IPv$IP_VER connectivity with msg_size $msg_size"
+    fi
+done
Quoted 8 lines
Quoted 3 lines

Is it really needed to ping with different message sizes? if yes, we couldadd this
functionality to tst_ping().

Yes, we need to make sure ipsec can handle all kinds of message size. But we could not make it in tst_ping because ah/esp and tunnel/transport have different header length. e.g. when there is no ipsec, the max playload is 65507. If we test ah + transport, the max playload is 65483. etc. It's hard to make tst_ping to handle all these scenarios.

I thought we could add variable length parameters, something like this

tst_ping p1 ... pN $ICMP_SIZE_ARRAY

tst_ping()

{
     local msg_sizes=${@:N+1}
Quoted 8 lines
Quoted 3 lines

for size in msg_sizes; do
...
}

I think tst_ping() is a unit test to check the connectivity, we do not need to add everything inside. Most time we only need to make sure the rhost is online. Let's make the test case deside what message size they want to test.

How to you think?

I still think we should add it to the library. tst_ping replaces 'icmp4/6_check_connectivity'. And adding variable message size there, will replace ns-echoclient library tool.

I don't understand why do you want to implement it in the each icmp test?

Thanks,
Alexey

#11 lore raw

PATCH v3 3/3 network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing

Hi Alexey,

Quoted 38 lines · Alexey Kodanev

Hi,

Quoted 19 lines · Hangbin Liu

Hi,

Quoted 17 lines · Alexey Kodanev

Hi,

Quoted 16 lines
Quoted 5 lines

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 LINK_NUM=${LINK_NUM:-0} · line 67

Quoted 4 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +1 -0
@@ -72,6 +65,7 @@ LINK_NUM=${LINK_NUM:-0}
 # The version of IP
 IP_VER=${IP_VER:-4}
+[ $IP_VER -eq 6 ] && TST_IPV6=6

just "ipv=${TST_IPV6:-4}" instead of two lines.

This is not work. Because test_net.sh will set TST_IPV6= , and icmp4-uni-basic01 need source it before test. The relation looks like

icmp6-uni-basic01
. icmp4-uni-basic01
. ipsec_lib.sh
. test_net.sh

If we want to use like ipv=${TST_IPV6:-4}, we need source test_net.sh in all sub-testcases instead of in ipsec_lib.sh. Which will like

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

icmp6-uni-basic01
. test_net.sh
. icmp4-uni-basic01
. ipsec_lib.sh

Could you add "ipv=..." to ipsec_lib.sh and we wouldn't set it in every test-case?

the IP_VER is to describe what the test run for. We shouldn't add it in ipsec_lib.sh. There is no relations between them.

Looking at the tests structure there... basically, one file implements test-cases
and the rest scripts source the first one along with changing a few parameters.
I think it's better to leave only one file there and remove the rest.

icmp4-uni-basic01 -> icmp-uni-basic.

Quoted 8 lines

May be moving them all to the upper directory, so in the end we should have only 3 tests:
icmp_multi_diffip.sh
icmp_multi_diffnic.sh
icmp_uni_basic.sh

Then, we could define each test-case in "runtests/", using env vars and parameters.

Does it looks like

icmp4-uni-basic01 icmp-uni-basic
icmp4-uni-basic02 DO_IPSEC=true IPSEC_PROTO=ah IPSEC_MODE=transport ICMP_SIZE_ARRAY="10 100 1000 10000 65483"; icmp-uni-basic
...
icmp6-uni-basic01 icmp-uni-basic -6
icmp6-uni-basic02 DO_IPSEC=true IPSEC_PROTO=ah IPSEC_MODE=transport ICMP_SIZE_ARRAY="10 100 1000 10000 65503"; icmp-uni-basic -6

Quoted 52 lines
Quoted 52 lines
Quoted 4 lines

BTW, does the attached patch help in the first case (added export to TST_IPV6)?

I'm afraid not. I'd tried to use like

icmp4-uni-basic01 icmp4-uni-basic01
icmp6-uni-basic01 icmp4-uni-basic01 -6

Then I find this is not only different of IP version, ipsec protocol, mode. But also different message sizes. So I give up to use like that.

Quoted 29 lines
Quoted 17 lines
Quoted 17 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +9 -6
-# Run a client
-$LTP_RSH $RHOST "${LTPROOT}/testcases/bin/ns-echoclient -S $lhost_addr -f $IP_VER -s \"$ICMP_SIZE_ARRAY\"" &
-
-sleep $NS_DURATION
-killall_icmp_traffic
-wait
+# Make sure the connectvity
+for msg_size in $ICMP_SIZE_ARRAY; do
+    tst_ping $lhost_ifname $rhost_addr $msg_size
+    if [ $? -ne 0 ]; then
+        tst_brkm TBROK "There is no IPv$IP_VER connectivity with msg_size $msg_size"
+    else
+        tst_resm TPASS "There has IPv$IP_VER connectivity with msg_size $msg_size"
+    fi
+done
Quoted 8 lines
Quoted 3 lines

Is it really needed to ping with different message sizes? if yes, we couldadd this
functionality to tst_ping().

Yes, we need to make sure ipsec can handle all kinds of message size. But we could not make it in tst_ping because ah/esp and tunnel/transport have different header length. e.g. when there is no ipsec, the max playload is 65507. If we test ah + transport, the max playload is 65483. etc. It's hard to make tst_ping to handle all these scenarios.

I thought we could add variable length parameters, something like this

tst_ping p1 ... pN $ICMP_SIZE_ARRAY

Quoted 7 lines

tst_ping()

{
    local msg_sizes=${@:N+1}

    for size in msg_sizes; do
    ...
}

I think tst_ping() is a unit test to check the connectivity, we do not need to add everything inside. Most time we only need to make sure the rhost is online. Let's make the test case deside what message size they want to test.

Quoted 5 lines
Quoted 1 line

How to you think?

I still think we should add it to the library. tst_ping replaces 'icmp4/6_check_connectivity'. And adding variable message size there, will replace ns-echoclient library tool.

I did't find icmp4/6_check_connectivity will do icmp msg_size check. But anyway, here is a msg_sizes version. how do you think? should we use ROD ping... directly?

tst_ping()

{
        # The max number of ICMP echo request
        PING_MAX=${PING_MAX:-"10"}

        local src_iface=${1:-"$(tst_iface)"}
        local dst_addr=${2:-"$(tst_ipaddr rhost)"}
        # ping cmd use 56 as default message size
        local msg_sizes=${3:-"56"}

        for size in $msg_sizes; do
                ping$TST_IPV6 -I $src_iface -c $PING_MAX $dst_addr \
                        -s $msg_size > /dev/null 2>&1
                if [ $? -ne 0 ]; then
                        tst_brkm TBROK "There is no IPv${IP_VER:-4} connectivity with msg_size $msg_size"
                else
                        tst_resm TPASS "There is IPv${IP_VER:-4} connectivity with msg_size $msg_size"
                fi
        done
}

Thanks & Best Regards
Hangbin Liu

#12 lore raw

PATCH v3 3/3 network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing

Hi,

Quoted 20 lines · Hangbin Liu

Hi Alexey,

Quoted 9 lines · Alexey Kodanev

Looking at the tests structure there... basically, one file implements test-cases
and the rest scripts source the first one along with changing a few parameters.
I think it's better to leave only one file there and remove the rest.

icmp4-uni-basic01 -> icmp-uni-basic.

Quoted 8 lines

May be moving them all to the upper directory, so in the end we should have only 3 tests:
icmp_multi_diffip.sh
icmp_multi_diffnic.sh
icmp_uni_basic.sh

Then, we could define each test-case in "runtests/", using env vars and parameters.

Quoted 7 lines

Does it looks like

icmp4-uni-basic01 icmp-uni-basic
icmp4-uni-basic02 DO_IPSEC=true IPSEC_PROTO=ah IPSEC_MODE=transport ICMP_SIZE_ARRAY="10 100 1000 10000 65483"; icmp-uni-basic
...
icmp6-uni-basic01 icmp-uni-basic -6
icmp6-uni-basic02 DO_IPSEC=true IPSEC_PROTO=ah IPSEC_MODE=transport ICMP_SIZE_ARRAY="10 100 1000 10000 65503"; icmp-uni-basic -6

Or something like network/virt_lib.sh does with getopts, so instead of setting
environment variables we would have easy to look at runtest lines, e.g.:

icmp6-uni-basic01 icmp-uni-basic -6
icmp6-uni-basic02 icmp-uni-basic -6 -p ah -m transport -s "10 100 1000 10000 65503"

Quoted 50 lines
Quoted 50 lines
Quoted 50 lines
Quoted 3 lines

BTW, does the attached patch help in the first case (added export to TST_IPV6)?

I'm afraid not. I'd tried to use like

icmp4-uni-basic01 icmp4-uni-basic01
icmp6-uni-basic01 icmp4-uni-basic01 -6

Then I find this is not only different of IP version, ipsec protocol, mode. But also different message sizes. So I give up to use like that.

Quoted 28 lines
Quoted 16 lines
Quoted 16 lines
(quoted diff) +9 -6
-# Run a client
-$LTP_RSH $RHOST "${LTPROOT}/testcases/bin/ns-echoclient -S $lhost_addr -f $IP_VER -s \"$ICMP_SIZE_ARRAY\"" &
-
-sleep $NS_DURATION
-killall_icmp_traffic
-wait
+# Make sure the connectvity
+for msg_size in $ICMP_SIZE_ARRAY; do
+    tst_ping $lhost_ifname $rhost_addr $msg_size
+    if [ $? -ne 0 ]; then
+        tst_brkm TBROK "There is no IPv$IP_VER connectivity with msg_size $msg_size"
+    else
+        tst_resm TPASS "There has IPv$IP_VER connectivity with msg_size $msg_size"
+    fi
+done
Quoted 8 lines
Quoted 3 lines

Is it really needed to ping with different message sizes? if yes, we couldadd this
functionality to tst_ping().

Yes, we need to make sure ipsec can handle all kinds of message size. But we could not make it in tst_ping because ah/esp and tunnel/transport have different header length. e.g. when there is no ipsec, the max playload is 65507. If we test ah + transport, the max playload is 65483. etc. It's hard to make tst_ping to handle all these scenarios.

I thought we could add variable length parameters, something like this

tst_ping p1 ... pN $ICMP_SIZE_ARRAY

Quoted 7 lines

tst_ping()

{
     local msg_sizes=${@:N+1}

     for size in msg_sizes; do
     ...
}

I think tst_ping() is a unit test to check the connectivity, we do not need to add everything inside. Most time we only need to make sure the rhost is online. Let's make the test case deside what message size they want to test.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

How to you think?

I still think we should add it to the library. tst_ping replaces 'icmp4/6_check_connectivity'. And adding variable message size there, will replace ns-echoclient library tool.

I did't find icmp4/6_check_connectivity will do icmp msg_size check. But anyway, here is a msg_sizes version. how do you think? should we use ROD ping... directly?

It's in "ns-echoclient".

About ROD in tst_ping()... may be we shouldn't use it here. It's quite simple
to call "ROD tst_ping" anyway.

Also I'm not sure we won't have tests that pass on failed ping. For example, vxlan tests set different IDs and check that there is no connectivity. In this particular cases,
the test shouldn't exit with TBROK but return TPASS status. We could simply return ping
status here and let test to decide what to do next.

Quoted 10 lines

tst_ping()

{
         # The max number of ICMP echo request
         PING_MAX=${PING_MAX:-"10"}

         local src_iface=${1:-"$(tst_iface)"}
         local dst_addr=${2:-"$(tst_ipaddr rhost)"}
         # ping cmd use 56 as default message size
         local msg_sizes=${3:-"56"}

local msg_sizes=${@:3}

for size in ${msg_sizes:-"56"}; do

     ping...

Best regards,
Alexey

Quoted 14 lines
         for size in $msg_sizes; do
                 ping$TST_IPV6 -I $src_iface -c $PING_MAX $dst_addr \
                         -s $msg_size > /dev/null 2>&1
                 if [ $? -ne 0 ]; then
                         tst_brkm TBROK "There is no IPv${IP_VER:-4} connectivity with msg_size $msg_size"
                 else
                         tst_resm TPASS "There is IPv${IP_VER:-4} connectivity with msg_size $msg_size"
                 fi
         done
}

Thanks & Best Regards
Hangbin Liu

#13 lore raw

PATCH v3 3/3 network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing

Hi,

Quoted 8 lines · Alexey Kodanev
Quoted 7 lines

Does it looks like

icmp4-uni-basic01 icmp-uni-basic
icmp4-uni-basic02 DO_IPSEC=true IPSEC_PROTO=ah IPSEC_MODE=transport ICMP_SIZE_ARRAY="10 100 1000 10000 65483"; icmp-uni-basic
...
icmp6-uni-basic01 icmp-uni-basic -6
icmp6-uni-basic02 DO_IPSEC=true IPSEC_PROTO=ah IPSEC_MODE=transport ICMP_SIZE_ARRAY="10 100 1000 10000 65503"; icmp-uni-basic -6

Quoted 6 lines

Or something like network/virt_lib.sh does with getopts, so instead of setting
environment variables we would have easy to look at runtest lines, e.g.:

icmp6-uni-basic01 icmp-uni-basic -6
icmp6-uni-basic02 icmp-uni-basic -6 -p ah -m transport -s "10 100 1000 10000 65503"

OK, I will try this way

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

I still think we should add it to the library. tst_ping replaces 'icmp4/6_check_connectivity'. And adding variable message size there, will replace ns-echoclient library tool.

I did't find icmp4/6_check_connectivity will do icmp msg_size check. But anyway, here is a msg_sizes version. how do you think? should we use ROD ping... directly?

It's in "ns-echoclient".

ns-echoclient only ping remote but do not check the return status.

Quoted 11 lines

About ROD in tst_ping()... may be we shouldn't use it here. It's quite simple
to call "ROD tst_ping" anyway.

Also I'm not sure we won't have tests that pass on failed ping. For example, vxlan tests set different IDs and check that there is no connectivity. In this particular cases,
the test shouldn't exit with TBROK but return TPASS status. We could simply return ping
status here and let test to decide what to do next.

Here comes back the old discuss. tst_ping is used for check connectivity. If we use msg_sizes="10 100 1000 10000 65530" and failed when send msg_size 10000 and return -1. How the test know which msg size failed? That's the reason I feel we should let tst_ping check one msg_size each time.

Thanks
Hangbin

Quoted 39 lines
Quoted 11 lines

tst_ping()

{
        # The max number of ICMP echo request
        PING_MAX=${PING_MAX:-"10"}

        local src_iface=${1:-"$(tst_iface)"}
        local dst_addr=${2:-"$(tst_ipaddr rhost)"}
        # ping cmd use 56 as default message size
        local msg_sizes=${3:-"56"}

local msg_sizes=${@:3}

for size in ${msg_sizes:-"56"}; do

    ping...

Best regards,
Alexey

Quoted 14 lines
        for size in $msg_sizes; do
                ping$TST_IPV6 -I $src_iface -c $PING_MAX $dst_addr \
                        -s $msg_size > /dev/null 2>&1
                if [ $? -ne 0 ]; then
                        tst_brkm TBROK "There is no IPv${IP_VER:-4} connectivity with msg_size $msg_size"
                else
                        tst_resm TPASS "There is IPv${IP_VER:-4} connectivity with msg_size $msg_size"
                fi
        done
}

Thanks & Best Regards
Hangbin Liu

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 3 lines
Thanks & Best Regards
Hangbin Liu <[email protected]>
Leo on #kernel-qe, #kernel, #eng-china
#14 lore raw

PATCH v3 3/3 network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing

Hi,

Quoted 17 lines · Hangbin Liu

Hi,

Quoted 7 lines · Alexey Kodanev
Quoted 7 lines

Does it looks like

icmp4-uni-basic01 icmp-uni-basic
icmp4-uni-basic02 DO_IPSEC=true IPSEC_PROTO=ah IPSEC_MODE=transport ICMP_SIZE_ARRAY="10 100 1000 10000 65483"; icmp-uni-basic
...
icmp6-uni-basic01 icmp-uni-basic -6
icmp6-uni-basic02 DO_IPSEC=true IPSEC_PROTO=ah IPSEC_MODE=transport ICMP_SIZE_ARRAY="10 100 1000 10000 65503"; icmp-uni-basic -6

Quoted 6 lines

Or something like network/virt_lib.sh does with getopts, so instead of setting
environment variables we would have easy to look at runtest lines, e.g.:

icmp6-uni-basic01 icmp-uni-basic -6
icmp6-uni-basic02 icmp-uni-basic -6 -p ah -m transport -s "10 100 1000 10000 65503"

OK, I will try this way

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

I still think we should add it to the library. tst_ping replaces 'icmp4/6_check_connectivity'. And adding variable message size there, will replace ns-echoclient library tool.

I did't find icmp4/6_check_connectivity will do icmp msg_size check. But anyway, here is a msg_sizes version. how do you think? should we use ROD ping... directly?

It's in "ns-echoclient".

ns-echoclient only ping remote but do not check the return status.

Yeah, I know, that's the reason you removed it in your patch.

Quoted 11 lines
Quoted 11 lines

About ROD in tst_ping()... may be we shouldn't use it here. It's quite simple
to call "ROD tst_ping" anyway.

Also I'm not sure we won't have tests that pass on failed ping. For example, vxlan tests set different IDs and check that there is no connectivity. In this particular cases,
the test shouldn't exit with TBROK but return TPASS status. We could simply return ping
status here and let test to decide what to do next.

Quoted 4 lines

Here comes back the old discuss. tst_ping is used for check connectivity. If we use msg_sizes="10 100 1000 10000 65530" and failed when send msg_size 10000 and return -1. How the test know which msg size failed? That's the reason I feel we should let tst_ping check one msg_size each time.

We could print it in tst_ping() as information message before 'return 1', will it be enough?

Thanks,
Alexey

Quoted 37 lines

Thanks
Hangbin

Quoted 34 lines
Quoted 9 lines

tst_ping()

{
         # The max number of ICMP echo request
         PING_MAX=${PING_MAX:-"10"}

         local src_iface=${1:-"$(tst_iface)"}
         local dst_addr=${2:-"$(tst_ipaddr rhost)"}
         # ping cmd use 56 as default message size
         local msg_sizes=${3:-"56"}

local msg_sizes=${@:3}

for size in ${msg_sizes:-"56"}; do

     ping...

Best regards,
Alexey

Quoted 13 lines
         for size in $msg_sizes; do
                 ping$TST_IPV6 -I $src_iface -c $PING_MAX $dst_addr \
                         -s $msg_size > /dev/null 2>&1
                 if [ $? -ne 0 ]; then
                         tst_brkm TBROK "There is no IPv${IP_VER:-4} connectivity with msg_size $msg_size"
                 else
                         tst_resm TPASS "There is IPv${IP_VER:-4} connectivity with msg_size $msg_size"
                 fi
         done
}

Thanks & Best Regards
Hangbin Liu

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#15 lore raw

PATCH v3 3/3 network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing

Quoted 41 lines · Alexey Kodanev

Hi,

Quoted 17 lines · Hangbin Liu

Hi,

Quoted 7 lines · Alexey Kodanev
Quoted 7 lines

Does it looks like

icmp4-uni-basic01 icmp-uni-basic
icmp4-uni-basic02 DO_IPSEC=true IPSEC_PROTO=ah IPSEC_MODE=transport ICMP_SIZE_ARRAY="10 100 1000 10000 65483"; icmp-uni-basic
...
icmp6-uni-basic01 icmp-uni-basic -6
icmp6-uni-basic02 DO_IPSEC=true IPSEC_PROTO=ah IPSEC_MODE=transport ICMP_SIZE_ARRAY="10 100 1000 10000 65503"; icmp-uni-basic -6

Quoted 6 lines

Or something like network/virt_lib.sh does with getopts, so instead of setting
environment variables we would have easy to look at runtest lines, e.g.:

icmp6-uni-basic01 icmp-uni-basic -6
icmp6-uni-basic02 icmp-uni-basic -6 -p ah -m transport -s "10 100 1000 10000 65503"

OK, I will try this way

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

I still think we should add it to the library. tst_ping replaces 'icmp4/6_check_connectivity'. And adding variable message size there, will replace ns-echoclient library tool.

I did't find icmp4/6_check_connectivity will do icmp msg_size check. But anyway, here is a msg_sizes version. how do you think? should we use ROD ping... directly?

It's in "ns-echoclient".

ns-echoclient only ping remote but do not check the return status.

Yeah, I know, that's the reason you removed it in your patch.

Quoted 11 lines
Quoted 11 lines

About ROD in tst_ping()... may be we shouldn't use it here. It's quite simple
to call "ROD tst_ping" anyway.

Also I'm not sure we won't have tests that pass on failed ping. For example, vxlan tests set different IDs and check that there is no connectivity. In this particular cases,
the test shouldn't exit with TBROK but return TPASS status. We could simply return ping
status here and let test to decide what to do next.

Quoted 7 lines
Quoted 4 lines

Here comes back the old discuss. tst_ping is used for check connectivity. If we use msg_sizes="10 100 1000 10000 65530" and failed when send msg_size 10000 and return -1. How the test know which msg size failed? That's the reason I feel we should let tst_ping check one msg_size each time.

We could print it in tst_ping() as information message before 'return 1', will it be enough?

Yes, that would be fine. Thanks for the advice.

Regards
Hangbin

Quoted 46 lines

Thanks,
Alexey

Quoted 37 lines

Thanks
Hangbin

Quoted 34 lines
Quoted 9 lines

tst_ping()

{
        # The max number of ICMP echo request
        PING_MAX=${PING_MAX:-"10"}

        local src_iface=${1:-"$(tst_iface)"}
        local dst_addr=${2:-"$(tst_ipaddr rhost)"}
        # ping cmd use 56 as default message size
        local msg_sizes=${3:-"56"}

local msg_sizes=${@:3}

for size in ${msg_sizes:-"56"}; do

    ping...

Best regards,
Alexey

Quoted 13 lines
        for size in $msg_sizes; do
                ping$TST_IPV6 -I $src_iface -c $PING_MAX $dst_addr \
                        -s $msg_size > /dev/null 2>&1
                if [ $? -ne 0 ]; then
                        tst_brkm TBROK "There is no IPv${IP_VER:-4} connectivity with msg_size $msg_size"
                else
                        tst_resm TPASS "There is IPv${IP_VER:-4} connectivity with msg_size $msg_size"
                fi
        done
}

Thanks & Best Regards
Hangbin Liu

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 3 lines
Thanks & Best Regards
Hangbin Liu <[email protected]>
Leo on #kernel-qe, #kernel, #eng-china