3 # SPDX-License-Identifier: BSD-2-Clause-FreeBSD
5 # Copyright (c) 2018 Orange Business Services
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 . $(atf_get_srcdir)/utils.subr
30 atf_test_case "basic" "cleanup"
33 atf_set descr 'Basic pfsync test'
34 atf_set require.user root
47 epair_sync=$(vnet_mkepair)
48 epair_one=$(vnet_mkepair)
49 epair_two=$(vnet_mkepair)
51 vnet_mkjail one ${epair_one}a ${epair_sync}a
52 vnet_mkjail two ${epair_two}a ${epair_sync}b
55 jexec one ifconfig ${epair_sync}a 192.0.2.1/24 up
56 jexec one ifconfig ${epair_one}a 198.51.100.1/24 up
57 jexec one ifconfig pfsync0 \
58 syncdev ${epair_sync}a \
62 jexec two ifconfig ${epair_two}a 198.51.100.2/24 up
63 jexec two ifconfig ${epair_sync}b 192.0.2.2/24 up
64 jexec two ifconfig pfsync0 \
65 syncdev ${epair_sync}b \
73 "set skip on ${epair_sync}a" \
77 "set skip on ${epair_sync}b" \
80 ifconfig ${epair_one}b 198.51.100.254/24 up
82 ping -c 1 -S 198.51.100.254 198.51.100.1
84 # Give pfsync time to do its thing
87 if ! jexec two pfctl -s states | grep icmp | grep 198.51.100.1 | \
88 grep 198.51.100.2 ; then
89 atf_fail "state not found on synced host"
98 atf_test_case "defer" "cleanup"
101 atf_set descr 'Defer mode pfsync test'
102 atf_set require.user root
115 atf_test_case "bulk" "cleanup"
118 atf_set descr 'Test bulk updates'
119 atf_set require.user root
126 epair_sync=$(vnet_mkepair)
127 epair_one=$(vnet_mkepair)
128 epair_two=$(vnet_mkepair)
130 vnet_mkjail one ${epair_one}a ${epair_sync}a
131 vnet_mkjail two ${epair_two}a ${epair_sync}b
134 jexec one ifconfig ${epair_sync}a 192.0.2.1/24 up
135 jexec one ifconfig ${epair_one}a 198.51.100.1/24 up
136 jexec one ifconfig pfsync0 \
137 syncdev ${epair_sync}a \
140 jexec two ifconfig ${epair_two}a 198.51.100.2/24 up
141 jexec two ifconfig ${epair_sync}b 192.0.2.2/24 up
146 "set skip on ${epair_sync}a" \
150 "set skip on ${epair_sync}b" \
153 ifconfig ${epair_one}b 198.51.100.254/24 up
155 # Create state prior to setting up pfsync
156 ping -c 1 -S 198.51.100.254 198.51.100.1
158 # Wait before setting up pfsync on two, so we don't accidentally catch
162 # Now set up pfsync in jail two
163 jexec two ifconfig pfsync0 \
164 syncdev ${epair_sync}b \
167 # Give pfsync time to do its thing
170 jexec two pfctl -s states
171 if ! jexec two pfctl -s states | grep icmp | grep 198.51.100.1 | \
172 grep 198.51.100.2 ; then
173 atf_fail "state not found on synced host"
182 atf_init_test_cases()
184 atf_add_test_case "basic"
185 atf_add_test_case "defer"
186 atf_add_test_case "bulk"