]> git.proxmox.com Git - mirror_ovs.git/blame - tests/ofp-actions.at
ofp-actions: Implement writing to metadata field
[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
42# actions=enqueue:10q55
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
4cceacb9
JS
72# actions=write_metadata:0xfedcba9876543210
73ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
74
75# actions=write_metadata:0xfedcba9876543210/0xffff0000ffff0000
76ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffff0000ffff0000
77
f25d0cf3
BP
78# actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
79ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
80
81# actions=autopath(2,NXM_NX_REG0[2..30])
ad7c0437 82& autopath|WARN|The autopath action is deprecated and may be removed in February 2013. Please email dev@openvswitch.org with concerns.
f25d0cf3
BP
83ffff 0018 00002320 000b 009c 00010004 00000002 00000000
84
85# actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
86ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
870004 0008 00000000
88
89# actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
90ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
910004 0008 00000000
92
93# actions=resubmit(10,5)
94ffff 0010 00002320 000e 000a 05 000000
95
96# actions=output:NXM_NX_REG1[5..10]
97ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
98
99# 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[])
100ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
101000c 00000802 0000 00000802 0000 dnl
1020030 00000406 0000 00000206 0000 dnl
1031010 00000002 0000 dnl
10400000000
105
106# actions=exit
107ffff 0010 00002320 0011 000000000000
108
109# actions=dec_ttl
110ffff 0010 00002320 0012 000000000000
111
112# actions=fin_timeout(idle_timeout=10,hard_timeout=20)
113ffff 0010 00002320 0013 000a 0014 0000
114
115# actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
116ffff 0010 00002320 0014 04d2 162e 02 00
117
c2d967a5
MM
118# actions=dec_ttl(32768,12345,90,765,1024)
119ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
120
f25d0cf3
BP
121])
122sed '/^[[#&]]/d' < test-data > input.txt
123sed -n 's/^# //p; /^$/p' < test-data > expout
124sed -n 's/^& //p' < test-data > experr
125AT_CAPTURE_FILE([input.txt])
126AT_CAPTURE_FILE([expout])
127AT_CAPTURE_FILE([experr])
128AT_CHECK(
129 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-ofp10-actions < input.txt],
130 [0], [expout], [experr])
131AT_CLEANUP
d01c980f
BP
132
133AT_SETUP([OpenFlow 1.1 action translation])
4cceacb9 134AT_KEYWORDS([ofp-actions OF1.1])
d01c980f
BP
135AT_DATA([test-data], [dnl
136# actions=LOCAL
1370000 0010 fffffffe 04d2 000000000000
138
139# actions=CONTROLLER:1234
1400000 0010 fffffffd 04d2 000000000000
141
142# actions=mod_vlan_vid:9
1430001 0008 0009 0000
144
145# actions=mod_vlan_pcp:6
1460002 0008 06 000000
147
148# actions=mod_dl_src:00:11:22:33:44:55
1490003 0010 001122334455 000000000000
150
151# actions=mod_dl_dst:10:20:30:40:50:60
1520004 0010 102030405060 000000000000
153
154# actions=mod_nw_src:1.2.3.4
1550005 0008 01020304
156
157# actions=mod_nw_dst:192.168.0.1
1580006 0008 c0a80001
159
160# actions=mod_nw_tos:48
1610007 0008 30 000000
162
163# actions=mod_tp_src:80
1640009 0008 0050 0000
165
166# actions=mod_tp_dst:443
167000a 0008 01bb 0000
168
8e61c110
IY
169# actions=strip_vlan
1700012 0008 00000000
171
d01c980f
BP
172# actions=resubmit:5
173ffff 0010 00002320 0001 0005 00000000
174
175# actions=set_tunnel:0x12345678
176ffff 0010 00002320 0002 0000 12345678
177
178# actions=set_queue:2309737729
179ffff 0010 00002320 0004 0000 89abcd01
180
181# actions=pop_queue
182ffff 0010 00002320 0005 000000000000
183
184# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
185ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
186
187# actions=load:0xf009->NXM_OF_VLAN_TCI[]
188ffff 0018 00002320 0007 000f 00000802 000000000000f009
189
190# actions=note:11.e9.9a.ad.67.f3
191ffff 0010 00002320 0008 11e99aad67f3
192
193# actions=set_tunnel64:0xc426384d49c53d60
194ffff 0018 00002320 0009 000000000000 c426384d49c53d60
195
196# actions=set_tunnel64:0x885f3298
197ffff 0018 00002320 0009 000000000000 00000000885f3298
198
4cceacb9
JS
199dnl OpenFlow 1.1 uses OFPIT_WRITE_METADATA to express the NXAST_WRITE_METADATA
200dnl action instead, so parse-ofp11-actions will recognise and drop this action.
201# actions=write_metadata:0xfedcba9876543210
202# 0: ff -> (none)
203# 1: ff -> (none)
204# 2: 00 -> (none)
205# 3: 20 -> (none)
206# 4: 00 -> (none)
207# 5: 00 -> (none)
208# 6: 23 -> (none)
209# 7: 20 -> (none)
210# 8: 00 -> (none)
211# 9: 16 -> (none)
212# 10: 00 -> (none)
213# 11: 00 -> (none)
214# 12: 00 -> (none)
215# 13: 00 -> (none)
216# 14: 00 -> (none)
217# 15: 00 -> (none)
218# 16: fe -> (none)
219# 17: dc -> (none)
220# 18: ba -> (none)
221# 19: 98 -> (none)
222# 20: 76 -> (none)
223# 21: 54 -> (none)
224# 22: 32 -> (none)
225# 23: 10 -> (none)
226# 24: ff -> (none)
227# 25: ff -> (none)
228# 26: ff -> (none)
229# 27: ff -> (none)
230# 28: ff -> (none)
231# 29: ff -> (none)
232# 30: ff -> (none)
233# 31: ff -> (none)
234ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
235
236dnl Write-Metadata duplicated.
237& ofp_actions|WARN|duplicate write_metadata instruction specified
238# bad OF1.1 actions: OFPBAC_UNSUPPORTED_ORDER
239ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
240
241dnl Write-Metadata in wrong position.
242& ofp_actions|WARN|write_metadata instruction must be specified after other instructions/actions
243# bad OF1.1 actions: OFPBAC_UNSUPPORTED_ORDER
244ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff ffff 0010 00002320 0002 0000 12345678
245
d01c980f
BP
246# actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
247ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
248
249# actions=autopath(2,NXM_NX_REG0[2..30])
ad7c0437 250& autopath|WARN|The autopath action is deprecated and may be removed in February 2013. Please email dev@openvswitch.org with concerns.
d01c980f
BP
251ffff 0018 00002320 000b 009c 00010004 00000002 00000000
252
253# actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
254ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
2550004 0008 00000000
256
257# actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
258ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
2590004 0008 00000000
260
261# actions=resubmit(10,5)
262ffff 0010 00002320 000e 000a 05 000000
263
264# actions=output:NXM_NX_REG1[5..10]
265ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
266
267# 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[])
268ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
269000c 00000802 0000 00000802 0000 dnl
2700030 00000406 0000 00000206 0000 dnl
2711010 00000002 0000 dnl
27200000000
273
274# actions=exit
275ffff 0010 00002320 0011 000000000000
276
7bcb1506 277dnl NXAST_DEC_TTL
d01c980f
BP
278# actions=dec_ttl
279ffff 0010 00002320 0012 000000000000
280
7bcb1506
IY
281dnl OpenFlow 1.1 OFPAT_DEC_TTL
282# actions=dec_ttl
2830018 0008 00000000
284
d01c980f
BP
285# actions=fin_timeout(idle_timeout=10,hard_timeout=20)
286ffff 0010 00002320 0013 000a 0014 0000
287
288# actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
289ffff 0010 00002320 0014 04d2 162e 02 00
290
c2d967a5
MM
291# actions=dec_ttl(32768,12345,90,765,1024)
292ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
293
d01c980f
BP
294])
295sed '/^[[#&]]/d' < test-data > input.txt
296sed -n 's/^# //p; /^$/p' < test-data > expout
297sed -n 's/^& //p' < test-data > experr
298AT_CAPTURE_FILE([input.txt])
299AT_CAPTURE_FILE([expout])
300AT_CAPTURE_FILE([experr])
301AT_CHECK(
302 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-ofp11-actions < input.txt],
303 [0], [expout], [experr])
304AT_CLEANUP
305
306AT_SETUP([OpenFlow 1.1 instruction translation])
4cceacb9 307AT_KEYWORDS([OF1.1 instruction ofp-actions])
d01c980f
BP
308AT_DATA([test-data], [dnl
309# actions=LOCAL
3100004 0018 00000000 dnl
3110000 0010 fffffffe 04d2 000000000000
312
8dd54666
IY
313dnl Apply-Actions non-zero padding
314# actions=drop
315# 0: 00 -> (none)
316# 1: 04 -> (none)
317# 2: 00 -> (none)
318# 3: 08 -> (none)
319# 4: 00 -> (none)
320# 5: 00 -> (none)
321# 6: 00 -> (none)
322# 7: 01 -> (none)
3230004 0008 00000001
324
d01c980f
BP
325dnl Check that an empty Apply-Actions instruction gets dropped.
326# actions=drop
327# 0: 00 -> (none)
328# 1: 04 -> (none)
329# 2: 00 -> (none)
330# 3: 08 -> (none)
331# 4: 00 -> (none)
332# 5: 00 -> (none)
333# 6: 00 -> (none)
334# 7: 00 -> (none)
3350004 0008 00000000
336
e38c9de5
SH
337dnl Duplicate instruction type:
338# bad OF1.1 instructions: OFPIT_BAD_INSTRUCTION
d01c980f
BP
3390004 0008 00000000 0004 0008 00000000
340
341dnl Instructions not multiple of 8 in length.
342& ofp_actions|WARN|OpenFlow message instructions length 9 is not a multiple of 8
343# bad OF1.1 instructions: OFPBIC_BAD_LEN
3440004 0009 01 00000000
345
346dnl Goto-Table instruction too long.
347# bad OF1.1 instructions: OFPBIC_BAD_LEN
3480001 0010 01 000000 0000000000000000
349
8dd54666
IY
350dnl Goto-Table 1 instruction non-zero padding
351# actions=goto_table:1
352# 7: 01 -> 00
3530001 0008 01 000001
354
355dnl Goto-Table 1
356# actions=goto_table:1
d01c980f
BP
3570001 0008 01 000000
358
4cceacb9
JS
359dnl Write-Metadata.
360# actions=write_metadata:0xfedcba9876543210
d01c980f
BP
3610002 0018 00000000 fedcba9876543210 ffffffffffffffff
362
4cceacb9
JS
363dnl Write-Metadata with mask.
364# actions=write_metadata:0xfedcba9876543210/0xff00ff00ff00ff00
3650002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
366
d01c980f
BP
367dnl Write-Metadata too short.
368# bad OF1.1 instructions: OFPBIC_BAD_LEN
3690002 0010 00000000 fedcba9876543210
370
371dnl Write-Metadata too long.
372# bad OF1.1 instructions: OFPBIC_BAD_LEN
3730002 0020 00000000 fedcba9876543210 ffffffffffffffff 0000000000000000
374
4cceacb9
JS
375dnl Write-Metadata duplicated.
376# bad OF1.1 instructions: OFPIT_BAD_INSTRUCTION
3770002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
378
379dnl Write-Metadata in wrong position.
380& ofp_actions|WARN|write_metadata instruction must be specified after other instructions/actions
381# bad OF1.1 instructions: OFPBAC_UNSUPPORTED_ORDER
3820001 0008 01 000000 0002 0018 00000000 fedcba9876543210 ffffffffffffffff
383
d01c980f
BP
384dnl Write-Actions not supported yet.
385# bad OF1.1 instructions: OFPBIC_UNSUP_INST
3860003 0008 01 000000
387
b19e8793
IY
388dnl Clear-Actions too-long
389# bad OF1.1 instructions: OFPBIC_BAD_LEN
3900005 0010 00000000 0000000000000000
391
392dnl Clear-Actions non-zero padding
393# actions=clear_actions
394# 7: 01 -> 00
3950005 0008 00000001
396
397dnl Clear-Actions non-zero padding
398# actions=clear_actions
399# 4: 01 -> 00
d01c980f
BP
4000005 0008 01 000000
401
b19e8793
IY
402dnl Clear-Actions
403# actions=clear_actions
4040005 0008 00000000
405
d01c980f
BP
406dnl Experimenter actions not supported yet.
407# bad OF1.1 instructions: OFPBIC_BAD_EXPERIMENTER
408ffff 0008 01 000000
409
410dnl Bad instruction number (0 not assigned).
411# bad OF1.1 instructions: OFPBIC_UNKNOWN_INST
4120000 0008 01 000000
413
414])
415sed '/^[[#&]]/d' < test-data > input.txt
416sed -n 's/^# //p; /^$/p' < test-data > expout
417sed -n 's/^& //p' < test-data > experr
418AT_CAPTURE_FILE([input.txt])
419AT_CAPTURE_FILE([expout])
420AT_CAPTURE_FILE([experr])
421AT_CHECK(
422 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-ofp11-instructions < input.txt],
423 [0], [expout], [experr])
424AT_CLEANUP