]> git.proxmox.com Git - mirror_ovs.git/blame - tests/ofp-actions.at
ofp-actions: Factor out decode_LEARN_{common,spec}().
[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
2cd20955
JR
94# actions=resubmit(10,5,ct)
95ffff 0010 00002320 002c 000a 05 000000
96
f25d0cf3
BP
97# actions=output:NXM_NX_REG1[5..10]
98ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
99
100# 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[])
101ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
102000c 00000802 0000 00000802 0000 dnl
1030030 00000406 0000 00000206 0000 dnl
1041010 00000002 0000 dnl
10500000000
106
107# actions=exit
108ffff 0010 00002320 0011 000000000000
109
110# actions=dec_ttl
111ffff 0010 00002320 0012 000000000000
112
113# actions=fin_timeout(idle_timeout=10,hard_timeout=20)
114ffff 0010 00002320 0013 000a 0014 0000
115
116# actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
117ffff 0010 00002320 0014 04d2 162e 02 00
118
77ab5fd2
BP
119# actions=controller(reason=invalid_ttl,max_len=1234,id=5678,userdata=01.02.03.04.05,pause)
120ffff 0040 00002320 0025 000000000000 dnl
bdcad671
BP
1210000 0008 04d2 0000 dnl
1220001 0008 162e 0000 dnl
1230002 0005 02 000000 dnl
77ab5fd2
BP
1240003 0009 0102030405 00000000000000 dnl
1250004 0004 00000000
bdcad671 126
c2d967a5
MM
127# actions=dec_ttl(32768,12345,90,765,1024)
128ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
129
29089a54
RL
130# actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
131ffff 0018 00002320 001d 3039 00005BA0 00008707 0000B26E
132
f69f713b
BY
133# actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678,sampling_port=56789)
134ffff 0020 00002320 0026 3039 00005BA0 00008707 0000B26E DDD50000 00000000
135
4930ea56
BP
136# actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678,sampling_port=56789,egress)
137ffff 0020 00002320 0029 3039 00005BA0 00008707 0000B26E DDD50200 00000000
138
b153b990
BP
139# bad OpenFlow10 actions: OFPBAC_BAD_LEN
140& ofp_actions|WARN|OpenFlow action OFPAT_OUTPUT length 240 exceeds action buffer length 8
141& ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_LEN):
142& 00000000 00 00 00 f0 00 00 00 00-
14300 00 00 f0 00 00 00 00
144
145# bad OpenFlow10 actions: OFPBAC_BAD_LEN
146& ofp_actions|WARN|OpenFlow action OFPAT_OUTPUT length 16 not in valid range [[8,8]]
147& ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_LEN):
148& 00000000 00 00 00 10 ff fe ff ff-00 00 00 00 00 00 00 00
14900 00 00 10 ff fe ff ff 00 00 00 00 00 00 00 00
150
151# bad OpenFlow10 actions: OFPBAC_BAD_LEN
152& ofp_actions|WARN|OpenFlow action NXAST_DEC_TTL_CNT_IDS length 17 is not a multiple of 8
153ffff 0011 00002320 0015 0001 00000000 0000000000000000
154
13d2c689
BP
155# bad OpenFlow10 actions: OFPBAC_BAD_OUT_PORT
1560000 0008 ffff 0000
157
07659514
JS
158# actions=ct()
159ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0000
160
161# actions=ct(commit)
162ffff 0018 00002320 0023 0001 00000000 0000 FF 000000 0000
163
a76a37ef
JR
164# actions=ct(commit,force)
165ffff 0018 00002320 0023 0003 00000000 0000 FF 000000 0000
166
167# bad OpenFlow10 actions: OFPBAC_BAD_ARGUMENT
168ffff 0018 00002320 0023 0002 00000000 0000 FF 000000 0000
169
07659514
JS
170# actions=ct(table=10)
171ffff 0018 00002320 0023 0000 00000000 0000 0A 000000 0000
172
173# actions=ct(zone=10)
174ffff 0018 00002320 0023 0000 00000000 000A FF 000000 0000
175
176# actions=ct(zone=NXM_NX_REG0[0..15])
177ffff 0018 00002320 0023 0000 00010004 000F FF 000000 0000
178
179dnl Can't read 8 bits from register into 16-bit zone.
180# bad OpenFlow10 actions: OFPBAC_BAD_SET_LEN
181ffff 0018 00002320 0023 0000 00010004 0007 FF 000000 0000
182
183dnl Can't read 32 bits from register into 16-bit zone.
184# bad OpenFlow10 actions: OFPBAC_BAD_SET_LEN
185ffff 0018 00002320 0023 0000 00010004 001F FF 000000 0000
186
8e53fe8c
JS
187# actions=ct(commit,exec(load:0xf009->NXM_NX_CT_MARK[]))
188ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
189ffff 0018 00002320 0007 001f 0001d604 000000000000f009
190
a76a37ef
JR
191# actions=ct(commit,force,exec(load:0xf009->NXM_NX_CT_MARK[]))
192ffff 0030 00002320 0023 0003 00000000 0000 FF 000000 0000 dnl
193ffff 0018 00002320 0007 001f 0001d604 000000000000f009
194
8e53fe8c
JS
195# bad OpenFlow10 actions: OFPBAC_BAD_SET_ARGUMENT
196& ofp_actions|WARN|cannot set CT fields outside of ct action
197ffff 0018 00002320 0007 001f 0001d604 000000000000f009
198
199# bad OpenFlow10 actions: OFPBAC_BAD_SET_ARGUMENT
200& meta_flow|WARN|destination field ct_zone is not writable
201ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
202ffff 0018 00002320 0007 000f 0001d504 000000000000f009
203
204# bad OpenFlow10 actions: OFPBAC_BAD_ARGUMENT
205& ofp_actions|WARN|ct action doesn't support nested action ct
206ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
207ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0000
208
209# bad OpenFlow10 actions: OFPBAC_BAD_ARGUMENT
210& ofp_actions|WARN|ct action doesn't support nested modification of reg0
211ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
212ffff 0018 00002320 0007 001f 00010004 000000000000f009
213
d787ad39
JS
214# actions=ct(alg=ftp)
215ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0015
216
40c7b2fc
JS
217# actions=ct(alg=tftp)
218ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0045
219
9ac0aada
JR
220# actions=ct(commit,nat(src))
221ffff 0028 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
222ffff 0010 00002320 0024 00 00 0001 0000
223
224# actions=ct(commit,nat(dst))
225ffff 0028 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
226ffff 0010 00002320 0024 00 00 0002 0000
227
228# actions=ct(nat)
229ffff 0028 00002320 0023 0000 00000000 0000 FF 000000 0000 dnl
230ffff 0010 00002320 0024 00 00 0000 0000
231
232# actions=ct(commit,nat(src=10.0.0.240,random))
233ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
234ffff 0018 00002320 0024 00 00 0011 0001 0a0000f0 00000000
235
236# actions=ct(commit,nat(src=10.0.0.240:32768-65535,random))
237ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
238ffff 0018 00002320 0024 00 00 0011 0031 0a0000f0 8000ffff
239
240# actions=ct(commit,nat(dst=10.0.0.128-10.0.0.254,hash))
241ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
242ffff 0018 00002320 0024 00 00 000a 0003 0a000080 0a0000fe
243
244# actions=ct(commit,nat(src=10.0.0.240-10.0.0.254:32768-65535,persistent))
245ffff 0038 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
246ffff 0020 00002320 0024 00 00 0005 0033 0a0000f0 0a0000fe 8000ffff 00000000
247
248# actions=ct(commit,nat(src=fe80::20c:29ff:fe88:a18b,random))
249ffff 0038 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
250ffff 0020 00002320 0024 00 00 0011 0004 fe800000 00000000 020c 29ff fe88 a18b
251
252# actions=ct(commit,nat(src=fe80::20c:29ff:fe88:1-fe80::20c:29ff:fe88:a18b,random))
253ffff 0048 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
254ffff 0030 00002320 0024 00 00 0011 000c fe800000 00000000 020c 29ff fe88 0001 fe800000 00000000 020c 29ff fe88 a18b
255
256# actions=ct(commit,nat(src=[fe80::20c:29ff:fe88:1]-[fe80::20c:29ff:fe88:a18b]:255-4096,random))
257ffff 0050 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
258ffff 0038 00002320 0024 00 00 0011 003c dnl
259fe800000 00000000 020c 29ff fe88 0001 dnl
260fe800000 00000000 020c 29ff fe88 a18b dnl
26100ff1000 00000000
262
72fe7578
BP
263# actions=ct_clear
264ffff 0010 00002320 002b 000000000000
265
aaca4fe0
WT
266# actions=output(port=1,max_len=100)
267ffff 0010 00002320 0027 0001 00000064
268
7ae62a67
WT
269# actions=clone(mod_vlan_vid:5,output:10)
270ffff 0020 00002320 002a 000000000000 dnl
2710001 0008 0005 0000 dnl
2720000 0008 000a 0000
273
88c8ca26
BP
274# actions=group:5
275ffff 0010 00002320 0028 0000 00000005
276
77ab5fd2
BP
277# bad OpenFlow10 actions: NXBRC_MUST_BE_ZERO
278ffff 0018 00002320 0025 0000 0005 0000 1122334455 000005
279
280# bad OpenFlow10 actions: NXBRC_MUST_BE_ZERO
281ffff 0018 00002320 0025 0000 0005 5000 1122334455 000000
282
9ac0aada
JR
283# bad OpenFlow10 actions: OFPBAC_BAD_ARGUMENT
284ffff 0048 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
285ffff 0030 00002320 0024 00 00 0011 000c fe800000 00000000 020c 29ff fe88 a18b fe800000 00000000 020c 29ff fe88 0001
286
f25d0cf3
BP
287])
288sed '/^[[#&]]/d' < test-data > input.txt
289sed -n 's/^# //p; /^$/p' < test-data > expout
290sed -n 's/^& //p' < test-data > experr
291AT_CAPTURE_FILE([input.txt])
292AT_CAPTURE_FILE([expout])
293AT_CAPTURE_FILE([experr])
294AT_CHECK(
65a8a59e 295 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow10 < input.txt],
f25d0cf3
BP
296 [0], [expout], [experr])
297AT_CLEANUP
d01c980f 298
8f2cded4
BP
299AT_SETUP([OpenFlow 1.0 "instruction" translations])
300AT_KEYWORDS([ofp-actions OF1.0 instruction])
301AT_DATA([test-data], [dnl
302dnl Try a couple of ordinary actions to make sure they're accepted,
303dnl but there's no point in retrying all the actions from the previous test.
304# actions=LOCAL
3050000 0008 fffe 04d2
306
307# actions=mod_dl_src:00:11:22:33:44:55
3080004 0010 001122334455 000000000000
309
310dnl Now check that write_metadata is accepted.
311# actions=write_metadata:0xfedcba9876543210
312ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
313
314# actions=write_metadata:0xfedcba9876543210/0xffff0000ffff0000
315ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffff0000ffff0000
316
317])
318sed '/^[[#&]]/d' < test-data > input.txt
319sed -n 's/^# //p; /^$/p' < test-data > expout
320sed -n 's/^& //p' < test-data > experr
321AT_CAPTURE_FILE([input.txt])
322AT_CAPTURE_FILE([expout])
323AT_CAPTURE_FILE([experr])
324AT_CHECK(
65a8a59e 325 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-instructions OpenFlow10 < input.txt],
8f2cded4
BP
326 [0], [expout], [experr])
327AT_CLEANUP
328
d01c980f 329AT_SETUP([OpenFlow 1.1 action translation])
4cceacb9 330AT_KEYWORDS([ofp-actions OF1.1])
d01c980f
BP
331AT_DATA([test-data], [dnl
332# actions=LOCAL
3330000 0010 fffffffe 04d2 000000000000
334
335# actions=CONTROLLER:1234
3360000 0010 fffffffd 04d2 000000000000
337
ca287d20 338# actions=set_vlan_vid:9
d01c980f
BP
3390001 0008 0009 0000
340
ca287d20 341# actions=set_vlan_pcp:6
d01c980f
BP
3420002 0008 06 000000
343
344# actions=mod_dl_src:00:11:22:33:44:55
3450003 0010 001122334455 000000000000
346
347# actions=mod_dl_dst:10:20:30:40:50:60
3480004 0010 102030405060 000000000000
349
350# actions=mod_nw_src:1.2.3.4
3510005 0008 01020304
352
353# actions=mod_nw_dst:192.168.0.1
3540006 0008 c0a80001
355
356# actions=mod_nw_tos:48
3570007 0008 30 000000
358
4b684612
BP
359# actions=mod_nw_ecn:2
3600008 0008 02 000000
361
d01c980f
BP
362# actions=mod_tp_src:80
3630009 0008 0050 0000
364
365# actions=mod_tp_dst:443
366000a 0008 01bb 0000
367
64fcc073 368# actions=pop_vlan
8e61c110
IY
3690012 0008 00000000
370
276c4e7a
SH
371# actions=set_queue:2309737729
3720015 0008 89abcd01
373
3e34fbdd
IY
374dnl 802.1ad isn't supported at the moment
375dnl # actions=push_vlan:0x88a8
376dnl 0011 0008 88a8 0000
377# actions=push_vlan:0x8100
3780011 0008 8100 0000
379
d01c980f
BP
380# actions=resubmit:5
381ffff 0010 00002320 0001 0005 00000000
382
383# actions=set_tunnel:0x12345678
384ffff 0010 00002320 0002 0000 12345678
385
d01c980f
BP
386# actions=pop_queue
387ffff 0010 00002320 0005 000000000000
388
389# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
390ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
391
392# actions=load:0xf009->NXM_OF_VLAN_TCI[]
393ffff 0018 00002320 0007 000f 00000802 000000000000f009
394
395# actions=note:11.e9.9a.ad.67.f3
396ffff 0010 00002320 0008 11e99aad67f3
397
398# actions=set_tunnel64:0xc426384d49c53d60
399ffff 0018 00002320 0009 000000000000 c426384d49c53d60
400
401# actions=set_tunnel64:0x885f3298
402ffff 0018 00002320 0009 000000000000 00000000885f3298
403
8f2cded4
BP
404dnl Write-Metadata is only allowed in contexts that allow instructions.
405& ofp_actions|WARN|write_metadata instruction not allowed here
65a8a59e 406# bad OpenFlow11 actions: OFPBIC_UNSUP_INST
4cceacb9
JS
407ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
408
d01c980f
BP
409# actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
410ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
411
d01c980f
BP
412# actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
413ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
4140004 0008 00000000
415
416# actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
417ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
4180004 0008 00000000
419
420# actions=resubmit(10,5)
421ffff 0010 00002320 000e 000a 05 000000
422
2cd20955
JR
423# actions=resubmit(10,5,ct)
424ffff 0010 00002320 002c 000a 05 000000
425
d01c980f
BP
426# actions=output:NXM_NX_REG1[5..10]
427ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
428
429# 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[])
430ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
431000c 00000802 0000 00000802 0000 dnl
4320030 00000406 0000 00000206 0000 dnl
4331010 00000002 0000 dnl
43400000000
435
436# actions=exit
437ffff 0010 00002320 0011 000000000000
438
7bcb1506
IY
439dnl OpenFlow 1.1 OFPAT_DEC_TTL
440# actions=dec_ttl
4410018 0008 00000000
442
d01c980f
BP
443# actions=fin_timeout(idle_timeout=10,hard_timeout=20)
444ffff 0010 00002320 0013 000a 0014 0000
445
446# actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
447ffff 0010 00002320 0014 04d2 162e 02 00
448
c2d967a5
MM
449# actions=dec_ttl(32768,12345,90,765,1024)
450ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
451
29089a54
RL
452# actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
453ffff 0018 00002320 001d 3039 00005BA0 00008707 0000B26E
454
13d2c689
BP
455# bad OpenFlow11 actions: OFPBAC_BAD_OUT_PORT
456& ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_OUT_PORT):
457& 00000000 00 00 00 10 ff ff ff ff-00 00 00 00 00 00 00 00
4580000 0010 ffffffff 0000 000000000000
459
d01c980f
BP
460])
461sed '/^[[#&]]/d' < test-data > input.txt
462sed -n 's/^# //p; /^$/p' < test-data > expout
463sed -n 's/^& //p' < test-data > experr
464AT_CAPTURE_FILE([input.txt])
465AT_CAPTURE_FILE([expout])
466AT_CAPTURE_FILE([experr])
467AT_CHECK(
65a8a59e 468 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow11 < input.txt],
d01c980f
BP
469 [0], [expout], [experr])
470AT_CLEANUP
471
472AT_SETUP([OpenFlow 1.1 instruction translation])
4cceacb9 473AT_KEYWORDS([OF1.1 instruction ofp-actions])
d01c980f
BP
474AT_DATA([test-data], [dnl
475# actions=LOCAL
4760004 0018 00000000 dnl
4770000 0010 fffffffe 04d2 000000000000
478
8dd54666
IY
479dnl Apply-Actions non-zero padding
480# actions=drop
481# 0: 00 -> (none)
482# 1: 04 -> (none)
483# 2: 00 -> (none)
484# 3: 08 -> (none)
485# 4: 00 -> (none)
486# 5: 00 -> (none)
487# 6: 00 -> (none)
488# 7: 01 -> (none)
4890004 0008 00000001
490
d01c980f
BP
491dnl Check that an empty Apply-Actions instruction gets dropped.
492# actions=drop
493# 0: 00 -> (none)
494# 1: 04 -> (none)
495# 2: 00 -> (none)
496# 3: 08 -> (none)
497# 4: 00 -> (none)
498# 5: 00 -> (none)
499# 6: 00 -> (none)
500# 7: 00 -> (none)
5010004 0008 00000000
502
e38c9de5 503dnl Duplicate instruction type:
65a8a59e 504# bad OpenFlow11 instructions: OFPBIC_DUP_INST
d01c980f
BP
5050004 0008 00000000 0004 0008 00000000
506
507dnl Instructions not multiple of 8 in length.
508& ofp_actions|WARN|OpenFlow message instructions length 9 is not a multiple of 8
65a8a59e 509# bad OpenFlow11 instructions: OFPBIC_BAD_LEN
d01c980f
BP
5100004 0009 01 00000000
511
512dnl Goto-Table instruction too long.
65a8a59e 513# bad OpenFlow11 instructions: OFPBIC_BAD_LEN
d01c980f
BP
5140001 0010 01 000000 0000000000000000
515
8dd54666
IY
516dnl Goto-Table 1 instruction non-zero padding
517# actions=goto_table:1
518# 7: 01 -> 00
5190001 0008 01 000001
520
bff7eeb6 521dnl Goto-Table 1 instruction go back to the previous table.
8c87971e 522# bad OpenFlow11 instructions: OFPBIC_BAD_TABLE_ID
bff7eeb6
JA
5232,0001 0008 01 000000
524
8dd54666
IY
525dnl Goto-Table 1
526# actions=goto_table:1
d01c980f
BP
5270001 0008 01 000000
528
4cceacb9
JS
529dnl Write-Metadata.
530# actions=write_metadata:0xfedcba9876543210
d01c980f
BP
5310002 0018 00000000 fedcba9876543210 ffffffffffffffff
532
8f2cded4
BP
533dnl Write-Metadata as Nicira extension action is transformed into instruction.
534# actions=write_metadata:0xfedcba9876543210
535# 1: 04 -> 02
536# 3: 28 -> 18
537# 8: ff -> fe
538# 9: ff -> dc
539# 10: 00 -> ba
540# 11: 20 -> 98
541# 12: 00 -> 76
542# 13: 00 -> 54
543# 14: 23 -> 32
544# 15: 20 -> 10
545# 16: 00 -> ff
546# 17: 16 -> ff
547# 18: 00 -> ff
548# 19: 00 -> ff
549# 20: 00 -> ff
550# 21: 00 -> ff
551# 22: 00 -> ff
552# 23: 00 -> ff
553# 24: fe -> (none)
554# 25: dc -> (none)
555# 26: ba -> (none)
556# 27: 98 -> (none)
557# 28: 76 -> (none)
558# 29: 54 -> (none)
559# 30: 32 -> (none)
560# 31: 10 -> (none)
561# 32: ff -> (none)
562# 33: ff -> (none)
563# 34: ff -> (none)
564# 35: ff -> (none)
565# 36: ff -> (none)
566# 37: ff -> (none)
567# 38: ff -> (none)
568# 39: ff -> (none)
5690004 0028 00000000 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
570
4cceacb9
JS
571dnl Write-Metadata with mask.
572# actions=write_metadata:0xfedcba9876543210/0xff00ff00ff00ff00
5730002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
574
d01c980f 575dnl Write-Metadata too short.
65a8a59e 576# bad OpenFlow11 instructions: OFPBIC_BAD_LEN
d01c980f
BP
5770002 0010 00000000 fedcba9876543210
578
579dnl Write-Metadata too long.
65a8a59e 580# bad OpenFlow11 instructions: OFPBIC_BAD_LEN
d01c980f
BP
5810002 0020 00000000 fedcba9876543210 ffffffffffffffff 0000000000000000
582
4cceacb9 583dnl Write-Metadata duplicated.
65a8a59e 584# bad OpenFlow11 instructions: OFPBIC_DUP_INST
4cceacb9
JS
5850002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
586
6813ee7c
BP
587dnl Write-Metadata in wrong position (OpenFlow 1.1+ disregards the order
588dnl and OVS reorders it to the canonical order)
589# actions=write_metadata:0xfedcba9876543210,goto_table:1
590# 1: 01 -> 02
591# 3: 08 -> 18
592# 4: 01 -> 00
593# 8: 00 -> fe
594# 9: 02 -> dc
595# 10: 00 -> ba
596# 11: 18 -> 98
597# 12: 00 -> 76
598# 13: 00 -> 54
599# 14: 00 -> 32
600# 15: 00 -> 10
601# 16: fe -> ff
602# 17: dc -> ff
603# 18: ba -> ff
604# 19: 98 -> ff
605# 20: 76 -> ff
606# 21: 54 -> ff
607# 22: 32 -> ff
608# 23: 10 -> ff
609# 24: ff -> 00
610# 25: ff -> 01
611# 26: ff -> 00
612# 27: ff -> 08
613# 28: ff -> 01
614# 29: ff -> 00
615# 30: ff -> 00
616# 31: ff -> 00
4cceacb9
JS
6170001 0008 01 000000 0002 0018 00000000 fedcba9876543210 ffffffffffffffff
618
7fdb60a7
SH
619dnl empty Write-Actions non-zero padding
620# actions=write_actions(drop)
621# 0: 00 -> (none)
622# 1: 03 -> (none)
623# 2: 00 -> (none)
624# 3: 08 -> (none)
625# 4: 00 -> (none)
626# 5: 00 -> (none)
627# 6: 00 -> (none)
628# 7: 01 -> (none)
6290003 0008 00000001
630
631dnl Check that an empty Write-Actions instruction gets dropped.
632# actions=write_actions(drop)
633# 0: 00 -> (none)
634# 1: 03 -> (none)
635# 2: 00 -> (none)
636# 3: 08 -> (none)
637# 4: 00 -> (none)
638# 5: 00 -> (none)
639# 6: 00 -> (none)
640# 7: 00 -> (none)
6410003 0008 00000000
d01c980f 642
b19e8793 643dnl Clear-Actions too-long
65a8a59e 644# bad OpenFlow11 instructions: OFPBIC_BAD_LEN
b19e8793
IY
6450005 0010 00000000 0000000000000000
646
647dnl Clear-Actions non-zero padding
648# actions=clear_actions
649# 7: 01 -> 00
6500005 0008 00000001
651
652dnl Clear-Actions non-zero padding
653# actions=clear_actions
654# 4: 01 -> 00
d01c980f
BP
6550005 0008 01 000000
656
b19e8793
IY
657dnl Clear-Actions
658# actions=clear_actions
6590005 0008 00000000
660
d01c980f 661dnl Experimenter actions not supported yet.
65a8a59e 662# bad OpenFlow11 instructions: OFPBIC_BAD_EXPERIMENTER
d01c980f
BP
663ffff 0008 01 000000
664
665dnl Bad instruction number (0 not assigned).
65a8a59e 666# bad OpenFlow11 instructions: OFPBIC_UNKNOWN_INST
d01c980f
BP
6670000 0008 01 000000
668
669])
670sed '/^[[#&]]/d' < test-data > input.txt
671sed -n 's/^# //p; /^$/p' < test-data > expout
672sed -n 's/^& //p' < test-data > experr
673AT_CAPTURE_FILE([input.txt])
674AT_CAPTURE_FILE([expout])
675AT_CAPTURE_FILE([experr])
676AT_CHECK(
65a8a59e 677 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-instructions OpenFlow11 < input.txt],
d01c980f
BP
678 [0], [expout], [experr])
679AT_CLEANUP
94baabf7 680
178742f9
BP
681dnl Our primary goal here is to verify OpenFlow 1.2-specific changes,
682dnl so the list of tests is short.
683AT_SETUP([OpenFlow 1.2 action translation])
684AT_KEYWORDS([ofp-actions OF1.2])
685AT_DATA([test-data], [dnl
686# actions=LOCAL
6870000 0010 fffffffe 04d2 000000000000
688
689# bad OpenFlow12 actions: OFPBAC_BAD_SET_MASK
690& ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_SET_MASK):
691& 00000000 00 19 00 18 80 00 09 0c-00 00 00 00 12 34 00 00
692& 00000010 00 00 ff ff 00 00 00 00-
6930019 0018 8000090c 000000001234 00000000ffff 00000000
694
695])
696sed '/^[[#&]]/d' < test-data > input.txt
697sed -n 's/^# //p; /^$/p' < test-data > expout
698sed -n 's/^& //p' < test-data > experr
699AT_CAPTURE_FILE([input.txt])
700AT_CAPTURE_FILE([expout])
701AT_CAPTURE_FILE([experr])
702AT_CHECK(
703 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow12 < input.txt],
704 [0], [expout], [experr])
705AT_CLEANUP
706
914624f8
BP
707dnl Our primary goal here is to verify OpenFlow 1.3-specific changes,
708dnl so the list of tests is short.
709AT_SETUP([OpenFlow 1.3 action translation])
710AT_KEYWORDS([ofp-actions OF1.3])
711AT_DATA([test-data], [dnl
712# actions=LOCAL
7130000 0010 fffffffe 04d2 000000000000
714
715dnl Check the Nicira extension form of "move".
716# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
717ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
718
719dnl Check the ONF extension form of "copy_field".
720# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
721ffff 0020 4f4e4600 0c80 0000 0010 0000 0000 0000 00000002 00000802 00000000
722
723])
724sed '/^[[#&]]/d' < test-data > input.txt
725sed -n 's/^# //p; /^$/p' < test-data > expout
726sed -n 's/^& //p' < test-data > experr
727AT_CAPTURE_FILE([input.txt])
728AT_CAPTURE_FILE([expout])
729AT_CAPTURE_FILE([experr])
730AT_CHECK(
731 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow13 < input.txt],
732 [0], [expout], [experr])
733AT_CLEANUP
734
da4425c7
BP
735dnl Our primary goal here is to verify that OpenFlow 1.5-specific changes,
736dnl so the list of tests is short.
73178f20
BP
737AT_SETUP([OpenFlow 1.5 action translation])
738AT_KEYWORDS([ofp-actions OF1.5])
739AT_DATA([test-data], [dnl
740# actions=LOCAL
7410000 0010 fffffffe 04d2 000000000000
742
743# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
650763d8 744001c 0018 0010 0000 0000 0000 00000002 00000802 00000000
73178f20 745
7eb4b1f1 746# actions=set_field:00:00:00:00:12:34/00:00:00:00:ff:ff->eth_src
178742f9 7470019 0018 8000090c 000000001234 00000000ffff 00000000
da4425c7 748
73178f20
BP
749])
750sed '/^[[#&]]/d' < test-data > input.txt
751sed -n 's/^# //p; /^$/p' < test-data > expout
752sed -n 's/^& //p' < test-data > experr
753AT_CAPTURE_FILE([input.txt])
754AT_CAPTURE_FILE([expout])
755AT_CAPTURE_FILE([experr])
756AT_CHECK(
757 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow15 < input.txt],
758 [0], [expout], [experr])
759AT_CLEANUP
760
94baabf7
SH
761AT_SETUP([ofp-actions - inconsistent MPLS actions])
762OVS_VSWITCHD_START
763dnl OK: Use fin_timeout action on TCP flow
764AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=fin_timeout(idle_timeout=1)'])
765dnl Bad: Use fin_timeout action on TCP flow that has been converted to MPLS
766AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=push_mpls:0x8847,fin_timeout(idle_timeout=1)'],
767 [1], [], [dnl
ba2fe8e9 768ovs-ofctl: none of the usable flow formats (OpenFlow10,NXM) is among the allowed flow formats (OpenFlow11)
94baabf7
SH
769])
770OVS_VSWITCHD_STOP
771AT_CLEANUP
fa078489
BP
772
773AT_SETUP([reg_load <-> set_field translation corner case])
774AT_KEYWORDS([ofp-actions])
775OVS_VSWITCHD_START
776dnl In OpenFlow 1.3, set_field always sets all the bits in the field,
777dnl but when we translate to NXAST_LOAD we need to only set the bits that
778dnl actually exist (e.g. mpls_label only has 20 bits) otherwise OVS rejects
779dnl the "load" action as invalid. Check that we do this correctly.
780AT_CHECK([ovs-ofctl -O OpenFlow13 add-flow br0 mpls,actions=set_field:10-\>mpls_label])
781AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
782NXST_FLOW reply:
783 mpls actions=load:0xa->OXM_OF_MPLS_LABEL[[]]
784])
785OVS_VSWITCHD_STOP
786AT_CLEANUP
0f2aaee9
BP
787
788AT_SETUP([enqueue action for OF1.1+])
789AT_KEYWORDS([ofp-actions])
790OVS_VSWITCHD_START
791dnl OpenFlow 1.0 has an "enqueue" action. For OpenFlow 1.1+, we translate
792dnl it to a series of actions that accomplish the same thing.
793AT_CHECK([ovs-ofctl -O OpenFlow10 add-flow br0 'actions=enqueue(123,456)'])
794AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
795NXST_FLOW reply:
796 actions=enqueue:123:456
797])
798AT_CHECK([ovs-ofctl -O OpenFlow13 dump-flows br0 | ofctl_strip], [0], [dnl
799OFPST_FLOW reply (OF1.3):
800 reset_counts actions=set_queue:456,output:123,pop_queue
801])
802OVS_VSWITCHD_STOP
803AT_CLEANUP
4b684612 804
56a91749
BP
805AT_SETUP([mod_nw_ttl action for OF1.0])
806AT_KEYWORDS([ofp-actions])
807OVS_VSWITCHD_START
808dnl OpenFlow 1.1+ have a mod_nw_ttl action. For OpenFlow 1.0, we translate
809dnl it to an Open vSwitch extension.
810AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 'ip,actions=mod_nw_ttl:123'])
811AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
812NXST_FLOW reply:
813 ip actions=load:0x7b->NXM_NX_IP_TTL[[]]
814])
815AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
816OFPST_FLOW reply (OF1.1):
817 ip actions=mod_nw_ttl:123
818])
819OVS_VSWITCHD_STOP
820AT_CLEANUP
821
4b684612
BP
822AT_SETUP([mod_nw_ecn action translation])
823AT_KEYWORDS([ofp-actions])
824OVS_VSWITCHD_START
825
826dnl OpenFlow 1.1, but no other version, has a "mod_nw_ecn" action.
827dnl Check that we translate it properly for OF1.0 and OF1.2.
828dnl (OF1.3+ should be the same as OF1.2.)
829AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 'ip,actions=mod_nw_ecn:2'])
830AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
831NXST_FLOW reply:
832 ip actions=load:0x2->NXM_NX_IP_ECN[[]]
833])
834AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
835OFPST_FLOW reply (OF1.1):
836 ip actions=mod_nw_ecn:2
837])
838AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [dnl
839OFPST_FLOW reply (OF1.2):
840 ip actions=set_field:2->nw_ecn
841])
842
843dnl Check that OF1.2+ set_field to set ECN is translated into the OF1.1
844dnl mod_nw_ecn action.
845dnl
846dnl We don't do anything equivalent for OF1.0 reg_load because we prefer
847dnl that anything that comes in as reg_load gets translated back to reg_load
848dnl on output. Perhaps this is somewhat inconsistent but it's what OVS
849dnl has done for multiple versions.
850AT_CHECK([ovs-ofctl del-flows br0])
851AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 'ip,actions=set_field:2->ip_ecn'])
852AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
853OFPST_FLOW reply (OF1.1):
854 ip actions=mod_nw_ecn:2
855])
1a1e1a49
EG
856
857dnl Check that OF1.2+ set_field to set ECN is translated for earlier OF
858dnl versions.
859AT_CHECK([ovs-ofctl del-flows br0])
860AT_CHECK([ovs-ofctl -O OpenFlow10 add-flow br0 'ip,actions=set_field:2->ip_ecn'])
861AT_CHECK([ovs-ofctl del-flows br0])
862AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 'ip,actions=set_field:2->ip_ecn'])
863
4b684612
BP
864OVS_VSWITCHD_STOP
865AT_CLEANUP
56a91749 866