Merge branch 'hotfix' into make-improv
[sliver-openvswitch.git] / tests / ofp-actions.at
1 AT_BANNER([OpenFlow actions])
2
3 AT_SETUP([OpenFlow 1.0 action translation])
4 AT_KEYWORDS([ofp-actions OF1.0])
5 AT_DATA([test-data], [dnl
6 # actions=LOCAL
7 0000 0008 fffe 04d2
8
9 # actions=CONTROLLER:1234
10 0000 0008 fffd 04d2
11
12 # actions=mod_vlan_vid:9
13 0001 0008 0009 0000
14
15 # actions=mod_vlan_pcp:6
16 0002 0008 06 000000
17
18 # actions=strip_vlan
19 0003 0008 00000000
20
21 # actions=mod_dl_src:00:11:22:33:44:55
22 0004 0010 001122334455 000000000000
23
24 # actions=mod_dl_dst:10:20:30:40:50:60
25 0005 0010 102030405060 000000000000
26
27 # actions=mod_nw_src:1.2.3.4
28 0006 0008 01020304
29
30 # actions=mod_nw_dst:192.168.0.1
31 0007 0008 c0a80001
32
33 # actions=mod_nw_tos:48
34 0008 0008 30 000000
35
36 # actions=mod_tp_src:80
37 0009 0008 0050 0000
38
39 # actions=mod_tp_dst:443
40 000a 0008 01bb 0000
41
42 # actions=enqueue:10q55
43 000b 0010 000a 000000000000 00000037
44
45 # actions=resubmit:5
46 ffff 0010 00002320 0001 0005 00000000
47
48 # actions=set_tunnel:0x12345678
49 ffff 0010 00002320 0002 0000 12345678
50
51 # actions=set_queue:2309737729
52 ffff 0010 00002320 0004 0000 89abcd01
53
54 # actions=pop_queue
55 ffff 0010 00002320 0005 000000000000
56
57 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
58 ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
59
60 # actions=load:0xf009->NXM_OF_VLAN_TCI[]
61 ffff 0018 00002320 0007 000f 00000802 000000000000f009
62
63 # actions=note:11.e9.9a.ad.67.f3
64 ffff 0010 00002320 0008 11e99aad67f3
65
66 # actions=set_tunnel64:0xc426384d49c53d60
67 ffff 0018 00002320 0009 000000000000 c426384d49c53d60
68
69 # actions=set_tunnel64:0x885f3298
70 ffff 0018 00002320 0009 000000000000 00000000885f3298
71
72 # actions=write_metadata:0xfedcba9876543210
73 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
74
75 # actions=write_metadata:0xfedcba9876543210/0xffff0000ffff0000
76 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffff0000ffff0000
77
78 # actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
79 ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
80
81 # actions=autopath(2,NXM_NX_REG0[2..30])
82 & autopath|WARN|The autopath action is deprecated and may be removed in February 2013.  Please email dev@openvswitch.org with concerns.
83 ffff 0018 00002320 000b 009c 00010004 00000002 00000000
84
85 # actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
86 ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
87 0004 0008 00000000
88
89 # actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
90 ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
91 0004 0008 00000000
92
93 # actions=resubmit(10,5)
94 ffff 0010 00002320 000e 000a 05 000000
95
96 # actions=output:NXM_NX_REG1[5..10]
97 ffff 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[])
100 ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
101 000c 00000802 0000 00000802 0000 dnl
102 0030 00000406 0000 00000206 0000 dnl
103 1010 00000002 0000 dnl
104 00000000
105
106 # actions=exit
107 ffff 0010 00002320 0011 000000000000
108
109 # actions=dec_ttl
110 ffff 0010 00002320 0012 000000000000
111
112 # actions=fin_timeout(idle_timeout=10,hard_timeout=20)
113 ffff 0010 00002320 0013 000a 0014 0000
114
115 # actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
116 ffff 0010 00002320 0014 04d2 162e 02 00
117
118 # actions=dec_ttl(32768,12345,90,765,1024)
119 ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
120
121 ])
122 sed '/^[[#&]]/d' < test-data > input.txt
123 sed -n 's/^# //p; /^$/p' < test-data > expout
124 sed -n 's/^& //p' < test-data > experr
125 AT_CAPTURE_FILE([input.txt])
126 AT_CAPTURE_FILE([expout])
127 AT_CAPTURE_FILE([experr])
128 AT_CHECK(
129   [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-ofp10-actions < input.txt],
130   [0], [expout], [experr])
131 AT_CLEANUP
132
133 AT_SETUP([OpenFlow 1.1 action translation])
134 AT_KEYWORDS([ofp-actions OF1.1])
135 AT_DATA([test-data], [dnl
136 # actions=LOCAL
137 0000 0010 fffffffe 04d2 000000000000
138
139 # actions=CONTROLLER:1234
140 0000 0010 fffffffd 04d2 000000000000
141
142 # actions=mod_vlan_vid:9
143 0001 0008 0009 0000
144
145 # actions=mod_vlan_pcp:6
146 0002 0008 06 000000
147
148 # actions=mod_dl_src:00:11:22:33:44:55
149 0003 0010 001122334455 000000000000
150
151 # actions=mod_dl_dst:10:20:30:40:50:60
152 0004 0010 102030405060 000000000000
153
154 # actions=mod_nw_src:1.2.3.4
155 0005 0008 01020304
156
157 # actions=mod_nw_dst:192.168.0.1
158 0006 0008 c0a80001
159
160 # actions=mod_nw_tos:48
161 0007 0008 30 000000
162
163 # actions=mod_tp_src:80
164 0009 0008 0050 0000
165
166 # actions=mod_tp_dst:443
167 000a 0008 01bb 0000
168
169 # actions=strip_vlan
170 0012 0008 00000000
171
172 dnl 802.1ad isn't supported at the moment
173 dnl # actions=push_vlan:0x88a8
174 dnl 0011 0008 88a8 0000
175 # actions=push_vlan:0x8100
176 0011 0008 8100 0000
177
178 # actions=resubmit:5
179 ffff 0010 00002320 0001 0005 00000000
180
181 # actions=set_tunnel:0x12345678
182 ffff 0010 00002320 0002 0000 12345678
183
184 # actions=set_queue:2309737729
185 ffff 0010 00002320 0004 0000 89abcd01
186
187 # actions=pop_queue
188 ffff 0010 00002320 0005 000000000000
189
190 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
191 ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
192
193 # actions=load:0xf009->NXM_OF_VLAN_TCI[]
194 ffff 0018 00002320 0007 000f 00000802 000000000000f009
195
196 # actions=note:11.e9.9a.ad.67.f3
197 ffff 0010 00002320 0008 11e99aad67f3
198
199 # actions=set_tunnel64:0xc426384d49c53d60
200 ffff 0018 00002320 0009 000000000000 c426384d49c53d60
201
202 # actions=set_tunnel64:0x885f3298
203 ffff 0018 00002320 0009 000000000000 00000000885f3298
204
205 dnl OpenFlow 1.1 uses OFPIT_WRITE_METADATA to express the NXAST_WRITE_METADATA
206 dnl action instead, so parse-ofp11-actions will recognise and drop this action.
207 # actions=write_metadata:0xfedcba9876543210
208 #  0: ff -> (none)
209 #  1: ff -> (none)
210 #  2: 00 -> (none)
211 #  3: 20 -> (none)
212 #  4: 00 -> (none)
213 #  5: 00 -> (none)
214 #  6: 23 -> (none)
215 #  7: 20 -> (none)
216 #  8: 00 -> (none)
217 #  9: 16 -> (none)
218 # 10: 00 -> (none)
219 # 11: 00 -> (none)
220 # 12: 00 -> (none)
221 # 13: 00 -> (none)
222 # 14: 00 -> (none)
223 # 15: 00 -> (none)
224 # 16: fe -> (none)
225 # 17: dc -> (none)
226 # 18: ba -> (none)
227 # 19: 98 -> (none)
228 # 20: 76 -> (none)
229 # 21: 54 -> (none)
230 # 22: 32 -> (none)
231 # 23: 10 -> (none)
232 # 24: ff -> (none)
233 # 25: ff -> (none)
234 # 26: ff -> (none)
235 # 27: ff -> (none)
236 # 28: ff -> (none)
237 # 29: ff -> (none)
238 # 30: ff -> (none)
239 # 31: ff -> (none)
240 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
241
242 dnl Write-Metadata duplicated.
243 & ofp_actions|WARN|duplicate write_metadata instruction specified
244 # bad OF1.1 actions: OFPBAC_UNSUPPORTED_ORDER
245 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
246
247 dnl Write-Metadata in wrong position.
248 & ofp_actions|WARN|write_metadata instruction must be specified after other instructions/actions
249 # bad OF1.1 actions: OFPBAC_UNSUPPORTED_ORDER
250 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff ffff 0010 00002320 0002 0000 12345678
251
252 # actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
253 ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
254
255 # actions=autopath(2,NXM_NX_REG0[2..30])
256 & autopath|WARN|The autopath action is deprecated and may be removed in February 2013.  Please email dev@openvswitch.org with concerns.
257 ffff 0018 00002320 000b 009c 00010004 00000002 00000000
258
259 # actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
260 ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
261 0004 0008 00000000
262
263 # actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
264 ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
265 0004 0008 00000000
266
267 # actions=resubmit(10,5)
268 ffff 0010 00002320 000e 000a 05 000000
269
270 # actions=output:NXM_NX_REG1[5..10]
271 ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
272
273 # 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[])
274 ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
275 000c 00000802 0000 00000802 0000 dnl
276 0030 00000406 0000 00000206 0000 dnl
277 1010 00000002 0000 dnl
278 00000000
279
280 # actions=exit
281 ffff 0010 00002320 0011 000000000000
282
283 dnl NXAST_DEC_TTL
284 # actions=dec_ttl
285 ffff 0010 00002320 0012 000000000000
286
287 dnl OpenFlow 1.1 OFPAT_DEC_TTL
288 # actions=dec_ttl
289 0018 0008 00000000
290
291 # actions=fin_timeout(idle_timeout=10,hard_timeout=20)
292 ffff 0010 00002320 0013 000a 0014 0000
293
294 # actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
295 ffff 0010 00002320 0014 04d2 162e 02 00
296
297 # actions=dec_ttl(32768,12345,90,765,1024)
298 ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
299
300 ])
301 sed '/^[[#&]]/d' < test-data > input.txt
302 sed -n 's/^# //p; /^$/p' < test-data > expout
303 sed -n 's/^& //p' < test-data > experr
304 AT_CAPTURE_FILE([input.txt])
305 AT_CAPTURE_FILE([expout])
306 AT_CAPTURE_FILE([experr])
307 AT_CHECK(
308   [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-ofp11-actions < input.txt],
309   [0], [expout], [experr])
310 AT_CLEANUP
311
312 AT_SETUP([OpenFlow 1.1 instruction translation])
313 AT_KEYWORDS([OF1.1 instruction ofp-actions])
314 AT_DATA([test-data], [dnl
315 # actions=LOCAL
316 0004 0018 00000000 dnl
317 0000 0010 fffffffe 04d2 000000000000
318
319 dnl Apply-Actions non-zero padding
320 # actions=drop
321 #  0: 00 -> (none)
322 #  1: 04 -> (none)
323 #  2: 00 -> (none)
324 #  3: 08 -> (none)
325 #  4: 00 -> (none)
326 #  5: 00 -> (none)
327 #  6: 00 -> (none)
328 #  7: 01 -> (none)
329 0004 0008 00000001
330
331 dnl Check that an empty Apply-Actions instruction gets dropped.
332 # actions=drop
333 #  0: 00 -> (none)
334 #  1: 04 -> (none)
335 #  2: 00 -> (none)
336 #  3: 08 -> (none)
337 #  4: 00 -> (none)
338 #  5: 00 -> (none)
339 #  6: 00 -> (none)
340 #  7: 00 -> (none)
341 0004 0008 00000000
342
343 dnl Duplicate instruction type:
344 # bad OF1.1 instructions: OFPIT_BAD_INSTRUCTION
345 0004 0008 00000000 0004 0008 00000000
346
347 dnl Instructions not multiple of 8 in length.
348 & ofp_actions|WARN|OpenFlow message instructions length 9 is not a multiple of 8
349 # bad OF1.1 instructions: OFPBIC_BAD_LEN
350 0004 0009 01 00000000
351
352 dnl Goto-Table instruction too long.
353 # bad OF1.1 instructions: OFPBIC_BAD_LEN
354 0001 0010 01 000000 0000000000000000
355
356 dnl Goto-Table 1 instruction non-zero padding
357 # actions=goto_table:1
358 #  7: 01 -> 00
359 0001 0008 01 000001
360
361 dnl Goto-Table 1
362 # actions=goto_table:1
363 0001 0008 01 000000
364
365 dnl Write-Metadata.
366 # actions=write_metadata:0xfedcba9876543210
367 0002 0018 00000000 fedcba9876543210 ffffffffffffffff
368
369 dnl Write-Metadata with mask.
370 # actions=write_metadata:0xfedcba9876543210/0xff00ff00ff00ff00
371 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
372
373 dnl Write-Metadata too short.
374 # bad OF1.1 instructions: OFPBIC_BAD_LEN
375 0002 0010 00000000 fedcba9876543210
376
377 dnl Write-Metadata too long.
378 # bad OF1.1 instructions: OFPBIC_BAD_LEN
379 0002 0020 00000000 fedcba9876543210 ffffffffffffffff 0000000000000000
380
381 dnl Write-Metadata duplicated.
382 # bad OF1.1 instructions: OFPIT_BAD_INSTRUCTION
383 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
384
385 dnl Write-Metadata in wrong position.
386 & ofp_actions|WARN|write_metadata instruction must be specified after other instructions/actions
387 # bad OF1.1 instructions: OFPBAC_UNSUPPORTED_ORDER
388 0001 0008 01 000000 0002 0018 00000000 fedcba9876543210 ffffffffffffffff
389
390 dnl Write-Actions not supported yet.
391 # bad OF1.1 instructions: OFPBIC_UNSUP_INST
392 0003 0008 01 000000
393
394 dnl Clear-Actions too-long
395 # bad OF1.1 instructions: OFPBIC_BAD_LEN
396 0005 0010 00000000 0000000000000000
397
398 dnl Clear-Actions non-zero padding
399 # actions=clear_actions
400 #  7: 01 -> 00
401 0005 0008 00000001
402
403 dnl Clear-Actions non-zero padding
404 # actions=clear_actions
405 #  4: 01 -> 00
406 0005 0008 01 000000
407
408 dnl Clear-Actions
409 # actions=clear_actions
410 0005 0008 00000000
411
412 dnl Experimenter actions not supported yet.
413 # bad OF1.1 instructions: OFPBIC_BAD_EXPERIMENTER
414 ffff 0008 01 000000
415
416 dnl Bad instruction number (0 not assigned).
417 # bad OF1.1 instructions: OFPBIC_UNKNOWN_INST
418 0000 0008 01 000000
419
420 ])
421 sed '/^[[#&]]/d' < test-data > input.txt
422 sed -n 's/^# //p; /^$/p' < test-data > expout
423 sed -n 's/^& //p' < test-data > experr
424 AT_CAPTURE_FILE([input.txt])
425 AT_CAPTURE_FILE([expout])
426 AT_CAPTURE_FILE([experr])
427 AT_CHECK(
428   [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-ofp11-instructions < input.txt],
429   [0], [expout], [experr])
430 AT_CLEANUP