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