3 . $(atf_get_srcdir)/../common/vnet.subr
5 atf_test_case "basic" "cleanup"
8 atf_set descr 'Basic VLAN test'
9 atf_set require.user root
16 epair_vlan=$(vnet_mkepair)
18 vnet_mkjail alcatraz ${epair_vlan}a
19 vnet_mkjail singsing ${epair_vlan}b
21 vlan0=$(jexec alcatraz ifconfig vlan create vlandev ${epair_vlan}a \
23 jexec alcatraz ifconfig ${epair_vlan}a up
24 jexec alcatraz ifconfig ${vlan0} 10.0.0.1/24 up
26 vlan1=$(jexec singsing ifconfig vlan create vlandev ${epair_vlan}b \
28 jexec singsing ifconfig ${epair_vlan}b up
29 jexec singsing ifconfig ${vlan1} 10.0.0.2/24 up
31 atf_check -s exit:0 -o ignore jexec singsing ping -c 1 10.0.0.1
39 # Simple Q-in-Q (802.1Q over 802.1ad)
41 atf_test_case "qinq_simple" "cleanup"
44 atf_set descr 'Simple Q-in-Q test (802.1Q over 802.1ad)'
45 atf_set require.user root
52 epair_qinq=$(vnet_mkepair)
54 vnet_mkjail jqinq0 ${epair_qinq}a
55 vnet_mkjail jqinq1 ${epair_qinq}b
57 vlan5a=$(jexec jqinq0 ifconfig vlan create \
58 vlandev ${epair_qinq}a vlan 5 vlanproto 802.1ad)
59 vlan42a=$(jexec jqinq0 ifconfig vlan create \
60 vlandev ${vlan5a} vlan 42 vlanproto 802.1q)
61 jexec jqinq0 ifconfig ${epair_qinq}a up
62 jexec jqinq0 ifconfig ${vlan5a} up
63 jexec jqinq0 ifconfig ${vlan42a} 10.5.42.1/24 up
65 vlan5b=$(jexec jqinq1 ifconfig vlan create \
66 vlandev ${epair_qinq}b vlan 5 vlanproto 802.1ad)
67 vlan42b=$(jexec jqinq1 ifconfig vlan create \
68 vlandev ${vlan5b} vlan 42 vlanproto 802.1q)
69 jexec jqinq1 ifconfig ${epair_qinq}b up
70 jexec jqinq1 ifconfig ${vlan5b} up
71 jexec jqinq1 ifconfig ${vlan42b} 10.5.42.2/24 up
73 atf_check -s exit:0 -o ignore jexec jqinq1 ping -c 1 10.5.42.1
81 # Deep Q-in-Q (802.1Q over 802.1ad over 802.1ad)
83 atf_test_case "qinq_deep" "cleanup"
86 atf_set descr 'Deep Q-in-Q test (802.1Q over 802.1ad over 802.1ad)'
87 atf_set require.user root
94 epair_qinq=$(vnet_mkepair)
96 vnet_mkjail jqinq2 ${epair_qinq}a
97 vnet_mkjail jqinq3 ${epair_qinq}b
99 vlan5a=$(jexec jqinq2 ifconfig vlan create \
100 vlandev ${epair_qinq}a vlan 5 vlanproto 802.1ad)
101 vlan6a=$(jexec jqinq2 ifconfig vlan create \
102 vlandev ${vlan5a} vlan 6 vlanproto 802.1ad)
103 vlan42a=$(jexec jqinq2 ifconfig vlan create \
104 vlandev ${vlan6a} vlan 42 vlanproto 802.1q)
105 jexec jqinq2 ifconfig ${epair_qinq}a up
106 jexec jqinq2 ifconfig ${vlan5a} up
107 jexec jqinq2 ifconfig ${vlan6a} up
108 jexec jqinq2 ifconfig ${vlan42a} 10.6.42.1/24 up
110 vlan5b=$(jexec jqinq3 ifconfig vlan create \
111 vlandev ${epair_qinq}b vlan 5 vlanproto 802.1ad)
112 vlan6b=$(jexec jqinq3 ifconfig vlan create \
113 vlandev ${vlan5b} vlan 6 vlanproto 802.1ad)
114 vlan42b=$(jexec jqinq3 ifconfig vlan create \
115 vlandev ${vlan6b} vlan 42 vlanproto 802.1q)
116 jexec jqinq3 ifconfig ${epair_qinq}b up
117 jexec jqinq3 ifconfig ${vlan5b} up
118 jexec jqinq3 ifconfig ${vlan6b} up
119 jexec jqinq3 ifconfig ${vlan42b} 10.6.42.2/24 up
121 atf_check -s exit:0 -o ignore jexec jqinq3 ping -c 1 10.6.42.1
129 # Legacy Q-in-Q (802.1Q over 802.1Q)
131 atf_test_case "qinq_legacy" "cleanup"
134 atf_set descr 'Legacy Q-in-Q test (802.1Q over 802.1Q)'
135 atf_set require.user root
142 epair_qinq=$(vnet_mkepair)
144 vnet_mkjail jqinq4 ${epair_qinq}a
145 vnet_mkjail jqinq5 ${epair_qinq}b
147 vlan5a=$(jexec jqinq4 ifconfig vlan create \
148 vlandev ${epair_qinq}a vlan 5)
149 vlan42a=$(jexec jqinq4 ifconfig vlan create \
150 vlandev ${vlan5a} vlan 42)
151 jexec jqinq4 ifconfig ${epair_qinq}a up
152 jexec jqinq4 ifconfig ${vlan5a} up
153 jexec jqinq4 ifconfig ${vlan42a} 10.5.42.1/24 up
155 vlan5b=$(jexec jqinq5 ifconfig vlan create \
156 vlandev ${epair_qinq}b vlan 5)
157 vlan42b=$(jexec jqinq5 ifconfig vlan create \
158 vlandev ${vlan5b} vlan 42)
159 jexec jqinq5 ifconfig ${epair_qinq}b up
160 jexec jqinq5 ifconfig ${vlan5b} up
161 jexec jqinq5 ifconfig ${vlan42b} 10.5.42.2/24 up
163 atf_check -s exit:0 -o ignore jexec jqinq5 ping -c 1 10.5.42.1
166 qinq_legacy_cleanup()
171 # Simple Q-in-Q with dot notation
173 atf_test_case "qinq_dot" "cleanup"
176 atf_set descr 'Simple Q-in-Q test with dot notation'
177 atf_set require.user root
184 epair_qinq=$(vnet_mkepair)
186 vnet_mkjail jqinq6 ${epair_qinq}a
187 vnet_mkjail jqinq7 ${epair_qinq}b
189 jexec jqinq6 ifconfig vlan5 create \
190 vlandev ${epair_qinq}a vlan 5 vlanproto 802.1ad
191 jexec jqinq6 ifconfig vlan5.42 create \
193 jexec jqinq6 ifconfig ${epair_qinq}a up
194 jexec jqinq6 ifconfig vlan5 up
195 jexec jqinq6 ifconfig vlan5.42 10.5.42.1/24 up
197 vlan5b=$(jexec jqinq7 ifconfig vlan create \
198 vlandev ${epair_qinq}b vlan 5 vlanproto 802.1ad)
199 vlan42b=$(jexec jqinq7 ifconfig vlan create \
200 vlandev ${vlan5b} vlan 42 vlanproto 802.1q)
201 jexec jqinq7 ifconfig ${epair_qinq}b up
202 jexec jqinq7 ifconfig ${vlan5b} up
203 jexec jqinq7 ifconfig ${vlan42b} 10.5.42.2/24 up
205 atf_check -s exit:0 -o ignore jexec jqinq7 ping -c 1 10.5.42.1
213 atf_test_case "bpf_pcp" "cleanup"
216 atf_set descr 'Set VLAN PCP through BPF'
217 atf_set require.user root
218 atf_set require.progs scapy
225 epair=$(vnet_mkepair)
227 ifconfig ${epair}a up
229 vnet_mkjail alcatraz ${epair}b
230 vlan=$(jexec alcatraz ifconfig vlan create)
231 jexec alcatraz ifconfig ${vlan} vlan 42 vlandev ${epair}b
232 jexec alcatraz ifconfig ${vlan} up
233 jexec alcatraz ifconfig ${epair}b up
235 jexec alcatraz sysctl net.link.vlan.mtag_pcp=1
237 jexec alcatraz dhclient ${vlan} &
238 atf_check -s exit:1 -o ignore -e ignore $(atf_get_srcdir)/pcp.py \
242 jexec alcatraz killall dhclient
245 jexec alcatraz dhclient -c $(atf_get_srcdir)/dhclient_pcp.conf ${vlan} &
246 atf_check -s exit:0 -o ignore -e ignore $(atf_get_srcdir)/pcp.py \
253 sysctl net.link.vlan.mtag_pcp=0
254 jexec alcatraz killall dhclient
258 atf_init_test_cases()
260 atf_add_test_case "basic"
261 atf_add_test_case "qinq_simple"
262 atf_add_test_case "qinq_deep"
263 atf_add_test_case "qinq_legacy"
264 atf_add_test_case "qinq_dot"
265 atf_add_test_case "bpf_pcp"