1 AT_BANNER([OpenFlow actions])
3 AT_SETUP([OpenFlow 1.0 action translation])
4 AT_KEYWORDS([ofp-actions OF1.0])
5 AT_DATA([test-data], [dnl
9 # actions=CONTROLLER:1234
12 # actions=mod_vlan_vid:9
15 # actions=mod_vlan_pcp:6
21 # actions=mod_dl_src:00:11:22:33:44:55
22 0004 0010 001122334455 000000000000
24 # actions=mod_dl_dst:10:20:30:40:50:60
25 0005 0010 102030405060 000000000000
27 # actions=mod_nw_src:1.2.3.4
30 # actions=mod_nw_dst:192.168.0.1
33 # actions=mod_nw_tos:48
36 # actions=mod_tp_src:80
39 # actions=mod_tp_dst:443
42 # actions=enqueue:10:55
43 000b 0010 000a 000000000000 00000037
46 ffff 0010 00002320 0001 0005 00000000
48 # actions=set_tunnel:0x12345678
49 ffff 0010 00002320 0002 0000 12345678
51 # actions=set_queue:2309737729
52 ffff 0010 00002320 0004 0000 89abcd01
55 ffff 0010 00002320 0005 000000000000
57 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
58 ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
60 # actions=load:0xf009->NXM_OF_VLAN_TCI[]
61 ffff 0018 00002320 0007 000f 00000802 000000000000f009
63 # actions=note:11.e9.9a.ad.67.f3
64 ffff 0010 00002320 0008 11e99aad67f3
66 # actions=set_tunnel64:0xc426384d49c53d60
67 ffff 0018 00002320 0009 000000000000 c426384d49c53d60
69 # actions=set_tunnel64:0x885f3298
70 ffff 0018 00002320 0009 000000000000 00000000885f3298
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
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
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
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
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
91 # actions=resubmit(10,5)
92 ffff 0010 00002320 000e 000a 05 000000
94 # actions=resubmit(10,5,ct)
95 ffff 0010 00002320 002c 000a 05 000000
97 # actions=output:NXM_NX_REG1[5..10]
98 ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
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
108 ffff 0010 00002320 0011 000000000000
111 ffff 0010 00002320 0012 000000000000
113 # actions=fin_timeout(idle_timeout=10,hard_timeout=20)
114 ffff 0010 00002320 0013 000a 0014 0000
116 # actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
117 ffff 0010 00002320 0014 04d2 162e 02 00
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
127 # actions=dec_ttl(32768,12345,90,765,1024)
128 ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
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
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
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
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
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
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
155 # bad OpenFlow10 actions: OFPBAC_BAD_OUT_PORT
159 ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0000
162 ffff 0018 00002320 0023 0001 00000000 0000 FF 000000 0000
164 # actions=ct(commit,force)
165 ffff 0018 00002320 0023 0003 00000000 0000 FF 000000 0000
167 # bad OpenFlow10 actions: OFPBAC_BAD_ARGUMENT
168 ffff 0018 00002320 0023 0002 00000000 0000 FF 000000 0000
170 # actions=ct(table=10)
171 ffff 0018 00002320 0023 0000 00000000 0000 0A 000000 0000
173 # actions=ct(zone=10)
174 ffff 0018 00002320 0023 0000 00000000 000A FF 000000 0000
176 # actions=ct(zone=NXM_NX_REG0[0..15])
177 ffff 0018 00002320 0023 0000 00010004 000F FF 000000 0000
179 dnl Can't read 8 bits from register into 16-bit zone.
180 # bad OpenFlow10 actions: OFPBAC_BAD_SET_LEN
181 ffff 0018 00002320 0023 0000 00010004 0007 FF 000000 0000
183 dnl Can't read 32 bits from register into 16-bit zone.
184 # bad OpenFlow10 actions: OFPBAC_BAD_SET_LEN
185 ffff 0018 00002320 0023 0000 00010004 001F FF 000000 0000
187 # actions=ct(commit,exec(load:0xf009->NXM_NX_CT_MARK[]))
188 ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
189 ffff 0018 00002320 0007 001f 0001d604 000000000000f009
191 # actions=ct(commit,force,exec(load:0xf009->NXM_NX_CT_MARK[]))
192 ffff 0030 00002320 0023 0003 00000000 0000 FF 000000 0000 dnl
193 ffff 0018 00002320 0007 001f 0001d604 000000000000f009
195 # actions=ct(commit,exec(load:0->NXM_NX_CT_LABEL[64..127],load:0x1d->NXM_NX_CT_LABEL[0..63]))
196 ffff 0048 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
197 ffff 0018 00002320 0007 103f 0001d810 0000 0000 0000 0000 dnl
198 ffff 0018 00002320 0007 003f 0001d810 0000 0000 0000 001d
200 # bad OpenFlow10 actions: OFPBAC_BAD_SET_ARGUMENT
201 & ofp_actions|WARN|cannot set CT fields outside of ct action
202 ffff 0018 00002320 0007 001f 0001d604 000000000000f009
204 # bad OpenFlow10 actions: OFPBAC_BAD_SET_ARGUMENT
205 & meta_flow|WARN|destination field ct_zone is not writable
206 ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
207 ffff 0018 00002320 0007 000f 0001d504 000000000000f009
209 # bad OpenFlow10 actions: OFPBAC_BAD_ARGUMENT
210 & ofp_actions|WARN|ct action doesn't support nested action ct
211 ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
212 ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0000
214 # bad OpenFlow10 actions: OFPBAC_BAD_ARGUMENT
215 & ofp_actions|WARN|ct action doesn't support nested modification of reg0
216 ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
217 ffff 0018 00002320 0007 001f 00010004 000000000000f009
219 # actions=ct(alg=ftp)
220 ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0015
222 # actions=ct(alg=tftp)
223 ffff 0018 00002320 0023 0000 00000000 0000 FF 000000 0045
225 # actions=ct(commit,nat(src))
226 ffff 0028 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
227 ffff 0010 00002320 0024 00 00 0001 0000
229 # actions=ct(commit,nat(dst))
230 ffff 0028 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
231 ffff 0010 00002320 0024 00 00 0002 0000
234 ffff 0028 00002320 0023 0000 00000000 0000 FF 000000 0000 dnl
235 ffff 0010 00002320 0024 00 00 0000 0000
237 # actions=ct(commit,nat(src=10.0.0.240,random))
238 ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
239 ffff 0018 00002320 0024 00 00 0011 0001 0a0000f0 00000000
241 # actions=ct(commit,nat(src=10.0.0.240:32768-65535,random))
242 ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
243 ffff 0018 00002320 0024 00 00 0011 0031 0a0000f0 8000ffff
245 # actions=ct(commit,nat(dst=10.0.0.128-10.0.0.254,hash))
246 ffff 0030 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
247 ffff 0018 00002320 0024 00 00 000a 0003 0a000080 0a0000fe
249 # actions=ct(commit,nat(src=10.0.0.240-10.0.0.254:32768-65535,persistent))
250 ffff 0038 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
251 ffff 0020 00002320 0024 00 00 0005 0033 0a0000f0 0a0000fe 8000ffff 00000000
253 # actions=ct(commit,nat(src=fe80::20c:29ff:fe88:a18b,random))
254 ffff 0038 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
255 ffff 0020 00002320 0024 00 00 0011 0004 fe800000 00000000 020c 29ff fe88 a18b
257 # actions=ct(commit,nat(src=fe80::20c:29ff:fe88:1-fe80::20c:29ff:fe88:a18b,random))
258 ffff 0048 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
259 ffff 0030 00002320 0024 00 00 0011 000c fe800000 00000000 020c 29ff fe88 0001 fe800000 00000000 020c 29ff fe88 a18b
261 # actions=ct(commit,nat(src=[fe80::20c:29ff:fe88:1]-[fe80::20c:29ff:fe88:a18b]:255-4096,random))
262 ffff 0050 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
263 ffff 0038 00002320 0024 00 00 0011 003c dnl
264 fe800000 00000000 020c 29ff fe88 0001 dnl
265 fe800000 00000000 020c 29ff fe88 a18b dnl
269 ffff 0010 00002320 002b 000000000000
271 # actions=output(port=1,max_len=100)
272 ffff 0010 00002320 0027 0001 00000064
274 # actions=clone(mod_vlan_vid:5,output:10)
275 ffff 0020 00002320 002a 000000000000 dnl
276 0001 0008 0005 0000 dnl
279 # actions=learn(table=2,priority=0,NXM_OF_VLAN_TCI[0..11],NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],output:NXM_OF_IN_PORT[])
280 ffff 0050 00002320 002d 0000 0000 0000 0000000000000000 0000 02 00 0000 0000 00000000 0000 0000 dnl
281 000c 00000802 0000 00000802 0000 dnl
282 0030 00000406 0000 00000206 0000 dnl
283 1010 00000002 0000 dnl
286 # actions=learn(table=2,idle_timeout=10,hard_timeout=20,fin_idle_timeout=2,fin_hard_timeout=4,priority=80,cookie=0x123456789abcdef0,limit=1,NXM_OF_VLAN_TCI[0..11],NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],output:NXM_OF_IN_PORT[])
287 ffff 0050 00002320 002d 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 00000001 0000 0000 dnl
288 000c 00000802 0000 00000802 0000 dnl
289 0030 00000406 0000 00000206 0000 dnl
290 1010 00000002 0000 dnl
293 # actions=learn(table=2,idle_timeout=10,hard_timeout=20,fin_idle_timeout=2,fin_hard_timeout=4,priority=80,cookie=0x123456789abcdef0,limit=1,result_dst=NXM_NX_REG0[8],NXM_OF_VLAN_TCI[0..11],NXM_OF_ETH_DST[]=NXM_OF_ETH_SRC[],output:NXM_OF_IN_PORT[])
294 ffff 0050 00002320 002d 000a 0014 0050 123456789abcdef0 0004 02 00 0002 0004 00000001 0008 0000 dnl
296 000c 00000802 0000 00000802 0000 dnl
297 0030 00000406 0000 00000206 0000 dnl
301 ffff 0010 00002320 0028 0000 00000005
303 # bad OpenFlow10 actions: NXBRC_MUST_BE_ZERO
304 ffff 0018 00002320 0025 0000 0005 0000 1122334455 000005
306 # bad OpenFlow10 actions: NXBRC_MUST_BE_ZERO
307 ffff 0018 00002320 0025 0000 0005 5000 1122334455 000000
309 # bad OpenFlow10 actions: OFPBAC_BAD_ARGUMENT
310 ffff 0048 00002320 0023 0001 00000000 0000 FF 000000 0000 dnl
311 ffff 0030 00002320 0024 00 00 0011 000c fe800000 00000000 020c 29ff fe88 a18b fe800000 00000000 020c 29ff fe88 0001
314 sed '/^[[#&]]/d' < test-data > input.txt
315 sed -n 's/^# //p; /^$/p' < test-data > expout
316 sed -n 's/^& //p' < test-data > experr
317 AT_CAPTURE_FILE([input.txt])
318 AT_CAPTURE_FILE([expout])
319 AT_CAPTURE_FILE([experr])
321 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow10 < input.txt],
322 [0], [expout], [experr])
325 AT_SETUP([OpenFlow 1.0 "instruction" translations])
326 AT_KEYWORDS([ofp-actions OF1.0 instruction])
327 AT_DATA([test-data], [dnl
328 dnl Try a couple of ordinary actions to make sure they're accepted,
329 dnl but there's no point in retrying all the actions from the previous test.
333 # actions=mod_dl_src:00:11:22:33:44:55
334 0004 0010 001122334455 000000000000
336 dnl Now check that write_metadata is accepted.
337 # actions=write_metadata:0xfedcba9876543210
338 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
340 # actions=write_metadata:0xfedcba9876543210/0xffff0000ffff0000
341 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffff0000ffff0000
344 sed '/^[[#&]]/d' < test-data > input.txt
345 sed -n 's/^# //p; /^$/p' < test-data > expout
346 sed -n 's/^& //p' < test-data > experr
347 AT_CAPTURE_FILE([input.txt])
348 AT_CAPTURE_FILE([expout])
349 AT_CAPTURE_FILE([experr])
351 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-instructions OpenFlow10 < input.txt],
352 [0], [expout], [experr])
355 AT_SETUP([OpenFlow 1.1 action translation])
356 AT_KEYWORDS([ofp-actions OF1.1])
357 AT_DATA([test-data], [dnl
359 0000 0010 fffffffe 04d2 000000000000
361 # actions=CONTROLLER:1234
362 0000 0010 fffffffd 04d2 000000000000
364 # actions=set_vlan_vid:9
367 # actions=set_vlan_pcp:6
370 # actions=mod_dl_src:00:11:22:33:44:55
371 0003 0010 001122334455 000000000000
373 # actions=mod_dl_dst:10:20:30:40:50:60
374 0004 0010 102030405060 000000000000
376 # actions=mod_nw_src:1.2.3.4
379 # actions=mod_nw_dst:192.168.0.1
382 # actions=mod_nw_tos:48
385 # actions=mod_nw_ecn:2
388 # actions=mod_tp_src:80
391 # actions=mod_tp_dst:443
397 # actions=set_queue:2309737729
400 dnl 802.1ad isn't supported at the moment
401 dnl # actions=push_vlan:0x88a8
402 dnl 0011 0008 88a8 0000
403 # actions=push_vlan:0x8100
407 ffff 0010 00002320 0001 0005 00000000
409 # actions=set_tunnel:0x12345678
410 ffff 0010 00002320 0002 0000 12345678
413 ffff 0010 00002320 0005 000000000000
415 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
416 ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
418 # actions=load:0xf009->NXM_OF_VLAN_TCI[]
419 ffff 0018 00002320 0007 000f 00000802 000000000000f009
421 # actions=note:11.e9.9a.ad.67.f3
422 ffff 0010 00002320 0008 11e99aad67f3
424 # actions=set_tunnel64:0xc426384d49c53d60
425 ffff 0018 00002320 0009 000000000000 c426384d49c53d60
427 # actions=set_tunnel64:0x885f3298
428 ffff 0018 00002320 0009 000000000000 00000000885f3298
430 dnl Write-Metadata is only allowed in contexts that allow instructions.
431 & ofp_actions|WARN|write_metadata instruction not allowed here
432 # bad OpenFlow11 actions: OFPBIC_UNSUP_INST
433 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
435 # actions=multipath(eth_src,50,modulo_n,1,0,NXM_NX_REG0[])
436 ffff 0020 00002320 000a 0000 0032 0000 0000 0000 0000 0000 0000 001f 00010004
438 # actions=bundle(eth_src,0,hrw,ofport,slaves:4,8)
439 ffff 0028 00002320 000c 0001 0000 0000 00000002 0002 0000 00000000 00000000 dnl
442 # actions=bundle_load(eth_src,0,hrw,ofport,NXM_NX_REG0[],slaves:4,8)
443 ffff 0028 00002320 000d 0001 0000 0000 00000002 0002 001f 00010004 00000000 dnl
446 # actions=resubmit(10,5)
447 ffff 0010 00002320 000e 000a 05 000000
449 # actions=resubmit(10,5,ct)
450 ffff 0010 00002320 002c 000a 05 000000
452 # actions=output:NXM_NX_REG1[5..10]
453 ffff 0018 00002320 000f 0145 00010204 ffff 000000000000
455 # 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[])
456 ffff 0048 00002320 0010 000a 0014 0050 123456789abcdef0 0000 02 00 0002 0004 dnl
457 000c 00000802 0000 00000802 0000 dnl
458 0030 00000406 0000 00000206 0000 dnl
459 1010 00000002 0000 dnl
463 ffff 0010 00002320 0011 000000000000
465 dnl OpenFlow 1.1 OFPAT_DEC_TTL
469 # actions=fin_timeout(idle_timeout=10,hard_timeout=20)
470 ffff 0010 00002320 0013 000a 0014 0000
472 # actions=controller(reason=invalid_ttl,max_len=1234,id=5678)
473 ffff 0010 00002320 0014 04d2 162e 02 00
475 # actions=dec_ttl(32768,12345,90,765,1024)
476 ffff 0020 00002320 0015 000500000000 80003039005A02fd 0400000000000000
478 # actions=sample(probability=12345,collector_set_id=23456,obs_domain_id=34567,obs_point_id=45678)
479 ffff 0018 00002320 001d 3039 00005BA0 00008707 0000B26E
481 # bad OpenFlow11 actions: OFPBAC_BAD_OUT_PORT
482 & ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_OUT_PORT):
483 & 00000000 00 00 00 10 ff ff ff ff-00 00 00 00 00 00 00 00
484 0000 0010 ffffffff 0000 000000000000
487 sed '/^[[#&]]/d' < test-data > input.txt
488 sed -n 's/^# //p; /^$/p' < test-data > expout
489 sed -n 's/^& //p' < test-data > experr
490 AT_CAPTURE_FILE([input.txt])
491 AT_CAPTURE_FILE([expout])
492 AT_CAPTURE_FILE([experr])
494 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow11 < input.txt],
495 [0], [expout], [experr])
498 AT_SETUP([OpenFlow 1.1 instruction translation])
499 AT_KEYWORDS([OF1.1 instruction ofp-actions])
500 AT_DATA([test-data], [dnl
502 0004 0018 00000000 dnl
503 0000 0010 fffffffe 04d2 000000000000
505 dnl Apply-Actions non-zero padding
517 dnl Check that an empty Apply-Actions instruction gets dropped.
529 dnl Duplicate instruction type:
530 # bad OpenFlow11 instructions: OFPBIC_DUP_INST
531 0004 0008 00000000 0004 0008 00000000
533 dnl Instructions not multiple of 8 in length.
534 & ofp_actions|WARN|OpenFlow message instructions length 9 is not a multiple of 8
535 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
536 0004 0009 01 00000000
538 dnl Goto-Table instruction too long.
539 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
540 0001 0010 01 000000 0000000000000000
542 dnl Goto-Table 1 instruction non-zero padding
543 # actions=goto_table:1
547 dnl Goto-Table 1 instruction go back to the previous table.
548 # bad OpenFlow11 instructions: OFPBIC_BAD_TABLE_ID
549 2,0001 0008 01 000000
552 # actions=goto_table:1
556 # actions=write_metadata:0xfedcba9876543210
557 0002 0018 00000000 fedcba9876543210 ffffffffffffffff
559 dnl Write-Metadata as Nicira extension action is transformed into instruction.
560 # actions=write_metadata:0xfedcba9876543210
595 0004 0028 00000000 ffff 0020 00002320 0016 000000000000 fedcba9876543210 ffffffffffffffff
597 dnl Write-Metadata with mask.
598 # actions=write_metadata:0xfedcba9876543210/0xff00ff00ff00ff00
599 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
601 dnl Write-Metadata too short.
602 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
603 0002 0010 00000000 fedcba9876543210
605 dnl Write-Metadata too long.
606 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
607 0002 0020 00000000 fedcba9876543210 ffffffffffffffff 0000000000000000
609 dnl Write-Metadata duplicated.
610 # bad OpenFlow11 instructions: OFPBIC_DUP_INST
611 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00 0002 0018 00000000 fedcba9876543210 ff00ff00ff00ff00
613 dnl Write-Metadata in wrong position (OpenFlow 1.1+ disregards the order
614 dnl and OVS reorders it to the canonical order)
615 # actions=write_metadata:0xfedcba9876543210,goto_table:1
643 0001 0008 01 000000 0002 0018 00000000 fedcba9876543210 ffffffffffffffff
645 dnl empty Write-Actions non-zero padding
646 # actions=write_actions(drop)
657 dnl Check that an empty Write-Actions instruction gets dropped.
658 # actions=write_actions(drop)
669 dnl Clear-Actions too-long
670 # bad OpenFlow11 instructions: OFPBIC_BAD_LEN
671 0005 0010 00000000 0000000000000000
673 dnl Clear-Actions non-zero padding
674 # actions=clear_actions
678 dnl Clear-Actions non-zero padding
679 # actions=clear_actions
684 # actions=clear_actions
687 dnl Experimenter actions not supported yet.
688 # bad OpenFlow11 instructions: OFPBIC_BAD_EXPERIMENTER
691 dnl Bad instruction number (0 not assigned).
692 # bad OpenFlow11 instructions: OFPBIC_UNKNOWN_INST
696 sed '/^[[#&]]/d' < test-data > input.txt
697 sed -n 's/^# //p; /^$/p' < test-data > expout
698 sed -n 's/^& //p' < test-data > experr
699 AT_CAPTURE_FILE([input.txt])
700 AT_CAPTURE_FILE([expout])
701 AT_CAPTURE_FILE([experr])
703 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-instructions OpenFlow11 < input.txt],
704 [0], [expout], [experr])
707 dnl Our primary goal here is to verify OpenFlow 1.2-specific changes,
708 dnl so the list of tests is short.
709 AT_SETUP([OpenFlow 1.2 action translation])
710 AT_KEYWORDS([ofp-actions OF1.2])
711 AT_DATA([test-data], [dnl
713 0000 0010 fffffffe 04d2 000000000000
715 # bad OpenFlow12 actions: OFPBAC_BAD_SET_MASK
716 & ofp_actions|WARN|bad action at offset 0 (OFPBAC_BAD_SET_MASK):
717 & 00000000 00 19 00 18 80 00 09 0c-00 00 00 00 12 34 00 00
718 & 00000010 00 00 ff ff 00 00 00 00-
719 0019 0018 8000090c 000000001234 00000000ffff 00000000
722 sed '/^[[#&]]/d' < test-data > input.txt
723 sed -n 's/^# //p; /^$/p' < test-data > expout
724 sed -n 's/^& //p' < test-data > experr
725 AT_CAPTURE_FILE([input.txt])
726 AT_CAPTURE_FILE([expout])
727 AT_CAPTURE_FILE([experr])
729 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow12 < input.txt],
730 [0], [expout], [experr])
733 dnl Our primary goal here is to verify OpenFlow 1.3-specific changes,
734 dnl so the list of tests is short.
735 AT_SETUP([OpenFlow 1.3 action translation])
736 AT_KEYWORDS([ofp-actions OF1.3])
737 AT_DATA([test-data], [dnl
739 0000 0010 fffffffe 04d2 000000000000
741 dnl Check the Nicira extension form of "move".
742 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
743 ffff 0018 00002320 0006 0010 0000 0000 00000002 00000802
745 dnl Check the ONF extension form of "copy_field".
746 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
747 ffff 0020 4f4e4600 0c80 0000 0010 0000 0000 0000 00000002 00000802 00000000
750 sed '/^[[#&]]/d' < test-data > input.txt
751 sed -n 's/^# //p; /^$/p' < test-data > expout
752 sed -n 's/^& //p' < test-data > experr
753 AT_CAPTURE_FILE([input.txt])
754 AT_CAPTURE_FILE([expout])
755 AT_CAPTURE_FILE([experr])
757 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow13 < input.txt],
758 [0], [expout], [experr])
761 dnl Our primary goal here is to verify that OpenFlow 1.5-specific changes,
762 dnl so the list of tests is short.
763 AT_SETUP([OpenFlow 1.5 action translation])
764 AT_KEYWORDS([ofp-actions OF1.5])
765 AT_DATA([test-data], [dnl
767 0000 0010 fffffffe 04d2 000000000000
769 # actions=move:NXM_OF_IN_PORT[]->NXM_OF_VLAN_TCI[]
770 001c 0018 0010 0000 0000 0000 00000002 00000802 00000000
772 # actions=set_field:00:00:00:00:12:34/00:00:00:00:ff:ff->eth_src
773 0019 0018 8000090c 000000001234 00000000ffff 00000000
776 sed '/^[[#&]]/d' < test-data > input.txt
777 sed -n 's/^# //p; /^$/p' < test-data > expout
778 sed -n 's/^& //p' < test-data > experr
779 AT_CAPTURE_FILE([input.txt])
780 AT_CAPTURE_FILE([expout])
781 AT_CAPTURE_FILE([experr])
783 [ovs-ofctl '-vPATTERN:console:%c|%p|%m' parse-actions OpenFlow15 < input.txt],
784 [0], [expout], [experr])
787 AT_SETUP([ofp-actions - inconsistent MPLS actions])
789 dnl OK: Use fin_timeout action on TCP flow
790 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=fin_timeout(idle_timeout=1)'])
791 dnl Bad: Use fin_timeout action on TCP flow that has been converted to MPLS
792 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=push_mpls:0x8847,fin_timeout(idle_timeout=1)'],
794 ovs-ofctl: none of the usable flow formats (OpenFlow10,NXM) is among the allowed flow formats (OpenFlow11)
799 AT_SETUP([reg_load <-> set_field translation corner case])
800 AT_KEYWORDS([ofp-actions])
802 dnl In OpenFlow 1.3, set_field always sets all the bits in the field,
803 dnl but when we translate to NXAST_LOAD we need to only set the bits that
804 dnl actually exist (e.g. mpls_label only has 20 bits) otherwise OVS rejects
805 dnl the "load" action as invalid. Check that we do this correctly.
806 AT_CHECK([ovs-ofctl -O OpenFlow13 add-flow br0 mpls,actions=set_field:10-\>mpls_label])
807 AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
809 mpls actions=load:0xa->OXM_OF_MPLS_LABEL[[]]
814 AT_SETUP([enqueue action for OF1.1+])
815 AT_KEYWORDS([ofp-actions])
817 dnl OpenFlow 1.0 has an "enqueue" action. For OpenFlow 1.1+, we translate
818 dnl it to a series of actions that accomplish the same thing.
819 AT_CHECK([ovs-ofctl -O OpenFlow10 add-flow br0 'actions=enqueue(123,456)'])
820 AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
822 actions=enqueue:123:456
824 AT_CHECK([ovs-ofctl -O OpenFlow13 dump-flows br0 | ofctl_strip], [0], [dnl
825 OFPST_FLOW reply (OF1.3):
826 reset_counts actions=set_queue:456,output:123,pop_queue
831 AT_SETUP([mod_nw_ttl action for OF1.0])
832 AT_KEYWORDS([ofp-actions])
834 dnl OpenFlow 1.1+ have a mod_nw_ttl action. For OpenFlow 1.0, we translate
835 dnl it to an Open vSwitch extension.
836 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 'ip,actions=mod_nw_ttl:123'])
837 AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
839 ip actions=load:0x7b->NXM_NX_IP_TTL[[]]
841 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
842 OFPST_FLOW reply (OF1.1):
843 ip actions=mod_nw_ttl:123
848 AT_SETUP([mod_nw_ecn action translation])
849 AT_KEYWORDS([ofp-actions])
852 dnl OpenFlow 1.1, but no other version, has a "mod_nw_ecn" action.
853 dnl Check that we translate it properly for OF1.0 and OF1.2.
854 dnl (OF1.3+ should be the same as OF1.2.)
855 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 'ip,actions=mod_nw_ecn:2'])
856 AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
858 ip actions=load:0x2->NXM_NX_IP_ECN[[]]
860 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
861 OFPST_FLOW reply (OF1.1):
862 ip actions=mod_nw_ecn:2
864 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [dnl
865 OFPST_FLOW reply (OF1.2):
866 ip actions=set_field:2->nw_ecn
869 dnl Check that OF1.2+ set_field to set ECN is translated into the OF1.1
870 dnl mod_nw_ecn action.
872 dnl We don't do anything equivalent for OF1.0 reg_load because we prefer
873 dnl that anything that comes in as reg_load gets translated back to reg_load
874 dnl on output. Perhaps this is somewhat inconsistent but it's what OVS
875 dnl has done for multiple versions.
876 AT_CHECK([ovs-ofctl del-flows br0])
877 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 'ip,actions=set_field:2->ip_ecn'])
878 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
879 OFPST_FLOW reply (OF1.1):
880 ip actions=mod_nw_ecn:2
883 dnl Check that OF1.2+ set_field to set ECN is translated for earlier OF
885 AT_CHECK([ovs-ofctl del-flows br0])
886 AT_CHECK([ovs-ofctl -O OpenFlow10 add-flow br0 'ip,actions=set_field:2->ip_ecn'])
887 AT_CHECK([ovs-ofctl del-flows br0])
888 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 'ip,actions=set_field:2->ip_ecn'])