@@ -105,6 +105,68 @@ v4_cleanup()
105105 pft_cleanup
106106}
107107
108+ atf_test_case " src_dst" " cleanup"
109+ src_dst_head ()
110+ {
111+ atf_set descr ' Test killing a state with source and destination specified'
112+ atf_set require.user root
113+ }
114+
115+ src_dst_body ()
116+ {
117+ pft_init
118+
119+ epair=$( vnet_mkepair)
120+ ifconfig ${epair} a 192.0.2.1/24 up
121+
122+ vnet_mkjail alcatraz ${epair} b
123+ jexec alcatraz ifconfig ${epair} b 192.0.2.2/24 up
124+ jexec alcatraz pfctl -e
125+
126+ pft_set_rules alcatraz " block all" \
127+ " pass in proto icmp" \
128+ " set skip on lo"
129+
130+ # Sanity check & establish state
131+ atf_check -s exit:0 -o ignore ${common_dir} /pft_ping.py \
132+ --sendif ${epair} a \
133+ --to 192.0.2.2 \
134+ --replyif ${epair} a
135+
136+ # Change rules to now deny the ICMP traffic
137+ pft_set_rules noflush alcatraz " block all"
138+ if ! find_state;
139+ then
140+ atf_fail " Setting new rules removed the state."
141+ fi
142+
143+ # Killing with the wrong source IP doesn't affect our state
144+ jexec alcatraz pfctl -k 192.0.2.3 -k 192.0.2.2
145+ if ! find_state;
146+ then
147+ atf_fail " Killing with the wrong source IP removed our state."
148+ fi
149+
150+ # Killing with the wrong destination IP doesn't affect our state
151+ jexec alcatraz pfctl -k 192.0.2.1 -k 192.0.2.3
152+ if ! find_state;
153+ then
154+ atf_fail " Killing with the wrong destination IP removed our state."
155+ fi
156+
157+ # But it does with the correct one
158+ jexec alcatraz pfctl -k 192.0.2.1 -k 192.0.2.2
159+ if find_state;
160+ then
161+ atf_fail " Killing with the correct IPs did not remove our state."
162+ fi
163+ }
164+
165+ src_dst_cleanup ()
166+ {
167+ pft_cleanup
168+ }
169+
108170atf_test_case " v6" " cleanup"
109171v6_head ()
110172{
@@ -698,6 +760,7 @@ nat_cleanup()
698760atf_init_test_cases ()
699761{
700762 atf_add_test_case " v4"
763+ atf_add_test_case " src_dst"
701764 atf_add_test_case " v6"
702765 atf_add_test_case " label"
703766 atf_add_test_case " multilabel"
0 commit comments