]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tests/sys/net/if_tun_test.sh
zfs: merge openzfs/zfs@797f55ef1
[FreeBSD/FreeBSD.git] / tests / sys / net / if_tun_test.sh
1
2 . $(atf_get_srcdir)/../common/vnet.subr
3
4 atf_test_case "235704" "cleanup"
5 235704_head()
6 {
7         atf_set descr "Test PR #235704"
8         atf_set require.user root
9 }
10 235704_body()
11 {
12         vnet_init
13         vnet_mkjail one
14
15         tun=$(jexec one ifconfig tun create)
16         jexec one ifconfig ${tun} name foo
17         atf_check -s exit:0 jexec one ifconfig foo destroy
18 }
19 235704_cleanup()
20 {
21         vnet_cleanup
22 }
23
24 atf_test_case "basic" "cleanup"
25 basic_head()
26 {
27         atf_set descr "Test if_tun using nc"
28         atf_set require.user root
29 }
30 basic_body()
31 {
32         vnet_init
33
34         epair=$(vnet_mkepair)
35
36         tun_duke=$(ifconfig tun create)
37         tun_bass=$(ifconfig tun create)
38
39         vnet_mkjail duke ${epair}a ${tun_duke}
40         vnet_mkjail bass ${epair}b ${tun_bass}
41
42         jexec duke ifconfig ${epair}a inet 10.0.0.1/24 up
43         jexec bass ifconfig ${epair}b inet 10.0.0.2/24 up
44
45         jexec duke nc -u -l --tun /dev/${tun_duke} 10.0.0.1 2600 &
46         jexec bass nc -u --tun /dev/${tun_bass} 10.0.0.1 2600 &
47
48         jexec duke ifconfig ${tun_duke} inet 10.100.0.1/24 10.100.0.2 up
49         jexec bass ifconfig ${tun_bass} inet 10.100.0.2/24 10.100.0.1 up
50
51         atf_check -s exit:0 -o ignore \
52                 jexec bass ping -c 1 10.100.0.1
53 }
54 basic_cleanup()
55 {
56         vnet_cleanup
57 }
58
59 atf_init_test_cases()
60 {
61         atf_add_test_case "235704"
62         atf_add_test_case "basic"
63 }