bridge tests: test linking bridges with a gif tunnel

Fairly basic test case for using gif(4)'s ability to tunnel Ethernet
traffic between bridges.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
This commit is contained in:
Kristof Provost 2021-07-21 17:32:24 +02:00
parent be79f30d6c
commit 4b765ab4cd

View File

@ -452,6 +452,71 @@ stp_validation_cleanup()
vnet_cleanup
}
atf_test_case "gif" "cleanup"
gif_head()
{
atf_set descr 'gif as a bridge member'
atf_set require.user root
}
gif_body()
{
vnet_init
epair=$(vnet_mkepair)
vnet_mkjail one ${epair}a
vnet_mkjail two ${epair}b
jexec one sysctl net.link.gif.max_nesting=2
jexec two sysctl net.link.gif.max_nesting=2
jexec one ifconfig ${epair}a 192.0.2.1/24 up
jexec two ifconfig ${epair}b 192.0.2.2/24 up
# Tunnel
gif_one=$(jexec one ifconfig gif create)
gif_two=$(jexec two ifconfig gif create)
jexec one ifconfig ${gif_one} tunnel 192.0.2.1 192.0.2.2
jexec one ifconfig ${gif_one} up
jexec two ifconfig ${gif_two} tunnel 192.0.2.2 192.0.2.1
jexec two ifconfig ${gif_two} up
bridge_one=$(jexec one ifconfig bridge create)
bridge_two=$(jexec two ifconfig bridge create)
jexec one ifconfig ${bridge_one} 198.51.100.1/24 up
jexec one ifconfig ${bridge_one} addm ${gif_one}
jexec two ifconfig ${bridge_two} 198.51.100.2/24 up
jexec two ifconfig ${bridge_two} addm ${gif_two}
# Sanity check
atf_check -s exit:0 -o ignore \
jexec one ping -c 1 192.0.2.2
# Test tunnel
atf_check -s exit:0 -o ignore \
jexec one ping -c 1 198.51.100.2
atf_check -s exit:0 -o ignore \
jexec one ping -c 1 -s 1200 198.51.100.2
atf_check -s exit:0 -o ignore \
jexec one ping -c 1 -s 2000 198.51.100.2
# Higher MTU on the tunnel than on the underlying interface
jexec one ifconfig ${epair}a mtu 1000
jexec two ifconfig ${epair}b mtu 1000
atf_check -s exit:0 -o ignore \
jexec one ping -c 1 -s 1200 198.51.100.2
atf_check -s exit:0 -o ignore \
jexec one ping -c 1 -s 2000 198.51.100.2
}
gif_cleanup()
{
vnet_cleanup
}
atf_init_test_cases()
{
atf_add_test_case "bridge_transmit_ipv4_unicast"
@ -463,4 +528,5 @@ atf_init_test_cases()
atf_add_test_case "delete_with_members"
atf_add_test_case "mac_conflict"
atf_add_test_case "stp_validation"
atf_add_test_case "gif"
}