Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/net/ipsec Dedup some routines
details: https://anonhg.NetBSD.org/src/rev/0237a7956d81
branches: trunk
changeset: 353562:0237a7956d81
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Fri May 12 02:34:45 2017 +0000
description:
Dedup some routines
diffstat:
tests/net/ipsec/algorithms.sh | 16 +++++++++-
tests/net/ipsec/t_ipsec_gif.sh | 56 +++++++++++++---------------------
tests/net/ipsec/t_ipsec_l2tp.sh | 56 +++++++++++++---------------------
tests/net/ipsec/t_ipsec_transport.sh | 44 ++++++++-------------------
tests/net/ipsec/t_ipsec_tunnel.sh | 44 ++++++++-------------------
tests/net/ipsec/t_ipsec_tunnel_odd.sh | 44 ++++++++-------------------
6 files changed, 96 insertions(+), 164 deletions(-)
diffs (truncated from 592 to 300 lines):
diff -r 49ad4082ee84 -r 0237a7956d81 tests/net/ipsec/algorithms.sh
--- a/tests/net/ipsec/algorithms.sh Fri May 12 00:41:25 2017 +0000
+++ b/tests/net/ipsec/algorithms.sh Fri May 12 02:34:45 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: algorithms.sh,v 1.3 2017/04/27 08:06:59 ozaki-r Exp $
+# $NetBSD: algorithms.sh,v 1.4 2017/05/12 02:34:45 ozaki-r Exp $
#
# Copyright (c) 2017 Internet Initiative Japan Inc.
# All rights reserved.
@@ -160,3 +160,17 @@
echo $key
}
+
+generate_algo_args()
+{
+ local proto=$1
+ local algo=$2
+ local keylen=$(get_one_valid_keylen $algo)
+ local key=$(generate_key $keylen)
+
+ if [ $proto = esp ]; then
+ echo "-E $algo $key"
+ else
+ echo "-A $algo $key"
+ fi
+}
diff -r 49ad4082ee84 -r 0237a7956d81 tests/net/ipsec/t_ipsec_gif.sh
--- a/tests/net/ipsec/t_ipsec_gif.sh Fri May 12 00:41:25 2017 +0000
+++ b/tests/net/ipsec/t_ipsec_gif.sh Fri May 12 02:34:45 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_ipsec_gif.sh,v 1.4 2017/05/10 04:46:13 ozaki-r Exp $
+# $NetBSD: t_ipsec_gif.sh,v 1.5 2017/05/12 02:34:45 ozaki-r Exp $
#
# Copyright (c) 2017 Internet Initiative Japan Inc.
# All rights reserved.
@@ -74,17 +74,10 @@
local ip_remote=10.0.2.2
local subnet_local=10.0.1.0
local subnet_remote=10.0.2.0
- local keylen=$(get_one_valid_keylen $algo)
- local key=$(generate_key $keylen)
local tmpfile=./tmp
local outfile=./out
- local opt= str=
-
- if [ $proto = esp ]; then
- opt=-E
- else
- opt=-A
- fi
+ local str=
+ local algo_args="$(generate_algo_args $proto $algo)"
rump_server_crypto_start $SOCK_LOCAL
rump_server_crypto_start $SOCK_TUN_LOCAL netipsec gif
@@ -152,8 +145,8 @@
export RUMP_SERVER=$SOCK_TUN_LOCAL
# from https://www.netbsd.org/docs/network/ipsec/
cat > $tmpfile <<-EOF
- add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $opt $algo $key;
- add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $opt $algo $key;
+ add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $algo_args;
+ add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $algo_args;
spdadd $subnet_local/24 $subnet_remote/24 any -P out ipsec
$proto/tunnel/$ip_gwlo_tun-$ip_gwre_tun/require;
spdadd $subnet_remote/24 $subnet_local/24 any -P in ipsec
@@ -164,8 +157,8 @@
export RUMP_SERVER=$SOCK_TUN_REMOTE
cat > $tmpfile <<-EOF
- add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $opt $algo $key;
- add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $opt $algo $key;
+ add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $algo_args;
+ add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $algo_args;
spdadd $subnet_remote/24 $subnet_local/24 any -P out ipsec
$proto/tunnel/$ip_gwre_tun-$ip_gwlo_tun/require;
spdadd $subnet_local/24 $subnet_remote/24 any -P in ipsec
@@ -177,8 +170,8 @@
export RUMP_SERVER=$SOCK_TUN_LOCAL
# from https://www.netbsd.org/docs/network/ipsec/
cat > $tmpfile <<-EOF
- add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $opt $algo $key;
- add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $opt $algo $key;
+ add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $algo_args;
+ add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $algo_args;
spdadd $ip_gwlo_tun/32 $ip_gwre_tun/32 any -P out ipsec
$proto/transport//require;
spdadd $ip_gwre_tun/32 $ip_gwlo_tun/32 any -P in ipsec
@@ -189,8 +182,8 @@
export RUMP_SERVER=$SOCK_TUN_REMOTE
cat > $tmpfile <<-EOF
- add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $opt $algo $key;
- add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $opt $algo $key;
+ add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $algo_args;
+ add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $algo_args;
spdadd $ip_gwre_tun/32 $ip_gwlo_tun/32 any -P out ipsec
$proto/transport//require;
spdadd $ip_gwlo_tun/32 $ip_gwre_tun/32 any -P in ipsec
@@ -233,17 +226,10 @@
local ip_remote=fd00:2::2
local subnet_local=fd00:1::
local subnet_remote=fd00:2::
- local keylen=$(get_one_valid_keylen $algo)
- local key=$(generate_key $keylen)
local tmpfile=./tmp
local outfile=./out
- local opt= str=
-
- if [ $proto = esp ]; then
- opt=-E
- else
- opt=-A
- fi
+ local str=
+ local algo_args="$(generate_algo_args $proto $algo)"
rump_server_crypto_start $SOCK_LOCAL netinet6
rump_server_crypto_start $SOCK_TUN_LOCAL netipsec netinet6 gif
@@ -309,8 +295,8 @@
export RUMP_SERVER=$SOCK_TUN_LOCAL
# from https://www.netbsd.org/docs/network/ipsec/
cat > $tmpfile <<-EOF
- add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $opt $algo $key;
- add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $opt $algo $key;
+ add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $algo_args;
+ add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $algo_args;
spdadd $subnet_local/64 $subnet_remote/64 any -P out ipsec
$proto/tunnel/$ip_gwlo_tun-$ip_gwre_tun/require;
spdadd $subnet_remote/64 $subnet_local/64 any -P in ipsec
@@ -321,8 +307,8 @@
export RUMP_SERVER=$SOCK_TUN_REMOTE
cat > $tmpfile <<-EOF
- add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $opt $algo $key;
- add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $opt $algo $key;
+ add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $algo_args;
+ add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $algo_args;
spdadd $subnet_remote/64 $subnet_local/64 any -P out ipsec
$proto/tunnel/$ip_gwre_tun-$ip_gwlo_tun/require;
spdadd $subnet_local/64 $subnet_remote/64 any -P in ipsec
@@ -334,8 +320,8 @@
export RUMP_SERVER=$SOCK_TUN_LOCAL
# from https://www.netbsd.org/docs/network/ipsec/
cat > $tmpfile <<-EOF
- add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $opt $algo $key;
- add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $opt $algo $key;
+ add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $algo_args;
+ add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $algo_args;
spdadd $ip_gwlo_tun/128 $ip_gwre_tun/128 any -P out ipsec
$proto/transport//require;
spdadd $ip_gwre_tun/128 $ip_gwlo_tun/128 any -P in ipsec
@@ -346,8 +332,8 @@
export RUMP_SERVER=$SOCK_TUN_REMOTE
cat > $tmpfile <<-EOF
- add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $opt $algo $key;
- add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $opt $algo $key;
+ add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $algo_args;
+ add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $algo_args;
spdadd $ip_gwre_tun/128 $ip_gwlo_tun/128 any -P out ipsec
$proto/transport//require;
spdadd $ip_gwlo_tun/128 $ip_gwre_tun/128 any -P in ipsec
diff -r 49ad4082ee84 -r 0237a7956d81 tests/net/ipsec/t_ipsec_l2tp.sh
--- a/tests/net/ipsec/t_ipsec_l2tp.sh Fri May 12 00:41:25 2017 +0000
+++ b/tests/net/ipsec/t_ipsec_l2tp.sh Fri May 12 02:34:45 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_ipsec_l2tp.sh,v 1.4 2017/05/10 04:46:13 ozaki-r Exp $
+# $NetBSD: t_ipsec_l2tp.sh,v 1.5 2017/05/12 02:34:45 ozaki-r Exp $
#
# Copyright (c) 2017 Internet Initiative Japan Inc.
# All rights reserved.
@@ -73,17 +73,10 @@
local ip_remote=10.0.0.2
local subnet_local=20.0.0.0
local subnet_remote=20.0.0.0
- local keylen=$(get_one_valid_keylen $algo)
- local key=$(generate_key $keylen)
local tmpfile=./tmp
local outfile=./out
- local opt= str=
-
- if [ $proto = esp ]; then
- opt=-E
- else
- opt=-A
- fi
+ local str=
+ local algo_args="$(generate_algo_args $proto $algo)"
# See https://www.netbsd.org/docs/network/ipsec/#sample_vpn
rump_server_crypto_start $SOCK_LOCAL
@@ -148,8 +141,8 @@
export RUMP_SERVER=$SOCK_TUN_LOCAL
# from https://www.netbsd.org/docs/network/ipsec/
cat > $tmpfile <<-EOF
- add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $opt $algo $key;
- add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $opt $algo $key;
+ add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $algo_args;
+ add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $algo_args;
spdadd $subnet_local/24 $subnet_remote/24 any -P out ipsec
$proto/tunnel/$ip_gwlo_tun-$ip_gwre_tun/require;
spdadd $subnet_remote/24 $subnet_local/24 any -P in ipsec
@@ -160,8 +153,8 @@
export RUMP_SERVER=$SOCK_TUN_REMOTE
cat > $tmpfile <<-EOF
- add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $opt $algo $key;
- add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $opt $algo $key;
+ add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $algo_args;
+ add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $algo_args;
spdadd $subnet_remote/24 $subnet_local/24 any -P out ipsec
$proto/tunnel/$ip_gwre_tun-$ip_gwlo_tun/require;
spdadd $subnet_local/24 $subnet_remote/24 any -P in ipsec
@@ -173,8 +166,8 @@
export RUMP_SERVER=$SOCK_TUN_LOCAL
# from https://www.netbsd.org/docs/network/ipsec/
cat > $tmpfile <<-EOF
- add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $opt $algo $key;
- add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $opt $algo $key;
+ add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $algo_args;
+ add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $algo_args;
spdadd $ip_gwlo_tun/32 $ip_gwre_tun/32 any -P out ipsec
$proto/transport//require;
spdadd $ip_gwre_tun/32 $ip_gwlo_tun/32 any -P in ipsec
@@ -185,8 +178,8 @@
export RUMP_SERVER=$SOCK_TUN_REMOTE
cat > $tmpfile <<-EOF
- add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $opt $algo $key;
- add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $opt $algo $key;
+ add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $algo_args;
+ add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $algo_args;
spdadd $ip_gwre_tun/32 $ip_gwlo_tun/32 any -P out ipsec
$proto/transport//require;
spdadd $ip_gwlo_tun/32 $ip_gwre_tun/32 any -P in ipsec
@@ -223,17 +216,10 @@
local ip_remote=fd00::2
local subnet_local=fc00::
local subnet_remote=fc00::
- local keylen=$(get_one_valid_keylen $algo)
- local key=$(generate_key $keylen)
local tmpfile=./tmp
local outfile=./out
- local opt= str=
-
- if [ $proto = esp ]; then
- opt=-E
- else
- opt=-A
- fi
+ local str=
+ local algo_args="$(generate_algo_args $proto $algo)"
rump_server_crypto_start $SOCK_LOCAL netinet6
rump_server_crypto_start $SOCK_TUN_LOCAL netipsec netinet6 l2tp bridge
@@ -297,8 +283,8 @@
export RUMP_SERVER=$SOCK_TUN_LOCAL
# from https://www.netbsd.org/docs/network/ipsec/
cat > $tmpfile <<-EOF
- add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $opt $algo $key;
- add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $opt $algo $key;
+ add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $algo_args;
+ add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $algo_args;
spdadd $subnet_local/64 $subnet_remote/64 any -P out ipsec
$proto/tunnel/$ip_gwlo_tun-$ip_gwre_tun/require;
spdadd $subnet_remote/64 $subnet_local/64 any -P in ipsec
@@ -309,8 +295,8 @@
export RUMP_SERVER=$SOCK_TUN_REMOTE
cat > $tmpfile <<-EOF
- add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $opt $algo $key;
- add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $opt $algo $key;
+ add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $algo_args;
+ add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $algo_args;
spdadd $subnet_remote/64 $subnet_local/64 any -P out ipsec
$proto/tunnel/$ip_gwre_tun-$ip_gwlo_tun/require;
spdadd $subnet_local/64 $subnet_remote/64 any -P in ipsec
@@ -322,8 +308,8 @@
export RUMP_SERVER=$SOCK_TUN_LOCAL
# from https://www.netbsd.org/docs/network/ipsec/
cat > $tmpfile <<-EOF
- add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $opt $algo $key;
- add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $opt $algo $key;
+ add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $algo_args;
+ add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $algo_args;
spdadd $ip_gwlo_tun/128 $ip_gwre_tun/128 any -P out ipsec
$proto/transport//require;
spdadd $ip_gwre_tun/128 $ip_gwlo_tun/128 any -P in ipsec
@@ -334,8 +320,8 @@
export RUMP_SERVER=$SOCK_TUN_REMOTE
cat > $tmpfile <<-EOF
- add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $opt $algo $key;
- add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $opt $algo $key;
+ add $ip_gwlo_tun $ip_gwre_tun $proto 10000 $algo_args;
+ add $ip_gwre_tun $ip_gwlo_tun $proto 10001 $algo_args;
spdadd $ip_gwre_tun/128 $ip_gwlo_tun/128 any -P out ipsec
$proto/transport//require;
Home |
Main Index |
Thread Index |
Old Index