mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Set up two jails, configure pfsync between them and create state in one of them, verify that this state is copied to the other jail. MFC after: 2 weeks Sponsored by: Orange Business Services Differential Revision: https://reviews.freebsd.org/D17504
83 lines
1.2 KiB
Text
83 lines
1.2 KiB
Text
# $FreeBSD$
|
|
# Utility functions
|
|
##
|
|
|
|
pft_init()
|
|
{
|
|
if [ ! -c /dev/pf ]; then
|
|
atf_skip "This test requires pf"
|
|
fi
|
|
|
|
if [ "`sysctl -i -n kern.features.vimage`" != 1 ]; then
|
|
atf_skip "This test requires VIMAGE"
|
|
fi
|
|
}
|
|
|
|
pfsynct_init()
|
|
{
|
|
pft_init
|
|
|
|
if ! kldstat -q -m pfsync; then
|
|
atf_skip "This test requires pfsync"
|
|
fi
|
|
}
|
|
|
|
pft_mkepair()
|
|
{
|
|
ifname=$(ifconfig epair create)
|
|
echo $ifname >> created_interfaces.lst
|
|
echo ${ifname%a}
|
|
}
|
|
|
|
pft_mkjail()
|
|
{
|
|
jailname=$1
|
|
shift
|
|
|
|
vnet_interfaces=
|
|
for ifname in $@
|
|
do
|
|
vnet_interfaces="${vnet_interfaces} vnet.interface=${ifname}"
|
|
done
|
|
jail -c name=${jailname} persist vnet ${vnet_interfaces}
|
|
|
|
echo $jailname >> created_jails.lst
|
|
}
|
|
|
|
pft_set_rules()
|
|
{
|
|
jname=$1
|
|
shift
|
|
|
|
# Flush all states, rules, fragments, ...
|
|
jexec ${jname} pfctl -F all
|
|
|
|
while [ $# -gt 0 ]; do
|
|
printf "$1\n"
|
|
shift
|
|
done | jexec ${jname} pfctl -f -
|
|
}
|
|
|
|
pft_cleanup()
|
|
{
|
|
if [ -f created_jails.lst ]; then
|
|
for jailname in `cat created_jails.lst`
|
|
do
|
|
jail -r ${jailname}
|
|
done
|
|
rm created_jails.lst
|
|
fi
|
|
|
|
if [ -f created_interfaces.lst ]; then
|
|
for ifname in `cat created_interfaces.lst`
|
|
do
|
|
ifconfig ${ifname} destroy
|
|
done
|
|
rm created_interfaces.lst
|
|
fi
|
|
}
|
|
|
|
pfsynct_cleanup()
|
|
{
|
|
pft_cleanup
|
|
}
|