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