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