Skip to contentSkip to conversation

networking/stress: add ip xfrm ipsec support

PATCH Superseded Hangbin Liu 2 participants 11 messages Mar 15, 2016 – Mar 17, 2016

v2 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v2 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 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                          |  21 ++++
 .../stress/icmp/uni-basic/icmp4-uni-basic01        |  96 +++++-----------
 testcases/network/stress/ipsec/Makefile            |  29 +++++
 testcases/network/stress/ipsec/ipsec_lib.sh        | 126 +++++++++++++++++++++
 4 files changed, 207 insertions(+), 65 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 v2 1/3 lib/test_net.sh: add tst_ping() to check icmp connectivity

---
 testcases/lib/test_net.sh | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
testcases/lib/test_net.sh +21 -0
index 418fed3..8517cb9 100644
@@ -314,3 +314,24 @@ 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"}
+
+	echo $dst_addr | grep -q ":" && TST_IPV6=6
+
+	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 v2 1/3 lib/test_net.sh: add tst_ping() to check icmp connectivity

Hi,

Quoted 20 lines · Hangbin Liu
---
  testcases/lib/test_net.sh | 21 +++++++++++++++++++++
  1 file changed, 21 insertions(+)
testcases/lib/test_net.sh +7 -0
index 418fed3..8517cb9 100644
@@ -314,3 +314,24 @@ 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()

testcases/lib/test_net.sh tst_netload() · line 333

Quoted 10 lines
testcases/lib/test_net.sh +10 -0
+{
+	# 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"}
+
+	echo $dst_addr | grep -q ":" && TST_IPV6=6

You shouldn't have this check here because TST_IPV6 should be set before test runs. Either test starts with '-6' parameter (that way it is automatically set in test_net.sh) or manually defined as TST_IPV6=6 in ipv6 specific test.

Note, tst_ipaddr function returns IPv4 or IPv6 address depending on TST_IPV6, so it is quite strange to check the returned address by this function and set TST_IPV6.

Thanks,
Alexey

#3 lore raw

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

Quoted 37 lines · Alexey Kodanev

Hi,

Quoted 19 lines · Hangbin Liu
---
 testcases/lib/test_net.sh | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
testcases/lib/test_net.sh +7 -0
index 418fed3..8517cb9 100644
@@ -314,3 +314,24 @@ 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()

testcases/lib/test_net.sh tst_netload() · line 332

Quoted 10 lines
testcases/lib/test_net.sh +10 -0
+{
+	# 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"}
+
+	echo $dst_addr | grep -q ":" && TST_IPV6=6

You shouldn't have this check here because TST_IPV6 should be set before test runs. Either test starts with '-6' parameter (that way it is automatically set in test_net.sh) or manually defined as TST_IPV6=6 in ipv6 specific test.

Quoted 3 lines

Note, tst_ipaddr function returns IPv4 or IPv6 address depending on TST_IPV6, so it is quite strange to check the returned address by this function and set TST_IPV6.

Hi Alexey:

icmp4-uni-basic01 use IP_VER to check ip version. So I did this check before ping. But as you said, I will remove the check and add TST_IPV6 in uni-basic tests.

BTW, Would you like to help apply the patches and check the ROD issue? I always got the following error when use ROD to run cmds.

# testscripts/networkstress.sh -i
<<<test_start>>>
tag=icmp4-uni-basic01 stime=1458033932
cmdline="icmp4-uni-basic01"
contacts=""
analysis=exit
<<<test_output>>>
icmp4-uni-basic01 1 TINFO : Verify that the kernel is not crashed with receiving and sending various size of ICMP message with the following conditions
icmp4-uni-basic01 1 TINFO : - Test duration is 3600 [sec]
icmp4-uni-basic01 1 TINFO : - Version of IP is IPv4
icmp4-uni-basic01 1 TINFO : - Size of packets are ( 10 100 1000 10000 65507 )
++ ROD ip xfrm state flush
++ local cmd
++ local arg
++ local file
++ local flag
++ for arg in '"$@"'
++ file=ip
++ '[' ip '!=' ip ']'
/opt/ltp/testcases/bin/test.sh: line 232: flag: unbound variable
<<<execution_status>>>
initiation_status="ok"
duration=0 termination_type=exited termination_id=1 corefile=no
cutime=0 cstime=0
<<<test_end>>>

Thanks
Hangbin

#4 lore raw

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

Hi,

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

Hi,

Quoted 19 lines · Hangbin Liu
---
  testcases/lib/test_net.sh | 21 +++++++++++++++++++++
  1 file changed, 21 insertions(+)
testcases/lib/test_net.sh +7 -0
index 418fed3..8517cb9 100644
@@ -314,3 +314,24 @@ 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()

testcases/lib/test_net.sh tst_netload() · line 332

Quoted 10 lines
testcases/lib/test_net.sh +10 -0
+{
+	# 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"}
+
+	echo $dst_addr | grep -q ":" && TST_IPV6=6

You shouldn't have this check here because TST_IPV6 should be set before test runs. Either test starts with '-6' parameter (that way it is automatically set in test_net.sh) or manually defined as TST_IPV6=6 in ipv6 specific test.

Quoted 3 lines

Note, tst_ipaddr function returns IPv4 or IPv6 address depending on TST_IPV6, so it is quite strange to check the returned address by this function and set TST_IPV6.

Quoted 8 lines

Hi Alexey:

icmp4-uni-basic01 use IP_VER to check ip version. So I did this check before ping. But as you said, I will remove the check and add TST_IPV6 in uni-basic tests.

BTW, Would you like to help apply the patches and check the ROD issue? I always got the following error when use ROD to run cmds.

ROD works fine for me. I would remove the old scripts first and cleanup the test.
It still includes the old scripts like check_env, check_cmds that I wouldn't use
anymore.

Thanks,
Alexey

#5 lore raw

PATCH v2 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 | 126 ++++++++++++++++++++++++++++
 2 files changed, 155 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 +126 -0

126 lines not on this page · raw message

Signature · 1 line
2.5.0
#6 lore raw

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

Quoted 20 lines · Hangbin Liu
---
  testcases/network/stress/ipsec/Makefile     |  29 +++++++
  testcases/network/stress/ipsec/ipsec_lib.sh | 126 ++++++++++++++++++++++++++++
  2 files changed, 155 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 +6 -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

testcases/network/stress/ipsec/Makefile line 16

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

Could be just "...program; If not, see <http://www.gnu.org/licenses/>."

Quoted 38 lines
testcases/network/stress/ipsec/Makefile new file +13 -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 +19 -0
new file mode 100644
index 0000000..94b7a43
@@ -0,0 +1,126 @@
+#!/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]>
+#

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

Quoted 10 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +10 -0
+#######################################################################
+
+. test_net.sh
+
+# c2x: convert charactor to hex
+c2x()
+{
+	for str in $@; do
+		for (( i=0; i<${#str}; i++ )); do
+			printf '%x' "'${str:$i:1}"

Again, C-style 'for' not supported by dash. Please change according to the previous comments.

Quoted 36 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +36 -0
+		done
+	done
+}
+
+# tst_ipsec flush: flush the ipsec state and policy
+# tst_ipsec target protocol mode first_spi src_addr dst_addr: config ipsec
+#
+# target: target of the configuration file ( src / dst )
+# protocol: ah / esp / ipcomp
+# mode: transport / tunnel
+# first_spi: the first spi value
+# src_addr: source IP address
+# dst_addr: destination IP address
+tst_ipsec()
+{
+	if [ "$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
+	if [ $# -ne 6 ]; then
+		tst_resm TINFO "tst_ipsec parameter mismatch"
+		return 1
+	fi
+
+	target=$1
+	protocol=$2
+	mode=$3
+	first_spi=$4
+	src_ipaddr=$5
+	dst_ipaddr=$6
+
+	# Encryption algorithm
+	EALGO="des3_ede"
+	EALGO_KEY="0x$(c2x _I_want_to_have_chicken_)"

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

Quoted 10 lines
testcases/network/stress/ipsec/ipsec_lib.sh new file +10 -0
+
+	# Authentication algorithm
+	AALGO="sha1"
+	AALGO_KEY="0x$(c2x beef_fish_pork_salad)"
+
+	# Compression algorithm
+	CALGO="deflate"
+	# Algorithm options for each protocol
+	case $protocol in
+		ah)

Please don't use indent for 'ah)' and in all other cases.

Thanks,
Alexey

#7 lore raw

PATCH v2 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        | 96 +++++++---------------
 1 file changed, 31 insertions(+), 65 deletions(-)
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +31 -65
index b78ac8f..93ddbbb 100644
@@ -50,10 +50,13 @@ $trace_logic
 TCID=${TCID:-icmp4-uni-basic01}
 TST_TOTAL=1
 TST_COUNT=1
+TST_CLEANUP="do_cleanup"
 export TCID
 export TST_COUNT
 export TST_TOTAL
 
+. 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"
 
@@ -100,16 +103,12 @@ 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
+    tst_ipsec flush
 
     # Clean up each interface
-    initialize_if lhost ${LINK_NUM}
-    initialize_if rhost ${LINK_NUM}
+    tst_init_iface lhost ${LINK_NUM}
+    tst_init_iface rhost ${LINK_NUM}
 }
 
 
@@ -127,10 +126,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 +145,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
@@ -181,14 +177,12 @@ case $IP_VER in
     # 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
+	tst_brkm TBROK "Failed to add any IP address at the local host"
     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
+	tst_brkm TBROK "Failed to add any IP address at the remote host"
     fi
 
     # IPv4 address of the local/remote host
@@ -210,14 +204,12 @@ case $IP_VER in
     # 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
+	tst_brkm TBROK "Failed to add any IP address at the local host"
     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
+	tst_brkm TBROK "Failed to add any IP address at the remote host"
     fi
 
     # IPv6 address of the local/remote host
@@ -232,58 +224,32 @@ esac
 
 # 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
+    tst_ipsec src $IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr
+    if [ $? -ne 0 ]; then
+	tst_brkm TBROK "Failed to configure SAD/SPD on the local host."
     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
+    tst_ipsec dst $IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr
+    if [ $? -ne 0 ]; then
+	tst_brkm TBROK "Failed to configure SAD/SPD on the remote host."
     fi
-    rm -f $ipsec_log
 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
#8 lore raw

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

Quoted 12 lines · Hangbin Liu

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

---
  .../stress/icmp/uni-basic/icmp4-uni-basic01        | 96 +++++++---------------
  1 file changed, 31 insertions(+), 65 deletions(-)
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +0 -0
index b78ac8f..93ddbbb 100644

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 $trace_logic · line 56

Quoted 7 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +1 -0
@@ -50,10 +50,13 @@ $trace_logic
  TCID=${TCID:-icmp4-uni-basic01}
  TST_TOTAL=1
  TST_COUNT=1
+TST_CLEANUP="do_cleanup"
  export TCID
  export TST_COUNT
  export TST_TOTAL

Please remove exports... they are useless here.

Quoted 13 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +2 -3
+. 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"
 
@@ -100,16 +103,12 @@ 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 111

Quoted 10 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +3 -4
      # 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
+    tst_ipsec flush
 
      # Clean up each interface
-    initialize_if lhost ${LINK_NUM}
-    initialize_if rhost ${LINK_NUM}
+    tst_init_iface lhost ${LINK_NUM}
+    tst_init_iface rhost ${LINK_NUM}

Again, we don't need it here.

Quoted 72 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +10 -17
  }
 
 
@@ -127,10 +126,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 +145,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
@@ -181,14 +177,12 @@ case $IP_VER in
      # 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
+	tst_brkm TBROK "Failed to add any IP address at the local host"
      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
+	tst_brkm TBROK "Failed to add any IP address at the remote host"
      fi
 
      # IPv4 address of the local/remote host
@@ -210,14 +204,12 @@ case $IP_VER in
      # 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
+	tst_brkm TBROK "Failed to add any IP address at the local host"
      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
+	tst_brkm TBROK "Failed to add any IP address at the remote host"
      fi
 
      # IPv6 address of the local/remote host

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 esac · line 224

Quoted 1 line
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +0 -0
@@ -232,58 +224,32 @@ esac
 

Please remove this part altogether. We only need configuration of ipsec in setup. Then do the test (ping).

Thanks,
Alexey

#9 lore raw

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

Quoted 14 lines · Alexey Kodanev
Quoted 14 lines

+. ipsec_lib.sh

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +1 -5
+
 # 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"
@@ -100,16 +103,12 @@ 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
Quoted 8 lines

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

Quoted 6 lines
testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +3 -2
+    tst_ipsec flush
     # Clean up each interface
-    initialize_if lhost ${LINK_NUM}
-    initialize_if rhost ${LINK_NUM}
+    tst_init_iface lhost ${LINK_NUM}
+    tst_init_iface rhost ${LINK_NUM}

Again, we don't need it here.

Hi Alexey,

Thanks for your patient review. I will correct all the other problems you mentioned. There only one thing. We will add the ip address before each test. e.g.

tst_add_ipaddr lhost $LINK_NUM
if [ $? -ne 0 ]; then
tst_brkm TBROK "Failed to add any IP address at the local host"
fi

If we do not remove the address after test. the next time we will get TBROK when add address since there already have one.

I saw you use lhost_addr=$(tst_ipaddr) directly after source test_net.sh in broken_ip4_lib.sh. But I didn't find when you init the iface addr. Could you tell me the secret?

Thanks
Hangbin

#10 lore raw

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

Hi,

Quoted 33 lines · Hangbin Liu
Quoted 13 lines · Alexey Kodanev
Quoted 13 lines

+. ipsec_lib.sh

testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 +1 -4
+
  # 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"
@@ -100,16 +103,12 @@ 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
Quoted 8 lines

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

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

Again, we don't need it here.

Hi Alexey,

Thanks for your patient review. I will correct all the other problems you mentioned. There only one thing. We will add the ip address before each test. e.g.

tst_add_ipaddr lhost $LINK_NUM
if [ $? -ne 0 ]; then
tst_brkm TBROK "Failed to add any IP address at the local host"
fi

Quoted 6 lines

If we do not remove the address after test. the next time we will get TBROK when add address since there already have one.

I saw you use lhost_addr=$(tst_ipaddr) directly after source test_net.sh in broken_ip4_lib.sh. But I didn't find when you init the iface addr. Could you tell me the secret?

It's simple, none of network tests (except somespecific stress/interfacegroup)
initialized IP addresses, all of them assumed that the test interfaces and management link are properly configured before start of the tests. So if the test don't need any additional IP address, we don't touch them.

May be we could add address verification code to initialization functions... a check that address is not assigned... but I'm not sure if it's useful.

Thanks,
Alexey