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