freebsd-src/tests/sys/net/if_tun_test.sh
Tom Jones fe701c39e8 if_tun: Add basic connectivity test with nc tun support
Reviewed by:    kevans
Sponsored by:   Zenarmor
Sponsored by:   OPNsense
Sponsored by:   Klara, Inc.
Differential Revision:  https://reviews.freebsd.org/D37435
2023-01-17 10:05:50 +00:00

68 lines
1.2 KiB
Bash
Executable file

# $FreeBSD$
. $(atf_get_srcdir)/../common/vnet.subr
atf_test_case "235704" "basic" "cleanup"
235704_head()
{
atf_set descr "Test PR #235704"
atf_set require.user root
}
235704_body()
{
vnet_init
vnet_mkjail one
tun=$(jexec one ifconfig tun create)
jexec one ifconfig ${tun} name foo
atf_check -s exit:0 jexec one ifconfig foo destroy
}
235704_cleanup()
{
vnet_cleanup
}
basic_head()
{
atf_set descr "Test if_tun using nc"
atf_set require.user root
}
basic_body()
{
vnet_init
epair=$(vnet_mkepair)
tun_duke=$(ifconfig tun create)
tun_bass=$(ifconfig tun create)
vnet_mkjail duke ${epair}a ${tun_duke}
vnet_mkjail bass ${epair}b ${tun_bass}
jexec duke ifconfig ${epair}a inet 10.0.0.1/24 up
jexec bass ifconfig ${epair}b inet 10.0.0.2/24 up
jexec duke nc -u -l --tun /dev/${tun_duke} 10.0.0.1 2600 &
jexec bass nc -u --tun /dev/${tun_bass} 10.0.0.1 2600 &
jexec duke ifconfig ${tun_duke} inet 10.100.0.1/24 10.100.0.2 up
jexec bass ifconfig ${tun_bass} inet 10.100.0.2/24 10.100.0.1 up
atf_check -s exit:0 -o ignore \
jexec bass ping -c 1 10.100.0.1
}
basic_clean()
{
vnet_cleanup
}
atf_init_test_cases()
{
atf_add_test_case "235704"
atf_add_test_case "basic"
}