]> git.proxmox.com Git - mirror_ovs.git/blame - tests/ofp-actions.at
ofp-actions: Pass ofp_version to decode functions.
[mirror_ovs.git] / tests / ofp-actions.at
CommitLineData
f25d0cf3
BP
1AT_BANNER([OpenFlow actions])
2
3AT_SETUP([OpenFlow 1.0 action translation])
4cceacb9 4AT_KEYWORDS([ofp-actions OF1.0])
f25d0cf3
BP
5AT_DATA([test-data], [dnl
6# actions=LOCAL
70000 0008 fffe 04d2
8
9# actions=CONTROLLER:1234
100000 0008 fffd 04d2
11
12# actions=mod_vlan_vid:9
130001 0008 0009 0000
14
15# actions=mod_vlan_pcp:6
160002 0008 06 000000
17
18# actions=strip_vlan
190003 0008 00000000
20
21# actions=mod_dl_src:00:11:22:33:44:55
220004 0010 001122334455 000000000000
23
24# actions=mod_dl_dst:10:20:30:40:50:60
250005 0010 102030405060 000000000000
26
27# actions=mod_nw_src:1.2.3.4
280006 0008 01020304
29
30# actions=mod_nw_dst:192.168.0.1
310007 0008 c0a80001
32
33# actions=mod_nw_tos:48
340008 0008 30 000000
35
36# actions=mod_tp_src:80
370009 0008 0050 0000
38
39# actions=mod_tp_dst:443
40000a 0008 01bb 0000
41
b55f2f79 42# actions=enqueue:10:55
f25d0cf3
BP
43000b 0010 000a 000000000000 00000037
44
45# actions=resubmit:5
46ffff 0010 00002320 0001 0005 00000000
47
48# actions=set_tunnel:0x12345678
49ffff 0010 00002320 0002 0000 12345678
50
51# actions=set_queue:2309737729
52ffff 0010 00002320 0004 0000 89abcd01
53
54# actions=pop_queue
55ffff 0010 00002320 0005 000000000000
56
57# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
58ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
59
60# actions=load:0xf009->NXM_OF_VLAN_TCI[]
61ffff 0018 00002320 0007 000f 00000802 000000000000f009
62
63# actions=note:11.e9.9a.ad.67.f3
64ffff 0010 00002320 0008 11e99aad67f3
65
66# actions=set_tunnel64:0xc426384d49c53d60
67ffff 0018 00002320 0009 000000000000 c426384d49c53d60
68
69# actions=set_tunnel64:0x885f3298
70ffff 0018 00002320 0009 000000000000 00000000885f3298
71
65a8a59e 72# bad OpenFlow10 actions: OFPBIC_UNSUP_INST
8f2cded4 73& ofp_actions|WARN|write_metadata instruction not allowed here
4cceacb9
JS
74ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
75
65a8a59e 76# bad OpenFlow10 actions: OFPBIC_UNSUP_INST
8f2cded4 77& ofp_actions|WARN|write_metadata instruction not allowed here
4cceacb9
JS
78ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffff0000ffff0000
79
f25d0cf3
BP
80# actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
81ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
82
f25d0cf3
BP
83# actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
84ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
850004 0008 00000000
86
87# actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
88ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
890004 0008 00000000
90
91# actions=resubmit(10,5)
92ffff 0010 00002320 000e 000a 05 000000
93
94# actions=output:NXM_NX_REG1[5..10]
95ffff 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[])
98ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
99000c 00000802 0000 00000802 0000 dnl
1000030 00000406 0000 00000206 0000 dnl
1011010 00000002 0000 dnl
10200000000
103
104# actions=exit
105ffff 0010 00002320 0011 000000000000
106
107# actions=dec_ttl
108ffff 0010 00002320 0012 000000000000
109
110# actions=fin_timeout(idle_timeout=10,hard_timeout=20)
111ffff 0010 00002320 0013 000a 0014 0000
112
113# actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
114ffff 0010 00002320 0014 04d2 162e 02 00
115
c2d967a5
MM
116# actions=dec_ttl(32768,12345,90,765,1024)
117ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
118
29089a54
RL
119# actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
120ffff 0018 00002320 001d 3039 00005BA0 00008707 0000B26E
121
b153b990
BP
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-
12600 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
13200 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
136ffff 0011 00002320 0015 0001 00000000 0000000000000000
137
13d2c689
BP
138# bad OpenFlow10 actions: OFPBAC_BAD_OUT_PORT
1390000 0008 ffff 0000
140
f25d0cf3
BP
141])
142sed '/^[[#&]]/d' < test-data > input.txt
143sed -n 's/^# //p; /^$/p' < test-data > expout
144sed -n 's/^& //p' < test-data > experr
145AT_CAPTURE_FILE([input.txt])
146AT_CAPTURE_FILE([expout])
147AT_CAPTURE_FILE([experr])
148AT_CHECK(
65a8a59e 149 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow10 < input.txt],
f25d0cf3
BP
150 [0], [expout], [experr])
151AT_CLEANUP
d01c980f 152
8f2cded4
BP
153AT_SETUP([OpenFlow 1.0 "instruction" translations])
154AT_KEYWORDS([ofp-actions OF1.0 instruction])
155AT_DATA([test-data], [dnl
156dnl Try a couple of ordinary actions to make sure they're accepted,
157dnl but there's no point in retrying all the actions from the previous test.
158# actions=LOCAL
1590000 0008 fffe 04d2
160
161# actions=mod_dl_src:00:11:22:33:44:55
1620004 0010 001122334455 000000000000
163
164dnl Now check that write_metadata is accepted.
165# actions=write_metadata:0xfedcba9876543210
166ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
167
168# actions=write_metadata:0xfedcba9876543210/0xffff0000ffff0000
169ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffff0000ffff0000
170
171])
172sed '/^[[#&]]/d' < test-data > input.txt
173sed -n 's/^# //p; /^$/p' < test-data > expout
174sed -n 's/^& //p' < test-data > experr
175AT_CAPTURE_FILE([input.txt])
176AT_CAPTURE_FILE([expout])
177AT_CAPTURE_FILE([experr])
178AT_CHECK(
65a8a59e 179 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-instructions OpenFlow10 < input.txt],
8f2cded4
BP
180 [0], [expout], [experr])
181AT_CLEANUP
182
d01c980f 183AT_SETUP([OpenFlow 1.1 action translation])
4cceacb9 184AT_KEYWORDS([ofp-actions OF1.1])
d01c980f
BP
185AT_DATA([test-data], [dnl
186# actions=LOCAL
1870000 0010 fffffffe 04d2 000000000000
188
189# actions=CONTROLLER:1234
1900000 0010 fffffffd 04d2 000000000000
191
ca287d20 192# actions=set_vlan_vid:9
d01c980f
BP
1930001 0008 0009 0000
194
ca287d20 195# actions=set_vlan_pcp:6
d01c980f
BP
1960002 0008 06 000000
197
198# actions=mod_dl_src:00:11:22:33:44:55
1990003 0010 001122334455 000000000000
200
201# actions=mod_dl_dst:10:20:30:40:50:60
2020004 0010 102030405060 000000000000
203
204# actions=mod_nw_src:1.2.3.4
2050005 0008 01020304
206
207# actions=mod_nw_dst:192.168.0.1
2080006 0008 c0a80001
209
210# actions=mod_nw_tos:48
2110007 0008 30 000000
212
213# actions=mod_tp_src:80
2140009 0008 0050 0000
215
216# actions=mod_tp_dst:443
217000a 0008 01bb 0000
218
64fcc073 219# actions=pop_vlan
8e61c110
IY
2200012 0008 00000000
221
276c4e7a
SH
222# actions=set_queue:2309737729
2230015 0008 89abcd01
224
3e34fbdd
IY
225dnl 802.1ad isn't supported at the moment
226dnl # actions=push_vlan:0x88a8
227dnl 0011 0008 88a8 0000
228# actions=push_vlan:0x8100
2290011 0008 8100 0000
230
d01c980f
BP
231# actions=resubmit:5
232ffff 0010 00002320 0001 0005 00000000
233
234# actions=set_tunnel:0x12345678
235ffff 0010 00002320 0002 0000 12345678
236
d01c980f
BP
237# actions=pop_queue
238ffff 0010 00002320 0005 000000000000
239
240# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
241ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
242
243# actions=load:0xf009->NXM_OF_VLAN_TCI[]
244ffff 0018 00002320 0007 000f 00000802 000000000000f009
245
246# actions=note:11.e9.9a.ad.67.f3
247ffff 0010 00002320 0008 11e99aad67f3
248
249# actions=set_tunnel64:0xc426384d49c53d60
250ffff 0018 00002320 0009 000000000000 c426384d49c53d60
251
252# actions=set_tunnel64:0x885f3298
253ffff 0018 00002320 0009 000000000000 00000000885f3298
254
8f2cded4
BP
255dnl Write-Metadata is only allowed in contexts that allow instructions.
256& ofp_actions|WARN|write_metadata instruction not allowed here
65a8a59e 257# bad OpenFlow11 actions: OFPBIC_UNSUP_INST
4cceacb9
JS
258ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
259
d01c980f
BP
260# actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
261ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
262
d01c980f
BP
263# actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
264ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
2650004 0008 00000000
266
267# actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
268ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
2690004 0008 00000000
270
271# actions=resubmit(10,5)
272ffff 0010 00002320 000e 000a 05 000000
273
274# actions=output:NXM_NX_REG1[5..10]
275ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
276
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[])
278ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
279000c 00000802 0000 00000802 0000 dnl
2800030 00000406 0000 00000206 0000 dnl
2811010 00000002 0000 dnl
28200000000
283
284# actions=exit
285ffff 0010 00002320 0011 000000000000
286
7bcb1506
IY
287dnl OpenFlow 1.1 OFPAT_DEC_TTL
288# actions=dec_ttl
2890018 0008 00000000
290
d01c980f
BP
291# actions=fin_timeout(idle_timeout=10,hard_timeout=20)
292ffff 0010 00002320 0013 000a 0014 0000
293
294# actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
295ffff 0010 00002320 0014 04d2 162e 02 00
296
c2d967a5
MM
297# actions=dec_ttl(32768,12345,90,765,1024)
298ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
299
29089a54
RL
300# actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
301ffff 0018 00002320 001d 3039 00005BA0 00008707 0000B26E
302
13d2c689
BP
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
3060000 0010 ffffffff 0000 000000000000
307
d01c980f
BP
308])
309sed '/^[[#&]]/d' < test-data > input.txt
310sed -n 's/^# //p; /^$/p' < test-data > expout
311sed -n 's/^& //p' < test-data > experr
312AT_CAPTURE_FILE([input.txt])
313AT_CAPTURE_FILE([expout])
314AT_CAPTURE_FILE([experr])
315AT_CHECK(
65a8a59e 316 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow11 < input.txt],
d01c980f
BP
317 [0], [expout], [experr])
318AT_CLEANUP
319
320AT_SETUP([OpenFlow 1.1 instruction translation])
4cceacb9 321AT_KEYWORDS([OF1.1 instruction ofp-actions])
d01c980f
BP
322AT_DATA([test-data], [dnl
323# actions=LOCAL
3240004 0018 00000000 dnl
3250000 0010 fffffffe 04d2 000000000000
326
8dd54666
IY
327dnl Apply-Actions non-zero padding
328# actions=drop
329# 0: 00 -> (none)
330# 1: 04 -> (none)
331# 2: 00 -> (none)
332# 3: 08 -> (none)
333# 4: 00 -> (none)
334# 5: 00 -> (none)
335# 6: 00 -> (none)
336# 7: 01 -> (none)
3370004 0008 00000001
338
d01c980f
BP
339dnl Check that an empty Apply-Actions instruction gets dropped.
340# actions=drop
341# 0: 00 -> (none)
342# 1: 04 -> (none)
343# 2: 00 -> (none)
344# 3: 08 -> (none)
345# 4: 00 -> (none)
346# 5: 00 -> (none)
347# 6: 00 -> (none)
348# 7: 00 -> (none)
3490004 0008 00000000
350
e38c9de5 351dnl Duplicate instruction type:
65a8a59e 352# bad OpenFlow11 instructions: OFPBIC_DUP_INST
d01c980f
BP
3530004 0008 00000000 0004 0008 00000000
354
355dnl Instructions not multiple of 8 in length.
356& ofp_actions|WARN|OpenFlow message instructions length 9 is not a multiple of 8
65a8a59e 357# bad OpenFlow11 instructions: OFPBIC_BAD_LEN
d01c980f
BP
3580004 0009 01 00000000
359
360dnl Goto-Table instruction too long.
65a8a59e 361# bad OpenFlow11 instructions: OFPBIC_BAD_LEN
d01c980f
BP
3620001 0010 01 000000 0000000000000000
363
8dd54666
IY
364dnl Goto-Table 1 instruction non-zero padding
365# actions=goto_table:1
366# 7: 01 -> 00
3670001 0008 01 000001
368
bff7eeb6 369dnl Goto-Table 1 instruction go back to the previous table.
8c87971e 370# bad OpenFlow11 instructions: OFPBIC_BAD_TABLE_ID
bff7eeb6
JA
3712,0001 0008 01 000000
372
8dd54666
IY
373dnl Goto-Table 1
374# actions=goto_table:1
d01c980f
BP
3750001 0008 01 000000
376
4cceacb9
JS
377dnl Write-Metadata.
378# actions=write_metadata:0xfedcba9876543210
d01c980f
BP
3790002 0018 00000000 fedcba9876543210 ffffffffffffffff
380
8f2cded4
BP
381dnl Write-Metadata as Nicira extension action is transformed into instruction.
382# actions=write_metadata:0xfedcba9876543210
383# 1: 04 -> 02
384# 3: 28 -> 18
385# 8: ff -> fe
386# 9: ff -> dc
387# 10: 00 -> ba
388# 11: 20 -> 98
389# 12: 00 -> 76
390# 13: 00 -> 54
391# 14: 23 -> 32
392# 15: 20 -> 10
393# 16: 00 -> ff
394# 17: 16 -> ff
395# 18: 00 -> ff
396# 19: 00 -> ff
397# 20: 00 -> ff
398# 21: 00 -> ff
399# 22: 00 -> ff
400# 23: 00 -> ff
401# 24: fe -> (none)
402# 25: dc -> (none)
403# 26: ba -> (none)
404# 27: 98 -> (none)
405# 28: 76 -> (none)
406# 29: 54 -> (none)
407# 30: 32 -> (none)
408# 31: 10 -> (none)
409# 32: ff -> (none)
410# 33: ff -> (none)
411# 34: ff -> (none)
412# 35: ff -> (none)
413# 36: ff -> (none)
414# 37: ff -> (none)
415# 38: ff -> (none)
416# 39: ff -> (none)
4170004 0028 00000000 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
418
4cceacb9
JS
419dnl Write-Metadata with mask.
420# actions=write_metadata:0xfedcba9876543210/0xff00ff00ff00ff00
4210002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
422
d01c980f 423dnl Write-Metadata too short.
65a8a59e 424# bad OpenFlow11 instructions: OFPBIC_BAD_LEN
d01c980f
BP
4250002 0010 00000000 fedcba9876543210
426
427dnl Write-Metadata too long.
65a8a59e 428# bad OpenFlow11 instructions: OFPBIC_BAD_LEN
d01c980f
BP
4290002 0020 00000000 fedcba9876543210 ffffffffffffffff 0000000000000000
430
4cceacb9 431dnl Write-Metadata duplicated.
65a8a59e 432# bad OpenFlow11 instructions: OFPBIC_DUP_INST
4cceacb9
JS
4330002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
434
6813ee7c
BP
435dnl Write-Metadata in wrong position (OpenFlow 1.1+ disregards the order
436dnl and OVS reorders it to the canonical order)
437# actions=write_metadata:0xfedcba9876543210,goto_table:1
438# 1: 01 -> 02
439# 3: 08 -> 18
440# 4: 01 -> 00
441# 8: 00 -> fe
442# 9: 02 -> dc
443# 10: 00 -> ba
444# 11: 18 -> 98
445# 12: 00 -> 76
446# 13: 00 -> 54
447# 14: 00 -> 32
448# 15: 00 -> 10
449# 16: fe -> ff
450# 17: dc -> ff
451# 18: ba -> ff
452# 19: 98 -> ff
453# 20: 76 -> ff
454# 21: 54 -> ff
455# 22: 32 -> ff
456# 23: 10 -> ff
457# 24: ff -> 00
458# 25: ff -> 01
459# 26: ff -> 00
460# 27: ff -> 08
461# 28: ff -> 01
462# 29: ff -> 00
463# 30: ff -> 00
464# 31: ff -> 00
4cceacb9
JS
4650001 0008 01 000000 0002 0018 00000000 fedcba9876543210 ffffffffffffffff
466
7fdb60a7
SH
467dnl empty Write-Actions non-zero padding
468# actions=write_actions(drop)
469# 0: 00 -> (none)
470# 1: 03 -> (none)
471# 2: 00 -> (none)
472# 3: 08 -> (none)
473# 4: 00 -> (none)
474# 5: 00 -> (none)
475# 6: 00 -> (none)
476# 7: 01 -> (none)
4770003 0008 00000001
478
479dnl Check that an empty Write-Actions instruction gets dropped.
480# actions=write_actions(drop)
481# 0: 00 -> (none)
482# 1: 03 -> (none)
483# 2: 00 -> (none)
484# 3: 08 -> (none)
485# 4: 00 -> (none)
486# 5: 00 -> (none)
487# 6: 00 -> (none)
488# 7: 00 -> (none)
4890003 0008 00000000
d01c980f 490
b19e8793 491dnl Clear-Actions too-long
65a8a59e 492# bad OpenFlow11 instructions: OFPBIC_BAD_LEN
b19e8793
IY
4930005 0010 00000000 0000000000000000
494
495dnl Clear-Actions non-zero padding
496# actions=clear_actions
497# 7: 01 -> 00
4980005 0008 00000001
499
500dnl Clear-Actions non-zero padding
501# actions=clear_actions
502# 4: 01 -> 00
d01c980f
BP
5030005 0008 01 000000
504
b19e8793
IY
505dnl Clear-Actions
506# actions=clear_actions
5070005 0008 00000000
508
d01c980f 509dnl Experimenter actions not supported yet.
65a8a59e 510# bad OpenFlow11 instructions: OFPBIC_BAD_EXPERIMENTER
d01c980f
BP
511ffff 0008 01 000000
512
513dnl Bad instruction number (0 not assigned).
65a8a59e 514# bad OpenFlow11 instructions: OFPBIC_UNKNOWN_INST
d01c980f
BP
5150000 0008 01 000000
516
517])
518sed '/^[[#&]]/d' < test-data > input.txt
519sed -n 's/^# //p; /^$/p' < test-data > expout
520sed -n 's/^& //p' < test-data > experr
521AT_CAPTURE_FILE([input.txt])
522AT_CAPTURE_FILE([expout])
523AT_CAPTURE_FILE([experr])
524AT_CHECK(
65a8a59e 525 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-instructions OpenFlow11 < input.txt],
d01c980f
BP
526 [0], [expout], [experr])
527AT_CLEANUP
94baabf7 528
178742f9
BP
529dnl Our primary goal here is to verify OpenFlow 1.2-specific changes,
530dnl so the list of tests is short.
531AT_SETUP([OpenFlow 1.2 action translation])
532AT_KEYWORDS([ofp-actions OF1.2])
533AT_DATA([test-data], [dnl
534# actions=LOCAL
5350000 0010 fffffffe 04d2 000000000000
536
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-
5410019 0018 8000090c 000000001234 00000000ffff 00000000
542
543])
544sed '/^[[#&]]/d' < test-data > input.txt
545sed -n 's/^# //p; /^$/p' < test-data > expout
546sed -n 's/^& //p' < test-data > experr
547AT_CAPTURE_FILE([input.txt])
548AT_CAPTURE_FILE([expout])
549AT_CAPTURE_FILE([experr])
550AT_CHECK(
551 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow12 < input.txt],
552 [0], [expout], [experr])
553AT_CLEANUP
554
914624f8
BP
555dnl Our primary goal here is to verify OpenFlow 1.3-specific changes,
556dnl so the list of tests is short.
557AT_SETUP([OpenFlow 1.3 action translation])
558AT_KEYWORDS([ofp-actions OF1.3])
559AT_DATA([test-data], [dnl
560# actions=LOCAL
5610000 0010 fffffffe 04d2 000000000000
562
563dnl Check the Nicira extension form of "move".
564# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
565ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
566
567dnl Check the ONF extension form of "copy_field".
568# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
569ffff 0020 4f4e4600 0c80 0000 0010 0000 0000 0000 00000002 00000802 00000000
570
571])
572sed '/^[[#&]]/d' < test-data > input.txt
573sed -n 's/^# //p; /^$/p' < test-data > expout
574sed -n 's/^& //p' < test-data > experr
575AT_CAPTURE_FILE([input.txt])
576AT_CAPTURE_FILE([expout])
577AT_CAPTURE_FILE([experr])
578AT_CHECK(
579 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow13 < input.txt],
580 [0], [expout], [experr])
581AT_CLEANUP
582
da4425c7
BP
583dnl Our primary goal here is to verify that OpenFlow 1.5-specific changes,
584dnl so the list of tests is short.
73178f20
BP
585AT_SETUP([OpenFlow 1.5 action translation])
586AT_KEYWORDS([ofp-actions OF1.5])
587AT_DATA([test-data], [dnl
588# actions=LOCAL
5890000 0010 fffffffe 04d2 000000000000
590
591# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
650763d8 592001c 0018 0010 0000 0000 0000 00000002 00000802 00000000
73178f20 593
7eb4b1f1 594# actions=set_field:00:00:00:00:12:34/00:00:00:00:ff:ff->eth_src
178742f9 5950019 0018 8000090c 000000001234 00000000ffff 00000000
da4425c7 596
73178f20
BP
597])
598sed '/^[[#&]]/d' < test-data > input.txt
599sed -n 's/^# //p; /^$/p' < test-data > expout
600sed -n 's/^& //p' < test-data > experr
601AT_CAPTURE_FILE([input.txt])
602AT_CAPTURE_FILE([expout])
603AT_CAPTURE_FILE([experr])
604AT_CHECK(
605 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow15 < input.txt],
606 [0], [expout], [experr])
607AT_CLEANUP
608
94baabf7
SH
609AT_SETUP([ofp-actions - inconsistent MPLS actions])
610OVS_VSWITCHD_START
611dnl OK: Use fin_timeout action on TCP flow
612AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=fin_timeout(idle_timeout=1)'])
613dnl Bad: Use fin_timeout action on TCP flow that has been converted to MPLS
614AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=push_mpls:0x8847,fin_timeout(idle_timeout=1)'],
615 [1], [], [dnl
ba2fe8e9 616ovs-ofctl: none of the usable flow formats (OpenFlow10,NXM) is among the allowed flow formats (OpenFlow11)
94baabf7
SH
617])
618OVS_VSWITCHD_STOP
619AT_CLEANUP
fa078489
BP
620
621AT_SETUP([reg_load <-> set_field translation corner case])
622AT_KEYWORDS([ofp-actions])
623OVS_VSWITCHD_START
624dnl In OpenFlow 1.3, set_field always sets all the bits in the field,
625dnl but when we translate to NXAST_LOAD we need to only set the bits that
626dnl actually exist (e.g. mpls_label only has 20 bits) otherwise OVS rejects
627dnl the "load" action as invalid. Check that we do this correctly.
628AT_CHECK([ovs-ofctl -O OpenFlow13 add-flow br0 mpls,actions=set_field:10-\>mpls_label])
629AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
630NXST_FLOW reply:
631 mpls actions=load:0xa->OXM_OF_MPLS_LABEL[[]]
632])
633OVS_VSWITCHD_STOP
634AT_CLEANUP