diff mbox series

[v3,2/2] net/ipsec: Add check for xfrm_user

Message ID 20181108142409.4955-2-pvorel@suse.cz
State Superseded
Delegated to: Petr Vorel
Headers show
Series [v3,1/2] net: Add tst_net_run helper | expand

Commit Message

Petr Vorel Nov. 8, 2018, 2:24 p.m. UTC
which is required by ip xfrm command.
As ipsec_lib.sh is used for other commands than it,
check it only when used. Call in cleanup function could trigger infinite
loop, therefore check only once.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/network/stress/ipsec/ipsec_lib.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Alexey Kodanev Nov. 12, 2018, 5:33 p.m. UTC | #1
On 08.11.2018 17:24, Petr Vorel wrote:
> which is required by ip xfrm command.
> As ipsec_lib.sh is used for other commands than it,
> check it only when used. Call in cleanup function could trigger infinite
> loop, therefore check only once.

What about adding cleanup_xfrm flag to cleanup() instead, something like this:

diff --git a/testcases/network/stress/ipsec/ipsec_lib.sh b/testcases/network/stress/ipsec/ipsec_lib.sh
index b099fde..28d457b 100644
--- a/testcases/network/stress/ipsec/ipsec_lib.sh
+++ b/testcases/network/stress/ipsec/ipsec_lib.sh
@@ -81,6 +81,11 @@ ipsec_lib_setup()
        cleanup_vti=
        ALG=
        ALGR=
+
+       if [ -n "$IPSEC_MODE" ]; then
+               tst_net_run "tst_test_drivers xfrm_user"
+               cleanup_xfrm=1
+       fi
 }
 
 TST_OPTS="l:m:p:s:S:k:A:e:a:c:r:"
@@ -110,6 +115,8 @@ tst_ipsec_setup()
 # tst_ipsec_cleanup: flush ipsec state and policy rules
 tst_ipsec_cleanup()
 {
+       [ -z "$cleanup_xfrm" ] && return
+
        ip xfrm state flush
        ip xfrm policy flush
        tst_rhost_run -c "ip xfrm state flush && ip xfrm policy flush"



> 
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  testcases/network/stress/ipsec/ipsec_lib.sh | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/testcases/network/stress/ipsec/ipsec_lib.sh b/testcases/network/stress/ipsec/ipsec_lib.sh
> index b099fdeaf..a9ac5bc50 100644
> --- a/testcases/network/stress/ipsec/ipsec_lib.sh
> +++ b/testcases/network/stress/ipsec/ipsec_lib.sh
> @@ -89,6 +89,14 @@ TST_SETUP=${TST_SETUP:-ipsec_lib_setup}
>  TST_USAGE=ipsec_lib_usage
>  . tst_net.sh
>  
> +tst_ipsec_check_driver()
> +{
> +	if [ -z "$ipsec_driver_checked" ]; then
> +		export ipsec_driver_checked=1
> +		tst_net_run "tst_test_drivers xfrm_user"
> +	fi
> +}
> +
>  get_key()
>  {
>  	local bits=$1
> @@ -110,6 +118,7 @@ tst_ipsec_setup()
>  # tst_ipsec_cleanup: flush ipsec state and policy rules
>  tst_ipsec_cleanup()
>  {
> +	tst_ipsec_check_driver
>  	ip xfrm state flush
>  	ip xfrm policy flush
>  	tst_rhost_run -c "ip xfrm state flush && ip xfrm policy flush"
> @@ -175,6 +184,7 @@ tst_ipsec()
>  	local p="proto $IPSEC_PROTO"
>  	[ "$IPSEC_PROTO" = "esp_aead" ] && p="proto esp"
>  
> +	tst_ipsec_check_driver
>  	ipsec_set_algoline
>  
>  	if [ $target = lhost ]; then
> @@ -234,6 +244,7 @@ tst_ipsec_vti()
>  		tst_brk TCONF "iproute doesn't support 'vti'"
>  
>  	ipsec_set_algoline
> +	tst_ipsec_check_driver
>  
>  	local o_dir="src $src dst $dst"
>  	local i_dir="src $dst dst $src"
>
diff mbox series

Patch

diff --git a/testcases/network/stress/ipsec/ipsec_lib.sh b/testcases/network/stress/ipsec/ipsec_lib.sh
index b099fdeaf..a9ac5bc50 100644
--- a/testcases/network/stress/ipsec/ipsec_lib.sh
+++ b/testcases/network/stress/ipsec/ipsec_lib.sh
@@ -89,6 +89,14 @@  TST_SETUP=${TST_SETUP:-ipsec_lib_setup}
 TST_USAGE=ipsec_lib_usage
 . tst_net.sh
 
+tst_ipsec_check_driver()
+{
+	if [ -z "$ipsec_driver_checked" ]; then
+		export ipsec_driver_checked=1
+		tst_net_run "tst_test_drivers xfrm_user"
+	fi
+}
+
 get_key()
 {
 	local bits=$1
@@ -110,6 +118,7 @@  tst_ipsec_setup()
 # tst_ipsec_cleanup: flush ipsec state and policy rules
 tst_ipsec_cleanup()
 {
+	tst_ipsec_check_driver
 	ip xfrm state flush
 	ip xfrm policy flush
 	tst_rhost_run -c "ip xfrm state flush && ip xfrm policy flush"
@@ -175,6 +184,7 @@  tst_ipsec()
 	local p="proto $IPSEC_PROTO"
 	[ "$IPSEC_PROTO" = "esp_aead" ] && p="proto esp"
 
+	tst_ipsec_check_driver
 	ipsec_set_algoline
 
 	if [ $target = lhost ]; then
@@ -234,6 +244,7 @@  tst_ipsec_vti()
 		tst_brk TCONF "iproute doesn't support 'vti'"
 
 	ipsec_set_algoline
+	tst_ipsec_check_driver
 
 	local o_dir="src $src dst $dst"
 	local i_dir="src $dst dst $src"