xref: /freebsd/tests/sys/net/if_wg.sh (revision c0f13232410cf881475d6e4dbd0ec28ab3476c59)
18fb97396SJohn Baldwin#
24d846d26SWarner Losh# SPDX-License-Identifier: BSD-2-Clause
38fb97396SJohn Baldwin#
48fb97396SJohn Baldwin# Copyright (c) 2021 The FreeBSD Foundation
58fb97396SJohn Baldwin#
68fb97396SJohn Baldwin# This software was developed by Mark Johnston under sponsorship
78fb97396SJohn Baldwin# from the FreeBSD Foundation.
88fb97396SJohn Baldwin#
98fb97396SJohn Baldwin# Redistribution and use in source and binary forms, with or without
108fb97396SJohn Baldwin# modification, are permitted provided that the following conditions
118fb97396SJohn Baldwin# are met:
128fb97396SJohn Baldwin# 1. Redistributions of source code must retain the above copyright
138fb97396SJohn Baldwin#    notice, this list of conditions and the following disclaimer.
148fb97396SJohn Baldwin# 2. Redistributions in binary form must reproduce the above copyright
158fb97396SJohn Baldwin#    notice, this list of conditions and the following disclaimer in the
168fb97396SJohn Baldwin#    documentation and/or other materials provided with the distribution.
178fb97396SJohn Baldwin#
188fb97396SJohn Baldwin# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
198fb97396SJohn Baldwin# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
208fb97396SJohn Baldwin# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
218fb97396SJohn Baldwin# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
228fb97396SJohn Baldwin# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
238fb97396SJohn Baldwin# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
248fb97396SJohn Baldwin# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
258fb97396SJohn Baldwin# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
268fb97396SJohn Baldwin# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
278fb97396SJohn Baldwin# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
288fb97396SJohn Baldwin# SUCH DAMAGE.
298fb97396SJohn Baldwin
308fb97396SJohn Baldwin. $(atf_get_srcdir)/../common/vnet.subr
318fb97396SJohn Baldwin
328fb97396SJohn Baldwinatf_test_case "wg_basic" "cleanup"
338fb97396SJohn Baldwinwg_basic_head()
348fb97396SJohn Baldwin{
358fb97396SJohn Baldwin	atf_set descr 'Create a wg(4) tunnel over an epair and pass traffic between jails'
368fb97396SJohn Baldwin	atf_set require.user root
378fb97396SJohn Baldwin}
388fb97396SJohn Baldwin
398fb97396SJohn Baldwinwg_basic_body()
408fb97396SJohn Baldwin{
418fb97396SJohn Baldwin	local epair pri1 pri2 pub1 pub2 wg1 wg2
428fb97396SJohn Baldwin        local endpoint1 endpoint2 tunnel1 tunnel2
438fb97396SJohn Baldwin
44d22c5c42SOlivier Cochard	kldload -n if_wg || atf_skip "This test requires if_wg and could not load it"
458fb97396SJohn Baldwin
468fb97396SJohn Baldwin	pri1=$(wg genkey)
478fb97396SJohn Baldwin	pri2=$(wg genkey)
488fb97396SJohn Baldwin
498fb97396SJohn Baldwin	endpoint1=192.168.2.1
508fb97396SJohn Baldwin	endpoint2=192.168.2.2
518fb97396SJohn Baldwin	tunnel1=169.254.0.1
528fb97396SJohn Baldwin	tunnel2=169.254.0.2
538fb97396SJohn Baldwin
548fb97396SJohn Baldwin	epair=$(vnet_mkepair)
558fb97396SJohn Baldwin
568fb97396SJohn Baldwin	vnet_init
578fb97396SJohn Baldwin
588fb97396SJohn Baldwin	vnet_mkjail wgtest1 ${epair}a
598fb97396SJohn Baldwin	vnet_mkjail wgtest2 ${epair}b
608fb97396SJohn Baldwin
618fb97396SJohn Baldwin	jexec wgtest1 ifconfig ${epair}a ${endpoint1}/24 up
628fb97396SJohn Baldwin	jexec wgtest2 ifconfig ${epair}b ${endpoint2}/24 up
638fb97396SJohn Baldwin
648fb97396SJohn Baldwin	wg1=$(jexec wgtest1 ifconfig wg create)
658fb97396SJohn Baldwin	echo "$pri1" | jexec wgtest1 wg set $wg1 listen-port 12345 \
668fb97396SJohn Baldwin	    private-key /dev/stdin
678fb97396SJohn Baldwin	pub1=$(jexec wgtest1 wg show $wg1 public-key)
688fb97396SJohn Baldwin	wg2=$(jexec wgtest2 ifconfig wg create)
698fb97396SJohn Baldwin	echo "$pri2" | jexec wgtest2 wg set $wg2 listen-port 12345 \
708fb97396SJohn Baldwin	    private-key /dev/stdin
718fb97396SJohn Baldwin	pub2=$(jexec wgtest2 wg show $wg2 public-key)
728fb97396SJohn Baldwin
738fb97396SJohn Baldwin	atf_check -s exit:0 -o ignore \
748fb97396SJohn Baldwin	    jexec wgtest1 wg set $wg1 peer "$pub2" \
758fb97396SJohn Baldwin	    endpoint ${endpoint2}:12345 allowed-ips ${tunnel2}/32
768fb97396SJohn Baldwin	atf_check -s exit:0 \
778fb97396SJohn Baldwin	    jexec wgtest1 ifconfig $wg1 inet ${tunnel1}/24 up
788fb97396SJohn Baldwin
798fb97396SJohn Baldwin	atf_check -s exit:0 -o ignore \
808fb97396SJohn Baldwin	    jexec wgtest2 wg set $wg2 peer "$pub1" \
818fb97396SJohn Baldwin	    endpoint ${endpoint1}:12345 allowed-ips ${tunnel1}/32
828fb97396SJohn Baldwin	atf_check -s exit:0 \
838fb97396SJohn Baldwin	    jexec wgtest2 ifconfig $wg2 inet ${tunnel2}/24 up
848fb97396SJohn Baldwin
858fb97396SJohn Baldwin	# Generous timeout since the handshake takes some time.
868fb97396SJohn Baldwin	atf_check -s exit:0 -o ignore jexec wgtest1 ping -c 1 -t 5 $tunnel2
878fb97396SJohn Baldwin	atf_check -s exit:0 -o ignore jexec wgtest2 ping -c 1 $tunnel1
888fb97396SJohn Baldwin}
898fb97396SJohn Baldwin
908fb97396SJohn Baldwinwg_basic_cleanup()
918fb97396SJohn Baldwin{
928fb97396SJohn Baldwin	vnet_cleanup
938fb97396SJohn Baldwin}
948fb97396SJohn Baldwin
95*c0f13232SMark Johnstonatf_test_case "wg_basic_netmap" "cleanup"
96*c0f13232SMark Johnstonwg_basic_netmap_head()
97*c0f13232SMark Johnston{
98*c0f13232SMark Johnston	atf_set descr 'Create a wg(4) tunnel over an epair and pass traffic between jails with netmap'
99*c0f13232SMark Johnston	atf_set require.user root
100*c0f13232SMark Johnston}
101*c0f13232SMark Johnston
102*c0f13232SMark Johnstonwg_basic_netmap_body()
103*c0f13232SMark Johnston{
104*c0f13232SMark Johnston	local epair pri1 pri2 pub1 pub2 wg1 wg2
105*c0f13232SMark Johnston        local endpoint1 endpoint2 tunnel1 tunnel2 tunnel3 tunnel4
106*c0f13232SMark Johnston	local pid status
107*c0f13232SMark Johnston
108*c0f13232SMark Johnston	kldload -n if_wg || atf_skip "This test requires if_wg and could not load it"
109*c0f13232SMark Johnston	kldload -n netmap || atf_skip "This test requires netmap and could not load it"
110*c0f13232SMark Johnston
111*c0f13232SMark Johnston	pri1=$(wg genkey)
112*c0f13232SMark Johnston	pri2=$(wg genkey)
113*c0f13232SMark Johnston
114*c0f13232SMark Johnston	endpoint1=192.168.2.1
115*c0f13232SMark Johnston	endpoint2=192.168.2.2
116*c0f13232SMark Johnston	tunnel1=192.168.3.1
117*c0f13232SMark Johnston	tunnel2=192.168.3.2
118*c0f13232SMark Johnston	tunnel3=192.168.3.3
119*c0f13232SMark Johnston	tunnel4=192.168.3.4
120*c0f13232SMark Johnston
121*c0f13232SMark Johnston	epair=$(vnet_mkepair)
122*c0f13232SMark Johnston
123*c0f13232SMark Johnston	vnet_init
124*c0f13232SMark Johnston
125*c0f13232SMark Johnston	vnet_mkjail wgtest1 ${epair}a
126*c0f13232SMark Johnston	vnet_mkjail wgtest2 ${epair}b
127*c0f13232SMark Johnston
128*c0f13232SMark Johnston	jexec wgtest1 ifconfig ${epair}a ${endpoint1}/24 up
129*c0f13232SMark Johnston	jexec wgtest2 ifconfig ${epair}b ${endpoint2}/24 up
130*c0f13232SMark Johnston
131*c0f13232SMark Johnston	wg1=$(jexec wgtest1 ifconfig wg create)
132*c0f13232SMark Johnston	echo "$pri1" | jexec wgtest1 wg set $wg1 listen-port 12345 \
133*c0f13232SMark Johnston	    private-key /dev/stdin
134*c0f13232SMark Johnston	pub1=$(jexec wgtest1 wg show $wg1 public-key)
135*c0f13232SMark Johnston	wg2=$(jexec wgtest2 ifconfig wg create)
136*c0f13232SMark Johnston	echo "$pri2" | jexec wgtest2 wg set $wg2 listen-port 12345 \
137*c0f13232SMark Johnston	    private-key /dev/stdin
138*c0f13232SMark Johnston	pub2=$(jexec wgtest2 wg show $wg2 public-key)
139*c0f13232SMark Johnston
140*c0f13232SMark Johnston	atf_check -s exit:0 -o ignore \
141*c0f13232SMark Johnston	    jexec wgtest1 wg set $wg1 peer "$pub2" \
142*c0f13232SMark Johnston	    endpoint ${endpoint2}:12345 allowed-ips ${tunnel2}/32,${tunnel4}/32
143*c0f13232SMark Johnston	atf_check -s exit:0 \
144*c0f13232SMark Johnston	    jexec wgtest1 ifconfig $wg1 inet ${tunnel1}/24 up
145*c0f13232SMark Johnston
146*c0f13232SMark Johnston	atf_check -s exit:0 -o ignore \
147*c0f13232SMark Johnston	    jexec wgtest2 wg set $wg2 peer "$pub1" \
148*c0f13232SMark Johnston	    endpoint ${endpoint1}:12345 allowed-ips ${tunnel1}/32,${tunnel3}/32
149*c0f13232SMark Johnston	atf_check -s exit:0 \
150*c0f13232SMark Johnston	    jexec wgtest2 ifconfig $wg2 inet ${tunnel2}/24 up
151*c0f13232SMark Johnston
152*c0f13232SMark Johnston	atf_check -s exit:0 -o ignore \
153*c0f13232SMark Johnston	    jexec wgtest1 sysctl net.inet.ip.forwarding=1
154*c0f13232SMark Johnston	atf_check -s exit:0 -o ignore \
155*c0f13232SMark Johnston	    jexec wgtest2 sysctl net.inet.ip.forwarding=1
156*c0f13232SMark Johnston
157*c0f13232SMark Johnston	jexec wgtest1 $(atf_get_srcdir)/bridge -w 0 -i netmap:wg0 -i netmap:wg0^ &
158*c0f13232SMark Johnston	pid=$!
159*c0f13232SMark Johnston
160*c0f13232SMark Johnston	# Generous timeout since the handshake takes some time.
161*c0f13232SMark Johnston	atf_check -s exit:0 -o ignore jexec wgtest1 ping -c 1 -t 5 $tunnel2
162*c0f13232SMark Johnston	atf_check -s exit:0 -o ignore jexec wgtest2 ping -c 1 $tunnel1
163*c0f13232SMark Johnston
164*c0f13232SMark Johnston	# Verify that we cannot ping non-existent tunnel addresses.  In general
165*c0f13232SMark Johnston	# the remote side should respond with an ICMP message.
166*c0f13232SMark Johnston	atf_check -s exit:2 -o ignore jexec wgtest1 ping -c 1 -t 2 $tunnel4
167*c0f13232SMark Johnston	atf_check -s exit:2 -o ignore jexec wgtest2 ping -c 1 -t 2 $tunnel3
168*c0f13232SMark Johnston
169*c0f13232SMark Johnston	# Make sure that the bridge is still functional.
170*c0f13232SMark Johnston	atf_check -s exit:0 -o ignore jexec wgtest1 ping -c 1 $tunnel2
171*c0f13232SMark Johnston	atf_check -s exit:0 -o ignore jexec wgtest2 ping -c 1 $tunnel1
172*c0f13232SMark Johnston
173*c0f13232SMark Johnston	atf_check -s exit:0 kill -TERM $pid
174*c0f13232SMark Johnston	wait $pid
175*c0f13232SMark Johnston	status=$?
176*c0f13232SMark Johnston
177*c0f13232SMark Johnston	# Make sure that SIGTERM was received and handled.
178*c0f13232SMark Johnston	atf_check_equal $status 143
179*c0f13232SMark Johnston}
180*c0f13232SMark Johnston
181*c0f13232SMark Johnstonwg_basic_netmap_cleanup()
182*c0f13232SMark Johnston{
183*c0f13232SMark Johnston	vnet_cleanup
184*c0f13232SMark Johnston}
185*c0f13232SMark Johnston
1868fb97396SJohn Baldwin# The kernel is expected to silently ignore any attempt to add a peer with a
1878fb97396SJohn Baldwin# public key identical to the host's.
1888fb97396SJohn Baldwinatf_test_case "wg_key_peerdev_shared" "cleanup"
1898fb97396SJohn Baldwinwg_key_peerdev_shared_head()
1908fb97396SJohn Baldwin{
1918fb97396SJohn Baldwin	atf_set descr 'Create a wg(4) interface with a shared pubkey between device and a peer'
1928fb97396SJohn Baldwin	atf_set require.user root
1938fb97396SJohn Baldwin}
1948fb97396SJohn Baldwin
1958fb97396SJohn Baldwinwg_key_peerdev_shared_body()
1968fb97396SJohn Baldwin{
1978fb97396SJohn Baldwin	local epair pri1 pub1 wg1
1988fb97396SJohn Baldwin        local endpoint1 tunnel1
1998fb97396SJohn Baldwin
200d22c5c42SOlivier Cochard	kldload -n if_wg || atf_skip "This test requires if_wg and could not load it"
2018fb97396SJohn Baldwin
2028fb97396SJohn Baldwin	pri1=$(wg genkey)
2038fb97396SJohn Baldwin
2048fb97396SJohn Baldwin	endpoint1=192.168.2.1
2058fb97396SJohn Baldwin	tunnel1=169.254.0.1
2068fb97396SJohn Baldwin
2078fb97396SJohn Baldwin	vnet_mkjail wgtest1
2088fb97396SJohn Baldwin
2098fb97396SJohn Baldwin	wg1=$(jexec wgtest1 ifconfig wg create)
2108fb97396SJohn Baldwin	echo "$pri1" | jexec wgtest1 wg set $wg1 listen-port 12345 \
2118fb97396SJohn Baldwin	    private-key /dev/stdin
2128fb97396SJohn Baldwin	pub1=$(jexec wgtest1 wg show $wg1 public-key)
2138fb97396SJohn Baldwin
2148fb97396SJohn Baldwin	atf_check -s exit:0 \
2158fb97396SJohn Baldwin	    jexec wgtest1 wg set ${wg1} peer "${pub1}" \
2168fb97396SJohn Baldwin	    allowed-ips "${tunnel1}/32"
2178fb97396SJohn Baldwin
2188fb97396SJohn Baldwin	atf_check -o empty jexec wgtest1 wg show ${wg1} peers
2198fb97396SJohn Baldwin}
2208fb97396SJohn Baldwin
2218fb97396SJohn Baldwinwg_key_peerdev_shared_cleanup()
2228fb97396SJohn Baldwin{
2238fb97396SJohn Baldwin	vnet_cleanup
2248fb97396SJohn Baldwin}
2258fb97396SJohn Baldwin
2268fb97396SJohn Baldwin# When a wg(8) interface has a private key reassigned that corresponds to the
2278fb97396SJohn Baldwin# public key already on a peer, the kernel is expected to deconfigure the peer
2288fb97396SJohn Baldwin# to resolve the conflict.
2298fb97396SJohn Baldwinatf_test_case "wg_key_peerdev_makeshared" "cleanup"
2308fb97396SJohn Baldwinwg_key_peerdev_makeshared_head()
2318fb97396SJohn Baldwin{
2328fb97396SJohn Baldwin	atf_set descr 'Create a wg(4) interface and assign peer key to device'
2338fb97396SJohn Baldwin	atf_set require.progs wg
2348fb97396SJohn Baldwin}
2358fb97396SJohn Baldwin
2368fb97396SJohn Baldwinwg_key_peerdev_makeshared_body()
2378fb97396SJohn Baldwin{
2388fb97396SJohn Baldwin	local epair pri1 pub1 pri2 wg1 wg2
2398fb97396SJohn Baldwin        local endpoint1 tunnel1
2408fb97396SJohn Baldwin
241d22c5c42SOlivier Cochard	kldload -n if_wg || atf_skip "This test requires if_wg and could not load it"
2428fb97396SJohn Baldwin
2438fb97396SJohn Baldwin	pri1=$(wg genkey)
2448fb97396SJohn Baldwin	pri2=$(wg genkey)
2458fb97396SJohn Baldwin
2468fb97396SJohn Baldwin	endpoint1=192.168.2.1
2478fb97396SJohn Baldwin	tunnel1=169.254.0.1
2488fb97396SJohn Baldwin
2498fb97396SJohn Baldwin	vnet_mkjail wgtest1
2508fb97396SJohn Baldwin
2518fb97396SJohn Baldwin	wg1=$(jexec wgtest1 ifconfig wg create)
2528fb97396SJohn Baldwin	echo "$pri1" | jexec wgtest1 wg set $wg1 listen-port 12345 \
2538fb97396SJohn Baldwin	    private-key /dev/stdin
2548fb97396SJohn Baldwin	pub1=$(jexec wgtest1 wg show $wg1 public-key)
2558fb97396SJohn Baldwin	wg2=$(jexec wgtest1 ifconfig wg create)
2568fb97396SJohn Baldwin	echo "$pri2" | jexec wgtest1 wg set $wg2 listen-port 12345 \
2578fb97396SJohn Baldwin	    private-key /dev/stdin
2588fb97396SJohn Baldwin
2598fb97396SJohn Baldwin	atf_check -s exit:0 -o ignore \
2608fb97396SJohn Baldwin	    jexec wgtest1 wg set ${wg2} peer "${pub1}" \
2618fb97396SJohn Baldwin	    allowed-ips "${tunnel1}/32"
2628fb97396SJohn Baldwin
2638fb97396SJohn Baldwin	atf_check -o not-empty jexec wgtest1 wg show ${wg2} peers
2648fb97396SJohn Baldwin
2658fb97396SJohn Baldwin	jexec wgtest1 sh -c "echo '${pri1}' > pri1"
2668fb97396SJohn Baldwin
2678fb97396SJohn Baldwin	atf_check -s exit:0 \
2688fb97396SJohn Baldwin	   jexec wgtest1 wg set ${wg2} private-key pri1
2698fb97396SJohn Baldwin
2708fb97396SJohn Baldwin	atf_check -o empty jexec wgtest1 wg show ${wg2} peers
2718fb97396SJohn Baldwin}
2728fb97396SJohn Baldwin
2738fb97396SJohn Baldwinwg_key_peerdev_makeshared_cleanup()
2748fb97396SJohn Baldwin{
2758fb97396SJohn Baldwin	vnet_cleanup
2768fb97396SJohn Baldwin}
2778fb97396SJohn Baldwin
27896f4ab26SKyle Evans# The kernel is expected to create the wg socket in the jail context that the
27996f4ab26SKyle Evans# wg interface was created in, even if the interface is moved to a different
28096f4ab26SKyle Evans# vnet.
28196f4ab26SKyle Evansatf_test_case "wg_vnet_parent_routing" "cleanup"
28296f4ab26SKyle Evanswg_vnet_parent_routing_head()
28396f4ab26SKyle Evans{
28496f4ab26SKyle Evans	atf_set descr 'Create a wg(4) tunnel without epairs and pass traffic between jails'
28596f4ab26SKyle Evans	atf_set require.user root
28696f4ab26SKyle Evans}
28796f4ab26SKyle Evans
28896f4ab26SKyle Evanswg_vnet_parent_routing_body()
28996f4ab26SKyle Evans{
29096f4ab26SKyle Evans	local pri1 pri2 pub1 pub2 wg1 wg2
29196f4ab26SKyle Evans        local tunnel1 tunnel2
29296f4ab26SKyle Evans
29396f4ab26SKyle Evans	kldload -n if_wg
29496f4ab26SKyle Evans
29596f4ab26SKyle Evans	pri1=$(wg genkey)
29696f4ab26SKyle Evans	pri2=$(wg genkey)
29796f4ab26SKyle Evans
29896f4ab26SKyle Evans	tunnel1=169.254.0.1
29996f4ab26SKyle Evans	tunnel2=169.254.0.2
30096f4ab26SKyle Evans
30196f4ab26SKyle Evans	vnet_init
30296f4ab26SKyle Evans
30396f4ab26SKyle Evans	wg1=$(ifconfig wg create)
30496f4ab26SKyle Evans	wg2=$(ifconfig wg create)
30596f4ab26SKyle Evans
30696f4ab26SKyle Evans	vnet_mkjail wgtest1 ${wg1}
30796f4ab26SKyle Evans	vnet_mkjail wgtest2 ${wg2}
30896f4ab26SKyle Evans
30996f4ab26SKyle Evans	echo "$pri1" | jexec wgtest1 wg set $wg1 listen-port 12345 \
31096f4ab26SKyle Evans	    private-key /dev/stdin
31196f4ab26SKyle Evans	pub1=$(jexec wgtest1 wg show $wg1 public-key)
31296f4ab26SKyle Evans	echo "$pri2" | jexec wgtest2 wg set $wg2 listen-port 12346 \
31396f4ab26SKyle Evans	    private-key /dev/stdin
31496f4ab26SKyle Evans	pub2=$(jexec wgtest2 wg show $wg2 public-key)
31596f4ab26SKyle Evans
31696f4ab26SKyle Evans	atf_check -s exit:0 -o ignore \
31796f4ab26SKyle Evans	    jexec wgtest1 wg set $wg1 peer "$pub2" \
31896f4ab26SKyle Evans	    endpoint 127.0.0.1:12346 allowed-ips ${tunnel2}/32
31996f4ab26SKyle Evans	atf_check -s exit:0 \
32096f4ab26SKyle Evans	    jexec wgtest1 ifconfig $wg1 inet ${tunnel1}/24 up
32196f4ab26SKyle Evans
32296f4ab26SKyle Evans	atf_check -s exit:0 -o ignore \
32396f4ab26SKyle Evans	    jexec wgtest2 wg set $wg2 peer "$pub1" \
32496f4ab26SKyle Evans	    endpoint 127.0.0.1:12345 allowed-ips ${tunnel1}/32
32596f4ab26SKyle Evans	atf_check -s exit:0 \
32696f4ab26SKyle Evans	    jexec wgtest2 ifconfig $wg2 inet ${tunnel2}/24 up
32796f4ab26SKyle Evans
32896f4ab26SKyle Evans	# Sanity check ICMP counters; should clearly be nothing on these new
32996f4ab26SKyle Evans	# jails.  We'll check them as we go to ensure that the ICMP packets
33096f4ab26SKyle Evans	# generated really are being handled by the jails' vnets.
33196f4ab26SKyle Evans	atf_check -o not-match:"histogram" jexec wgtest1 netstat -s -p icmp
33296f4ab26SKyle Evans	atf_check -o not-match:"histogram" jexec wgtest2 netstat -s -p icmp
33396f4ab26SKyle Evans
33496f4ab26SKyle Evans	# Generous timeout since the handshake takes some time.
33596f4ab26SKyle Evans	atf_check -s exit:0 -o ignore jexec wgtest1 ping -c 1 -t 5 $tunnel2
33696f4ab26SKyle Evans	atf_check -o match:"echo reply: 1" jexec wgtest1 netstat -s -p icmp
33796f4ab26SKyle Evans	atf_check -o match:"echo: 1" jexec wgtest2 netstat -s -p icmp
33896f4ab26SKyle Evans
33996f4ab26SKyle Evans	atf_check -s exit:0 -o ignore jexec wgtest2 ping -c 1 $tunnel1
34096f4ab26SKyle Evans	atf_check -o match:"echo reply: 1" jexec wgtest2 netstat -s -p icmp
34196f4ab26SKyle Evans	atf_check -o match:"echo: 1" jexec wgtest1 netstat -s -p icmp
34296f4ab26SKyle Evans}
34396f4ab26SKyle Evans
34496f4ab26SKyle Evanswg_vnet_parent_routing_cleanup()
34596f4ab26SKyle Evans{
34696f4ab26SKyle Evans	vnet_cleanup
34796f4ab26SKyle Evans}
34896f4ab26SKyle Evans
3498fb97396SJohn Baldwinatf_init_test_cases()
3508fb97396SJohn Baldwin{
3518fb97396SJohn Baldwin	atf_add_test_case "wg_basic"
352*c0f13232SMark Johnston	atf_add_test_case "wg_basic_netmap"
3538fb97396SJohn Baldwin	atf_add_test_case "wg_key_peerdev_shared"
3548fb97396SJohn Baldwin	atf_add_test_case "wg_key_peerdev_makeshared"
35596f4ab26SKyle Evans	atf_add_test_case "wg_vnet_parent_routing"
3568fb97396SJohn Baldwin}
357