1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4# End-to-end eBPF tunnel test suite
5#   The script tests BPF network tunnel implementation.
6#
7# Topology:
8# ---------
9#     root namespace   |     at_ns0 namespace
10#                      |
11#      -----------     |     -----------
12#      | tnl dev |     |     | tnl dev |  (overlay network)
13#      -----------     |     -----------
14#      metadata-mode   |     native-mode
15#       with bpf       |
16#                      |
17#      ----------      |     ----------
18#      |  veth1  | --------- |  veth0  |  (underlay network)
19#      ----------    peer    ----------
20#
21#
22# Device Configuration
23# --------------------
24# Root namespace with metadata-mode tunnel + BPF
25# Device names and addresses:
26# 	veth1 IP: 172.16.1.200, IPv6: 00::22 (underlay)
27# 	tunnel dev <type>11, ex: gre11, IPv4: 10.1.1.200, IPv6: 1::22 (overlay)
28#
29# Namespace at_ns0 with native tunnel
30# Device names and addresses:
31# 	veth0 IPv4: 172.16.1.100, IPv6: 00::11 (underlay)
32# 	tunnel dev <type>00, ex: gre00, IPv4: 10.1.1.100, IPv6: 1::11 (overlay)
33#
34#
35# End-to-end ping packet flow
36# ---------------------------
37# Most of the tests start by namespace creation, device configuration,
38# then ping the underlay and overlay network.  When doing 'ping 10.1.1.100'
39# from root namespace, the following operations happen:
40# 1) Route lookup shows 10.1.1.100/24 belongs to tnl dev, fwd to tnl dev.
41# 2) Tnl device's egress BPF program is triggered and set the tunnel metadata,
42#    with remote_ip=172.16.1.100 and others.
43# 3) Outer tunnel header is prepended and route the packet to veth1's egress
44# 4) veth0's ingress queue receive the tunneled packet at namespace at_ns0
45# 5) Tunnel protocol handler, ex: vxlan_rcv, decap the packet
46# 6) Forward the packet to the overlay tnl dev
47
48BPF_FILE="test_tunnel_kern.bpf.o"
49BPF_PIN_TUNNEL_DIR="/sys/fs/bpf/tc/tunnel"
50PING_ARG="-c 3 -w 10 -q"
51ret=0
52GREEN='\033[0;92m'
53RED='\033[0;31m'
54NC='\033[0m' # No Color
55
56config_device()
57{
58	ip netns add at_ns0
59	ip link add veth0 type veth peer name veth1
60	ip link set veth0 netns at_ns0
61	ip netns exec at_ns0 ip addr add 172.16.1.100/24 dev veth0
62	ip netns exec at_ns0 ip link set dev veth0 up
63	ip link set dev veth1 up mtu 1500
64	ip addr add dev veth1 172.16.1.200/24
65}
66
67add_gre_tunnel()
68{
69	# at_ns0 namespace
70	ip netns exec at_ns0 \
71        ip link add dev $DEV_NS type $TYPE seq key 2 \
72		local 172.16.1.100 remote 172.16.1.200
73	ip netns exec at_ns0 ip link set dev $DEV_NS up
74	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
75
76	# root namespace
77	ip link add dev $DEV type $TYPE key 2 external
78	ip link set dev $DEV up
79	ip addr add dev $DEV 10.1.1.200/24
80}
81
82add_ip6gretap_tunnel()
83{
84
85	# assign ipv6 address
86	ip netns exec at_ns0 ip addr add ::11/96 dev veth0
87	ip netns exec at_ns0 ip link set dev veth0 up
88	ip addr add dev veth1 ::22/96
89	ip link set dev veth1 up
90
91	# at_ns0 namespace
92	ip netns exec at_ns0 \
93		ip link add dev $DEV_NS type $TYPE seq flowlabel 0xbcdef key 2 \
94		local ::11 remote ::22
95
96	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
97	ip netns exec at_ns0 ip addr add dev $DEV_NS fc80::100/96
98	ip netns exec at_ns0 ip link set dev $DEV_NS up
99
100	# root namespace
101	ip link add dev $DEV type $TYPE external
102	ip addr add dev $DEV 10.1.1.200/24
103	ip addr add dev $DEV fc80::200/24
104	ip link set dev $DEV up
105}
106
107add_erspan_tunnel()
108{
109	# at_ns0 namespace
110	if [ "$1" == "v1" ]; then
111		ip netns exec at_ns0 \
112		ip link add dev $DEV_NS type $TYPE seq key 2 \
113		local 172.16.1.100 remote 172.16.1.200 \
114		erspan_ver 1 erspan 123
115	else
116		ip netns exec at_ns0 \
117		ip link add dev $DEV_NS type $TYPE seq key 2 \
118		local 172.16.1.100 remote 172.16.1.200 \
119		erspan_ver 2 erspan_dir egress erspan_hwid 3
120	fi
121	ip netns exec at_ns0 ip link set dev $DEV_NS up
122	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
123
124	# root namespace
125	ip link add dev $DEV type $TYPE external
126	ip link set dev $DEV up
127	ip addr add dev $DEV 10.1.1.200/24
128}
129
130add_ip6erspan_tunnel()
131{
132
133	# assign ipv6 address
134	ip netns exec at_ns0 ip addr add ::11/96 dev veth0
135	ip netns exec at_ns0 ip link set dev veth0 up
136	ip addr add dev veth1 ::22/96
137	ip link set dev veth1 up
138
139	# at_ns0 namespace
140	if [ "$1" == "v1" ]; then
141		ip netns exec at_ns0 \
142		ip link add dev $DEV_NS type $TYPE seq key 2 \
143		local ::11 remote ::22 \
144		erspan_ver 1 erspan 123
145	else
146		ip netns exec at_ns0 \
147		ip link add dev $DEV_NS type $TYPE seq key 2 \
148		local ::11 remote ::22 \
149		erspan_ver 2 erspan_dir egress erspan_hwid 7
150	fi
151	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
152	ip netns exec at_ns0 ip link set dev $DEV_NS up
153
154	# root namespace
155	ip link add dev $DEV type $TYPE external
156	ip addr add dev $DEV 10.1.1.200/24
157	ip link set dev $DEV up
158}
159
160add_geneve_tunnel()
161{
162	# at_ns0 namespace
163	ip netns exec at_ns0 \
164		ip link add dev $DEV_NS type $TYPE \
165		id 2 dstport 6081 remote 172.16.1.200
166	ip netns exec at_ns0 ip link set dev $DEV_NS up
167	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
168
169	# root namespace
170	ip link add dev $DEV type $TYPE dstport 6081 external
171	ip link set dev $DEV up
172	ip addr add dev $DEV 10.1.1.200/24
173}
174
175add_ip6geneve_tunnel()
176{
177	ip netns exec at_ns0 ip addr add ::11/96 dev veth0
178	ip netns exec at_ns0 ip link set dev veth0 up
179	ip addr add dev veth1 ::22/96
180	ip link set dev veth1 up
181
182	# at_ns0 namespace
183	ip netns exec at_ns0 \
184		ip link add dev $DEV_NS type $TYPE id 22 \
185		remote ::22     # geneve has no local option
186	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
187	ip netns exec at_ns0 ip link set dev $DEV_NS up
188
189	# root namespace
190	ip link add dev $DEV type $TYPE external
191	ip addr add dev $DEV 10.1.1.200/24
192	ip link set dev $DEV up
193}
194
195add_ipip_tunnel()
196{
197	# at_ns0 namespace
198	ip netns exec at_ns0 \
199		ip link add dev $DEV_NS type $TYPE \
200		local 172.16.1.100 remote 172.16.1.200
201	ip netns exec at_ns0 ip link set dev $DEV_NS up
202	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
203
204	# root namespace
205	ip link add dev $DEV type $TYPE external
206	ip link set dev $DEV up
207	ip addr add dev $DEV 10.1.1.200/24
208}
209
210add_ip6tnl_tunnel()
211{
212	ip netns exec at_ns0 ip addr add ::11/96 dev veth0
213	ip netns exec at_ns0 ip link set dev veth0 up
214	ip addr add dev veth1 ::22/96
215	ip link set dev veth1 up
216
217	# at_ns0 namespace
218	ip netns exec at_ns0 \
219		ip link add dev $DEV_NS type $TYPE \
220		local ::11 remote ::22
221	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
222	ip netns exec at_ns0 ip addr add dev $DEV_NS 1::11/96
223	ip netns exec at_ns0 ip link set dev $DEV_NS up
224
225	# root namespace
226	ip link add dev $DEV type $TYPE external
227	ip addr add dev $DEV 10.1.1.200/24
228	ip addr add dev $DEV 1::22/96
229	ip link set dev $DEV up
230}
231
232test_gre()
233{
234	TYPE=gretap
235	DEV_NS=gretap00
236	DEV=gretap11
237	ret=0
238
239	check $TYPE
240	config_device
241	add_gre_tunnel
242	attach_bpf $DEV gre_set_tunnel gre_get_tunnel
243	ping $PING_ARG 10.1.1.100
244	check_err $?
245	ip netns exec at_ns0 ping $PING_ARG 10.1.1.200
246	check_err $?
247	cleanup
248
249        if [ $ret -ne 0 ]; then
250                echo -e ${RED}"FAIL: $TYPE"${NC}
251                return 1
252        fi
253        echo -e ${GREEN}"PASS: $TYPE"${NC}
254}
255
256test_ip6gre()
257{
258	TYPE=ip6gre
259	DEV_NS=ip6gre00
260	DEV=ip6gre11
261	ret=0
262
263	check $TYPE
264	config_device
265	# reuse the ip6gretap function
266	add_ip6gretap_tunnel
267	attach_bpf $DEV ip6gretap_set_tunnel ip6gretap_get_tunnel
268	# underlay
269	ping6 $PING_ARG ::11
270	# overlay: ipv4 over ipv6
271	ip netns exec at_ns0 ping $PING_ARG 10.1.1.200
272	ping $PING_ARG 10.1.1.100
273	check_err $?
274	# overlay: ipv6 over ipv6
275	ip netns exec at_ns0 ping6 $PING_ARG fc80::200
276	check_err $?
277	cleanup
278
279        if [ $ret -ne 0 ]; then
280                echo -e ${RED}"FAIL: $TYPE"${NC}
281                return 1
282        fi
283        echo -e ${GREEN}"PASS: $TYPE"${NC}
284}
285
286test_ip6gretap()
287{
288	TYPE=ip6gretap
289	DEV_NS=ip6gretap00
290	DEV=ip6gretap11
291	ret=0
292
293	check $TYPE
294	config_device
295	add_ip6gretap_tunnel
296	attach_bpf $DEV ip6gretap_set_tunnel ip6gretap_get_tunnel
297	# underlay
298	ping6 $PING_ARG ::11
299	# overlay: ipv4 over ipv6
300	ip netns exec at_ns0 ping $PING_ARG 10.1.1.200
301	ping $PING_ARG 10.1.1.100
302	check_err $?
303	# overlay: ipv6 over ipv6
304	ip netns exec at_ns0 ping6 $PING_ARG fc80::200
305	check_err $?
306	cleanup
307
308	if [ $ret -ne 0 ]; then
309                echo -e ${RED}"FAIL: $TYPE"${NC}
310                return 1
311        fi
312        echo -e ${GREEN}"PASS: $TYPE"${NC}
313}
314
315test_erspan()
316{
317	TYPE=erspan
318	DEV_NS=erspan00
319	DEV=erspan11
320	ret=0
321
322	check $TYPE
323	config_device
324	add_erspan_tunnel $1
325	attach_bpf $DEV erspan_set_tunnel erspan_get_tunnel
326	ping $PING_ARG 10.1.1.100
327	check_err $?
328	ip netns exec at_ns0 ping $PING_ARG 10.1.1.200
329	check_err $?
330	cleanup
331
332	if [ $ret -ne 0 ]; then
333                echo -e ${RED}"FAIL: $TYPE"${NC}
334                return 1
335        fi
336        echo -e ${GREEN}"PASS: $TYPE"${NC}
337}
338
339test_ip6erspan()
340{
341	TYPE=ip6erspan
342	DEV_NS=ip6erspan00
343	DEV=ip6erspan11
344	ret=0
345
346	check $TYPE
347	config_device
348	add_ip6erspan_tunnel $1
349	attach_bpf $DEV ip4ip6erspan_set_tunnel ip4ip6erspan_get_tunnel
350	ping6 $PING_ARG ::11
351	ip netns exec at_ns0 ping $PING_ARG 10.1.1.200
352	check_err $?
353	cleanup
354
355	if [ $ret -ne 0 ]; then
356                echo -e ${RED}"FAIL: $TYPE"${NC}
357                return 1
358        fi
359        echo -e ${GREEN}"PASS: $TYPE"${NC}
360}
361
362test_geneve()
363{
364	TYPE=geneve
365	DEV_NS=geneve00
366	DEV=geneve11
367	ret=0
368
369	check $TYPE
370	config_device
371	add_geneve_tunnel
372	attach_bpf $DEV geneve_set_tunnel geneve_get_tunnel
373	ping $PING_ARG 10.1.1.100
374	check_err $?
375	ip netns exec at_ns0 ping $PING_ARG 10.1.1.200
376	check_err $?
377	cleanup
378
379	if [ $ret -ne 0 ]; then
380                echo -e ${RED}"FAIL: $TYPE"${NC}
381                return 1
382        fi
383        echo -e ${GREEN}"PASS: $TYPE"${NC}
384}
385
386test_ip6geneve()
387{
388	TYPE=geneve
389	DEV_NS=ip6geneve00
390	DEV=ip6geneve11
391	ret=0
392
393	check $TYPE
394	config_device
395	add_ip6geneve_tunnel
396	attach_bpf $DEV ip6geneve_set_tunnel ip6geneve_get_tunnel
397	ping $PING_ARG 10.1.1.100
398	check_err $?
399	ip netns exec at_ns0 ping $PING_ARG 10.1.1.200
400	check_err $?
401	cleanup
402
403	if [ $ret -ne 0 ]; then
404                echo -e ${RED}"FAIL: ip6$TYPE"${NC}
405                return 1
406        fi
407        echo -e ${GREEN}"PASS: ip6$TYPE"${NC}
408}
409
410test_ipip()
411{
412	TYPE=ipip
413	DEV_NS=ipip00
414	DEV=ipip11
415	ret=0
416
417	check $TYPE
418	config_device
419	add_ipip_tunnel
420	ip link set dev veth1 mtu 1500
421	attach_bpf $DEV ipip_set_tunnel ipip_get_tunnel
422	ping $PING_ARG 10.1.1.100
423	check_err $?
424	ip netns exec at_ns0 ping $PING_ARG 10.1.1.200
425	check_err $?
426	cleanup
427
428	if [ $ret -ne 0 ]; then
429                echo -e ${RED}"FAIL: $TYPE"${NC}
430                return 1
431        fi
432        echo -e ${GREEN}"PASS: $TYPE"${NC}
433}
434
435test_ipip6()
436{
437	TYPE=ip6tnl
438	DEV_NS=ipip6tnl00
439	DEV=ipip6tnl11
440	ret=0
441
442	check $TYPE
443	config_device
444	add_ip6tnl_tunnel
445	ip link set dev veth1 mtu 1500
446	attach_bpf $DEV ipip6_set_tunnel ipip6_get_tunnel
447	# underlay
448	ping6 $PING_ARG ::11
449	# ip4 over ip6
450	ping $PING_ARG 10.1.1.100
451	check_err $?
452	ip netns exec at_ns0 ping $PING_ARG 10.1.1.200
453	check_err $?
454	cleanup
455
456	if [ $ret -ne 0 ]; then
457                echo -e ${RED}"FAIL: $TYPE"${NC}
458                return 1
459        fi
460        echo -e ${GREEN}"PASS: $TYPE"${NC}
461}
462
463test_ip6ip6()
464{
465	TYPE=ip6tnl
466	DEV_NS=ip6ip6tnl00
467	DEV=ip6ip6tnl11
468	ret=0
469
470	check $TYPE
471	config_device
472	add_ip6tnl_tunnel
473	ip link set dev veth1 mtu 1500
474	attach_bpf $DEV ip6ip6_set_tunnel ip6ip6_get_tunnel
475	# underlay
476	ping6 $PING_ARG ::11
477	# ip6 over ip6
478	ping6 $PING_ARG 1::11
479	check_err $?
480	ip netns exec at_ns0 ping6 $PING_ARG 1::22
481	check_err $?
482	cleanup
483
484	if [ $ret -ne 0 ]; then
485                echo -e ${RED}"FAIL: ip6$TYPE"${NC}
486                return 1
487        fi
488        echo -e ${GREEN}"PASS: ip6$TYPE"${NC}
489}
490
491setup_xfrm_tunnel()
492{
493	auth=0x$(printf '1%.0s' {1..40})
494	enc=0x$(printf '2%.0s' {1..32})
495	spi_in_to_out=0x1
496	spi_out_to_in=0x2
497	# at_ns0 namespace
498	# at_ns0 -> root
499	ip netns exec at_ns0 \
500		ip xfrm state add src 172.16.1.100 dst 172.16.1.200 proto esp \
501			spi $spi_in_to_out reqid 1 mode tunnel \
502			auth-trunc 'hmac(sha1)' $auth 96 enc 'cbc(aes)' $enc
503	ip netns exec at_ns0 \
504		ip xfrm policy add src 10.1.1.100/32 dst 10.1.1.200/32 dir out \
505		tmpl src 172.16.1.100 dst 172.16.1.200 proto esp reqid 1 \
506		mode tunnel
507	# root -> at_ns0
508	ip netns exec at_ns0 \
509		ip xfrm state add src 172.16.1.200 dst 172.16.1.100 proto esp \
510			spi $spi_out_to_in reqid 2 mode tunnel \
511			auth-trunc 'hmac(sha1)' $auth 96 enc 'cbc(aes)' $enc
512	ip netns exec at_ns0 \
513		ip xfrm policy add src 10.1.1.200/32 dst 10.1.1.100/32 dir in \
514		tmpl src 172.16.1.200 dst 172.16.1.100 proto esp reqid 2 \
515		mode tunnel
516	# address & route
517	ip netns exec at_ns0 \
518		ip addr add dev veth0 10.1.1.100/32
519	ip netns exec at_ns0 \
520		ip route add 10.1.1.200 dev veth0 via 172.16.1.200 \
521			src 10.1.1.100
522
523	# root namespace
524	# at_ns0 -> root
525	ip xfrm state add src 172.16.1.100 dst 172.16.1.200 proto esp \
526		spi $spi_in_to_out reqid 1 mode tunnel \
527		auth-trunc 'hmac(sha1)' $auth 96  enc 'cbc(aes)' $enc
528	ip xfrm policy add src 10.1.1.100/32 dst 10.1.1.200/32 dir in \
529		tmpl src 172.16.1.100 dst 172.16.1.200 proto esp reqid 1 \
530		mode tunnel
531	# root -> at_ns0
532	ip xfrm state add src 172.16.1.200 dst 172.16.1.100 proto esp \
533		spi $spi_out_to_in reqid 2 mode tunnel \
534		auth-trunc 'hmac(sha1)' $auth 96  enc 'cbc(aes)' $enc
535	ip xfrm policy add src 10.1.1.200/32 dst 10.1.1.100/32 dir out \
536		tmpl src 172.16.1.200 dst 172.16.1.100 proto esp reqid 2 \
537		mode tunnel
538	# address & route
539	ip addr add dev veth1 10.1.1.200/32
540	ip route add 10.1.1.100 dev veth1 via 172.16.1.100 src 10.1.1.200
541}
542
543test_xfrm_tunnel()
544{
545	config_device
546	> /sys/kernel/debug/tracing/trace
547	setup_xfrm_tunnel
548	mkdir -p ${BPF_PIN_TUNNEL_DIR}
549	bpftool prog loadall ${BPF_FILE} ${BPF_PIN_TUNNEL_DIR}
550	tc qdisc add dev veth1 clsact
551	tc filter add dev veth1 proto ip ingress bpf da object-pinned \
552		${BPF_PIN_TUNNEL_DIR}/xfrm_get_state
553	ip netns exec at_ns0 ping $PING_ARG 10.1.1.200
554	sleep 1
555	grep "reqid 1" /sys/kernel/debug/tracing/trace
556	check_err $?
557	grep "spi 0x1" /sys/kernel/debug/tracing/trace
558	check_err $?
559	grep "remote ip 0xac100164" /sys/kernel/debug/tracing/trace
560	check_err $?
561	cleanup
562
563	if [ $ret -ne 0 ]; then
564		echo -e ${RED}"FAIL: xfrm tunnel"${NC}
565		return 1
566	fi
567	echo -e ${GREEN}"PASS: xfrm tunnel"${NC}
568}
569
570attach_bpf()
571{
572	DEV=$1
573	SET=$2
574	GET=$3
575	mkdir -p ${BPF_PIN_TUNNEL_DIR}
576	bpftool prog loadall ${BPF_FILE} ${BPF_PIN_TUNNEL_DIR}/
577	tc qdisc add dev $DEV clsact
578	tc filter add dev $DEV egress bpf da object-pinned ${BPF_PIN_TUNNEL_DIR}/$SET
579	tc filter add dev $DEV ingress bpf da object-pinned ${BPF_PIN_TUNNEL_DIR}/$GET
580}
581
582cleanup()
583{
584        rm -rf ${BPF_PIN_TUNNEL_DIR}
585
586	ip netns delete at_ns0 2> /dev/null
587	ip link del veth1 2> /dev/null
588	ip link del ipip11 2> /dev/null
589	ip link del ipip6tnl11 2> /dev/null
590	ip link del ip6ip6tnl11 2> /dev/null
591	ip link del gretap11 2> /dev/null
592	ip link del ip6gre11 2> /dev/null
593	ip link del ip6gretap11 2> /dev/null
594	ip link del geneve11 2> /dev/null
595	ip link del ip6geneve11 2> /dev/null
596	ip link del erspan11 2> /dev/null
597	ip link del ip6erspan11 2> /dev/null
598	ip xfrm policy delete dir out src 10.1.1.200/32 dst 10.1.1.100/32 2> /dev/null
599	ip xfrm policy delete dir in src 10.1.1.100/32 dst 10.1.1.200/32 2> /dev/null
600	ip xfrm state delete src 172.16.1.100 dst 172.16.1.200 proto esp spi 0x1 2> /dev/null
601	ip xfrm state delete src 172.16.1.200 dst 172.16.1.100 proto esp spi 0x2 2> /dev/null
602}
603
604cleanup_exit()
605{
606	echo "CATCH SIGKILL or SIGINT, cleanup and exit"
607	cleanup
608	exit 0
609}
610
611check()
612{
613	ip link help 2>&1 | grep -q "\s$1\s"
614	if [ $? -ne 0 ];then
615		echo "SKIP $1: iproute2 not support"
616	cleanup
617	return 1
618	fi
619}
620
621enable_debug()
622{
623	echo 'file ip_gre.c +p' > /sys/kernel/debug/dynamic_debug/control
624	echo 'file ip6_gre.c +p' > /sys/kernel/debug/dynamic_debug/control
625	echo 'file geneve.c +p' > /sys/kernel/debug/dynamic_debug/control
626	echo 'file ipip.c +p' > /sys/kernel/debug/dynamic_debug/control
627}
628
629check_err()
630{
631	if [ $ret -eq 0 ]; then
632		ret=$1
633	fi
634}
635
636bpf_tunnel_test()
637{
638	local errors=0
639
640	echo "Testing GRE tunnel..."
641	test_gre
642	errors=$(( $errors + $? ))
643
644	echo "Testing IP6GRE tunnel..."
645	test_ip6gre
646	errors=$(( $errors + $? ))
647
648	echo "Testing IP6GRETAP tunnel..."
649	test_ip6gretap
650	errors=$(( $errors + $? ))
651
652	echo "Testing ERSPAN tunnel..."
653	test_erspan v2
654	errors=$(( $errors + $? ))
655
656	echo "Testing IP6ERSPAN tunnel..."
657	test_ip6erspan v2
658	errors=$(( $errors + $? ))
659
660	echo "Testing GENEVE tunnel..."
661	test_geneve
662	errors=$(( $errors + $? ))
663
664	echo "Testing IP6GENEVE tunnel..."
665	test_ip6geneve
666	errors=$(( $errors + $? ))
667
668	echo "Testing IPIP tunnel..."
669	test_ipip
670	errors=$(( $errors + $? ))
671
672	echo "Testing IPIP6 tunnel..."
673	test_ipip6
674	errors=$(( $errors + $? ))
675
676	echo "Testing IP6IP6 tunnel..."
677	test_ip6ip6
678	errors=$(( $errors + $? ))
679
680	echo "Testing IPSec tunnel..."
681	test_xfrm_tunnel
682	errors=$(( $errors + $? ))
683
684	return $errors
685}
686
687trap cleanup 0 3 6
688trap cleanup_exit 2 9
689
690cleanup
691bpf_tunnel_test
692
693if [ $? -ne 0 ]; then
694	echo -e "$(basename $0): ${RED}FAIL${NC}"
695	exit 1
696fi
697echo -e "$(basename $0): ${GREEN}PASS${NC}"
698exit 0
699