]> git.proxmox.com Git - mirror_ovs.git/blame - tests/ofp-actions.at
ofp-util: Again allow OpenFlow port 0 in commands and actions.
[mirror_ovs.git] / tests / ofp-actions.at
CommitLineData
f25d0cf3
BP
1AT_BANNER([OpenFlow actions])
2
3AT_SETUP([OpenFlow 1.0 action translation])
4AT_KEYWORDS([OF1.0])
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
72# actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
73ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
74
75# actions=autopath(2,NXM_NX_REG0[2..30])
ad7c0437 76& autopath|WARN|The autopath action is deprecated and may be removed in February 2013. Please email dev@openvswitch.org with concerns.
f25d0cf3
BP
77ffff 0018 00002320 000b 009c 00010004 00000002 00000000
78
79# actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
80ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
810004 0008 00000000
82
83# actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
84ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
850004 0008 00000000
86
87# actions=resubmit(10,5)
88ffff 0010 00002320 000e 000a 05 000000
89
90# actions=output:NXM_NX_REG1[5..10]
91ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
92
93# 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[])
94ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
95000c 00000802 0000 00000802 0000 dnl
960030 00000406 0000 00000206 0000 dnl
971010 00000002 0000 dnl
9800000000
99
100# actions=exit
101ffff 0010 00002320 0011 000000000000
102
103# actions=dec_ttl
104ffff 0010 00002320 0012 000000000000
105
106# actions=fin_timeout(idle_timeout=10,hard_timeout=20)
107ffff 0010 00002320 0013 000a 0014 0000
108
109# actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
110ffff 0010 00002320 0014 04d2 162e 02 00
111
c2d967a5
MM
112# actions=dec_ttl(32768,12345,90,765,1024)
113ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
114
f25d0cf3
BP
115])
116sed '/^[[#&]]/d' < test-data > input.txt
117sed -n 's/^# //p; /^$/p' < test-data > expout
118sed -n 's/^& //p' < test-data > experr
119AT_CAPTURE_FILE([input.txt])
120AT_CAPTURE_FILE([expout])
121AT_CAPTURE_FILE([experr])
122AT_CHECK(
123 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-ofp10-actions < input.txt],
124 [0], [expout], [experr])
125AT_CLEANUP
d01c980f
BP
126
127AT_SETUP([OpenFlow 1.1 action translation])
128AT_KEYWORDS([OF1.1])
129AT_DATA([test-data], [dnl
130# actions=LOCAL
1310000 0010 fffffffe 04d2 000000000000
132
133# actions=CONTROLLER:1234
1340000 0010 fffffffd 04d2 000000000000
135
136# actions=mod_vlan_vid:9
1370001 0008 0009 0000
138
139# actions=mod_vlan_pcp:6
1400002 0008 06 000000
141
142# actions=mod_dl_src:00:11:22:33:44:55
1430003 0010 001122334455 000000000000
144
145# actions=mod_dl_dst:10:20:30:40:50:60
1460004 0010 102030405060 000000000000
147
148# actions=mod_nw_src:1.2.3.4
1490005 0008 01020304
150
151# actions=mod_nw_dst:192.168.0.1
1520006 0008 c0a80001
153
154# actions=mod_nw_tos:48
1550007 0008 30 000000
156
157# actions=mod_tp_src:80
1580009 0008 0050 0000
159
160# actions=mod_tp_dst:443
161000a 0008 01bb 0000
162
163# actions=resubmit:5
164ffff 0010 00002320 0001 0005 00000000
165
166# actions=set_tunnel:0x12345678
167ffff 0010 00002320 0002 0000 12345678
168
169# actions=set_queue:2309737729
170ffff 0010 00002320 0004 0000 89abcd01
171
172# actions=pop_queue
173ffff 0010 00002320 0005 000000000000
174
175# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
176ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
177
178# actions=load:0xf009->NXM_OF_VLAN_TCI[]
179ffff 0018 00002320 0007 000f 00000802 000000000000f009
180
181# actions=note:11.e9.9a.ad.67.f3
182ffff 0010 00002320 0008 11e99aad67f3
183
184# actions=set_tunnel64:0xc426384d49c53d60
185ffff 0018 00002320 0009 000000000000 c426384d49c53d60
186
187# actions=set_tunnel64:0x885f3298
188ffff 0018 00002320 0009 000000000000 00000000885f3298
189
190# actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
191ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
192
193# actions=autopath(2,NXM_NX_REG0[2..30])
ad7c0437 194& autopath|WARN|The autopath action is deprecated and may be removed in February 2013. Please email dev@openvswitch.org with concerns.
d01c980f
BP
195ffff 0018 00002320 000b 009c 00010004 00000002 00000000
196
197# actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
198ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
1990004 0008 00000000
200
201# actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
202ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
2030004 0008 00000000
204
205# actions=resubmit(10,5)
206ffff 0010 00002320 000e 000a 05 000000
207
208# actions=output:NXM_NX_REG1[5..10]
209ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
210
211# 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[])
212ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
213000c 00000802 0000 00000802 0000 dnl
2140030 00000406 0000 00000206 0000 dnl
2151010 00000002 0000 dnl
21600000000
217
218# actions=exit
219ffff 0010 00002320 0011 000000000000
220
7bcb1506 221dnl NXAST_DEC_TTL
d01c980f
BP
222# actions=dec_ttl
223ffff 0010 00002320 0012 000000000000
224
7bcb1506
IY
225dnl OpenFlow 1.1 OFPAT_DEC_TTL
226# actions=dec_ttl
2270018 0008 00000000
228
d01c980f
BP
229# actions=fin_timeout(idle_timeout=10,hard_timeout=20)
230ffff 0010 00002320 0013 000a 0014 0000
231
232# actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
233ffff 0010 00002320 0014 04d2 162e 02 00
234
c2d967a5
MM
235# actions=dec_ttl(32768,12345,90,765,1024)
236ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
237
d01c980f
BP
238])
239sed '/^[[#&]]/d' < test-data > input.txt
240sed -n 's/^# //p; /^$/p' < test-data > expout
241sed -n 's/^& //p' < test-data > experr
242AT_CAPTURE_FILE([input.txt])
243AT_CAPTURE_FILE([expout])
244AT_CAPTURE_FILE([experr])
245AT_CHECK(
246 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-ofp11-actions < input.txt],
247 [0], [expout], [experr])
248AT_CLEANUP
249
250AT_SETUP([OpenFlow 1.1 instruction translation])
8dd54666 251AT_KEYWORDS([OF1.1 instruction])
d01c980f
BP
252AT_DATA([test-data], [dnl
253# actions=LOCAL
2540004 0018 00000000 dnl
2550000 0010 fffffffe 04d2 000000000000
256
8dd54666
IY
257dnl Apply-Actions non-zero padding
258# actions=drop
259# 0: 00 -> (none)
260# 1: 04 -> (none)
261# 2: 00 -> (none)
262# 3: 08 -> (none)
263# 4: 00 -> (none)
264# 5: 00 -> (none)
265# 6: 00 -> (none)
266# 7: 01 -> (none)
2670004 0008 00000001
268
d01c980f
BP
269dnl Check that an empty Apply-Actions instruction gets dropped.
270# actions=drop
271# 0: 00 -> (none)
272# 1: 04 -> (none)
273# 2: 00 -> (none)
274# 3: 08 -> (none)
275# 4: 00 -> (none)
276# 5: 00 -> (none)
277# 6: 00 -> (none)
278# 7: 00 -> (none)
2790004 0008 00000000
280
e38c9de5
SH
281dnl Duplicate instruction type:
282# bad OF1.1 instructions: OFPIT_BAD_INSTRUCTION
d01c980f
BP
2830004 0008 00000000 0004 0008 00000000
284
285dnl Instructions not multiple of 8 in length.
286& ofp_actions|WARN|OpenFlow message instructions length 9 is not a multiple of 8
287# bad OF1.1 instructions: OFPBIC_BAD_LEN
2880004 0009 01 00000000
289
290dnl Goto-Table instruction too long.
291# bad OF1.1 instructions: OFPBIC_BAD_LEN
2920001 0010 01 000000 0000000000000000
293
8dd54666
IY
294dnl Goto-Table 1 instruction non-zero padding
295# actions=goto_table:1
296# 7: 01 -> 00
2970001 0008 01 000001
298
299dnl Goto-Table 1
300# actions=goto_table:1
d01c980f
BP
3010001 0008 01 000000
302
303dnl Write-Metadata not supported yet.
304# bad OF1.1 instructions: OFPBIC_UNSUP_INST
3050002 0018 00000000 fedcba9876543210 ffffffffffffffff
306
307dnl Write-Metadata too short.
308# bad OF1.1 instructions: OFPBIC_BAD_LEN
3090002 0010 00000000 fedcba9876543210
310
311dnl Write-Metadata too long.
312# bad OF1.1 instructions: OFPBIC_BAD_LEN
3130002 0020 00000000 fedcba9876543210 ffffffffffffffff 0000000000000000
314
315dnl Write-Actions not supported yet.
316# bad OF1.1 instructions: OFPBIC_UNSUP_INST
3170003 0008 01 000000
318
b19e8793
IY
319dnl Clear-Actions too-long
320# bad OF1.1 instructions: OFPBIC_BAD_LEN
3210005 0010 00000000 0000000000000000
322
323dnl Clear-Actions non-zero padding
324# actions=clear_actions
325# 7: 01 -> 00
3260005 0008 00000001
327
328dnl Clear-Actions non-zero padding
329# actions=clear_actions
330# 4: 01 -> 00
d01c980f
BP
3310005 0008 01 000000
332
b19e8793
IY
333dnl Clear-Actions
334# actions=clear_actions
3350005 0008 00000000
336
d01c980f
BP
337dnl Experimenter actions not supported yet.
338# bad OF1.1 instructions: OFPBIC_BAD_EXPERIMENTER
339ffff 0008 01 000000
340
341dnl Bad instruction number (0 not assigned).
342# bad OF1.1 instructions: OFPBIC_UNKNOWN_INST
3430000 0008 01 000000
344
345])
346sed '/^[[#&]]/d' < test-data > input.txt
347sed -n 's/^# //p; /^$/p' < test-data > expout
348sed -n 's/^& //p' < test-data > experr
349AT_CAPTURE_FILE([input.txt])
350AT_CAPTURE_FILE([expout])
351AT_CAPTURE_FILE([experr])
352AT_CHECK(
353 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-ofp11-instructions < input.txt],
354 [0], [expout], [experr])
355AT_CLEANUP