ofp-actions: Support "copy_field" ONF extension to OpenFlow 1.3.
[cascardo/ovs.git] / tests / ofp-actions.at
1 AT_BANNER([OpenFlow actions])
2
3 AT_SETUP([OpenFlow 1.0 action translation])
4 AT_KEYWORDS([ofp-actions 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:10:55
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 # bad OpenFlow10 actions: OFPBIC_UNSUP_INST
73 & ofp_actions|WARN|write_metadata instruction not allowed here
74 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
75
76 # bad OpenFlow10 actions: OFPBIC_UNSUP_INST
77 & ofp_actions|WARN|write_metadata instruction not allowed here
78 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffff0000ffff0000
79
80 # actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
81 ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
82
83 # actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
84 ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
85 0004 0008 00000000
86
87 # actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
88 ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
89 0004 0008 00000000
90
91 # actions=resubmit(10,5)
92 ffff 0010 00002320 000e 000a 05 000000
93
94 # actions=output:NXM_NX_REG1[5..10]
95 ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
96
97 # 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[])
98 ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
99 000c 00000802 0000 00000802 0000 dnl
100 0030 00000406 0000 00000206 0000 dnl
101 1010 00000002 0000 dnl
102 00000000
103
104 # actions=exit
105 ffff 0010 00002320 0011 000000000000
106
107 # actions=dec_ttl
108 ffff 0010 00002320 0012 000000000000
109
110 # actions=fin_timeout(idle_timeout=10,hard_timeout=20)
111 ffff 0010 00002320 0013 000a 0014 0000
112
113 # actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
114 ffff 0010 00002320 0014 04d2 162e 02 00
115
116 # actions=dec_ttl(32768,12345,90,765,1024)
117 ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
118
119 # actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
120 ffff 0018 00002320 001d 3039 00005BA0 00008707 0000B26E
121
122 # bad OpenFlow10 actions: OFPBAC_BAD_LEN
123 & ofp_actions|WARN|OpenFlow action OFPAT_OUTPUT length 240 exceeds action buffer length 8
124 & ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_LEN):
125 & 00000000  00 00 00 f0 00 00 00 00-
126 00 00 00 f0 00 00 00 00
127
128 # bad OpenFlow10 actions: OFPBAC_BAD_LEN
129 & ofp_actions|WARN|OpenFlow action OFPAT_OUTPUT length 16 not in valid range [[8,8]]
130 & ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_LEN):
131 & 00000000  00 00 00 10 ff fe ff ff-00 00 00 00 00 00 00 00
132 00 00 00 10 ff fe ff ff 00 00 00 00 00 00 00 00
133
134 # bad OpenFlow10 actions: OFPBAC_BAD_LEN
135 & ofp_actions|WARN|OpenFlow action NXAST_DEC_TTL_CNT_IDS length 17 is not a multiple of 8
136 ffff 0011 00002320 0015 0001 00000000 0000000000000000
137
138 ])
139 sed '/^[[#&]]/d' < test-data > input.txt
140 sed -n 's/^# //p; /^$/p' < test-data > expout
141 sed -n 's/^& //p' < test-data > experr
142 AT_CAPTURE_FILE([input.txt])
143 AT_CAPTURE_FILE([expout])
144 AT_CAPTURE_FILE([experr])
145 AT_CHECK(
146   [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow10 < input.txt],
147   [0], [expout], [experr])
148 AT_CLEANUP
149
150 AT_SETUP([OpenFlow 1.0 "instruction" translations])
151 AT_KEYWORDS([ofp-actions OF1.0 instruction])
152 AT_DATA([test-data], [dnl
153 dnl Try a couple of ordinary actions to make sure they're accepted,
154 dnl but there's no point in retrying all the actions from the previous test.
155 # actions=LOCAL
156 0000 0008 fffe 04d2
157
158 # actions=mod_dl_src:00:11:22:33:44:55
159 0004 0010 001122334455 000000000000
160
161 dnl Now check that write_metadata is accepted.
162 # actions=write_metadata:0xfedcba9876543210
163 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
164
165 # actions=write_metadata:0xfedcba9876543210/0xffff0000ffff0000
166 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffff0000ffff0000
167
168 ])
169 sed '/^[[#&]]/d' < test-data > input.txt
170 sed -n 's/^# //p; /^$/p' < test-data > expout
171 sed -n 's/^& //p' < test-data > experr
172 AT_CAPTURE_FILE([input.txt])
173 AT_CAPTURE_FILE([expout])
174 AT_CAPTURE_FILE([experr])
175 AT_CHECK(
176   [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-instructions OpenFlow10 < input.txt],
177   [0], [expout], [experr])
178 AT_CLEANUP
179
180 AT_SETUP([OpenFlow 1.1 action translation])
181 AT_KEYWORDS([ofp-actions OF1.1])
182 AT_DATA([test-data], [dnl
183 # actions=LOCAL
184 0000 0010 fffffffe 04d2 000000000000
185
186 # actions=CONTROLLER:1234
187 0000 0010 fffffffd 04d2 000000000000
188
189 # actions=set_vlan_vid:9
190 0001 0008 0009 0000
191
192 # actions=set_vlan_pcp:6
193 0002 0008 06 000000
194
195 # actions=mod_dl_src:00:11:22:33:44:55
196 0003 0010 001122334455 000000000000
197
198 # actions=mod_dl_dst:10:20:30:40:50:60
199 0004 0010 102030405060 000000000000
200
201 # actions=mod_nw_src:1.2.3.4
202 0005 0008 01020304
203
204 # actions=mod_nw_dst:192.168.0.1
205 0006 0008 c0a80001
206
207 # actions=mod_nw_tos:48
208 0007 0008 30 000000
209
210 # actions=mod_tp_src:80
211 0009 0008 0050 0000
212
213 # actions=mod_tp_dst:443
214 000a 0008 01bb 0000
215
216 # actions=pop_vlan
217 0012 0008 00000000
218
219 # actions=set_queue:2309737729
220 0015 0008 89abcd01
221
222 dnl 802.1ad isn't supported at the moment
223 dnl # actions=push_vlan:0x88a8
224 dnl 0011 0008 88a8 0000
225 # actions=push_vlan:0x8100
226 0011 0008 8100 0000
227
228 # actions=resubmit:5
229 ffff 0010 00002320 0001 0005 00000000
230
231 # actions=set_tunnel:0x12345678
232 ffff 0010 00002320 0002 0000 12345678
233
234 # actions=pop_queue
235 ffff 0010 00002320 0005 000000000000
236
237 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
238 ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
239
240 # actions=load:0xf009->NXM_OF_VLAN_TCI[]
241 ffff 0018 00002320 0007 000f 00000802 000000000000f009
242
243 # actions=note:11.e9.9a.ad.67.f3
244 ffff 0010 00002320 0008 11e99aad67f3
245
246 # actions=set_tunnel64:0xc426384d49c53d60
247 ffff 0018 00002320 0009 000000000000 c426384d49c53d60
248
249 # actions=set_tunnel64:0x885f3298
250 ffff 0018 00002320 0009 000000000000 00000000885f3298
251
252 dnl Write-Metadata is only allowed in contexts that allow instructions.
253 & ofp_actions|WARN|write_metadata instruction not allowed here
254 # bad OpenFlow11 actions: OFPBIC_UNSUP_INST
255 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
256
257 # actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
258 ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
259
260 # actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
261 ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
262 0004 0008 00000000
263
264 # actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
265 ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
266 0004 0008 00000000
267
268 # actions=resubmit(10,5)
269 ffff 0010 00002320 000e 000a 05 000000
270
271 # actions=output:NXM_NX_REG1[5..10]
272 ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
273
274 # 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[])
275 ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
276 000c 00000802 0000 00000802 0000 dnl
277 0030 00000406 0000 00000206 0000 dnl
278 1010 00000002 0000 dnl
279 00000000
280
281 # actions=exit
282 ffff 0010 00002320 0011 000000000000
283
284 dnl OpenFlow 1.1 OFPAT_DEC_TTL
285 # actions=dec_ttl
286 0018 0008 00000000
287
288 # actions=fin_timeout(idle_timeout=10,hard_timeout=20)
289 ffff 0010 00002320 0013 000a 0014 0000
290
291 # actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
292 ffff 0010 00002320 0014 04d2 162e 02 00
293
294 # actions=dec_ttl(32768,12345,90,765,1024)
295 ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
296
297 # actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
298 ffff 0018 00002320 001d 3039 00005BA0 00008707 0000B26E
299
300 ])
301 sed '/^[[#&]]/d' < test-data > input.txt
302 sed -n 's/^# //p; /^$/p' < test-data > expout
303 sed -n 's/^& //p' < test-data > experr
304 AT_CAPTURE_FILE([input.txt])
305 AT_CAPTURE_FILE([expout])
306 AT_CAPTURE_FILE([experr])
307 AT_CHECK(
308   [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow11 < input.txt],
309   [0], [expout], [experr])
310 AT_CLEANUP
311
312 AT_SETUP([OpenFlow 1.1 instruction translation])
313 AT_KEYWORDS([OF1.1 instruction ofp-actions])
314 AT_DATA([test-data], [dnl
315 # actions=LOCAL
316 0004 0018 00000000 dnl
317 0000 0010 fffffffe 04d2 000000000000
318
319 dnl Apply-Actions non-zero padding
320 # actions=drop
321 #  0: 00 -> (none)
322 #  1: 04 -> (none)
323 #  2: 00 -> (none)
324 #  3: 08 -> (none)
325 #  4: 00 -> (none)
326 #  5: 00 -> (none)
327 #  6: 00 -> (none)
328 #  7: 01 -> (none)
329 0004 0008 00000001
330
331 dnl Check that an empty Apply-Actions instruction gets dropped.
332 # actions=drop
333 #  0: 00 -> (none)
334 #  1: 04 -> (none)
335 #  2: 00 -> (none)
336 #  3: 08 -> (none)
337 #  4: 00 -> (none)
338 #  5: 00 -> (none)
339 #  6: 00 -> (none)
340 #  7: 00 -> (none)
341 0004 0008 00000000
342
343 dnl Duplicate instruction type:
344 # bad OpenFlow11 instructions: OFPBIC_DUP_INST
345 0004 0008 00000000 0004 0008 00000000
346
347 dnl Instructions not multiple of 8 in length.
348 & ofp_actions|WARN|OpenFlow message instructions length 9 is not a multiple of 8
349 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
350 0004 0009 01 00000000
351
352 dnl Goto-Table instruction too long.
353 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
354 0001 0010 01 000000 0000000000000000
355
356 dnl Goto-Table 1 instruction non-zero padding
357 # actions=goto_table:1
358 #  7: 01 -> 00
359 0001 0008 01 000001
360
361 dnl Goto-Table 1 instruction go back to the previous table.
362 # bad OpenFlow11 instructions: OFPBIC_BAD_TABLE_ID
363 2,0001 0008 01 000000
364
365 dnl Goto-Table 1
366 # actions=goto_table:1
367 0001 0008 01 000000
368
369 dnl Write-Metadata.
370 # actions=write_metadata:0xfedcba9876543210
371 0002 0018 00000000 fedcba9876543210 ffffffffffffffff
372
373 dnl Write-Metadata as Nicira extension action is transformed into instruction.
374 # actions=write_metadata:0xfedcba9876543210
375 #  1: 04 -> 02
376 #  3: 28 -> 18
377 #  8: ff -> fe
378 #  9: ff -> dc
379 # 10: 00 -> ba
380 # 11: 20 -> 98
381 # 12: 00 -> 76
382 # 13: 00 -> 54
383 # 14: 23 -> 32
384 # 15: 20 -> 10
385 # 16: 00 -> ff
386 # 17: 16 -> ff
387 # 18: 00 -> ff
388 # 19: 00 -> ff
389 # 20: 00 -> ff
390 # 21: 00 -> ff
391 # 22: 00 -> ff
392 # 23: 00 -> ff
393 # 24: fe -> (none)
394 # 25: dc -> (none)
395 # 26: ba -> (none)
396 # 27: 98 -> (none)
397 # 28: 76 -> (none)
398 # 29: 54 -> (none)
399 # 30: 32 -> (none)
400 # 31: 10 -> (none)
401 # 32: ff -> (none)
402 # 33: ff -> (none)
403 # 34: ff -> (none)
404 # 35: ff -> (none)
405 # 36: ff -> (none)
406 # 37: ff -> (none)
407 # 38: ff -> (none)
408 # 39: ff -> (none)
409 0004 0028 00000000 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
410
411 dnl Write-Metadata with mask.
412 # actions=write_metadata:0xfedcba9876543210/0xff00ff00ff00ff00
413 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
414
415 dnl Write-Metadata too short.
416 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
417 0002 0010 00000000 fedcba9876543210
418
419 dnl Write-Metadata too long.
420 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
421 0002 0020 00000000 fedcba9876543210 ffffffffffffffff 0000000000000000
422
423 dnl Write-Metadata duplicated.
424 # bad OpenFlow11 instructions: OFPBIC_DUP_INST
425 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
426
427 dnl Write-Metadata in wrong position (OpenFlow 1.1+ disregards the order
428 dnl and OVS reorders it to the canonical order)
429 # actions=write_metadata:0xfedcba9876543210,goto_table:1
430 #  1: 01 -> 02
431 #  3: 08 -> 18
432 #  4: 01 -> 00
433 #  8: 00 -> fe
434 #  9: 02 -> dc
435 # 10: 00 -> ba
436 # 11: 18 -> 98
437 # 12: 00 -> 76
438 # 13: 00 -> 54
439 # 14: 00 -> 32
440 # 15: 00 -> 10
441 # 16: fe -> ff
442 # 17: dc -> ff
443 # 18: ba -> ff
444 # 19: 98 -> ff
445 # 20: 76 -> ff
446 # 21: 54 -> ff
447 # 22: 32 -> ff
448 # 23: 10 -> ff
449 # 24: ff -> 00
450 # 25: ff -> 01
451 # 26: ff -> 00
452 # 27: ff -> 08
453 # 28: ff -> 01
454 # 29: ff -> 00
455 # 30: ff -> 00
456 # 31: ff -> 00
457 0001 0008 01 000000 0002 0018 00000000 fedcba9876543210 ffffffffffffffff
458
459 dnl empty Write-Actions non-zero padding
460 # actions=write_actions(drop)
461 #  0: 00 -> (none)
462 #  1: 03 -> (none)
463 #  2: 00 -> (none)
464 #  3: 08 -> (none)
465 #  4: 00 -> (none)
466 #  5: 00 -> (none)
467 #  6: 00 -> (none)
468 #  7: 01 -> (none)
469 0003 0008 00000001
470
471 dnl Check that an empty Write-Actions instruction gets dropped.
472 # actions=write_actions(drop)
473 #  0: 00 -> (none)
474 #  1: 03 -> (none)
475 #  2: 00 -> (none)
476 #  3: 08 -> (none)
477 #  4: 00 -> (none)
478 #  5: 00 -> (none)
479 #  6: 00 -> (none)
480 #  7: 00 -> (none)
481 0003 0008 00000000
482
483 dnl Clear-Actions too-long
484 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
485 0005 0010 00000000 0000000000000000
486
487 dnl Clear-Actions non-zero padding
488 # actions=clear_actions
489 #  7: 01 -> 00
490 0005 0008 00000001
491
492 dnl Clear-Actions non-zero padding
493 # actions=clear_actions
494 #  4: 01 -> 00
495 0005 0008 01 000000
496
497 dnl Clear-Actions
498 # actions=clear_actions
499 0005 0008 00000000
500
501 dnl Experimenter actions not supported yet.
502 # bad OpenFlow11 instructions: OFPBIC_BAD_EXPERIMENTER
503 ffff 0008 01 000000
504
505 dnl Bad instruction number (0 not assigned).
506 # bad OpenFlow11 instructions: OFPBIC_UNKNOWN_INST
507 0000 0008 01 000000
508
509 ])
510 sed '/^[[#&]]/d' < test-data > input.txt
511 sed -n 's/^# //p; /^$/p' < test-data > expout
512 sed -n 's/^& //p' < test-data > experr
513 AT_CAPTURE_FILE([input.txt])
514 AT_CAPTURE_FILE([expout])
515 AT_CAPTURE_FILE([experr])
516 AT_CHECK(
517   [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-instructions OpenFlow11 < input.txt],
518   [0], [expout], [experr])
519 AT_CLEANUP
520
521 dnl Our primary goal here is to verify OpenFlow 1.2-specific changes,
522 dnl so the list of tests is short.
523 AT_SETUP([OpenFlow 1.2 action translation])
524 AT_KEYWORDS([ofp-actions OF1.2])
525 AT_DATA([test-data], [dnl
526 # actions=LOCAL
527 0000 0010 fffffffe 04d2 000000000000
528
529 # bad OpenFlow12 actions: OFPBAC_BAD_SET_MASK
530 & ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_SET_MASK):
531 & 00000000  00 19 00 18 80 00 09 0c-00 00 00 00 12 34 00 00
532 & 00000010  00 00 ff ff 00 00 00 00-
533 0019 0018 8000090c 000000001234 00000000ffff 00000000
534
535 ])
536 sed '/^[[#&]]/d' < test-data > input.txt
537 sed -n 's/^# //p; /^$/p' < test-data > expout
538 sed -n 's/^& //p' < test-data > experr
539 AT_CAPTURE_FILE([input.txt])
540 AT_CAPTURE_FILE([expout])
541 AT_CAPTURE_FILE([experr])
542 AT_CHECK(
543   [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow12 < input.txt],
544   [0], [expout], [experr])
545 AT_CLEANUP
546
547 dnl Our primary goal here is to verify OpenFlow 1.3-specific changes,
548 dnl so the list of tests is short.
549 AT_SETUP([OpenFlow 1.3 action translation])
550 AT_KEYWORDS([ofp-actions OF1.3])
551 AT_DATA([test-data], [dnl
552 # actions=LOCAL
553 0000 0010 fffffffe 04d2 000000000000
554
555 dnl Check the Nicira extension form of "move".
556 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
557 ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
558
559 dnl Check the ONF extension form of "copy_field".
560 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
561 ffff 0020 4f4e4600 0c80 0000 0010 0000 0000 0000 00000002 00000802 00000000
562
563 ])
564 sed '/^[[#&]]/d' < test-data > input.txt
565 sed -n 's/^# //p; /^$/p' < test-data > expout
566 sed -n 's/^& //p' < test-data > experr
567 AT_CAPTURE_FILE([input.txt])
568 AT_CAPTURE_FILE([expout])
569 AT_CAPTURE_FILE([experr])
570 AT_CHECK(
571   [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow13 < input.txt],
572   [0], [expout], [experr])
573 AT_CLEANUP
574
575 dnl Our primary goal here is to verify that OpenFlow 1.5-specific changes,
576 dnl so the list of tests is short.
577 AT_SETUP([OpenFlow 1.5 action translation])
578 AT_KEYWORDS([ofp-actions OF1.5])
579 AT_DATA([test-data], [dnl
580 # actions=LOCAL
581 0000 0010 fffffffe 04d2 000000000000
582
583 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
584 001c 0018 0010 0000 0000 0000 00000002 00000802 00000000
585
586 # actions=set_field:00:00:00:00:12:34/00:00:00:00:ff:ff->eth_src
587 0019 0018 8000090c 000000001234 00000000ffff 00000000
588
589 ])
590 sed '/^[[#&]]/d' < test-data > input.txt
591 sed -n 's/^# //p; /^$/p' < test-data > expout
592 sed -n 's/^& //p' < test-data > experr
593 AT_CAPTURE_FILE([input.txt])
594 AT_CAPTURE_FILE([expout])
595 AT_CAPTURE_FILE([experr])
596 AT_CHECK(
597   [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow15 < input.txt],
598   [0], [expout], [experr])
599 AT_CLEANUP
600
601 AT_SETUP([ofp-actions - inconsistent MPLS actions])
602 OVS_VSWITCHD_START
603 dnl OK: Use fin_timeout action on TCP flow
604 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=fin_timeout(idle_timeout=1)'])
605 dnl Bad: Use fin_timeout action on TCP flow that has been converted to MPLS
606 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=push_mpls:0x8847,fin_timeout(idle_timeout=1)'],
607          [1], [], [dnl
608 ovs-ofctl: none of the usable flow formats (OpenFlow10,NXM) is among the allowed flow formats (OpenFlow11)
609 ])
610 OVS_VSWITCHD_STOP
611 AT_CLEANUP
612
613 AT_SETUP([reg_load <-> set_field translation corner case])
614 AT_KEYWORDS([ofp-actions])
615 OVS_VSWITCHD_START
616 dnl In OpenFlow 1.3, set_field always sets all the bits in the field,
617 dnl but when we translate to NXAST_LOAD we need to only set the bits that
618 dnl actually exist (e.g. mpls_label only has 20 bits) otherwise OVS rejects
619 dnl the "load" action as invalid.  Check that we do this correctly.
620 AT_CHECK([ovs-ofctl -O OpenFlow13 add-flow br0 mpls,actions=set_field:10-\>mpls_label])
621 AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
622 NXST_FLOW reply:
623  mpls actions=load:0xa->OXM_OF_MPLS_LABEL[[]]
624 ])
625 OVS_VSWITCHD_STOP
626 AT_CLEANUP