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/0862bb5b2a79
branches: trunk
changeset: 353518:0862bb5b2a79
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Wed May 10 08:59:40 2017 +0000
description:
Dedup some routines
diffstat:
tests/net/ipsec/t_ipsec_tunnel.sh | 68 +++++++++++++++++++-------------------
1 files changed, 34 insertions(+), 34 deletions(-)
diffs (110 lines):
diff -r 8ea54da0c743 -r 0862bb5b2a79 tests/net/ipsec/t_ipsec_tunnel.sh
--- a/tests/net/ipsec/t_ipsec_tunnel.sh Wed May 10 08:48:46 2017 +0000
+++ b/tests/net/ipsec/t_ipsec_tunnel.sh Wed May 10 08:59:40 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_ipsec_tunnel.sh,v 1.5 2017/05/10 04:46:13 ozaki-r Exp $
+# $NetBSD: t_ipsec_tunnel.sh,v 1.6 2017/05/10 08:59:40 ozaki-r Exp $
#
# Copyright (c) 2017 Internet Initiative Japan Inc.
# All rights reserved.
@@ -35,6 +35,33 @@
DEBUG=${DEBUG:-false}
+setup_servers()
+{
+
+ # See https://www.netbsd.org/docs/network/ipsec/#sample_vpn
+ rump_server_crypto_start $SOCK_LOCAL netinet6
+ rump_server_crypto_start $SOCK_TUNNEL_LOCAL netipsec netinet6
+ rump_server_crypto_start $SOCK_TUNNEL_REMOTE netipsec netinet6
+ rump_server_crypto_start $SOCK_REMOTE netinet6
+ rump_server_add_iface $SOCK_LOCAL shmif0 $BUS_LOCAL
+ rump_server_add_iface $SOCK_TUNNEL_LOCAL shmif0 $BUS_LOCAL
+ rump_server_add_iface $SOCK_TUNNEL_LOCAL shmif1 $BUS_TUNNEL
+ rump_server_add_iface $SOCK_TUNNEL_REMOTE shmif0 $BUS_REMOTE
+ rump_server_add_iface $SOCK_TUNNEL_REMOTE shmif1 $BUS_TUNNEL
+ rump_server_add_iface $SOCK_REMOTE shmif0 $BUS_REMOTE
+}
+
+check_tunnel_packets()
+{
+ local outfile=$1
+ local src=$2
+ local dst=$3
+ local proto=$4
+
+ atf_check -s exit:0 -o match:"$src > $dst: $proto" cat $outfile
+ atf_check -s exit:0 -o match:"$dst > $src: $proto" cat $outfile
+}
+
test_ipsec4_tunnel()
{
local proto=$1
@@ -61,17 +88,7 @@
proto_cap=AH
fi
- # See https://www.netbsd.org/docs/network/ipsec/#sample_vpn
- rump_server_crypto_start $SOCK_LOCAL
- rump_server_crypto_start $SOCK_TUNNEL_LOCAL netipsec
- rump_server_crypto_start $SOCK_TUNNEL_REMOTE netipsec
- rump_server_crypto_start $SOCK_REMOTE
- rump_server_add_iface $SOCK_LOCAL shmif0 $BUS_LOCAL
- rump_server_add_iface $SOCK_TUNNEL_LOCAL shmif0 $BUS_LOCAL
- rump_server_add_iface $SOCK_TUNNEL_LOCAL shmif1 $BUS_TUNNEL
- rump_server_add_iface $SOCK_TUNNEL_REMOTE shmif0 $BUS_REMOTE
- rump_server_add_iface $SOCK_TUNNEL_REMOTE shmif1 $BUS_TUNNEL
- rump_server_add_iface $SOCK_REMOTE shmif0 $BUS_REMOTE
+ setup_servers
export RUMP_SERVER=$SOCK_LOCAL
atf_check -s exit:0 rump.ifconfig shmif0 $ip_local/24
@@ -145,12 +162,8 @@
atf_check -s exit:0 -o ignore rump.ping -c 1 -n -w 3 $ip_remote
extract_new_packets $BUS_TUNNEL > $outfile
- atf_check -s exit:0 \
- -o match:"$ip_gw_local_tunnel > $ip_gw_remote_tunnel: $proto_cap" \
- cat $outfile
- atf_check -s exit:0 \
- -o match:"$ip_gw_remote_tunnel > $ip_gw_local_tunnel: $proto_cap" \
- cat $outfile
+ check_tunnel_packets $outfile $ip_gw_local_tunnel $ip_gw_remote_tunnel \
+ $proto_cap
test_flush_entries $SOCK_TUNNEL_LOCAL
test_flush_entries $SOCK_TUNNEL_REMOTE
@@ -182,16 +195,7 @@
proto_cap=AH
fi
- rump_server_crypto_start $SOCK_LOCAL netinet6
- rump_server_crypto_start $SOCK_TUNNEL_LOCAL netipsec netinet6
- rump_server_crypto_start $SOCK_TUNNEL_REMOTE netipsec netinet6
- rump_server_crypto_start $SOCK_REMOTE netinet6
- rump_server_add_iface $SOCK_LOCAL shmif0 $BUS_LOCAL
- rump_server_add_iface $SOCK_TUNNEL_LOCAL shmif0 $BUS_LOCAL
- rump_server_add_iface $SOCK_TUNNEL_LOCAL shmif1 $BUS_TUNNEL
- rump_server_add_iface $SOCK_TUNNEL_REMOTE shmif0 $BUS_REMOTE
- rump_server_add_iface $SOCK_TUNNEL_REMOTE shmif1 $BUS_TUNNEL
- rump_server_add_iface $SOCK_REMOTE shmif0 $BUS_REMOTE
+ setup_servers
export RUMP_SERVER=$SOCK_LOCAL
atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip_local/64
@@ -265,12 +269,8 @@
atf_check -s exit:0 -o ignore rump.ping6 -c 1 -n -X 3 $ip_remote
extract_new_packets $BUS_TUNNEL > $outfile
- atf_check -s exit:0 \
- -o match:"$ip_gw_local_tunnel > $ip_gw_remote_tunnel: $proto_cap" \
- cat $outfile
- atf_check -s exit:0 \
- -o match:"$ip_gw_remote_tunnel > $ip_gw_local_tunnel: $proto_cap" \
- cat $outfile
+ check_tunnel_packets $outfile $ip_gw_local_tunnel $ip_gw_remote_tunnel \
+ $proto_cap
test_flush_entries $SOCK_TUNNEL_LOCAL
test_flush_entries $SOCK_TUNNEL_REMOTE
Home |
Main Index |
Thread Index |
Old Index