]> git.proxmox.com Git - mirror_ovs.git/blame - tests/ofp-actions.at
Rename NOT_REACHED to OVS_NOT_REACHED
[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
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
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
f25d0cf3
BP
81# actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
82ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
830004 0008 00000000
84
85# actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
86ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
870004 0008 00000000
88
89# actions=resubmit(10,5)
90ffff 0010 00002320 000e 000a 05 000000
91
92# actions=output:NXM_NX_REG1[5..10]
93ffff 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[])
96ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
97000c 00000802 0000 00000802 0000 dnl
980030 00000406 0000 00000206 0000 dnl
991010 00000002 0000 dnl
10000000000
101
102# actions=exit
103ffff 0010 00002320 0011 000000000000
104
105# actions=dec_ttl
106ffff 0010 00002320 0012 000000000000
107
108# actions=fin_timeout(idle_timeout=10,hard_timeout=20)
109ffff 0010 00002320 0013 000a 0014 0000
110
111# actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
112ffff 0010 00002320 0014 04d2 162e 02 00
113
c2d967a5
MM
114# actions=dec_ttl(32768,12345,90,765,1024)
115ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
116
29089a54
RL
117# actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
118ffff 0018 00002320 001d 3039 00005BA0 00008707 0000B26E
119
f25d0cf3
BP
120])
121sed '/^[[#&]]/d' < test-data > input.txt
122sed -n 's/^# //p; /^$/p' < test-data > expout
123sed -n 's/^& //p' < test-data > experr
124AT_CAPTURE_FILE([input.txt])
125AT_CAPTURE_FILE([expout])
126AT_CAPTURE_FILE([experr])
127AT_CHECK(
128 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-ofp10-actions < input.txt],
129 [0], [expout], [experr])
130AT_CLEANUP
d01c980f
BP
131
132AT_SETUP([OpenFlow 1.1 action translation])
4cceacb9 133AT_KEYWORDS([ofp-actions OF1.1])
d01c980f
BP
134AT_DATA([test-data], [dnl
135# actions=LOCAL
1360000 0010 fffffffe 04d2 000000000000
137
138# actions=CONTROLLER:1234
1390000 0010 fffffffd 04d2 000000000000
140
ca287d20 141# actions=set_vlan_vid:9
d01c980f
BP
1420001 0008 0009 0000
143
ca287d20 144# actions=set_vlan_pcp:6
d01c980f
BP
1450002 0008 06 000000
146
147# actions=mod_dl_src:00:11:22:33:44:55
1480003 0010 001122334455 000000000000
149
150# actions=mod_dl_dst:10:20:30:40:50:60
1510004 0010 102030405060 000000000000
152
153# actions=mod_nw_src:1.2.3.4
1540005 0008 01020304
155
156# actions=mod_nw_dst:192.168.0.1
1570006 0008 c0a80001
158
159# actions=mod_nw_tos:48
1600007 0008 30 000000
161
162# actions=mod_tp_src:80
1630009 0008 0050 0000
164
165# actions=mod_tp_dst:443
166000a 0008 01bb 0000
167
64fcc073 168# actions=pop_vlan
8e61c110
IY
1690012 0008 00000000
170
276c4e7a
SH
171# actions=set_queue:2309737729
1720015 0008 89abcd01
173
3e34fbdd
IY
174dnl 802.1ad isn't supported at the moment
175dnl # actions=push_vlan:0x88a8
176dnl 0011 0008 88a8 0000
177# actions=push_vlan:0x8100
1780011 0008 8100 0000
179
d01c980f
BP
180# actions=resubmit:5
181ffff 0010 00002320 0001 0005 00000000
182
183# actions=set_tunnel:0x12345678
184ffff 0010 00002320 0002 0000 12345678
185
d01c980f
BP
186# actions=pop_queue
187ffff 0010 00002320 0005 000000000000
188
189# actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
190ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
191
192# actions=load:0xf009->NXM_OF_VLAN_TCI[]
193ffff 0018 00002320 0007 000f 00000802 000000000000f009
194
195# actions=note:11.e9.9a.ad.67.f3
196ffff 0010 00002320 0008 11e99aad67f3
197
198# actions=set_tunnel64:0xc426384d49c53d60
199ffff 0018 00002320 0009 000000000000 c426384d49c53d60
200
201# actions=set_tunnel64:0x885f3298
202ffff 0018 00002320 0009 000000000000 00000000885f3298
203
4cceacb9
JS
204dnl OpenFlow 1.1 uses OFPIT_WRITE_METADATA to express the NXAST_WRITE_METADATA
205dnl action instead, so parse-ofp11-actions will recognise and drop this action.
206# actions=write_metadata:0xfedcba9876543210
207# 0: ff -> (none)
208# 1: ff -> (none)
209# 2: 00 -> (none)
210# 3: 20 -> (none)
211# 4: 00 -> (none)
212# 5: 00 -> (none)
213# 6: 23 -> (none)
214# 7: 20 -> (none)
215# 8: 00 -> (none)
216# 9: 16 -> (none)
217# 10: 00 -> (none)
218# 11: 00 -> (none)
219# 12: 00 -> (none)
220# 13: 00 -> (none)
221# 14: 00 -> (none)
222# 15: 00 -> (none)
223# 16: fe -> (none)
224# 17: dc -> (none)
225# 18: ba -> (none)
226# 19: 98 -> (none)
227# 20: 76 -> (none)
228# 21: 54 -> (none)
229# 22: 32 -> (none)
230# 23: 10 -> (none)
231# 24: ff -> (none)
232# 25: ff -> (none)
233# 26: ff -> (none)
234# 27: ff -> (none)
235# 28: ff -> (none)
236# 29: ff -> (none)
237# 30: ff -> (none)
238# 31: ff -> (none)
239ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
240
241dnl Write-Metadata duplicated.
6813ee7c 242& ofp_actions|WARN|duplicate write_metadata instruction not allowed, for OpenFlow 1.1+ compatibility
4cceacb9
JS
243# bad OF1.1 actions: OFPBAC_UNSUPPORTED_ORDER
244ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
245
246dnl Write-Metadata in wrong position.
6813ee7c 247& ofp_actions|WARN|invalid instruction ordering: apply_actions must appear before write_metadata, for OpenFlow 1.1+ compatibility
4cceacb9
JS
248# bad OF1.1 actions: OFPBAC_UNSUPPORTED_ORDER
249ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff ffff 0010 00002320 0002 0000 12345678
250
d01c980f
BP
251# actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
252ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
253
d01c980f
BP
254# actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
255ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
2560004 0008 00000000
257
258# actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
259ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
2600004 0008 00000000
261
262# actions=resubmit(10,5)
263ffff 0010 00002320 000e 000a 05 000000
264
265# actions=output:NXM_NX_REG1[5..10]
266ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
267
268# 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[])
269ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
270000c 00000802 0000 00000802 0000 dnl
2710030 00000406 0000 00000206 0000 dnl
2721010 00000002 0000 dnl
27300000000
274
275# actions=exit
276ffff 0010 00002320 0011 000000000000
277
7bcb1506 278dnl NXAST_DEC_TTL
d01c980f
BP
279# actions=dec_ttl
280ffff 0010 00002320 0012 000000000000
281
7bcb1506
IY
282dnl OpenFlow 1.1 OFPAT_DEC_TTL
283# actions=dec_ttl
2840018 0008 00000000
285
d01c980f
BP
286# actions=fin_timeout(idle_timeout=10,hard_timeout=20)
287ffff 0010 00002320 0013 000a 0014 0000
288
289# actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
290ffff 0010 00002320 0014 04d2 162e 02 00
291
c2d967a5
MM
292# actions=dec_ttl(32768,12345,90,765,1024)
293ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
294
29089a54
RL
295# actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
296ffff 0018 00002320 001d 3039 00005BA0 00008707 0000B26E
297
d01c980f
BP
298])
299sed '/^[[#&]]/d' < test-data > input.txt
300sed -n 's/^# //p; /^$/p' < test-data > expout
301sed -n 's/^& //p' < test-data > experr
302AT_CAPTURE_FILE([input.txt])
303AT_CAPTURE_FILE([expout])
304AT_CAPTURE_FILE([experr])
305AT_CHECK(
306 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-ofp11-actions < input.txt],
307 [0], [expout], [experr])
308AT_CLEANUP
309
310AT_SETUP([OpenFlow 1.1 instruction translation])
4cceacb9 311AT_KEYWORDS([OF1.1 instruction ofp-actions])
d01c980f
BP
312AT_DATA([test-data], [dnl
313# actions=LOCAL
3140004 0018 00000000 dnl
3150000 0010 fffffffe 04d2 000000000000
316
8dd54666
IY
317dnl Apply-Actions non-zero padding
318# actions=drop
319# 0: 00 -> (none)
320# 1: 04 -> (none)
321# 2: 00 -> (none)
322# 3: 08 -> (none)
323# 4: 00 -> (none)
324# 5: 00 -> (none)
325# 6: 00 -> (none)
326# 7: 01 -> (none)
3270004 0008 00000001
328
d01c980f
BP
329dnl Check that an empty Apply-Actions instruction gets dropped.
330# actions=drop
331# 0: 00 -> (none)
332# 1: 04 -> (none)
333# 2: 00 -> (none)
334# 3: 08 -> (none)
335# 4: 00 -> (none)
336# 5: 00 -> (none)
337# 6: 00 -> (none)
338# 7: 00 -> (none)
3390004 0008 00000000
340
e38c9de5 341dnl Duplicate instruction type:
f4104c68 342# bad OF1.1 instructions: ONFBIC_DUP_INSTRUCTION
d01c980f
BP
3430004 0008 00000000 0004 0008 00000000
344
345dnl Instructions not multiple of 8 in length.
346& ofp_actions|WARN|OpenFlow message instructions length 9 is not a multiple of 8
347# bad OF1.1 instructions: OFPBIC_BAD_LEN
3480004 0009 01 00000000
349
350dnl Goto-Table instruction too long.
351# bad OF1.1 instructions: OFPBIC_BAD_LEN
3520001 0010 01 000000 0000000000000000
353
8dd54666
IY
354dnl Goto-Table 1 instruction non-zero padding
355# actions=goto_table:1
356# 7: 01 -> 00
3570001 0008 01 000001
358
bff7eeb6
JA
359dnl Goto-Table 1 instruction go back to the previous table.
360# bad OF1.1 instructions: OFPBRC_BAD_TABLE_ID
3612,0001 0008 01 000000
362
8dd54666
IY
363dnl Goto-Table 1
364# actions=goto_table:1
d01c980f
BP
3650001 0008 01 000000
366
4cceacb9
JS
367dnl Write-Metadata.
368# actions=write_metadata:0xfedcba9876543210
d01c980f
BP
3690002 0018 00000000 fedcba9876543210 ffffffffffffffff
370
4cceacb9
JS
371dnl Write-Metadata with mask.
372# actions=write_metadata:0xfedcba9876543210/0xff00ff00ff00ff00
3730002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
374
d01c980f
BP
375dnl Write-Metadata too short.
376# bad OF1.1 instructions: OFPBIC_BAD_LEN
3770002 0010 00000000 fedcba9876543210
378
379dnl Write-Metadata too long.
380# bad OF1.1 instructions: OFPBIC_BAD_LEN
3810002 0020 00000000 fedcba9876543210 ffffffffffffffff 0000000000000000
382
4cceacb9 383dnl Write-Metadata duplicated.
f4104c68 384# bad OF1.1 instructions: ONFBIC_DUP_INSTRUCTION
4cceacb9
JS
3850002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
386
6813ee7c
BP
387dnl Write-Metadata in wrong position (OpenFlow 1.1+ disregards the order
388dnl and OVS reorders it to the canonical order)
389# actions=write_metadata:0xfedcba9876543210,goto_table:1
390# 1: 01 -> 02
391# 3: 08 -> 18
392# 4: 01 -> 00
393# 8: 00 -> fe
394# 9: 02 -> dc
395# 10: 00 -> ba
396# 11: 18 -> 98
397# 12: 00 -> 76
398# 13: 00 -> 54
399# 14: 00 -> 32
400# 15: 00 -> 10
401# 16: fe -> ff
402# 17: dc -> ff
403# 18: ba -> ff
404# 19: 98 -> ff
405# 20: 76 -> ff
406# 21: 54 -> ff
407# 22: 32 -> ff
408# 23: 10 -> ff
409# 24: ff -> 00
410# 25: ff -> 01
411# 26: ff -> 00
412# 27: ff -> 08
413# 28: ff -> 01
414# 29: ff -> 00
415# 30: ff -> 00
416# 31: ff -> 00
4cceacb9
JS
4170001 0008 01 000000 0002 0018 00000000 fedcba9876543210 ffffffffffffffff
418
7fdb60a7
SH
419dnl empty Write-Actions non-zero padding
420# actions=write_actions(drop)
421# 0: 00 -> (none)
422# 1: 03 -> (none)
423# 2: 00 -> (none)
424# 3: 08 -> (none)
425# 4: 00 -> (none)
426# 5: 00 -> (none)
427# 6: 00 -> (none)
428# 7: 01 -> (none)
4290003 0008 00000001
430
431dnl Check that an empty Write-Actions instruction gets dropped.
432# actions=write_actions(drop)
433# 0: 00 -> (none)
434# 1: 03 -> (none)
435# 2: 00 -> (none)
436# 3: 08 -> (none)
437# 4: 00 -> (none)
438# 5: 00 -> (none)
439# 6: 00 -> (none)
440# 7: 00 -> (none)
4410003 0008 00000000
d01c980f 442
b19e8793
IY
443dnl Clear-Actions too-long
444# bad OF1.1 instructions: OFPBIC_BAD_LEN
4450005 0010 00000000 0000000000000000
446
447dnl Clear-Actions non-zero padding
448# actions=clear_actions
449# 7: 01 -> 00
4500005 0008 00000001
451
452dnl Clear-Actions non-zero padding
453# actions=clear_actions
454# 4: 01 -> 00
d01c980f
BP
4550005 0008 01 000000
456
b19e8793
IY
457dnl Clear-Actions
458# actions=clear_actions
4590005 0008 00000000
460
d01c980f
BP
461dnl Experimenter actions not supported yet.
462# bad OF1.1 instructions: OFPBIC_BAD_EXPERIMENTER
463ffff 0008 01 000000
464
465dnl Bad instruction number (0 not assigned).
466# bad OF1.1 instructions: OFPBIC_UNKNOWN_INST
4670000 0008 01 000000
468
469])
470sed '/^[[#&]]/d' < test-data > input.txt
471sed -n 's/^# //p; /^$/p' < test-data > expout
472sed -n 's/^& //p' < test-data > experr
473AT_CAPTURE_FILE([input.txt])
474AT_CAPTURE_FILE([expout])
475AT_CAPTURE_FILE([experr])
476AT_CHECK(
477 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-ofp11-instructions < input.txt],
478 [0], [expout], [experr])
479AT_CLEANUP
94baabf7
SH
480
481AT_SETUP([ofp-actions - inconsistent MPLS actions])
482OVS_VSWITCHD_START
483dnl OK: Use fin_timeout action on TCP flow
484AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=fin_timeout(idle_timeout=1)'])
485dnl Bad: Use fin_timeout action on TCP flow that has been converted to MPLS
486AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=push_mpls:0x8847,fin_timeout(idle_timeout=1)'],
487 [1], [], [dnl
ba2fe8e9 488ovs-ofctl: none of the usable flow formats (OpenFlow10,NXM) is among the allowed flow formats (OpenFlow11)
94baabf7
SH
489])
490OVS_VSWITCHD_STOP
491AT_CLEANUP