1# $FreeBSD$ 2# VNAT/jail utility functions 3## 4 5vnet_init() 6{ 7 if [ "`sysctl -i -n kern.features.vimage`" != 1 ]; then 8 atf_skip "This test requires VIMAGE" 9 fi 10} 11 12vnet_mkepair() 13{ 14 ifname=$(ifconfig epair create) 15 echo $ifname >> created_interfaces.lst 16 echo ${ifname%a}b >> created_interfaces.lst 17 echo ${ifname%a} 18} 19 20vnet_mkbridge() 21{ 22 ifname=$(ifconfig bridge create) 23 echo $ifname >> created_interfaces.lst 24 echo ${ifname} 25} 26 27vnet_mkloopback() 28{ 29 ifname=$(ifconfig lo create) 30 echo $ifname >> created_interfaces.lst 31 echo ${ifname} 32} 33 34vnet_mkjail() 35{ 36 jailname=$1 37 shift 38 39 vnet_interfaces= 40 for ifname in $@ 41 do 42 vnet_interfaces="${vnet_interfaces} vnet.interface=${ifname}" 43 done 44 jail -c name=${jailname} persist vnet ${vnet_interfaces} 45 46 echo $jailname >> created_jails.lst 47} 48 49vnet_cleanup() 50{ 51 if [ -f created_jails.lst ]; then 52 for jailname in `cat created_jails.lst` 53 do 54 jail -r ${jailname} 55 done 56 rm created_jails.lst 57 fi 58 59 if [ -f created_interfaces.lst ]; then 60 for ifname in `cat created_interfaces.lst` 61 do 62 ifconfig ${ifname} destroy 63 done 64 rm created_interfaces.lst 65 fi 66} 67