ofpaction: support OF11 pop_vlan
[sliver-openvswitch.git] / tests / ofp-actions.at
1 AT_BANNER([OpenFlow actions])
2
3 AT_SETUP([OpenFlow 1.0 action translation])
4 AT_KEYWORDS([OF1.0])
5 AT_DATA([test-data], [dnl
6 # actions=LOCAL
7 0000 0008 fffe 04d2
8
9 # actions=CONTROLLER:1234
10 0000 0008 fffd 04d2
11
12 # actions=mod_vlan_vid:9
13 0001 0008 0009 0000
14
15 # actions=mod_vlan_pcp:6
16 0002 0008 06 000000
17
18 # actions=strip_vlan
19 0003 0008 00000000
20
21 # actions=mod_dl_src:00:11:22:33:44:55
22 0004 0010 001122334455 000000000000
23
24 # actions=mod_dl_dst:10:20:30:40:50:60
25 0005 0010 102030405060 000000000000
26
27 # actions=mod_nw_src:1.2.3.4
28 0006 0008 01020304
29
30 # actions=mod_nw_dst:192.168.0.1
31 0007 0008 c0a80001
32
33 # actions=mod_nw_tos:48
34 0008 0008 30 000000
35
36 # actions=mod_tp_src:80
37 0009 0008 0050 0000
38
39 # actions=mod_tp_dst:443
40 000a 0008 01bb 0000
41
42 # actions=enqueue:10q55
43 000b 0010 000a 000000000000 00000037
44
45 # actions=resubmit:5
46 ffff 0010 00002320 0001 0005 00000000
47
48 # actions=set_tunnel:0x12345678
49 ffff 0010 00002320 0002 0000 12345678
50
51 # actions=set_queue:2309737729
52 ffff 0010 00002320 0004 0000 89abcd01
53
54 # actions=pop_queue
55 ffff 0010 00002320 0005 000000000000
56
57 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
58 ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
59
60 # actions=load:0xf009->NXM_OF_VLAN_TCI[]
61 ffff 0018 00002320 0007 000f 00000802 000000000000f009
62
63 # actions=note:11.e9.9a.ad.67.f3
64 ffff 0010 00002320 0008 11e99aad67f3
65
66 # actions=set_tunnel64:0xc426384d49c53d60
67 ffff 0018 00002320 0009 000000000000 c426384d49c53d60
68
69 # actions=set_tunnel64:0x885f3298
70 ffff 0018 00002320 0009 000000000000 00000000885f3298
71
72 # actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
73 ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
74
75 # actions=autopath(2,NXM_NX_REG0[2..30])
76 & autopath|WARN|The autopath action is deprecated and may be removed in February 2013.  Please email dev@openvswitch.org with concerns.
77 ffff 0018 00002320 000b 009c 00010004 00000002 00000000
78
79 # actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
80 ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
81 0004 0008 00000000
82
83 # actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
84 ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
85 0004 0008 00000000
86
87 # actions=resubmit(10,5)
88 ffff 0010 00002320 000e 000a 05 000000
89
90 # actions=output:NXM_NX_REG1[5..10]
91 ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
92
93 # actions=learn(table=2,idle_timeout=10,hard_timeout=20,fin_idle_timeout=2,fin_hard_timeout=4,priority=80,cookie=0x123456789abcdef0,NXM_OF_VLAN_TCI[0..11],NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],output:NXM_OF_IN_PORT[])
94 ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
95 000c 00000802 0000 00000802 0000 dnl
96 0030 00000406 0000 00000206 0000 dnl
97 1010 00000002 0000 dnl
98 00000000
99
100 # actions=exit
101 ffff 0010 00002320 0011 000000000000
102
103 # actions=dec_ttl
104 ffff 0010 00002320 0012 000000000000
105
106 # actions=fin_timeout(idle_timeout=10,hard_timeout=20)
107 ffff 0010 00002320 0013 000a 0014 0000
108
109 # actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
110 ffff 0010 00002320 0014 04d2 162e 02 00
111
112 # actions=dec_ttl(32768,12345,90,765,1024)
113 ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
114
115 ])
116 sed '/^[[#&]]/d' < test-data > input.txt
117 sed -n 's/^# //p; /^$/p' < test-data > expout
118 sed -n 's/^& //p' < test-data > experr
119 AT_CAPTURE_FILE([input.txt])
120 AT_CAPTURE_FILE([expout])
121 AT_CAPTURE_FILE([experr])
122 AT_CHECK(
123   [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-ofp10-actions < input.txt],
124   [0], [expout], [experr])
125 AT_CLEANUP
126
127 AT_SETUP([OpenFlow 1.1 action translation])
128 AT_KEYWORDS([OF1.1])
129 AT_DATA([test-data], [dnl
130 # actions=LOCAL
131 0000 0010 fffffffe 04d2 000000000000
132
133 # actions=CONTROLLER:1234
134 0000 0010 fffffffd 04d2 000000000000
135
136 # actions=mod_vlan_vid:9
137 0001 0008 0009 0000
138
139 # actions=mod_vlan_pcp:6
140 0002 0008 06 000000
141
142 # actions=mod_dl_src:00:11:22:33:44:55
143 0003 0010 001122334455 000000000000
144
145 # actions=mod_dl_dst:10:20:30:40:50:60
146 0004 0010 102030405060 000000000000
147
148 # actions=mod_nw_src:1.2.3.4
149 0005 0008 01020304
150
151 # actions=mod_nw_dst:192.168.0.1
152 0006 0008 c0a80001
153
154 # actions=mod_nw_tos:48
155 0007 0008 30 000000
156
157 # actions=mod_tp_src:80
158 0009 0008 0050 0000
159
160 # actions=mod_tp_dst:443
161 000a 0008 01bb 0000
162
163 # actions=strip_vlan
164 0012 0008 00000000
165
166 # actions=resubmit:5
167 ffff 0010 00002320 0001 0005 00000000
168
169 # actions=set_tunnel:0x12345678
170 ffff 0010 00002320 0002 0000 12345678
171
172 # actions=set_queue:2309737729
173 ffff 0010 00002320 0004 0000 89abcd01
174
175 # actions=pop_queue
176 ffff 0010 00002320 0005 000000000000
177
178 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
179 ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
180
181 # actions=load:0xf009->NXM_OF_VLAN_TCI[]
182 ffff 0018 00002320 0007 000f 00000802 000000000000f009
183
184 # actions=note:11.e9.9a.ad.67.f3
185 ffff 0010 00002320 0008 11e99aad67f3
186
187 # actions=set_tunnel64:0xc426384d49c53d60
188 ffff 0018 00002320 0009 000000000000 c426384d49c53d60
189
190 # actions=set_tunnel64:0x885f3298
191 ffff 0018 00002320 0009 000000000000 00000000885f3298
192
193 # actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
194 ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
195
196 # actions=autopath(2,NXM_NX_REG0[2..30])
197 & autopath|WARN|The autopath action is deprecated and may be removed in February 2013.  Please email dev@openvswitch.org with concerns.
198 ffff 0018 00002320 000b 009c 00010004 00000002 00000000
199
200 # actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
201 ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
202 0004 0008 00000000
203
204 # actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
205 ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
206 0004 0008 00000000
207
208 # actions=resubmit(10,5)
209 ffff 0010 00002320 000e 000a 05 000000
210
211 # actions=output:NXM_NX_REG1[5..10]
212 ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
213
214 # actions=learn(table=2,idle_timeout=10,hard_timeout=20,fin_idle_timeout=2,fin_hard_timeout=4,priority=80,cookie=0x123456789abcdef0,NXM_OF_VLAN_TCI[0..11],NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],output:NXM_OF_IN_PORT[])
215 ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
216 000c 00000802 0000 00000802 0000 dnl
217 0030 00000406 0000 00000206 0000 dnl
218 1010 00000002 0000 dnl
219 00000000
220
221 # actions=exit
222 ffff 0010 00002320 0011 000000000000
223
224 dnl NXAST_DEC_TTL
225 # actions=dec_ttl
226 ffff 0010 00002320 0012 000000000000
227
228 dnl OpenFlow 1.1 OFPAT_DEC_TTL
229 # actions=dec_ttl
230 0018 0008 00000000
231
232 # actions=fin_timeout(idle_timeout=10,hard_timeout=20)
233 ffff 0010 00002320 0013 000a 0014 0000
234
235 # actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
236 ffff 0010 00002320 0014 04d2 162e 02 00
237
238 # actions=dec_ttl(32768,12345,90,765,1024)
239 ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
240
241 ])
242 sed '/^[[#&]]/d' < test-data > input.txt
243 sed -n 's/^# //p; /^$/p' < test-data > expout
244 sed -n 's/^& //p' < test-data > experr
245 AT_CAPTURE_FILE([input.txt])
246 AT_CAPTURE_FILE([expout])
247 AT_CAPTURE_FILE([experr])
248 AT_CHECK(
249   [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-ofp11-actions < input.txt],
250   [0], [expout], [experr])
251 AT_CLEANUP
252
253 AT_SETUP([OpenFlow 1.1 instruction translation])
254 AT_KEYWORDS([OF1.1 instruction])
255 AT_DATA([test-data], [dnl
256 # actions=LOCAL
257 0004 0018 00000000 dnl
258 0000 0010 fffffffe 04d2 000000000000
259
260 dnl Apply-Actions non-zero padding
261 # actions=drop
262 #  0: 00 -> (none)
263 #  1: 04 -> (none)
264 #  2: 00 -> (none)
265 #  3: 08 -> (none)
266 #  4: 00 -> (none)
267 #  5: 00 -> (none)
268 #  6: 00 -> (none)
269 #  7: 01 -> (none)
270 0004 0008 00000001
271
272 dnl Check that an empty Apply-Actions instruction gets dropped.
273 # actions=drop
274 #  0: 00 -> (none)
275 #  1: 04 -> (none)
276 #  2: 00 -> (none)
277 #  3: 08 -> (none)
278 #  4: 00 -> (none)
279 #  5: 00 -> (none)
280 #  6: 00 -> (none)
281 #  7: 00 -> (none)
282 0004 0008 00000000
283
284 dnl Duplicate instruction type:
285 # bad OF1.1 instructions: OFPIT_BAD_INSTRUCTION
286 0004 0008 00000000 0004 0008 00000000
287
288 dnl Instructions not multiple of 8 in length.
289 & ofp_actions|WARN|OpenFlow message instructions length 9 is not a multiple of 8
290 # bad OF1.1 instructions: OFPBIC_BAD_LEN
291 0004 0009 01 00000000
292
293 dnl Goto-Table instruction too long.
294 # bad OF1.1 instructions: OFPBIC_BAD_LEN
295 0001 0010 01 000000 0000000000000000
296
297 dnl Goto-Table 1 instruction non-zero padding
298 # actions=goto_table:1
299 #  7: 01 -> 00
300 0001 0008 01 000001
301
302 dnl Goto-Table 1
303 # actions=goto_table:1
304 0001 0008 01 000000
305
306 dnl Write-Metadata not supported yet.
307 # bad OF1.1 instructions: OFPBIC_UNSUP_INST
308 0002 0018 00000000 fedcba9876543210 ffffffffffffffff
309
310 dnl Write-Metadata too short.
311 # bad OF1.1 instructions: OFPBIC_BAD_LEN
312 0002 0010 00000000 fedcba9876543210
313
314 dnl Write-Metadata too long.
315 # bad OF1.1 instructions: OFPBIC_BAD_LEN
316 0002 0020 00000000 fedcba9876543210 ffffffffffffffff 0000000000000000
317
318 dnl Write-Actions not supported yet.
319 # bad OF1.1 instructions: OFPBIC_UNSUP_INST
320 0003 0008 01 000000
321
322 dnl Clear-Actions too-long
323 # bad OF1.1 instructions: OFPBIC_BAD_LEN
324 0005 0010 00000000 0000000000000000
325
326 dnl Clear-Actions non-zero padding
327 # actions=clear_actions
328 #  7: 01 -> 00
329 0005 0008 00000001
330
331 dnl Clear-Actions non-zero padding
332 # actions=clear_actions
333 #  4: 01 -> 00
334 0005 0008 01 000000
335
336 dnl Clear-Actions
337 # actions=clear_actions
338 0005 0008 00000000
339
340 dnl Experimenter actions not supported yet.
341 # bad OF1.1 instructions: OFPBIC_BAD_EXPERIMENTER
342 ffff 0008 01 000000
343
344 dnl Bad instruction number (0 not assigned).
345 # bad OF1.1 instructions: OFPBIC_UNKNOWN_INST
346 0000 0008 01 000000
347
348 ])
349 sed '/^[[#&]]/d' < test-data > input.txt
350 sed -n 's/^# //p; /^$/p' < test-data > expout
351 sed -n 's/^& //p' < test-data > experr
352 AT_CAPTURE_FILE([input.txt])
353 AT_CAPTURE_FILE([expout])
354 AT_CAPTURE_FILE([experr])
355 AT_CHECK(
356   [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-ofp11-instructions < input.txt],
357   [0], [expout], [experr])
358 AT_CLEANUP