3 . $(atf_get_srcdir)/utils.subr
5 common_dir=$(atf_get_srcdir)/../common
7 atf_test_case "v4" "cleanup"
10 atf_set descr 'Basic forwarding test'
11 atf_set require.user root
13 # We need scapy to be installed for out test scripts to work
14 atf_set require.progs scapy
19 if [ `uname -p` = "i386" ]; then
20 atf_skip "https://bugs.freebsd.org/239380"
25 epair_send=$(vnet_mkepair)
26 ifconfig ${epair_send}a 192.0.2.1/24 up
28 epair_recv=$(vnet_mkepair)
29 ifconfig ${epair_recv}a up
31 vnet_mkjail alcatraz ${epair_send}b ${epair_recv}b
32 jexec alcatraz ifconfig ${epair_send}b 192.0.2.2/24 up
33 jexec alcatraz ifconfig ${epair_recv}b 198.51.100.2/24 up
34 jexec alcatraz sysctl net.inet.ip.forwarding=1
35 jexec alcatraz arp -s 198.51.100.3 00:01:02:03:04:05
36 route add -net 198.51.100.0/24 192.0.2.2
38 # Sanity check, can we forward ICMP echo requests without pf?
39 atf_check -s exit:0 $(atf_get_srcdir)/pft_ping.py \
40 --sendif ${epair_send}a \
42 --recvif ${epair_recv}a
44 jexec alcatraz pfctl -e
46 # Forward with pf enabled
47 pft_set_rules alcatraz "block in"
48 atf_check -s exit:1 ${common_dir}/pft_ping.py \
49 --sendif ${epair_send}a \
51 --recvif ${epair_recv}a
53 pft_set_rules alcatraz "block out"
54 atf_check -s exit:1 ${common_dir}/pft_ping.py \
55 --sendif ${epair_send}a \
60 pft_set_rules alcatraz "block in" "pass in proto icmp"
61 atf_check -s exit:0 ${common_dir}/pft_ping.py \
62 --sendif ${epair_send}a \
64 --recvif ${epair_recv}a
72 atf_test_case "v6" "cleanup"
75 atf_set descr 'Basic IPv6 forwarding test'
76 atf_set require.user root
77 atf_set require.progs scapy
82 if [ `uname -p` = "i386" ]; then
83 atf_skip "https://bugs.freebsd.org/239380"
88 epair_send=$(vnet_mkepair)
89 epair_recv=$(vnet_mkepair)
91 ifconfig ${epair_send}a inet6 2001:db8:42::1/64 up no_dad -ifdisabled
92 ifconfig ${epair_recv}a up
94 vnet_mkjail alcatraz ${epair_send}b ${epair_recv}b
96 jexec alcatraz ifconfig ${epair_send}b inet6 2001:db8:42::2/64 up no_dad
97 jexec alcatraz ifconfig ${epair_recv}b inet6 2001:db8:43::2/64 up no_dad
98 jexec alcatraz sysctl net.inet6.ip6.forwarding=1
99 jexec alcatraz ndp -s 2001:db8:43::3 00:01:02:03:04:05
100 route add -6 2001:db8:43::/64 2001:db8:42::2
102 # Sanity check, can we forward ICMP echo requests without pf?
103 atf_check -s exit:0 ${common_dir}/pft_ping.py \
105 --sendif ${epair_send}a \
106 --to 2001:db8:43::3 \
107 --recvif ${epair_recv}a
109 jexec alcatraz pfctl -e
111 # Block incoming echo request packets
112 pft_set_rules alcatraz \
113 "block in inet6 proto icmp6 icmp6-type echoreq"
114 atf_check -s exit:1 ${common_dir}/pft_ping.py \
116 --sendif ${epair_send}a \
117 --to 2001:db8:43::3 \
118 --recvif ${epair_recv}a
120 # Block outgoing echo request packets
121 pft_set_rules alcatraz \
122 "block out inet6 proto icmp6 icmp6-type echoreq"
123 atf_check -s exit:1 -e ignore ${common_dir}/pft_ping.py \
125 --sendif ${epair_send}a \
126 --to 2001:db8:43::3 \
127 --recvif ${epair_recv}a
129 # Allow ICMPv6 but nothing else
130 pft_set_rules alcatraz \
132 "pass out inet6 proto icmp6"
133 atf_check -s exit:0 ${common_dir}/pft_ping.py \
135 --sendif ${epair_send}a \
136 --to 2001:db8:43::3 \
137 --recvif ${epair_recv}a
139 # Allowing ICMPv4 does not allow ICMPv6
140 pft_set_rules alcatraz \
141 "block out inet6 proto icmp6 icmp6-type echoreq" \
143 atf_check -s exit:1 ${common_dir}/pft_ping.py \
145 --sendif ${epair_send}a \
146 --to 2001:db8:43::3 \
147 --recvif ${epair_recv}a
155 atf_init_test_cases()
157 atf_add_test_case "v4"
158 atf_add_test_case "v6"