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