All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP]  [PATCH 0/3] networking/stress: add ip xfrm ipsec support
@ 2016-03-07  7:14 Hangbin Liu
  2016-03-07  7:14 ` [LTP] [PATCH 1/3] lib/test_net.sh: add tst_ping() to check icmp connectivity Hangbin Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Hangbin Liu @ 2016-03-07  7:14 UTC (permalink / raw)
  To: ltp

Hi Alexey and Cyril,

Sorry for the late patches. I was bussy with other stuff durning previous
months. Here I only add an ipsec lib and add ip xfrm support for
icmp4-uni-basic01. I will fix other tests when you feel these patches are
OK.

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.

For c2x function in ipsec_lib.sh. It's only a convert function and do not
print any info. So I kept it with the old style.

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

Here is the test result:
# ./networkstress.sh -i
<<<test_start>>>
tag=icmp4-uni-basic01 stime=1457331713
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 )
icmp4-uni-basic01 1 TINFO : initialize 'lhost' 'eth1' interface
icmp4-uni-basic01 1 TINFO : initialize 'rhost' 'eth1' interface
icmp4-uni-basic01 1 TPASS : There has IPv4 connectivity with msg_size 10
icmp4-uni-basic01 2 TPASS : There has IPv4 connectivity with msg_size 100
icmp4-uni-basic01 3 TPASS : There has IPv4 connectivity with msg_size 1000
icmp4-uni-basic01 4 TPASS : There has IPv4 connectivity with msg_size 10000
icmp4-uni-basic01 5 TPASS : There has IPv4 connectivity with msg_size 65507
icmp4-uni-basic01 6 TPASS : Test is finished successfully.
icmp4-uni-basic01 7 TINFO : initialize 'lhost' 'eth1' interface
icmp4-uni-basic01 7 TINFO : initialize 'rhost' 'eth1' interface
<<<execution_status>>>
initiation_status="ok"
duration=49 termination_type=exited termination_id=0 corefile=no
cutime=48 cstime=10
<<<test_end>>>
<<<test_start>>>
tag=icmp4-uni-basic02 stime=1457331762
cmdline="icmp4-uni-basic02"
contacts=""
analysis=exit
<<<test_output>>>
incrementing stop
icmp4-uni-basic02 1 TINFO : Verify that the kernel is not crashed with receiving and sending various size of ICMP message with the following conditions
icmp4-uni-basic02 1 TINFO : - Test duration is 3600 [sec]
icmp4-uni-basic02 1 TINFO : - Version of IP is IPv4
icmp4-uni-basic02 1 TINFO : - Size of packets are ( 10 100 1000 10000 65507 )
icmp4-uni-basic02 1 TINFO : - IPsec [ AH / transport ]
icmp4-uni-basic02 1 TINFO : initialize 'lhost' 'eth1' interface
icmp4-uni-basic02 1 TINFO : initialize 'rhost' 'eth1' interface
src 10.0.0.1 dst 10.0.0.2
        proto ah spi 0x00001001 reqid 0 mode transport
        replay-window 0
        auth hmac(sha1) 0x626565665f666973685f706f726b5f73616c6164
        sel src 10.0.0.1/32 dst 10.0.0.2/32
src 10.0.0.2 dst 10.0.0.1
        proto ah spi 0x00001000 reqid 0 mode transport
        replay-window 0
        auth hmac(sha1) 0x626565665f666973685f706f726b5f73616c6164
        sel src 10.0.0.2/32 dst 10.0.0.1/32
src 10.0.0.1/32 dst 10.0.0.2/32
        dir in priority 0 ptype main
        tmpl src 10.0.0.1 dst 10.0.0.2
                proto ah reqid 0 mode transport
src 10.0.0.2/32 dst 10.0.0.1/32
        dir out priority 0 ptype main
        tmpl src 10.0.0.2 dst 10.0.0.1
                proto ah reqid 0 mode transport
src 10.0.0.2 dst 10.0.0.1
        proto ah spi 0x00001000 reqid 0 mode transport
        replay-window 0
        auth-trunc hmac(sha1) 0x626565665f666973685f706f726b5f73616c6164 96
        sel src 10.0.0.2/32 dst 10.0.0.1/32
src 10.0.0.1 dst 10.0.0.2
        proto ah spi 0x00001001 reqid 0 mode transport
        replay-window 0
        auth-trunc hmac(sha1) 0x626565665f666973685f706f726b5f73616c6164 96
        sel src 10.0.0.1/32 dst 10.0.0.2/32
src 10.0.0.2/32 dst 10.0.0.1/32
        dir in priority 0 ptype main
        tmpl src 10.0.0.2 dst 10.0.0.1
                proto ah reqid 0 mode transport
src 10.0.0.1/32 dst 10.0.0.2/32
        dir out priority 0 ptype main
        tmpl src 10.0.0.1 dst 10.0.0.2
                proto ah reqid 0 mode transport
icmp4-uni-basic02 1 TPASS : There has IPv4 connectivity with msg_size 10
icmp4-uni-basic02 2 TPASS : There has IPv4 connectivity with msg_size 100
icmp4-uni-basic02 3 TPASS : There has IPv4 connectivity with msg_size 1000
icmp4-uni-basic02 4 TPASS : There has IPv4 connectivity with msg_size 10000
icmp4-uni-basic02 5 TBROK : There is no IPv4 connectivity with msg_size 65507

       ^^ here is a TBROK in icmp4-uni-basic02, I will fix it in next patch

icmp4-uni-basic02 5 TINFO : initialize 'lhost' 'eth1' interface
icmp4-uni-basic02 5 TINFO : initialize 'rhost' 'eth1' interface
icmp4-uni-basic02 5 TINFO : initialize 'lhost' 'eth1' interface
icmp4-uni-basic02 5 TINFO : initialize 'rhost' 'eth1' interface
<<<execution_status>>>
initiation_status="ok"
duration=62 termination_type=exited termination_id=2 corefile=no
cutime=78 cstime=17
<<<test_end>>>
ltp-pan reported FAIL


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                          |  37 ++++++
 .../stress/icmp/uni-basic/icmp4-uni-basic01        |  66 ++++------
 testcases/network/stress/ipsec/Makefile            |  31 +++++
 testcases/network/stress/ipsec/ipsec_lib.sh        | 134 +++++++++++++++++++++
 4 files changed, 224 insertions(+), 44 deletions(-)
 create mode 100644 testcases/network/stress/ipsec/Makefile
 create mode 100644 testcases/network/stress/ipsec/ipsec_lib.sh

-- 
2.5.0


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [LTP] [PATCH 1/3] lib/test_net.sh: add tst_ping() to check icmp connectivity
  2016-03-07  7:14 [LTP] [PATCH 0/3] networking/stress: add ip xfrm ipsec support Hangbin Liu
@ 2016-03-07  7:14 ` Hangbin Liu
  2016-03-07  7:14 ` [LTP] [PATCH 2/3] network/stress: add ipsec lib Hangbin Liu
  2016-03-07  7:14 ` [LTP] [PATCH 3/3] network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing Hangbin Liu
  2 siblings, 0 replies; 17+ messages in thread
From: Hangbin Liu @ 2016-03-07  7:14 UTC (permalink / raw)
  To: ltp

Signed-off-by: Hangbin Liu <haliu@redhat.com>
---
 testcases/lib/test_net.sh | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/testcases/lib/test_net.sh b/testcases/lib/test_net.sh
index 418fed3..f75e78e 100644
--- a/testcases/lib/test_net.sh
+++ b/testcases/lib/test_net.sh
@@ -314,3 +314,40 @@ 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"}
+
+	# Check the arguments
+	if [ $# -lt 2 ]; then
+		tst_resm TBROK "tst_ping src_iface dest_ipv4/6_addr [msg_size]"
+		return 1
+	fi
+
+	local src_iface=$1
+	local dst_addr=$2
+	# ping cmd use 56 as default message size
+	local msg_size=${3:-"56"}
+
+	if echo $dst_addr | grep ":"; then
+		local PING="ping6"
+		TST_IPV6=6
+	else
+		local PING="ping"
+	fi
+
+	if [ "$dst_addr" == "$(tst_ipaddr)" ]; then
+		tst_rhost_run -c "$PING -I $src_iface -c $PING_MAX $dst_addr \
+			-s $msg_size > /dev/null 2>&1"
+	else
+		$PING -I $src_iface -c $PING_MAX $dst_addr -s $msg_size > \
+			/dev/null 2>&1
+	fi
+}
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [LTP]  [PATCH 2/3] network/stress: add ipsec lib
  2016-03-07  7:14 [LTP] [PATCH 0/3] networking/stress: add ip xfrm ipsec support Hangbin Liu
  2016-03-07  7:14 ` [LTP] [PATCH 1/3] lib/test_net.sh: add tst_ping() to check icmp connectivity Hangbin Liu
@ 2016-03-07  7:14 ` Hangbin Liu
  2016-03-09 12:42   ` Alexey Kodanev
  2016-03-07  7:14 ` [LTP] [PATCH 3/3] network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing Hangbin Liu
  2 siblings, 1 reply; 17+ messages in thread
From: Hangbin Liu @ 2016-03-07  7:14 UTC (permalink / raw)
  To: ltp

Signed-off-by: Hangbin Liu <haliu@redhat.com>
---
 testcases/network/stress/ipsec/Makefile     |  31 +++++++
 testcases/network/stress/ipsec/ipsec_lib.sh | 134 ++++++++++++++++++++++++++++
 2 files changed, 165 insertions(+)
 create mode 100644 testcases/network/stress/ipsec/Makefile
 create mode 100644 testcases/network/stress/ipsec/ipsec_lib.sh

diff --git a/testcases/network/stress/ipsec/Makefile b/testcases/network/stress/ipsec/Makefile
new file mode 100644
index 0000000..b3a1657
--- /dev/null
+++ b/testcases/network/stress/ipsec/Makefile
@@ -0,0 +1,31 @@
+#!/bin/sh
+# Copyright (c) 2016 Red Hat Inc.,  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+# Author: Hangbin Liu <haliu@redhat.com>
+#
+#######################################################################
+
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= *.sh
+
+MAKE_TARGETS		:=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/stress/ipsec/ipsec_lib.sh b/testcases/network/stress/ipsec/ipsec_lib.sh
new file mode 100644
index 0000000..feeecf9
--- /dev/null
+++ b/testcases/network/stress/ipsec/ipsec_lib.sh
@@ -0,0 +1,134 @@
+#!/bin/sh
+# Copyright (c) 2016 Red Hat Inc.,  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+# Author: Hangbin Liu <haliu@redhat.com>
+#
+#######################################################################
+
+#Uncomment line below for debug output.
+#trace_logic=${trace_logic:-"set -x"}
+$trace_logic
+
+# Make sure the value of LTPROOT
+LTPROOT=${LTPROOT:-`(cd ../../../../ ; pwd)`}
+export LTPROOT
+
+. test_net.sh
+
+# c2x: convert charactor to hex
+c2x()
+{
+	for str in $@; do
+		for (( i=0; i<${#str}; i++ )); do
+			c=${str:$i:1}
+			printf '%x' "'$c"
+		done
+	done
+}
+
+# tst_ipsec flush: flush the ipsec state and policy
+# tst_ipsec target protocol mode first_spi src_addr dst_addr: config ipsec
+#
+# target: target of the configuration file ( src / dst )
+# protocol: ah / esp / ipcomp
+# mode: transport / tunnel
+# first_spi: the first spi value
+# src_addr: source IP address
+# dst_addr: destination IP address
+tst_ipsec()
+{
+	if [ x$1 = x"flush" ]; then
+		ip xfrm state flush && ip xfrm policy flush
+		tst_rhost_run -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_)"
+
+	# 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)
+			algo_line="auth $AALGO $AALGO_KEY"
+			proto="ah"
+			;;
+		esp)
+			algo_line="enc $EALGO $EALGO_KEY auth $AALGO $AALGO_KEY"
+			proto="esp"
+			;;
+		ipcomp)
+			algo_line="comp $CALGO"
+			proto="comp"
+			;;
+		*)
+			tst_resm TINFO "tst_ipsec protocol mismatch"
+			return 1
+			;;
+	esac
+
+	if [ $target = src ]; then
+		src=$src_ipaddr
+		dst=$dst_ipaddr
+		spi_1="0x$first_spi"
+		spi_2="0x$(( $first_spi + 1 ))"
+		ip xfrm state add src $src dst $dst spi $spi_1 proto $proto \
+			$algo_line mode $mode sel src $src dst $dst
+		ip xfrm policy add src $src dst $dst dir out tmpl src $src \
+			dst $dst proto $proto mode $mode
+
+		ip xfrm state add src $dst dst $src spi $spi_2 proto $proto \
+			$algo_line mode $mode sel src $dst dst $src
+		ip xfrm policy add src $dst dst $src dir in tmpl src $dst \
+			dst $src proto $proto mode $mode
+		ip xfrm state
+		ip xfrm policy
+	elif [ $target = dst ]; then
+		src=$dst_ipaddr
+		dst=$src_ipaddr
+		spi_1="0x$(( $first_spi + 1 ))"
+		spi_2="0x$first_spi"
+		tst_rhost_run -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 -c "ip xfrm policy add src $src dst $dst dir out \
+			tmpl src $src dst $dst proto $proto mode $mode"
+
+		tst_rhost_run -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 -c "ip xfrm policy add src $dst dst $src dir in \
+			tmpl src $dst dst $src proto $proto mode $mode"
+		tst_rhost_run -c "ip xfrm state"
+		tst_rhost_run -c "ip xfrm policy"
+	fi
+}
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [LTP] [PATCH 3/3] network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing
  2016-03-07  7:14 [LTP] [PATCH 0/3] networking/stress: add ip xfrm ipsec support Hangbin Liu
  2016-03-07  7:14 ` [LTP] [PATCH 1/3] lib/test_net.sh: add tst_ping() to check icmp connectivity Hangbin Liu
  2016-03-07  7:14 ` [LTP] [PATCH 2/3] network/stress: add ipsec lib Hangbin Liu
@ 2016-03-07  7:14 ` Hangbin Liu
  2016-03-09 12:53   ` Alexey Kodanev
  2 siblings, 1 reply; 17+ messages in thread
From: Hangbin Liu @ 2016-03-07  7:14 UTC (permalink / raw)
  To: ltp

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

Signed-off-by: Hangbin Liu <haliu@redhat.com>
---
 .../stress/icmp/uni-basic/icmp4-uni-basic01        | 66 ++++++++--------------
 1 file changed, 22 insertions(+), 44 deletions(-)

diff --git a/testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 b/testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01
index b78ac8f..55ddff5 100644
--- a/testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01
+++ b/testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01
@@ -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"
 
@@ -104,12 +107,11 @@ do_cleanup()
     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,7 +129,7 @@ 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
@@ -147,13 +149,13 @@ 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
 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
@@ -232,58 +234,34 @@ 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_ipsec src $IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr
+    if [ $? -ne 0 ]; 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_ipsec dst $IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr
+    if [ $? -ne 0 ]; then
 	tst_resm TBROK "Failed to configure SAD/SPD on the remote host."
-	rm -f $ipsec_log
 	exit 1
     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 $rhost_ifname $lhost_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
 
 #-----------------------------------------------------------------------
 #
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [LTP] [PATCH 2/3] network/stress: add ipsec lib
  2016-03-07  7:14 ` [LTP] [PATCH 2/3] network/stress: add ipsec lib Hangbin Liu
@ 2016-03-09 12:42   ` Alexey Kodanev
  2016-03-10  6:43     ` Hangbin Liu
  2016-03-11  5:34     ` Hangbin Liu
  0 siblings, 2 replies; 17+ messages in thread
From: Alexey Kodanev @ 2016-03-09 12:42 UTC (permalink / raw)
  To: ltp


On 03/07/2016 10:14 AM, Hangbin Liu wrote:
> Signed-off-by: Hangbin Liu <haliu@redhat.com>
> ---
>   testcases/network/stress/ipsec/Makefile     |  31 +++++++
>   testcases/network/stress/ipsec/ipsec_lib.sh | 134 ++++++++++++++++++++++++++++
>   2 files changed, 165 insertions(+)
>   create mode 100644 testcases/network/stress/ipsec/Makefile
>   create mode 100644 testcases/network/stress/ipsec/ipsec_lib.sh
>
> diff --git a/testcases/network/stress/ipsec/Makefile b/testcases/network/stress/ipsec/Makefile
> new file mode 100644
> index 0000000..b3a1657
> --- /dev/null
> +++ b/testcases/network/stress/ipsec/Makefile
> @@ -0,0 +1,31 @@
> +#!/bin/sh
> +# Copyright (c) 2016 Red Hat Inc.,  All Rights Reserved.
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License as
> +# published by the Free Software Foundation; either version 2 of
> +# the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it would be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write the Free Software Foundation,
> +# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#
> +# Author: Hangbin Liu <haliu@redhat.com>
> +#
> +#######################################################################
> +
> +
> +top_srcdir		?= ../../../..
> +
> +include $(top_srcdir)/include/mk/env_pre.mk
> +
> +INSTALL_TARGETS		:= *.sh
> +
> +MAKE_TARGETS		:=

It can be removed.

> +
> +include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/network/stress/ipsec/ipsec_lib.sh b/testcases/network/stress/ipsec/ipsec_lib.sh
> new file mode 100644
> index 0000000..feeecf9
> --- /dev/null
> +++ b/testcases/network/stress/ipsec/ipsec_lib.sh
> @@ -0,0 +1,134 @@
> +#!/bin/sh
> +# Copyright (c) 2016 Red Hat Inc.,  All Rights Reserved.
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License as
> +# published by the Free Software Foundation; either version 2 of
> +# the License, or (at your option) any later version.
> +#
> +# This program is distributed in the hope that it would be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write the Free Software Foundation,
> +# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#
> +# Author: Hangbin Liu <haliu@redhat.com>
> +#
> +#######################################################################
> +
> +#Uncomment line below for debug output.
> +#trace_logic=${trace_logic:-"set -x"}
> +$trace_logic
> +

Not used anymore, can be removed.

> +# Make sure the value of LTPROOT
> +LTPROOT=${LTPROOT:-`(cd ../../../../ ; pwd)`}
> +export LTPROOT

It's not needed, test.sh (which included by test_net.sh) has all checksfor
LTPROOT

> +. test_net.sh
> +
> +# c2x: convert charactor to hex
> +c2x()
> +{
> +	for str in $@; do
> +		for (( i=0; i<${#str}; i++ )); do

Not portable "for (());", could be changed to "for i in $(seq 0 
${#str}); do.

> +			c=${str:$i:1}
> +			printf '%x' "'$c"

c var is redundant, we can substitute "$c" with "${str:$i:1}"

> +		done
> +	done
> +}
> +
> +# tst_ipsec flush: flush the ipsec state and policy
> +# tst_ipsec target protocol mode first_spi src_addr dst_addr: config ipsec
> +#
> +# target: target of the configuration file ( src / dst )
> +# protocol: ah / esp / ipcomp
> +# mode: transport / tunnel
> +# first_spi: the first spi value
> +# src_addr: source IP address
> +# dst_addr: destination IP address
> +tst_ipsec()
> +{
> +	if [ x$1 = x"flush" ]; then

if [ "$1" = "flush"]; then

> +		ip xfrm state flush && ip xfrm policy flush
> +		tst_rhost_run -c "ip xfrm state flush && ip xfrm policy flush"
> +		return 0


I would run each ip commands with ROD "ip ..." and tst_rhost_run with -s 
option.
In that way, if command fails, test will exit with TBROK.

Thanks,
Alexey

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [LTP] [PATCH 3/3] network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing
  2016-03-07  7:14 ` [LTP] [PATCH 3/3] network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing Hangbin Liu
@ 2016-03-09 12:53   ` Alexey Kodanev
  2016-03-10  6:50     ` Hangbin Liu
  0 siblings, 1 reply; 17+ messages in thread
From: Alexey Kodanev @ 2016-03-09 12:53 UTC (permalink / raw)
  To: ltp


On 03/07/2016 10:14 AM, Hangbin Liu wrote:
> Also check each msg_size in $ICMP_SIZE_ARRAY to make sure the connectvity.
>
> Signed-off-by: Hangbin Liu <haliu@redhat.com>
> ---
>   .../stress/icmp/uni-basic/icmp4-uni-basic01        | 66 ++++++++--------------
>   1 file changed, 22 insertions(+), 44 deletions(-)
>
> diff --git a/testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 b/testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01
> index b78ac8f..55ddff5 100644
> --- a/testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01
> +++ b/testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01
> @@ -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"
>   
> @@ -104,12 +107,11 @@ do_cleanup()
>       killall_icmp_traffic

should we remove it, is it ping 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}

Can we remove them instead? Most tests expect that they are already 
initialized.


>   }
>   
>   
> @@ -127,7 +129,7 @@ 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
> @@ -147,13 +149,13 @@ 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
>   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
> @@ -232,58 +234,34 @@ 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_ipsec src $IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr
> +    if [ $? -ne 0 ]; then
>   	tst_resm TBROK "Failed to configure SAD/SPD on the local host."
> -	rm -f $ipsec_log
>   	exit 1

tst_brkm TBROK does what tst_resm & exit do. Additionally, it returns
a correct exit number.

>       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_ipsec dst $IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr
> +    if [ $? -ne 0 ]; then
>   	tst_resm TBROK "Failed to configure SAD/SPD on the remote host."
> -	rm -f $ipsec_log
>   	exit 1
>       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 $rhost_ifname $lhost_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
>   
>   #-----------------------------------------------------------------------
>   #


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [LTP] [PATCH 2/3] network/stress: add ipsec lib
  2016-03-09 12:42   ` Alexey Kodanev
@ 2016-03-10  6:43     ` Hangbin Liu
  2016-03-11  5:34     ` Hangbin Liu
  1 sibling, 0 replies; 17+ messages in thread
From: Hangbin Liu @ 2016-03-10  6:43 UTC (permalink / raw)
  To: ltp

Hi Alexey,

Thanks for all the comments. I will fix these issues.

Regards
Hangbin
On Wed, Mar 09, 2016 at 03:42:06PM +0300, Alexey Kodanev wrote:
> 
> On 03/07/2016 10:14 AM, Hangbin Liu wrote:
> >Signed-off-by: Hangbin Liu <haliu@redhat.com>
> >---
> >  testcases/network/stress/ipsec/Makefile     |  31 +++++++
> >  testcases/network/stress/ipsec/ipsec_lib.sh | 134 ++++++++++++++++++++++++++++
> >  2 files changed, 165 insertions(+)
> >  create mode 100644 testcases/network/stress/ipsec/Makefile
> >  create mode 100644 testcases/network/stress/ipsec/ipsec_lib.sh
> >
> >diff --git a/testcases/network/stress/ipsec/Makefile b/testcases/network/stress/ipsec/Makefile
> >new file mode 100644
> >index 0000000..b3a1657
> >--- /dev/null
> >+++ b/testcases/network/stress/ipsec/Makefile
> >@@ -0,0 +1,31 @@
> >+#!/bin/sh
> >+# Copyright (c) 2016 Red Hat Inc.,  All Rights Reserved.
> >+#
> >+# This program is free software; you can redistribute it and/or
> >+# modify it under the terms of the GNU General Public License as
> >+# published by the Free Software Foundation; either version 2 of
> >+# the License, or (at your option) any later version.
> >+#
> >+# This program is distributed in the hope that it would be useful,
> >+# but WITHOUT ANY WARRANTY; without even the implied warranty of
> >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> >+# GNU General Public License for more details.
> >+#
> >+# You should have received a copy of the GNU General Public License
> >+# along with this program; if not, write the Free Software Foundation,
> >+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> >+#
> >+# Author: Hangbin Liu <haliu@redhat.com>
> >+#
> >+#######################################################################
> >+
> >+
> >+top_srcdir		?= ../../../..
> >+
> >+include $(top_srcdir)/include/mk/env_pre.mk
> >+
> >+INSTALL_TARGETS		:= *.sh
> >+
> >+MAKE_TARGETS		:=
> 
> It can be removed.
> 
> >+
> >+include $(top_srcdir)/include/mk/generic_leaf_target.mk
> >diff --git a/testcases/network/stress/ipsec/ipsec_lib.sh b/testcases/network/stress/ipsec/ipsec_lib.sh
> >new file mode 100644
> >index 0000000..feeecf9
> >--- /dev/null
> >+++ b/testcases/network/stress/ipsec/ipsec_lib.sh
> >@@ -0,0 +1,134 @@
> >+#!/bin/sh
> >+# Copyright (c) 2016 Red Hat Inc.,  All Rights Reserved.
> >+#
> >+# This program is free software; you can redistribute it and/or
> >+# modify it under the terms of the GNU General Public License as
> >+# published by the Free Software Foundation; either version 2 of
> >+# the License, or (at your option) any later version.
> >+#
> >+# This program is distributed in the hope that it would be useful,
> >+# but WITHOUT ANY WARRANTY; without even the implied warranty of
> >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> >+# GNU General Public License for more details.
> >+#
> >+# You should have received a copy of the GNU General Public License
> >+# along with this program; if not, write the Free Software Foundation,
> >+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> >+#
> >+# Author: Hangbin Liu <haliu@redhat.com>
> >+#
> >+#######################################################################
> >+
> >+#Uncomment line below for debug output.
> >+#trace_logic=${trace_logic:-"set -x"}
> >+$trace_logic
> >+
> 
> Not used anymore, can be removed.
> 
> >+# Make sure the value of LTPROOT
> >+LTPROOT=${LTPROOT:-`(cd ../../../../ ; pwd)`}
> >+export LTPROOT
> 
> It's not needed, test.sh (which included by test_net.sh) has all checksfor
> LTPROOT
> 
> >+. test_net.sh
> >+
> >+# c2x: convert charactor to hex
> >+c2x()
> >+{
> >+	for str in $@; do
> >+		for (( i=0; i<${#str}; i++ )); do
> 
> Not portable "for (());", could be changed to "for i in $(seq 0 ${#str});
> do.
> 
> >+			c=${str:$i:1}
> >+			printf '%x' "'$c"
> 
> c var is redundant, we can substitute "$c" with "${str:$i:1}"
> 
> >+		done
> >+	done
> >+}
> >+
> >+# tst_ipsec flush: flush the ipsec state and policy
> >+# tst_ipsec target protocol mode first_spi src_addr dst_addr: config ipsec
> >+#
> >+# target: target of the configuration file ( src / dst )
> >+# protocol: ah / esp / ipcomp
> >+# mode: transport / tunnel
> >+# first_spi: the first spi value
> >+# src_addr: source IP address
> >+# dst_addr: destination IP address
> >+tst_ipsec()
> >+{
> >+	if [ x$1 = x"flush" ]; then
> 
> if [ "$1" = "flush"]; then
> 
> >+		ip xfrm state flush && ip xfrm policy flush
> >+		tst_rhost_run -c "ip xfrm state flush && ip xfrm policy flush"
> >+		return 0
> 
> 
> I would run each ip commands with ROD "ip ..." and tst_rhost_run with -s
> option.
> In that way, if command fails, test will exit with TBROK.
> 
> Thanks,
> Alexey
> 
> -- 
> Mailing list info: http://lists.linux.it/listinfo/ltp

-- 

Thanks & Best Regards
Hangbin Liu <haliu@redhat.com>
Leo on #kernel-qe, #kernel, #eng-china

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [LTP] [PATCH 3/3] network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing
  2016-03-09 12:53   ` Alexey Kodanev
@ 2016-03-10  6:50     ` Hangbin Liu
  2016-03-10  7:32       ` Alexey Kodanev
  0 siblings, 1 reply; 17+ messages in thread
From: Hangbin Liu @ 2016-03-10  6:50 UTC (permalink / raw)
  To: ltp

Hi Alexey,

On Wed, Mar 09, 2016 at 03:53:50PM +0300, Alexey Kodanev wrote:
> 
> On 03/07/2016 10:14 AM, Hangbin Liu wrote:
> >Also check each msg_size in $ICMP_SIZE_ARRAY to make sure the connectvity.
> >
> >Signed-off-by: Hangbin Liu <haliu@redhat.com>
> >---
> >  .../stress/icmp/uni-basic/icmp4-uni-basic01        | 66 ++++++++--------------
> >  1 file changed, 22 insertions(+), 44 deletions(-)
> >
> >diff --git a/testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01 b/testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01
> >index b78ac8f..55ddff5 100644
> >--- a/testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01
> >+++ b/testcases/network/stress/icmp/uni-basic/icmp4-uni-basic01
> >@@ -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"
> >@@ -104,12 +107,11 @@ do_cleanup()
> >      killall_icmp_traffic
> 
> should we remove it, is it ping traffic?

OK, we can remove it.
> 
> >      # 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}
> 
> Can we remove them instead? Most tests expect that they are already
> initialized.

I think we'd better not remove them. uni-basic is still OK. But multi-diffip
tests will add multi ip addresses. We need clean the env after each test.

> 
> 
> >  }
> >@@ -127,7 +129,7 @@ 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
> >@@ -147,13 +149,13 @@ 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
> >  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
> >@@ -232,58 +234,34 @@ 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_ipsec src $IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr
> >+    if [ $? -ne 0 ]; then
> >  	tst_resm TBROK "Failed to configure SAD/SPD on the local host."
> >-	rm -f $ipsec_log
> >  	exit 1
> 
> tst_brkm TBROK does what tst_resm & exit do. Additionally, it returns
> a correct exit number.

Thanks for this tips. will change to tst_brkm.

Best Regards
Hangbin Liu

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [LTP] [PATCH 3/3] network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing
  2016-03-10  6:50     ` Hangbin Liu
@ 2016-03-10  7:32       ` Alexey Kodanev
  2016-03-11  3:08         ` Hangbin Liu
  0 siblings, 1 reply; 17+ messages in thread
From: Alexey Kodanev @ 2016-03-10  7:32 UTC (permalink / raw)
  To: ltp

On 03/10/2016 09:50 AM, Hangbin Liu wrote:
>>>       # 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}
>> Can we remove them instead? Most tests expect that they are already
>> initialized.
> I think we'd better not remove them. uni-basic is still OK. But multi-diffip
> tests will add multi ip addresses. We need clean the env after each test.

OK, let's keep it only in tests which add/remove IP addresses.

By the way, if you are going to fix such tests please use IP range
that is defined with the following env vars:

export IPV4_NET16_UNUSED=${IPV4_NET16_UNUSED:-"10.23"}
export IPV6_NET32_UNUSED=${IPV6_NET32_UNUSED:-"fd00:23"}

it's from testscripts/network.sh.


Thanks,
Alexey


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [LTP] [PATCH 3/3] network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing
  2016-03-10  7:32       ` Alexey Kodanev
@ 2016-03-11  3:08         ` Hangbin Liu
  2016-03-11 11:41           ` Alexey Kodanev
  0 siblings, 1 reply; 17+ messages in thread
From: Hangbin Liu @ 2016-03-11  3:08 UTC (permalink / raw)
  To: ltp

On Thu, Mar 10, 2016 at 10:32:06AM +0300, Alexey Kodanev wrote:
> On 03/10/2016 09:50 AM, Hangbin Liu wrote:
> >>>      # 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}
> >>Can we remove them instead? Most tests expect that they are already
> >>initialized.
> >I think we'd better not remove them. uni-basic is still OK. But multi-diffip
> >tests will add multi ip addresses. We need clean the env after each test.
> 
> OK, let's keep it only in tests which add/remove IP addresses.

OK

> 
> By the way, if you are going to fix such tests please use IP range
> that is defined with the following env vars:
> 
> export IPV4_NET16_UNUSED=${IPV4_NET16_UNUSED:-"10.23"}
> export IPV6_NET32_UNUSED=${IPV6_NET32_UNUSED:-"fd00:23"}
> 
> it's from testscripts/network.sh.

Thanks for this tip. multi-diffip and multi-diffnic use multi different subnets.
So I think we still need keep using the previous method.

while [ $ipaddr_pair_num -lt $IP_TOTAL_FOR_TCPIP ]; do
    # Add new IP addresses
    x=`expr $ipaddr_pair_num \/ 255 % 255`
    y=`expr $ipaddr_pair_num % 255`
    if [ $x -ge 255 ]; then
        tst_info TINFO "This script cannot add more than $ipaddr_pair_num addresses"
        break
    fi

    case $IP_VER in
        4)
        network_part="10.${x}.${y}"
        network_broadcast=${network_part}.255


while [ $link_num -lt $link_total ]; do
    # name of interface of the local/remote host
    lhost_ifname=`get_ifname lhost $link_num`
    rhost_ifname=`get_ifname rhost $link_num`

    # Set the IP address to each interface
    case $IP_VER in
        4)
        network_part="10.0.${link_num}"
        network_mask=24
        lhost_host_part="2"     # local host
        rhost_host_part="1"     # remote host

Thanks
Hangbin

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [LTP] [PATCH 2/3] network/stress: add ipsec lib
  2016-03-09 12:42   ` Alexey Kodanev
  2016-03-10  6:43     ` Hangbin Liu
@ 2016-03-11  5:34     ` Hangbin Liu
  2016-03-11 11:20       ` Alexey Kodanev
  1 sibling, 1 reply; 17+ messages in thread
From: Hangbin Liu @ 2016-03-11  5:34 UTC (permalink / raw)
  To: ltp

On Wed, Mar 09, 2016 at 03:42:06PM +0300, Alexey Kodanev wrote:
> >+# c2x: convert charactor to hex
> >+c2x()
> >+{
> >+	for str in $@; do
> >+		for (( i=0; i<${#str}; i++ )); do
> 
> Not portable "for (());", could be changed to "for i in $(seq 0 ${#str});
> do.

Hi Alexey,

Since we need to use the number from 0 to str_len - 1. I think it's also
not portable if we use like "for i in $(seq 0 $((${#str} - 1))); do". So I
will keep the format. Please tell me if you have any other suggestion.

Thanks
Hangbin

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [LTP] [PATCH 2/3] network/stress: add ipsec lib
  2016-03-11  5:34     ` Hangbin Liu
@ 2016-03-11 11:20       ` Alexey Kodanev
  2016-03-11 14:10         ` Hangbin Liu
  0 siblings, 1 reply; 17+ messages in thread
From: Alexey Kodanev @ 2016-03-11 11:20 UTC (permalink / raw)
  To: ltp

Hi,
On 03/11/2016 08:34 AM, Hangbin Liu wrote:
> On Wed, Mar 09, 2016 at 03:42:06PM +0300, Alexey Kodanev wrote:
>>> +# c2x: convert charactor to hex
>>> +c2x()
>>> +{
>>> +	for str in $@; do
>>> +		for (( i=0; i<${#str}; i++ )); do
>> Not portable "for (());", could be changed to "for i in $(seq 0 ${#str});
>> do.
> Hi Alexey,
>
> Since we need to use the number from 0 to str_len - 1. I think it's also
> not portable if we use like "for i in $(seq 0 $((${#str} - 1))); do". So I
> will keep the format. Please tell me if you have any other suggestion.

No, double parentheses for arithmetic is fine, at least bash, dash and
ash support it.

Also, we could use hexdump, xxd, etc...

c2x()
{
     printf "$@" | hexdump  -e '/1 "%x"'
}

if $@ contains strings separated by spaces, we could add

"tr -d' '" to it.

Best regards,
Alexey

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [LTP] [PATCH 3/3] network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing
  2016-03-11  3:08         ` Hangbin Liu
@ 2016-03-11 11:41           ` Alexey Kodanev
  2016-03-11 14:33             ` Hangbin Liu
  0 siblings, 1 reply; 17+ messages in thread
From: Alexey Kodanev @ 2016-03-11 11:41 UTC (permalink / raw)
  To: ltp

On 03/11/2016 06:08 AM, Hangbin Liu wrote:
> On Thu, Mar 10, 2016 at 10:32:06AM +0300, Alexey Kodanev wrote:
>> On 03/10/2016 09:50 AM, Hangbin Liu wrote:
>>>>>       # 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}
>>>> Can we remove them instead? Most tests expect that they are already
>>>> initialized.
>>> I think we'd better not remove them. uni-basic is still OK. But multi-diffip
>>> tests will add multi ip addresses. We need clean the env after each test.
>> OK, let's keep it only in tests which add/remove IP addresses.
> OK
>
>> By the way, if you are going to fix such tests please use IP range
>> that is defined with the following env vars:
>>
>> export IPV4_NET16_UNUSED=${IPV4_NET16_UNUSED:-"10.23"}
>> export IPV6_NET32_UNUSED=${IPV6_NET32_UNUSED:-"fd00:23"}
>>
>> it's from testscripts/network.sh.
> Thanks for this tip. multi-diffip and multi-diffnic use multi different subnets.
> So I think we still need keep using the previous method.
>
> while [ $ipaddr_pair_num -lt $IP_TOTAL_FOR_TCPIP ]; do
>      # Add new IP addresses
>      x=`expr $ipaddr_pair_num \/ 255 % 255`
>      y=`expr $ipaddr_pair_num % 255`
>      if [ $x -ge 255 ]; then
>          tst_info TINFO "This script cannot add more than $ipaddr_pair_num addresses"
>          break
>      fi
>
>      case $IP_VER in
>          4)
>          network_part="10.${x}.${y}"
>          network_broadcast=${network_part}.255

Please look at the stress/interface/if-addr-addlarge

while [ $cnt -le $IP_TOTAL ]; do
     if [ "$TST_IPV6" ]; then
         local hex_x=$(printf '%x' $x)
         local hex_y=$(printf '%x' $y)
         local new_ip=${IPV6_NET32_UNUSED}:1:1:1:$hex_x:$hex_y:1
     else
         local new_ip=${IPV4_NET16_UNUSED}.$x.$y
     fi
...

I think 254 * 254 (for IPv4) is more than enough for such tests.

Best regards,
Alexey

>
> while [ $link_num -lt $link_total ]; do
>      # name of interface of the local/remote host
>      lhost_ifname=`get_ifname lhost $link_num`
>      rhost_ifname=`get_ifname rhost $link_num`
>
>      # Set the IP address to each interface
>      case $IP_VER in
>          4)
>          network_part="10.0.${link_num}"
>          network_mask=24
>          lhost_host_part="2"     # local host
>          rhost_host_part="1"     # remote host
>
> Thanks
> Hangbin


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [LTP] [PATCH 2/3] network/stress: add ipsec lib
  2016-03-11 11:20       ` Alexey Kodanev
@ 2016-03-11 14:10         ` Hangbin Liu
  0 siblings, 0 replies; 17+ messages in thread
From: Hangbin Liu @ 2016-03-11 14:10 UTC (permalink / raw)
  To: ltp

On Fri, Mar 11, 2016 at 02:20:32PM +0300, Alexey Kodanev wrote:
> Hi,
> On 03/11/2016 08:34 AM, Hangbin Liu wrote:
> >On Wed, Mar 09, 2016 at 03:42:06PM +0300, Alexey Kodanev wrote:
> >>>+# c2x: convert charactor to hex
> >>>+c2x()
> >>>+{
> >>>+	for str in $@; do
> >>>+		for (( i=0; i<${#str}; i++ )); do
> >>Not portable "for (());", could be changed to "for i in $(seq 0 ${#str});
> >>do.
> >Hi Alexey,
> >
> >Since we need to use the number from 0 to str_len - 1. I think it's also
> >not portable if we use like "for i in $(seq 0 $((${#str} - 1))); do". So I
> >will keep the format. Please tell me if you have any other suggestion.
> 
> No, double parentheses for arithmetic is fine, at least bash, dash and
> ash support it.
> 
> Also, we could use hexdump, xxd, etc...
> 
> c2x()
> {
>     printf "$@" | hexdump  -e '/1 "%x"'
> }

Thanks for this tip. I tested but there seems some different with the old one.
I will look into it.

BTW. I tried to use ROD to run cmds like ROD ip xfrm state flush. But it failed
with error like

/opt/ltp/testcases/bin/test.sh: line 232: flag: unbound variable

Do you know why?

Thanks
Hangbin

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [LTP] [PATCH 3/3] network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing
  2016-03-11 11:41           ` Alexey Kodanev
@ 2016-03-11 14:33             ` Hangbin Liu
  2016-03-14  7:33               ` Alexey Kodanev
  0 siblings, 1 reply; 17+ messages in thread
From: Hangbin Liu @ 2016-03-11 14:33 UTC (permalink / raw)
  To: ltp

On Fri, Mar 11, 2016 at 02:41:04PM +0300, Alexey Kodanev wrote:
> On 03/11/2016 06:08 AM, Hangbin Liu wrote:
> >On Thu, Mar 10, 2016 at 10:32:06AM +0300, Alexey Kodanev wrote:
> >>On 03/10/2016 09:50 AM, Hangbin Liu wrote:
> >>>>>      # 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}
> >>>>Can we remove them instead? Most tests expect that they are already
> >>>>initialized.
> >>>I think we'd better not remove them. uni-basic is still OK. But multi-diffip
> >>>tests will add multi ip addresses. We need clean the env after each test.
> >>OK, let's keep it only in tests which add/remove IP addresses.
> >OK
> >
> >>By the way, if you are going to fix such tests please use IP range
> >>that is defined with the following env vars:
> >>
> >>export IPV4_NET16_UNUSED=${IPV4_NET16_UNUSED:-"10.23"}
> >>export IPV6_NET32_UNUSED=${IPV6_NET32_UNUSED:-"fd00:23"}
> >>
> >>it's from testscripts/network.sh.
> >Thanks for this tip. multi-diffip and multi-diffnic use multi different subnets.
> >So I think we still need keep using the previous method.
> >
> >while [ $ipaddr_pair_num -lt $IP_TOTAL_FOR_TCPIP ]; do
> >     # Add new IP addresses
> >     x=`expr $ipaddr_pair_num \/ 255 % 255`
> >     y=`expr $ipaddr_pair_num % 255`
> >     if [ $x -ge 255 ]; then
> >         tst_info TINFO "This script cannot add more than $ipaddr_pair_num addresses"
> >         break
> >     fi
> >
> >     case $IP_VER in
> >         4)
> >         network_part="10.${x}.${y}"
> >         network_broadcast=${network_part}.255
> 
> Please look at the stress/interface/if-addr-addlarge
> 
> while [ $cnt -le $IP_TOTAL ]; do
>     if [ "$TST_IPV6" ]; then
>         local hex_x=$(printf '%x' $x)
>         local hex_y=$(printf '%x' $y)
>         local new_ip=${IPV6_NET32_UNUSED}:1:1:1:$hex_x:$hex_y:1
>     else
>         local new_ip=${IPV4_NET16_UNUSED}.$x.$y
>     fi
> ...
> 
> I think 254 * 254 (for IPv4) is more than enough for such tests.
> 

Hmm, looks multi-diffnic could use this method since it only has ${link_num}
subnets, but multi-diffip test use two dimension subnets. which looks like
client: 10.${x}.${y}.1 , server: 10.${x}.${y}.2 . So I think we could not use
like local new_ip=${IPV4_NET16_UNUSED}.$x.$y

Thanks
Hangbin
> 
> >
> >while [ $link_num -lt $link_total ]; do
> >     # name of interface of the local/remote host
> >     lhost_ifname=`get_ifname lhost $link_num`
> >     rhost_ifname=`get_ifname rhost $link_num`
> >
> >     # Set the IP address to each interface
> >     case $IP_VER in
> >         4)
> >         network_part="10.0.${link_num}"
> >         network_mask=24
> >         lhost_host_part="2"     # local host
> >         rhost_host_part="1"     # remote host

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [LTP] [PATCH 3/3] network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing
  2016-03-11 14:33             ` Hangbin Liu
@ 2016-03-14  7:33               ` Alexey Kodanev
  2016-03-15  9:41                 ` Hangbin Liu
  0 siblings, 1 reply; 17+ messages in thread
From: Alexey Kodanev @ 2016-03-14  7:33 UTC (permalink / raw)
  To: ltp

Hi,
On 03/11/2016 05:33 PM, Hangbin Liu wrote:
>>>> By the way, if you are going to fix such tests please use IP range
>>>> that is defined with the following env vars:
>>>>
>>>> export IPV4_NET16_UNUSED=${IPV4_NET16_UNUSED:-"10.23"}
>>>> export IPV6_NET32_UNUSED=${IPV6_NET32_UNUSED:-"fd00:23"}
>>>>
>>>> it's from testscripts/network.sh.
>>> Thanks for this tip. multi-diffip and multi-diffnic use multi different subnets.
>>> So I think we still need keep using the previous method.
>>>
>>> while [ $ipaddr_pair_num -lt $IP_TOTAL_FOR_TCPIP ]; do
>>>      # Add new IP addresses
>>>      x=`expr $ipaddr_pair_num \/ 255 % 255`
>>>      y=`expr $ipaddr_pair_num % 255`
>>>      if [ $x -ge 255 ]; then
>>>          tst_info TINFO "This script cannot add more than $ipaddr_pair_num addresses"
>>>          break
>>>      fi
>>>
>>>      case $IP_VER in
>>>          4)
>>>          network_part="10.${x}.${y}"
>>>          network_broadcast=${network_part}.255
>> Please look at the stress/interface/if-addr-addlarge
>>
>> while [ $cnt -le $IP_TOTAL ]; do
>>      if [ "$TST_IPV6" ]; then
>>          local hex_x=$(printf '%x' $x)
>>          local hex_y=$(printf '%x' $y)
>>          local new_ip=${IPV6_NET32_UNUSED}:1:1:1:$hex_x:$hex_y:1
>>      else
>>          local new_ip=${IPV4_NET16_UNUSED}.$x.$y
>>      fi
>> ...
>>
>> I think 254 * 254 (for IPv4) is more than enough for such tests.
>>
> Hmm, looks multi-diffnic could use this method since it only has ${link_num}
> subnets, but multi-diffip test use two dimension subnets. which looks like
> client: 10.${x}.${y}.1 , server: 10.${x}.${y}.2 . So I think we could not use
> like local new_ip=${IPV4_NET16_UNUSED}.$x.$y

We can create 16K subnets with $IPV4_NET16_UNUSED.$x.$y/30 that each can 
have
two hosts. Is it not enough for the test? I see diffip01 test set only
100 IP pairs (subnets) for default.

Best regards,
Alexey


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [LTP] [PATCH 3/3] network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing
  2016-03-14  7:33               ` Alexey Kodanev
@ 2016-03-15  9:41                 ` Hangbin Liu
  0 siblings, 0 replies; 17+ messages in thread
From: Hangbin Liu @ 2016-03-15  9:41 UTC (permalink / raw)
  To: ltp

On Mon, Mar 14, 2016 at 10:33:45AM +0300, Alexey Kodanev wrote:
> >Hmm, looks multi-diffnic could use this method since it only has ${link_num}
> >subnets, but multi-diffip test use two dimension subnets. which looks like
> >client: 10.${x}.${y}.1 , server: 10.${x}.${y}.2 . So I think we could not use
> >like local new_ip=${IPV4_NET16_UNUSED}.$x.$y
> 
> We can create 16K subnets with $IPV4_NET16_UNUSED.$x.$y/30 that each can
> have
> two hosts. Is it not enough for the test? I see diffip01 test set only
> 100 IP pairs (subnets) for default.

Hi Alexey,

Yes, this way is good. I will do as you said when update multi-ip/nic test
cases.

Thanks
Hangbin

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2016-03-15  9:41 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-07  7:14 [LTP] [PATCH 0/3] networking/stress: add ip xfrm ipsec support Hangbin Liu
2016-03-07  7:14 ` [LTP] [PATCH 1/3] lib/test_net.sh: add tst_ping() to check icmp connectivity Hangbin Liu
2016-03-07  7:14 ` [LTP] [PATCH 2/3] network/stress: add ipsec lib Hangbin Liu
2016-03-09 12:42   ` Alexey Kodanev
2016-03-10  6:43     ` Hangbin Liu
2016-03-11  5:34     ` Hangbin Liu
2016-03-11 11:20       ` Alexey Kodanev
2016-03-11 14:10         ` Hangbin Liu
2016-03-07  7:14 ` [LTP] [PATCH 3/3] network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing Hangbin Liu
2016-03-09 12:53   ` Alexey Kodanev
2016-03-10  6:50     ` Hangbin Liu
2016-03-10  7:32       ` Alexey Kodanev
2016-03-11  3:08         ` Hangbin Liu
2016-03-11 11:41           ` Alexey Kodanev
2016-03-11 14:33             ` Hangbin Liu
2016-03-14  7:33               ` Alexey Kodanev
2016-03-15  9:41                 ` Hangbin Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.