Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save adventureloop/316aec2f6f73f58458e6d3a1fe357edb to your computer and use it in GitHub Desktop.
Save adventureloop/316aec2f6f73f58458e6d3a1fe357edb to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
. /usr/tests/sys/common/vnet.subr
create_jail()
{
addr=$1
jailname=zeist-${addr}
epair=$(vnet_mkepair)
vnet_mkjail $jailname ${epair}b
jexec $jailname ifconfig ${epair}b 192.0.${addr}.2/24 up
ifconfig ${epair}a inet 192.168.${addr}.1/24 up
#sleep 1
### stuff to run in a jail once we are ready
jexec $jailname ifconfig ${epair}b inet 192.168.${addr}.2/24 up
jexec $jailname route add default 192.168.${addr}.1 > /dev/null
#jexec $jailname ipfw add 100 pipe 2 ip from any to any
#jexec $jailname ipfw pipe 2 config delay 20ms
#jexec $jailname ping -q -c 5 192.168.${addr}.1 > result-jailonly-${addr}.txt
# jexec ipfw sh
jail -r $jailname
#sleep 2
ifconfig ${epair}a destroy
}
if [ -z $1 ]
then
count=1
else
count=$1
fi
for y in `jot $count`
do
# echo starting $y jails
start=`date +%s`
for x in `jot $y`
do
create_jail $x &
done
wait
end=`date +%s`
echo $y $(($end-$start))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment