t_basic.sh revision 1.1 1 1.1 riastrad # $NetBSD: t_basic.sh,v 1.1 2020/08/26 16:03:42 riastradh Exp $
2 1.1 riastrad #
3 1.1 riastrad # Copyright (c) 2018 Ryota Ozaki <ozaki.ryota (at] gmail.com>
4 1.1 riastrad # All rights reserved.
5 1.1 riastrad #
6 1.1 riastrad # Redistribution and use in source and binary forms, with or without
7 1.1 riastrad # modification, are permitted provided that the following conditions
8 1.1 riastrad # are met:
9 1.1 riastrad # 1. Redistributions of source code must retain the above copyright
10 1.1 riastrad # notice, this list of conditions and the following disclaimer.
11 1.1 riastrad # 2. Redistributions in binary form must reproduce the above copyright
12 1.1 riastrad # notice, this list of conditions and the following disclaimer in the
13 1.1 riastrad # documentation and/or other materials provided with the distribution.
14 1.1 riastrad #
15 1.1 riastrad # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 1.1 riastrad # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 1.1 riastrad # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 1.1 riastrad # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 1.1 riastrad # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 1.1 riastrad # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 1.1 riastrad # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 1.1 riastrad # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 1.1 riastrad # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 1.1 riastrad # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.1 riastrad # POSSIBILITY OF SUCH DAMAGE.
26 1.1 riastrad #
27 1.1 riastrad
28 1.1 riastrad BUS=bus
29 1.1 riastrad SOCK_LOCAL=unix://wg_local
30 1.1 riastrad SOCK_PEER=unix://wg_peer
31 1.1 riastrad SOCK_PEER2=unix://wg_peer2
32 1.1 riastrad
33 1.1 riastrad
34 1.1 riastrad check_ping_payload()
35 1.1 riastrad {
36 1.1 riastrad local proto=$1
37 1.1 riastrad local ip=$2
38 1.1 riastrad local ping= size=
39 1.1 riastrad
40 1.1 riastrad if [ $proto = inet ]; then
41 1.1 riastrad ping="atf_check -s exit:0 -o ignore rump.ping -n -c 1 -w 1"
42 1.1 riastrad else
43 1.1 riastrad ping="atf_check -s exit:0 -o ignore rump.ping6 -n -c 1 -X 1"
44 1.1 riastrad fi
45 1.1 riastrad
46 1.1 riastrad for size in $(seq 1 100) $(seq 450 550) $(seq 1400 1500); do
47 1.1 riastrad $ping -s $size $ip
48 1.1 riastrad done
49 1.1 riastrad }
50 1.1 riastrad
51 1.1 riastrad test_common()
52 1.1 riastrad {
53 1.1 riastrad local type=$1
54 1.1 riastrad local outer_proto=$2
55 1.1 riastrad local inner_proto=$3
56 1.1 riastrad local ifconfig="atf_check -s exit:0 rump.ifconfig"
57 1.1 riastrad local port=51820
58 1.1 riastrad local ip_local= ip_peer=
59 1.1 riastrad local ip_wg_local= ip_wg_peer=
60 1.1 riastrad local outer_prefix= outer_prefixall=
61 1.1 riastrad local inner_prefix= inner_prefixall=
62 1.1 riastrad
63 1.1 riastrad if [ $outer_proto = inet ]; then
64 1.1 riastrad ip_local=192.168.1.1
65 1.1 riastrad ip_peer=192.168.1.2
66 1.1 riastrad outer_prefix=24
67 1.1 riastrad outer_prefixall=32
68 1.1 riastrad else
69 1.1 riastrad ip_local=fc00::1
70 1.1 riastrad ip_peer=fc00::2
71 1.1 riastrad outer_prefix=64
72 1.1 riastrad outer_prefixall=128
73 1.1 riastrad fi
74 1.1 riastrad
75 1.1 riastrad if [ $inner_proto = inet ]; then
76 1.1 riastrad ip_wg_local=10.0.0.1
77 1.1 riastrad ip_wg_peer=10.0.0.2
78 1.1 riastrad inner_prefix=24
79 1.1 riastrad inner_prefixall=32
80 1.1 riastrad else
81 1.1 riastrad ip_wg_local=fd00::1
82 1.1 riastrad ip_wg_peer=fd00::2
83 1.1 riastrad inner_prefix=64
84 1.1 riastrad inner_prefixall=128
85 1.1 riastrad fi
86 1.1 riastrad
87 1.1 riastrad setup_servers
88 1.1 riastrad
89 1.1 riastrad # It sets key_priv_local key_pub_local key_priv_peer key_pub_peer
90 1.1 riastrad generate_keys
91 1.1 riastrad
92 1.1 riastrad export RUMP_SERVER=$SOCK_LOCAL
93 1.1 riastrad setup_common shmif0 $outer_proto $ip_local $outer_prefix
94 1.1 riastrad setup_wg_common wg0 $inner_proto $ip_wg_local $inner_prefix $port "$key_priv_local"
95 1.1 riastrad
96 1.1 riastrad export RUMP_SERVER=$SOCK_PEER
97 1.1 riastrad setup_common shmif0 $outer_proto $ip_peer $outer_prefix
98 1.1 riastrad setup_wg_common wg0 $inner_proto $ip_wg_peer $inner_prefix $port "$key_priv_peer"
99 1.1 riastrad
100 1.1 riastrad export RUMP_SERVER=$SOCK_LOCAL
101 1.1 riastrad add_peer wg0 peer0 $key_pub_peer $ip_peer:$port $ip_wg_peer/$inner_prefixall
102 1.1 riastrad
103 1.1 riastrad export RUMP_SERVER=$SOCK_PEER
104 1.1 riastrad add_peer wg0 peer0 $key_pub_local $ip_local:$port $ip_wg_local/$inner_prefixall
105 1.1 riastrad
106 1.1 riastrad if [ $type = basic ]; then
107 1.1 riastrad export RUMP_SERVER=$SOCK_LOCAL
108 1.1 riastrad check_ping $inner_proto $ip_wg_peer
109 1.1 riastrad elif [ $type = payload ]; then
110 1.1 riastrad export RUMP_SERVER=$SOCK_LOCAL
111 1.1 riastrad check_ping_payload $inner_proto $ip_wg_peer
112 1.1 riastrad fi
113 1.1 riastrad
114 1.1 riastrad destroy_wg_interfaces
115 1.1 riastrad }
116 1.1 riastrad
117 1.1 riastrad atf_test_case wg_create_destroy cleanup
118 1.1 riastrad wg_create_destroy_head()
119 1.1 riastrad {
120 1.1 riastrad
121 1.1 riastrad atf_set "descr" "tests to create/destroy wg(4) interfaces"
122 1.1 riastrad atf_set "require.progs" "rump_server" "wgconfig" "wg-keygen"
123 1.1 riastrad }
124 1.1 riastrad
125 1.1 riastrad wg_create_destroy_body()
126 1.1 riastrad {
127 1.1 riastrad
128 1.1 riastrad rump_server_crypto_start $SOCK_LOCAL netinet6 wg
129 1.1 riastrad
130 1.1 riastrad test_create_destroy_common $SOCK_LOCAL wg0 true
131 1.1 riastrad }
132 1.1 riastrad
133 1.1 riastrad wg_create_destroy_cleanup()
134 1.1 riastrad {
135 1.1 riastrad
136 1.1 riastrad $DEBUG && dump
137 1.1 riastrad cleanup
138 1.1 riastrad }
139 1.1 riastrad
140 1.1 riastrad wg_create_destroy_peers_common()
141 1.1 riastrad {
142 1.1 riastrad local proto=$1
143 1.1 riastrad local ifconfig="atf_check -s exit:0 rump.ifconfig"
144 1.1 riastrad local port=51820
145 1.1 riastrad local ip_local= ip_peer=
146 1.1 riastrad local ip_wg_local= ip_wg_peer=
147 1.1 riastrad local outer_prefix= outer_prefixall=
148 1.1 riastrad local inner_prefix= inner_prefixall=
149 1.1 riastrad
150 1.1 riastrad if [ $proto = inet ]; then
151 1.1 riastrad ip_local=192.168.1.1
152 1.1 riastrad ip_peer=192.168.1.2
153 1.1 riastrad outer_prefix=24
154 1.1 riastrad outer_prefixall=32
155 1.1 riastrad ip_wg_local=10.0.0.1
156 1.1 riastrad ip_wg_peer=10.0.0.2
157 1.1 riastrad inner_prefix=24
158 1.1 riastrad inner_prefixall=32
159 1.1 riastrad else
160 1.1 riastrad ip_local=fc00::1
161 1.1 riastrad ip_peer=fc00::2
162 1.1 riastrad outer_prefix=64
163 1.1 riastrad outer_prefixall=128
164 1.1 riastrad ip_wg_local=fd00::1
165 1.1 riastrad ip_wg_peer=fd00::2
166 1.1 riastrad inner_prefix=64
167 1.1 riastrad inner_prefixall=128
168 1.1 riastrad fi
169 1.1 riastrad
170 1.1 riastrad rump_server_crypto_start $SOCK_LOCAL netinet6 wg
171 1.1 riastrad rump_server_add_iface $SOCK_LOCAL shmif0 $BUS
172 1.1 riastrad
173 1.1 riastrad # It sets key_priv_local key_pub_local key_priv_peer key_pub_peer
174 1.1 riastrad generate_keys
175 1.1 riastrad
176 1.1 riastrad export RUMP_SERVER=$SOCK_LOCAL
177 1.1 riastrad setup_common shmif0 $proto $ip_local $outer_prefix
178 1.1 riastrad setup_wg_common wg0 $proto $ip_wg_local $inner_prefix $port "$key_priv_local"
179 1.1 riastrad
180 1.1 riastrad add_peer wg0 peer0 $key_pub_peer $ip_peer:$port $ip_wg_peer/$inner_prefixall
181 1.1 riastrad
182 1.1 riastrad delete_peer wg0 peer0
183 1.1 riastrad }
184 1.1 riastrad
185 1.1 riastrad atf_test_case wg_create_destroy_peers_ipv4 cleanup
186 1.1 riastrad wg_create_destroy_peers_ipv4_head()
187 1.1 riastrad {
188 1.1 riastrad
189 1.1 riastrad atf_set "descr" "tests to create/destroy peers (IPv4)"
190 1.1 riastrad atf_set "require.progs" "rump_server" "wgconfig" "wg-keygen"
191 1.1 riastrad }
192 1.1 riastrad
193 1.1 riastrad wg_create_destroy_peers_ipv4_body()
194 1.1 riastrad {
195 1.1 riastrad
196 1.1 riastrad wg_create_destroy_peers_common inet
197 1.1 riastrad }
198 1.1 riastrad
199 1.1 riastrad wg_create_destroy_peers_ipv4_cleanup()
200 1.1 riastrad {
201 1.1 riastrad
202 1.1 riastrad $DEBUG && dump
203 1.1 riastrad cleanup
204 1.1 riastrad }
205 1.1 riastrad
206 1.1 riastrad atf_test_case wg_create_destroy_peers_ipv6 cleanup
207 1.1 riastrad wg_create_destroy_peers_ipv6_head()
208 1.1 riastrad {
209 1.1 riastrad
210 1.1 riastrad atf_set "descr" "tests to create/destroy peers (IPv6)"
211 1.1 riastrad atf_set "require.progs" "rump_server" "wgconfig" "wg-keygen"
212 1.1 riastrad }
213 1.1 riastrad
214 1.1 riastrad wg_create_destroy_peers_ipv6_body()
215 1.1 riastrad {
216 1.1 riastrad
217 1.1 riastrad wg_create_destroy_peers_common inet6
218 1.1 riastrad }
219 1.1 riastrad
220 1.1 riastrad wg_create_destroy_peers_ipv6_cleanup()
221 1.1 riastrad {
222 1.1 riastrad
223 1.1 riastrad $DEBUG && dump
224 1.1 riastrad cleanup
225 1.1 riastrad }
226 1.1 riastrad
227 1.1 riastrad add_basic_test()
228 1.1 riastrad {
229 1.1 riastrad local inner=$1
230 1.1 riastrad local outer=$2
231 1.1 riastrad local ipv4=inet
232 1.1 riastrad local ipv6=inet6
233 1.1 riastrad
234 1.1 riastrad name="wg_basic_${inner}_over_${outer}"
235 1.1 riastrad fulldesc="Test wg(4) with ${inner} over ${outer}"
236 1.1 riastrad
237 1.1 riastrad eval inner=\$$inner
238 1.1 riastrad eval outer=\$$outer
239 1.1 riastrad
240 1.1 riastrad atf_test_case ${name} cleanup
241 1.1 riastrad eval "
242 1.1 riastrad ${name}_head() {
243 1.1 riastrad atf_set descr \"${fulldesc}\"
244 1.1 riastrad atf_set require.progs rump_server wgconfig wg-keygen
245 1.1 riastrad }
246 1.1 riastrad ${name}_body() {
247 1.1 riastrad test_common basic $outer $inner
248 1.1 riastrad rump_server_destroy_ifaces
249 1.1 riastrad }
250 1.1 riastrad ${name}_cleanup() {
251 1.1 riastrad \$DEBUG && dump
252 1.1 riastrad cleanup
253 1.1 riastrad }"
254 1.1 riastrad atf_add_test_case ${name}
255 1.1 riastrad }
256 1.1 riastrad
257 1.1 riastrad add_payload_sizes_test()
258 1.1 riastrad {
259 1.1 riastrad local inner=$1
260 1.1 riastrad local outer=$2
261 1.1 riastrad local ipv4=inet
262 1.1 riastrad local ipv6=inet6
263 1.1 riastrad
264 1.1 riastrad name="wg_payload_sizes_${inner}_over_${outer}"
265 1.1 riastrad fulldesc="Test wg(4) with ${inner} over ${outer} with various payload sizes"
266 1.1 riastrad
267 1.1 riastrad eval inner=\$$inner
268 1.1 riastrad eval outer=\$$outer
269 1.1 riastrad
270 1.1 riastrad atf_test_case ${name} cleanup
271 1.1 riastrad eval "
272 1.1 riastrad ${name}_head() {
273 1.1 riastrad atf_set descr \"${fulldesc}\"
274 1.1 riastrad atf_set require.progs rump_server wgconfig wg-keygen
275 1.1 riastrad }
276 1.1 riastrad ${name}_body() {
277 1.1 riastrad test_common payload $outer $inner
278 1.1 riastrad rump_server_destroy_ifaces
279 1.1 riastrad }
280 1.1 riastrad ${name}_cleanup() {
281 1.1 riastrad \$DEBUG && dump
282 1.1 riastrad cleanup
283 1.1 riastrad }"
284 1.1 riastrad atf_add_test_case ${name}
285 1.1 riastrad }
286 1.1 riastrad
287 1.1 riastrad atf_test_case wg_multiple_interfaces cleanup
288 1.1 riastrad wg_multiple_interfaces_head()
289 1.1 riastrad {
290 1.1 riastrad
291 1.1 riastrad atf_set "descr" "tests multiple wg(4) interfaces"
292 1.1 riastrad atf_set "require.progs" "rump_server" "wgconfig" "wg-keygen"
293 1.1 riastrad }
294 1.1 riastrad
295 1.1 riastrad wg_multiple_interfaces_body()
296 1.1 riastrad {
297 1.1 riastrad local ifconfig="atf_check -s exit:0 rump.ifconfig"
298 1.1 riastrad local ping="atf_check -s exit:0 -o ignore rump.ping -n -i 0.1 -c 3 -w 1"
299 1.1 riastrad local ping_fail="atf_check -s not-exit:0 -o ignore rump.ping -n -c 1 -w 1"
300 1.1 riastrad local key_priv_peer2=
301 1.1 riastrad local key_pub_peer2=
302 1.1 riastrad local ip_local=192.168.1.1
303 1.1 riastrad local ip_local2=192.168.2.1
304 1.1 riastrad local ip_peer=192.168.1.2
305 1.1 riastrad local ip_peer2=192.168.2.2
306 1.1 riastrad local ip_wg_local=10.0.0.1
307 1.1 riastrad local ip_wg_local2=10.0.1.1
308 1.1 riastrad local ip_wg_peer=10.0.0.2
309 1.1 riastrad local ip_wg_peer2=10.0.1.2
310 1.1 riastrad local port=51820
311 1.1 riastrad local port2=51821
312 1.1 riastrad local outfile=./out
313 1.1 riastrad
314 1.1 riastrad setup_servers
315 1.1 riastrad rump_server_add_iface $SOCK_LOCAL shmif1 $BUS
316 1.1 riastrad
317 1.1 riastrad rump_server_crypto_start $SOCK_PEER2 netinet6 wg
318 1.1 riastrad rump_server_add_iface $SOCK_PEER2 shmif0 $BUS
319 1.1 riastrad
320 1.1 riastrad # It sets key_priv_local key_pub_local key_priv_peer key_pub_peer
321 1.1 riastrad generate_keys
322 1.1 riastrad key_priv_peer2=$(wg-keygen)
323 1.1 riastrad key_pub_peer2=$(echo $key_priv_peer2| wg-keygen --pub)
324 1.1 riastrad
325 1.1 riastrad export RUMP_SERVER=$SOCK_LOCAL
326 1.1 riastrad setup_common shmif0 inet $ip_local 24
327 1.1 riastrad setup_common shmif1 inet $ip_local2 24
328 1.1 riastrad setup_wg_common wg0 inet $ip_wg_local 24 $port "$key_priv_local"
329 1.1 riastrad setup_wg_common wg1 inet $ip_wg_local2 24 $port2 "$key_priv_local"
330 1.1 riastrad
331 1.1 riastrad export RUMP_SERVER=$SOCK_PEER
332 1.1 riastrad setup_common shmif0 inet $ip_peer 24
333 1.1 riastrad setup_wg_common wg0 inet $ip_wg_peer 24 $port "$key_priv_peer"
334 1.1 riastrad
335 1.1 riastrad export RUMP_SERVER=$SOCK_PEER2
336 1.1 riastrad setup_common shmif0 inet $ip_peer2 24
337 1.1 riastrad setup_wg_common wg0 inet $ip_wg_peer2 24 $port2 "$key_priv_peer2"
338 1.1 riastrad
339 1.1 riastrad export RUMP_SERVER=$SOCK_LOCAL
340 1.1 riastrad add_peer wg0 peer0 $key_pub_peer $ip_peer:$port $ip_wg_peer/32
341 1.1 riastrad add_peer wg1 peer0 $key_pub_peer2 $ip_peer2:$port2 $ip_wg_peer2/32
342 1.1 riastrad
343 1.1 riastrad export RUMP_SERVER=$SOCK_PEER
344 1.1 riastrad add_peer wg0 peer0 $key_pub_local $ip_local:$port $ip_wg_local/32
345 1.1 riastrad
346 1.1 riastrad export RUMP_SERVER=$SOCK_PEER2
347 1.1 riastrad add_peer wg0 peer0 $key_pub_local $ip_local2:$port2 $ip_wg_local2/32
348 1.1 riastrad
349 1.1 riastrad export RUMP_SERVER=$SOCK_LOCAL
350 1.1 riastrad
351 1.1 riastrad extract_new_packets $BUS > $outfile
352 1.1 riastrad $DEBUG && cat $outfile
353 1.1 riastrad
354 1.1 riastrad $ping $ip_wg_peer
355 1.1 riastrad
356 1.1 riastrad extract_new_packets $BUS > $outfile
357 1.1 riastrad $DEBUG && cat $outfile
358 1.1 riastrad
359 1.1 riastrad $ping $ip_wg_peer2
360 1.1 riastrad
361 1.1 riastrad extract_new_packets $BUS > $outfile
362 1.1 riastrad $DEBUG && cat $outfile
363 1.1 riastrad
364 1.1 riastrad export RUMP_SERVER=$SOCK_LOCAL
365 1.1 riastrad $ifconfig wg0 destroy
366 1.1 riastrad $ifconfig wg1 destroy
367 1.1 riastrad export RUMP_SERVER=$SOCK_PEER
368 1.1 riastrad $ifconfig wg0 destroy
369 1.1 riastrad export RUMP_SERVER=$SOCK_PEER2
370 1.1 riastrad $ifconfig wg0 destroy
371 1.1 riastrad }
372 1.1 riastrad
373 1.1 riastrad wg_multiple_interfaces_cleanup()
374 1.1 riastrad {
375 1.1 riastrad
376 1.1 riastrad $DEBUG && dump
377 1.1 riastrad cleanup
378 1.1 riastrad }
379 1.1 riastrad
380 1.1 riastrad atf_test_case wg_multiple_peers cleanup
381 1.1 riastrad wg_multiple_peers_head()
382 1.1 riastrad {
383 1.1 riastrad
384 1.1 riastrad atf_set "descr" "tests multiple wg(4) peers"
385 1.1 riastrad atf_set "require.progs" "rump_server" "wgconfig" "wg-keygen"
386 1.1 riastrad }
387 1.1 riastrad
388 1.1 riastrad wg_multiple_peers_body()
389 1.1 riastrad {
390 1.1 riastrad local ifconfig="atf_check -s exit:0 rump.ifconfig"
391 1.1 riastrad local ping="atf_check -s exit:0 -o ignore rump.ping -n -i 0.1 -c 3 -w 1"
392 1.1 riastrad local ping_fail="atf_check -s not-exit:0 -o ignore rump.ping -n -c 1 -w 1"
393 1.1 riastrad local key_priv_peer2=
394 1.1 riastrad local key_pub_peer2=
395 1.1 riastrad local ip_local=192.168.1.1
396 1.1 riastrad local ip_peer=192.168.1.2
397 1.1 riastrad local ip_peer2=192.168.1.3
398 1.1 riastrad local ip_wg_local=10.0.0.1
399 1.1 riastrad local ip_wg_peer=10.0.0.2
400 1.1 riastrad local ip_wg_peer2=10.0.0.3
401 1.1 riastrad local port=51820
402 1.1 riastrad local outfile=./out
403 1.1 riastrad
404 1.1 riastrad setup_servers
405 1.1 riastrad rump_server_add_iface $SOCK_LOCAL shmif1 $BUS
406 1.1 riastrad
407 1.1 riastrad rump_server_crypto_start $SOCK_PEER2 netinet6 wg
408 1.1 riastrad rump_server_add_iface $SOCK_PEER2 shmif0 $BUS
409 1.1 riastrad
410 1.1 riastrad # It sets key_priv_local key_pub_local key_priv_peer key_pub_peer
411 1.1 riastrad generate_keys
412 1.1 riastrad key_priv_peer2=$(wg-keygen)
413 1.1 riastrad key_pub_peer2=$(echo $key_priv_peer2| wg-keygen --pub)
414 1.1 riastrad
415 1.1 riastrad export RUMP_SERVER=$SOCK_LOCAL
416 1.1 riastrad setup_common shmif0 inet $ip_local 24
417 1.1 riastrad setup_wg_common wg0 inet $ip_wg_local 24 $port "$key_priv_local"
418 1.1 riastrad
419 1.1 riastrad export RUMP_SERVER=$SOCK_PEER
420 1.1 riastrad setup_common shmif0 inet $ip_peer 24
421 1.1 riastrad setup_wg_common wg0 inet $ip_wg_peer 24 $port "$key_priv_peer"
422 1.1 riastrad
423 1.1 riastrad export RUMP_SERVER=$SOCK_PEER2
424 1.1 riastrad setup_common shmif0 inet $ip_peer2 24
425 1.1 riastrad setup_wg_common wg0 inet $ip_wg_peer2 24 $port "$key_priv_peer2"
426 1.1 riastrad
427 1.1 riastrad export RUMP_SERVER=$SOCK_LOCAL
428 1.1 riastrad add_peer wg0 peer0 $key_pub_peer $ip_peer:$port $ip_wg_peer/32
429 1.1 riastrad add_peer wg0 peer1 $key_pub_peer2 $ip_peer2:$port $ip_wg_peer2/32
430 1.1 riastrad
431 1.1 riastrad export RUMP_SERVER=$SOCK_PEER
432 1.1 riastrad add_peer wg0 peer0 $key_pub_local $ip_local:$port $ip_wg_local/32
433 1.1 riastrad
434 1.1 riastrad export RUMP_SERVER=$SOCK_PEER2
435 1.1 riastrad add_peer wg0 peer0 $key_pub_local $ip_local:$port $ip_wg_local/32
436 1.1 riastrad
437 1.1 riastrad export RUMP_SERVER=$SOCK_LOCAL
438 1.1 riastrad
439 1.1 riastrad extract_new_packets $BUS > $outfile
440 1.1 riastrad $DEBUG && cat $outfile
441 1.1 riastrad
442 1.1 riastrad $ping $ip_wg_peer
443 1.1 riastrad
444 1.1 riastrad extract_new_packets $BUS > $outfile
445 1.1 riastrad $DEBUG && cat $outfile
446 1.1 riastrad
447 1.1 riastrad $ping $ip_wg_peer2
448 1.1 riastrad
449 1.1 riastrad extract_new_packets $BUS > $outfile
450 1.1 riastrad $DEBUG && cat $outfile
451 1.1 riastrad
452 1.1 riastrad export RUMP_SERVER=$SOCK_LOCAL
453 1.1 riastrad $ifconfig wg0 destroy
454 1.1 riastrad export RUMP_SERVER=$SOCK_PEER
455 1.1 riastrad $ifconfig wg0 destroy
456 1.1 riastrad export RUMP_SERVER=$SOCK_PEER2
457 1.1 riastrad $ifconfig wg0 destroy
458 1.1 riastrad }
459 1.1 riastrad
460 1.1 riastrad wg_multiple_peers_cleanup()
461 1.1 riastrad {
462 1.1 riastrad
463 1.1 riastrad $DEBUG && dump
464 1.1 riastrad cleanup
465 1.1 riastrad }
466 1.1 riastrad
467 1.1 riastrad atf_init_test_cases()
468 1.1 riastrad {
469 1.1 riastrad
470 1.1 riastrad add_basic_test ipv4 ipv4
471 1.1 riastrad add_basic_test ipv4 ipv6
472 1.1 riastrad add_basic_test ipv6 ipv4
473 1.1 riastrad add_basic_test ipv6 ipv6
474 1.1 riastrad
475 1.1 riastrad add_payload_sizes_test ipv4 ipv4
476 1.1 riastrad add_payload_sizes_test ipv4 ipv6
477 1.1 riastrad add_payload_sizes_test ipv6 ipv4
478 1.1 riastrad add_payload_sizes_test ipv6 ipv6
479 1.1 riastrad
480 1.1 riastrad atf_add_test_case wg_create_destroy
481 1.1 riastrad atf_add_test_case wg_create_destroy_peers_ipv4
482 1.1 riastrad atf_add_test_case wg_create_destroy_peers_ipv6
483 1.1 riastrad atf_add_test_case wg_multiple_interfaces
484 1.1 riastrad atf_add_test_case wg_multiple_peers
485 1.1 riastrad }
486