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