]> git.proxmox.com Git - ovs.git/blame - tests/ofp-actions.at
expr: Add additional invariant check in test.
[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
6bee8689
JR
195# actions=ct(commit,exec(load:0->NXM_NX_CT_LABEL[64..127],load:0x1d->NXM_NX_CT_LABEL[0..63]))
196ffff 0048 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
197ffff 0018 00002320 0007 103f 0001d810 0000 0000 0000 0000 dnl
198ffff 0018 00002320 0007 003f 0001d810 0000 0000 0000 001d
199
8e53fe8c
JS
200# bad OpenFlow10 actions: OFPBAC_BAD_SET_ARGUMENT
201& ofp_actions|WARN|cannot set CT fields outside of ct action
202ffff 0018 00002320 0007 001f 0001d604 000000000000f009
203
204# bad OpenFlow10 actions: OFPBAC_BAD_SET_ARGUMENT
205& meta_flow|WARN|destination field ct_zone is not writable
206ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
207ffff 0018 00002320 0007 000f 0001d504 000000000000f009
208
209# bad OpenFlow10 actions: OFPBAC_BAD_ARGUMENT
210& ofp_actions|WARN|ct action doesn't support nested action ct
211ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
212ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0000
213
214# bad OpenFlow10 actions: OFPBAC_BAD_ARGUMENT
215& ofp_actions|WARN|ct action doesn't support nested modification of reg0
216ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
217ffff 0018 00002320 0007 001f 00010004 000000000000f009
218
d787ad39
JS
219# actions=ct(alg=ftp)
220ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0015
221
40c7b2fc
JS
222# actions=ct(alg=tftp)
223ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0045
224
9ac0aada
JR
225# actions=ct(commit,nat(src))
226ffff 0028 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
227ffff 0010 00002320 0024 00 00 0001 0000
228
229# actions=ct(commit,nat(dst))
230ffff 0028 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
231ffff 0010 00002320 0024 00 00 0002 0000
232
233# actions=ct(nat)
234ffff 0028 00002320 0023 0000 00000000 0000 FF 000000 0000 dnl
235ffff 0010 00002320 0024 00 00 0000 0000
236
237# actions=ct(commit,nat(src=10.0.0.240,random))
238ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
239ffff 0018 00002320 0024 00 00 0011 0001 0a0000f0 00000000
240
241# actions=ct(commit,nat(src=10.0.0.240:32768-65535,random))
242ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
243ffff 0018 00002320 0024 00 00 0011 0031 0a0000f0 8000ffff
244
245# actions=ct(commit,nat(dst=10.0.0.128-10.0.0.254,hash))
246ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
247ffff 0018 00002320 0024 00 00 000a 0003 0a000080 0a0000fe
248
249# actions=ct(commit,nat(src=10.0.0.240-10.0.0.254:32768-65535,persistent))
250ffff 0038 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
251ffff 0020 00002320 0024 00 00 0005 0033 0a0000f0 0a0000fe 8000ffff 00000000
252
253# actions=ct(commit,nat(src=fe80::20c:29ff:fe88:a18b,random))
254ffff 0038 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
255ffff 0020 00002320 0024 00 00 0011 0004 fe800000 00000000 020c 29ff fe88 a18b
256
257# actions=ct(commit,nat(src=fe80::20c:29ff:fe88:1-fe80::20c:29ff:fe88:a18b,random))
258ffff 0048 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
259ffff 0030 00002320 0024 00 00 0011 000c fe800000 00000000 020c 29ff fe88 0001 fe800000 00000000 020c 29ff fe88 a18b
260
261# actions=ct(commit,nat(src=[fe80::20c:29ff:fe88:1]-[fe80::20c:29ff:fe88:a18b]:255-4096,random))
262ffff 0050 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
263ffff 0038 00002320 0024 00 00 0011 003c dnl
264fe800000 00000000 020c 29ff fe88 0001 dnl
265fe800000 00000000 020c 29ff fe88 a18b dnl
26600ff1000 00000000
267
72fe7578
BP
268# actions=ct_clear
269ffff 0010 00002320 002b 000000000000
270
aaca4fe0
WT
271# actions=output(port=1,max_len=100)
272ffff 0010 00002320 0027 0001 00000064
273
7ae62a67
WT
274# actions=clone(mod_vlan_vid:5,output:10)
275ffff 0020 00002320 002a 000000000000 dnl
2760001 0008 0005 0000 dnl
2770000 0008 000a 0000
278
a9fedc78
JS
279# actions=learn(table=2,priority=0,NXM_OF_VLAN_TCI[0..11],NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],output:NXM_OF_IN_PORT[])
280ffff 0050 00002320 002d 0000 0000 0000 0000000000000000 0000 02 00 0000 0000 00000000 0000 0000 dnl
281000c 00000802 0000 00000802 0000 dnl
2820030 00000406 0000 00000206 0000 dnl
2831010 00000002 0000 dnl
28400000000
285
4c71600d
DDP
286# actions=learn(table=2,idle_timeout=10,hard_timeout=20,fin_idle_timeout=2,fin_hard_timeout=4,priority=80,cookie=0x123456789abcdef0,limit=1,NXM_OF_VLAN_TCI[0..11],NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],output:NXM_OF_IN_PORT[])
287ffff 0050 00002320 002d 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 00000001 0000 0000 dnl
288000c 00000802 0000 00000802 0000 dnl
2890030 00000406 0000 00000206 0000 dnl
2901010 00000002 0000 dnl
29100000000
292
293# actions=learn(table=2,idle_timeout=10,hard_timeout=20,fin_idle_timeout=2,fin_hard_timeout=4,priority=80,cookie=0x123456789abcdef0,limit=1,result_dst=NXM_NX_REG0[8],NXM_OF_VLAN_TCI[0..11],NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],output:NXM_OF_IN_PORT[])
294ffff 0050 00002320 002d 000a 0014 0050 123456789abcdef0 0004 02 00 0002 0004 00000001 0008 0000 dnl
29500010004 dnl
296000c 00000802 0000 00000802 0000 dnl
2970030 00000406 0000 00000206 0000 dnl
2981010 00000002 0000
299
88c8ca26
BP
300# actions=group:5
301ffff 0010 00002320 0028 0000 00000005
302
77ab5fd2
BP
303# bad OpenFlow10 actions: NXBRC_MUST_BE_ZERO
304ffff 0018 00002320 0025 0000 0005 0000 1122334455 000005
305
306# bad OpenFlow10 actions: NXBRC_MUST_BE_ZERO
307ffff 0018 00002320 0025 0000 0005 5000 1122334455 000000
308
9ac0aada
JR
309# bad OpenFlow10 actions: OFPBAC_BAD_ARGUMENT
310ffff 0048 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
311ffff 0030 00002320 0024 00 00 0011 000c fe800000 00000000 020c 29ff fe88 a18b fe800000 00000000 020c 29ff fe88 0001
312
f25d0cf3
BP
313])
314sed '/^[[#&]]/d' < test-data > input.txt
315sed -n 's/^# //p; /^$/p' < test-data > expout
316sed -n 's/^& //p' < test-data > experr
317AT_CAPTURE_FILE([input.txt])
318AT_CAPTURE_FILE([expout])
319AT_CAPTURE_FILE([experr])
320AT_CHECK(
65a8a59e 321 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow10 < input.txt],
f25d0cf3
BP
322 [0], [expout], [experr])
323AT_CLEANUP
d01c980f 324
8f2cded4
BP
325AT_SETUP([OpenFlow 1.0 "instruction" translations])
326AT_KEYWORDS([ofp-actions OF1.0 instruction])
327AT_DATA([test-data], [dnl
328dnl Try a couple of ordinary actions to make sure they're accepted,
329dnl but there's no point in retrying all the actions from the previous test.
330# actions=LOCAL
3310000 0008 fffe 04d2
332
333# actions=mod_dl_src:00:11:22:33:44:55
3340004 0010 001122334455 000000000000
335
336dnl Now check that write_metadata is accepted.
337# actions=write_metadata:0xfedcba9876543210
338ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
339
340# actions=write_metadata:0xfedcba9876543210/0xffff0000ffff0000
341ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffff0000ffff0000
342
343])
344sed '/^[[#&]]/d' < test-data > input.txt
345sed -n 's/^# //p; /^$/p' < test-data > expout
346sed -n 's/^& //p' < test-data > experr
347AT_CAPTURE_FILE([input.txt])
348AT_CAPTURE_FILE([expout])
349AT_CAPTURE_FILE([experr])
350AT_CHECK(
65a8a59e 351 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-instructions OpenFlow10 < input.txt],
8f2cded4
BP
352 [0], [expout], [experr])
353AT_CLEANUP
354
d01c980f 355AT_SETUP([OpenFlow 1.1 action translation])
4cceacb9 356AT_KEYWORDS([ofp-actions OF1.1])
d01c980f
BP
357AT_DATA([test-data], [dnl
358# actions=LOCAL
3590000 0010 fffffffe 04d2 000000000000
360
361# actions=CONTROLLER:1234
3620000 0010 fffffffd 04d2 000000000000
363
ca287d20 364# actions=set_vlan_vid:9
d01c980f
BP
3650001 0008 0009 0000
366
ca287d20 367# actions=set_vlan_pcp:6
d01c980f
BP
3680002 0008 06 000000
369
370# actions=mod_dl_src:00:11:22:33:44:55
3710003 0010 001122334455 000000000000
372
373# actions=mod_dl_dst:10:20:30:40:50:60
3740004 0010 102030405060 000000000000
375
376# actions=mod_nw_src:1.2.3.4
3770005 0008 01020304
378
379# actions=mod_nw_dst:192.168.0.1
3800006 0008 c0a80001
381
382# actions=mod_nw_tos:48
3830007 0008 30 000000
384
4b684612
BP
385# actions=mod_nw_ecn:2
3860008 0008 02 000000
387
d01c980f
BP
388# actions=mod_tp_src:80
3890009 0008 0050 0000
390
391# actions=mod_tp_dst:443
392000a 0008 01bb 0000
393
64fcc073 394# actions=pop_vlan
8e61c110
IY
3950012 0008 00000000
396
276c4e7a
SH
397# actions=set_queue:2309737729
3980015 0008 89abcd01
399
3e34fbdd
IY
400dnl 802.1ad isn't supported at the moment
401dnl # actions=push_vlan:0x88a8
402dnl 0011 0008 88a8 0000
403# actions=push_vlan:0x8100
4040011 0008 8100 0000
405
d01c980f
BP
406# actions=resubmit:5
407ffff 0010 00002320 0001 0005 00000000
408
409# actions=set_tunnel:0x12345678
410ffff 0010 00002320 0002 0000 12345678
411
d01c980f
BP
412# actions=pop_queue
413ffff 0010 00002320 0005 000000000000
414
415# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
416ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
417
418# actions=load:0xf009->NXM_OF_VLAN_TCI[]
419ffff 0018 00002320 0007 000f 00000802 000000000000f009
420
421# actions=note:11.e9.9a.ad.67.f3
422ffff 0010 00002320 0008 11e99aad67f3
423
424# actions=set_tunnel64:0xc426384d49c53d60
425ffff 0018 00002320 0009 000000000000 c426384d49c53d60
426
427# actions=set_tunnel64:0x885f3298
428ffff 0018 00002320 0009 000000000000 00000000885f3298
429
8f2cded4
BP
430dnl Write-Metadata is only allowed in contexts that allow instructions.
431& ofp_actions|WARN|write_metadata instruction not allowed here
65a8a59e 432# bad OpenFlow11 actions: OFPBIC_UNSUP_INST
4cceacb9
JS
433ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
434
d01c980f
BP
435# actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
436ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
437
d01c980f
BP
438# actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
439ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
4400004 0008 00000000
441
442# actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
443ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
4440004 0008 00000000
445
446# actions=resubmit(10,5)
447ffff 0010 00002320 000e 000a 05 000000
448
2cd20955
JR
449# actions=resubmit(10,5,ct)
450ffff 0010 00002320 002c 000a 05 000000
451
d01c980f
BP
452# actions=output:NXM_NX_REG1[5..10]
453ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
454
455# 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[])
456ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
457000c 00000802 0000 00000802 0000 dnl
4580030 00000406 0000 00000206 0000 dnl
4591010 00000002 0000 dnl
46000000000
461
462# actions=exit
463ffff 0010 00002320 0011 000000000000
464
7bcb1506
IY
465dnl OpenFlow 1.1 OFPAT_DEC_TTL
466# actions=dec_ttl
4670018 0008 00000000
468
d01c980f
BP
469# actions=fin_timeout(idle_timeout=10,hard_timeout=20)
470ffff 0010 00002320 0013 000a 0014 0000
471
472# actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
473ffff 0010 00002320 0014 04d2 162e 02 00
474
c2d967a5
MM
475# actions=dec_ttl(32768,12345,90,765,1024)
476ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
477
29089a54
RL
478# actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
479ffff 0018 00002320 001d 3039 00005BA0 00008707 0000B26E
480
13d2c689
BP
481# bad OpenFlow11 actions: OFPBAC_BAD_OUT_PORT
482& ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_OUT_PORT):
483& 00000000 00 00 00 10 ff ff ff ff-00 00 00 00 00 00 00 00
4840000 0010 ffffffff 0000 000000000000
485
d01c980f
BP
486])
487sed '/^[[#&]]/d' < test-data > input.txt
488sed -n 's/^# //p; /^$/p' < test-data > expout
489sed -n 's/^& //p' < test-data > experr
490AT_CAPTURE_FILE([input.txt])
491AT_CAPTURE_FILE([expout])
492AT_CAPTURE_FILE([experr])
493AT_CHECK(
65a8a59e 494 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow11 < input.txt],
d01c980f
BP
495 [0], [expout], [experr])
496AT_CLEANUP
497
498AT_SETUP([OpenFlow 1.1 instruction translation])
4cceacb9 499AT_KEYWORDS([OF1.1 instruction ofp-actions])
d01c980f
BP
500AT_DATA([test-data], [dnl
501# actions=LOCAL
5020004 0018 00000000 dnl
5030000 0010 fffffffe 04d2 000000000000
504
8dd54666
IY
505dnl Apply-Actions non-zero padding
506# actions=drop
507# 0: 00 -> (none)
508# 1: 04 -> (none)
509# 2: 00 -> (none)
510# 3: 08 -> (none)
511# 4: 00 -> (none)
512# 5: 00 -> (none)
513# 6: 00 -> (none)
514# 7: 01 -> (none)
5150004 0008 00000001
516
d01c980f
BP
517dnl Check that an empty Apply-Actions instruction gets dropped.
518# actions=drop
519# 0: 00 -> (none)
520# 1: 04 -> (none)
521# 2: 00 -> (none)
522# 3: 08 -> (none)
523# 4: 00 -> (none)
524# 5: 00 -> (none)
525# 6: 00 -> (none)
526# 7: 00 -> (none)
5270004 0008 00000000
528
e38c9de5 529dnl Duplicate instruction type:
65a8a59e 530# bad OpenFlow11 instructions: OFPBIC_DUP_INST
d01c980f
BP
5310004 0008 00000000 0004 0008 00000000
532
533dnl Instructions not multiple of 8 in length.
534& ofp_actions|WARN|OpenFlow message instructions length 9 is not a multiple of 8
65a8a59e 535# bad OpenFlow11 instructions: OFPBIC_BAD_LEN
d01c980f
BP
5360004 0009 01 00000000
537
538dnl Goto-Table instruction too long.
65a8a59e 539# bad OpenFlow11 instructions: OFPBIC_BAD_LEN
d01c980f
BP
5400001 0010 01 000000 0000000000000000
541
8dd54666
IY
542dnl Goto-Table 1 instruction non-zero padding
543# actions=goto_table:1
544# 7: 01 -> 00
5450001 0008 01 000001
546
bff7eeb6 547dnl Goto-Table 1 instruction go back to the previous table.
8c87971e 548# bad OpenFlow11 instructions: OFPBIC_BAD_TABLE_ID
bff7eeb6
JA
5492,0001 0008 01 000000
550
8dd54666
IY
551dnl Goto-Table 1
552# actions=goto_table:1
d01c980f
BP
5530001 0008 01 000000
554
4cceacb9
JS
555dnl Write-Metadata.
556# actions=write_metadata:0xfedcba9876543210
d01c980f
BP
5570002 0018 00000000 fedcba9876543210 ffffffffffffffff
558
8f2cded4
BP
559dnl Write-Metadata as Nicira extension action is transformed into instruction.
560# actions=write_metadata:0xfedcba9876543210
561# 1: 04 -> 02
562# 3: 28 -> 18
563# 8: ff -> fe
564# 9: ff -> dc
565# 10: 00 -> ba
566# 11: 20 -> 98
567# 12: 00 -> 76
568# 13: 00 -> 54
569# 14: 23 -> 32
570# 15: 20 -> 10
571# 16: 00 -> ff
572# 17: 16 -> ff
573# 18: 00 -> ff
574# 19: 00 -> ff
575# 20: 00 -> ff
576# 21: 00 -> ff
577# 22: 00 -> ff
578# 23: 00 -> ff
579# 24: fe -> (none)
580# 25: dc -> (none)
581# 26: ba -> (none)
582# 27: 98 -> (none)
583# 28: 76 -> (none)
584# 29: 54 -> (none)
585# 30: 32 -> (none)
586# 31: 10 -> (none)
587# 32: ff -> (none)
588# 33: ff -> (none)
589# 34: ff -> (none)
590# 35: ff -> (none)
591# 36: ff -> (none)
592# 37: ff -> (none)
593# 38: ff -> (none)
594# 39: ff -> (none)
5950004 0028 00000000 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
596
4cceacb9
JS
597dnl Write-Metadata with mask.
598# actions=write_metadata:0xfedcba9876543210/0xff00ff00ff00ff00
5990002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
600
d01c980f 601dnl Write-Metadata too short.
65a8a59e 602# bad OpenFlow11 instructions: OFPBIC_BAD_LEN
d01c980f
BP
6030002 0010 00000000 fedcba9876543210
604
605dnl Write-Metadata too long.
65a8a59e 606# bad OpenFlow11 instructions: OFPBIC_BAD_LEN
d01c980f
BP
6070002 0020 00000000 fedcba9876543210 ffffffffffffffff 0000000000000000
608
4cceacb9 609dnl Write-Metadata duplicated.
65a8a59e 610# bad OpenFlow11 instructions: OFPBIC_DUP_INST
4cceacb9
JS
6110002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
612
6813ee7c
BP
613dnl Write-Metadata in wrong position (OpenFlow 1.1+ disregards the order
614dnl and OVS reorders it to the canonical order)
615# actions=write_metadata:0xfedcba9876543210,goto_table:1
616# 1: 01 -> 02
617# 3: 08 -> 18
618# 4: 01 -> 00
619# 8: 00 -> fe
620# 9: 02 -> dc
621# 10: 00 -> ba
622# 11: 18 -> 98
623# 12: 00 -> 76
624# 13: 00 -> 54
625# 14: 00 -> 32
626# 15: 00 -> 10
627# 16: fe -> ff
628# 17: dc -> ff
629# 18: ba -> ff
630# 19: 98 -> ff
631# 20: 76 -> ff
632# 21: 54 -> ff
633# 22: 32 -> ff
634# 23: 10 -> ff
635# 24: ff -> 00
636# 25: ff -> 01
637# 26: ff -> 00
638# 27: ff -> 08
639# 28: ff -> 01
640# 29: ff -> 00
641# 30: ff -> 00
642# 31: ff -> 00
4cceacb9
JS
6430001 0008 01 000000 0002 0018 00000000 fedcba9876543210 ffffffffffffffff
644
7fdb60a7
SH
645dnl empty Write-Actions non-zero padding
646# actions=write_actions(drop)
647# 0: 00 -> (none)
648# 1: 03 -> (none)
649# 2: 00 -> (none)
650# 3: 08 -> (none)
651# 4: 00 -> (none)
652# 5: 00 -> (none)
653# 6: 00 -> (none)
654# 7: 01 -> (none)
6550003 0008 00000001
656
657dnl Check that an empty Write-Actions instruction gets dropped.
658# actions=write_actions(drop)
659# 0: 00 -> (none)
660# 1: 03 -> (none)
661# 2: 00 -> (none)
662# 3: 08 -> (none)
663# 4: 00 -> (none)
664# 5: 00 -> (none)
665# 6: 00 -> (none)
666# 7: 00 -> (none)
6670003 0008 00000000
d01c980f 668
b19e8793 669dnl Clear-Actions too-long
65a8a59e 670# bad OpenFlow11 instructions: OFPBIC_BAD_LEN
b19e8793
IY
6710005 0010 00000000 0000000000000000
672
673dnl Clear-Actions non-zero padding
674# actions=clear_actions
675# 7: 01 -> 00
6760005 0008 00000001
677
678dnl Clear-Actions non-zero padding
679# actions=clear_actions
680# 4: 01 -> 00
d01c980f
BP
6810005 0008 01 000000
682
b19e8793
IY
683dnl Clear-Actions
684# actions=clear_actions
6850005 0008 00000000
686
d01c980f 687dnl Experimenter actions not supported yet.
65a8a59e 688# bad OpenFlow11 instructions: OFPBIC_BAD_EXPERIMENTER
d01c980f
BP
689ffff 0008 01 000000
690
691dnl Bad instruction number (0 not assigned).
65a8a59e 692# bad OpenFlow11 instructions: OFPBIC_UNKNOWN_INST
d01c980f
BP
6930000 0008 01 000000
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(
65a8a59e 703 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-instructions OpenFlow11 < input.txt],
d01c980f
BP
704 [0], [expout], [experr])
705AT_CLEANUP
94baabf7 706
178742f9
BP
707dnl Our primary goal here is to verify OpenFlow 1.2-specific changes,
708dnl so the list of tests is short.
709AT_SETUP([OpenFlow 1.2 action translation])
710AT_KEYWORDS([ofp-actions OF1.2])
711AT_DATA([test-data], [dnl
712# actions=LOCAL
7130000 0010 fffffffe 04d2 000000000000
714
715# bad OpenFlow12 actions: OFPBAC_BAD_SET_MASK
716& ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_SET_MASK):
717& 00000000 00 19 00 18 80 00 09 0c-00 00 00 00 12 34 00 00
718& 00000010 00 00 ff ff 00 00 00 00-
7190019 0018 8000090c 000000001234 00000000ffff 00000000
720
721])
722sed '/^[[#&]]/d' < test-data > input.txt
723sed -n 's/^# //p; /^$/p' < test-data > expout
724sed -n 's/^& //p' < test-data > experr
725AT_CAPTURE_FILE([input.txt])
726AT_CAPTURE_FILE([expout])
727AT_CAPTURE_FILE([experr])
728AT_CHECK(
729 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow12 < input.txt],
730 [0], [expout], [experr])
731AT_CLEANUP
732
914624f8
BP
733dnl Our primary goal here is to verify OpenFlow 1.3-specific changes,
734dnl so the list of tests is short.
735AT_SETUP([OpenFlow 1.3 action translation])
736AT_KEYWORDS([ofp-actions OF1.3])
737AT_DATA([test-data], [dnl
738# actions=LOCAL
7390000 0010 fffffffe 04d2 000000000000
740
741dnl Check the Nicira extension form of "move".
742# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
743ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
744
745dnl Check the ONF extension form of "copy_field".
746# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
747ffff 0020 4f4e4600 0c80 0000 0010 0000 0000 0000 00000002 00000802 00000000
748
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 OpenFlow13 < input.txt],
758 [0], [expout], [experr])
759AT_CLEANUP
760
da4425c7
BP
761dnl Our primary goal here is to verify that OpenFlow 1.5-specific changes,
762dnl so the list of tests is short.
73178f20
BP
763AT_SETUP([OpenFlow 1.5 action translation])
764AT_KEYWORDS([ofp-actions OF1.5])
765AT_DATA([test-data], [dnl
766# actions=LOCAL
7670000 0010 fffffffe 04d2 000000000000
768
769# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
650763d8 770001c 0018 0010 0000 0000 0000 00000002 00000802 00000000
73178f20 771
7eb4b1f1 772# actions=set_field:00:00:00:00:12:34/00:00:00:00:ff:ff->eth_src
178742f9 7730019 0018 8000090c 000000001234 00000000ffff 00000000
da4425c7 774
73178f20
BP
775])
776sed '/^[[#&]]/d' < test-data > input.txt
777sed -n 's/^# //p; /^$/p' < test-data > expout
778sed -n 's/^& //p' < test-data > experr
779AT_CAPTURE_FILE([input.txt])
780AT_CAPTURE_FILE([expout])
781AT_CAPTURE_FILE([experr])
782AT_CHECK(
783 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow15 < input.txt],
784 [0], [expout], [experr])
785AT_CLEANUP
786
94baabf7
SH
787AT_SETUP([ofp-actions - inconsistent MPLS actions])
788OVS_VSWITCHD_START
789dnl OK: Use fin_timeout action on TCP flow
790AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=fin_timeout(idle_timeout=1)'])
791dnl Bad: Use fin_timeout action on TCP flow that has been converted to MPLS
792AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=push_mpls:0x8847,fin_timeout(idle_timeout=1)'],
793 [1], [], [dnl
ba2fe8e9 794ovs-ofctl: none of the usable flow formats (OpenFlow10,NXM) is among the allowed flow formats (OpenFlow11)
94baabf7
SH
795])
796OVS_VSWITCHD_STOP
797AT_CLEANUP
fa078489
BP
798
799AT_SETUP([reg_load <-> set_field translation corner case])
800AT_KEYWORDS([ofp-actions])
801OVS_VSWITCHD_START
802dnl In OpenFlow 1.3, set_field always sets all the bits in the field,
803dnl but when we translate to NXAST_LOAD we need to only set the bits that
804dnl actually exist (e.g. mpls_label only has 20 bits) otherwise OVS rejects
805dnl the "load" action as invalid. Check that we do this correctly.
806AT_CHECK([ovs-ofctl -O OpenFlow13 add-flow br0 mpls,actions=set_field:10-\>mpls_label])
807AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
808NXST_FLOW reply:
809 mpls actions=load:0xa->OXM_OF_MPLS_LABEL[[]]
810])
811OVS_VSWITCHD_STOP
812AT_CLEANUP
0f2aaee9
BP
813
814AT_SETUP([enqueue action for OF1.1+])
815AT_KEYWORDS([ofp-actions])
816OVS_VSWITCHD_START
817dnl OpenFlow 1.0 has an "enqueue" action. For OpenFlow 1.1+, we translate
818dnl it to a series of actions that accomplish the same thing.
819AT_CHECK([ovs-ofctl -O OpenFlow10 add-flow br0 'actions=enqueue(123,456)'])
820AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
821NXST_FLOW reply:
822 actions=enqueue:123:456
823])
824AT_CHECK([ovs-ofctl -O OpenFlow13 dump-flows br0 | ofctl_strip], [0], [dnl
825OFPST_FLOW reply (OF1.3):
826 reset_counts actions=set_queue:456,output:123,pop_queue
827])
828OVS_VSWITCHD_STOP
829AT_CLEANUP
4b684612 830
56a91749
BP
831AT_SETUP([mod_nw_ttl action for OF1.0])
832AT_KEYWORDS([ofp-actions])
833OVS_VSWITCHD_START
834dnl OpenFlow 1.1+ have a mod_nw_ttl action. For OpenFlow 1.0, we translate
835dnl it to an Open vSwitch extension.
836AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 'ip,actions=mod_nw_ttl:123'])
837AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
838NXST_FLOW reply:
839 ip actions=load:0x7b->NXM_NX_IP_TTL[[]]
840])
841AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
842OFPST_FLOW reply (OF1.1):
843 ip actions=mod_nw_ttl:123
844])
845OVS_VSWITCHD_STOP
846AT_CLEANUP
847
4b684612
BP
848AT_SETUP([mod_nw_ecn action translation])
849AT_KEYWORDS([ofp-actions])
850OVS_VSWITCHD_START
851
852dnl OpenFlow 1.1, but no other version, has a "mod_nw_ecn" action.
853dnl Check that we translate it properly for OF1.0 and OF1.2.
854dnl (OF1.3+ should be the same as OF1.2.)
855AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 'ip,actions=mod_nw_ecn:2'])
856AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
857NXST_FLOW reply:
858 ip actions=load:0x2->NXM_NX_IP_ECN[[]]
859])
860AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
861OFPST_FLOW reply (OF1.1):
862 ip actions=mod_nw_ecn:2
863])
864AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [dnl
865OFPST_FLOW reply (OF1.2):
866 ip actions=set_field:2->nw_ecn
867])
868
869dnl Check that OF1.2+ set_field to set ECN is translated into the OF1.1
870dnl mod_nw_ecn action.
871dnl
872dnl We don't do anything equivalent for OF1.0 reg_load because we prefer
873dnl that anything that comes in as reg_load gets translated back to reg_load
874dnl on output. Perhaps this is somewhat inconsistent but it's what OVS
875dnl has done for multiple versions.
876AT_CHECK([ovs-ofctl del-flows br0])
877AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 'ip,actions=set_field:2->ip_ecn'])
878AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
879OFPST_FLOW reply (OF1.1):
880 ip actions=mod_nw_ecn:2
881])
1a1e1a49
EG
882
883dnl Check that OF1.2+ set_field to set ECN is translated for earlier OF
884dnl versions.
885AT_CHECK([ovs-ofctl del-flows br0])
886AT_CHECK([ovs-ofctl -O OpenFlow10 add-flow br0 'ip,actions=set_field:2->ip_ecn'])
887AT_CHECK([ovs-ofctl del-flows br0])
888AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 'ip,actions=set_field:2->ip_ecn'])
889
4b684612
BP
890OVS_VSWITCHD_STOP
891AT_CLEANUP
56a91749 892