1 # $NetBSD: t_tap.sh,v 1.3 2016/08/10 22:42:21 kre Exp $
3 # Copyright (c) 2016 Internet Initiative Japan Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
28 RUMP_FLAGS="-lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6"
29 RUMP_FLAGS="$RUMP_FLAGS -lrumpnet_shmif -lrumpnet_tap -lrumpnet_bridge -lrumpdev"
30 HIJACKING="env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=sysctl=yes"
32 SOCK_LOCAL=unix://commsock1
33 SOCK_REMOTE=unix://commsock2
45 atf_test_case tap_create_destroy cleanup
46 tap_create_destroy_head()
49 atf_set "descr" "tests of creation and deletion of tap interface"
50 atf_set "require.progs" "rump_server"
53 tap_create_destroy_body()
56 atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_LOCAL}
58 export RUMP_SERVER=${SOCK_LOCAL}
60 # Create and destroy (no address)
61 atf_check -s exit:0 rump.ifconfig tap0 create
62 atf_check -s exit:0 rump.ifconfig tap0 destroy
64 # Create and destroy (with an IPv4 address)
65 atf_check -s exit:0 rump.ifconfig tap0 create
66 atf_check -s exit:0 rump.ifconfig tap0 $IP4_TAP
67 atf_check -s exit:0 rump.ifconfig tap0 up
68 atf_check -s exit:0 rump.ifconfig tap0 destroy
70 # Create and destroy (with an IPv6 address)
71 atf_check -s exit:0 rump.ifconfig tap0 create
72 atf_check -s exit:0 rump.ifconfig tap0 inet6 $IP6_TAP
73 atf_check -s exit:0 rump.ifconfig tap0 up
74 atf_check -s exit:0 rump.ifconfig tap0 destroy
77 tap_create_destroy_cleanup()
80 RUMP_SERVER=${SOCK_LOCAL} rump.halt
83 atf_test_case tap_stand_alone cleanup
84 tap_create_destroy_head()
87 atf_set "descr" "tests of alone tap interface"
88 atf_set "require.progs" "rump_server"
91 tap_stand_alone_body()
93 atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_LOCAL}
94 atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_REMOTE}
96 export RUMP_SERVER=${SOCK_LOCAL}
98 atf_check -s exit:0 rump.ifconfig shmif0 create
99 atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS
100 atf_check -s exit:0 rump.ifconfig shmif0 $IP4_LOCAL
101 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_LOCAL
102 atf_check -s exit:0 rump.ifconfig shmif0 up
103 atf_check -s exit:0 rump.ifconfig tap0 create
104 atf_check -s exit:0 rump.ifconfig tap0 $IP4_TAP
105 atf_check -s exit:0 rump.ifconfig tap0 inet6 $IP6_TAP
106 atf_check -s exit:0 rump.ifconfig tap0 up
107 atf_check -s exit:0 rump.ifconfig -w 10
109 export RUMP_SERVER=${SOCK_REMOTE}
111 atf_check -s exit:0 rump.ifconfig shmif0 create
112 atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS
113 atf_check -s exit:0 rump.ifconfig shmif0 $IP4_REMOTE
114 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_REMOTE
115 atf_check -s exit:0 rump.ifconfig shmif0 up
116 atf_check -s exit:0 rump.ifconfig -w 10
118 atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4_LOCAL
119 # Cannot reach to an alone tap
120 atf_check -s not-exit:0 -o ignore -e ignore \
121 rump.ping -n -w $TIMEOUT -c 1 $IP4_TAP
123 atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6_LOCAL
124 # Cannot reach to an alone tap
125 atf_check -s not-exit:0 -o ignore -e ignore \
126 rump.ping6 -n -X $TIMEOUT -c 1 $IP6_TAP
129 tap_stand_alone_cleanup()
132 RUMP_SERVER=${SOCK_LOCAL} rump.halt
133 RUMP_SERVER=${SOCK_REMOTE} rump.halt
136 atf_test_case tap_bridged cleanup
140 atf_set "descr" "tests of alone tap interface"
141 atf_set "require.progs" "rump_server"
146 atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_LOCAL}
147 atf_check -s exit:0 rump_server ${RUMP_FLAGS} ${SOCK_REMOTE}
149 export RUMP_SERVER=${SOCK_LOCAL}
151 atf_check -s exit:0 rump.ifconfig shmif0 create
152 atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS
153 atf_check -s exit:0 rump.ifconfig shmif0 $IP4_LOCAL
154 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_LOCAL
155 atf_check -s exit:0 rump.ifconfig shmif0 up
156 atf_check -s exit:0 rump.ifconfig tap0 create
157 atf_check -s exit:0 rump.ifconfig tap0 $IP4_TAP
158 atf_check -s exit:0 rump.ifconfig tap0 inet6 $IP6_TAP
159 atf_check -s exit:0 rump.ifconfig tap0 up
160 atf_check -s exit:0 rump.ifconfig -w 10
162 atf_check -s exit:0 rump.ifconfig bridge0 create
163 atf_check -s exit:0 rump.ifconfig bridge0 up
164 export LD_PRELOAD=/usr/lib/librumphijack.so
165 atf_check -s exit:0 brconfig bridge0 add shmif0
166 atf_check -s exit:0 brconfig bridge0 add tap0
169 export RUMP_SERVER=${SOCK_REMOTE}
171 atf_check -s exit:0 rump.ifconfig shmif0 create
172 atf_check -s exit:0 rump.ifconfig shmif0 linkstr $BUS
173 atf_check -s exit:0 rump.ifconfig shmif0 $IP4_REMOTE
174 atf_check -s exit:0 rump.ifconfig shmif0 inet6 $IP6_REMOTE
175 atf_check -s exit:0 rump.ifconfig shmif0 up
176 atf_check -s exit:0 rump.ifconfig -w 10
178 atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4_LOCAL
179 atf_check -s exit:0 -o ignore rump.ping -n -w $TIMEOUT -c 1 $IP4_TAP
181 atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6_LOCAL
182 atf_check -s exit:0 -o ignore rump.ping6 -n -X $TIMEOUT -c 1 $IP6_TAP
185 tap_bridged_cleanup()
188 RUMP_SERVER=${SOCK_LOCAL} rump.halt
189 RUMP_SERVER=${SOCK_REMOTE} rump.halt
192 atf_init_test_cases()
195 atf_add_test_case tap_create_destroy
196 atf_add_test_case tap_stand_alone
197 atf_add_test_case tap_bridged