Skip to contentSkip to conversation

networking/stress: add ip xfrm ipsec support

PATCH Superseded Hangbin Liu 1 participant 6 messages Apr 8, 2016

v4 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v4 cover networking/stress: add ip xfrm ipsec support

From: Hangbin Liu <[email protected]>

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 V3:
1. use message size array in tst_ping
2. add tst_ipsec_cleanup in ipsec_lib
3. use lhost/rhost naming in ipsec_lib
4. add icmp-uni-basic in the upper icmp directory
5. some other small fixs.

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 icmp uni-basic ipsec testing

 runtest/network_stress.icmp                  |  28 +++---
 testcases/lib/test_net.sh                    |  31 +++++++
 testcases/network/stress/icmp/Makefile       |   3 +
 testcases/network/stress/icmp/icmp-uni-basic | 132 +++++++++++++++++++++++++++
 testcases/network/stress/ipsec/Makefile      |  28 ++++++
 testcases/network/stress/ipsec/ipsec_lib.sh  | 114 +++++++++++++++++++++++
 6 files changed, 322 insertions(+), 14 deletions(-)
 create mode 100755 testcases/network/stress/icmp/icmp-uni-basic
 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 v4 1/3 lib/test_net.sh: add tst_ping() to check icmp connectivity

From: Hangbin Liu <[email protected]>

---
 testcases/lib/test_net.sh | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
testcases/lib/test_net.sh +31 -0
index 418fed3..dd05f91 100644
@@ -314,3 +314,34 @@ tst_netload()
 
 	return $ret
 }
+
+# tst_ping [IFACE] [SRC ADDR] [DST ADDR] [MESSAGE SIZE ARREY]
+# Check icmp connectivity
+# IFACE: source interface name
+# SRC ADDR: source IPv4 or IPv6 address
+# DST ADDR: destination IPv4 or IPv6 address
+# MESSAGE SIZE ARREY: message size arrey
+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)"}
+	local msg_sizes=${@:3}
+	local ret=0
+
+	# ping cmd use 56 as default message size
+	for size in ${msg_sizes:-"56"}; do
+		ping$TST_IPV6 -I $src_iface -c $PING_MAX $dst_addr \
+			-s $size > /dev/null 2>&1
+		ret=$?
+		if [ $ret -eq 0 ]; then
+			tst_resm TINFO "tst_ping IPv${TST_IPV6:-4} msg_size $size pass"
+		else
+			tst_resm TINFO "tst_ping IPv${TST_IPV6:-4} msg_size $size fail"
+			break
+		fi
+	done
+	return $ret
+}
Signature · 1 line
2.5.0
#2 lore raw

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

In reply to Hangbin Liu

From: Hangbin Liu <[email protected]>

---
 testcases/network/stress/ipsec/Makefile     |  28 +++++++
 testcases/network/stress/ipsec/ipsec_lib.sh | 114 ++++++++++++++++++++++++++++
 2 files changed, 142 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 +28 -0
new file mode 100644
index 0000000..43352cc
@@ -0,0 +1,28 @@
+#!/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]>
+#
+#######################################################################
+
+
+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 +114 -0

114 lines not on this page · raw message

Signature · 1 line
2.5.0
#3 lore raw

PATCH v4 3/3 network/stress/icmp: use ip xfrm for icmp uni-basic ipsec testing

In reply to Hangbin Liu

From: Hangbin Liu <[email protected]>

Add icmp-uni-basic to implements the test case and define each test case in "runtests/" and use parameters. Also use ip xfrm instead of setkey for ipsec testing.

---
 runtest/network_stress.icmp                  |  28 +++---
 testcases/network/stress/icmp/Makefile       |   3 +
 testcases/network/stress/icmp/icmp-uni-basic | 132 +++++++++++++++++++++++++++
 3 files changed, 149 insertions(+), 14 deletions(-)
 create mode 100755 testcases/network/stress/icmp/icmp-uni-basic
runtest/network_stress.icmp +14 -14
index 29b52d1..1803b21 100644
@@ -2,21 +2,21 @@
 # Stress test for TCP/IP protocol stack (ICMP)
 #
 
-icmp4-uni-basic01 icmp4-uni-basic01
-icmp4-uni-basic02 icmp4-uni-basic02
-icmp4-uni-basic03 icmp4-uni-basic03
-icmp4-uni-basic04 icmp4-uni-basic04
-icmp4-uni-basic05 icmp4-uni-basic05
-icmp4-uni-basic06 icmp4-uni-basic06
-icmp4-uni-basic07 icmp4-uni-basic07
+icmp4-uni-basic01 icmp-uni-basic -s "10 100 1000 10000 65503"
+icmp4-uni-basic02 icmp-uni-basic -p ah -m transport -s "10 100 1000 10000 65483"
+icmp4-uni-basic03 icmp-uni-basic -p ah -m tunnel -s "10 100 1000 10000 65463"
+icmp4-uni-basic04 icmp-uni-basic -p esp -m transport -s "10 100 1000 10000 65470"
+icmp4-uni-basic05 icmp-uni-basic -p esp -m tunnel -s "10 100 1000 10000 65450"
+icmp4-uni-basic06 icmp-uni-basic -p ipcomp -m transport -s "1000 10000 65000"
+icmp4-uni-basic07 icmp-uni-basic -p ipcomp -m tunnel -s "1000 10000 65000"
 
-icmp6-uni-basic01 icmp6-uni-basic01
-icmp6-uni-basic02 icmp6-uni-basic02
-icmp6-uni-basic03 icmp6-uni-basic03
-icmp6-uni-basic04 icmp6-uni-basic04
-icmp6-uni-basic05 icmp6-uni-basic05
-icmp6-uni-basic06 icmp6-uni-basic06
-icmp6-uni-basic07 icmp6-uni-basic07
+icmp6-uni-basic01 icmp-uni-basic -6 -s "10 100 1000 10000 65527"
+icmp6-uni-basic02 icmp-uni-basic -6 -p ah -m transport -s "10 100 1000 10000 65503"
+icmp6-uni-basic03 icmp-uni-basic -6 -p ah -m tunnel -s "10 100 1000 10000 65527"
+icmp6-uni-basic04 icmp-uni-basic -6 -p esp -m transport -s "10 100 1000 10000 65494"
+icmp6-uni-basic05 icmp-uni-basic -6 -p esp -m tunnel -s "10 100 1000 10000 65495"
+icmp6-uni-basic06 icmp-uni-basic -6 -p ipcomp -m transport -s "1000 10000 65000"
+icmp6-uni-basic07 icmp-uni-basic -6 -p ipcomp -m tunnel -s "1000 10000 65000"
 
 icmp4-multi-diffip01 icmp4-multi-diffip01
 icmp4-multi-diffip02 icmp4-multi-diffip02
testcases/network/stress/icmp/Makefile +3 -0
index 0dad1d1..9310aa1 100644
@@ -23,4 +23,7 @@
 top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= icmp*
+
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
testcases/network/stress/icmp/icmp-uni-basic new file +132 -0

132 lines not on this page · raw message

Signature · 1 line
2.5.0
#4 lore raw

PATCH v4 3/3 network/stress/icmp: use ip xfrm for icmp uni-basic ipsec testing

Hi Alexey,

Quoted 20 lines · Hangbin Liu

From: Hangbin Liu <[email protected]>

Add icmp-uni-basic to implements the test case and define each test case in "runtests/" and use parameters. Also use ip xfrm instead of setkey for ipsec testing.

---
 runtest/network_stress.icmp                  |  28 +++---
 testcases/network/stress/icmp/Makefile       |   3 +
 testcases/network/stress/icmp/icmp-uni-basic | 132 +++++++++++++++++++++++++++
 3 files changed, 149 insertions(+), 14 deletions(-)
 create mode 100755 testcases/network/stress/icmp/icmp-uni-basic
runtest/network_stress.icmp +0 -0
index 29b52d1..1803b21 100644
@@ -2,21 +2,21 @@
 # Stress test for TCP/IP protocol stack (ICMP)

runtest/network_stress.icmp line 5

Quoted 10 lines
runtest/network_stress.icmp +1 -7
 #
 
-icmp4-uni-basic01 icmp4-uni-basic01
-icmp4-uni-basic02 icmp4-uni-basic02
-icmp4-uni-basic03 icmp4-uni-basic03
-icmp4-uni-basic04 icmp4-uni-basic04
-icmp4-uni-basic05 icmp4-uni-basic05
-icmp4-uni-basic06 icmp4-uni-basic06
-icmp4-uni-basic07 icmp4-uni-basic07
+icmp4-uni-basic01 icmp-uni-basic -s "10 100 1000 10000 65503"
                                                           ^^ typo here, should be 65507
Quoted 11 lines
runtest/network_stress.icmp +6 -4
+icmp4-uni-basic02 icmp-uni-basic -p ah -m transport -s "10 100 1000 10000 65483"
+icmp4-uni-basic03 icmp-uni-basic -p ah -m tunnel -s "10 100 1000 10000 65463"
+icmp4-uni-basic04 icmp-uni-basic -p esp -m transport -s "10 100 1000 10000 65470"
+icmp4-uni-basic05 icmp-uni-basic -p esp -m tunnel -s "10 100 1000 10000 65450"
+icmp4-uni-basic06 icmp-uni-basic -p ipcomp -m transport -s "1000 10000 65000"
+icmp4-uni-basic07 icmp-uni-basic -p ipcomp -m tunnel -s "1000 10000 65000"
 
-icmp6-uni-basic01 icmp6-uni-basic01
-icmp6-uni-basic02 icmp6-uni-basic02
-icmp6-uni-basic03 icmp6-uni-basic03
-icmp6-uni-basic04 icmp6-uni-basic04

runtest/network_stress.icmp line 19

Quoted 10 lines
runtest/network_stress.icmp +7 -3
-icmp6-uni-basic05 icmp6-uni-basic05
-icmp6-uni-basic06 icmp6-uni-basic06
-icmp6-uni-basic07 icmp6-uni-basic07
+icmp6-uni-basic01 icmp-uni-basic -6 -s "10 100 1000 10000 65527"
+icmp6-uni-basic02 icmp-uni-basic -6 -p ah -m transport -s "10 100 1000 10000 65503"
+icmp6-uni-basic03 icmp-uni-basic -6 -p ah -m tunnel -s "10 100 1000 10000 65527"
+icmp6-uni-basic04 icmp-uni-basic -6 -p esp -m transport -s "10 100 1000 10000 65494"
+icmp6-uni-basic05 icmp-uni-basic -6 -p esp -m tunnel -s "10 100 1000 10000 65495"
+icmp6-uni-basic06 icmp-uni-basic -6 -p ipcomp -m transport -s "1000 10000 65000"
+icmp6-uni-basic07 icmp-uni-basic -6 -p ipcomp -m tunnel -s "1000 10000 65000"

The max message size for ipv6 is incorrect.

The pure ipv4 icmp max message is 65535 - 20(ipv4 hdr) - 8(icmp hdr) = 65507, IPv4 ah + transport max message is 65535 - 20 - 24(ah hdr) - 8 = 65483. The pure ipv6 icmp max message is 65535 - 8 = 65527.

What I mean is each IPsec mode/protocol have different max message size. Should we calculate each size and test them or just use a commom size like 65000? How do you think.

BTW, this patch set's signoff info is incorrect. I will send a new version. But it would be good if you could help review this patch set and give advice first so I can fix them in next version.

Thanks
Hangbin

Quoted 156 lines
runtest/network_stress.icmp +0 -0
 icmp4-multi-diffip01 icmp4-multi-diffip01
 icmp4-multi-diffip02 icmp4-multi-diffip02
testcases/network/stress/icmp/Makefile +3 -0
index 0dad1d1..9310aa1 100644
@@ -23,4 +23,7 @@
 top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= icmp*
+
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
testcases/network/stress/icmp/icmp-uni-basic new file +132 -0
new file mode 100755
index 0000000..de586d6
@@ -0,0 +1,132 @@
+#!/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]>
+#
+################################################################################
+#
+# File:
+#   icmp-uni-basic.sh
+#
+# Description:
+#   Verify that the kernel is not crashed with receiving and sending various
+#   size of ICMP message
+#
+#   *) This script may be read by the other test case
+#
+# Setup:
+#   See ltp-yyyymmdd/testcases/network/stress/README
+#
+#-----------------------------------------------------------------------
+# The test case ID, the test case count and the total number of test case
+TCID=${TCID:-icmp-uni-basic}
+TST_TOTAL=1
+TST_COUNT=1
+TST_CLEANUP="tst_ipsec_cleanup"
+
+. ipsec_lib.sh
+
+while getopts "hl:m:p:s:S:6" opt; do
+	case "$opt" in
+	h)
+		echo "Usage:"
+		echo "h        help"
+		echo "l n      n is the number of test link when tests run"
+		echo "m x      x is ipsec mode, could be transport / tunnel"
+		echo "p x      x is ipsec protcol, could be ah / esp / ipcomp"
+		echo "s x      x is icmp messge size array"
+		echo "S n      n is IPsec SPI value"
+		echo "6        run over IPv6"
+		exit 0
+	;;
+	l) LINK_NUM=$OPTARG ;;
+	m) IPSEC_MODE=$OPTARG ;;
+	p) IPSEC_PROTO=$OPTARG ;;
+	s) ICMP_SIZE_ARRAY=$OPTARG ;;
+	S) SPI=$OPTARG ;;
+	6) # skip, test_net library already processed it
+	;;
+	*) tst_brkm TBROK "unknown option: $opt" ;;
+	esac
+done
+
+SPI=${SPI:-1000}
+LINK_NUM=${LINK_NUM:-0}
+DO_IPSEC=${DO_IPSEC:-false}
+ICMP_SIZE_ARRAY=${ICMP_SIZE_ARRAY:-"10 100 1000 10000 65507"}
+[ -n "$IPSEC_MODE" -a -n "$IPSEC_PROTO" ] && DO_IPSEC=true || DO_IPSEC=false
+
+#-----------------------------------------------------------------------
+#
+# Setup
+#
+
+# Unset the maximum number of processes
+ulimit -u unlimited
+
+# 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"
+tst_resm TINFO "- Version of IP is IPv${TST_IPV6:-4}"
+tst_resm TINFO "- Size of packets are ( $ICMP_SIZE_ARRAY )"
+
+if $DO_IPSEC; then
+	case $IPSEC_PROTO in
+	ah)	tst_resm TINFO "- IPsec [ AH / $IPSEC_MODE ]" ;;
+	esp)	tst_resm TINFO "- IPsec [ ESP / $IPSEC_MODE ]" ;;
+	ipcomp)	tst_resm TINFO "- IPcomp [ $IPSEC_MODE ]" ;;
+	esac
+fi
+
+# name of interface of the local/remote host
+lhost_ifname=`tst_iface lhost $LINK_NUM`
+rhost_ifname=`tst_iface rhost $LINK_NUM`
+
+# Initialize the system configuration
+tst_ipsec_cleanup
+
+# Call cleanup function before exit
+trap tst_ipsec_cleanup 0
+
+lhost_addr=$(tst_ipaddr)
+rhost_addr=$(tst_ipaddr rhost)
+
+# Configure SAD/SPD
+if $DO_IPSEC ; then
+	tst_ipsec lhost $IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr
+	tst_ipsec rhost $IPSEC_PROTO $IPSEC_MODE $SPI $rhost_addr $lhost_addr
+fi
+
+#-----------------------------------------------------------------------
+#
+# Main
+#
+#
+
+# Make sure the connectvity
+tst_ping $lhost_ifname $rhost_addr $ICMP_SIZE_ARRAY
+if [ $? -ne 0 ]; then
+	tst_brkm TBROK "IPv${TST_IPV6:-4} $IPSEC_PROTO $IPSEC_MODE connectivity"
+else
+	tst_resm TPASS "IPv${TST_IPV6:-4} $IPSEC_PROTO $IPSEC_MODE connectivity"
+fi
+
+#-----------------------------------------------------------------------
+#
+# Clean up
+#
+
+tst_resm TPASS "Test is finished successfully."
+exit 0
Signature · 1 line
2.5.0
Signature · 3 lines
Thanks & Best Regards
Hangbin Liu <[email protected]>
Leo on #kernel-qe, #kernel, #eng-china
#5 lore raw

v4 cover networking/stress: add ip xfrm ipsec support

In reply to Hangbin Liu

Sorry, the signoff info is incorrect. Please ignore this patch set.

Thanks
Hangbin

Quoted 52 lines · Hangbin Liu

From: Hangbin Liu <[email protected]>

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 V3:
1. use message size array in tst_ping
2. add tst_ipsec_cleanup in ipsec_lib
3. use lhost/rhost naming in ipsec_lib
4. add icmp-uni-basic in the upper icmp directory
5. some other small fixs.

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 icmp uni-basic ipsec testing

 runtest/network_stress.icmp                  |  28 +++---
 testcases/lib/test_net.sh                    |  31 +++++++
 testcases/network/stress/icmp/Makefile       |   3 +
 testcases/network/stress/icmp/icmp-uni-basic | 132 +++++++++++++++++++++++++++
 testcases/network/stress/ipsec/Makefile      |  28 ++++++
 testcases/network/stress/ipsec/ipsec_lib.sh  | 114 +++++++++++++++++++++++
 6 files changed, 322 insertions(+), 14 deletions(-)
 create mode 100755 testcases/network/stress/icmp/icmp-uni-basic
 create mode 100644 testcases/network/stress/ipsec/Makefile
 create mode 100644 testcases/network/stress/ipsec/ipsec_lib.sh
Signature · 1 line
2.5.0
Signature · 3 lines
Thanks & Best Regards
Hangbin Liu <[email protected]>
Leo on #kernel-qe, #kernel, #eng-china