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:10q55
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 # actions=write_metadata:0xfedcba9876543210
73 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
75 # actions=write_metadata:0xfedcba9876543210/0xffff0000ffff0000
76 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffff0000ffff0000
78 # actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
79 ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
81 # actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
82 ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
85 # actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
86 ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
89 # actions=resubmit(10,5)
90 ffff 0010 00002320 000e 000a 05 000000
92 # actions=output:NXM_NX_REG1[5..10]
93 ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
95 # 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[])
96 ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
97 000c 00000802 0000 00000802 0000 dnl
98 0030 00000406 0000 00000206 0000 dnl
99 1010 00000002 0000 dnl
103 ffff 0010 00002320 0011 000000000000
106 ffff 0010 00002320 0012 000000000000
108 # actions=fin_timeout(idle_timeout=10,hard_timeout=20)
109 ffff 0010 00002320 0013 000a 0014 0000
111 # actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
112 ffff 0010 00002320 0014 04d2 162e 02 00
114 # actions=dec_ttl(32768,12345,90,765,1024)
115 ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
118 sed '/^[[#&]]/d' < test-data > input.txt
119 sed -n 's/^# //p; /^$/p' < test-data > expout
120 sed -n 's/^& //p' < test-data > experr
121 AT_CAPTURE_FILE([input.txt])
122 AT_CAPTURE_FILE([expout])
123 AT_CAPTURE_FILE([experr])
125 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-ofp10-actions < input.txt],
126 [0], [expout], [experr])
129 AT_SETUP([OpenFlow 1.1 action translation])
130 AT_KEYWORDS([ofp-actions OF1.1])
131 AT_DATA([test-data], [dnl
133 0000 0010 fffffffe 04d2 000000000000
135 # actions=CONTROLLER:1234
136 0000 0010 fffffffd 04d2 000000000000
138 # actions=mod_vlan_vid:9
141 # actions=mod_vlan_pcp:6
144 # actions=mod_dl_src:00:11:22:33:44:55
145 0003 0010 001122334455 000000000000
147 # actions=mod_dl_dst:10:20:30:40:50:60
148 0004 0010 102030405060 000000000000
150 # actions=mod_nw_src:1.2.3.4
153 # actions=mod_nw_dst:192.168.0.1
156 # actions=mod_nw_tos:48
159 # actions=mod_tp_src:80
162 # actions=mod_tp_dst:443
168 # actions=set_queue:2309737729
171 dnl 802.1ad isn't supported at the moment
172 dnl # actions=push_vlan:0x88a8
173 dnl 0011 0008 88a8 0000
174 # actions=push_vlan:0x8100
178 ffff 0010 00002320 0001 0005 00000000
180 # actions=set_tunnel:0x12345678
181 ffff 0010 00002320 0002 0000 12345678
184 ffff 0010 00002320 0005 000000000000
186 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
187 ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
189 # actions=load:0xf009->NXM_OF_VLAN_TCI[]
190 ffff 0018 00002320 0007 000f 00000802 000000000000f009
192 # actions=note:11.e9.9a.ad.67.f3
193 ffff 0010 00002320 0008 11e99aad67f3
195 # actions=set_tunnel64:0xc426384d49c53d60
196 ffff 0018 00002320 0009 000000000000 c426384d49c53d60
198 # actions=set_tunnel64:0x885f3298
199 ffff 0018 00002320 0009 000000000000 00000000885f3298
201 dnl OpenFlow 1.1 uses OFPIT_WRITE_METADATA to express the NXAST_WRITE_METADATA
202 dnl action instead, so parse-ofp11-actions will recognise and drop this action.
203 # actions=write_metadata:0xfedcba9876543210
236 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
238 dnl Write-Metadata duplicated.
239 & ofp_actions|WARN|duplicate write_metadata instruction not allowed, for OpenFlow 1.1+ compatibility
240 # bad OF1.1 actions: OFPBAC_UNSUPPORTED_ORDER
241 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
243 dnl Write-Metadata in wrong position.
244 & ofp_actions|WARN|invalid instruction ordering: apply_actions must appear before write_metadata, for OpenFlow 1.1+ compatibility
245 # bad OF1.1 actions: OFPBAC_UNSUPPORTED_ORDER
246 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff ffff 0010 00002320 0002 0000 12345678
248 # actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
249 ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
251 # actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
252 ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
255 # actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
256 ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
259 # actions=resubmit(10,5)
260 ffff 0010 00002320 000e 000a 05 000000
262 # actions=output:NXM_NX_REG1[5..10]
263 ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
265 # 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[])
266 ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
267 000c 00000802 0000 00000802 0000 dnl
268 0030 00000406 0000 00000206 0000 dnl
269 1010 00000002 0000 dnl
273 ffff 0010 00002320 0011 000000000000
277 ffff 0010 00002320 0012 000000000000
279 dnl OpenFlow 1.1 OFPAT_DEC_TTL
283 # actions=fin_timeout(idle_timeout=10,hard_timeout=20)
284 ffff 0010 00002320 0013 000a 0014 0000
286 # actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
287 ffff 0010 00002320 0014 04d2 162e 02 00
289 # actions=dec_ttl(32768,12345,90,765,1024)
290 ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
293 sed '/^[[#&]]/d' < test-data > input.txt
294 sed -n 's/^# //p; /^$/p' < test-data > expout
295 sed -n 's/^& //p' < test-data > experr
296 AT_CAPTURE_FILE([input.txt])
297 AT_CAPTURE_FILE([expout])
298 AT_CAPTURE_FILE([experr])
300 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-ofp11-actions < input.txt],
301 [0], [expout], [experr])
304 AT_SETUP([OpenFlow 1.1 instruction translation])
305 AT_KEYWORDS([OF1.1 instruction ofp-actions])
306 AT_DATA([test-data], [dnl
308 0004 0018 00000000 dnl
309 0000 0010 fffffffe 04d2 000000000000
311 dnl Apply-Actions non-zero padding
323 dnl Check that an empty Apply-Actions instruction gets dropped.
335 dnl Duplicate instruction type:
336 # bad OF1.1 instructions: OFPBAC_UNSUPPORTED_ORDER
337 0004 0008 00000000 0004 0008 00000000
339 dnl Instructions not multiple of 8 in length.
340 & ofp_actions|WARN|OpenFlow message instructions length 9 is not a multiple of 8
341 # bad OF1.1 instructions: OFPBIC_BAD_LEN
342 0004 0009 01 00000000
344 dnl Goto-Table instruction too long.
345 # bad OF1.1 instructions: OFPBIC_BAD_LEN
346 0001 0010 01 000000 0000000000000000
348 dnl Goto-Table 1 instruction non-zero padding
349 # actions=goto_table:1
354 # actions=goto_table:1
358 # actions=write_metadata:0xfedcba9876543210
359 0002 0018 00000000 fedcba9876543210 ffffffffffffffff
361 dnl Write-Metadata with mask.
362 # actions=write_metadata:0xfedcba9876543210/0xff00ff00ff00ff00
363 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
365 dnl Write-Metadata too short.
366 # bad OF1.1 instructions: OFPBIC_BAD_LEN
367 0002 0010 00000000 fedcba9876543210
369 dnl Write-Metadata too long.
370 # bad OF1.1 instructions: OFPBIC_BAD_LEN
371 0002 0020 00000000 fedcba9876543210 ffffffffffffffff 0000000000000000
373 dnl Write-Metadata duplicated.
374 # bad OF1.1 instructions: OFPBAC_UNSUPPORTED_ORDER
375 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
377 dnl Write-Metadata in wrong position (OpenFlow 1.1+ disregards the order
378 dnl and OVS reorders it to the canonical order)
379 # actions=write_metadata:0xfedcba9876543210,goto_table:1
407 0001 0008 01 000000 0002 0018 00000000 fedcba9876543210 ffffffffffffffff
409 dnl Write-Actions not supported yet.
410 # bad OF1.1 instructions: OFPBIC_UNSUP_INST
413 dnl Clear-Actions too-long
414 # bad OF1.1 instructions: OFPBIC_BAD_LEN
415 0005 0010 00000000 0000000000000000
417 dnl Clear-Actions non-zero padding
418 # actions=clear_actions
422 dnl Clear-Actions non-zero padding
423 # actions=clear_actions
428 # actions=clear_actions
431 dnl Experimenter actions not supported yet.
432 # bad OF1.1 instructions: OFPBIC_BAD_EXPERIMENTER
435 dnl Bad instruction number (0 not assigned).
436 # bad OF1.1 instructions: OFPBIC_UNKNOWN_INST
440 sed '/^[[#&]]/d' < test-data > input.txt
441 sed -n 's/^# //p; /^$/p' < test-data > expout
442 sed -n 's/^& //p' < test-data > experr
443 AT_CAPTURE_FILE([input.txt])
444 AT_CAPTURE_FILE([expout])
445 AT_CAPTURE_FILE([experr])
447 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-ofp11-instructions < input.txt],
448 [0], [expout], [experr])