diff --git a/tests/sys/common/vnet.subr b/tests/sys/common/vnet.subr --- a/tests/sys/common/vnet.subr +++ b/tests/sys/common/vnet.subr @@ -86,12 +86,22 @@ shift vnet_interfaces= - for ifname in $@ - do - vnet_interfaces="${vnet_interfaces} vnet.interface=${ifname}" + opts= + + while [ $# -gt 0 ]; do + if [ "$1" == "-o" ]; then + shift + opts="${opts} $1" + shift + continue + fi + + vnet_interfaces="${vnet_interfaces} vnet.interface=$1" unlist_interface $ifname + shift done - jail -c name=${jailname} persist vnet ${vnet_interfaces} + + jail -c name=${jailname} persist vnet ${opts} ${vnet_interfaces} echo $jailname $@ >> created_jails.lst } diff --git a/tests/sys/net/if_vxlan.sh b/tests/sys/net/if_vxlan.sh --- a/tests/sys/net/if_vxlan.sh +++ b/tests/sys/net/if_vxlan.sh @@ -62,7 +62,50 @@ vnet_cleanup } +atf_test_case "move" "cleanup" +move_head() +{ + atf_set descr 'Test moving interfaces into a jail' + atf_set require.user root +} + +move_body() +{ + vnet_init + + ifconfig lo0 inet 127.0.0.1/8 up + + epair=$(vnet_mkepair) + vnet_mkjail srv_a -o children.max=2 ${epair}a + vnet_mkjail srv_b -o children.max=2 ${epair}b + + jexec srv_a ifconfig ${epair}a 192.0.2.1/24 up + jexec srv_b ifconfig ${epair}b 192.0.2.2/24 up + + # Sanity check on underlay network + atf_check -s exit:0 -o ignore \ + jexec srv_a ping -c 1 192.0.2.2 + + vxlan_a=$(jexec srv_a ifconfig vxlan create vxlanid 1 vxlanlocal 192.0.2.1 vxlanremote 192.0.2.2) + vxlan_b=$(jexec srv_b ifconfig vxlan create vxlanid 1 vxlanlocal 192.0.2.2 vxlanremote 192.0.2.1) + + jexec srv_a jail -c name=a vnet persist vnet.interface=${vxlan_a} + jexec srv_b jail -c name=b vnet persist vnet.interface=${vxlan_b} + + jexec srv_a.a ifconfig ${vxlan_a} 198.51.100.1/24 up + jexec srv_b.b ifconfig ${vxlan_b} 198.51.100.2/24 up + + atf_check -s exit:0 -o ignore \ + jexec srv_a.a ping -c 3 198.51.100.2 +} + +move_cleanup() +{ + vnet_cleanup +} + atf_init_test_cases() { atf_add_test_case "basic" + atf_add_test_case "move" }