]> git.proxmox.com Git - ovs.git/blob - tests/ofp-actions.at
actions: Add resubmit with conntrack tuple.
[ovs.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:10:55
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 # bad OpenFlow10 actions: OFPBIC_UNSUP_INST
73 & ofp_actions|WARN|write_metadata instruction not allowed here
74 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
75
76 # bad OpenFlow10 actions: OFPBIC_UNSUP_INST
77 & ofp_actions|WARN|write_metadata instruction not allowed here
78 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffff0000ffff0000
79
80 # actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
81 ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
82
83 # actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
84 ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
85 0004 0008 00000000
86
87 # actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
88 ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
89 0004 0008 00000000
90
91 # actions=resubmit(10,5)
92 ffff 0010 00002320 000e 000a 05 000000
93
94 # actions=resubmit(10,5,ct)
95 ffff 0010 00002320 002c 000a 05 000000
96
97 # actions=output:NXM_NX_REG1[5..10]
98 ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
99
100 # 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[])
101 ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
102 000c 00000802 0000 00000802 0000 dnl
103 0030 00000406 0000 00000206 0000 dnl
104 1010 00000002 0000 dnl
105 00000000
106
107 # actions=exit
108 ffff 0010 00002320 0011 000000000000
109
110 # actions=dec_ttl
111 ffff 0010 00002320 0012 000000000000
112
113 # actions=fin_timeout(idle_timeout=10,hard_timeout=20)
114 ffff 0010 00002320 0013 000a 0014 0000
115
116 # actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
117 ffff 0010 00002320 0014 04d2 162e 02 00
118
119 # actions=controller(reason=invalid_ttl,max_len=1234,id=5678,userdata=01.02.03.04.05,pause)
120 ffff 0040 00002320 0025 000000000000 dnl
121 0000 0008 04d2 0000 dnl
122 0001 0008 162e 0000 dnl
123 0002 0005 02 000000 dnl
124 0003 0009 0102030405 00000000000000 dnl
125 0004 0004 00000000
126
127 # actions=dec_ttl(32768,12345,90,765,1024)
128 ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
129
130 # actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
131 ffff 0018 00002320 001d 3039 00005BA0 00008707 0000B26E
132
133 # actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678,sampling_port=56789)
134 ffff 0020 00002320 0026 3039 00005BA0 00008707 0000B26E DDD50000 00000000
135
136 # actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678,sampling_port=56789,egress)
137 ffff 0020 00002320 0029 3039 00005BA0 00008707 0000B26E DDD50200 00000000
138
139 # bad OpenFlow10 actions: OFPBAC_BAD_LEN
140 & ofp_actions|WARN|OpenFlow action OFPAT_OUTPUT length 240 exceeds action buffer length 8
141 & ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_LEN):
142 & 00000000 00 00 00 f0 00 00 00 00-
143 00 00 00 f0 00 00 00 00
144
145 # bad OpenFlow10 actions: OFPBAC_BAD_LEN
146 & ofp_actions|WARN|OpenFlow action OFPAT_OUTPUT length 16 not in valid range [[8,8]]
147 & ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_LEN):
148 & 00000000 00 00 00 10 ff fe ff ff-00 00 00 00 00 00 00 00
149 00 00 00 10 ff fe ff ff 00 00 00 00 00 00 00 00
150
151 # bad OpenFlow10 actions: OFPBAC_BAD_LEN
152 & ofp_actions|WARN|OpenFlow action NXAST_DEC_TTL_CNT_IDS length 17 is not a multiple of 8
153 ffff 0011 00002320 0015 0001 00000000 0000000000000000
154
155 # bad OpenFlow10 actions: OFPBAC_BAD_OUT_PORT
156 0000 0008 ffff 0000
157
158 # actions=ct()
159 ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0000
160
161 # actions=ct(commit)
162 ffff 0018 00002320 0023 0001 00000000 0000 FF 000000 0000
163
164 # actions=ct(table=10)
165 ffff 0018 00002320 0023 0000 00000000 0000 0A 000000 0000
166
167 # actions=ct(zone=10)
168 ffff 0018 00002320 0023 0000 00000000 000A FF 000000 0000
169
170 # actions=ct(zone=NXM_NX_REG0[0..15])
171 ffff 0018 00002320 0023 0000 00010004 000F FF 000000 0000
172
173 dnl Can't read 8 bits from register into 16-bit zone.
174 # bad OpenFlow10 actions: OFPBAC_BAD_SET_LEN
175 ffff 0018 00002320 0023 0000 00010004 0007 FF 000000 0000
176
177 dnl Can't read 32 bits from register into 16-bit zone.
178 # bad OpenFlow10 actions: OFPBAC_BAD_SET_LEN
179 ffff 0018 00002320 0023 0000 00010004 001F FF 000000 0000
180
181 # actions=ct(commit,exec(load:0xf009->NXM_NX_CT_MARK[]))
182 ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
183 ffff 0018 00002320 0007 001f 0001d604 000000000000f009
184
185 # bad OpenFlow10 actions: OFPBAC_BAD_SET_ARGUMENT
186 & ofp_actions|WARN|cannot set CT fields outside of ct action
187 ffff 0018 00002320 0007 001f 0001d604 000000000000f009
188
189 # bad OpenFlow10 actions: OFPBAC_BAD_SET_ARGUMENT
190 & meta_flow|WARN|destination field ct_zone is not writable
191 ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
192 ffff 0018 00002320 0007 000f 0001d504 000000000000f009
193
194 # bad OpenFlow10 actions: OFPBAC_BAD_ARGUMENT
195 & ofp_actions|WARN|ct action doesn't support nested action ct
196 ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
197 ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0000
198
199 # bad OpenFlow10 actions: OFPBAC_BAD_ARGUMENT
200 & ofp_actions|WARN|ct action doesn't support nested modification of reg0
201 ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
202 ffff 0018 00002320 0007 001f 00010004 000000000000f009
203
204 # actions=ct(alg=ftp)
205 ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0015
206
207 # actions=ct(alg=tftp)
208 ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0045
209
210 # actions=ct(commit,nat(src))
211 ffff 0028 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
212 ffff 0010 00002320 0024 00 00 0001 0000
213
214 # actions=ct(commit,nat(dst))
215 ffff 0028 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
216 ffff 0010 00002320 0024 00 00 0002 0000
217
218 # actions=ct(nat)
219 ffff 0028 00002320 0023 0000 00000000 0000 FF 000000 0000 dnl
220 ffff 0010 00002320 0024 00 00 0000 0000
221
222 # actions=ct(commit,nat(src=10.0.0.240,random))
223 ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
224 ffff 0018 00002320 0024 00 00 0011 0001 0a0000f0 00000000
225
226 # actions=ct(commit,nat(src=10.0.0.240:32768-65535,random))
227 ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
228 ffff 0018 00002320 0024 00 00 0011 0031 0a0000f0 8000ffff
229
230 # actions=ct(commit,nat(dst=10.0.0.128-10.0.0.254,hash))
231 ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
232 ffff 0018 00002320 0024 00 00 000a 0003 0a000080 0a0000fe
233
234 # actions=ct(commit,nat(src=10.0.0.240-10.0.0.254:32768-65535,persistent))
235 ffff 0038 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
236 ffff 0020 00002320 0024 00 00 0005 0033 0a0000f0 0a0000fe 8000ffff 00000000
237
238 # actions=ct(commit,nat(src=fe80::20c:29ff:fe88:a18b,random))
239 ffff 0038 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
240 ffff 0020 00002320 0024 00 00 0011 0004 fe800000 00000000 020c 29ff fe88 a18b
241
242 # actions=ct(commit,nat(src=fe80::20c:29ff:fe88:1-fe80::20c:29ff:fe88:a18b,random))
243 ffff 0048 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
244 ffff 0030 00002320 0024 00 00 0011 000c fe800000 00000000 020c 29ff fe88 0001 fe800000 00000000 020c 29ff fe88 a18b
245
246 # actions=ct(commit,nat(src=[fe80::20c:29ff:fe88:1]-[fe80::20c:29ff:fe88:a18b]:255-4096,random))
247 ffff 0050 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
248 ffff 0038 00002320 0024 00 00 0011 003c dnl
249 fe800000 00000000 020c 29ff fe88 0001 dnl
250 fe800000 00000000 020c 29ff fe88 a18b dnl
251 00ff1000 00000000
252
253 # actions=ct_clear
254 ffff 0010 00002320 002b 000000000000
255
256 # actions=output(port=1,max_len=100)
257 ffff 0010 00002320 0027 0001 00000064
258
259 # actions=clone(mod_vlan_vid:5,output:10)
260 ffff 0020 00002320 002a 000000000000 dnl
261 0001 0008 0005 0000 dnl
262 0000 0008 000a 0000
263
264 # actions=group:5
265 ffff 0010 00002320 0028 0000 00000005
266
267 # bad OpenFlow10 actions: NXBRC_MUST_BE_ZERO
268 ffff 0018 00002320 0025 0000 0005 0000 1122334455 000005
269
270 # bad OpenFlow10 actions: NXBRC_MUST_BE_ZERO
271 ffff 0018 00002320 0025 0000 0005 5000 1122334455 000000
272
273 # bad OpenFlow10 actions: OFPBAC_BAD_ARGUMENT
274 ffff 0048 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
275 ffff 0030 00002320 0024 00 00 0011 000c fe800000 00000000 020c 29ff fe88 a18b fe800000 00000000 020c 29ff fe88 0001
276
277 ])
278 sed '/^[[#&]]/d' < test-data > input.txt
279 sed -n 's/^# //p; /^$/p' < test-data > expout
280 sed -n 's/^& //p' < test-data > experr
281 AT_CAPTURE_FILE([input.txt])
282 AT_CAPTURE_FILE([expout])
283 AT_CAPTURE_FILE([experr])
284 AT_CHECK(
285 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow10 < input.txt],
286 [0], [expout], [experr])
287 AT_CLEANUP
288
289 AT_SETUP([OpenFlow 1.0 "instruction" translations])
290 AT_KEYWORDS([ofp-actions OF1.0 instruction])
291 AT_DATA([test-data], [dnl
292 dnl Try a couple of ordinary actions to make sure they're accepted,
293 dnl but there's no point in retrying all the actions from the previous test.
294 # actions=LOCAL
295 0000 0008 fffe 04d2
296
297 # actions=mod_dl_src:00:11:22:33:44:55
298 0004 0010 001122334455 000000000000
299
300 dnl Now check that write_metadata is accepted.
301 # actions=write_metadata:0xfedcba9876543210
302 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
303
304 # actions=write_metadata:0xfedcba9876543210/0xffff0000ffff0000
305 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffff0000ffff0000
306
307 ])
308 sed '/^[[#&]]/d' < test-data > input.txt
309 sed -n 's/^# //p; /^$/p' < test-data > expout
310 sed -n 's/^& //p' < test-data > experr
311 AT_CAPTURE_FILE([input.txt])
312 AT_CAPTURE_FILE([expout])
313 AT_CAPTURE_FILE([experr])
314 AT_CHECK(
315 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-instructions OpenFlow10 < input.txt],
316 [0], [expout], [experr])
317 AT_CLEANUP
318
319 AT_SETUP([OpenFlow 1.1 action translation])
320 AT_KEYWORDS([ofp-actions OF1.1])
321 AT_DATA([test-data], [dnl
322 # actions=LOCAL
323 0000 0010 fffffffe 04d2 000000000000
324
325 # actions=CONTROLLER:1234
326 0000 0010 fffffffd 04d2 000000000000
327
328 # actions=set_vlan_vid:9
329 0001 0008 0009 0000
330
331 # actions=set_vlan_pcp:6
332 0002 0008 06 000000
333
334 # actions=mod_dl_src:00:11:22:33:44:55
335 0003 0010 001122334455 000000000000
336
337 # actions=mod_dl_dst:10:20:30:40:50:60
338 0004 0010 102030405060 000000000000
339
340 # actions=mod_nw_src:1.2.3.4
341 0005 0008 01020304
342
343 # actions=mod_nw_dst:192.168.0.1
344 0006 0008 c0a80001
345
346 # actions=mod_nw_tos:48
347 0007 0008 30 000000
348
349 # actions=mod_nw_ecn:2
350 0008 0008 02 000000
351
352 # actions=mod_tp_src:80
353 0009 0008 0050 0000
354
355 # actions=mod_tp_dst:443
356 000a 0008 01bb 0000
357
358 # actions=pop_vlan
359 0012 0008 00000000
360
361 # actions=set_queue:2309737729
362 0015 0008 89abcd01
363
364 dnl 802.1ad isn't supported at the moment
365 dnl # actions=push_vlan:0x88a8
366 dnl 0011 0008 88a8 0000
367 # actions=push_vlan:0x8100
368 0011 0008 8100 0000
369
370 # actions=resubmit:5
371 ffff 0010 00002320 0001 0005 00000000
372
373 # actions=set_tunnel:0x12345678
374 ffff 0010 00002320 0002 0000 12345678
375
376 # actions=pop_queue
377 ffff 0010 00002320 0005 000000000000
378
379 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
380 ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
381
382 # actions=load:0xf009->NXM_OF_VLAN_TCI[]
383 ffff 0018 00002320 0007 000f 00000802 000000000000f009
384
385 # actions=note:11.e9.9a.ad.67.f3
386 ffff 0010 00002320 0008 11e99aad67f3
387
388 # actions=set_tunnel64:0xc426384d49c53d60
389 ffff 0018 00002320 0009 000000000000 c426384d49c53d60
390
391 # actions=set_tunnel64:0x885f3298
392 ffff 0018 00002320 0009 000000000000 00000000885f3298
393
394 dnl Write-Metadata is only allowed in contexts that allow instructions.
395 & ofp_actions|WARN|write_metadata instruction not allowed here
396 # bad OpenFlow11 actions: OFPBIC_UNSUP_INST
397 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
398
399 # actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
400 ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
401
402 # actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
403 ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
404 0004 0008 00000000
405
406 # actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
407 ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
408 0004 0008 00000000
409
410 # actions=resubmit(10,5)
411 ffff 0010 00002320 000e 000a 05 000000
412
413 # actions=resubmit(10,5,ct)
414 ffff 0010 00002320 002c 000a 05 000000
415
416 # actions=output:NXM_NX_REG1[5..10]
417 ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
418
419 # 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[])
420 ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
421 000c 00000802 0000 00000802 0000 dnl
422 0030 00000406 0000 00000206 0000 dnl
423 1010 00000002 0000 dnl
424 00000000
425
426 # actions=exit
427 ffff 0010 00002320 0011 000000000000
428
429 dnl OpenFlow 1.1 OFPAT_DEC_TTL
430 # actions=dec_ttl
431 0018 0008 00000000
432
433 # actions=fin_timeout(idle_timeout=10,hard_timeout=20)
434 ffff 0010 00002320 0013 000a 0014 0000
435
436 # actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
437 ffff 0010 00002320 0014 04d2 162e 02 00
438
439 # actions=dec_ttl(32768,12345,90,765,1024)
440 ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
441
442 # actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
443 ffff 0018 00002320 001d 3039 00005BA0 00008707 0000B26E
444
445 # bad OpenFlow11 actions: OFPBAC_BAD_OUT_PORT
446 & ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_OUT_PORT):
447 & 00000000 00 00 00 10 ff ff ff ff-00 00 00 00 00 00 00 00
448 0000 0010 ffffffff 0000 000000000000
449
450 ])
451 sed '/^[[#&]]/d' < test-data > input.txt
452 sed -n 's/^# //p; /^$/p' < test-data > expout
453 sed -n 's/^& //p' < test-data > experr
454 AT_CAPTURE_FILE([input.txt])
455 AT_CAPTURE_FILE([expout])
456 AT_CAPTURE_FILE([experr])
457 AT_CHECK(
458 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow11 < input.txt],
459 [0], [expout], [experr])
460 AT_CLEANUP
461
462 AT_SETUP([OpenFlow 1.1 instruction translation])
463 AT_KEYWORDS([OF1.1 instruction ofp-actions])
464 AT_DATA([test-data], [dnl
465 # actions=LOCAL
466 0004 0018 00000000 dnl
467 0000 0010 fffffffe 04d2 000000000000
468
469 dnl Apply-Actions non-zero padding
470 # actions=drop
471 # 0: 00 -> (none)
472 # 1: 04 -> (none)
473 # 2: 00 -> (none)
474 # 3: 08 -> (none)
475 # 4: 00 -> (none)
476 # 5: 00 -> (none)
477 # 6: 00 -> (none)
478 # 7: 01 -> (none)
479 0004 0008 00000001
480
481 dnl Check that an empty Apply-Actions instruction gets dropped.
482 # actions=drop
483 # 0: 00 -> (none)
484 # 1: 04 -> (none)
485 # 2: 00 -> (none)
486 # 3: 08 -> (none)
487 # 4: 00 -> (none)
488 # 5: 00 -> (none)
489 # 6: 00 -> (none)
490 # 7: 00 -> (none)
491 0004 0008 00000000
492
493 dnl Duplicate instruction type:
494 # bad OpenFlow11 instructions: OFPBIC_DUP_INST
495 0004 0008 00000000 0004 0008 00000000
496
497 dnl Instructions not multiple of 8 in length.
498 & ofp_actions|WARN|OpenFlow message instructions length 9 is not a multiple of 8
499 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
500 0004 0009 01 00000000
501
502 dnl Goto-Table instruction too long.
503 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
504 0001 0010 01 000000 0000000000000000
505
506 dnl Goto-Table 1 instruction non-zero padding
507 # actions=goto_table:1
508 # 7: 01 -> 00
509 0001 0008 01 000001
510
511 dnl Goto-Table 1 instruction go back to the previous table.
512 # bad OpenFlow11 instructions: OFPBIC_BAD_TABLE_ID
513 2,0001 0008 01 000000
514
515 dnl Goto-Table 1
516 # actions=goto_table:1
517 0001 0008 01 000000
518
519 dnl Write-Metadata.
520 # actions=write_metadata:0xfedcba9876543210
521 0002 0018 00000000 fedcba9876543210 ffffffffffffffff
522
523 dnl Write-Metadata as Nicira extension action is transformed into instruction.
524 # actions=write_metadata:0xfedcba9876543210
525 # 1: 04 -> 02
526 # 3: 28 -> 18
527 # 8: ff -> fe
528 # 9: ff -> dc
529 # 10: 00 -> ba
530 # 11: 20 -> 98
531 # 12: 00 -> 76
532 # 13: 00 -> 54
533 # 14: 23 -> 32
534 # 15: 20 -> 10
535 # 16: 00 -> ff
536 # 17: 16 -> ff
537 # 18: 00 -> ff
538 # 19: 00 -> ff
539 # 20: 00 -> ff
540 # 21: 00 -> ff
541 # 22: 00 -> ff
542 # 23: 00 -> ff
543 # 24: fe -> (none)
544 # 25: dc -> (none)
545 # 26: ba -> (none)
546 # 27: 98 -> (none)
547 # 28: 76 -> (none)
548 # 29: 54 -> (none)
549 # 30: 32 -> (none)
550 # 31: 10 -> (none)
551 # 32: ff -> (none)
552 # 33: ff -> (none)
553 # 34: ff -> (none)
554 # 35: ff -> (none)
555 # 36: ff -> (none)
556 # 37: ff -> (none)
557 # 38: ff -> (none)
558 # 39: ff -> (none)
559 0004 0028 00000000 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
560
561 dnl Write-Metadata with mask.
562 # actions=write_metadata:0xfedcba9876543210/0xff00ff00ff00ff00
563 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
564
565 dnl Write-Metadata too short.
566 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
567 0002 0010 00000000 fedcba9876543210
568
569 dnl Write-Metadata too long.
570 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
571 0002 0020 00000000 fedcba9876543210 ffffffffffffffff 0000000000000000
572
573 dnl Write-Metadata duplicated.
574 # bad OpenFlow11 instructions: OFPBIC_DUP_INST
575 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
576
577 dnl Write-Metadata in wrong position (OpenFlow 1.1+ disregards the order
578 dnl and OVS reorders it to the canonical order)
579 # actions=write_metadata:0xfedcba9876543210,goto_table:1
580 # 1: 01 -> 02
581 # 3: 08 -> 18
582 # 4: 01 -> 00
583 # 8: 00 -> fe
584 # 9: 02 -> dc
585 # 10: 00 -> ba
586 # 11: 18 -> 98
587 # 12: 00 -> 76
588 # 13: 00 -> 54
589 # 14: 00 -> 32
590 # 15: 00 -> 10
591 # 16: fe -> ff
592 # 17: dc -> ff
593 # 18: ba -> ff
594 # 19: 98 -> ff
595 # 20: 76 -> ff
596 # 21: 54 -> ff
597 # 22: 32 -> ff
598 # 23: 10 -> ff
599 # 24: ff -> 00
600 # 25: ff -> 01
601 # 26: ff -> 00
602 # 27: ff -> 08
603 # 28: ff -> 01
604 # 29: ff -> 00
605 # 30: ff -> 00
606 # 31: ff -> 00
607 0001 0008 01 000000 0002 0018 00000000 fedcba9876543210 ffffffffffffffff
608
609 dnl empty Write-Actions non-zero padding
610 # actions=write_actions(drop)
611 # 0: 00 -> (none)
612 # 1: 03 -> (none)
613 # 2: 00 -> (none)
614 # 3: 08 -> (none)
615 # 4: 00 -> (none)
616 # 5: 00 -> (none)
617 # 6: 00 -> (none)
618 # 7: 01 -> (none)
619 0003 0008 00000001
620
621 dnl Check that an empty Write-Actions instruction gets dropped.
622 # actions=write_actions(drop)
623 # 0: 00 -> (none)
624 # 1: 03 -> (none)
625 # 2: 00 -> (none)
626 # 3: 08 -> (none)
627 # 4: 00 -> (none)
628 # 5: 00 -> (none)
629 # 6: 00 -> (none)
630 # 7: 00 -> (none)
631 0003 0008 00000000
632
633 dnl Clear-Actions too-long
634 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
635 0005 0010 00000000 0000000000000000
636
637 dnl Clear-Actions non-zero padding
638 # actions=clear_actions
639 # 7: 01 -> 00
640 0005 0008 00000001
641
642 dnl Clear-Actions non-zero padding
643 # actions=clear_actions
644 # 4: 01 -> 00
645 0005 0008 01 000000
646
647 dnl Clear-Actions
648 # actions=clear_actions
649 0005 0008 00000000
650
651 dnl Experimenter actions not supported yet.
652 # bad OpenFlow11 instructions: OFPBIC_BAD_EXPERIMENTER
653 ffff 0008 01 000000
654
655 dnl Bad instruction number (0 not assigned).
656 # bad OpenFlow11 instructions: OFPBIC_UNKNOWN_INST
657 0000 0008 01 000000
658
659 ])
660 sed '/^[[#&]]/d' < test-data > input.txt
661 sed -n 's/^# //p; /^$/p' < test-data > expout
662 sed -n 's/^& //p' < test-data > experr
663 AT_CAPTURE_FILE([input.txt])
664 AT_CAPTURE_FILE([expout])
665 AT_CAPTURE_FILE([experr])
666 AT_CHECK(
667 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-instructions OpenFlow11 < input.txt],
668 [0], [expout], [experr])
669 AT_CLEANUP
670
671 dnl Our primary goal here is to verify OpenFlow 1.2-specific changes,
672 dnl so the list of tests is short.
673 AT_SETUP([OpenFlow 1.2 action translation])
674 AT_KEYWORDS([ofp-actions OF1.2])
675 AT_DATA([test-data], [dnl
676 # actions=LOCAL
677 0000 0010 fffffffe 04d2 000000000000
678
679 # bad OpenFlow12 actions: OFPBAC_BAD_SET_MASK
680 & ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_SET_MASK):
681 & 00000000 00 19 00 18 80 00 09 0c-00 00 00 00 12 34 00 00
682 & 00000010 00 00 ff ff 00 00 00 00-
683 0019 0018 8000090c 000000001234 00000000ffff 00000000
684
685 ])
686 sed '/^[[#&]]/d' < test-data > input.txt
687 sed -n 's/^# //p; /^$/p' < test-data > expout
688 sed -n 's/^& //p' < test-data > experr
689 AT_CAPTURE_FILE([input.txt])
690 AT_CAPTURE_FILE([expout])
691 AT_CAPTURE_FILE([experr])
692 AT_CHECK(
693 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow12 < input.txt],
694 [0], [expout], [experr])
695 AT_CLEANUP
696
697 dnl Our primary goal here is to verify OpenFlow 1.3-specific changes,
698 dnl so the list of tests is short.
699 AT_SETUP([OpenFlow 1.3 action translation])
700 AT_KEYWORDS([ofp-actions OF1.3])
701 AT_DATA([test-data], [dnl
702 # actions=LOCAL
703 0000 0010 fffffffe 04d2 000000000000
704
705 dnl Check the Nicira extension form of "move".
706 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
707 ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
708
709 dnl Check the ONF extension form of "copy_field".
710 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
711 ffff 0020 4f4e4600 0c80 0000 0010 0000 0000 0000 00000002 00000802 00000000
712
713 ])
714 sed '/^[[#&]]/d' < test-data > input.txt
715 sed -n 's/^# //p; /^$/p' < test-data > expout
716 sed -n 's/^& //p' < test-data > experr
717 AT_CAPTURE_FILE([input.txt])
718 AT_CAPTURE_FILE([expout])
719 AT_CAPTURE_FILE([experr])
720 AT_CHECK(
721 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow13 < input.txt],
722 [0], [expout], [experr])
723 AT_CLEANUP
724
725 dnl Our primary goal here is to verify that OpenFlow 1.5-specific changes,
726 dnl so the list of tests is short.
727 AT_SETUP([OpenFlow 1.5 action translation])
728 AT_KEYWORDS([ofp-actions OF1.5])
729 AT_DATA([test-data], [dnl
730 # actions=LOCAL
731 0000 0010 fffffffe 04d2 000000000000
732
733 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
734 001c 0018 0010 0000 0000 0000 00000002 00000802 00000000
735
736 # actions=set_field:00:00:00:00:12:34/00:00:00:00:ff:ff->eth_src
737 0019 0018 8000090c 000000001234 00000000ffff 00000000
738
739 ])
740 sed '/^[[#&]]/d' < test-data > input.txt
741 sed -n 's/^# //p; /^$/p' < test-data > expout
742 sed -n 's/^& //p' < test-data > experr
743 AT_CAPTURE_FILE([input.txt])
744 AT_CAPTURE_FILE([expout])
745 AT_CAPTURE_FILE([experr])
746 AT_CHECK(
747 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow15 < input.txt],
748 [0], [expout], [experr])
749 AT_CLEANUP
750
751 AT_SETUP([ofp-actions - inconsistent MPLS actions])
752 OVS_VSWITCHD_START
753 dnl OK: Use fin_timeout action on TCP flow
754 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=fin_timeout(idle_timeout=1)'])
755 dnl Bad: Use fin_timeout action on TCP flow that has been converted to MPLS
756 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=push_mpls:0x8847,fin_timeout(idle_timeout=1)'],
757 [1], [], [dnl
758 ovs-ofctl: none of the usable flow formats (OpenFlow10,NXM) is among the allowed flow formats (OpenFlow11)
759 ])
760 OVS_VSWITCHD_STOP
761 AT_CLEANUP
762
763 AT_SETUP([reg_load <-> set_field translation corner case])
764 AT_KEYWORDS([ofp-actions])
765 OVS_VSWITCHD_START
766 dnl In OpenFlow 1.3, set_field always sets all the bits in the field,
767 dnl but when we translate to NXAST_LOAD we need to only set the bits that
768 dnl actually exist (e.g. mpls_label only has 20 bits) otherwise OVS rejects
769 dnl the "load" action as invalid. Check that we do this correctly.
770 AT_CHECK([ovs-ofctl -O OpenFlow13 add-flow br0 mpls,actions=set_field:10-\>mpls_label])
771 AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
772 NXST_FLOW reply:
773 mpls actions=load:0xa->OXM_OF_MPLS_LABEL[[]]
774 ])
775 OVS_VSWITCHD_STOP
776 AT_CLEANUP
777
778 AT_SETUP([enqueue action for OF1.1+])
779 AT_KEYWORDS([ofp-actions])
780 OVS_VSWITCHD_START
781 dnl OpenFlow 1.0 has an "enqueue" action. For OpenFlow 1.1+, we translate
782 dnl it to a series of actions that accomplish the same thing.
783 AT_CHECK([ovs-ofctl -O OpenFlow10 add-flow br0 'actions=enqueue(123,456)'])
784 AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
785 NXST_FLOW reply:
786 actions=enqueue:123:456
787 ])
788 AT_CHECK([ovs-ofctl -O OpenFlow13 dump-flows br0 | ofctl_strip], [0], [dnl
789 OFPST_FLOW reply (OF1.3):
790 reset_counts actions=set_queue:456,output:123,pop_queue
791 ])
792 OVS_VSWITCHD_STOP
793 AT_CLEANUP
794
795 AT_SETUP([mod_nw_ttl action for OF1.0])
796 AT_KEYWORDS([ofp-actions])
797 OVS_VSWITCHD_START
798 dnl OpenFlow 1.1+ have a mod_nw_ttl action. For OpenFlow 1.0, we translate
799 dnl it to an Open vSwitch extension.
800 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 'ip,actions=mod_nw_ttl:123'])
801 AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
802 NXST_FLOW reply:
803 ip actions=load:0x7b->NXM_NX_IP_TTL[[]]
804 ])
805 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
806 OFPST_FLOW reply (OF1.1):
807 ip actions=mod_nw_ttl:123
808 ])
809 OVS_VSWITCHD_STOP
810 AT_CLEANUP
811
812 AT_SETUP([mod_nw_ecn action translation])
813 AT_KEYWORDS([ofp-actions])
814 OVS_VSWITCHD_START
815
816 dnl OpenFlow 1.1, but no other version, has a "mod_nw_ecn" action.
817 dnl Check that we translate it properly for OF1.0 and OF1.2.
818 dnl (OF1.3+ should be the same as OF1.2.)
819 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 'ip,actions=mod_nw_ecn:2'])
820 AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
821 NXST_FLOW reply:
822 ip actions=load:0x2->NXM_NX_IP_ECN[[]]
823 ])
824 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
825 OFPST_FLOW reply (OF1.1):
826 ip actions=mod_nw_ecn:2
827 ])
828 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [dnl
829 OFPST_FLOW reply (OF1.2):
830 ip actions=set_field:2->nw_ecn
831 ])
832
833 dnl Check that OF1.2+ set_field to set ECN is translated into the OF1.1
834 dnl mod_nw_ecn action.
835 dnl
836 dnl We don't do anything equivalent for OF1.0 reg_load because we prefer
837 dnl that anything that comes in as reg_load gets translated back to reg_load
838 dnl on output. Perhaps this is somewhat inconsistent but it's what OVS
839 dnl has done for multiple versions.
840 AT_CHECK([ovs-ofctl del-flows br0])
841 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 'ip,actions=set_field:2->ip_ecn'])
842 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
843 OFPST_FLOW reply (OF1.1):
844 ip actions=mod_nw_ecn:2
845 ])
846
847 dnl Check that OF1.2+ set_field to set ECN is translated for earlier OF
848 dnl versions.
849 AT_CHECK([ovs-ofctl del-flows br0])
850 AT_CHECK([ovs-ofctl -O OpenFlow10 add-flow br0 'ip,actions=set_field:2->ip_ecn'])
851 AT_CHECK([ovs-ofctl del-flows br0])
852 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 'ip,actions=set_field:2->ip_ecn'])
853
854 OVS_VSWITCHD_STOP
855 AT_CLEANUP
856