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

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

-- 
2.5.0


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

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

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

diff --git a/testcases/lib/test_net.sh b/testcases/lib/test_net.sh
index 418fed3..8517cb9 100644
--- a/testcases/lib/test_net.sh
+++ b/testcases/lib/test_net.sh
@@ -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
+}
-- 
2.5.0


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

* [LTP]  [PATCHv2 2/3] network/stress: add ipsec lib
  2016-03-15  9:50 [LTP] [PATCHv2 0/3] networking/stress: add ip xfrm ipsec support Hangbin Liu
  2016-03-15  9:50 ` [LTP] [PATCHv2 1/3] lib/test_net.sh: add tst_ping() to check icmp connectivity Hangbin Liu
@ 2016-03-15  9:50 ` Hangbin Liu
  2016-03-16  8:27   ` Alexey Kodanev
  2016-03-15  9:50 ` [LTP] [PATCHv2 3/3] network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing Hangbin Liu
  2 siblings, 1 reply; 11+ messages in thread
From: Hangbin Liu @ 2016-03-15  9:50 UTC (permalink / raw)
  To: ltp

Signed-off-by: Hangbin Liu <haliu@redhat.com>
---
 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

diff --git a/testcases/network/stress/ipsec/Makefile b/testcases/network/stress/ipsec/Makefile
new file mode 100644
index 0000000..0d7f1b6
--- /dev/null
+++ b/testcases/network/stress/ipsec/Makefile
@@ -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 <haliu@redhat.com>
+#
+#######################################################################
+
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= *.sh
+
+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..94b7a43
--- /dev/null
+++ b/testcases/network/stress/ipsec/ipsec_lib.sh
@@ -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 <haliu@redhat.com>
+#
+#######################################################################
+
+. 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}"
+		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_)"
+
+	# 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 ))"
+		ROD ip xfrm state add src $src dst $dst spi $spi_1 proto $proto \
+			$algo_line mode $mode sel src $src dst $dst
+		ROD ip xfrm policy add src $src dst $dst dir out tmpl src $src \
+			dst $dst proto $proto mode $mode
+
+		ROD ip xfrm state add src $dst dst $src spi $spi_2 proto $proto \
+			$algo_line mode $mode sel src $dst dst $src
+		ROD ip xfrm policy add src $dst dst $src dir in tmpl src $dst \
+			dst $src proto $proto mode $mode
+		ROD ip xfrm state
+		ROD 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 -s -c "ip xfrm state add src $src dst $dst spi $spi_1 \
+			proto $proto $algo_line mode $mode sel src $src dst $dst"
+		tst_rhost_run -s -c "ip xfrm policy add src $src dst $dst dir out \
+			tmpl src $src dst $dst proto $proto mode $mode"
+
+		tst_rhost_run -s -c "ip xfrm state add src $dst dst $src spi $spi_2 \
+			proto $proto $algo_line mode $mode sel src $dst dst $src"
+		tst_rhost_run -s -c "ip xfrm policy add src $dst dst $src dir in \
+			tmpl src $dst dst $src proto $proto mode $mode"
+		tst_rhost_run -s -c "ip xfrm state"
+		tst_rhost_run -s -c "ip xfrm policy"
+	fi
+}
-- 
2.5.0


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

* [LTP] [PATCHv2 3/3] network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing
  2016-03-15  9:50 [LTP] [PATCHv2 0/3] networking/stress: add ip xfrm ipsec support Hangbin Liu
  2016-03-15  9:50 ` [LTP] [PATCHv2 1/3] lib/test_net.sh: add tst_ping() to check icmp connectivity Hangbin Liu
  2016-03-15  9:50 ` [LTP] [PATCHv2 2/3] network/stress: add ipsec lib Hangbin Liu
@ 2016-03-15  9:50 ` Hangbin Liu
  2016-03-16  8:36   ` Alexey Kodanev
  2 siblings, 1 reply; 11+ messages in thread
From: Hangbin Liu @ 2016-03-15  9:50 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        | 96 +++++++---------------
 1 file changed, 31 insertions(+), 65 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..93ddbbb 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"
 
@@ -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
 
 #-----------------------------------------------------------------------
 #
-- 
2.5.0


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

* [LTP] [PATCHv2 1/3] lib/test_net.sh: add tst_ping() to check icmp connectivity
  2016-03-15  9:50 ` [LTP] [PATCHv2 1/3] lib/test_net.sh: add tst_ping() to check icmp connectivity Hangbin Liu
@ 2016-03-15 12:00   ` Alexey Kodanev
  2016-03-15 12:41     ` Hangbin Liu
  0 siblings, 1 reply; 11+ messages in thread
From: Alexey Kodanev @ 2016-03-15 12:00 UTC (permalink / raw)
  To: ltp

Hi,
On 03/15/2016 12:50 PM, Hangbin Liu wrote:
> Signed-off-by: Hangbin Liu <haliu@redhat.com>
> ---
>   testcases/lib/test_net.sh | 21 +++++++++++++++++++++
>   1 file changed, 21 insertions(+)
>
> diff --git a/testcases/lib/test_net.sh b/testcases/lib/test_net.sh
> index 418fed3..8517cb9 100644
> --- a/testcases/lib/test_net.sh
> +++ b/testcases/lib/test_net.sh
> @@ -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

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

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

* [LTP] [PATCHv2 1/3] lib/test_net.sh: add tst_ping() to check icmp connectivity
  2016-03-15 12:00   ` Alexey Kodanev
@ 2016-03-15 12:41     ` Hangbin Liu
  2016-03-16  8:16       ` Alexey Kodanev
  0 siblings, 1 reply; 11+ messages in thread
From: Hangbin Liu @ 2016-03-15 12:41 UTC (permalink / raw)
  To: ltp

On Tue, Mar 15, 2016 at 03:00:30PM +0300, Alexey Kodanev wrote:
> Hi,
> On 03/15/2016 12:50 PM, Hangbin Liu wrote:
> >Signed-off-by: Hangbin Liu <haliu@redhat.com>
> >---
> >  testcases/lib/test_net.sh | 21 +++++++++++++++++++++
> >  1 file changed, 21 insertions(+)
> >
> >diff --git a/testcases/lib/test_net.sh b/testcases/lib/test_net.sh
> >index 418fed3..8517cb9 100644
> >--- a/testcases/lib/test_net.sh
> >+++ b/testcases/lib/test_net.sh
> >@@ -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
> 
> 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.

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

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

* [LTP] [PATCHv2 1/3] lib/test_net.sh: add tst_ping() to check icmp connectivity
  2016-03-15 12:41     ` Hangbin Liu
@ 2016-03-16  8:16       ` Alexey Kodanev
  0 siblings, 0 replies; 11+ messages in thread
From: Alexey Kodanev @ 2016-03-16  8:16 UTC (permalink / raw)
  To: ltp

Hi,
On 03/15/2016 03:41 PM, Hangbin Liu wrote:
> On Tue, Mar 15, 2016 at 03:00:30PM +0300, Alexey Kodanev wrote:
>> Hi,
>> On 03/15/2016 12:50 PM, Hangbin Liu wrote:
>>> Signed-off-by: Hangbin Liu <haliu@redhat.com>
>>> ---
>>>   testcases/lib/test_net.sh | 21 +++++++++++++++++++++
>>>   1 file changed, 21 insertions(+)
>>>
>>> diff --git a/testcases/lib/test_net.sh b/testcases/lib/test_net.sh
>>> index 418fed3..8517cb9 100644
>>> --- a/testcases/lib/test_net.sh
>>> +++ b/testcases/lib/test_net.sh
>>> @@ -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
>> 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.
> 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


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

* [LTP] [PATCHv2 2/3] network/stress: add ipsec lib
  2016-03-15  9:50 ` [LTP] [PATCHv2 2/3] network/stress: add ipsec lib Hangbin Liu
@ 2016-03-16  8:27   ` Alexey Kodanev
  0 siblings, 0 replies; 11+ messages in thread
From: Alexey Kodanev @ 2016-03-16  8:27 UTC (permalink / raw)
  To: ltp


On 03/15/2016 12:50 PM, Hangbin Liu wrote:
> Signed-off-by: Hangbin Liu <haliu@redhat.com>
> ---
>   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
>
> diff --git a/testcases/network/stress/ipsec/Makefile b/testcases/network/stress/ipsec/Makefile
> new file mode 100644
> index 0000000..0d7f1b6
> --- /dev/null
> +++ b/testcases/network/stress/ipsec/Makefile
> @@ -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

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

> +#
> +# Author: Hangbin Liu <haliu@redhat.com>
> +#
> +#######################################################################
> +
> +
> +top_srcdir		?= ../../../..
> +
> +include $(top_srcdir)/include/mk/env_pre.mk
> +
> +INSTALL_TARGETS		:= *.sh
> +
> +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..94b7a43
> --- /dev/null
> +++ b/testcases/network/stress/ipsec/ipsec_lib.sh
> @@ -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 <haliu@redhat.com>
> +#
> +#######################################################################
> +
> +. 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.

> +		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_)"
> +
> +	# 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


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

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

On 03/15/2016 12:50 PM, 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        | 96 +++++++---------------
>   1 file changed, 31 insertions(+), 65 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..93ddbbb 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

Please remove exports... they are useless here.

>   
> +. 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}

Again, we don't need it here.

>   }
>   
>   
> @@ -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
>   

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


Thanks,
Alexey


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

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

On Wed, Mar 16, 2016 at 11:36:48AM +0300, Alexey Kodanev wrote:
> >+. 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}
> 
> 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

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

* [LTP] [PATCHv2 3/3] network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing
  2016-03-16 14:10     ` Hangbin Liu
@ 2016-03-17  8:43       ` Alexey Kodanev
  0 siblings, 0 replies; 11+ messages in thread
From: Alexey Kodanev @ 2016-03-17  8:43 UTC (permalink / raw)
  To: ltp

Hi,
On 03/16/2016 05:10 PM, Hangbin Liu wrote:
> On Wed, Mar 16, 2016 at 11:36:48AM +0300, Alexey Kodanev wrote:
>>> +. 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}
>> 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?

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


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

end of thread, other threads:[~2016-03-17  8:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-15  9:50 [LTP] [PATCHv2 0/3] networking/stress: add ip xfrm ipsec support Hangbin Liu
2016-03-15  9:50 ` [LTP] [PATCHv2 1/3] lib/test_net.sh: add tst_ping() to check icmp connectivity Hangbin Liu
2016-03-15 12:00   ` Alexey Kodanev
2016-03-15 12:41     ` Hangbin Liu
2016-03-16  8:16       ` Alexey Kodanev
2016-03-15  9:50 ` [LTP] [PATCHv2 2/3] network/stress: add ipsec lib Hangbin Liu
2016-03-16  8:27   ` Alexey Kodanev
2016-03-15  9:50 ` [LTP] [PATCHv2 3/3] network/stress/icmp: use ip xfrm for icmp4-uni-basic01 ipsec testing Hangbin Liu
2016-03-16  8:36   ` Alexey Kodanev
2016-03-16 14:10     ` Hangbin Liu
2016-03-17  8:43       ` Alexey Kodanev

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.