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