Home | History | Annotate | Line # | Download | only in ipsec
t_ipsec_tunnel_odd.sh revision 1.2
      1  1.2  ozaki #	$NetBSD: t_ipsec_tunnel_odd.sh,v 1.2 2017/05/12 02:34:45 ozaki-r Exp $
      2  1.1  ozaki #
      3  1.1  ozaki # Copyright (c) 2017 Internet Initiative Japan Inc.
      4  1.1  ozaki # All rights reserved.
      5  1.1  ozaki #
      6  1.1  ozaki # Redistribution and use in source and binary forms, with or without
      7  1.1  ozaki # modification, are permitted provided that the following conditions
      8  1.1  ozaki # are met:
      9  1.1  ozaki # 1. Redistributions of source code must retain the above copyright
     10  1.1  ozaki #    notice, this list of conditions and the following disclaimer.
     11  1.1  ozaki # 2. Redistributions in binary form must reproduce the above copyright
     12  1.1  ozaki #    notice, this list of conditions and the following disclaimer in the
     13  1.1  ozaki #    documentation and/or other materials provided with the distribution.
     14  1.1  ozaki #
     15  1.1  ozaki # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     16  1.1  ozaki # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     17  1.1  ozaki # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     18  1.1  ozaki # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     19  1.1  ozaki # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     20  1.1  ozaki # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     21  1.1  ozaki # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     22  1.1  ozaki # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     23  1.1  ozaki # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     24  1.1  ozaki # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     25  1.1  ozaki # POSSIBILITY OF SUCH DAMAGE.
     26  1.1  ozaki #
     27  1.1  ozaki 
     28  1.1  ozaki SOCK_LOCAL=unix://ipsec_local
     29  1.1  ozaki SOCK_TUNNEL_LOCAL=unix://ipsec_tunel_local
     30  1.1  ozaki SOCK_TUNNEL_REMOTE=unix://ipsec_tunnel_remote
     31  1.1  ozaki SOCK_REMOTE=unix://ipsec_remote
     32  1.1  ozaki BUS_LOCAL=./bus_ipsec_local
     33  1.1  ozaki BUS_TUNNEL=./bus_ipsec_tunnel
     34  1.1  ozaki BUS_REMOTE=./bus_ipsec_remote
     35  1.1  ozaki 
     36  1.1  ozaki DEBUG=${DEBUG:-false}
     37  1.1  ozaki 
     38  1.1  ozaki setup_servers()
     39  1.1  ozaki {
     40  1.1  ozaki 
     41  1.1  ozaki 	# See https://www.netbsd.org/docs/network/ipsec/#sample_vpn
     42  1.1  ozaki 	rump_server_crypto_start $SOCK_LOCAL netinet6
     43  1.1  ozaki 	rump_server_crypto_start $SOCK_TUNNEL_LOCAL netipsec netinet6
     44  1.1  ozaki 	rump_server_crypto_start $SOCK_TUNNEL_REMOTE netipsec netinet6
     45  1.1  ozaki 	rump_server_crypto_start $SOCK_REMOTE netinet6
     46  1.1  ozaki 	rump_server_add_iface $SOCK_LOCAL shmif0 $BUS_LOCAL
     47  1.1  ozaki 	rump_server_add_iface $SOCK_TUNNEL_LOCAL shmif0 $BUS_LOCAL
     48  1.1  ozaki 	rump_server_add_iface $SOCK_TUNNEL_LOCAL shmif1 $BUS_TUNNEL
     49  1.1  ozaki 	rump_server_add_iface $SOCK_TUNNEL_REMOTE shmif0 $BUS_REMOTE
     50  1.1  ozaki 	rump_server_add_iface $SOCK_TUNNEL_REMOTE shmif1 $BUS_TUNNEL
     51  1.1  ozaki 	rump_server_add_iface $SOCK_REMOTE shmif0 $BUS_REMOTE
     52  1.1  ozaki }
     53  1.1  ozaki 
     54  1.1  ozaki check_tunnel_packets()
     55  1.1  ozaki {
     56  1.1  ozaki 	local outfile=$1
     57  1.1  ozaki 	local src=$2
     58  1.1  ozaki 	local dst=$3
     59  1.1  ozaki 	local proto=$4
     60  1.1  ozaki 
     61  1.1  ozaki 	atf_check -s exit:0 -o match:"$src > $dst: $proto" cat $outfile
     62  1.1  ozaki 	atf_check -s exit:0 -o match:"$dst > $src: $proto" cat $outfile
     63  1.1  ozaki }
     64  1.1  ozaki 
     65  1.1  ozaki test_ipsec46_tunnel()
     66  1.1  ozaki {
     67  1.1  ozaki 	local proto=$1
     68  1.1  ozaki 	local algo=$2
     69  1.1  ozaki 	local ip_local=10.0.1.2
     70  1.1  ozaki 	local ip_gw_local=10.0.1.1
     71  1.1  ozaki 	local ip_gw_local_tunnel=20.0.0.1
     72  1.1  ozaki 	local ip_gw_remote_tunnel=20.0.0.2
     73  1.1  ozaki 	local ip6_gw_local_tunnel=fc00::1
     74  1.1  ozaki 	local ip6_gw_remote_tunnel=fc00::2
     75  1.1  ozaki 	local ip_gw_remote=10.0.2.1
     76  1.1  ozaki 	local ip_remote=10.0.2.2
     77  1.1  ozaki 	local subnet_local=10.0.1.0
     78  1.1  ozaki 	local subnet_remote=10.0.2.0
     79  1.1  ozaki 	local tmpfile=./tmp
     80  1.1  ozaki 	local outfile=./out
     81  1.2  ozaki 	local proto_cap=$(echo $proto | tr 'a-z' 'A-Z')
     82  1.2  ozaki 	local algo_args="$(generate_algo_args $proto $algo)"
     83  1.1  ozaki 
     84  1.1  ozaki 	setup_servers
     85  1.1  ozaki 
     86  1.1  ozaki 	export RUMP_SERVER=$SOCK_LOCAL
     87  1.1  ozaki 	atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.dad_count=0
     88  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif0 $ip_local/24
     89  1.1  ozaki 	atf_check -s exit:0 -o ignore \
     90  1.1  ozaki 	    rump.route -n add -net $subnet_remote $ip_gw_local
     91  1.1  ozaki 
     92  1.1  ozaki 	export RUMP_SERVER=$SOCK_TUNNEL_LOCAL
     93  1.1  ozaki 	atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.dad_count=0
     94  1.1  ozaki 	atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.dad_count=0
     95  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif0 $ip_gw_local/24
     96  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif1 $ip_gw_local_tunnel/24
     97  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif1 inet6 $ip6_gw_local_tunnel/24
     98  1.1  ozaki 	atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=1
     99  1.1  ozaki 	atf_check -s exit:0 -o ignore \
    100  1.1  ozaki 	    rump.route -n add -net $subnet_remote $ip_gw_remote_tunnel
    101  1.1  ozaki 
    102  1.1  ozaki 	export RUMP_SERVER=$SOCK_TUNNEL_REMOTE
    103  1.1  ozaki 	atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.dad_count=0
    104  1.1  ozaki 	atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.dad_count=0
    105  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif0 $ip_gw_remote/24
    106  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif1 $ip_gw_remote_tunnel/24
    107  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif1 inet6 $ip6_gw_remote_tunnel/24
    108  1.1  ozaki 	atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.forwarding=1
    109  1.1  ozaki 	atf_check -s exit:0 -o ignore \
    110  1.1  ozaki 	    rump.route -n add -net $subnet_local $ip_gw_local_tunnel
    111  1.1  ozaki 
    112  1.1  ozaki 	export RUMP_SERVER=$SOCK_REMOTE
    113  1.1  ozaki 	atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.dad_count=0
    114  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif0 $ip_remote/24
    115  1.1  ozaki 	atf_check -s exit:0 -o ignore \
    116  1.1  ozaki 	    rump.route -n add -net $subnet_local $ip_gw_remote
    117  1.1  ozaki 
    118  1.1  ozaki 	extract_new_packets $BUS_TUNNEL > $outfile
    119  1.1  ozaki 
    120  1.1  ozaki 	export RUMP_SERVER=$SOCK_LOCAL
    121  1.1  ozaki 	atf_check -s exit:0 -o ignore rump.ping -c 1 -n -w 3 $ip_remote
    122  1.1  ozaki 
    123  1.1  ozaki 	extract_new_packets $BUS_TUNNEL > $outfile
    124  1.1  ozaki 	atf_check -s exit:0 \
    125  1.1  ozaki 	    -o match:"$ip_local > $ip_remote: ICMP echo request" \
    126  1.1  ozaki 	    cat $outfile
    127  1.1  ozaki 	atf_check -s exit:0 \
    128  1.1  ozaki 	    -o match:"$ip_remote > $ip_local: ICMP echo reply" \
    129  1.1  ozaki 	    cat $outfile
    130  1.1  ozaki 
    131  1.1  ozaki 	export RUMP_SERVER=$SOCK_TUNNEL_LOCAL
    132  1.1  ozaki 	# from https://www.netbsd.org/docs/network/ipsec/
    133  1.1  ozaki 	cat > $tmpfile <<-EOF
    134  1.2  ozaki 	add $ip6_gw_local_tunnel $ip6_gw_remote_tunnel $proto 10000 $algo_args;
    135  1.2  ozaki 	add $ip6_gw_remote_tunnel $ip6_gw_local_tunnel $proto 10001 $algo_args;
    136  1.1  ozaki 	spdadd $subnet_local/24 $subnet_remote/24 any -P out ipsec
    137  1.1  ozaki 	    $proto/tunnel/$ip6_gw_local_tunnel-$ip6_gw_remote_tunnel/require;
    138  1.1  ozaki 	spdadd $subnet_remote/24 $subnet_local/24 any -P in ipsec
    139  1.1  ozaki 	    $proto/tunnel/$ip6_gw_remote_tunnel-$ip6_gw_local_tunnel/require;
    140  1.1  ozaki 	EOF
    141  1.1  ozaki 	$DEBUG && cat $tmpfile
    142  1.1  ozaki 	atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
    143  1.1  ozaki 	check_sa_entries $SOCK_TUNNEL_LOCAL $ip6_gw_local_tunnel \
    144  1.1  ozaki 	    $ip6_gw_remote_tunnel
    145  1.1  ozaki 
    146  1.1  ozaki 	export RUMP_SERVER=$SOCK_TUNNEL_REMOTE
    147  1.1  ozaki 	cat > $tmpfile <<-EOF
    148  1.2  ozaki 	add $ip6_gw_local_tunnel $ip6_gw_remote_tunnel $proto 10000 $algo_args;
    149  1.2  ozaki 	add $ip6_gw_remote_tunnel $ip6_gw_local_tunnel $proto 10001 $algo_args;
    150  1.1  ozaki 	spdadd $subnet_remote/24 $subnet_local/24 any -P out ipsec
    151  1.1  ozaki 	    $proto/tunnel/$ip6_gw_remote_tunnel-$ip6_gw_local_tunnel/require;
    152  1.1  ozaki 	spdadd $subnet_local/24 $subnet_remote/24 any -P in ipsec
    153  1.1  ozaki 	    $proto/tunnel/$ip6_gw_local_tunnel-$ip6_gw_remote_tunnel/require;
    154  1.1  ozaki 	EOF
    155  1.1  ozaki 	$DEBUG && cat $tmpfile
    156  1.1  ozaki 	atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
    157  1.1  ozaki 	check_sa_entries $SOCK_TUNNEL_REMOTE $ip6_gw_local_tunnel \
    158  1.1  ozaki 	    $ip6_gw_remote_tunnel
    159  1.1  ozaki 
    160  1.1  ozaki 	export RUMP_SERVER=$SOCK_LOCAL
    161  1.1  ozaki 	atf_check -s exit:0 -o ignore rump.ping -c 1 -n -w 3 $ip_remote
    162  1.1  ozaki 
    163  1.1  ozaki 	extract_new_packets $BUS_TUNNEL > $outfile
    164  1.1  ozaki 	check_tunnel_packets $outfile $ip6_gw_local_tunnel $ip6_gw_remote_tunnel \
    165  1.1  ozaki 	    $proto_cap
    166  1.1  ozaki 
    167  1.1  ozaki 	test_flush_entries $SOCK_TUNNEL_LOCAL
    168  1.1  ozaki 	test_flush_entries $SOCK_TUNNEL_REMOTE
    169  1.1  ozaki }
    170  1.1  ozaki 
    171  1.1  ozaki test_ipsec64_tunnel()
    172  1.1  ozaki {
    173  1.1  ozaki 	local proto=$1
    174  1.1  ozaki 	local algo=$2
    175  1.1  ozaki 	local ip_local=fd00:1::2
    176  1.1  ozaki 	local ip_gw_local=fd00:1::1
    177  1.1  ozaki 	local ip_gw_local_tunnel=fc00::1
    178  1.1  ozaki 	local ip_gw_remote_tunnel=fc00::2
    179  1.1  ozaki 	local ip4_gw_local_tunnel=20.0.0.1
    180  1.1  ozaki 	local ip4_gw_remote_tunnel=20.0.0.2
    181  1.1  ozaki 	local ip_gw_remote=fd00:2::1
    182  1.1  ozaki 	local ip_remote=fd00:2::2
    183  1.1  ozaki 	local subnet_local=fd00:1::
    184  1.1  ozaki 	local subnet_remote=fd00:2::
    185  1.1  ozaki 	local tmpfile=./tmp
    186  1.1  ozaki 	local outfile=./out
    187  1.2  ozaki 	local proto_cap=$(echo $proto | tr 'a-z' 'A-Z')
    188  1.2  ozaki 	local algo_args="$(generate_algo_args $proto $algo)"
    189  1.1  ozaki 
    190  1.1  ozaki 	setup_servers
    191  1.1  ozaki 
    192  1.1  ozaki 	export RUMP_SERVER=$SOCK_LOCAL
    193  1.1  ozaki 	atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.dad_count=0
    194  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip_local/64
    195  1.1  ozaki 	atf_check -s exit:0 -o ignore \
    196  1.1  ozaki 	    rump.route -n add -inet6 -net $subnet_remote/64 $ip_gw_local
    197  1.1  ozaki 
    198  1.1  ozaki 	export RUMP_SERVER=$SOCK_TUNNEL_LOCAL
    199  1.1  ozaki 	atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.dad_count=0
    200  1.1  ozaki 	atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.dad_count=0
    201  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip_gw_local/64
    202  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif1 inet6 $ip_gw_local_tunnel/64
    203  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif1 $ip4_gw_local_tunnel
    204  1.1  ozaki 	atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.forwarding=1
    205  1.1  ozaki 	atf_check -s exit:0 -o ignore \
    206  1.1  ozaki 	    rump.route -n add -inet6 -net $subnet_remote/64 $ip_gw_remote_tunnel
    207  1.1  ozaki 
    208  1.1  ozaki 	export RUMP_SERVER=$SOCK_TUNNEL_REMOTE
    209  1.1  ozaki 	atf_check -s exit:0 rump.sysctl -q -w net.inet.ip.dad_count=0
    210  1.1  ozaki 	atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.dad_count=0
    211  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip_gw_remote/64
    212  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif1 inet6 $ip_gw_remote_tunnel/64
    213  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif1 $ip4_gw_remote_tunnel
    214  1.1  ozaki 	atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.forwarding=1
    215  1.1  ozaki 	atf_check -s exit:0 -o ignore \
    216  1.1  ozaki 	    rump.route -n add -inet6 -net $subnet_local/64 $ip_gw_local_tunnel
    217  1.1  ozaki 
    218  1.1  ozaki 	export RUMP_SERVER=$SOCK_REMOTE
    219  1.1  ozaki 	atf_check -s exit:0 rump.sysctl -q -w net.inet6.ip6.dad_count=0
    220  1.1  ozaki 	atf_check -s exit:0 rump.ifconfig shmif0 inet6 $ip_remote
    221  1.1  ozaki 	atf_check -s exit:0 -o ignore \
    222  1.1  ozaki 	    rump.route -n add -inet6 -net $subnet_local/64 $ip_gw_remote
    223  1.1  ozaki 
    224  1.1  ozaki 	extract_new_packets $BUS_TUNNEL > $outfile
    225  1.1  ozaki 
    226  1.1  ozaki 	export RUMP_SERVER=$SOCK_LOCAL
    227  1.1  ozaki 	atf_check -s exit:0 -o ignore rump.ping6 -c 1 -n -X 3 $ip_remote
    228  1.1  ozaki 
    229  1.1  ozaki 	extract_new_packets $BUS_TUNNEL > $outfile
    230  1.1  ozaki 	atf_check -s exit:0 \
    231  1.1  ozaki 	    -o match:"$ip_local > $ip_remote: ICMP6, echo request" \
    232  1.1  ozaki 	    cat $outfile
    233  1.1  ozaki 	atf_check -s exit:0 \
    234  1.1  ozaki 	    -o match:"$ip_remote > $ip_local: ICMP6, echo reply" \
    235  1.1  ozaki 	    cat $outfile
    236  1.1  ozaki 
    237  1.1  ozaki 	export RUMP_SERVER=$SOCK_TUNNEL_LOCAL
    238  1.1  ozaki 	# from https://www.netbsd.org/docs/network/ipsec/
    239  1.1  ozaki 	cat > $tmpfile <<-EOF
    240  1.2  ozaki 	add $ip4_gw_local_tunnel $ip4_gw_remote_tunnel $proto 10000 $algo_args;
    241  1.2  ozaki 	add $ip4_gw_remote_tunnel $ip4_gw_local_tunnel $proto 10001 $algo_args;
    242  1.1  ozaki 	spdadd $subnet_local/64 $subnet_remote/64 any -P out ipsec
    243  1.1  ozaki 	    $proto/tunnel/$ip4_gw_local_tunnel-$ip4_gw_remote_tunnel/require;
    244  1.1  ozaki 	spdadd $subnet_remote/64 $subnet_local/64 any -P in ipsec
    245  1.1  ozaki 	    $proto/tunnel/$ip4_gw_remote_tunnel-$ip4_gw_local_tunnel/require;
    246  1.1  ozaki 	EOF
    247  1.1  ozaki 	$DEBUG && cat $tmpfile
    248  1.1  ozaki 	atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
    249  1.1  ozaki 	check_sa_entries $SOCK_TUNNEL_LOCAL $ip4_gw_local_tunnel \
    250  1.1  ozaki 	    $ip4_gw_remote_tunnel
    251  1.1  ozaki 
    252  1.1  ozaki 	export RUMP_SERVER=$SOCK_TUNNEL_REMOTE
    253  1.1  ozaki 	cat > $tmpfile <<-EOF
    254  1.2  ozaki 	add $ip4_gw_local_tunnel $ip4_gw_remote_tunnel $proto 10000 $algo_args;
    255  1.2  ozaki 	add $ip4_gw_remote_tunnel $ip4_gw_local_tunnel $proto 10001 $algo_args;
    256  1.1  ozaki 	spdadd $subnet_remote/64 $subnet_local/64 any -P out ipsec
    257  1.1  ozaki 	    $proto/tunnel/$ip4_gw_remote_tunnel-$ip4_gw_local_tunnel/require;
    258  1.1  ozaki 	spdadd $subnet_local/64 $subnet_remote/64 any -P in ipsec
    259  1.1  ozaki 	    $proto/tunnel/$ip4_gw_local_tunnel-$ip4_gw_remote_tunnel/require;
    260  1.1  ozaki 	EOF
    261  1.1  ozaki 	$DEBUG && cat $tmpfile
    262  1.1  ozaki 	atf_check -s exit:0 -o empty $HIJACKING setkey -c < $tmpfile
    263  1.1  ozaki 	check_sa_entries $SOCK_TUNNEL_REMOTE $ip4_gw_local_tunnel \
    264  1.1  ozaki 	    $ip4_gw_remote_tunnel
    265  1.1  ozaki 
    266  1.1  ozaki 	export RUMP_SERVER=$SOCK_LOCAL
    267  1.1  ozaki 	atf_check -s exit:0 -o ignore rump.ping6 -c 1 -n -X 3 $ip_remote
    268  1.1  ozaki 
    269  1.1  ozaki 	extract_new_packets $BUS_TUNNEL > $outfile
    270  1.1  ozaki 	check_tunnel_packets $outfile $ip4_gw_local_tunnel $ip4_gw_remote_tunnel \
    271  1.1  ozaki 	    $proto_cap
    272  1.1  ozaki 
    273  1.1  ozaki 	test_flush_entries $SOCK_TUNNEL_LOCAL
    274  1.1  ozaki 	test_flush_entries $SOCK_TUNNEL_REMOTE
    275  1.1  ozaki }
    276  1.1  ozaki 
    277  1.1  ozaki test_tunnel_common()
    278  1.1  ozaki {
    279  1.1  ozaki 	local ipproto=$1
    280  1.1  ozaki 	local proto=$2
    281  1.1  ozaki 	local algo=$3
    282  1.1  ozaki 
    283  1.1  ozaki 	if [ $ipproto = v4v6 ]; then
    284  1.1  ozaki 		test_ipsec46_tunnel $proto $algo
    285  1.1  ozaki 	else
    286  1.1  ozaki 		test_ipsec64_tunnel $proto $algo
    287  1.1  ozaki 	fi
    288  1.1  ozaki }
    289  1.1  ozaki 
    290  1.1  ozaki add_test_tunnel_mode()
    291  1.1  ozaki {
    292  1.1  ozaki 	local ipproto=$1
    293  1.1  ozaki 	local proto=$2
    294  1.1  ozaki 	local algo=$3
    295  1.1  ozaki 	local _algo=$(echo $algo | sed 's/-//g')
    296  1.1  ozaki 	local name= desc=
    297  1.1  ozaki 
    298  1.1  ozaki 	name="ipsec_tunnel_${ipproto}_${proto}_${_algo}"
    299  1.1  ozaki 	if [ $ipproto = v4v6 ]; then
    300  1.1  ozaki 		desc="Tests of IPsec tunnel mode (IPv4 over IPv6) with $proto ($algo)"
    301  1.1  ozaki 	else
    302  1.1  ozaki 		desc="Tests of IPsec tunnel mode (IPv6 over IPv4) with $proto ($algo)"
    303  1.1  ozaki 	fi
    304  1.1  ozaki 
    305  1.1  ozaki 	atf_test_case ${name} cleanup
    306  1.1  ozaki 	eval "								\
    307  1.1  ozaki 	    ${name}_head() {						\
    308  1.1  ozaki 	        atf_set \"descr\" \"$desc\";				\
    309  1.1  ozaki 	        atf_set \"require.progs\" \"rump_server\" \"setkey\";	\
    310  1.1  ozaki 	    };								\
    311  1.1  ozaki 	    ${name}_body() {						\
    312  1.1  ozaki 	        test_tunnel_common $ipproto $proto $algo;		\
    313  1.1  ozaki 	        rump_server_destroy_ifaces;				\
    314  1.1  ozaki 	    };								\
    315  1.1  ozaki 	    ${name}_cleanup() {						\
    316  1.1  ozaki 	        $DEBUG && dump;						\
    317  1.1  ozaki 	        cleanup;						\
    318  1.1  ozaki 	    }								\
    319  1.1  ozaki 	"
    320  1.1  ozaki 	atf_add_test_case ${name}
    321  1.1  ozaki }
    322  1.1  ozaki 
    323  1.1  ozaki atf_init_test_cases()
    324  1.1  ozaki {
    325  1.1  ozaki 	local algo=
    326  1.1  ozaki 
    327  1.1  ozaki 	for algo in $ESP_ENCRYPTION_ALGORITHMS; do
    328  1.1  ozaki 		add_test_tunnel_mode v4v6 esp $algo
    329  1.1  ozaki 		add_test_tunnel_mode v6v4 esp $algo
    330  1.1  ozaki 	done
    331  1.1  ozaki 
    332  1.1  ozaki 	for algo in $AH_AUTHENTICATION_ALGORITHMS; do
    333  1.1  ozaki 		add_test_tunnel_mode v4v6 ah $algo
    334  1.1  ozaki 		add_test_tunnel_mode v6v4 ah $algo
    335  1.1  ozaki 	done
    336  1.1  ozaki }
    337