1 AT_BANNER([OpenFlow actions])
3 AT_SETUP([OpenFlow 1.0 action translation])
4 AT_KEYWORDS([ofp-actions OF1.0])
5 AT_DATA([test-data], [dnl
9 # actions=CONTROLLER:1234
12 # actions=mod_vlan_vid:9
15 # actions=mod_vlan_pcp:6
21 # actions=mod_dl_src:00:11:22:33:44:55
22 0004 0010 001122334455 000000000000
24 # actions=mod_dl_dst:10:20:30:40:50:60
25 0005 0010 102030405060 000000000000
27 # actions=mod_nw_src:1.2.3.4
30 # actions=mod_nw_dst:192.168.0.1
33 # actions=mod_nw_tos:48
36 # actions=mod_tp_src:80
39 # actions=mod_tp_dst:443
42 # actions=enqueue:10:55
43 000b 0010 000a 000000000000 00000037
46 ffff 0010 00002320 0001 0005 00000000
48 # actions=set_tunnel:0x12345678
49 ffff 0010 00002320 0002 0000 12345678
51 # actions=set_queue:2309737729
52 ffff 0010 00002320 0004 0000 89abcd01
55 ffff 0010 00002320 0005 000000000000
57 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
58 ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
60 # actions=load:0xf009->NXM_OF_VLAN_TCI[]
61 ffff 0018 00002320 0007 000f 00000802 000000000000f009
63 # actions=note:11.e9.9a.ad.67.f3
64 ffff 0010 00002320 0008 11e99aad67f3
66 # actions=set_tunnel64:0xc426384d49c53d60
67 ffff 0018 00002320 0009 000000000000 c426384d49c53d60
69 # actions=set_tunnel64:0x885f3298
70 ffff 0018 00002320 0009 000000000000 00000000885f3298
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
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
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
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
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
91 # actions=resubmit(10,5)
92 ffff 0010 00002320 000e 000a 05 000000
94 # actions=output:NXM_NX_REG1[5..10]
95 ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
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
105 ffff 0010 00002320 0011 000000000000
108 ffff 0010 00002320 0012 000000000000
110 # actions=fin_timeout(idle_timeout=10,hard_timeout=20)
111 ffff 0010 00002320 0013 000a 0014 0000
113 # actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
114 ffff 0010 00002320 0014 04d2 162e 02 00
116 # actions=dec_ttl(32768,12345,90,765,1024)
117 ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
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
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
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
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
138 # bad OpenFlow10 actions: OFPBAC_BAD_OUT_PORT
142 sed '/^[[#&]]/d' < test-data > input.txt
143 sed -n 's/^# //p; /^$/p' < test-data > expout
144 sed -n 's/^& //p' < test-data > experr
145 AT_CAPTURE_FILE([input.txt])
146 AT_CAPTURE_FILE([expout])
147 AT_CAPTURE_FILE([experr])
149 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow10 < input.txt],
150 [0], [expout], [experr])
153 AT_SETUP([OpenFlow 1.0 "instruction" translations])
154 AT_KEYWORDS([ofp-actions OF1.0 instruction])
155 AT_DATA([test-data], [dnl
156 dnl Try a couple of ordinary actions to make sure they're accepted,
157 dnl but there's no point in retrying all the actions from the previous test.
161 # actions=mod_dl_src:00:11:22:33:44:55
162 0004 0010 001122334455 000000000000
164 dnl Now check that write_metadata is accepted.
165 # actions=write_metadata:0xfedcba9876543210
166 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
168 # actions=write_metadata:0xfedcba9876543210/0xffff0000ffff0000
169 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffff0000ffff0000
172 sed '/^[[#&]]/d' < test-data > input.txt
173 sed -n 's/^# //p; /^$/p' < test-data > expout
174 sed -n 's/^& //p' < test-data > experr
175 AT_CAPTURE_FILE([input.txt])
176 AT_CAPTURE_FILE([expout])
177 AT_CAPTURE_FILE([experr])
179 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-instructions OpenFlow10 < input.txt],
180 [0], [expout], [experr])
183 AT_SETUP([OpenFlow 1.1 action translation])
184 AT_KEYWORDS([ofp-actions OF1.1])
185 AT_DATA([test-data], [dnl
187 0000 0010 fffffffe 04d2 000000000000
189 # actions=CONTROLLER:1234
190 0000 0010 fffffffd 04d2 000000000000
192 # actions=set_vlan_vid:9
195 # actions=set_vlan_pcp:6
198 # actions=mod_dl_src:00:11:22:33:44:55
199 0003 0010 001122334455 000000000000
201 # actions=mod_dl_dst:10:20:30:40:50:60
202 0004 0010 102030405060 000000000000
204 # actions=mod_nw_src:1.2.3.4
207 # actions=mod_nw_dst:192.168.0.1
210 # actions=mod_nw_tos:48
213 # actions=mod_tp_src:80
216 # actions=mod_tp_dst:443
222 # actions=set_queue:2309737729
225 dnl 802.1ad isn't supported at the moment
226 dnl # actions=push_vlan:0x88a8
227 dnl 0011 0008 88a8 0000
228 # actions=push_vlan:0x8100
232 ffff 0010 00002320 0001 0005 00000000
234 # actions=set_tunnel:0x12345678
235 ffff 0010 00002320 0002 0000 12345678
238 ffff 0010 00002320 0005 000000000000
240 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
241 ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
243 # actions=load:0xf009->NXM_OF_VLAN_TCI[]
244 ffff 0018 00002320 0007 000f 00000802 000000000000f009
246 # actions=note:11.e9.9a.ad.67.f3
247 ffff 0010 00002320 0008 11e99aad67f3
249 # actions=set_tunnel64:0xc426384d49c53d60
250 ffff 0018 00002320 0009 000000000000 c426384d49c53d60
252 # actions=set_tunnel64:0x885f3298
253 ffff 0018 00002320 0009 000000000000 00000000885f3298
255 dnl Write-Metadata is only allowed in contexts that allow instructions.
256 & ofp_actions|WARN|write_metadata instruction not allowed here
257 # bad OpenFlow11 actions: OFPBIC_UNSUP_INST
258 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
260 # actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
261 ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
263 # actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
264 ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
267 # actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
268 ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
271 # actions=resubmit(10,5)
272 ffff 0010 00002320 000e 000a 05 000000
274 # actions=output:NXM_NX_REG1[5..10]
275 ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
277 # 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[])
278 ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
279 000c 00000802 0000 00000802 0000 dnl
280 0030 00000406 0000 00000206 0000 dnl
281 1010 00000002 0000 dnl
285 ffff 0010 00002320 0011 000000000000
287 dnl OpenFlow 1.1 OFPAT_DEC_TTL
291 # actions=fin_timeout(idle_timeout=10,hard_timeout=20)
292 ffff 0010 00002320 0013 000a 0014 0000
294 # actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
295 ffff 0010 00002320 0014 04d2 162e 02 00
297 # actions=dec_ttl(32768,12345,90,765,1024)
298 ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
300 # actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
301 ffff 0018 00002320 001d 3039 00005BA0 00008707 0000B26E
303 # bad OpenFlow11 actions: OFPBAC_BAD_OUT_PORT
304 & ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_OUT_PORT):
305 & 00000000 00 00 00 10 ff ff ff ff-00 00 00 00 00 00 00 00
306 0000 0010 ffffffff 0000 000000000000
309 sed '/^[[#&]]/d' < test-data > input.txt
310 sed -n 's/^# //p; /^$/p' < test-data > expout
311 sed -n 's/^& //p' < test-data > experr
312 AT_CAPTURE_FILE([input.txt])
313 AT_CAPTURE_FILE([expout])
314 AT_CAPTURE_FILE([experr])
316 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow11 < input.txt],
317 [0], [expout], [experr])
320 AT_SETUP([OpenFlow 1.1 instruction translation])
321 AT_KEYWORDS([OF1.1 instruction ofp-actions])
322 AT_DATA([test-data], [dnl
324 0004 0018 00000000 dnl
325 0000 0010 fffffffe 04d2 000000000000
327 dnl Apply-Actions non-zero padding
339 dnl Check that an empty Apply-Actions instruction gets dropped.
351 dnl Duplicate instruction type:
352 # bad OpenFlow11 instructions: OFPBIC_DUP_INST
353 0004 0008 00000000 0004 0008 00000000
355 dnl Instructions not multiple of 8 in length.
356 & ofp_actions|WARN|OpenFlow message instructions length 9 is not a multiple of 8
357 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
358 0004 0009 01 00000000
360 dnl Goto-Table instruction too long.
361 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
362 0001 0010 01 000000 0000000000000000
364 dnl Goto-Table 1 instruction non-zero padding
365 # actions=goto_table:1
369 dnl Goto-Table 1 instruction go back to the previous table.
370 # bad OpenFlow11 instructions: OFPBIC_BAD_TABLE_ID
371 2,0001 0008 01 000000
374 # actions=goto_table:1
378 # actions=write_metadata:0xfedcba9876543210
379 0002 0018 00000000 fedcba9876543210 ffffffffffffffff
381 dnl Write-Metadata as Nicira extension action is transformed into instruction.
382 # actions=write_metadata:0xfedcba9876543210
417 0004 0028 00000000 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
419 dnl Write-Metadata with mask.
420 # actions=write_metadata:0xfedcba9876543210/0xff00ff00ff00ff00
421 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
423 dnl Write-Metadata too short.
424 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
425 0002 0010 00000000 fedcba9876543210
427 dnl Write-Metadata too long.
428 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
429 0002 0020 00000000 fedcba9876543210 ffffffffffffffff 0000000000000000
431 dnl Write-Metadata duplicated.
432 # bad OpenFlow11 instructions: OFPBIC_DUP_INST
433 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
435 dnl Write-Metadata in wrong position (OpenFlow 1.1+ disregards the order
436 dnl and OVS reorders it to the canonical order)
437 # actions=write_metadata:0xfedcba9876543210,goto_table:1
465 0001 0008 01 000000 0002 0018 00000000 fedcba9876543210 ffffffffffffffff
467 dnl empty Write-Actions non-zero padding
468 # actions=write_actions(drop)
479 dnl Check that an empty Write-Actions instruction gets dropped.
480 # actions=write_actions(drop)
491 dnl Clear-Actions too-long
492 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
493 0005 0010 00000000 0000000000000000
495 dnl Clear-Actions non-zero padding
496 # actions=clear_actions
500 dnl Clear-Actions non-zero padding
501 # actions=clear_actions
506 # actions=clear_actions
509 dnl Experimenter actions not supported yet.
510 # bad OpenFlow11 instructions: OFPBIC_BAD_EXPERIMENTER
513 dnl Bad instruction number (0 not assigned).
514 # bad OpenFlow11 instructions: OFPBIC_UNKNOWN_INST
518 sed '/^[[#&]]/d' < test-data > input.txt
519 sed -n 's/^# //p; /^$/p' < test-data > expout
520 sed -n 's/^& //p' < test-data > experr
521 AT_CAPTURE_FILE([input.txt])
522 AT_CAPTURE_FILE([expout])
523 AT_CAPTURE_FILE([experr])
525 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-instructions OpenFlow11 < input.txt],
526 [0], [expout], [experr])
529 dnl Our primary goal here is to verify OpenFlow 1.2-specific changes,
530 dnl so the list of tests is short.
531 AT_SETUP([OpenFlow 1.2 action translation])
532 AT_KEYWORDS([ofp-actions OF1.2])
533 AT_DATA([test-data], [dnl
535 0000 0010 fffffffe 04d2 000000000000
537 # bad OpenFlow12 actions: OFPBAC_BAD_SET_MASK
538 & ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_SET_MASK):
539 & 00000000 00 19 00 18 80 00 09 0c-00 00 00 00 12 34 00 00
540 & 00000010 00 00 ff ff 00 00 00 00-
541 0019 0018 8000090c 000000001234 00000000ffff 00000000
544 sed '/^[[#&]]/d' < test-data > input.txt
545 sed -n 's/^# //p; /^$/p' < test-data > expout
546 sed -n 's/^& //p' < test-data > experr
547 AT_CAPTURE_FILE([input.txt])
548 AT_CAPTURE_FILE([expout])
549 AT_CAPTURE_FILE([experr])
551 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow12 < input.txt],
552 [0], [expout], [experr])
555 dnl Our primary goal here is to verify OpenFlow 1.3-specific changes,
556 dnl so the list of tests is short.
557 AT_SETUP([OpenFlow 1.3 action translation])
558 AT_KEYWORDS([ofp-actions OF1.3])
559 AT_DATA([test-data], [dnl
561 0000 0010 fffffffe 04d2 000000000000
563 dnl Check the Nicira extension form of "move".
564 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
565 ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
567 dnl Check the ONF extension form of "copy_field".
568 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
569 ffff 0020 4f4e4600 0c80 0000 0010 0000 0000 0000 00000002 00000802 00000000
572 sed '/^[[#&]]/d' < test-data > input.txt
573 sed -n 's/^# //p; /^$/p' < test-data > expout
574 sed -n 's/^& //p' < test-data > experr
575 AT_CAPTURE_FILE([input.txt])
576 AT_CAPTURE_FILE([expout])
577 AT_CAPTURE_FILE([experr])
579 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow13 < input.txt],
580 [0], [expout], [experr])
583 dnl Our primary goal here is to verify that OpenFlow 1.5-specific changes,
584 dnl so the list of tests is short.
585 AT_SETUP([OpenFlow 1.5 action translation])
586 AT_KEYWORDS([ofp-actions OF1.5])
587 AT_DATA([test-data], [dnl
589 0000 0010 fffffffe 04d2 000000000000
591 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
592 001c 0018 0010 0000 0000 0000 00000002 00000802 00000000
594 # actions=set_field:00:00:00:00:12:34/00:00:00:00:ff:ff->eth_src
595 0019 0018 8000090c 000000001234 00000000ffff 00000000
598 sed '/^[[#&]]/d' < test-data > input.txt
599 sed -n 's/^# //p; /^$/p' < test-data > expout
600 sed -n 's/^& //p' < test-data > experr
601 AT_CAPTURE_FILE([input.txt])
602 AT_CAPTURE_FILE([expout])
603 AT_CAPTURE_FILE([experr])
605 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow15 < input.txt],
606 [0], [expout], [experr])
609 AT_SETUP([ofp-actions - inconsistent MPLS actions])
611 dnl OK: Use fin_timeout action on TCP flow
612 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=fin_timeout(idle_timeout=1)'])
613 dnl Bad: Use fin_timeout action on TCP flow that has been converted to MPLS
614 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=push_mpls:0x8847,fin_timeout(idle_timeout=1)'],
616 ovs-ofctl: none of the usable flow formats (OpenFlow10,NXM) is among the allowed flow formats (OpenFlow11)
621 AT_SETUP([reg_load <-> set_field translation corner case])
622 AT_KEYWORDS([ofp-actions])
624 dnl In OpenFlow 1.3, set_field always sets all the bits in the field,
625 dnl but when we translate to NXAST_LOAD we need to only set the bits that
626 dnl actually exist (e.g. mpls_label only has 20 bits) otherwise OVS rejects
627 dnl the "load" action as invalid. Check that we do this correctly.
628 AT_CHECK([ovs-ofctl -O OpenFlow13 add-flow br0 mpls,actions=set_field:10-\>mpls_label])
629 AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
631 mpls actions=load:0xa->OXM_OF_MPLS_LABEL[[]]