openflow: Support matching and modifying MPLS TTL field.
[cascardo/ovs.git] / tests / ofproto.at
1 AT_BANNER([ofproto])
2
3 AT_SETUP([ofproto - echo request])
4 OVS_VSWITCHD_START
5 AT_CHECK([ovs-ofctl -vwarn probe br0])
6 OVS_VSWITCHD_STOP
7 AT_CLEANUP
8
9 AT_SETUP([ofproto - handling messages with bad version])
10 OVS_VSWITCHD_START
11
12 # Start a monitor running OpenFlow 1.0, then send the switch an OF1.1 features
13 # request
14 AT_CHECK([ovs-ofctl -P standard monitor br0 --detach --no-chdir --pidfile])
15 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
16 AT_CAPTURE_FILE([monitor.log])
17 ovs-appctl -t ovs-ofctl ofctl/send 0205000801234567
18 ovs-appctl -t ovs-ofctl ofctl/barrier
19 ovs-appctl -t ovs-ofctl exit
20
21 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//
22 /ECHO/d' monitor.log], [0], [dnl
23 send: OFPT_FEATURES_REQUEST (OF1.1):
24 OFPT_ERROR (OF1.1): OFPBRC_BAD_VERSION
25 OFPT_FEATURES_REQUEST (OF1.1):
26 OFPT_BARRIER_REPLY:
27 ])
28
29 OVS_VSWITCHD_STOP(["/received OpenFlow version 0x02 != expected 01/d"])
30 AT_CLEANUP
31
32 AT_SETUP([ofproto - feature request, config request])
33 OVS_VSWITCHD_START
34 AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
35 AT_CHECK([strip_xids < stdout], [0], [dnl
36 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
37 n_tables:254, n_buffers:256
38 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
39 actions: output enqueue set_vlan_vid set_vlan_pcp strip_vlan mod_dl_src mod_dl_dst mod_nw_src mod_nw_dst mod_nw_tos mod_tp_src mod_tp_dst
40  LOCAL(br0): addr:aa:55:aa:55:00:00
41      config:     PORT_DOWN
42      state:      LINK_DOWN
43      speed: 0 Mbps now, 0 Mbps max
44 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
45 ])
46 OVS_VSWITCHD_STOP
47 AT_CLEANUP
48
49 AT_SETUP([ofproto - set OpenFlow port number])
50 OVS_VSWITCHD_START(
51        [add-port br0 p1 -- set Interface p1 type=dummy --\
52         add-port br0 p2 -- set Interface p2 type=dummy ofport_request=99])
53 AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
54 AT_CHECK([[sed '
55 s/ (xid=0x[0-9a-fA-F]*)//
56 s/00:0.$/00:0x/' < stdout]],
57       [0], [dnl
58 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
59 n_tables:254, n_buffers:256
60 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
61 actions: output enqueue set_vlan_vid set_vlan_pcp strip_vlan mod_dl_src mod_dl_dst mod_nw_src mod_nw_dst mod_nw_tos mod_tp_src mod_tp_dst
62  1(p1): addr:aa:55:aa:55:00:0x
63      config:     PORT_DOWN
64      state:      LINK_DOWN
65      speed: 0 Mbps now, 0 Mbps max
66  99(p2): addr:aa:55:aa:55:00:0x
67      config:     PORT_DOWN
68      state:      LINK_DOWN
69      speed: 0 Mbps now, 0 Mbps max
70  LOCAL(br0): addr:aa:55:aa:55:00:0x
71      config:     PORT_DOWN
72      state:      LINK_DOWN
73      speed: 0 Mbps now, 0 Mbps max
74 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
75 ])
76
77 OVS_VSWITCHD_STOP
78 AT_CLEANUP
79
80 dnl This is really bare-bones.
81 dnl It at least checks request and reply serialization and deserialization.
82 AT_SETUP([ofproto - port stats - (OpenFlow 1.0)])
83 OVS_VSWITCHD_START
84 AT_CHECK([ovs-ofctl -vwarn dump-ports br0], [0], [stdout])
85 AT_CHECK([strip_xids < stdout], [0], [dnl
86 OFPST_PORT reply: 1 ports
87   port LOCAL: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
88            tx pkts=0, bytes=0, drop=0, errs=0, coll=0
89 ])
90 OVS_VSWITCHD_STOP
91 AT_CLEANUP
92
93 AT_SETUP([ofproto - port stats - (OpenFlow 1.2)])
94 OVS_VSWITCHD_START
95 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn dump-ports br0], [0], [stdout])
96 AT_CHECK([strip_xids < stdout], [0], [dnl
97 OFPST_PORT reply (OF1.2): 1 ports
98   port LOCAL: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
99            tx pkts=0, bytes=0, drop=0, errs=0, coll=0
100 ])
101 OVS_VSWITCHD_STOP
102 AT_CLEANUP
103
104 AT_SETUP([ofproto - port stats - (OpenFlow 1.4)])
105 OVS_VSWITCHD_START
106 AT_CHECK([ovs-ofctl -O OpenFlow14 -vwarn dump-ports br0], [0], [stdout])
107 AT_CHECK([strip_xids < stdout | sed 's/duration=[[0-9.]]*s/duration=?s/'],
108   [0], [dnl
109 OFPST_PORT reply (OF1.4): 1 ports
110   port LOCAL: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
111            tx pkts=0, bytes=0, drop=0, errs=0, coll=0
112            duration=?s
113 ])
114 OVS_VSWITCHD_STOP
115 AT_CLEANUP
116
117 dnl This is really bare-bones.
118 dnl It at least checks request and reply serialization and deserialization.
119 AT_SETUP([ofproto - port-desc stats (OpenFlow 1.0)])
120 OVS_VSWITCHD_START
121 AT_CHECK([ovs-ofctl -vwarn dump-ports-desc br0], [0], [stdout])
122 AT_CHECK([strip_xids < stdout], [0], [dnl
123 OFPST_PORT_DESC reply:
124  LOCAL(br0): addr:aa:55:aa:55:00:00
125      config:     PORT_DOWN
126      state:      LINK_DOWN
127      speed: 0 Mbps now, 0 Mbps max
128 ])
129 OVS_VSWITCHD_STOP
130 AT_CLEANUP
131
132 dnl This is really bare-bones.
133 dnl It at least checks request and reply serialization and deserialization.
134 AT_SETUP([ofproto - port-desc stats (OpenFlow 1.2)])
135 OVS_VSWITCHD_START
136 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn dump-ports-desc br0], [0], [stdout])
137 AT_CHECK([strip_xids < stdout], [0], [dnl
138 OFPST_PORT_DESC reply (OF1.2):
139  LOCAL(br0): addr:aa:55:aa:55:00:00
140      config:     PORT_DOWN
141      state:      LINK_DOWN
142      speed: 0 Mbps now, 0 Mbps max
143 ])
144 OVS_VSWITCHD_STOP
145 AT_CLEANUP
146
147 AT_SETUP([ofproto - port-desc stats (OpenFlow 1.5)])
148 OVS_VSWITCHD_START
149 add_of_ports br0 1 2 3
150 AT_CHECK([ovs-ofctl -F OXM-OpenFlow15 -O OpenFlow15 -vwarn dump-ports-desc br0], [0], [stdout])
151 AT_CHECK([strip_xids < stdout | sed 's/00:0./00:0x/'], [0], [dnl
152 OFPST_PORT_DESC reply (OF1.5):
153  1(p1): addr:aa:55:aa:55:00:0x
154      config:     PORT_DOWN
155      state:      LINK_DOWN
156      speed: 0 Mbps now, 0 Mbps max
157  2(p2): addr:aa:55:aa:55:00:0x
158      config:     PORT_DOWN
159      state:      LINK_DOWN
160      speed: 0 Mbps now, 0 Mbps max
161  3(p3): addr:aa:55:aa:55:00:0x
162      config:     PORT_DOWN
163      state:      LINK_DOWN
164      speed: 0 Mbps now, 0 Mbps max
165  LOCAL(br0): addr:aa:55:aa:55:00:0x
166      config:     PORT_DOWN
167      state:      LINK_DOWN
168      speed: 0 Mbps now, 0 Mbps max
169 ])
170 AT_CHECK([ovs-ofctl -F OXM-OpenFlow15 -O OpenFlow15 -vwarn dump-ports-desc br0 2], [0], [stdout])
171 AT_CHECK([strip_xids < stdout | sed 's/00:0./00:0x/'], [0], [dnl
172 OFPST_PORT_DESC reply (OF1.5):
173  2(p2): addr:aa:55:aa:55:00:0x
174      config:     PORT_DOWN
175      state:      LINK_DOWN
176      speed: 0 Mbps now, 0 Mbps max
177 ])
178 OVS_VSWITCHD_STOP
179 AT_CLEANUP
180
181 dnl CHECK_QUEUE_STATS(label, option, format)
182 m4_define([CHECK_QUEUE_STATS], [
183 AT_SETUP([ofproto - queue stats - (OpenFlow $1)])
184 OVS_VSWITCHD_START
185
186 AT_CHECK([ovs-ofctl -O $2 queue-stats br0 | strip_xids], [0],
187   [OFPST_QUEUE reply$3: 1 queues
188   port LOCAL queue 0: bytes=?, pkts=?, errors=?, duration=?
189 ])
190
191 AT_CHECK([ovs-ofctl -O $2 queue-stats br0 LOCAL | strip_xids], [0],
192   [OFPST_QUEUE reply$3: 1 queues
193   port LOCAL queue 0: bytes=?, pkts=?, errors=?, duration=?
194 ])
195
196 AT_CHECK([ovs-ofctl -O $2 queue-stats br0 LOCAL 0 | strip_xids], [0],
197   [OFPST_QUEUE reply$3: 1 queues
198   port LOCAL queue 0: bytes=?, pkts=?, errors=?, duration=?
199 ])
200
201 AT_CHECK([ovs-ofctl -O $2 queue-stats br0 ANY 0 | strip_xids], [0],
202   [OFPST_QUEUE reply$3: 1 queues
203   port LOCAL queue 0: bytes=?, pkts=?, errors=?, duration=?
204 ])
205
206 AT_CHECK([ovs-ofctl -O $2 queue-stats br0 LOCAL 5 | strip_xids], [0],
207   [OFPT_ERROR$3: OFPQOFC_BAD_QUEUE
208 OFPST_QUEUE request$3: port=LOCAL queue=5
209 ])
210
211 AT_CHECK([ovs-ofctl -O $2 queue-stats br0 ANY 5 | strip_xids], [0],
212   [OFPT_ERROR$3: OFPQOFC_BAD_QUEUE
213 OFPST_QUEUE request$3: port=ANY queue=5
214 ])
215
216 AT_CHECK([ovs-ofctl -O $2 queue-stats br0 10 | strip_xids], [0],
217   [OFPT_ERROR$3: OFPQOFC_BAD_PORT
218 OFPST_QUEUE request$3: port=10 queue=ALL
219 ])
220 OVS_VSWITCHD_STOP
221 AT_CLEANUP
222 ])
223 CHECK_QUEUE_STATS([1.0], [OpenFlow10], [])
224 CHECK_QUEUE_STATS([1.1], [OpenFlow11], [ (OF1.1)])
225 CHECK_QUEUE_STATS([1.2], [OpenFlow12], [ (OF1.2)])
226 CHECK_QUEUE_STATS([1.3], [OpenFlow13], [ (OF1.3)])
227 CHECK_QUEUE_STATS([1.4], [OpenFlow14], [ (OF1.4)])
228
229 dnl This is really bare-bones.
230 dnl It at least checks request and reply serialization and deserialization.
231 AT_SETUP([ofproto - queue configuration - (OpenFlow 1.0)])
232 OVS_VSWITCHD_START
233 add_of_ports br0 1 2
234 AT_CHECK([ovs-ofctl queue-get-config br0 1], [0], [stdout])
235 AT_CHECK([strip_xids < stdout], [0], [dnl
236 OFPT_QUEUE_GET_CONFIG_REPLY: port=1
237 queue 0:
238 ])
239 AT_CHECK([ovs-ofctl queue-get-config br0], [0], [stdout])
240 AT_CHECK([strip_xids < stdout | sort], [0], [dnl
241 OFPT_QUEUE_GET_CONFIG_REPLY: port=1
242 OFPT_QUEUE_GET_CONFIG_REPLY: port=2
243 queue 0:
244 queue 0:
245 ])
246 AT_CHECK([ovs-ofctl queue-get-config br0 10], [0],
247   [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_PORT
248 OFPT_QUEUE_GET_CONFIG_REQUEST (xid=0x2): port=10
249 ])
250 OVS_VSWITCHD_STOP
251 AT_CLEANUP
252
253 AT_SETUP([ofproto - queue configuration - (OpenFlow 1.1)])
254 OVS_VSWITCHD_START
255 add_of_ports br0 1 2
256 AT_CHECK([ovs-ofctl -O OpenFlow11 queue-get-config br0 1], [0], [stdout])
257 AT_CHECK([strip_xids < stdout], [0], [dnl
258 OFPT_QUEUE_GET_CONFIG_REPLY (OF1.1): port=1
259 queue 0:
260 ])
261 AT_CHECK([ovs-ofctl -O OpenFlow11 queue-get-config br0 10 | strip_xids], [0],
262   [OFPT_ERROR (OF1.1): OFPQOFC_BAD_PORT
263 OFPT_QUEUE_GET_CONFIG_REQUEST (OF1.1): port=10
264 ])
265 OVS_VSWITCHD_STOP
266 AT_CLEANUP
267
268 AT_SETUP([ofproto - queue configuration - (OpenFlow 1.2)])
269 OVS_VSWITCHD_START
270 add_of_ports br0 1 2
271 AT_CHECK([ovs-ofctl -O OpenFlow12 queue-get-config br0 1], [0], [stdout])
272 AT_CHECK([strip_xids < stdout], [0], [dnl
273 OFPT_QUEUE_GET_CONFIG_REPLY (OF1.2): port=1
274 queue 0:
275 ])
276 AT_CHECK([ovs-ofctl -O OpenFlow12 queue-get-config br0 ANY], [0], [stdout])
277 AT_CHECK([strip_xids < stdout], [0], [dnl
278 OFPT_QUEUE_GET_CONFIG_REPLY (OF1.2): port=ANY
279 queue 0:
280 queue 0:
281 queue 0:
282 ])
283 AT_CHECK([ovs-ofctl -O OpenFlow12 queue-get-config br0 10 | strip_xids], [0],
284   [OFPT_ERROR (OF1.2): OFPQOFC_BAD_PORT
285 OFPT_QUEUE_GET_CONFIG_REQUEST (OF1.2): port=10
286 ])
287 OVS_VSWITCHD_STOP
288 AT_CLEANUP
289
290 AT_SETUP([ofproto - queue configuration - (OpenFlow 1.4)])
291 OVS_VSWITCHD_START
292 add_of_ports br0 1 2
293
294 AT_CHECK([ovs-ofctl -O OpenFlow14 queue-get-config br0 any | strip_xids], [0],
295   [OFPST_QUEUE_DESC reply (OF1.4): port=1
296 queue 0:
297 port=LOCAL
298 queue 0:
299 port=2
300 queue 0:
301 ])
302
303 AT_CHECK([ovs-ofctl -O OpenFlow14 queue-get-config br0 1 | strip_xids], [0],
304   [OFPST_QUEUE_DESC reply (OF1.4): port=1
305 queue 0:
306 ])
307
308 AT_CHECK([ovs-ofctl -O OpenFlow14 queue-get-config br0 10 | strip_xids], [0],
309   [OFPT_ERROR (OF1.4): OFPQOFC_BAD_PORT
310 OFPST_QUEUE_DESC request (OF1.4): port=10
311 ])
312
313 AT_CHECK([ovs-ofctl -O OpenFlow14 queue-get-config br0 1 2 | strip_xids], [0],
314   [OFPT_ERROR (OF1.4): OFPQOFC_BAD_QUEUE
315 OFPST_QUEUE_DESC request (OF1.4): port=1 queue=2
316 ])
317 OVS_VSWITCHD_STOP
318 AT_CLEANUP
319
320 dnl This is really bare-bones.
321 dnl It at least checks request and reply serialization and deserialization.
322 dnl Actions definition listed in both supported formats (w/ actions=)
323 AT_SETUP([ofproto - no group support (OpenFlow 1.0)])
324 OVS_VSWITCHD_START
325 AT_DATA([groups.txt], [dnl
326 group_id=1234,type=all,bucket=output:10
327 group_id=1235,type=all,bucket=actions=output:10
328 ])
329 AT_DATA([stderr], [dnl
330 ovs-ofctl: none of the usable flow formats (OXM,OpenFlow11) is among the allowed flow formats (OpenFlow10,NXM)
331 ])
332 AT_CHECK([ovs-ofctl -O OpenFlow10 -vwarn add-groups br0 groups.txt], [1], ,[stderr])
333 AT_CHECK([ovs-ofctl -O OpenFlow10 -vwarn mod-group br0 'group_id=1234,type=all,bucket=output:10'], [1], ,[stderr])
334 AT_CHECK([ovs-ofctl -O OpenFlow10 -vwarn del-groups br0], [1], ,[stderr])
335 AT_CHECK([ovs-ofctl -O OpenFlow10 -vwarn dump-groups br0 ], [1], ,[stderr])
336 OVS_VSWITCHD_STOP
337 AT_CLEANUP
338
339 dnl This is really bare-bones.
340 dnl It at least checks request and reply serialization and deserialization.
341 dnl Actions definition listed in both supported formats (w/ actions=)
342 AT_SETUP([ofproto - del group (OpenFlow 1.1)])
343 OVS_VSWITCHD_START
344 AT_DATA([groups.txt], [dnl
345 group_id=1234,type=all,bucket=output:10
346 group_id=1235,type=all,bucket=actions=output:10
347 ])
348 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-groups br0 groups.txt])
349 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0 ], [0], [stdout])
350 AT_CHECK([strip_xids < stdout], [0], [dnl
351 OFPST_GROUP_DESC reply (OF1.1):
352  group_id=1234,type=all,bucket=actions=output:10
353  group_id=1235,type=all,bucket=actions=output:10
354 ])
355 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
356 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
357 AT_CHECK([strip_xids < stdout], [0], [dnl
358 OFPST_GROUP_DESC reply (OF1.1):
359  group_id=1235,type=all,bucket=actions=output:10
360 ])
361 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
362 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
363 AT_CHECK([strip_xids < stdout], [0], [dnl
364 OFPST_GROUP_DESC reply (OF1.1):
365  group_id=1235,type=all,bucket=actions=output:10
366 ])
367 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0], [0])
368 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
369 AT_CHECK([strip_xids < stdout], [0], [dnl
370 OFPST_GROUP_DESC reply (OF1.1):
371 ])
372
373 # Negative test.
374 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=0xfffffff0],
375   [1], [], [ovs-ofctl: invalid group id 4294967280
376 ])
377 OVS_VSWITCHD_STOP
378 AT_CLEANUP
379
380 dnl This is really bare-bones.
381 dnl It at least checks request and reply serialization and deserialization.
382 dnl Actions definition listed in both supported formats (w/ actions=)
383 AT_SETUP([ofproto - add indirect group])
384 OVS_VSWITCHD_START
385 dnl indirect group must have exactly one bucket
386 AT_DATA([stderr], [dnl
387 OFPT_ERROR (OF1.1) (xid=0x2): OFPGMFC_INVALID_GROUP
388 OFPT_GROUP_MOD (OF1.1) (xid=0x2): ***decode error: OFPGMFC_INVALID_GROUP***
389 ])
390 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 'group_id=1234,type=indirect'], [1], , [stderr])
391 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 'group_id=1235,type=indirect,bucket=output:10'])
392 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 'group_id=1236,type=indirect,bucket=output:10,bucket=output:11'], [1], , [stderr])
393 OVS_VSWITCHD_STOP
394 AT_CLEANUP
395
396 dnl This is really bare-bones.
397 dnl It at least checks request and reply serialization and deserialization.
398 dnl Actions definition listed in both supported formats (w/ actions=)
399 AT_SETUP([ofproto - del group (OpenFlow 1.5)])
400 OVS_VSWITCHD_START
401 AT_DATA([groups.txt], [dnl
402 group_id=1233,type=select,selection_method=hash,bucket=output:10,bucket=output:11
403 group_id=1234,type=select,selection_method=hash,fields(eth_dst,ip_dst,tcp_dst),bucket=output:10,bucket=output:11
404 group_id=1235,type=all,bucket=actions=output:12,bucket=bucket_id:0,actions=output:10,bucket=bucket_id:1,actions=output:11
405 ])
406 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn add-groups br0 groups.txt])
407 AT_CHECK([ovs-ofctl -F OXM-OpenFlow15 -O OpenFlow15 -vwarn dump-groups br0 1234], [0], [stdout])
408 AT_CHECK([strip_xids < stdout], [0], [dnl
409 OFPST_GROUP_DESC reply (OF1.5):
410  group_id=1234,type=select,selection_method=hash,fields(eth_dst,ip_dst,tcp_dst),bucket=bucket_id:0,actions=output:10,bucket=bucket_id:1,actions=output:11
411 ])
412 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn del-groups br0 group_id=1234])
413 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
414 AT_CHECK([strip_xids < stdout], [0], [dnl
415 OFPST_GROUP_DESC reply (OF1.5):
416  group_id=1235,type=all,bucket=bucket_id:2,actions=output:12,bucket=bucket_id:0,actions=output:10,bucket=bucket_id:1,actions=output:11
417  group_id=1233,type=select,selection_method=hash,bucket=bucket_id:0,actions=output:10,bucket=bucket_id:1,actions=output:11
418 ])
419 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn del-groups br0 group_id=1234])
420 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
421 AT_CHECK([strip_xids < stdout], [0], [dnl
422 OFPST_GROUP_DESC reply (OF1.5):
423  group_id=1235,type=all,bucket=bucket_id:2,actions=output:12,bucket=bucket_id:0,actions=output:10,bucket=bucket_id:1,actions=output:11
424  group_id=1233,type=select,selection_method=hash,bucket=bucket_id:0,actions=output:10,bucket=bucket_id:1,actions=output:11
425 ])
426 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn del-groups br0], [0])
427 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
428 AT_CHECK([strip_xids < stdout], [0], [dnl
429 OFPST_GROUP_DESC reply (OF1.5):
430 ])
431 OVS_VSWITCHD_STOP
432 AT_CLEANUP
433
434 dnl This is really bare-bones.
435 dnl It at least checks request and reply serialization and deserialization.
436 AT_SETUP([ofproto - del group deletes flows])
437 OVS_VSWITCHD_START
438 AT_DATA([groups.txt], [dnl
439 group_id=1234,type=all,bucket=output:10
440 group_id=1235,type=all,bucket=output:10
441 ])
442 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-groups br0 groups.txt])
443 AT_DATA([flows.txt], [dnl
444 tcp actions=group:1234
445 table=2 udp actions=group:1235
446 ])
447 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flows br0 flows.txt])
448 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
449 [0], [dnl
450  table=2, udp actions=group:1235
451  tcp actions=group:1234
452 OFPST_FLOW reply (OF1.1):
453 ])
454 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
455 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
456 [0], [dnl
457  table=2, udp actions=group:1235
458 OFPST_FLOW reply (OF1.1):
459 ])
460 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
461 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
462 [0], [dnl
463  table=2, udp actions=group:1235
464 OFPST_FLOW reply (OF1.1):
465 ])
466 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0])
467 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
468 [0], [dnl
469 OFPST_FLOW reply (OF1.1):
470 ])
471 OVS_VSWITCHD_STOP
472 AT_CLEANUP
473
474 dnl This is really bare-bones.
475 dnl It at least checks request and reply serialization and deserialization.
476 dnl Actions definition listed in both supported formats (w/ actions=)
477 AT_SETUP([ofproto - insert buckets])
478 OVS_VSWITCHD_START
479 # Add group with no buckets.
480 AT_DATA([groups.txt], [dnl
481 group_id=1234,type=all
482 ])
483 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn add-groups br0 groups.txt])
484 AT_CHECK([ovs-ofctl -F OXM-OpenFlow15 -O OpenFlow15 -vwarn dump-groups br0 1234], [0], [stdout])
485 AT_CHECK([strip_xids < stdout], [0], [dnl
486 OFPST_GROUP_DESC reply (OF1.5):
487  group_id=1234,type=all
488 ])
489
490 # Add two buckets, using "last".
491 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=last,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11])
492 AT_CHECK([ovs-ofctl -F OXM-OpenFlow15 -O OpenFlow15 -vwarn dump-groups br0 1234], [0], [stdout])
493 AT_CHECK([strip_xids < stdout], [0], [dnl
494 OFPST_GROUP_DESC reply (OF1.5):
495  group_id=1234,type=all,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11
496 ])
497
498 # Start over again, then add two buckets using "first".
499 AT_CHECK([ovs-ofctl -O OpenFlow15 --strict del-groups br0 group_id=1234])
500 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn add-group br0 group_id=1234,type=all])
501 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=first,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11])
502 AT_CHECK([ovs-ofctl -F OXM-OpenFlow15 -O OpenFlow15 -vwarn dump-groups br0 1234], [0], [stdout])
503 AT_CHECK([strip_xids < stdout], [0], [dnl
504 OFPST_GROUP_DESC reply (OF1.5):
505  group_id=1234,type=all,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11
506 ])
507
508 # Add two more buckets before the existing ones.
509 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=first,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1])
510 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
511 AT_CHECK([strip_xids < stdout], [0], [dnl
512 OFPST_GROUP_DESC reply (OF1.5):
513  group_id=1234,type=all,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11
514 ])
515
516 # Add another bucket at the end.
517 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=last,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15])
518 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
519 AT_CHECK([strip_xids < stdout], [0], [dnl
520 OFPST_GROUP_DESC reply (OF1.5):
521  group_id=1234,type=all,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15
522 ])
523
524 # Verify that duplicate bucket IDs are rejected.
525 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=last,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15], [1], [], [stderr])
526 AT_CHECK([strip_xids < stderr | sed '/truncated/,$d'], [0], [dnl
527 OFPT_ERROR (OF1.5): OFPGMFC_BUCKET_EXISTS
528 OFPT_GROUP_MOD (OF1.5):
529 ])
530
531
532 # Add another bucket just before bucket 15.
533 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=15])
534 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
535 AT_CHECK([strip_xids < stdout], [0], [dnl
536 OFPST_GROUP_DESC reply (OF1.5):
537  group_id=1234,type=all,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15
538 ])
539
540 # Add two more buckets just before bucket 11,
541 # getting the command from a file.
542 AT_DATA([buckets.txt], [dnl
543 group_id=1234,command_bucket_id=11,bucket=bucket_id:12,actions=output:12,bucket=bucket_id:13,actions=output:13
544 ])
545 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 - < buckets.txt])
546 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
547 AT_CHECK([strip_xids < stdout], [0], [dnl
548 OFPST_GROUP_DESC reply (OF1.5):
549  group_id=1234,type=all,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:12,actions=output:12,bucket=bucket_id:13,actions=output:13,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15
550 ])
551
552 # Add yet two more buckets.
553 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=15,bucket=bucket_id:20,actions=output:20,bucket=bucket_id:21,actions=output:21])
554 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
555 AT_CHECK([strip_xids < stdout], [0], [dnl
556 OFPST_GROUP_DESC reply (OF1.5):
557  group_id=1234,type=all,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:12,actions=output:12,bucket=bucket_id:13,actions=output:13,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15,bucket=bucket_id:20,actions=output:20,bucket=bucket_id:21,actions=output:21
558 ])
559
560 # Negative tests.
561 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=0xffffff01,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1], [1], [],
562   [ovs-ofctl: invalid command bucket id 4294967041
563 ])
564 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=first,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1], [1], [],
565   [ovs-ofctl: insert-bucket needs OpenFlow 1.5 or later ('-O OpenFlow15')
566 ])
567 OVS_VSWITCHD_STOP
568 AT_CLEANUP
569
570 dnl This is really bare-bones.
571 dnl It at least checks request and reply serialization and deserialization.
572 dnl Actions definition listed in both supported formats (w/ actions=)
573 AT_SETUP([ofproto - remove buckets])
574 OVS_VSWITCHD_START
575 AT_DATA([groups.txt], [dnl
576 group_id=1234,type=all,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:12,actions=output:12,bucket=bucket_id:13,actions=output:13,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15,bucket=bucket_id:16,actions=output:16
577 ])
578 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn add-groups br0 groups.txt])
579 AT_CHECK([ovs-ofctl -F OXM-OpenFlow15 -O OpenFlow15 -vwarn dump-groups br0 1234], [0], [stdout])
580 AT_CHECK([strip_xids < stdout], [0], [dnl
581 OFPST_GROUP_DESC reply (OF1.5):
582  group_id=1234,type=all,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:12,actions=output:12,bucket=bucket_id:13,actions=output:13,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15,bucket=bucket_id:16,actions=output:16
583 ])
584 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn remove-buckets br0 group_id=1234,command_bucket_id=first])
585 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
586 AT_CHECK([strip_xids < stdout], [0], [dnl
587 OFPST_GROUP_DESC reply (OF1.5):
588  group_id=1234,type=all,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:12,actions=output:12,bucket=bucket_id:13,actions=output:13,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15,bucket=bucket_id:16,actions=output:16
589 ])
590 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn remove-buckets br0 group_id=1234,command_bucket_id=last])
591 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
592 AT_CHECK([strip_xids < stdout], [0], [dnl
593 OFPST_GROUP_DESC reply (OF1.5):
594  group_id=1234,type=all,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:12,actions=output:12,bucket=bucket_id:13,actions=output:13,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15
595 ])
596 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn remove-buckets br0 group_id=1234,command_bucket_id=13])
597 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
598 AT_CHECK([strip_xids < stdout], [0], [dnl
599 OFPST_GROUP_DESC reply (OF1.5):
600  group_id=1234,type=all,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:12,actions=output:12,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15
601 ])
602 AT_DATA([buckets.txt], [dnl
603 group_id=1234
604 ])
605 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn remove-buckets br0 - < buckets.txt])
606 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
607 AT_CHECK([strip_xids < stdout], [0], [dnl
608 OFPST_GROUP_DESC reply (OF1.5):
609  group_id=1234,type=all
610 ])
611 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn remove-buckets br0 group_id=1234,command_bucket_id=first])
612 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn remove-buckets br0 group_id=1234,command_bucket_id=last])
613 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn remove-buckets br0 group_id=1234,command_bucket_id=all])
614 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn remove-buckets br0 group_id=1234,command_bucket_id=1], [1], [], [stderr])
615 AT_CHECK([ofctl_strip < stderr], [0], [dnl
616 OFPT_ERROR (OF1.5): OFPGMFC_UNKNOWN_BUCKET
617 OFPT_GROUP_MOD (OF1.5):
618  REMOVE_BUCKET command_bucket_id:1,group_id=1234
619 ])
620 # Negative test.
621 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn remove-buckets br0 group_id=1234,command_bucket_id=last], [1], [],
622   [ovs-ofctl: remove-bucket needs OpenFlow 1.5 or later ('-O OpenFlow15')
623 ])
624 OVS_VSWITCHD_STOP
625 AT_CLEANUP
626
627 dnl This is really bare-bones.
628 dnl It at least checks request and reply serialization and deserialization.
629 AT_SETUP([ofproto - flow mod checks group availability])
630 OVS_VSWITCHD_START
631 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 group_id=1234,type=all,bucket=output:10])
632 AT_DATA([flows.txt], [dnl
633 tcp actions=group:1234
634 udp actions=group:1235
635 ])
636 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=group:1234'])
637 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=group:1235'], [1], [], [stderr])
638
639 # The output should look like this:
640 #
641 # 00000000  02 0e 00 98 00 00 00 02-00 00 00 00 00 00 00 00 |................|
642 # 00000010  00 00 00 00 00 00 00 00-ff 00 00 00 00 00 80 00 |................|
643 # 00000020  ff ff ff ff ff ff ff ff-ff ff ff ff 00 00 00 00 |................|
644 # 00000030  00 00 00 58 00 00 00 00-00 00 03 d7 00 00 00 00 |...X............|
645 #
646 # This 'sed' command captures the error message but drops details.
647 AT_CHECK([sed '/truncated/d
648 /^000000.0/d' stderr | strip_xids], [0],
649   [OFPT_ERROR (OF1.1): OFPBAC_BAD_OUT_GROUP
650 OFPT_FLOW_MOD (OF1.1):
651 ])
652 OVS_VSWITCHD_STOP
653 AT_CLEANUP
654
655 dnl This is really bare-bones.
656 dnl It at least checks request and reply serialization and deserialization.
657 AT_SETUP([ofproto - group description])
658 OVS_VSWITCHD_START
659 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 group_id=1234,type=all,bucket=output:10], [0], [stdout])
660 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
661 AT_CHECK([strip_xids < stdout], [0], [dnl
662 OFPST_GROUP_DESC reply (OF1.1):
663  group_id=1234,type=all,bucket=actions=output:10
664 ])
665 OVS_VSWITCHD_STOP
666 AT_CLEANUP
667
668 dnl This is really bare-bones.
669 dnl It at least checks request and reply serialization and deserialization.
670 AT_SETUP([ofproto - group description])
671 OVS_VSWITCHD_START
672 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 group_id=1234,type=all,bucket=output:10])
673 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
674 AT_CHECK([strip_xids < stdout], [0], [dnl
675 OFPST_GROUP_DESC reply (OF1.1):
676  group_id=1234,type=all,bucket=actions=output:10
677 ])
678 OVS_VSWITCHD_STOP
679 AT_CLEANUP
680
681 dnl This is really bare-bones.
682 dnl It at least checks request and reply serialization and deserialization.
683 AT_SETUP([ofproto - group features])
684 OVS_VSWITCHD_START
685 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn dump-group-features br0], [0], [stdout])
686 AT_CHECK([strip_xids < stdout], [0], [dnl
687 OFPST_GROUP_FEATURES reply (OF1.2):
688  Group table:
689     Types:  0xf
690     Capabilities:  0x7
691     all group:
692        max_groups=0xffffff00
693        actions: output group set_field strip_vlan push_vlan mod_nw_ttl dec_ttl set_mpls_ttl dec_mpls_ttl push_mpls pop_mpls set_queue
694     select group:
695        max_groups=0xffffff00
696        actions: output group set_field strip_vlan push_vlan mod_nw_ttl dec_ttl set_mpls_ttl dec_mpls_ttl push_mpls pop_mpls set_queue
697     indirect group:
698        max_groups=0xffffff00
699        actions: output group set_field strip_vlan push_vlan mod_nw_ttl dec_ttl set_mpls_ttl dec_mpls_ttl push_mpls pop_mpls set_queue
700     fast failover group:
701        max_groups=0xffffff00
702        actions: output group set_field strip_vlan push_vlan mod_nw_ttl dec_ttl set_mpls_ttl dec_mpls_ttl push_mpls pop_mpls set_queue
703 ])
704 OVS_VSWITCHD_STOP
705 AT_CLEANUP
706
707 dnl This is really bare-bones.
708 dnl It at least checks request and reply serialization and deserialization.
709 AT_SETUP([ofproto - group stats (OpenFlow 1.1)])
710 OVS_VSWITCHD_START
711 AT_DATA([groups.txt], [dnl
712 group_id=1234,type=all,bucket=output:10
713 group_id=1235,type=all,bucket=output:10
714 ])
715 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-groups br0 groups.txt])
716 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=group:1234'])
717 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-group-stats br0 group_id=1234], [0], [stdout])
718 AT_CHECK([strip_xids < stdout | sort], [0], [dnl
719  group_id=1234,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
720 OFPST_GROUP reply (OF1.1):
721 ])
722 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-group-stats br0], [0], [stdout])
723 AT_CHECK([strip_xids < stdout | sort], [0], [dnl
724  group_id=1234,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
725  group_id=1235,ref_count=0,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
726 OFPST_GROUP reply (OF1.1):
727 ])
728 OVS_VSWITCHD_STOP
729 AT_CLEANUP
730
731 dnl This is really bare-bones.
732 dnl It at least checks request and reply serialization and deserialization.
733 AT_SETUP([ofproto - group stats (OpenFlow 1.3)])
734 OVS_VSWITCHD_START
735 AT_DATA([groups.txt], [dnl
736 group_id=1234,type=all,bucket=output:10
737 group_id=1235,type=all,bucket=output:10
738 ])
739 AT_CHECK([ovs-ofctl -O OpenFlow13 -vwarn add-groups br0 groups.txt])
740 AT_CHECK([ovs-ofctl -O OpenFlow13 -vwarn add-flow br0 'tcp actions=group:1234'])
741 AT_CHECK([ovs-ofctl -O OpenFlow13 -vwarn dump-group-stats br0 group_id=1234], [0], [stdout])
742 AT_CHECK([strip_xids < stdout | sed 's/duration=[[0-9.]]*s/duration=?s/' | sort], [0], [dnl
743  group_id=1234,duration=?s,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
744 OFPST_GROUP reply (OF1.3):
745 ])
746 AT_CHECK([ovs-ofctl -O OpenFlow13 -vwarn dump-group-stats br0], [0], [stdout])
747 AT_CHECK([strip_xids < stdout | sed 's/duration=[[0-9.]]*s/duration=?s/' | sort], [0], [dnl
748  group_id=1234,duration=?s,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
749  group_id=1235,duration=?s,ref_count=0,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
750 OFPST_GROUP reply (OF1.3):
751 ])
752 OVS_VSWITCHD_STOP
753 AT_CLEANUP
754
755 dnl This is really bare-bones.
756 dnl It at least checks request and reply serialization and deserialization.
757 AT_SETUP([ofproto - group stats (OpenFlow 1.5)])
758 OVS_VSWITCHD_START
759 AT_DATA([groups.txt], [dnl
760 group_id=1234,type=all,bucket=output:10
761 group_id=1235,type=all,bucket=output:10
762 ])
763 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn add-groups br0 groups.txt])
764 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn add-flow br0 'tcp actions=group:1234'])
765 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-group-stats br0 group_id=1234], [0], [stdout])
766 AT_CHECK([strip_xids < stdout | sed 's/duration=[[0-9.]]*s/duration=?s/' | sort], [0], [dnl
767  group_id=1234,duration=?s,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
768 OFPST_GROUP reply (OF1.5):
769 ])
770 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-group-stats br0], [0], [stdout])
771 AT_CHECK([strip_xids < stdout | sed 's/duration=[[0-9.]]*s/duration=?s/' | sort], [0], [dnl
772  group_id=1234,duration=?s,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
773  group_id=1235,duration=?s,ref_count=0,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
774 OFPST_GROUP reply (OF1.5):
775 ])
776 OVS_VSWITCHD_STOP
777 AT_CLEANUP
778
779 dnl This found a use-after-free error in bridge destruction in the
780 dnl presence of groups.
781 AT_SETUP([ofproto - group add then bridge delete (OpenFlow 1.3)])
782 OVS_VSWITCHD_START
783 AT_DATA([groups.txt], [dnl
784 group_id=1234,type=all,bucket=output:10
785 group_id=1235,type=all,bucket=output:10
786 ])
787 AT_CHECK([ovs-ofctl -O OpenFlow13 -vwarn add-groups br0 groups.txt])
788 AT_CHECK([ovs-vsctl del-br br0])
789 OVS_VSWITCHD_STOP
790 AT_CLEANUP
791
792 AT_SETUP([ofproto - mod-port (OpenFlow 1.0)])
793 OVS_VSWITCHD_START
794 for command_config_state in \
795     'up 0 0' \
796     'noflood NO_FLOOD 0' \
797     'down PORT_DOWN,NO_FLOOD LINK_DOWN' \
798     'flood PORT_DOWN LINK_DOWN' \
799     'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
800     'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
801     'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
802     'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
803     'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
804     'up NO_RECV 0' \
805     'receive 0 0'
806 do
807     set $command_config_state
808     command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
809     AT_CHECK([ovs-ofctl -vwarn mod-port br0 br0 $command])
810     AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
811     AT_CHECK_UNQUOTED([strip_xids < stdout], [0], [dnl
812 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
813 n_tables:254, n_buffers:256
814 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
815 actions: output enqueue set_vlan_vid set_vlan_pcp strip_vlan mod_dl_src mod_dl_dst mod_nw_src mod_nw_dst mod_nw_tos mod_tp_src mod_tp_dst
816  LOCAL(br0): addr:aa:55:aa:55:00:00
817      config:     $config
818      state:      $state
819      speed: 0 Mbps now, 0 Mbps max
820 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
821 ])
822 done
823 OVS_VSWITCHD_STOP
824 AT_CLEANUP
825
826 AT_SETUP([ofproto - mod-port (OpenFlow 1.2)])
827 OVS_VSWITCHD_START
828 for command_config_state in \
829     'up 0 0' \
830     'down PORT_DOWN LINK_DOWN' \
831     'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
832     'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
833     'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
834     'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
835     'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
836     'up NO_RECV 0' \
837     'receive 0 0'
838 do
839     set $command_config_state
840     command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
841     AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn mod-port br0 br0 $command])
842     AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn show br0], [0], [stdout])
843     AT_CHECK_UNQUOTED([strip_xids < stdout], [0], [dnl
844 OFPT_FEATURES_REPLY (OF1.2): dpid:fedcba9876543210
845 n_tables:254, n_buffers:256
846 capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS QUEUE_STATS
847  LOCAL(br0): addr:aa:55:aa:55:00:00
848      config:     $config
849      state:      $state
850      speed: 0 Mbps now, 0 Mbps max
851 OFPT_GET_CONFIG_REPLY (OF1.2): frags=normal miss_send_len=0
852 ])
853 done
854 OVS_VSWITCHD_STOP
855 AT_CLEANUP
856
857 AT_SETUP([ofproto - mod-port (OpenFlow 1.4)])
858 OVS_VSWITCHD_START
859 for command_config_state in \
860     'up 0 0' \
861     'down PORT_DOWN LINK_DOWN' \
862     'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
863     'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
864     'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
865     'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
866     'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
867     'up NO_RECV 0' \
868     'receive 0 0'
869 do
870     set $command_config_state
871     command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
872     AT_CHECK([ovs-ofctl -O OpenFlow14 -vwarn mod-port br0 br0 $command])
873     AT_CHECK([ovs-ofctl -O OpenFlow14 -vwarn show br0], [0], [stdout])
874     AT_CHECK_UNQUOTED([strip_xids < stdout], [0], [dnl
875 OFPT_FEATURES_REPLY (OF1.4): dpid:fedcba9876543210
876 n_tables:254, n_buffers:256
877 capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS QUEUE_STATS
878 OFPST_PORT_DESC reply (OF1.4):
879  LOCAL(br0): addr:aa:55:aa:55:00:00
880      config:     $config
881      state:      $state
882      speed: 0 Mbps now, 0 Mbps max
883 OFPT_GET_CONFIG_REPLY (OF1.4): frags=normal miss_send_len=0
884 ])
885 done
886 OVS_VSWITCHD_STOP
887 AT_CLEANUP
888
889 AT_SETUP([ofproto - basic flow_mod commands (NXM)])
890 OVS_VSWITCHD_START
891 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
892 ])
893 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl add-flows br0 -])
894 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=2])
895 AT_CHECK([ovs-ofctl -F nxm add-flow br0 table=1,in_port=4,actions=3])
896 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
897  in_port=1 actions=output:2
898  in_port=2 actions=output:1
899  table=1, in_port=4 actions=output:3
900 NXST_FLOW reply:
901 ])
902 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | strip_xids], [0], [dnl
903 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
904 ])
905 AT_CHECK([ovs-ofctl del-flows br0])
906 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
907 ])
908 OVS_VSWITCHD_STOP
909 AT_CLEANUP
910
911 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.0)])
912 OVS_VSWITCHD_START
913 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
914 ])
915 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -F openflow10 add-flows br0 -])
916 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 in_port=1,actions=2])
917 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 table=1,in_port=4,actions=3])
918 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
919  in_port=1 actions=output:2
920  in_port=2 actions=output:1
921  table=1, in_port=4 actions=output:3
922 OFPST_FLOW reply:
923 ])
924 AT_CHECK([ovs-ofctl -F openflow10 dump-aggregate br0 table=0 | strip_xids], [0], [dnl
925 OFPST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
926 ])
927 AT_CHECK([ovs-ofctl -F openflow10 del-flows br0])
928 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
929 ])
930 OVS_VSWITCHD_STOP
931 AT_CLEANUP
932
933 # It's really dumb that check_overlap and reset_counts are considered
934 # part of flow state, but OpenFlow implies that it is, and OFTest and
935 # some users insist on it.
936 AT_SETUP([ofproto - add-flow and flags])
937 OVS_VSWITCHD_START
938 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 check_overlap,in_port=1,actions=drop])
939 # Prior to OF1.3, flow dumps didn't include a "flags" field.
940 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [dnl
941 OFPST_FLOW reply:
942  in_port=1 actions=drop
943 ])
944 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
945 OFPST_FLOW reply (OF1.1):
946  in_port=1 actions=drop
947 ])
948 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [dnl
949 OFPST_FLOW reply (OF1.2):
950  in_port=1 actions=drop
951 ])
952 # OF1.3 makes the flags visible.
953 AT_CHECK([ovs-ofctl -O OpenFlow13 dump-flows br0 | ofctl_strip], [0], [dnl
954 OFPST_FLOW reply (OF1.3):
955  check_overlap reset_counts in_port=1 actions=drop
956 ])
957 AT_CHECK([ovs-ofctl -O OpenFlow14 dump-flows br0 | ofctl_strip], [0], [dnl
958 OFPST_FLOW reply (OF1.4):
959  check_overlap reset_counts in_port=1 actions=drop
960 ])
961 AT_CHECK([ovs-ofctl -O OpenFlow15 dump-flows br0 | ofctl_strip], [0], [dnl
962 OFPST_FLOW reply (OF1.5):
963  check_overlap reset_counts in_port=1 actions=drop
964 ])
965 OVS_VSWITCHD_STOP
966 AT_CLEANUP
967
968 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.1)])
969 OVS_VSWITCHD_START
970 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.1):
971 ])
972 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -O OpenFlow11 add-flows br0 -])
973 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 in_port=1,actions=2])
974 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 table=1,in_port=4,actions=3])
975 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
976  in_port=1 actions=output:2
977  in_port=2 actions=output:1
978  table=1, in_port=4 actions=output:3
979 OFPST_FLOW reply (OF1.1):
980 ])
981 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-aggregate br0 table=0 | strip_xids], [0], [dnl
982 OFPST_AGGREGATE reply (OF1.1): packet_count=0 byte_count=0 flow_count=2
983 ])
984 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0])
985 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.1):
986  table=1, in_port=4 actions=output:3
987 ])
988 OVS_VSWITCHD_STOP
989 AT_CLEANUP
990
991 AT_SETUP([ofproto - flow_mod negative test (OpenFlow 1.1)])
992 OVS_VSWITCHD_START(
993   [set bridge br0 protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13])
994 AT_CHECK([ovs-ofctl add-flow -O OpenFlow11 br0 table=1,action=goto_table:2])
995
996 # The error message here actually comes from ovs-ofctl, not from ovs-vswitchd,
997 # but at least it's the same code in ofpacts_check() that issues the error.
998 AT_CHECK([ovs-ofctl add-flow -O OpenFlow11 br0 table=1,action=goto_table:1],
999   [1], [],
1000   [ovs-ofctl: actions are invalid with specified match (OFPBIC_BAD_TABLE_ID)
1001 ])
1002 OVS_VSWITCHD_STOP
1003 AT_CLEANUP
1004
1005 AT_SETUP([ofproto - set-field flow_mod commands (NXM)])
1006 OVS_VSWITCHD_START
1007 AT_CHECK([ovs-ofctl add-flow br0 ipv6,table=1,in_port=3,actions=drop])
1008 AT_CHECK([ovs-ofctl add-flow br0 ipv6,table=1,in_port=3,actions=set_field:fe80:0123:4567:890a:a6ba:dbff:fefe:59fa-\>ipv6_src])
1009 AT_CHECK([ovs-ofctl add-flow br0 icmp6,icmp_type=136,table=1,in_port=3,actions=set_field:fe80:8675:3097:890a:a6ba:dbff:f00d:59fa-\>nd_target,set_field:cc:dd:ee:ff:00:11-\>nd_tll])
1010 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1011  table=1, icmp6,in_port=3,icmp_type=136 actions=load:0xa6badbfff00d59fa->NXM_NX_ND_TARGET[[0..63]],load:0xfe8086753097890a->NXM_NX_ND_TARGET[[64..127]],load:0xccddeeff0011->NXM_NX_ND_TLL[[]]
1012  table=1, ipv6,in_port=3 actions=load:0xa6badbfffefe59fa->NXM_NX_IPV6_SRC[[0..63]],load:0xfe8001234567890a->NXM_NX_IPV6_SRC[[64..127]]
1013 NXST_FLOW reply:
1014 ])
1015 OVS_VSWITCHD_STOP
1016 AT_CLEANUP
1017
1018 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.2)])
1019 OVS_VSWITCHD_START
1020 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.2):
1021 ])
1022 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -O OpenFlow12 add-flows br0 -])
1023 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=1,actions=2])
1024 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 table=1,in_port=4,actions=3])
1025 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1026  in_port=1 actions=output:2
1027  in_port=2 actions=output:1
1028  table=1, in_port=4 actions=output:3
1029 OFPST_FLOW reply (OF1.2):
1030 ])
1031 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0])
1032 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.2):
1033 ])
1034 OVS_VSWITCHD_STOP
1035 AT_CLEANUP
1036
1037 AT_SETUP([ofproto - set-field flow_mod commands (OF1.2)])
1038 OVS_VSWITCHD_START
1039 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 ipv6,table=1,in_port=3,actions=drop])
1040 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 ipv6,table=1,in_port=3,actions=set_field:fe80:0123:4567:890a:a6ba:dbff:fefe:59fa-\>ipv6_src])
1041 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 icmp6,icmp_type=136,table=1,in_port=3,actions=set_field:fe80:8675:3097:890a:a6ba:dbff:f00d:59fa-\>nd_target,set_field:cc:dd:ee:ff:00:11-\>nd_tll])
1042 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1043  table=1, icmp6,in_port=3,icmp_type=136 actions=set_field:fe80:8675:3097:890a:a6ba:dbff:f00d:59fa->nd_target,set_field:cc:dd:ee:ff:00:11->nd_tll
1044  table=1, ipv6,in_port=3 actions=set_field:fe80:123:4567:890a:a6ba:dbff:fefe:59fa->ipv6_src
1045 OFPST_FLOW reply (OF1.2):
1046 ])
1047 OVS_VSWITCHD_STOP
1048 AT_CLEANUP
1049
1050 AT_SETUP([ofproto - dump flows with cookie])
1051 OVS_VSWITCHD_START
1052 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
1053 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
1054 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
1055 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1056  cookie=0x1, in_port=1 actions=output:1
1057  cookie=0x2, in_port=2 actions=output:1
1058  cookie=0x3, in_port=3 actions=output:1
1059 NXST_FLOW reply:
1060 ])
1061 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | strip_xids], [0], [dnl
1062 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
1063 ])
1064 AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/-1 | ofctl_strip | sort], [0], [dnl
1065  cookie=0x3, in_port=3 actions=output:1
1066 NXST_FLOW reply:
1067 ])
1068 AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/-1 | strip_xids], [0], [dnl
1069 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=1
1070 ])
1071 OVS_VSWITCHD_STOP
1072 AT_CLEANUP
1073
1074 AT_SETUP([ofproto - mod flow with cookie change (OpenFlow 1.0)])
1075 OVS_VSWITCHD_START
1076 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 cookie=0x1,in_port=1,actions=1])
1077 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1078  cookie=0x1, in_port=1 actions=output:1
1079 OFPST_FLOW reply:
1080 ])
1081
1082 AT_CHECK([ovs-ofctl -F openflow10 mod-flows br0 cookie=0x2,in_port=1,actions=1])
1083 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1084  cookie=0x2, in_port=1 actions=output:1
1085 OFPST_FLOW reply:
1086 ])
1087 OVS_VSWITCHD_STOP
1088 AT_CLEANUP
1089
1090 AT_SETUP([ofproto - mod flow with cookie change (NXM)])
1091 OVS_VSWITCHD_START
1092 AT_CHECK([ovs-ofctl -F nxm add-flow br0 cookie=0x1,in_port=1,actions=1])
1093 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
1094  cookie=0x1, in_port=1 actions=output:1
1095 NXST_FLOW reply:
1096 ])
1097
1098 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x2,in_port=1,actions=1])
1099 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
1100  cookie=0x2, in_port=1 actions=output:1
1101 NXST_FLOW reply:
1102 ])
1103 OVS_VSWITCHD_STOP
1104 AT_CLEANUP
1105
1106 AT_SETUP([ofproto - no mod flow with cookie change (OpenFlow 1.1)])
1107 OVS_VSWITCHD_START
1108 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
1109 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1110  cookie=0x1, in_port=1 actions=output:1
1111 OFPST_FLOW reply (OF1.1):
1112 ])
1113 AT_CHECK([ovs-ofctl -O OpenFlow11 mod-flows br0 cookie=0x2,in_port=1,actions=1])
1114 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1115  cookie=0x1, in_port=1 actions=output:1
1116 OFPST_FLOW reply (OF1.1):
1117 ])
1118 OVS_VSWITCHD_STOP
1119 AT_CLEANUP
1120
1121 dnl The OpenFlow 1.2 spec states that the cookie may not be modified
1122 AT_SETUP([ofproto - no mod flow with cookie change (OpenFlow 1.2)])
1123 OVS_VSWITCHD_START
1124 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
1125 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1126  cookie=0x1, in_port=1 actions=output:1
1127 OFPST_FLOW reply (OF1.2):
1128 ])
1129
1130 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 cookie=0x2,in_port=1,actions=1])
1131 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1132  cookie=0x1, in_port=1 actions=output:1
1133 OFPST_FLOW reply (OF1.2):
1134 ])
1135 OVS_VSWITCHD_STOP
1136 AT_CLEANUP
1137
1138 AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.0)])
1139 OVS_VSWITCHD_START
1140 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
1141 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
1142 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
1143 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1144  cookie=0x1, in_port=1 actions=output:1
1145  cookie=0x1, in_port=2 actions=output:1
1146  cookie=0x2, in_port=3 actions=output:1
1147 NXST_FLOW reply:
1148 ])
1149
1150 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x1/0xff,actions=4])
1151 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
1152  cookie=0x1, in_port=1 actions=output:4
1153  cookie=0x1, in_port=2 actions=output:4
1154  cookie=0x2, in_port=3 actions=output:1
1155 NXST_FLOW reply:
1156 ])
1157 OVS_VSWITCHD_STOP
1158 AT_CLEANUP
1159
1160 AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.1)])
1161 OVS_VSWITCHD_START
1162 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
1163 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=2,actions=1])
1164 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x2,in_port=3,actions=1])
1165 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1166  cookie=0x1, in_port=1 actions=output:1
1167  cookie=0x1, in_port=2 actions=output:1
1168  cookie=0x2, in_port=3 actions=output:1
1169 OFPST_FLOW reply (OF1.1):
1170 ])
1171
1172 AT_CHECK([ovs-ofctl -O OpenFlow11 mod-flows br0 cookie=0x1/0xff,actions=4])
1173 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1174  cookie=0x1, in_port=1 actions=output:4
1175  cookie=0x1, in_port=2 actions=output:4
1176  cookie=0x2, in_port=3 actions=output:1
1177 OFPST_FLOW reply (OF1.1):
1178 ])
1179 OVS_VSWITCHD_STOP
1180 AT_CLEANUP
1181
1182 AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.2)])
1183 OVS_VSWITCHD_START
1184 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
1185 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=2,actions=1])
1186 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=3,actions=1])
1187 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1188  cookie=0x1, in_port=1 actions=output:1
1189  cookie=0x1, in_port=2 actions=output:1
1190  cookie=0x2, in_port=3 actions=output:1
1191 OFPST_FLOW reply (OF1.2):
1192 ])
1193
1194 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 cookie=0x1/0xff,actions=4])
1195 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1196  cookie=0x1, in_port=1 actions=output:4
1197  cookie=0x1, in_port=2 actions=output:4
1198  cookie=0x2, in_port=3 actions=output:1
1199 OFPST_FLOW reply (OF1.2):
1200 ])
1201 OVS_VSWITCHD_STOP
1202 AT_CLEANUP
1203
1204 dnl The OpenFlow 1.2 spec states that the cookie may not be modified
1205 AT_SETUP([ofproto - mod flows based on cookie mask with cookie change])
1206 OVS_VSWITCHD_START
1207 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
1208 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
1209 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
1210 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1211  cookie=0x1, in_port=1 actions=output:1
1212  cookie=0x1, in_port=2 actions=output:1
1213  cookie=0x2, in_port=3 actions=output:1
1214 NXST_FLOW reply:
1215 ])
1216
1217 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/-1,cookie=4,actions=4])
1218 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
1219  cookie=0x2, in_port=3 actions=output:1
1220  cookie=0x4, in_port=1 actions=output:4
1221  cookie=0x4, in_port=2 actions=output:4
1222 NXST_FLOW reply:
1223 ])
1224 OVS_VSWITCHD_STOP
1225 AT_CLEANUP
1226
1227 AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - NXM])
1228 OVS_VSWITCHD_START
1229 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 in_port=1,actions=1])
1230 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
1231  in_port=1 actions=output:1
1232 NXST_FLOW reply:
1233 ])
1234 OVS_VSWITCHD_STOP
1235 AT_CLEANUP
1236
1237 AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - OF1.1])
1238 OVS_VSWITCHD_START
1239 AT_CHECK([ovs-ofctl -O openflow11 mod-flows br0 in_port=1,actions=1])
1240 AT_CHECK([ovs-ofctl -O openflow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1241  in_port=1 actions=output:1
1242 OFPST_FLOW reply (OF1.1):
1243 ])
1244 OVS_VSWITCHD_STOP
1245 AT_CLEANUP
1246
1247 AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - OF1.2])
1248 OVS_VSWITCHD_START
1249 AT_CHECK([ovs-ofctl -O openflow12 mod-flows br0 in_port=1,actions=1])
1250 AT_CHECK([ovs-ofctl -O openflow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1251 OFPST_FLOW reply (OF1.2):
1252 ])
1253 OVS_VSWITCHD_STOP
1254 AT_CLEANUP
1255
1256 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - NXM])
1257 OVS_VSWITCHD_START
1258 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/1,in_port=1,actions=1])
1259 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
1260 NXST_FLOW reply:
1261 ])
1262 OVS_VSWITCHD_STOP
1263 AT_CLEANUP
1264
1265 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - OF1.1])
1266 OVS_VSWITCHD_START
1267 AT_CHECK([ovs-ofctl -O openflow11 mod-flows br0 cookie=1/1,in_port=1,actions=1])
1268 AT_CHECK([ovs-ofctl -O openflow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1269 OFPST_FLOW reply (OF1.1):
1270 ])
1271 OVS_VSWITCHD_STOP
1272 AT_CLEANUP
1273
1274 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - OF1.2])
1275 OVS_VSWITCHD_START
1276 AT_CHECK([ovs-ofctl -O openflow12 mod-flows br0 cookie=1/1,in_port=1,actions=1])
1277 AT_CHECK([ovs-ofctl -O openflow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1278 OFPST_FLOW reply (OF1.2):
1279 ])
1280 OVS_VSWITCHD_STOP
1281 AT_CLEANUP
1282
1283 AT_SETUP([ofproto - del flows with cookies])
1284 OVS_VSWITCHD_START
1285 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
1286 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
1287 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
1288 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1289  cookie=0x1, in_port=1 actions=output:1
1290  cookie=0x2, in_port=2 actions=output:1
1291  cookie=0x3, in_port=3 actions=output:1
1292 NXST_FLOW reply:
1293 ])
1294
1295 AT_CHECK([ovs-ofctl del-flows br0])
1296 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1297 NXST_FLOW reply:
1298 ])
1299 OVS_VSWITCHD_STOP
1300 AT_CLEANUP
1301
1302 AT_SETUP([ofproto - del flows based on cookie])
1303 OVS_VSWITCHD_START
1304 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
1305 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
1306 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
1307 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1308  cookie=0x1, in_port=1 actions=output:1
1309  cookie=0x2, in_port=2 actions=output:1
1310  cookie=0x3, in_port=3 actions=output:1
1311 NXST_FLOW reply:
1312 ])
1313
1314 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/-1])
1315 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1316  cookie=0x1, in_port=1 actions=output:1
1317  cookie=0x2, in_port=2 actions=output:1
1318 NXST_FLOW reply:
1319 ])
1320 OVS_VSWITCHD_STOP
1321 AT_CLEANUP
1322
1323 AT_SETUP([ofproto - del flows based on cookie mask])
1324 OVS_VSWITCHD_START
1325 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
1326 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
1327 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
1328 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1329  cookie=0x1, in_port=1 actions=output:1
1330  cookie=0x2, in_port=2 actions=output:1
1331  cookie=0x3, in_port=3 actions=output:1
1332 NXST_FLOW reply:
1333 ])
1334 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/0x1])
1335 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1336  cookie=0x2, in_port=2 actions=output:1
1337 NXST_FLOW reply:
1338 ])
1339 OVS_VSWITCHD_STOP
1340 AT_CLEANUP
1341
1342 AT_SETUP([ofproto - del flows based on table id (NXM)])
1343 OVS_VSWITCHD_START
1344 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
1345 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
1346 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1347  cookie=0x1, in_port=1 actions=output:1
1348  cookie=0x2, table=1, in_port=2 actions=output:1
1349 NXST_FLOW reply:
1350 ])
1351 AT_CHECK([ovs-ofctl del-flows br0 table=0])
1352 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1353  cookie=0x2, table=1, in_port=2 actions=output:1
1354 NXST_FLOW reply:
1355 ])
1356 AT_CHECK([ovs-ofctl del-flows br0 table=1])
1357 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1358 NXST_FLOW reply:
1359 ])
1360 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
1361 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
1362 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1363  cookie=0x1, in_port=1 actions=output:1
1364  cookie=0x2, table=1, in_port=2 actions=output:1
1365 NXST_FLOW reply:
1366 ])
1367 AT_CHECK([ovs-ofctl del-flows br0])
1368 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1369 NXST_FLOW reply:
1370 ])
1371 OVS_VSWITCHD_STOP
1372 AT_CLEANUP
1373
1374 AT_SETUP([ofproto - del flows based on table id (OpenFlow 1.1)])
1375 OVS_VSWITCHD_START
1376 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
1377 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
1378 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1379  cookie=0x1, in_port=1 actions=output:1
1380  cookie=0x2, table=1, in_port=2 actions=output:1
1381 OFPST_FLOW reply (OF1.1):
1382 ])
1383 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 table=0])
1384 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1385  cookie=0x2, table=1, in_port=2 actions=output:1
1386 OFPST_FLOW reply (OF1.1):
1387 ])
1388 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 table=1])
1389 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1390 OFPST_FLOW reply (OF1.1):
1391 ])
1392 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
1393 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
1394 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1395  cookie=0x1, in_port=1 actions=output:1
1396  cookie=0x2, table=1, in_port=2 actions=output:1
1397 OFPST_FLOW reply (OF1.1):
1398 ])
1399 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0])
1400 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
1401 OFPST_FLOW reply (OF1.1):
1402  cookie=0x2, table=1, in_port=2 actions=output:1
1403 ])
1404 OVS_VSWITCHD_STOP
1405 AT_CLEANUP
1406
1407 AT_SETUP([ofproto - del flows based on table id (OpenFlow 1.2)])
1408 OVS_VSWITCHD_START
1409 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
1410 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
1411 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1412  cookie=0x1, in_port=1 actions=output:1
1413  cookie=0x2, table=1, in_port=2 actions=output:1
1414 OFPST_FLOW reply (OF1.2):
1415 ])
1416 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0 table=0])
1417 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1418  cookie=0x2, table=1, in_port=2 actions=output:1
1419 OFPST_FLOW reply (OF1.2):
1420 ])
1421 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0 table=1])
1422 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1423 OFPST_FLOW reply (OF1.2):
1424 ])
1425 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
1426 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
1427 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1428  cookie=0x1, in_port=1 actions=output:1
1429  cookie=0x2, table=1, in_port=2 actions=output:1
1430 OFPST_FLOW reply (OF1.2):
1431 ])
1432 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0])
1433 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1434 OFPST_FLOW reply (OF1.2):
1435 ])
1436 OVS_VSWITCHD_STOP
1437 AT_CLEANUP
1438
1439 AT_SETUP([ofproto - flow_mod with out_port matching (OpenFlow 1.0)])
1440 OVS_VSWITCHD_START
1441 AT_DATA([flows.txt], [dnl
1442  in_port=1 actions=output:2
1443  in_port=2 actions=output:1,output:2,output:3
1444  in_port=3 actions=output:3,output:1,output:2
1445  in_port=4 actions=drop
1446  in_port=5 actions=output:3
1447  in_port=6 actions=output:1
1448 ])
1449 AT_CHECK([ovs-ofctl -F openflow10 add-flows br0 flows.txt])
1450 (cat flows.txt; echo 'OFPST_FLOW reply:') > expout
1451 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0],
1452   [expout])
1453
1454 (grep 'output:2' flows.txt; echo 'OFPST_FLOW reply:') > expout
1455 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 out_port=2 | ofctl_strip | sort], [0], [expout])
1456
1457 AT_CHECK([ovs-ofctl -F openflow10 del-flows br0 out_port=2])
1458 (grep -v 'output:2' flows.txt; echo 'OFPST_FLOW reply:') > expout
1459 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0],
1460   [expout])
1461
1462 AT_CHECK([ovs-ofctl -F openflow10 del-flows br0 out_port=3])
1463 (grep -v 'output:[[23]]' flows.txt; echo 'OFPST_FLOW reply:') > expout
1464 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0],
1465   [expout])
1466
1467 AT_CHECK([ovs-ofctl -F openflow10 del-flows br0 out_port=1])
1468 (grep -v 'output:[[123]]' flows.txt; echo 'OFPST_FLOW reply:') > expout
1469 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0],
1470   [expout])
1471
1472 OVS_VSWITCHD_STOP
1473 AT_CLEANUP
1474
1475 AT_SETUP([ofproto - flow_mod with out_port matching (OpenFlow 1.1)])
1476 OVS_VSWITCHD_START
1477 AT_DATA([flows.txt], [dnl
1478  in_port=1 actions=output:2
1479  in_port=2 actions=output:1,write_actions(output:2,output:3)
1480  in_port=3 actions=output:3,output:1,write_actions(output:2)
1481  in_port=4 actions=drop
1482  in_port=5 actions=write_actions(output:3)
1483  in_port=6 actions=output:1
1484 ])
1485 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flows br0 flows.txt])
1486 (cat flows.txt; echo 'OFPST_FLOW reply (OF1.1):') > expout
1487 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0],
1488   [expout])
1489
1490 (grep 'output:2' flows.txt; echo 'OFPST_FLOW reply (OF1.1):') > expout
1491 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 out_port=2 | ofctl_strip | sort], [0], [expout])
1492
1493 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 out_port=2])
1494 (grep -v 'output:2' flows.txt; echo 'OFPST_FLOW reply (OF1.1):') > expout
1495 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0],
1496   [expout])
1497
1498 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 out_port=3])
1499 (grep -v 'output:[[23]]' flows.txt; echo 'OFPST_FLOW reply (OF1.1):') > expout
1500 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0],
1501   [expout])
1502
1503 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 out_port=1])
1504 (grep -v 'output:[[123]]' flows.txt; echo 'OFPST_FLOW reply (OF1.1):') > expout
1505 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0],
1506   [expout])
1507
1508 OVS_VSWITCHD_STOP
1509 AT_CLEANUP
1510
1511 AT_SETUP([ofproto - flow_mod with out_group matching (OpenFlow 1.1)])
1512 OVS_VSWITCHD_START
1513 AT_DATA([groups.txt], [dnl
1514 group_id=1,type=all,bucket=output:10
1515 group_id=2,type=all,bucket=output:10
1516 group_id=3,type=all,bucket=output:10
1517 ])
1518 AT_CHECK([ovs-ofctl -O OpenFlow11 add-groups br0 groups.txt])
1519 AT_DATA([flows.txt], [dnl
1520  in_port=1 actions=group:2,output:5
1521  in_port=2 actions=group:1,write_actions(group:2,group:3,output:6)
1522  in_port=3 actions=group:3,group:1,write_actions(group:2,output:3)
1523  in_port=4 actions=output:4
1524  in_port=5 actions=write_actions(output:4,group:3)
1525  in_port=6 actions=group:1
1526 ])
1527 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flows br0 flows.txt])
1528 (cat flows.txt; echo 'OFPST_FLOW reply (OF1.1):') > expout
1529 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0],
1530   [expout])
1531
1532 (grep 'output:3' flows.txt | grep 'group:2'; echo 'OFPST_FLOW reply (OF1.1):') > expout
1533 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 out_port=3,out_group=2 | ofctl_strip | sort], [0], [expout])
1534
1535 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 out_group=2])
1536 (grep -v 'group:2' flows.txt; echo 'OFPST_FLOW reply (OF1.1):') > expout
1537 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0],
1538   [expout])
1539
1540 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 out_group=3])
1541 (grep -v 'group:[[23]]' flows.txt; echo 'OFPST_FLOW reply (OF1.1):') > expout
1542 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0],
1543   [expout])
1544
1545 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 out_group=1])
1546 (grep -v 'group:[[123]]' flows.txt; echo 'OFPST_FLOW reply (OF1.1):') > expout
1547 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0],
1548   [expout])
1549
1550 OVS_VSWITCHD_STOP
1551 AT_CLEANUP
1552
1553 AT_SETUP([ofproto - flow table configuration (OpenFlow 1.0)])
1554 OVS_VSWITCHD_START
1555 # Check the default configuration.
1556 head_table() {
1557     printf 'OFPST_TABLE reply (xid=0x2):
1558   table 0 ("%s"):
1559     active=0, lookup=0, matched=0
1560     max_entries=1000000
1561     matching:
1562       in_port: exact match or wildcard
1563       eth_src: exact match or wildcard
1564       eth_dst: exact match or wildcard
1565       eth_type: exact match or wildcard
1566       vlan_vid: exact match or wildcard
1567       vlan_pcp: exact match or wildcard
1568       ip_src: exact match or wildcard
1569       ip_dst: exact match or wildcard
1570       nw_proto: exact match or wildcard
1571       nw_tos: exact match or wildcard
1572       tcp_src: exact match or wildcard
1573       tcp_dst: exact match or wildcard
1574
1575 ' $1
1576 }
1577 ditto() {
1578     for i in `seq $1 $2`; do
1579         printf '  table %d ("table%d"): ditto\n' $i $i
1580     done
1581 }
1582 (head_table classifier; ditto 1 253) > expout
1583 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
1584 # Change the configuration.
1585 AT_CHECK(
1586   [ovs-vsctl \
1587      -- --id=@t0 create Flow_Table name=main \
1588      -- --id=@t1 create Flow_Table flow-limit=1024 \
1589      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
1590    | ${PERL} $srcdir/uuidfilt.pl],
1591   [0], [<0>
1592 <1>
1593 ])
1594 # Check that the configuration was updated.
1595 (head_table main; echo '  table 1 ("table1"):
1596     active=0, lookup=0, matched=0
1597     max_entries=1024
1598     (same matching)
1599
1600   table 2 ("table2"):
1601     active=0, lookup=0, matched=0
1602     max_entries=1000000
1603     (same matching)
1604 '; ditto 3 253) > expout
1605 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
1606 OVS_VSWITCHD_STOP
1607 AT_CLEANUP
1608
1609 dnl In-band and fail-open add "hidden rules" to table 0.  These rules shouldn't
1610 dnl be visible to OpenFlow.  This test checks that "dump-flows" and
1611 dnl "dump-tables" don't make them visible.
1612 AT_SETUP([ofproto - hidden rules not in table stats])
1613 # Use an IP address for a controller that won't actually exist: we
1614 # want to create in-band rules but we do not want to actually connect
1615 # to a controller (because that could mess about with our test).  The
1616 # Class E range 240.0.0.0 - 255.255.255.255 seems like a good choice.
1617 OVS_VSWITCHD_START([set-controller br0 tcp:240.0.0.1:6653])
1618 for i in 1 2 3 4 5; do ovs-appctl time/warp 1000; done
1619
1620 # Check that no hidden flows are visible in OpenFlow.
1621 AT_CHECK([ovs-ofctl dump-flows br0], [0], [NXST_FLOW reply (xid=0x4):
1622 ])
1623
1624 # Check that some hidden flows related to 240.0.0.1 are actually in table 0.
1625 #
1626 # We discard flows that mention table_id because we only want table 0 flows,
1627 # which in OVS is implied by the absence of a table_id.
1628 AT_CHECK([ovs-appctl bridge/dump-flows br0], [0], [stdout])
1629 AT_CHECK([test `grep '240\.0\.0\.1' stdout | grep -v table_id= | wc -l` -gt 0])
1630
1631 # Check that dump-tables doesn't count the hidden flows.
1632 head_table() {
1633     printf 'OFPST_TABLE reply (xid=0x2):
1634   table 0 ("%s"):
1635     active=0, lookup=0, matched=0
1636     max_entries=1000000
1637     matching:
1638       in_port: exact match or wildcard
1639       eth_src: exact match or wildcard
1640       eth_dst: exact match or wildcard
1641       eth_type: exact match or wildcard
1642       vlan_vid: exact match or wildcard
1643       vlan_pcp: exact match or wildcard
1644       ip_src: exact match or wildcard
1645       ip_dst: exact match or wildcard
1646       nw_proto: exact match or wildcard
1647       nw_tos: exact match or wildcard
1648       tcp_src: exact match or wildcard
1649       tcp_dst: exact match or wildcard
1650
1651 ' $1
1652 }
1653 ditto() {
1654     for i in `seq $1 $2`; do
1655         printf '  table %d ("table%d"): ditto\n' $i $i
1656     done
1657 }
1658 (head_table classifier; ditto 1 253) > expout
1659 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
1660 OVS_VSWITCHD_STOP(["/240\.0\.0\.1/d"])
1661 AT_CLEANUP
1662
1663 AT_SETUP([ofproto - flow table configuration (OpenFlow 1.2)])
1664 OVS_VSWITCHD_START
1665 # Check the default configuration.
1666 head_table() {
1667     printf 'OFPST_TABLE reply (OF1.2) (xid=0x2):
1668   table 0 ("%s"):
1669     active=0, lookup=0, matched=0
1670     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1671     config=controller
1672     max_entries=1000000
1673     instructions (table miss and others):
1674       instructions: apply_actions,clear_actions,write_actions,write_metadata,goto_table
1675       Write-Actions and Apply-Actions features:
1676         actions: output group set_field strip_vlan push_vlan mod_nw_ttl dec_ttl set_mpls_ttl dec_mpls_ttl push_mpls pop_mpls set_queue
1677         supported on Set-Field: metadata in_port_oxm eth_src eth_dst vlan_vid vlan_pcp mpls_label mpls_tc ip_src ip_dst ipv6_src ipv6_dst ipv6_label ip_dscp nw_ecn arp_op arp_spa arp_tpa arp_sha arp_tha tcp_src tcp_dst udp_src udp_dst sctp_src sctp_dst icmp_type icmp_code icmpv6_type icmpv6_code nd_target nd_sll nd_tll
1678     matching:
1679       metadata: exact match or wildcard
1680       in_port_oxm: exact match or wildcard
1681       eth_src: exact match or wildcard
1682       eth_dst: exact match or wildcard
1683       eth_type: exact match or wildcard
1684       vlan_vid: exact match or wildcard
1685       vlan_pcp: exact match or wildcard
1686       mpls_label: exact match or wildcard
1687       mpls_tc: exact match or wildcard
1688       ip_src: exact match or wildcard
1689       ip_dst: exact match or wildcard
1690       ipv6_src: exact match or wildcard
1691       ipv6_dst: exact match or wildcard
1692       ipv6_label: exact match or wildcard
1693       nw_proto: exact match or wildcard
1694       ip_dscp: exact match or wildcard
1695       nw_ecn: exact match or wildcard
1696       arp_op: exact match or wildcard
1697       arp_spa: exact match or wildcard
1698       arp_tpa: exact match or wildcard
1699       arp_sha: exact match or wildcard
1700       arp_tha: exact match or wildcard
1701       tcp_src: exact match or wildcard
1702       tcp_dst: exact match or wildcard
1703       udp_src: exact match or wildcard
1704       udp_dst: exact match or wildcard
1705       sctp_src: exact match or wildcard
1706       sctp_dst: exact match or wildcard
1707       icmp_type: exact match or wildcard
1708       icmp_code: exact match or wildcard
1709       icmpv6_type: exact match or wildcard
1710       icmpv6_code: exact match or wildcard
1711       nd_target: exact match or wildcard
1712       nd_sll: exact match or wildcard
1713       nd_tll: exact match or wildcard
1714
1715 ' $1
1716 }
1717 ditto() {
1718     for i in `seq $1 $2`; do
1719         printf '  table %d ("table%d"): ditto\n' $i $i
1720     done
1721 }
1722 tail_table() {
1723     printf '  table 253 ("table253"):
1724     active=0, lookup=0, matched=0
1725     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1726     config=controller
1727     max_entries=1000000
1728     instructions (table miss and others):
1729       instructions: apply_actions,clear_actions,write_actions,write_metadata
1730       (same actions)
1731     (same matching)
1732 '
1733 }
1734 (head_table classifier; ditto 1 252; tail_table) > expout
1735 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
1736 # Change the configuration.
1737 AT_CHECK(
1738   [ovs-vsctl \
1739      -- --id=@t0 create Flow_Table name=main \
1740      -- --id=@t1 create Flow_Table flow-limit=1024 \
1741      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
1742    | ${PERL} $srcdir/uuidfilt.pl],
1743   [0], [<0>
1744 <1>
1745 ])
1746 # Check that the configuration was updated.
1747 (head_table main; echo '  table 1 ("table1"):
1748     active=0, lookup=0, matched=0
1749     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1750     config=controller
1751     max_entries=1024
1752     (same instructions)
1753     (same matching)
1754
1755   table 2 ("table2"):
1756     active=0, lookup=0, matched=0
1757     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1758     config=controller
1759     max_entries=1000000
1760     (same instructions)
1761     (same matching)
1762 '; ditto 3 252; tail_table) > expout
1763 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
1764 OVS_VSWITCHD_STOP
1765 AT_CLEANUP
1766
1767 AT_SETUP([ofproto - table features (OpenFlow 1.3)])
1768 OVS_VSWITCHD_START
1769 head_table () {
1770     printf '  table 0 ("%s"):
1771     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1772     max_entries=1000000
1773     instructions (table miss and others):
1774       next tables: 1-253
1775       instructions: meter,apply_actions,clear_actions,write_actions,write_metadata,goto_table
1776       Write-Actions and Apply-Actions features:
1777         actions: output group set_field strip_vlan push_vlan mod_nw_ttl dec_ttl set_mpls_ttl dec_mpls_ttl push_mpls pop_mpls set_queue
1778         supported on Set-Field: tun_id tun_src tun_dst tun_ipv6_src tun_ipv6_dst tun_flags tun_gbp_id tun_gbp_flags tun_metadata0 dnl
1779 tun_metadata1 tun_metadata2 tun_metadata3 tun_metadata4 tun_metadata5 tun_metadata6 tun_metadata7 tun_metadata8 tun_metadata9 tun_metadata10 tun_metadata11 tun_metadata12 tun_metadata13 tun_metadata14 tun_metadata15 tun_metadata16 tun_metadata17 tun_metadata18 tun_metadata19 tun_metadata20 tun_metadata21 tun_metadata22 tun_metadata23 tun_metadata24 tun_metadata25 tun_metadata26 tun_metadata27 tun_metadata28 tun_metadata29 tun_metadata30 tun_metadata31 tun_metadata32 tun_metadata33 tun_metadata34 tun_metadata35 tun_metadata36 tun_metadata37 tun_metadata38 tun_metadata39 tun_metadata40 tun_metadata41 tun_metadata42 tun_metadata43 tun_metadata44 tun_metadata45 tun_metadata46 tun_metadata47 tun_metadata48 tun_metadata49 tun_metadata50 tun_metadata51 tun_metadata52 tun_metadata53 tun_metadata54 tun_metadata55 tun_metadata56 tun_metadata57 tun_metadata58 tun_metadata59 tun_metadata60 tun_metadata61 tun_metadata62 tun_metadata63 dnl
1780 metadata in_port in_port_oxm pkt_mark ct_mark ct_label reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 xreg0 xreg1 xreg2 xreg3 eth_src eth_dst vlan_tci vlan_vid vlan_pcp mpls_label mpls_tc mpls_ttl ip_src ip_dst ipv6_src ipv6_dst ipv6_label nw_tos ip_dscp nw_ecn nw_ttl arp_op arp_spa arp_tpa arp_sha arp_tha tcp_src tcp_dst udp_src udp_dst sctp_src sctp_dst icmp_type icmp_code icmpv6_type icmpv6_code nd_target nd_sll nd_tll
1781     matching:
1782       dp_hash: arbitrary mask
1783       recirc_id: exact match or wildcard
1784       conj_id: exact match or wildcard
1785       tun_id: arbitrary mask
1786       tun_src: arbitrary mask
1787       tun_dst: arbitrary mask
1788       tun_ipv6_src: arbitrary mask
1789       tun_ipv6_dst: arbitrary mask
1790       tun_flags: arbitrary mask
1791       tun_gbp_id: arbitrary mask
1792       tun_gbp_flags: arbitrary mask
1793       tun_metadata0: arbitrary mask
1794       tun_metadata1: arbitrary mask
1795       tun_metadata2: arbitrary mask
1796       tun_metadata3: arbitrary mask
1797       tun_metadata4: arbitrary mask
1798       tun_metadata5: arbitrary mask
1799       tun_metadata6: arbitrary mask
1800       tun_metadata7: arbitrary mask
1801       tun_metadata8: arbitrary mask
1802       tun_metadata9: arbitrary mask
1803       tun_metadata10: arbitrary mask
1804       tun_metadata11: arbitrary mask
1805       tun_metadata12: arbitrary mask
1806       tun_metadata13: arbitrary mask
1807       tun_metadata14: arbitrary mask
1808       tun_metadata15: arbitrary mask
1809       tun_metadata16: arbitrary mask
1810       tun_metadata17: arbitrary mask
1811       tun_metadata18: arbitrary mask
1812       tun_metadata19: arbitrary mask
1813       tun_metadata20: arbitrary mask
1814       tun_metadata21: arbitrary mask
1815       tun_metadata22: arbitrary mask
1816       tun_metadata23: arbitrary mask
1817       tun_metadata24: arbitrary mask
1818       tun_metadata25: arbitrary mask
1819       tun_metadata26: arbitrary mask
1820       tun_metadata27: arbitrary mask
1821       tun_metadata28: arbitrary mask
1822       tun_metadata29: arbitrary mask
1823       tun_metadata30: arbitrary mask
1824       tun_metadata31: arbitrary mask
1825       tun_metadata32: arbitrary mask
1826       tun_metadata33: arbitrary mask
1827       tun_metadata34: arbitrary mask
1828       tun_metadata35: arbitrary mask
1829       tun_metadata36: arbitrary mask
1830       tun_metadata37: arbitrary mask
1831       tun_metadata38: arbitrary mask
1832       tun_metadata39: arbitrary mask
1833       tun_metadata40: arbitrary mask
1834       tun_metadata41: arbitrary mask
1835       tun_metadata42: arbitrary mask
1836       tun_metadata43: arbitrary mask
1837       tun_metadata44: arbitrary mask
1838       tun_metadata45: arbitrary mask
1839       tun_metadata46: arbitrary mask
1840       tun_metadata47: arbitrary mask
1841       tun_metadata48: arbitrary mask
1842       tun_metadata49: arbitrary mask
1843       tun_metadata50: arbitrary mask
1844       tun_metadata51: arbitrary mask
1845       tun_metadata52: arbitrary mask
1846       tun_metadata53: arbitrary mask
1847       tun_metadata54: arbitrary mask
1848       tun_metadata55: arbitrary mask
1849       tun_metadata56: arbitrary mask
1850       tun_metadata57: arbitrary mask
1851       tun_metadata58: arbitrary mask
1852       tun_metadata59: arbitrary mask
1853       tun_metadata60: arbitrary mask
1854       tun_metadata61: arbitrary mask
1855       tun_metadata62: arbitrary mask
1856       tun_metadata63: arbitrary mask
1857       metadata: arbitrary mask
1858       in_port: exact match or wildcard
1859       in_port_oxm: exact match or wildcard
1860       actset_output: exact match or wildcard
1861       pkt_mark: arbitrary mask
1862       ct_state: arbitrary mask
1863       ct_zone: exact match or wildcard
1864       ct_mark: arbitrary mask
1865       ct_label: arbitrary mask
1866       reg0: arbitrary mask
1867       reg1: arbitrary mask
1868       reg2: arbitrary mask
1869       reg3: arbitrary mask
1870       reg4: arbitrary mask
1871       reg5: arbitrary mask
1872       reg6: arbitrary mask
1873       reg7: arbitrary mask
1874       xreg0: arbitrary mask
1875       xreg1: arbitrary mask
1876       xreg2: arbitrary mask
1877       xreg3: arbitrary mask
1878       eth_src: arbitrary mask
1879       eth_dst: arbitrary mask
1880       eth_type: exact match or wildcard
1881       vlan_tci: arbitrary mask
1882       vlan_vid: arbitrary mask
1883       vlan_pcp: exact match or wildcard
1884       mpls_label: exact match or wildcard
1885       mpls_tc: exact match or wildcard
1886       mpls_bos: exact match or wildcard
1887       mpls_ttl: exact match or wildcard
1888       ip_src: arbitrary mask
1889       ip_dst: arbitrary mask
1890       ipv6_src: arbitrary mask
1891       ipv6_dst: arbitrary mask
1892       ipv6_label: arbitrary mask
1893       nw_proto: exact match or wildcard
1894       nw_tos: exact match or wildcard
1895       ip_dscp: exact match or wildcard
1896       nw_ecn: exact match or wildcard
1897       nw_ttl: exact match or wildcard
1898       ip_frag: arbitrary mask
1899       arp_op: exact match or wildcard
1900       arp_spa: arbitrary mask
1901       arp_tpa: arbitrary mask
1902       arp_sha: arbitrary mask
1903       arp_tha: arbitrary mask
1904       tcp_src: arbitrary mask
1905       tcp_dst: arbitrary mask
1906       tcp_flags: arbitrary mask
1907       udp_src: arbitrary mask
1908       udp_dst: arbitrary mask
1909       sctp_src: arbitrary mask
1910       sctp_dst: arbitrary mask
1911       icmp_type: exact match or wildcard
1912       icmp_code: exact match or wildcard
1913       icmpv6_type: exact match or wildcard
1914       icmpv6_code: exact match or wildcard
1915       nd_target: arbitrary mask
1916       nd_sll: arbitrary mask
1917       nd_tll: arbitrary mask
1918
1919 ' $1
1920 }
1921 ditto() {
1922     printf '  table %d ("%s"):
1923     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1924     max_entries=%d
1925     instructions (table miss and others):
1926       next tables: %d-253
1927       (same instructions)
1928       (same actions)
1929     (same matching)
1930
1931 ' $1 $2 $3 `expr $1 + 1`
1932 }
1933 tail_tables() {
1934 echo '  table 252 ("table252"):
1935     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1936     max_entries=1000000
1937     instructions (table miss and others):
1938       next tables: 253
1939       (same instructions)
1940       (same actions)
1941     (same matching)
1942
1943   table 253 ("table253"):
1944     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1945     max_entries=1000000
1946     instructions (table miss and others):
1947       instructions: meter,apply_actions,clear_actions,write_actions,write_metadata
1948       (same actions)
1949     (same matching)
1950 '
1951 }
1952 (head_table classifier
1953  for i in `seq 1 251`; do
1954      ditto $i table$i 1000000
1955  done
1956  tail_tables) > expout
1957 AT_CHECK([ovs-ofctl -O OpenFlow13 dump-table-features br0], [0], [expout])
1958 # Change the configuration.
1959 AT_CHECK(
1960   [ovs-vsctl \
1961      -- --id=@t0 create Flow_Table name=main \
1962      -- --id=@t1 create Flow_Table flow-limit=1024 \
1963      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
1964    | ${PERL} $srcdir/uuidfilt.pl],
1965   [0], [<0>
1966 <1>
1967 ])
1968 # Check that the configuration was updated.
1969 (head_table main
1970  ditto 1 table1 1024
1971  for i in `seq 2 251`; do
1972      ditto $i table$i 1000000
1973  done
1974  tail_tables) > expout
1975 AT_CHECK([ovs-ofctl -O OpenFlow13 dump-table-features br0], [0], [expout])
1976 OVS_VSWITCHD_STOP
1977 AT_CLEANUP
1978
1979 AT_SETUP([ofproto - table description (OpenFlow 1.4)])
1980 OVS_VSWITCHD_START
1981 (x=0
1982  while test $x -lt 254; do
1983    y=`expr $x + 1`
1984    echo "  table $x:
1985    eviction=off eviction_flags=OTHER|IMPORTANCE|LIFETIME
1986    vacancy=off"
1987    x=$y
1988  done) > expout
1989 AT_CHECK([ovs-ofctl -O OpenFlow14 dump-table-desc br0 | sed '/^$/d
1990 /^OFPST_TABLE_DESC/d'], [0], [expout])
1991
1992 # Change the configuration.
1993 AT_CHECK([ovs-ofctl -O Openflow14 mod-table br0 0 evict])
1994 # Check that the configuration was updated.
1995 mv expout orig-expout
1996 sed -e '2s/eviction=off/eviction=on/' <orig-expout > expout
1997 AT_CHECK([ovs-ofctl -O OpenFlow14 dump-table-desc br0 | sed '/^$/d
1998 /^OFPST_TABLE_DESC/d'], [0], [expout])
1999
2000 AT_CHECK([ovs-ofctl -O Openflow14 mod-table br0 0 vacancy:20,80])
2001 # Check that the configuration was updated.
2002 mv expout orig-expout
2003 sed -e '3s/vacancy=off/vacancy=on vacancy_down=20% vacancy_up=80% vacancy=100%/' <orig-expout > expout
2004 AT_CHECK([ovs-ofctl -O OpenFlow14 dump-table-desc br0 | sed '/^$/d
2005 /^OFPST_TABLE_DESC/d'], [0], [expout])
2006 OVS_VSWITCHD_STOP
2007 AT_CLEANUP
2008
2009 AT_SETUP([ofproto - hard limits on flow table size (OpenFlow 1.0)])
2010 OVS_VSWITCHD_START
2011 # Configure a maximum of 4 flows.
2012 AT_CHECK(
2013   [ovs-vsctl \
2014      -- --id=@t0 create Flow_Table flow-limit=4 \
2015      -- set bridge br0 flow_tables:0=@t0 \
2016    | ${PERL} $srcdir/uuidfilt.pl],
2017   [0], [<0>
2018 ])
2019 # Add 4 flows.
2020 for in_port in 1 2 3 4; do
2021     ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
2022 done
2023 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2024  in_port=1 actions=drop
2025  in_port=2 actions=drop
2026  in_port=3 actions=drop
2027  in_port=4 actions=drop
2028 NXST_FLOW reply:
2029 ])
2030 # Adding another flow will be refused.
2031 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
2032 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2033   [OFPT_ERROR: OFPFMFC_TABLE_FULL
2034 ])
2035 # Also a mod-flow that would add a flow will be refused.
2036 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
2037 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2038   [OFPT_ERROR: OFPFMFC_TABLE_FULL
2039 ])
2040 # Replacing or modifying an existing flow is allowed.
2041 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
2042 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
2043 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2044  in_port=1 actions=drop
2045  in_port=2 actions=drop
2046  in_port=3 actions=output:1
2047  in_port=4 actions=NORMAL
2048 NXST_FLOW reply:
2049 ])
2050 OVS_VSWITCHD_STOP
2051 AT_CLEANUP
2052
2053 AT_SETUP([ofproto - hard limits on flow table size (OpenFlow 1.2)])
2054 OVS_VSWITCHD_START
2055 # Configure a maximum of 4 flows.
2056 AT_CHECK(
2057   [ovs-vsctl \
2058      -- --id=@t0 create Flow_Table flow-limit=4 \
2059      -- set bridge br0 flow_tables:0=@t0 \
2060    | ${PERL} $srcdir/uuidfilt.pl],
2061   [0], [<0>
2062 ])
2063 # Add 4 flows.
2064 for in_port in 1 2 3 4; do
2065     ovs-ofctl -O OpenFlow12 add-flow br0 in_port=$in_port,actions=drop
2066 done
2067 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2068  in_port=1 actions=drop
2069  in_port=2 actions=drop
2070  in_port=3 actions=drop
2071  in_port=4 actions=drop
2072 OFPST_FLOW reply (OF1.2):
2073 ])
2074 # Adding another flow will be refused.
2075 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
2076 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2077   [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
2078 ])
2079 # Replacing or modifying an existing flow is allowed.
2080 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
2081 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
2082 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2083  in_port=1 actions=drop
2084  in_port=2 actions=drop
2085  in_port=3 actions=output:1
2086  in_port=4 actions=NORMAL
2087 OFPST_FLOW reply (OF1.2):
2088 ])
2089 OVS_VSWITCHD_STOP
2090 AT_CLEANUP
2091
2092 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.0)])
2093 OVS_VSWITCHD_START
2094 # Configure a maximum of 4 flows.
2095 AT_CHECK(
2096   [ovs-vsctl \
2097      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
2098      -- set bridge br0 flow_tables:0=@t0 \
2099    | ${PERL} $srcdir/uuidfilt.pl],
2100   [0], [<0>
2101 ])
2102 # Add 4 flows.
2103 for in_port in 4 3 2 1; do
2104     ovs-ofctl add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
2105 done
2106 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2107  idle_timeout=10, in_port=1 actions=drop
2108  idle_timeout=20, in_port=2 actions=drop
2109  idle_timeout=30, in_port=3 actions=drop
2110  idle_timeout=40, in_port=4 actions=drop
2111 NXST_FLOW reply:
2112 ])
2113 # Adding another flow will cause the one that expires soonest to be evicted.
2114 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
2115 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2116  idle_timeout=20, in_port=2 actions=drop
2117  idle_timeout=30, in_port=3 actions=drop
2118  idle_timeout=40, in_port=4 actions=drop
2119  in_port=5 actions=drop
2120 NXST_FLOW reply:
2121 ])
2122 # A mod-flow that adds a flow also causes eviction, but replacing or
2123 # modifying an existing flow doesn't.
2124 AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
2125 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
2126 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
2127 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2128  idle_timeout=30, in_port=3 actions=output:1
2129  in_port=4 actions=NORMAL
2130  in_port=5 actions=drop
2131  in_port=6 actions=drop
2132 NXST_FLOW reply:
2133 ])
2134 # Flows with no timeouts at all cannot be evicted.
2135 AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
2136 AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
2137 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2138   [OFPT_ERROR: OFPFMFC_TABLE_FULL
2139 ])
2140 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2141  in_port=4 actions=NORMAL
2142  in_port=5 actions=drop
2143  in_port=6 actions=drop
2144  in_port=7 actions=NORMAL
2145 NXST_FLOW reply:
2146 ])
2147 OVS_VSWITCHD_STOP
2148 AT_CLEANUP
2149
2150 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.2)])
2151 OVS_VSWITCHD_START
2152 # Configure a maximum of 4 flows.
2153 AT_CHECK(
2154   [ovs-vsctl \
2155      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
2156      -- set bridge br0 flow_tables:0=@t0 \
2157    | ${PERL} $srcdir/uuidfilt.pl],
2158   [0], [<0>
2159 ])
2160 # Add 4 flows.
2161 for in_port in 4 3 2 1; do
2162     ovs-ofctl -O OpenFlow12 add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
2163 done
2164 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2165  idle_timeout=10, in_port=1 actions=drop
2166  idle_timeout=20, in_port=2 actions=drop
2167  idle_timeout=30, in_port=3 actions=drop
2168  idle_timeout=40, in_port=4 actions=drop
2169 OFPST_FLOW reply (OF1.2):
2170 ])
2171 # Adding another flow will cause the one that expires soonest to be evicted.
2172 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop])
2173 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2174  idle_timeout=20, in_port=2 actions=drop
2175  idle_timeout=30, in_port=3 actions=drop
2176  idle_timeout=40, in_port=4 actions=drop
2177  in_port=5 actions=drop
2178 OFPST_FLOW reply (OF1.2):
2179 ])
2180 # In OpenFlow 1.2 a mod-flow does not ever add a flow and thus
2181 # has no effect on eviction
2182 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=6,actions=drop])
2183 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
2184 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
2185 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2186  idle_timeout=20, in_port=2 actions=drop
2187  idle_timeout=30, in_port=3 actions=output:1
2188  in_port=4 actions=NORMAL
2189  in_port=5 actions=drop
2190 OFPST_FLOW reply (OF1.2):
2191 ])
2192 # Flows with no timeouts at all cannot be evicted.
2193 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=6,actions=drop])
2194 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=7,actions=normal])
2195 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
2196 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2197   [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
2198 ])
2199 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2200  in_port=4 actions=NORMAL
2201  in_port=5 actions=drop
2202  in_port=6 actions=drop
2203  in_port=7 actions=NORMAL
2204 OFPST_FLOW reply (OF1.2):
2205 ])
2206 OVS_VSWITCHD_STOP
2207 AT_CLEANUP
2208
2209 AT_SETUP([ofproto - eviction using importance upon table overflow (OpenFlow 1.4)])
2210 OVS_VSWITCHD_START
2211 # Configure a maximum of 4 flows.
2212 AT_CHECK(
2213   [ovs-vsctl \
2214      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
2215      -- set bridge br0 flow_tables:0=@t0 \
2216    | ${PERL} $srcdir/uuidfilt.pl],
2217   [0], [<0>
2218 ])
2219 # Use mod-table to turn on eviction just to demonstrate that it works.
2220 AT_CHECK([ovs-ofctl -O OpenFlow14 mod-table br0 0 evict])
2221 # Add 4 flows.
2222 for in_port in 4 3 2 1; do
2223     ovs-ofctl -O Openflow14 add-flow br0 importance=$((in_port + 30)),priority=$((in_port + 5)),hard_timeout=$((in_port + 500)),actions=drop
2224 done
2225 AT_CHECK([ovs-ofctl -O Openflow14 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2226  hard_timeout=501, importance=31, priority=6 actions=drop
2227  hard_timeout=502, importance=32, priority=7 actions=drop
2228  hard_timeout=503, importance=33, priority=8 actions=drop
2229  hard_timeout=504, importance=34, priority=9 actions=drop
2230 OFPST_FLOW reply (OF1.4):
2231 ])
2232 # Adding another flow will cause the one with lowest importance to be evicted.
2233 AT_CHECK([ovs-ofctl -O Openflow14 add-flow br0 hard_timeout=505,importance=35,priority=10,in_port=2,actions=drop])
2234 AT_CHECK([ovs-ofctl -O Openflow14 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2235  hard_timeout=502, importance=32, priority=7 actions=drop
2236  hard_timeout=503, importance=33, priority=8 actions=drop
2237  hard_timeout=504, importance=34, priority=9 actions=drop
2238  hard_timeout=505, importance=35, priority=10,in_port=2 actions=drop
2239 OFPST_FLOW reply (OF1.4):
2240 ])
2241 # Disable the Eviction configuration.
2242 AT_CHECK([ovs-ofctl -O OpenFlow14 mod-table br0 0 noevict])
2243 # Adding another flow will cause the system to give error for FULL TABLE.
2244 AT_CHECK([ovs-ofctl -O Openflow14 add-flow br0 hard_timeout=506,importance=36,priority=11,actions=drop],[1], [], [stderr])
2245 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2246  [OFPT_ERROR (OF1.4): OFPFMFC_TABLE_FULL
2247 ])
2248 #Dump flows. It should show only the old values
2249 AT_CHECK([ovs-ofctl -O Openflow14 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2250  hard_timeout=502, importance=32, priority=7 actions=drop
2251  hard_timeout=503, importance=33, priority=8 actions=drop
2252  hard_timeout=504, importance=34, priority=9 actions=drop
2253  hard_timeout=505, importance=35, priority=10,in_port=2 actions=drop
2254 OFPST_FLOW reply (OF1.4):
2255 ])
2256 # mod-flow that would modify a flow will be done successfully.
2257 AT_CHECK([ovs-ofctl -O Openflow14 mod-flows br0 in_port=2,actions=NORMAL])
2258 AT_CHECK([ovs-ofctl -O Openflow14 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2259  hard_timeout=502, importance=32, priority=7 actions=drop
2260  hard_timeout=503, importance=33, priority=8 actions=drop
2261  hard_timeout=504, importance=34, priority=9 actions=drop
2262  hard_timeout=505, importance=35, priority=10,in_port=2 actions=NORMAL
2263 OFPST_FLOW reply (OF1.4):
2264 ])
2265 # Also a mod-flow that would add a flow will be refused.
2266 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
2267 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2268   [OFPT_ERROR: OFPFMFC_TABLE_FULL
2269 ])
2270 OVS_VSWITCHD_STOP
2271 AT_CLEANUP
2272
2273 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.0)])
2274 OVS_VSWITCHD_START
2275 # Configure a maximum of 4 flows.
2276 AT_CHECK(
2277   [ovs-vsctl \
2278      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
2279                                    overflow-policy=evict \
2280                                    groups='"NXM_OF_IN_PORT[[]]"' \
2281      -- set bridge br0 flow_tables:0=@t0 \
2282    | ${PERL} $srcdir/uuidfilt.pl],
2283   [0], [<0>
2284 ])
2285 # Add 4 flows.
2286 ovs-ofctl add-flows br0 - <<EOF
2287 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
2288 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
2289 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
2290 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
2291 EOF
2292 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2293  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2294  idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
2295  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2296  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2297 NXST_FLOW reply:
2298 ])
2299 # Adding another flow will cause the one that expires soonest within
2300 # the largest group (those with in_port=1) to be evicted.  In this
2301 # case this is not the same as the one that expires soonest overall
2302 # (which is what makes the test interesting):
2303 AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
2304 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2305  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2306  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2307  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2308  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2309 NXST_FLOW reply:
2310 ])
2311 # Enlarge the flow limit, change the eviction policy back to strictly
2312 # based on expiration, and and add some flows.
2313 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
2314 ovs-ofctl add-flows br0 - <<EOF
2315 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
2316 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
2317 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
2318 EOF
2319 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2320  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2321  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2322  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2323  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
2324  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2325  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2326  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2327 NXST_FLOW reply:
2328 ])
2329 # Adding another flow will cause the one that expires soonest overall
2330 # to be evicted.
2331 AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
2332 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2333  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2334  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2335  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
2336  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2337  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2338  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
2339  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2340 NXST_FLOW reply:
2341 ])
2342 # Reducing the flow limit also causes the flows that expire soonest
2343 # overall to be evicted.
2344 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
2345 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2346  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2347  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2348  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
2349  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2350 NXST_FLOW reply:
2351 ])
2352 OVS_VSWITCHD_STOP
2353 AT_CLEANUP
2354
2355 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.2)])
2356 OVS_VSWITCHD_START
2357 # Configure a maximum of 4 flows.
2358 AT_CHECK(
2359   [ovs-vsctl \
2360      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
2361                                    overflow-policy=evict \
2362                                    groups='"NXM_OF_IN_PORT[[]]"' \
2363      -- set bridge br0 flow_tables:0=@t0 \
2364    | ${PERL} $srcdir/uuidfilt.pl],
2365   [0], [<0>
2366 ])
2367 # Add 4 flows.
2368 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
2369 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
2370 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
2371 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
2372 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
2373 EOF
2374 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2375  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2376  idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
2377  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2378  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2379 OFPST_FLOW reply (OF1.2):
2380 ])
2381 # Adding another flow will cause the one that expires soonest within
2382 # the largest group (those with in_port=1) to be evicted.  In this
2383 # case this is not the same as the one that expires soonest overall
2384 # (which is what makes the test interesting):
2385 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
2386 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2387  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2388  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2389  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2390  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2391 OFPST_FLOW reply (OF1.2):
2392 ])
2393 # Enlarge the flow limit, change the eviction policy back to strictly
2394 # based on expiration, and and add some flows.
2395 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
2396 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
2397 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
2398 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
2399 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
2400 EOF
2401 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2402  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2403  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2404  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2405  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
2406  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2407  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2408  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2409 OFPST_FLOW reply (OF1.2):
2410 ])
2411 # Adding another flow will cause the one that expires soonest overall
2412 # to be evicted.
2413 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
2414 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2415  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2416  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2417  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
2418  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2419  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2420  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
2421  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2422 OFPST_FLOW reply (OF1.2):
2423 ])
2424 # Reducing the flow limit also causes the flows that expire soonest
2425 # overall to be evicted.
2426 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
2427 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2428  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2429  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2430  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
2431  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2432 OFPST_FLOW reply (OF1.2):
2433 ])
2434 OVS_VSWITCHD_STOP
2435 AT_CLEANUP
2436
2437 AT_SETUP([ofproto - eviction upon table overflow, with modified hard timeout])
2438 OVS_VSWITCHD_START
2439 # Configure a maximum of 4 flows.
2440 AT_CHECK(
2441   [ovs-vsctl \
2442      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
2443      -- set bridge br0 flow_tables:0=@t0 \
2444    | ${PERL} $srcdir/uuidfilt.pl],
2445   [0], [<0>
2446 ])
2447 ovs-appctl time/stop
2448 # Add 4 flows.
2449 for in_port in 4 3 2 1; do
2450     ovs-ofctl add-flow br0 hard_timeout=$((10 + in_port * 3)),in_port=$in_port,actions=drop
2451 done
2452 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2453  hard_timeout=13, in_port=1 actions=drop
2454  hard_timeout=16, in_port=2 actions=drop
2455  hard_timeout=19, in_port=3 actions=drop
2456  hard_timeout=22, in_port=4 actions=drop
2457 NXST_FLOW reply:
2458 ])
2459 # Sleep and modify the one that expires soonest
2460 ovs-appctl time/warp 5000
2461 AT_CHECK([ovs-ofctl mod-flows br0 in_port=1,actions=drop])
2462 # At this point the table would looks like:
2463 #  in_port   seconds to expire
2464 #     1            13
2465 #     2            11
2466 #     3            14
2467 #     4            17
2468 ovs-appctl time/warp 2000
2469 # Adding another flow will cause the one that expires soonest to be evicted.
2470 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
2471 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2472  hard_timeout=13, in_port=1 actions=drop
2473  hard_timeout=19, in_port=3 actions=drop
2474  hard_timeout=22, in_port=4 actions=drop
2475  in_port=5 actions=drop
2476 NXST_FLOW reply:
2477 ])
2478 OVS_VSWITCHD_STOP
2479 AT_CLEANUP
2480
2481 AT_SETUP([ofproto - eviction upon table overflow, with modified idle timeout])
2482 OVS_VSWITCHD_START([add-port br0 p1 -- set interface p1 type=dummy ofport_request=1])
2483 # Configure a maximum of 4 flows.
2484 AT_CHECK(
2485   [ovs-vsctl \
2486      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
2487      -- set bridge br0 flow_tables:0=@t0 \
2488    | ${PERL} $srcdir/uuidfilt.pl],
2489   [0], [<0>
2490 ])
2491 # Add 4 flows.
2492 for in_port in 4 3 2 1; do
2493     ovs-ofctl add-flow br0 idle_timeout=$((10 + in_port * 3)),in_port=$in_port,actions=drop
2494 done
2495 ovs-appctl time/stop
2496 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2497  idle_timeout=13, in_port=1 actions=drop
2498  idle_timeout=16, in_port=2 actions=drop
2499  idle_timeout=19, in_port=3 actions=drop
2500  idle_timeout=22, in_port=4 actions=drop
2501 NXST_FLOW reply:
2502 ])
2503 # Sleep and receive on the flow that expires soonest
2504 ovs-appctl time/warp 5000
2505 AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1)'])
2506 # At this point the table would looks like:
2507 #  in_port   seconds to expire
2508 #     1            13
2509 #     2            11
2510 #     3            14
2511 #     4            17
2512 ovs-appctl time/warp 2000
2513 # Adding another flow will cause the one that expires soonest to be evicted.
2514 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
2515 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2516  idle_timeout=19, in_port=3 actions=drop
2517  idle_timeout=22, in_port=4 actions=drop
2518  in_port=5 actions=drop
2519  n_packets=1, n_bytes=60, idle_timeout=13, in_port=1 actions=drop
2520 NXST_FLOW reply:
2521 ])
2522 OVS_VSWITCHD_STOP
2523 AT_CLEANUP
2524
2525 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.0)])
2526 OVS_VSWITCHD_START
2527 AT_CHECK([ovs-ofctl -P standard monitor br0 --detach --no-chdir --pidfile])
2528 check_async () {
2529     printf '\n\n--- check_async %d ---\n\n\n' $1
2530     shift
2531
2532     ovs-appctl -t ovs-ofctl ofctl/barrier
2533     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2534     : > expout
2535
2536     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
2537     ovs-ofctl -v packet-out br0 controller controller '0001020304050010203040501234'
2538     if test X"$1" = X"OFPR_ACTION"; then shift;
2539         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
2540 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2541     fi
2542
2543     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
2544     ovs-ofctl -v packet-out br0 controller 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
2545     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
2546         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via no_match) data_len=14 (unbuffered)
2547 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2548     fi
2549
2550     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
2551     ovs-ofctl packet-out br0 controller dec_ttl '002583dfb4000026b98cb0f908004500003eb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
2552     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
2553         echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=CONTROLLER (via invalid_ttl) data_len=76 (unbuffered)
2554 udp,vlan_tci=0x0000,dl_src=00:26:b9:8c:b0:f9,dl_dst=00:25:83:df:b4:00,nw_src=172.17.55.13,nw_dst=172.16.0.2,nw_tos=0,nw_ecn=0,nw_ttl=0,tp_src=55155,tp_dst=53 udp_csum:8f6d"
2555     fi
2556
2557     # OFPT_PORT_STATUS, OFPPR_ADD
2558     ovs-vsctl add-port br0 test -- set Interface test type=dummy ofport_request=1
2559     if test X"$1" = X"OFPPR_ADD"; then shift;
2560         echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
2561      config:     PORT_DOWN
2562      state:      LINK_DOWN
2563      speed: 0 Mbps now, 0 Mbps max"
2564     fi
2565
2566     # OFPT_PORT_STATUS, OFPPR_DELETE
2567     ovs-vsctl del-port br0 test
2568     if test X"$1" = X"OFPPR_DELETE"; then shift;
2569         echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
2570      config:     PORT_DOWN
2571      state:      LINK_DOWN
2572      speed: 0 Mbps now, 0 Mbps max"
2573     fi
2574
2575     # OFPT_FLOW_REMOVED, OFPRR_DELETE
2576     ovs-ofctl add-flow br0 send_flow_rem,actions=drop
2577     ovs-ofctl --strict del-flows br0 ''
2578     if test X"$1" = X"OFPRR_DELETE"; then shift;
2579         echo >>expout "OFPT_FLOW_REMOVED:  reason=delete"
2580     fi
2581     AT_FAIL_IF([test X"$1" != X])
2582
2583     ovs-appctl -t ovs-ofctl ofctl/barrier
2584     echo >>expout "OFPT_BARRIER_REPLY:"
2585
2586     AT_CHECK(
2587       [[sed '
2588 s/ (xid=0x[0-9a-fA-F]*)//
2589 s/ *duration.*//
2590 s/00:0.$/00:0x/' < monitor.log]],
2591       [0], [expout])
2592 }
2593
2594 # It's a service connection so initially there should be no async messages.
2595 check_async 1
2596
2597 # Set miss_send_len to 128, turning on packet-ins for our service connection.
2598 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
2599 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2600
2601 # Set miss_send_len to 128 and enable invalid_ttl.
2602 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
2603 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2604
2605 # Become slave, which should disable everything except port status.
2606 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
2607 check_async 4 OFPPR_ADD OFPPR_DELETE
2608
2609 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
2610 ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
2611 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
2612
2613 # Set controller ID 123.
2614 ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
2615 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
2616
2617 # Restore controller ID 0.
2618 ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
2619
2620 # Become master.
2621 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
2622 check_async 7 OFPR_ACTION OFPPR_ADD
2623
2624 ovs-appctl -t ovs-ofctl exit
2625 OVS_VSWITCHD_STOP
2626 AT_CLEANUP
2627
2628 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.2)])
2629 OVS_VSWITCHD_START
2630 AT_CHECK([ovs-ofctl -O OpenFlow12 -P standard monitor br0 --detach --no-chdir --pidfile])
2631 check_async () {
2632     printf '\n\n--- check_async %d ---\n\n\n' $1
2633     INDEX=$1
2634     shift
2635
2636     ovs-appctl -t ovs-ofctl ofctl/barrier
2637     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2638     : > expout
2639
2640     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
2641     ovs-ofctl -O OpenFlow12 -v packet-out br0 none controller '0001020304050010203040501234'
2642     if test X"$1" = X"OFPR_ACTION"; then shift;
2643         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
2644 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2645     fi
2646
2647     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
2648     ovs-ofctl -O OpenFlow12 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
2649     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
2650         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
2651 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2652     fi
2653
2654     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
2655     ovs-ofctl -O OpenFlow12 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003eb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
2656     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
2657         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
2658 udp,vlan_tci=0x0000,dl_src=00:26:b9:8c:b0:f9,dl_dst=00:25:83:df:b4:00,nw_src=172.17.55.13,nw_dst=172.16.0.2,nw_tos=0,nw_ecn=0,nw_ttl=0,tp_src=55155,tp_dst=53 udp_csum:8f6d"
2659     fi
2660
2661     # OFPT_PORT_STATUS, OFPPR_ADD
2662     ovs-vsctl add-port br0 test -- set Interface test type=dummy
2663     if test X"$1" = X"OFPPR_ADD"; then shift;
2664         echo >>expout "OFPT_PORT_STATUS (OF1.2): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2665      config:     PORT_DOWN
2666      state:      LINK_DOWN
2667      speed: 0 Mbps now, 0 Mbps max"
2668     fi
2669
2670     # OFPT_PORT_STATUS, OFPPR_DELETE
2671     ovs-vsctl del-port br0 test
2672     if test X"$1" = X"OFPPR_DELETE"; then shift;
2673         echo >>expout "OFPT_PORT_STATUS (OF1.2): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2674      config:     PORT_DOWN
2675      state:      LINK_DOWN
2676      speed: 0 Mbps now, 0 Mbps max"
2677     fi
2678
2679     # OFPT_FLOW_REMOVED, OFPRR_DELETE
2680     ovs-ofctl -O OpenFlow12 add-flow br0 send_flow_rem,actions=drop
2681     ovs-ofctl -O OpenFlow12 --strict del-flows br0 ''
2682     if test X"$1" = X"OFPRR_DELETE"; then shift;
2683         echo >>expout "OFPT_FLOW_REMOVED (OF1.2):  reason=delete table_id=0"
2684     fi
2685     AT_FAIL_IF([test X"$1" != X])
2686
2687     sleep 1
2688
2689     AT_CHECK(
2690       [[sed '
2691 s/ (xid=0x[0-9a-fA-F]*)//
2692 s/ *duration.*//
2693 s/00:0.$/00:0x/' < monitor.log]],
2694       [0], [expout])
2695 }
2696
2697 # It's a service connection so initially there should be no async messages.
2698 check_async 1
2699
2700 # Set miss_send_len to 128, turning on packet-ins for our service connection.
2701 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
2702 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2703
2704 # Set miss_send_len to 128 and enable invalid_ttl.
2705 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700040080
2706 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2707
2708 # Become slave (OF 1.2), which should disable everything except port status.
2709 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000200000003000000000000000000000001
2710 check_async 4 OFPPR_ADD OFPPR_DELETE
2711
2712 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
2713 ovs-appctl -t ovs-ofctl ofctl/send 03040028000000020000232000000013000000020000000500000005000000020000000200000005
2714 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
2715
2716 # Set controller ID 123.
2717 ovs-appctl -t ovs-ofctl ofctl/send 03040018000000030000232000000014000000000000007b
2718 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
2719
2720 # Restore controller ID 0.
2721 ovs-appctl -t ovs-ofctl ofctl/send 030400180000000300002320000000140000000000000000
2722
2723 # Become master (OF 1.2).
2724 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000400000002000000000000000000000002
2725 check_async 7 OFPR_ACTION OFPPR_ADD
2726
2727 ovs-appctl -t ovs-ofctl exit
2728 OVS_VSWITCHD_STOP
2729 AT_CLEANUP
2730
2731 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.3)])
2732 OVS_VSWITCHD_START
2733 AT_CHECK([ovs-ofctl -O OpenFlow13 -P standard monitor br0 --detach --no-chdir --pidfile])
2734 check_async () {
2735     printf '\n\n--- check_async %d ---\n\n\n' $1
2736     INDEX=$1
2737     shift
2738
2739     ovs-appctl -t ovs-ofctl ofctl/barrier
2740     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2741     : > expout
2742
2743     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
2744     ovs-ofctl -O OpenFlow13 -v packet-out br0 none controller '0001020304050010203040501234'
2745     if test X"$1" = X"OFPR_ACTION"; then shift;
2746         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
2747 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2748     fi
2749
2750     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
2751     ovs-ofctl -O OpenFlow13 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
2752     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
2753         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
2754 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2755     fi
2756
2757     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
2758     ovs-ofctl -O OpenFlow13 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003eb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
2759     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
2760         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
2761 udp,vlan_tci=0x0000,dl_src=00:26:b9:8c:b0:f9,dl_dst=00:25:83:df:b4:00,nw_src=172.17.55.13,nw_dst=172.16.0.2,nw_tos=0,nw_ecn=0,nw_ttl=0,tp_src=55155,tp_dst=53 udp_csum:8f6d"
2762     fi
2763
2764     # OFPT_PORT_STATUS, OFPPR_ADD
2765     ovs-vsctl add-port br0 test -- set Interface test type=dummy
2766     if test X"$1" = X"OFPPR_ADD"; then shift;
2767         echo >>expout "OFPT_PORT_STATUS (OF1.3): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2768      config:     PORT_DOWN
2769      state:      LINK_DOWN
2770      speed: 0 Mbps now, 0 Mbps max"
2771     fi
2772
2773     # OFPT_PORT_STATUS, OFPPR_DELETE
2774     ovs-vsctl del-port br0 test
2775     if test X"$1" = X"OFPPR_DELETE"; then shift;
2776         echo >>expout "OFPT_PORT_STATUS (OF1.3): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2777      config:     PORT_DOWN
2778      state:      LINK_DOWN
2779      speed: 0 Mbps now, 0 Mbps max"
2780     fi
2781
2782     # OFPT_FLOW_REMOVED, OFPRR_DELETE
2783     ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=drop
2784     ovs-ofctl -O OpenFlow13 --strict del-flows br0 ''
2785     if test X"$1" = X"OFPRR_DELETE"; then shift;
2786         echo >>expout "OFPT_FLOW_REMOVED (OF1.3):  reason=delete table_id=0"
2787     fi
2788
2789     # OFPT_FLOW_REMOVED, OFPRR_GROUP_DELETE
2790     ovs-ofctl -O OpenFlow13 add-group br0 group_id=1234,type=all,bucket=output:10
2791     ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=group:1234
2792     ovs-ofctl -O OpenFlow13 --strict del-groups br0 group_id=1234
2793     if test X"$1" = X"OFPRR_DELETE"; then shift;
2794         echo >>expout "OFPT_FLOW_REMOVED (OF1.3):  reason=gropu_delete table_id=0"
2795     fi
2796
2797     AT_FAIL_IF([test X"$1" != X])
2798
2799     ovs-appctl -t ovs-ofctl ofctl/barrier
2800     echo >>expout "OFPT_BARRIER_REPLY (OF1.3):"
2801
2802     AT_CHECK(
2803       [[sed '
2804 s/ (xid=0x[0-9a-fA-F]*)//
2805 s/ *duration.*//
2806 s/00:0.$/00:0x/' < monitor.log]],
2807       [0], [expout])
2808 }
2809
2810 # It's a service connection so initially there should be no async messages.
2811 check_async 1
2812
2813 # Set miss_send_len to 128, turning on packet-ins for our service connection.
2814 ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
2815 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2816
2817 # Become slave (OF 1.3), which should disable everything except port status.
2818 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000200000003000000000000000000000001
2819 check_async 3 OFPPR_ADD OFPPR_DELETE
2820
2821 # Use OF 1.3 OFPT_SET_ASYNC to enable a patchwork of asynchronous messages.
2822 ovs-appctl -t ovs-ofctl ofctl/send 041c002000000002000000020000000500000005000000020000000200000005
2823 check_async 4 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
2824
2825 # Set controller ID 123.
2826 ovs-appctl -t ovs-ofctl ofctl/send 04040018000000030000232000000014000000000000007b
2827 check_async 5 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
2828
2829 # Restore controller ID 0.
2830 ovs-appctl -t ovs-ofctl ofctl/send 040400180000000300002320000000140000000000000000
2831
2832 # Become master (OF 1.3).
2833 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000400000002000000000000000000000002
2834 check_async 6 OFPR_ACTION OFPPR_ADD
2835
2836 ovs-appctl -t ovs-ofctl exit
2837 OVS_VSWITCHD_STOP
2838 AT_CLEANUP
2839
2840 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.4)])
2841 OVS_VSWITCHD_START
2842 AT_CHECK([ovs-ofctl -O OpenFlow14 -P standard monitor br0 --detach --no-chdir --pidfile])
2843 check_async () {
2844     printf '\n\n--- check_async %d ---\n\n\n' $1
2845     INDEX=$1
2846     shift
2847
2848     ovs-appctl -t ovs-ofctl ofctl/barrier
2849     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2850     : > expout
2851
2852     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
2853     ovs-ofctl -O OpenFlow14 -v packet-out br0 none controller '0001020304050010203040501234'
2854     if test X"$1" = X"OFPR_ACTION"; then shift;
2855         echo >>expout "OFPT_PACKET_IN (OF1.4): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
2856 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2857     fi
2858
2859     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
2860     ovs-ofctl -O OpenFlow14 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
2861     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
2862         echo >>expout "OFPT_PACKET_IN (OF1.4): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
2863 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2864     fi
2865
2866     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
2867     ovs-ofctl -O OpenFlow14 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003eb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
2868     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
2869         echo >>expout "OFPT_PACKET_IN (OF1.4): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
2870 udp,vlan_tci=0x0000,dl_src=00:26:b9:8c:b0:f9,dl_dst=00:25:83:df:b4:00,nw_src=172.17.55.13,nw_dst=172.16.0.2,nw_tos=0,nw_ecn=0,nw_ttl=0,tp_src=55155,tp_dst=53 udp_csum:8f6d"
2871     fi
2872
2873 # OFPT_PORT_STATUS, OFPPR_ADD
2874     ovs-vsctl add-port br0 test -- set Interface test type=dummy
2875     if test X"$1" = X"OFPPR_ADD"; then shift;
2876         echo >>expout "OFPT_PORT_STATUS (OF1.4): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2877      config:     PORT_DOWN
2878      state:      LINK_DOWN
2879      speed: 0 Mbps now, 0 Mbps max"
2880     fi
2881
2882     # OFPT_PORT_STATUS, OFPPR_MODIFY
2883     ovs-ofctl -O OpenFlow14 -vwarn mod-port br0 test up
2884     if test X"$1" = X"OFPPR_MODIFY"; then shift;
2885         echo >>expout "OFPT_PORT_STATUS (OF1.4): MOD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2886      config:     0
2887      state:      LINK_DOWN
2888      speed: 0 Mbps now, 0 Mbps max
2889 OFPT_PORT_STATUS (OF1.4): MOD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2890      config:     0
2891      state:      0
2892      speed: 0 Mbps now, 0 Mbps max"
2893     fi
2894
2895     # OFPT_PORT_STATUS, OFPPR_DELETE
2896     ovs-vsctl del-port br0 test
2897     if test X"$1" = X"OFPPR_DELETE"; then shift;
2898         echo >>expout "OFPT_PORT_STATUS (OF1.4): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2899      config:     0
2900      state:      0
2901      speed: 0 Mbps now, 0 Mbps max"
2902     fi
2903
2904     # OFPT_FLOW_REMOVED, OFPRR_DELETE
2905     ovs-ofctl -O OpenFlow14 add-flow br0 send_flow_rem,actions=drop
2906     ovs-ofctl -O OpenFlow14 --strict del-flows br0 ''
2907     if test X"$1" = X"OFPRR_DELETE"; then shift;
2908         echo >>expout "OFPT_FLOW_REMOVED (OF1.4):  reason=delete table_id=0"
2909     fi
2910
2911     # OFPT_FLOW_REMOVED, OFPRR_GROUP_DELETE
2912     ovs-ofctl -O OpenFlow14 add-group br0 group_id=1234,type=all,bucket=output:10
2913     ovs-ofctl -O OpenFlow14 add-flow br0 send_flow_rem,actions=group:1234
2914     ovs-ofctl -O OpenFlow14 --strict del-groups br0 group_id=1234
2915     if test X"$1" = X"OFPRR_GROUP_DELETE"; then shift;
2916         echo >>expout "OFPT_FLOW_REMOVED (OF1.4):  reason=group_delete table_id=0"
2917     fi
2918
2919     # OFPT_TABLE_STATUS, OFPTR_VACANCY_UP
2920     if test X"$1" = X"OFPTR_VACANCY_UP"; then shift;
2921         ovs-vsctl -- --id=@t1 create Flow_Table flow-limit=10 -- set bridge br0 flow_tables:1=@t1
2922
2923         # Turn on vacancy events, then add flows until we're full.
2924         # With initial vacancy of 100% and vacancy_up of 80%, so that
2925         # vacancy >= vacancy_up, this enables VACANY_DOWN events, so
2926         # we get a single such message when vacancy dips below 20%.
2927         ovs-ofctl -O OpenFlow14 mod-table br0 1 vacancy:20,80
2928         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=1,actions=2
2929         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=2,actions=2
2930         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=3,actions=2
2931         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=4,actions=2
2932         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=5,actions=2
2933         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=6,actions=2
2934         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=7,actions=2
2935         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=8,actions=2
2936         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=9,actions=2
2937         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=10,actions=2
2938         echo >>expout "OFPT_TABLE_STATUS (OF1.4): reason=VACANCY_DOWN
2939 table_desc:-
2940   table 1:
2941    eviction=off eviction_flags=OTHER|IMPORTANCE|LIFETIME
2942    vacancy=on vacancy_down=20% vacancy_up=80% vacancy=10%"
2943         # Then delete flows until we're empty.  Sending the
2944         # VACANCY_DOWN message enabled VACANCY_UP events, so we get a
2945         # single such message when vacancy rises above 80%.
2946         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=1
2947         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=2
2948         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=3
2949         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=4
2950         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=5
2951         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=6
2952         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=7
2953         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=8
2954         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=9
2955         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=10
2956         echo >>expout "OFPT_TABLE_STATUS (OF1.4): reason=VACANCY_UP
2957 table_desc:-
2958   table 1:
2959    eviction=off eviction_flags=OTHER|IMPORTANCE|LIFETIME
2960    vacancy=on vacancy_down=20% vacancy_up=80% vacancy=90%"
2961
2962         # Now approach vacancy from the other direction.  First
2963         # disable vacancy events.  With initial vacancy of 70%, so
2964         # that vacancy < vacancy_up, this enables VACANCY_UP events.
2965         # That means that filling up the table generates no message,
2966         # but deleting all the flows generates VACANCY_UP at the point
2967         # vacancy rises above 80%.
2968         ovs-ofctl -O OpenFlow14 mod-table br0 1 novacancy
2969         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=1,actions=2
2970         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=2,actions=2
2971         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=3,actions=2
2972         ovs-ofctl -O OpenFlow14 mod-table br0 1 vacancy:20,80
2973         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=4,actions=2
2974         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=5,actions=2
2975         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=6,actions=2
2976         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=7,actions=2
2977         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=8,actions=2
2978         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=9,actions=2
2979         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=10,actions=2
2980         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=1
2981         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=2
2982         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=3
2983         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=4
2984         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=5
2985         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=6
2986         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=7
2987         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=8
2988         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=9
2989         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=10
2990         echo >>expout "OFPT_TABLE_STATUS (OF1.4): reason=VACANCY_UP
2991 table_desc:-
2992   table 1:
2993    eviction=off eviction_flags=OTHER|IMPORTANCE|LIFETIME
2994    vacancy=on vacancy_down=20% vacancy_up=80% vacancy=90%"
2995     fi
2996
2997     AT_FAIL_IF([test X"$1" != X])
2998
2999     ovs-appctl -t ovs-ofctl ofctl/barrier
3000     echo >>expout "OFPT_BARRIER_REPLY (OF1.4):"
3001
3002     AT_CHECK(
3003       [[sed '
3004 s/ (xid=0x[0-9a-fA-F]*)//
3005 s/ *duration.*//
3006 s/00:0.$/00:0x/' < monitor.log]],
3007       [0], [expout])
3008 }
3009
3010 # It's a service connection so initially there should be no async messages.
3011 check_async 1
3012
3013 # Set miss_send_len to 128, turning on packet-ins for our service connection.
3014 ovs-appctl -t ovs-ofctl ofctl/send 0509000c0123456700000080
3015 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_MODIFY OFPPR_DELETE OFPRR_DELETE OFPRR_GROUP_DELETE
3016
3017 # Become slave (OF 1.4), which should disable everything except port status.
3018 ovs-appctl -t ovs-ofctl ofctl/send 051800180000000200000003000000000000000000000001
3019 check_async 3 OFPPR_ADD OFPPR_MODIFY OFPPR_DELETE
3020
3021 # Use OF 1.4 OFPT_SET_ASYNC to enable a patchwork of asynchronous messages.
3022 ovs-appctl -t ovs-ofctl ofctl/send 051c0040000000020000000800000005000100080000000200020008000000020003000800000005000400080000001c00050008000000050008000800000018
3023 check_async 4 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE OFPRR_GROUP_DELETE OFPTR_VACANCY_UP
3024
3025 # Set controller ID 123.
3026 ovs-appctl -t ovs-ofctl ofctl/send 05040018000000030000232000000014000000000000007b
3027 check_async 5 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE OFPRR_GROUP_DELETE
3028
3029 # Restore controller ID 0.
3030 ovs-appctl -t ovs-ofctl ofctl/send 050400180000000300002320000000140000000000000000
3031
3032 # Become master (OF 1.4).
3033 ovs-appctl -t ovs-ofctl ofctl/send 051800180000000400000002000000000000000000000002
3034 check_async 6 OFPR_ACTION OFPPR_ADD OFPPR_MODIFY OFPRR_DELETE
3035
3036 ovs-appctl -t ovs-ofctl exit
3037 OVS_VSWITCHD_STOP
3038 AT_CLEANUP
3039
3040 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.5)])
3041 OVS_VSWITCHD_START
3042 AT_CHECK([ovs-ofctl -O OpenFlow15 -P standard monitor br0 --detach --no-chdir --pidfile])
3043 check_async () {
3044     printf '\n\n--- check_async %d ---\n\n\n' $1
3045     INDEX=$1
3046     shift
3047
3048     ovs-appctl -t ovs-ofctl ofctl/barrier
3049     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3050     : > expout
3051
3052     # Other tests are not working with OF 1.5, and message
3053     # format may change, so leave them out.
3054
3055     # OFPT_PORT_STATUS, OFPPR_ADD
3056     ovs-vsctl add-port br0 test -- set Interface test type=dummy
3057     if test X"$1" = X"OFPPR_ADD"; then shift;
3058         echo >>expout "OFPT_PORT_STATUS (OF1.5): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
3059      config:     PORT_DOWN
3060      state:      LINK_DOWN
3061      speed: 0 Mbps now, 0 Mbps max"
3062     fi
3063
3064     # OFPT_PORT_STATUS, OFPPR_MODIFY
3065     ovs-ofctl -O OpenFlow15 -vwarn mod-port br0 test up
3066     if test X"$1" = X"OFPPR_MODIFY"; then shift;
3067         echo >>expout "OFPT_PORT_STATUS (OF1.5): MOD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
3068      config:     0
3069      state:      LINK_DOWN
3070      speed: 0 Mbps now, 0 Mbps max
3071 OFPT_PORT_STATUS (OF1.5): MOD: 2(test): addr:aa:55:aa:55:00:0x
3072      config:     0
3073      state:      0
3074      speed: 0 Mbps now, 0 Mbps max"
3075     fi
3076
3077     # OFPT_PORT_STATUS, OFPPR_DELETE
3078     ovs-vsctl del-port br0 test
3079     if test X"$1" = X"OFPPR_DELETE"; then shift;
3080         echo >>expout "OFPT_PORT_STATUS (OF1.5): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
3081      config:     0
3082      state:      0
3083      speed: 0 Mbps now, 0 Mbps max"
3084     fi
3085
3086     AT_FAIL_IF([test X"$1" != X])
3087
3088     ovs-appctl -t ovs-ofctl ofctl/barrier
3089     echo >>expout "OFPT_BARRIER_REPLY (OF1.5):"
3090
3091     AT_CHECK(
3092       [[sed '
3093 s/ (xid=0x[0-9a-fA-F]*)//
3094 s/ *duration.*//
3095 s/00:0.$/00:0x/' < monitor.log]],
3096       [0], [expout])
3097 }
3098
3099 # It's a service connection so initially there should be no async messages.
3100 check_async 1
3101
3102 # If we don't set this, async messages are not received.
3103 # Set miss_send_len to 128, turning on packet-ins for our service connection.
3104 ovs-appctl -t ovs-ofctl ofctl/send 0609000c0123456700000080
3105 check_async 2 OFPPR_ADD OFPPR_MODIFY OFPPR_DELETE
3106
3107 # Set-async has changed in OF 1.4 and is not yet implemented.
3108
3109 ovs-appctl -t ovs-ofctl exit
3110 OVS_VSWITCHD_STOP
3111 AT_CLEANUP
3112
3113 dnl This test checks that the role request/response messaging works
3114 dnl and that generation_id is handled properly.
3115 AT_SETUP([ofproto - controller role (OpenFlow 1.2)])
3116 OVS_VSWITCHD_START
3117 on_exit 'kill `cat c1.pid c2.pid`'
3118
3119 # Start two ovs-ofctl controller processes.
3120 AT_CAPTURE_FILE([monitor1.log])
3121 AT_CAPTURE_FILE([expout1])
3122 AT_CAPTURE_FILE([experr1])
3123 AT_CAPTURE_FILE([monitor2.log])
3124 AT_CAPTURE_FILE([expout2])
3125 AT_CAPTURE_FILE([experr2])
3126 for i in 1 2; do
3127      AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile=`pwd`/c$i.pid --unixctl=`pwd`/c$i])
3128     ovs-appctl -t `pwd`/c$i ofctl/barrier
3129     ovs-appctl -t `pwd`/c$i ofctl/set-output-file monitor$i.log
3130     : > expout$i
3131     : > experr$i
3132
3133     # find out current role
3134     ovs-appctl -t `pwd`/c$i ofctl/send 031800180000000200000000000000000000000000000000
3135     echo >>experr$i "send: OFPT_ROLE_REQUEST (OF1.2): role=nochange"
3136     echo >>expout$i "OFPT_ROLE_REPLY (OF1.2): role=equal"
3137 done
3138
3139 # controller 1: Become slave (generation_id is initially undefined, so
3140 # 2^63+2 should not be stale)
3141 ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000300000003000000008000000000000002
3142 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=slave generation_id=9223372036854775810"
3143 echo >>expout1 "OFPT_ROLE_REPLY (OF1.2): role=slave generation_id=9223372036854775810"
3144
3145 # controller 2: Become master.
3146 ovs-appctl -t `pwd`/c2 ofctl/send 031800180000000300000002000000008000000000000003
3147 echo >>experr2 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=9223372036854775811"
3148 echo >>expout2 "OFPT_ROLE_REPLY (OF1.2): role=master generation_id=9223372036854775811"
3149
3150 # controller 1: Try to become the master using a stale generation ID
3151 ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000400000002000000000000000000000003
3152 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=3"
3153 echo >>expout1 "OFPT_ERROR (OF1.2): OFPRRFC_STALE"
3154 echo >>expout1 "OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=3"
3155
3156 # controller 1: Become master using a valid generation ID
3157 ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000500000002000000000000000000000001
3158 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=1"
3159 echo >>expout1 "OFPT_ROLE_REPLY (OF1.2): role=master generation_id=1"
3160
3161 for i in 1 2; do
3162     ovs-appctl -t `pwd`/c$i ofctl/barrier
3163     echo >>expout$i "OFPT_BARRIER_REPLY (OF1.2):"
3164 done
3165
3166 # Check output.
3167 for i in 1 2; do
3168     cp expout$i expout
3169     AT_CHECK([grep -v '^send:' monitor$i.log | strip_xids], [0], [expout])
3170     cp experr$i expout
3171     AT_CHECK([grep '^send:' monitor$i.log | strip_xids], [0], [expout])
3172 done
3173 OVS_VSWITCHD_STOP
3174 AT_CLEANUP
3175
3176 dnl This test checks that the role request/response messaging works,
3177 dnl that generation_id is handled properly, and that role status update
3178 dnl messages are sent when a controller's role gets changed from master
3179 dnl to slave.
3180 AT_SETUP([ofproto - controller role (OpenFlow 1.4)])
3181 OVS_VSWITCHD_START
3182 on_exit 'kill `cat c1.pid c2.pid`'
3183
3184 # Start two ovs-ofctl controller processes.
3185 AT_CAPTURE_FILE([monitor1.log])
3186 AT_CAPTURE_FILE([expout1])
3187 AT_CAPTURE_FILE([experr1])
3188 AT_CAPTURE_FILE([monitor2.log])
3189 AT_CAPTURE_FILE([expout2])
3190 AT_CAPTURE_FILE([experr2])
3191 for i in 1 2; do
3192      AT_CHECK([ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile=`pwd`/c$i.pid --unixctl=`pwd`/c$i])
3193     ovs-appctl -t `pwd`/c$i ofctl/barrier
3194     ovs-appctl -t `pwd`/c$i ofctl/set-output-file monitor$i.log
3195     : > expout$i
3196     : > experr$i
3197
3198     # find out current role
3199     ovs-appctl -t `pwd`/c$i ofctl/send 051800180000000200000000000000000000000000000000
3200     echo >>experr$i "send: OFPT_ROLE_REQUEST (OF1.4): role=nochange"
3201     echo >>expout$i "OFPT_ROLE_REPLY (OF1.4): role=equal"
3202 done
3203
3204 # controller 1: Become slave (generation_id is initially undefined, so
3205 # 2^63+2 should not be stale)
3206 ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000300000003000000008000000000000002
3207 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=slave generation_id=9223372036854775810"
3208 echo >>expout1 "OFPT_ROLE_REPLY (OF1.4): role=slave generation_id=9223372036854775810"
3209
3210 # controller 2: Become master.
3211 ovs-appctl -t `pwd`/c2 ofctl/send 051800180000000300000002000000008000000000000003
3212 echo >>experr2 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=9223372036854775811"
3213 echo >>expout2 "OFPT_ROLE_REPLY (OF1.4): role=master generation_id=9223372036854775811"
3214
3215 # controller 1: Try to become the master using a stale generation ID
3216 ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000400000002000000000000000000000003
3217 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=3"
3218 echo >>expout1 "OFPT_ERROR (OF1.4): OFPRRFC_STALE"
3219 echo >>expout1 "OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=3"
3220
3221 # controller 1: Become master using a valid generation ID
3222 ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000500000002000000000000000000000001
3223 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=1"
3224 echo >>expout1 "OFPT_ROLE_REPLY (OF1.4): role=master generation_id=1"
3225 echo >>expout2 "OFPT_ROLE_STATUS (OF1.4): role=slave generation_id=1 reason=master_request"
3226
3227 for i in 1 2; do
3228     ovs-appctl -t `pwd`/c$i ofctl/barrier
3229     echo >>expout$i "OFPT_BARRIER_REPLY (OF1.4):"
3230 done
3231
3232 # Check output.
3233 for i in 1 2; do
3234     cp expout$i expout
3235     AT_CHECK([grep -v '^send:' monitor$i.log | strip_xids], [0], [expout])
3236     cp experr$i expout
3237     AT_CHECK([grep '^send:' monitor$i.log | strip_xids], [0], [expout])
3238 done
3239 OVS_VSWITCHD_STOP
3240 AT_CLEANUP
3241
3242 dnl This test checks the Group and meter notifications when a group mod
3243 dnl command is sent from one controller and the reply is received by
3244 dnl other controllers.
3245 AT_SETUP([ofproto - requestforward (OpenFlow 1.4)])
3246 OVS_VSWITCHD_START
3247 on_exit 'kill `cat c1.pid c2.pid c3.pid`'
3248
3249 # Start two ovs-ofctl controller processes.
3250 AT_CAPTURE_FILE([monitor1.log])
3251 AT_CAPTURE_FILE([expout1])
3252 AT_CAPTURE_FILE([monitor2.log])
3253 AT_CAPTURE_FILE([expout2])
3254 AT_CAPTURE_FILE([monitor3.log])
3255 AT_CAPTURE_FILE([expout3])
3256
3257 ovs-ofctl -O OpenFlow15 monitor br0 --detach --no-chdir --pidfile=`pwd`/c1.pid --unixctl=`pwd`/c1
3258 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile=`pwd`/c2.pid --unixctl=`pwd`/c2
3259 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile=`pwd`/c3.pid --unixctl=`pwd`/c3
3260
3261 check_async () {
3262     for i in 1 3; do
3263         ovs-appctl -t `pwd`/c$i ofctl/barrier
3264         ovs-appctl -t `pwd`/c$i ofctl/set-output-file monitor$i.log
3265         : > expout$i
3266     done
3267
3268     printf '\n\n--- check_async %d ---\n\n\n' $1
3269     INDEX=$1
3270     shift
3271
3272     # OFPGC_ADD
3273     ovs-appctl -t `pwd`/c2 ofctl/send "050f0020000000020000000000000001 00100000 ffffffffffffffff 00000000"
3274     if test X"$1" = X"OFPGC_ADD"; then shift;
3275         echo >>expout2 "send: OFPT_GROUP_MOD (OF1.4):
3276  ADD group_id=1,type=all,bucket=actions=drop"
3277         echo >>expout1 "OFPT_REQUESTFORWARD (OF1.5): reason=group_mod
3278  ADD group_id=1,type=all,bucket=bucket_id:0,actions=drop"
3279         echo >>expout3 "OFPT_REQUESTFORWARD (OF1.4): reason=group_mod
3280  ADD group_id=1,type=all,bucket=actions=drop"
3281     fi
3282
3283     # OFPGC_MODIFY
3284     ovs-appctl -t `pwd`/c2 ofctl/send "050f0020000000020001010000000001 00100000 ffffffffffffffff 00000000"
3285     if test X"$1" = X"OFPGC_MODIFY"; then shift;
3286         echo >>expout2 "send: OFPT_GROUP_MOD (OF1.4):
3287  MOD group_id=1,type=select,bucket=weight:0,actions=drop"
3288         echo >>expout1 "OFPT_REQUESTFORWARD (OF1.5): reason=group_mod
3289  MOD group_id=1,type=select,bucket=bucket_id:0,weight:0,actions=drop"
3290         echo >>expout3 "OFPT_REQUESTFORWARD (OF1.4): reason=group_mod
3291  MOD group_id=1,type=select,bucket=weight:0,actions=drop"
3292     fi
3293
3294     ovs-appctl -t `pwd`/c1 ofctl/barrier
3295     echo >>expout1 "OFPT_BARRIER_REPLY (OF1.5):"
3296     ovs-appctl -t `pwd`/c2 ofctl/barrier
3297     echo >>expout2 "OFPT_BARRIER_REPLY (OF1.4):"
3298     ovs-appctl -t `pwd`/c3 ofctl/barrier
3299     echo >>expout3 "OFPT_BARRIER_REPLY (OF1.4):"
3300
3301     # Check output.
3302     for i in 1 3; do
3303         cp expout$i expout
3304         AT_CHECK(
3305       [[sed '
3306 s/ (xid=0x[0-9a-fA-F]*)//'< monitor$i.log]],
3307       [0], [expout])
3308     done
3309 }
3310
3311 # controller 1: Become slave
3312 ovs-appctl -t `pwd`/c1 ofctl/send 061800180000000300000003000000008000000000000002
3313
3314 # controller 2: Become master
3315 ovs-appctl -t `pwd`/c2 ofctl/send 051800180000000300000002000000008000000000000003
3316
3317 # controller 1: Become slave
3318 ovs-appctl -t `pwd`/c3 ofctl/send 051800180000000300000003000000008000000000000004
3319
3320 # controller 1: Enabled requestforward using set Asynchronous message
3321 ovs-appctl -t `pwd`/c1 ofctl/send 061c00280000000200000008000000050002000800000002000400080000001a000a000800000003
3322
3323 # controller 2: Enabled requestforward using set Asynchronous message
3324 ovs-appctl -t `pwd`/c2 ofctl/send 051c002800000002000100080000000200030008000000050005000800000005000b000800000003
3325
3326 # controller 1: Enabled requestforward using set Asynchronous message
3327 ovs-appctl -t `pwd`/c3 ofctl/send 051c00280000000200000008000000050002000800000002000400080000001a000a000800000003
3328 check_async 1 OFPGC_ADD OFPGC_MODIFY
3329
3330 OVS_VSWITCHD_STOP
3331 AT_CLEANUP
3332
3333 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
3334 dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
3335 dnl controllers despite the spec) as meaning a packet that was generated
3336 dnl by the controller.
3337 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.0)])
3338 OVS_VSWITCHD_START
3339 add_of_ports br0 1
3340
3341 # Start a monitor listening for packet-ins.
3342 AT_CHECK([ovs-ofctl -P standard monitor br0 --detach --no-chdir --pidfile])
3343 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
3344 ovs-appctl -t ovs-ofctl ofctl/barrier
3345 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3346 AT_CAPTURE_FILE([monitor.log])
3347
3348 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
3349 AT_CHECK([ovs-ofctl packet-out br0 none controller,1 '0001020304050010203040501234'])
3350 AT_CHECK([ovs-ofctl packet-out br0 controller controller,1 '0001020304050010203040505678'])
3351
3352 # Stop the monitor and check its output.
3353 ovs-appctl -t ovs-ofctl ofctl/barrier
3354 ovs-appctl -t ovs-ofctl exit
3355
3356 ovs-ofctl dump-ports br0
3357
3358 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3359 OFPT_PACKET_IN: total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
3360 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3361 OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
3362 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
3363 OFPT_BARRIER_REPLY:
3364 ])
3365
3366 OVS_VSWITCHD_STOP
3367 AT_CLEANUP
3368
3369 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
3370 dnl specified by OpenFlow 1.2) and OFPP_CONTROLLER (used by some
3371 dnl controllers despite the spec) as meaning a packet that was generated
3372 dnl by the controller.
3373 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.2)])
3374 OVS_VSWITCHD_START
3375
3376 # Start a monitor listening for packet-ins.
3377 AT_CHECK([ovs-ofctl -O OpenFlow12 -P standard monitor br0 --detach --no-chdir --pidfile])
3378 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
3379 ovs-appctl -t ovs-ofctl ofctl/barrier
3380 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3381 AT_CAPTURE_FILE([monitor.log])
3382
3383 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
3384 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none controller '0001020304050010203040501234'])
3385 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 4294967293 controller '0001020304050010203040505678'])
3386
3387 # Stop the monitor and check its output.
3388 ovs-appctl -t ovs-ofctl ofctl/barrier
3389 ovs-appctl -t ovs-ofctl exit
3390
3391 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3392 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
3393 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3394 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
3395 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
3396 OFPT_BARRIER_REPLY (OF1.2):
3397 ])
3398
3399 OVS_VSWITCHD_STOP
3400 AT_CLEANUP
3401
3402 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
3403 dnl specified by OpenFlow 1.1) and OFPP_CONTROLLER (used by some
3404 dnl controllers despite the spec) as meaning a packet that was generated
3405 dnl by the controller.
3406 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.1)])
3407 OVS_VSWITCHD_START
3408
3409 # Start a monitor listening for packet-ins.
3410 AT_CHECK([ovs-ofctl -O OpenFlow11 -P standard monitor br0 --detach --no-chdir --pidfile])
3411 ovs-appctl -t ovs-ofctl ofctl/send 0209000c0123456700000080
3412 ovs-appctl -t ovs-ofctl ofctl/barrier
3413 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3414 AT_CAPTURE_FILE([monitor.log])
3415
3416 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
3417 AT_CHECK([ovs-ofctl -O OpenFlow11 packet-out br0 none controller '0001020304050010203040501234'])
3418 AT_CHECK([ovs-ofctl -O OpenFlow11 packet-out br0 4294967293 controller '0001020304050010203040505678'])
3419
3420 # Stop the monitor and check its output.
3421 ovs-appctl -t ovs-ofctl ofctl/barrier
3422 ovs-appctl -t ovs-ofctl exit
3423
3424 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3425 OFPT_PACKET_IN (OF1.1): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
3426 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3427 OFPT_PACKET_IN (OF1.1): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
3428 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
3429 OFPT_BARRIER_REPLY (OF1.1):
3430 ])
3431
3432 OVS_VSWITCHD_STOP
3433 AT_CLEANUP
3434
3435 dnl This test checks that metadata and userdata are encoded in NXT_PACKET_IN2.
3436 AT_SETUP([ofproto - packet-out with metadata and userdata (NXT_PACKET_IN2)])
3437 OVS_VSWITCHD_START
3438
3439 # Start a monitor listening for packet-ins.
3440 AT_CHECK([ovs-ofctl -P nxt_packet_in2 monitor br0 --detach --no-chdir --pidfile])
3441 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
3442 ovs-appctl -t ovs-ofctl ofctl/barrier
3443 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3444 AT_CAPTURE_FILE([monitor.log])
3445
3446 # Send a packet-out with a load action to set some metadata, and forward to controller
3447 AT_CHECK([ovs-ofctl packet-out br0 controller 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), load(0xaa->NXM_NX_PKT_MARK[[]]), controller(userdata=01.02.03.04.05)' '0001020304050010203040501234'])
3448
3449 # Stop the monitor and check its output.
3450 ovs-appctl -t ovs-ofctl ofctl/barrier
3451 ovs-appctl -t ovs-ofctl exit
3452
3453 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3454 NXT_PACKET_IN2: total_len=14 pkt_mark=0xaa,metadata=0xfafafafa5a5a5a5a,in_port=CONTROLLER (via action) data_len=14 (unbuffered)
3455  userdata=01.02.03.04.05
3456 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3457 OFPT_BARRIER_REPLY:
3458 ])
3459
3460 OVS_VSWITCHD_STOP
3461 AT_CLEANUP
3462
3463 dnl This test checks that metadata is encoded in packet_in structures,
3464 dnl supported by NXAST.
3465 AT_SETUP([ofproto - packet-out with metadata (NXM)])
3466 OVS_VSWITCHD_START
3467
3468 # Start a monitor listening for packet-ins.
3469 AT_CHECK([ovs-ofctl -P nxt_packet_in monitor br0 --detach --no-chdir --pidfile])
3470 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
3471 ovs-appctl -t ovs-ofctl ofctl/barrier
3472 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3473 AT_CAPTURE_FILE([monitor.log])
3474
3475 # Send a packet-out with a load action to set some metadata, and forward to controller
3476 AT_CHECK([ovs-ofctl packet-out br0 controller 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), load(0xaa->NXM_NX_PKT_MARK[[]]), controller' '0001020304050010203040501234'])
3477
3478 # Stop the monitor and check its output.
3479 ovs-appctl -t ovs-ofctl ofctl/barrier
3480 ovs-appctl -t ovs-ofctl exit
3481
3482 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3483 NXT_PACKET_IN: total_len=14 pkt_mark=0xaa,metadata=0xfafafafa5a5a5a5a,in_port=CONTROLLER (via action) data_len=14 (unbuffered)
3484 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3485 OFPT_BARRIER_REPLY:
3486 ])
3487
3488 OVS_VSWITCHD_STOP
3489 AT_CLEANUP
3490
3491 dnl This test checks that metadata is encoded in packet_in structures,
3492 dnl supported by NXAST.
3493 AT_SETUP([ofproto - packet-out with metadata (OpenFlow 1.2)])
3494 OVS_VSWITCHD_START
3495
3496 # Start a monitor listening for packet-ins.
3497 AT_CHECK([ovs-ofctl -O OpenFlow12 -P standard monitor br0 --detach --no-chdir --pidfile])
3498 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
3499 ovs-appctl -t ovs-ofctl ofctl/barrier
3500 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3501 AT_CAPTURE_FILE([monitor.log])
3502
3503 # Send a packet-out with a set-field action to set some metadata, and forward to controller
3504 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none 'set_field:0xfafafafa5a5a5a5a->metadata, controller' '0001020304050010203040501234'])
3505
3506 # Stop the monitor and check its output.
3507 ovs-appctl -t ovs-ofctl ofctl/barrier
3508 ovs-appctl -t ovs-ofctl exit
3509
3510 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3511 OFPT_PACKET_IN (OF1.2): total_len=14 metadata=0xfafafafa5a5a5a5a,in_port=ANY (via action) data_len=14 (unbuffered)
3512 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3513 OFPT_BARRIER_REPLY (OF1.2):
3514 ])
3515
3516 OVS_VSWITCHD_STOP
3517 AT_CLEANUP
3518
3519 dnl This test checks that metadata is encoded in packet_in structures,
3520 dnl supported by NXAST.
3521 AT_SETUP([ofproto - packet-out with metadata and dual set_field (OpenFlow 1.3)])
3522 OVS_VSWITCHD_START
3523
3524 # Start a monitor listening for packet-ins.
3525 AT_CHECK([ovs-ofctl -O OpenFlow13 -P standard monitor br0 --detach --no-chdir --pidfile])
3526 ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
3527 ovs-appctl -t ovs-ofctl ofctl/barrier
3528 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3529 AT_CAPTURE_FILE([monitor.log])
3530
3531 # Send a packet-out with a couple of set-field action to set some metadata, and forward to controller
3532 AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 none 'set_field:0xfafafafa5a5a5a5a->metadata, set_field:0x6b->metadata, controller' '0001020304050010203040501234'])
3533
3534 # Stop the monitor and check its output.
3535 ovs-appctl -t ovs-ofctl ofctl/barrier
3536 ovs-appctl -t ovs-ofctl exit
3537
3538 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3539 OFPT_PACKET_IN (OF1.3): total_len=14 metadata=0x6b,in_port=ANY (via action) data_len=14 (unbuffered)
3540 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3541 OFPT_BARRIER_REPLY (OF1.3):
3542 ])
3543
3544 OVS_VSWITCHD_STOP
3545 AT_CLEANUP
3546
3547 dnl This test checks that tunnel metadata is encoded in packet_in structures.
3548 AT_SETUP([ofproto - packet-out with tunnel metadata (OpenFlow 1.2)])
3549 OVS_VSWITCHD_START
3550
3551 # Start a monitor listening for packet-ins.
3552 AT_CHECK([ovs-ofctl -O OpenFlow12 -P standard monitor br0 --detach --no-chdir --pidfile])
3553 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
3554 ovs-appctl -t ovs-ofctl ofctl/barrier
3555 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3556 AT_CAPTURE_FILE([monitor.log])
3557
3558 # Send a packet-out with set field actions to set some tunnel metadata, and forward to controller
3559 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none 'set_field:127.0.0.1->tun_src,set_field:0x01020304->tun_id,set_field:192.168.0.1->tun_dst, controller' '0001020304050010203040501234'])
3560
3561 # Stop the monitor and check its output.
3562 ovs-appctl -t ovs-ofctl ofctl/barrier
3563 ovs-appctl -t ovs-ofctl exit
3564
3565 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3566 OFPT_PACKET_IN (OF1.2): total_len=14 tun_id=0x1020304,tun_src=127.0.0.1,tun_dst=192.168.0.1,in_port=ANY (via action) data_len=14 (unbuffered)
3567 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3568 OFPT_BARRIER_REPLY (OF1.2):
3569 ])
3570
3571 OVS_VSWITCHD_STOP
3572 AT_CLEANUP
3573
3574 m4_divert_push([PREPARE_TESTS])
3575 # Sorts groups of lines that start with a space, without moving them
3576 # past the nearest line that does not start with a space.
3577 multiline_sort () {
3578     ${PERL} -e '
3579         use warnings;
3580         use strict;
3581         my @buffer = ();
3582         while (<STDIN>) {
3583             if (/^ /) {
3584                 push(@buffer, $_);
3585             } else {
3586                 print $_ foreach sort(@buffer);
3587                 print $_;
3588                 @buffer = ();
3589             }
3590         }
3591         print $_ foreach sort(@buffer);
3592 '
3593 }
3594 m4_divert_pop([PREPARE_TESTS])
3595
3596 AT_SETUP([ofproto - flow monitoring])
3597 AT_KEYWORDS([monitor])
3598 OVS_VSWITCHD_START
3599
3600 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
3601
3602 # Start a monitor watching the flow table and check the initial reply.
3603 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
3604 AT_CAPTURE_FILE([monitor.log])
3605 ovs-appctl -t ovs-ofctl ofctl/barrier
3606 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3607   [NXST_FLOW_MONITOR reply:
3608  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
3609 OFPT_BARRIER_REPLY:
3610 ])
3611
3612 # Add, delete, and modify some flows and check the updates.
3613 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3614 ovs-ofctl add-flow br0 in_port=0,dl_vlan=124,actions=output:2
3615 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:5
3616 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=0,actions=output:6
3617 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=1,actions=output:7
3618 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:8
3619 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=0,actions=output:9
3620 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=1,actions=output:10
3621 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,actions=output:11
3622 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=0,actions=output:12
3623 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=1,actions=output:13
3624 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,actions=output:14
3625 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:15
3626 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:16
3627 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:17
3628 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:18
3629 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:19
3630 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:20
3631 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=0,actions=output:21
3632 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=1,actions=output:22
3633 ovs-ofctl add-flow br0 in_port=0,actions=output:23
3634 ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:3
3635 ovs-ofctl mod-flows br0 cookie=5,dl_vlan=123,actions=output:3
3636 ovs-ofctl del-flows br0 dl_vlan=123
3637 ovs-ofctl del-flows br0
3638 ovs-appctl -t ovs-ofctl ofctl/barrier
3639 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | multiline_sort], [0],
3640 [NXST_FLOW_MONITOR reply (xid=0x0):
3641  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
3642 NXST_FLOW_MONITOR reply (xid=0x0):
3643  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:5
3644 NXST_FLOW_MONITOR reply (xid=0x0):
3645  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:6
3646 NXST_FLOW_MONITOR reply (xid=0x0):
3647  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:7
3648 NXST_FLOW_MONITOR reply (xid=0x0):
3649  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:8
3650 NXST_FLOW_MONITOR reply (xid=0x0):
3651  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:9
3652 NXST_FLOW_MONITOR reply (xid=0x0):
3653  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:10
3654 NXST_FLOW_MONITOR reply (xid=0x0):
3655  event=ADDED table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
3656 NXST_FLOW_MONITOR reply (xid=0x0):
3657  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
3658 NXST_FLOW_MONITOR reply (xid=0x0):
3659  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
3660 NXST_FLOW_MONITOR reply (xid=0x0):
3661  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
3662 NXST_FLOW_MONITOR reply (xid=0x0):
3663  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:15
3664 NXST_FLOW_MONITOR reply (xid=0x0):
3665  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:16
3666 NXST_FLOW_MONITOR reply (xid=0x0):
3667  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:17
3668 NXST_FLOW_MONITOR reply (xid=0x0):
3669  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
3670 NXST_FLOW_MONITOR reply (xid=0x0):
3671  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
3672 NXST_FLOW_MONITOR reply (xid=0x0):
3673  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
3674 NXST_FLOW_MONITOR reply (xid=0x0):
3675  event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
3676 NXST_FLOW_MONITOR reply (xid=0x0):
3677  event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
3678 NXST_FLOW_MONITOR reply (xid=0x0):
3679  event=ADDED table=0 cookie=0 in_port=0 actions=output:23
3680 NXST_FLOW_MONITOR reply (xid=0x0):
3681  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:3
3682  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
3683  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
3684 NXST_FLOW_MONITOR reply (xid=0x0):
3685  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
3686  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
3687  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
3688 NXST_FLOW_MONITOR reply (xid=0x0):
3689  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
3690  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
3691  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
3692 NXST_FLOW_MONITOR reply (xid=0x0):
3693  event=DELETED reason=delete table=0 cookie=0 in_port=0 actions=output:23
3694  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
3695  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
3696  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
3697  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
3698  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
3699  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
3700  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
3701  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
3702  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
3703  event=DELETED reason=delete table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
3704 OFPT_BARRIER_REPLY:
3705 ])
3706
3707 # Check that our own changes are reported as full updates.
3708 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3709 ovs-ofctl add-flow br0 in_port=1,actions=output:2
3710 ovs-ofctl add-flow br0 in_port=2,actions=output:1
3711 ovs-appctl -t ovs-ofctl ofctl/barrier
3712 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
3713 ovs-appctl -t ovs-ofctl ofctl/barrier
3714 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
3715 ])
3716 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | multiline_sort], [0],
3717 [NXST_FLOW_MONITOR reply (xid=0x0):
3718  event=ADDED table=0 cookie=0 in_port=1 actions=output:2
3719 NXST_FLOW_MONITOR reply (xid=0x0):
3720  event=ADDED table=0 cookie=0 in_port=2 actions=output:1
3721 OFPT_BARRIER_REPLY:
3722 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
3723 NXST_FLOW_MONITOR reply (xid=0x0):
3724  event=DELETED reason=delete table=0 cookie=0 in_port=1 actions=output:2
3725  event=DELETED reason=delete table=0 cookie=0 in_port=2 actions=output:1
3726 OFPT_BARRIER_REPLY:
3727 ])
3728
3729 ovs-appctl -t ovs-ofctl exit
3730 OVS_VSWITCHD_STOP
3731 AT_CLEANUP
3732
3733 AT_SETUP([ofproto - flow monitoring with !own])
3734 AT_KEYWORDS([monitor])
3735 OVS_VSWITCHD_START
3736
3737 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
3738
3739 # Start a monitor watching the flow table and check the initial reply.
3740 ovs-ofctl monitor br0 watch:\!own --detach --no-chdir --pidfile >monitor.log 2>&1
3741 AT_CAPTURE_FILE([monitor.log])
3742 ovs-appctl -t ovs-ofctl ofctl/barrier
3743 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3744   [NXST_FLOW_MONITOR reply:
3745  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
3746 OFPT_BARRIER_REPLY:
3747 ])
3748
3749 # Check that our own changes are reported as abbreviations.
3750 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3751 ovs-ofctl add-flow br0 in_port=1,actions=output:2
3752 ovs-ofctl add-flow br0 in_port=2,actions=output:1
3753 ovs-appctl -t ovs-ofctl ofctl/barrier
3754 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
3755 ovs-appctl -t ovs-ofctl ofctl/barrier
3756 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
3757 ])
3758 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3759 [NXST_FLOW_MONITOR reply (xid=0x0):
3760  event=ADDED table=0 cookie=0 in_port=1 actions=output:2
3761 NXST_FLOW_MONITOR reply (xid=0x0):
3762  event=ADDED table=0 cookie=0 in_port=2 actions=output:1
3763 OFPT_BARRIER_REPLY:
3764 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
3765 NXST_FLOW_MONITOR reply (xid=0x0):
3766  event=ABBREV xid=0x12345678
3767 OFPT_BARRIER_REPLY:
3768 ])
3769
3770 ovs-appctl -t ovs-ofctl exit
3771 OVS_VSWITCHD_STOP
3772 AT_CLEANUP
3773
3774 AT_SETUP([ofproto - flow monitoring with out_port])
3775 AT_KEYWORDS([monitor])
3776 OVS_VSWITCHD_START
3777
3778 ovs-ofctl add-flow br0 in_port=0,dl_vlan=121,actions=output:1
3779 ovs-ofctl add-flow br0 in_port=0,dl_vlan=122,actions=output:1
3780 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:2
3781
3782 # Start a monitor watching the flow table and check the initial reply.
3783 ovs-ofctl monitor br0 watch:out_port=2 --detach --no-chdir --pidfile >monitor.log 2>&1
3784 AT_CAPTURE_FILE([monitor.log])
3785 ovs-appctl -t ovs-ofctl ofctl/barrier
3786 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3787   [NXST_FLOW_MONITOR reply:
3788  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:2
3789 OFPT_BARRIER_REPLY:
3790 ])
3791
3792 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3793
3794 # Add, modify flows and check the updates.
3795 ovs-ofctl mod-flows br0 dl_vlan=121,actions=drop
3796 ovs-ofctl mod-flows br0 dl_vlan=122,actions=output:1,output:2
3797 ovs-appctl -t ovs-ofctl ofctl/barrier
3798
3799 ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:1,output:2
3800 ovs-appctl -t ovs-ofctl ofctl/barrier
3801
3802 ovs-ofctl mod-flows br0 dl_vlan=122,actions=output:1
3803 ovs-appctl -t ovs-ofctl ofctl/barrier
3804 ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:2
3805 ovs-appctl -t ovs-ofctl ofctl/barrier
3806
3807 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3808 [NXST_FLOW_MONITOR reply (xid=0x0):
3809  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=122 actions=output:1,output:2
3810 OFPT_BARRIER_REPLY:
3811 NXST_FLOW_MONITOR reply (xid=0x0):
3812  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1,output:2
3813 OFPT_BARRIER_REPLY:
3814 NXST_FLOW_MONITOR reply (xid=0x0):
3815  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=122 actions=output:1
3816 OFPT_BARRIER_REPLY:
3817 NXST_FLOW_MONITOR reply (xid=0x0):
3818  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:2
3819 OFPT_BARRIER_REPLY:
3820 ])
3821
3822 ovs-appctl -t ovs-ofctl exit
3823 OVS_VSWITCHD_STOP
3824 AT_CLEANUP
3825
3826 AT_SETUP([ofproto - flow monitoring pause and resume])
3827 AT_KEYWORDS([monitor])
3828
3829 # The maximum socket receive buffer size is important for this test, which
3830 # tests behavior when the receive buffer overflows.
3831 if test -e /proc/sys/net/core/rmem_max; then
3832     # Linux
3833     rmem_max=`cat /proc/sys/net/core/rmem_max`
3834 elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
3835     : # FreeBSD, NetBSD
3836 else
3837     # Don't know how to get maximum socket receive buffer on this OS
3838     AT_SKIP_IF([:])
3839 fi
3840 # Calculate the total amount of queuing: rmem_max in the kernel, 128 kB
3841 # in ofproto sending userspace (see ofmonitor_flush() in connmgr.c).
3842 queue_size=`expr $rmem_max + 128 \* 1024`
3843 echo rmem_max=$rmem_max queue_size=$queue_size
3844
3845 # If there's too much queuing skip the test to avoid timing out.
3846 AT_SKIP_IF([test $rmem_max -gt 1048576])
3847
3848 # Each flow update message takes up at least 48 bytes of space in queues
3849 # and in practice more than that.
3850 n_msgs=`expr $queue_size / 48`
3851 echo n_msgs=$n_msgs
3852
3853 OVS_VSWITCHD_START
3854
3855 # Start a monitor watching the flow table, then make it block.
3856 on_exit 'kill `cat ovs-ofctl.pid`'
3857 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
3858 AT_CAPTURE_FILE([monitor.log])
3859 ovs-appctl -t ovs-ofctl ofctl/block
3860
3861 # Add $n_msgs flows.
3862 (echo "in_port=2,actions=output:2"
3863 ${PERL} -e '
3864     for ($i = 0; $i < '$n_msgs'; $i++) {
3865         print "cookie=1,reg1=$i,actions=drop\n";
3866     }
3867 ') > flows.txt
3868 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
3869 # Check that multipart flow dumps work properly:
3870 AT_CHECK([ovs-ofctl diff-flows br0 flows.txt])
3871 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,cookie=3,actions=drop])
3872 AT_CHECK([ovs-ofctl mod-flows br0 in_port=2,cookie=2,actions=output:2])
3873 AT_CHECK([ovs-ofctl del-flows br0 cookie=1/-1])
3874
3875 ovs-appctl -t ovs-ofctl ofctl/unblock
3876
3877 # Wait for the connection resumed.
3878 # A barrier doesn't work for this purpose.
3879 #    https://www.mail-archive.com/dev@openvswitch.org/msg27013.html
3880 #    https://www.mail-archive.com/dev@openvswitch.org/msg27675.html
3881 OVS_WAIT_UNTIL([grep NXT_FLOW_MONITOR_RESUMED monitor.log])
3882
3883 ovs-appctl -t ovs-ofctl exit
3884
3885 # Check that the flow monitor reported the same number of flows
3886 # added and deleted, but fewer than we actually added and deleted.
3887 adds=`grep -c 'ADDED.*reg1=' monitor.log`
3888 deletes=`grep -c 'DELETED.*reg1=' monitor.log`
3889 echo adds=$adds deletes=$deletes
3890 AT_CHECK([test $adds -gt 100 && test $adds -lt $n_msgs])
3891 AT_CHECK([test $adds = $deletes])
3892
3893 # Check that the flow monitor reported everything in the expected order:
3894 #
3895 #     event=ADDED table=0 cookie=0x1 reg1=0x22
3896 # ...
3897 #    NXT_FLOW_MONITOR_PAUSED:
3898 # ...
3899 #     event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
3900 # ...
3901 #     event=ADDED table=0 cookie=0x3 in_port=1
3902 #     event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
3903 #    NXT_FLOW_MONITOR_RESUMED:
3904 #
3905 # except that, between the PAUSED and RESUMED, the order of the ADDED
3906 # and MODIFIED lines lines depends on hash order, that is, it varies
3907 # as we change the hash function or change architecture.  Therefore,
3908 # we use a couple of tests below to accept both orders.
3909 AT_CHECK([ofctl_strip < monitor.log | sed -n -e '
3910 /reg1=0x22$/p
3911 /cookie=0x[[23]]/p
3912 /NXT_FLOW_MONITOR_PAUSED:/p
3913 /NXT_FLOW_MONITOR_RESUMED:/p
3914 ' > monitor.log.subset])
3915 AT_CHECK([grep -v MODIFIED monitor.log.subset], [0], [dnl
3916  event=ADDED table=0 cookie=0x1 reg1=0x22
3917 NXT_FLOW_MONITOR_PAUSED:
3918  event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
3919  event=ADDED table=0 cookie=0x3 in_port=1
3920 NXT_FLOW_MONITOR_RESUMED:
3921 ])
3922 AT_CHECK([grep -v ADDED monitor.log.subset], [0], [dnl
3923 NXT_FLOW_MONITOR_PAUSED:
3924  event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
3925  event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
3926 NXT_FLOW_MONITOR_RESUMED:
3927 ])
3928
3929 OVS_VSWITCHD_STOP
3930 AT_CLEANUP
3931
3932 AT_SETUP([ofproto - event filtering (OpenFlow 1.3)])
3933 AT_KEYWORDS([monitor])
3934 OVS_VSWITCHD_START
3935
3936 # Start a monitor, use the required protocol version
3937 ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3938 AT_CAPTURE_FILE([monitor.log])
3939
3940 # Send an OpenFlow13 message (04), OFPT_GET_ASYNC_REQUEST (1a), length (8), xid (0a)
3941 ovs-appctl -t ovs-ofctl ofctl/send 041a00080000000a
3942 ovs-appctl -t ovs-ofctl ofctl/barrier
3943
3944 # Check default setting
3945 read -r -d '' expected <<'EOF'
3946 EOF
3947
3948 AT_CHECK([ofctl_strip < monitor.log], [], [dnl
3949 send: OFPT_GET_ASYNC_REQUEST (OF1.3):
3950 OFPT_GET_ASYNC_REPLY (OF1.3):
3951  master:
3952        PACKET_IN: no_match action
3953      PORT_STATUS: add delete modify
3954     FLOW_REMOVED: idle hard delete
3955      ROLE_STATUS: (off)
3956     TABLE_STATUS: (off)
3957   REQUESTFORWARD: (off)
3958
3959  slave:
3960        PACKET_IN: (off)
3961      PORT_STATUS: add delete modify
3962     FLOW_REMOVED: (off)
3963      ROLE_STATUS: (off)
3964     TABLE_STATUS: (off)
3965   REQUESTFORWARD: (off)
3966 OFPT_BARRIER_REPLY (OF1.3):
3967 ])
3968
3969 OVS_VSWITCHD_STOP
3970 AT_CLEANUP
3971
3972 AT_SETUP([ofproto - ofport_request])
3973 OVS_VSWITCHD_START
3974 add_of_ports br0 1 2 3
3975
3976 set_and_check_specific_ofports () {
3977     ovs-vsctl set Interface p1 ofport_request="$1" -- \
3978               set Interface p2 ofport_request="$2" -- \
3979               set Interface p3 ofport_request="$3"
3980     ofports=`ovs-vsctl get Interface p1 ofport -- \
3981                        get Interface p2 ofport -- \
3982                        get Interface p3 ofport`
3983     AT_CHECK_UNQUOTED([echo $ofports], [0], [$1 $2 $3
3984 ])
3985 }
3986 for pre in      '1 2 3' '1 3 2' '2 1 3' '2 3 1' '3 1 2' '3 2 1'; do
3987     for post in '1 2 3' '1 3 2' '2 1 3' '2 3 1' '3 1 2' '3 2 1'; do
3988         echo -----------------------------------------------------------
3989         echo "Check changing port numbers from $pre to $post"
3990         set_and_check_specific_ofports $pre
3991         set_and_check_specific_ofports $post
3992     done
3993 done
3994
3995 ovs-vsctl del-port p3
3996
3997 set_and_check_poorly_specified_ofports () {
3998     ovs-vsctl set Interface p1 ofport_request="$1" -- \
3999               set Interface p2 ofport_request="$2"
4000     p1=`ovs-vsctl get Interface p1 ofport`
4001     p2=`ovs-vsctl get Interface p2 ofport`
4002     echo $p1 $p2
4003
4004     AT_CHECK([test "$p1" != "$p2"])
4005     if test "$1" = "$2" && test "$1" != '[[]]'; then
4006         # One port number must be the requested one.
4007         AT_CHECK([test "$p1" = "$1" || test "$p2" = "$1"])
4008         # The other port number must be different (already tested above).
4009     else
4010         AT_CHECK([test "$1" = '[[]]' || test "$p1" = "$1"])
4011         AT_CHECK([test "$2" = '[[]]' || test "$p2" = "$2"])
4012     fi
4013 }
4014 for pre in      '1 2' '[[]] 2' '1 [[]]' '[[]] [[]]' '2 1' '[[]] 1' '2 [[]]' \
4015                 '1 1' '2 2'; do
4016     for post in '1 2' '[[]] 2' '1 [[]]' '[[]] [[]]' '2 1' '[[]] 1' '2 [[]]' \
4017                 '1 1' '2 2'; do
4018         echo -----------------------------------------------------------
4019         echo "Check changing port numbers from $pre to $post"
4020         set_and_check_poorly_specified_ofports $pre
4021         set_and_check_poorly_specified_ofports $post
4022     done
4023 done
4024 OVS_VSWITCHD_STOP
4025 AT_CLEANUP
4026
4027
4028 AT_SETUP([ofproto - bundle open (OpenFlow 1.4)])
4029 AT_KEYWORDS([monitor])
4030 OVS_VSWITCHD_START
4031
4032 # Start a monitor, use the required protocol version
4033 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4034 AT_CAPTURE_FILE([monitor.log])
4035
4036 # Send an OpenFlow14 message (05), OFPT_BUNDLE_CONTROL (21), length (10), xid (0a)
4037 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
4038 ovs-appctl -t ovs-ofctl ofctl/barrier
4039 ovs-appctl -t ovs-ofctl exit
4040
4041 AT_CHECK([ofctl_strip < monitor.log], [], [dnl
4042 send: OFPT_BUNDLE_CONTROL (OF1.4):
4043  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4044 OFPT_BUNDLE_CONTROL (OF1.4):
4045  bundle_id=0x1 type=OPEN_REPLY flags=0
4046 OFPT_BARRIER_REPLY (OF1.4):
4047 ])
4048
4049 OVS_VSWITCHD_STOP
4050 AT_CLEANUP
4051
4052 AT_SETUP([ofproto - bundle double open (OpenFlow 1.4)])
4053 AT_KEYWORDS([monitor])
4054 OVS_VSWITCHD_START
4055
4056 # Start a monitor, use the required protocol version
4057 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4058 AT_CAPTURE_FILE([monitor.log])
4059
4060 # Send twice an OpenFlow14 message (05), OFPT_BUNDLE_CONTROL (21), length (10), xid (0a)
4061 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
4062 ovs-appctl -t ovs-ofctl ofctl/barrier
4063 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
4064 ovs-appctl -t ovs-ofctl ofctl/barrier
4065 ovs-appctl -t ovs-ofctl exit
4066
4067 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4068 send: OFPT_BUNDLE_CONTROL (OF1.4):
4069  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4070 OFPT_BUNDLE_CONTROL (OF1.4):
4071  bundle_id=0x1 type=OPEN_REPLY flags=0
4072 OFPT_BARRIER_REPLY (OF1.4):
4073 send: OFPT_BUNDLE_CONTROL (OF1.4):
4074  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4075 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
4076 OFPT_BUNDLE_CONTROL (OF1.4):
4077  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4078 OFPT_BARRIER_REPLY (OF1.4):
4079 ])
4080
4081 OVS_VSWITCHD_STOP
4082 AT_CLEANUP
4083
4084 AT_SETUP([ofproto - bundle close without open (OpenFlow 1.4)])
4085 AT_KEYWORDS([monitor])
4086 OVS_VSWITCHD_START
4087
4088 # Start a monitor, use the required protocol version
4089 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4090 AT_CAPTURE_FILE([monitor.log])
4091
4092 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 02"
4093 ovs-appctl -t ovs-ofctl ofctl/barrier
4094 ovs-appctl -t ovs-ofctl exit
4095
4096 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4097 send: OFPT_BUNDLE_CONTROL (OF1.4):
4098  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
4099 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
4100 OFPT_BUNDLE_CONTROL (OF1.4):
4101  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
4102 OFPT_BARRIER_REPLY (OF1.4):
4103 ])
4104
4105 OVS_VSWITCHD_STOP
4106 AT_CLEANUP
4107
4108 AT_SETUP([ofproto - bundle double close (OpenFlow 1.4)])
4109 AT_KEYWORDS([monitor])
4110 OVS_VSWITCHD_START
4111
4112 # Start a monitor, use the required protocol version
4113 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4114 AT_CAPTURE_FILE([monitor.log])
4115
4116 # Open, Close, Close
4117 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
4118 ovs-appctl -t ovs-ofctl ofctl/barrier
4119 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 02"
4120 ovs-appctl -t ovs-ofctl ofctl/barrier
4121 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 02"
4122 ovs-appctl -t ovs-ofctl ofctl/barrier
4123 ovs-appctl -t ovs-ofctl exit
4124
4125 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4126 send: OFPT_BUNDLE_CONTROL (OF1.4):
4127  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4128 OFPT_BUNDLE_CONTROL (OF1.4):
4129  bundle_id=0x1 type=OPEN_REPLY flags=0
4130 OFPT_BARRIER_REPLY (OF1.4):
4131 send: OFPT_BUNDLE_CONTROL (OF1.4):
4132  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
4133 OFPT_BUNDLE_CONTROL (OF1.4):
4134  bundle_id=0x1 type=CLOSE_REPLY flags=0
4135 OFPT_BARRIER_REPLY (OF1.4):
4136 send: OFPT_BUNDLE_CONTROL (OF1.4):
4137  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
4138 OFPT_ERROR (OF1.4): OFPBFC_BUNDLE_CLOSED
4139 OFPT_BUNDLE_CONTROL (OF1.4):
4140  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
4141 OFPT_BARRIER_REPLY (OF1.4):
4142 ])
4143
4144 OVS_VSWITCHD_STOP
4145 AT_CLEANUP
4146
4147 AT_SETUP([ofproto - bundle close, different flags (OpenFlow 1.4)])
4148 AT_KEYWORDS([monitor])
4149 OVS_VSWITCHD_START
4150
4151 # Start a monitor, use the required protocol version
4152 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4153 AT_CAPTURE_FILE([monitor.log])
4154
4155 # Open, Close, Close
4156 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
4157 ovs-appctl -t ovs-ofctl ofctl/barrier
4158 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 01"
4159 ovs-appctl -t ovs-ofctl ofctl/barrier
4160 ovs-appctl -t ovs-ofctl exit
4161
4162 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4163 send: OFPT_BUNDLE_CONTROL (OF1.4):
4164  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4165 OFPT_BUNDLE_CONTROL (OF1.4):
4166  bundle_id=0x1 type=OPEN_REPLY flags=0
4167 OFPT_BARRIER_REPLY (OF1.4):
4168 send: OFPT_BUNDLE_CONTROL (OF1.4):
4169  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
4170 OFPT_ERROR (OF1.4): OFPBFC_BAD_FLAGS
4171 OFPT_BUNDLE_CONTROL (OF1.4):
4172  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
4173 OFPT_BARRIER_REPLY (OF1.4):
4174 ])
4175
4176 OVS_VSWITCHD_STOP
4177 AT_CLEANUP
4178
4179 AT_SETUP([ofproto - bundle commit without open (OpenFlow 1.4)])
4180 AT_KEYWORDS([monitor])
4181 OVS_VSWITCHD_START
4182
4183 # Start a monitor, use the required protocol version
4184 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4185 AT_CAPTURE_FILE([monitor.log])
4186
4187 # Open, Close, Close
4188 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 04 00 02"
4189 ovs-appctl -t ovs-ofctl ofctl/barrier
4190 ovs-appctl -t ovs-ofctl exit
4191
4192 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4193 send: OFPT_BUNDLE_CONTROL (OF1.4):
4194  bundle_id=0x1 type=COMMIT_REQUEST flags=ordered
4195 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
4196 OFPT_BUNDLE_CONTROL (OF1.4):
4197  bundle_id=0x1 type=COMMIT_REQUEST flags=ordered
4198 OFPT_BARRIER_REPLY (OF1.4):
4199 ])
4200
4201 OVS_VSWITCHD_STOP
4202 AT_CLEANUP
4203
4204 AT_SETUP([ofproto - bundle commit, different flags (OpenFlow 1.4)])
4205 AT_KEYWORDS([monitor])
4206 OVS_VSWITCHD_START
4207
4208 # Start a monitor, use the required protocol version
4209 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4210 AT_CAPTURE_FILE([monitor.log])
4211
4212 # Open, Close, Close
4213 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
4214 ovs-appctl -t ovs-ofctl ofctl/barrier
4215 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 04 00 01"
4216 ovs-appctl -t ovs-ofctl ofctl/barrier
4217 ovs-appctl -t ovs-ofctl exit
4218
4219 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4220 send: OFPT_BUNDLE_CONTROL (OF1.4):
4221  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4222 OFPT_BUNDLE_CONTROL (OF1.4):
4223  bundle_id=0x1 type=OPEN_REPLY flags=0
4224 OFPT_BARRIER_REPLY (OF1.4):
4225 send: OFPT_BUNDLE_CONTROL (OF1.4):
4226  bundle_id=0x1 type=COMMIT_REQUEST flags=atomic
4227 OFPT_ERROR (OF1.4): OFPBFC_BAD_FLAGS
4228 OFPT_BUNDLE_CONTROL (OF1.4):
4229  bundle_id=0x1 type=COMMIT_REQUEST flags=atomic
4230 OFPT_BARRIER_REPLY (OF1.4):
4231 ])
4232
4233 OVS_VSWITCHD_STOP
4234 AT_CLEANUP
4235
4236 AT_SETUP([ofproto - bundle discard without open (OpenFlow 1.4)])
4237 AT_KEYWORDS([monitor])
4238 OVS_VSWITCHD_START
4239
4240 # Start a monitor, use the required protocol version
4241 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4242 AT_CAPTURE_FILE([monitor.log])
4243
4244 # Open, Close, Close
4245 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 06 00 02"
4246 ovs-appctl -t ovs-ofctl ofctl/barrier
4247 ovs-appctl -t ovs-ofctl exit
4248
4249 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4250 send: OFPT_BUNDLE_CONTROL (OF1.4):
4251  bundle_id=0x1 type=DISCARD_REQUEST flags=ordered
4252 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
4253 OFPT_BUNDLE_CONTROL (OF1.4):
4254  bundle_id=0x1 type=DISCARD_REQUEST flags=ordered
4255 OFPT_BARRIER_REPLY (OF1.4):
4256 ])
4257
4258 OVS_VSWITCHD_STOP
4259 AT_CLEANUP
4260
4261
4262 AT_SETUP([ofproto - bundle with multiple flow mods (OpenFlow 1.4)])
4263 AT_KEYWORDS([monitor])
4264 OVS_VSWITCHD_START
4265
4266 AT_CHECK([ovs-appctl vlog/set vconn:dbg])
4267
4268 AT_CHECK([ovs-ofctl del-flows br0])
4269
4270 AT_DATA([flows.txt], [dnl
4271 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=1
4272 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=2
4273 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=3
4274 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=4
4275 delete
4276 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=5
4277 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=6
4278 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=7
4279 delete in_port=2 dl_src=00:88:99:aa:bb:cc
4280 ])
4281
4282 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
4283
4284 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4285  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:5
4286  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:6
4287 NXST_FLOW reply:
4288 ])
4289
4290 AT_DATA([flows.txt], [dnl
4291 modify actions=drop
4292 modify_strict in_port=2 dl_src=00:77:88:99:aa:bb actions=7
4293 ])
4294
4295 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
4296
4297 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4298  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4299  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:7
4300 NXST_FLOW reply:
4301 ])
4302
4303 # Adding an existing flow acts as a modify, and delete_strict also works.
4304 AT_DATA([flows.txt], [dnl
4305 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=8
4306 delete_strict in_port=2 dl_src=00:66:77:88:99:aa
4307 add in_port=2 dl_src=00:66:77:88:99:aa actions=drop
4308 ])
4309
4310 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
4311
4312 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4313  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:8
4314  in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4315 NXST_FLOW reply:
4316 ])
4317
4318 dnl Check logs for OpenFlow trace
4319 # Prevent race.
4320 OVS_WAIT_UNTIL([vconn_sub < ovs-vswitchd.log | test `grep -- "|vconn|DBG|unix: sent (Success): NXST_FLOW reply" | wc -l` -ge 3])
4321 AT_CHECK([print_vconn_debug | vconn_sub | ofctl_strip], [0], [dnl
4322 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4323  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4324 vconn|DBG|unix: received: OFPT_HELLO:
4325  version bitmap: 0x01
4326 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4327 vconn|DBG|unix: received: OFPT_FLOW_MOD: DEL actions=drop
4328 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4329 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4330 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4331  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4332 vconn|DBG|unix: received: OFPT_HELLO (OF1.4):
4333  version bitmap: 0x05
4334 vconn|DBG|unix: negotiated OpenFlow version 0x05 (we support version 0x06 and earlier, peer supports version 0x05)
4335 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4336  bundle_id=0 type=OPEN_REQUEST flags=atomic ordered
4337 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4338  bundle_id=0 type=OPEN_REPLY flags=0
4339 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4340  bundle_id=0 flags=atomic ordered
4341 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:66:77:88:99:aa idle:50 actions=output:1
4342 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4343  bundle_id=0 flags=atomic ordered
4344 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:77:88:99:aa:bb idle:60 actions=output:2
4345 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4346  bundle_id=0 flags=atomic ordered
4347 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:88:99:aa:bb:cc idle:70 actions=output:3
4348 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4349  bundle_id=0 flags=atomic ordered
4350 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:66:77:88:99:aa idle:50 actions=output:4
4351 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4352  bundle_id=0 flags=atomic ordered
4353 OFPT_FLOW_MOD (OF1.4): DEL table:255 actions=drop
4354 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4355  bundle_id=0 flags=atomic ordered
4356 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:66:77:88:99:aa idle:50 actions=output:5
4357 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4358  bundle_id=0 flags=atomic ordered
4359 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:77:88:99:aa:bb idle:60 actions=output:6
4360 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4361  bundle_id=0 flags=atomic ordered
4362 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:88:99:aa:bb:cc idle:70 actions=output:7
4363 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4364  bundle_id=0 flags=atomic ordered
4365 OFPT_FLOW_MOD (OF1.4): DEL table:255 in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
4366 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4367  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4368 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4369  bundle_id=0 type=COMMIT_REPLY flags=0
4370 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4371  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4372 vconn|DBG|unix: received: OFPT_HELLO:
4373  version bitmap: 0x01
4374 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4375 vconn|DBG|unix: received: NXT_SET_FLOW_FORMAT: format=nxm
4376 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4377 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4378 vconn|DBG|unix: received: NXST_FLOW request:
4379 vconn|DBG|unix: sent (Success): NXST_FLOW reply:
4380  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:5
4381  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:6
4382 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4383  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4384 vconn|DBG|unix: received: OFPT_HELLO (OF1.4):
4385  version bitmap: 0x05
4386 vconn|DBG|unix: negotiated OpenFlow version 0x05 (we support version 0x06 and earlier, peer supports version 0x05)
4387 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4388  bundle_id=0 type=OPEN_REQUEST flags=atomic ordered
4389 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4390  bundle_id=0 type=OPEN_REPLY flags=0
4391 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4392  bundle_id=0 flags=atomic ordered
4393 OFPT_FLOW_MOD (OF1.4): MOD actions=drop
4394 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4395  bundle_id=0 flags=atomic ordered
4396 OFPT_FLOW_MOD (OF1.4): MOD_STRICT in_port=2,dl_src=00:77:88:99:aa:bb actions=output:7
4397 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4398  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4399 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4400  bundle_id=0 type=COMMIT_REPLY flags=0
4401 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4402  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4403 vconn|DBG|unix: received: OFPT_HELLO:
4404  version bitmap: 0x01
4405 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4406 vconn|DBG|unix: received: NXT_SET_FLOW_FORMAT: format=nxm
4407 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4408 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4409 vconn|DBG|unix: received: NXST_FLOW request:
4410 vconn|DBG|unix: sent (Success): NXST_FLOW reply:
4411  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4412  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:7
4413 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4414  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4415 vconn|DBG|unix: received: OFPT_HELLO (OF1.4):
4416  version bitmap: 0x05
4417 vconn|DBG|unix: negotiated OpenFlow version 0x05 (we support version 0x06 and earlier, peer supports version 0x05)
4418 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4419  bundle_id=0 type=OPEN_REQUEST flags=atomic ordered
4420 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4421  bundle_id=0 type=OPEN_REPLY flags=0
4422 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4423  bundle_id=0 flags=atomic ordered
4424 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:77:88:99:aa:bb idle:60 actions=output:8
4425 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4426  bundle_id=0 flags=atomic ordered
4427 OFPT_FLOW_MOD (OF1.4): DEL_STRICT table:255 in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4428 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4429  bundle_id=0 flags=atomic ordered
4430 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4431 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4432  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4433 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4434  bundle_id=0 type=COMMIT_REPLY flags=0
4435 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4436  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4437 vconn|DBG|unix: received: OFPT_HELLO:
4438  version bitmap: 0x01
4439 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4440 vconn|DBG|unix: received: NXT_SET_FLOW_FORMAT: format=nxm
4441 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4442 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4443 vconn|DBG|unix: received: NXST_FLOW request: 
4444 vconn|DBG|unix: sent (Success): NXST_FLOW reply:
4445  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:8
4446  in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4447 ])
4448
4449 OVS_VSWITCHD_STOP
4450 AT_CLEANUP
4451
4452
4453 AT_SETUP([ofproto - failing bundle commit (OpenFlow 1.4)])
4454 AT_KEYWORDS([monitor])
4455 OVS_VSWITCHD_START
4456
4457 AT_CHECK([ovs-ofctl del-flows br0])
4458
4459 ovs-ofctl add-flows br0 - <<EOF
4460 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=11
4461 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=22
4462 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=33
4463 EOF
4464 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4465  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:11
4466  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:22
4467  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=output:33
4468 NXST_FLOW reply:
4469 ])
4470
4471 # last line uses illegal table number (OVS internal table)
4472 AT_DATA([flows.txt], [dnl
4473 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=1
4474 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=2
4475 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=3
4476 modify idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=4
4477 delete
4478 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=5
4479 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=6
4480 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=7
4481 delete in_port=2 dl_src=00:88:99:aa:bb:cc
4482 add table=254 actions=drop
4483 ])
4484
4485 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt 2>&1 | sed '/|WARN|/d
4486 s/unix:.*br0\.mgmt/unix:br0.mgmt/' | sed 's/(.* error)/(error)/'],
4487 [0], [dnl
4488 OFPT_ERROR (OF1.4) (xid=0xb): OFPBRC_EPERM
4489 OFPT_FLOW_MOD (OF1.4) (xid=0xb): ADD table:254 actions=drop
4490 OFPT_ERROR (OF1.4) (xid=0xd): OFPBFC_MSG_FAILED
4491 OFPT_BUNDLE_CONTROL (OF1.4) (xid=0xd):
4492  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4493 ovs-ofctl: talking to unix:br0.mgmt (error)
4494 ])
4495
4496 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4497  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:11
4498  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:22
4499  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=output:33
4500 NXST_FLOW reply:
4501 ])
4502
4503 OVS_VSWITCHD_STOP
4504 AT_CLEANUP
4505
4506
4507 AT_SETUP([ofproto - bundle open (OpenFlow 1.3)])
4508 AT_KEYWORDS([monitor])
4509 OVS_VSWITCHD_START
4510
4511 # Start a monitor, use the required protocol version
4512 ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4513 AT_CAPTURE_FILE([monitor.log])
4514
4515 # Send an OpenFlow13 message (04), OFPT_EXPERIMENTER (04), length (0018),
4516 # xid (0000000a), ONF_EXPERIMENTER_ID (4F4E4600),
4517 # ONFT_BUNDLE_CONTROL (2300 = 0x08FC), bundle id (00000001),
4518 # message type (0000), and flags (0002)
4519 ovs-appctl -t ovs-ofctl ofctl/send "04 04 00 18 00 00 00 0a 4F 4E 46 00 00 00 08 FC 00 00 00 01 00 00 00 02"
4520 ovs-appctl -t ovs-ofctl ofctl/barrier
4521 ovs-appctl -t ovs-ofctl exit
4522
4523 AT_CHECK([ofctl_strip < monitor.log], [], [dnl
4524 send: ONFT_BUNDLE_CONTROL (OF1.3):
4525  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4526 ONFT_BUNDLE_CONTROL (OF1.3):
4527  bundle_id=0x1 type=OPEN_REPLY flags=0
4528 OFPT_BARRIER_REPLY (OF1.3):
4529 ])
4530
4531 OVS_VSWITCHD_STOP
4532 AT_CLEANUP
4533
4534 AT_SETUP([ofproto - bundle double open (OpenFlow 1.3)])
4535 AT_KEYWORDS([monitor])
4536 OVS_VSWITCHD_START
4537
4538 # Start a monitor, use the required protocol version
4539 ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4540 AT_CAPTURE_FILE([monitor.log])
4541
4542 # Send twice an OpenFlow13 message (04), OFPT_EXPERIMENTER (04), length (0018),
4543 # xid (0000000a), ONF_EXPERIMENTER_ID (4F4E4600),
4544 # ONFT_BUNDLE_CONTROL (2300 = 0x08FC), bundle id (00000001),
4545 # message type (0000), and flags (0002)
4546 ovs-appctl -t ovs-ofctl ofctl/send "04 04 00 18 00 00 00 0a 4F 4E 46 00 00 00 08 FC 00 00 00 01 00 00 00 02"
4547 ovs-appctl -t ovs-ofctl ofctl/barrier
4548 ovs-appctl -t ovs-ofctl ofctl/send "04 04 00 18 00 00 00 0a 4F 4E 46 00 00 00 08 FC 00 00 00 01 00 00 00 02"
4549 ovs-appctl -t ovs-ofctl ofctl/barrier
4550 ovs-appctl -t ovs-ofctl exit
4551
4552 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4553 send: ONFT_BUNDLE_CONTROL (OF1.3):
4554  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4555 ONFT_BUNDLE_CONTROL (OF1.3):
4556  bundle_id=0x1 type=OPEN_REPLY flags=0
4557 OFPT_BARRIER_REPLY (OF1.3):
4558 send: ONFT_BUNDLE_CONTROL (OF1.3):
4559  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4560 OFPT_ERROR (OF1.3): OFPBFC_BAD_ID
4561 ONFT_BUNDLE_CONTROL (OF1.3):
4562  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4563 OFPT_BARRIER_REPLY (OF1.3):
4564 ])
4565
4566 OVS_VSWITCHD_STOP
4567 AT_CLEANUP
4568
4569 AT_SETUP([ofproto - bundle close without open (OpenFlow 1.3)])
4570 AT_KEYWORDS([monitor])
4571 OVS_VSWITCHD_START
4572
4573 # Start a monitor, use the required protocol version
4574 ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4575 AT_CAPTURE_FILE([monitor.log])
4576
4577 ovs-appctl -t ovs-ofctl ofctl/send "04 04 00 18 00 00 00 0a 4F 4E 46 00 00 00 08 FC 00 00 00 01 00 02 00 02"
4578 ovs-appctl -t ovs-ofctl ofctl/barrier
4579 ovs-appctl -t ovs-ofctl exit
4580
4581 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4582 send: ONFT_BUNDLE_CONTROL (OF1.3):
4583  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
4584 OFPT_ERROR (OF1.3): OFPBFC_BAD_ID
4585 ONFT_BUNDLE_CONTROL (OF1.3):
4586  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
4587 OFPT_BARRIER_REPLY (OF1.3):
4588 ])
4589
4590 OVS_VSWITCHD_STOP
4591 AT_CLEANUP
4592
4593 AT_SETUP([ofproto - bundle double close (OpenFlow 1.3)])
4594 AT_KEYWORDS([monitor])
4595 OVS_VSWITCHD_START
4596
4597 # Start a monitor, use the required protocol version
4598 ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4599 AT_CAPTURE_FILE([monitor.log])
4600
4601 # Open, Close, Close
4602 ovs-appctl -t ovs-ofctl ofctl/send "04 04 00 18 00 00 00 0a 4F 4E 46 00 00 00 08 FC 00 00 00 01 00 00 00 02"
4603 ovs-appctl -t ovs-ofctl ofctl/barrier
4604 ovs-appctl -t ovs-ofctl ofctl/send "04 04 00 18 00 00 00 0a 4F 4E 46 00 00 00 08 FC 00 00 00 01 00 02 00 02"
4605 ovs-appctl -t ovs-ofctl ofctl/barrier
4606 ovs-appctl -t ovs-ofctl ofctl/send "04 04 00 18 00 00 00 0a 4F 4E 46 00 00 00 08 FC 00 00 00 01 00 02 00 02"
4607 ovs-appctl -t ovs-ofctl ofctl/barrier
4608 ovs-appctl -t ovs-ofctl exit
4609
4610 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4611 send: ONFT_BUNDLE_CONTROL (OF1.3):
4612  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4613 ONFT_BUNDLE_CONTROL (OF1.3):
4614  bundle_id=0x1 type=OPEN_REPLY flags=0
4615 OFPT_BARRIER_REPLY (OF1.3):
4616 send: ONFT_BUNDLE_CONTROL (OF1.3):
4617  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
4618 ONFT_BUNDLE_CONTROL (OF1.3):
4619  bundle_id=0x1 type=CLOSE_REPLY flags=0
4620 OFPT_BARRIER_REPLY (OF1.3):
4621 send: ONFT_BUNDLE_CONTROL (OF1.3):
4622  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
4623 OFPT_ERROR (OF1.3): OFPBFC_BUNDLE_CLOSED
4624 ONFT_BUNDLE_CONTROL (OF1.3):
4625  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
4626 OFPT_BARRIER_REPLY (OF1.3):
4627 ])
4628
4629 OVS_VSWITCHD_STOP
4630 AT_CLEANUP
4631
4632 AT_SETUP([ofproto - bundle close, different flags (OpenFlow 1.3)])
4633 AT_KEYWORDS([monitor])
4634 OVS_VSWITCHD_START
4635
4636 # Start a monitor, use the required protocol version
4637 ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4638 AT_CAPTURE_FILE([monitor.log])
4639
4640 # Open, Close
4641 ovs-appctl -t ovs-ofctl ofctl/send "04 04 00 18 00 00 00 0a 4F 4E 46 00 00 00 08 FC 00 00 00 01 00 00 00 02"
4642 ovs-appctl -t ovs-ofctl ofctl/barrier
4643 ovs-appctl -t ovs-ofctl ofctl/send "04 04 00 18 00 00 00 0a 4F 4E 46 00 00 00 08 FC 00 00 00 01 00 02 00 01"
4644 ovs-appctl -t ovs-ofctl ofctl/barrier
4645 ovs-appctl -t ovs-ofctl exit
4646
4647 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4648 send: ONFT_BUNDLE_CONTROL (OF1.3):
4649  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4650 ONFT_BUNDLE_CONTROL (OF1.3):
4651  bundle_id=0x1 type=OPEN_REPLY flags=0
4652 OFPT_BARRIER_REPLY (OF1.3):
4653 send: ONFT_BUNDLE_CONTROL (OF1.3):
4654  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
4655 OFPT_ERROR (OF1.3): OFPBFC_BAD_FLAGS
4656 ONFT_BUNDLE_CONTROL (OF1.3):
4657  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
4658 OFPT_BARRIER_REPLY (OF1.3):
4659 ])
4660
4661 OVS_VSWITCHD_STOP
4662 AT_CLEANUP
4663
4664 AT_SETUP([ofproto - bundle commit without open (OpenFlow 1.3)])
4665 AT_KEYWORDS([monitor])
4666 OVS_VSWITCHD_START
4667
4668 # Start a monitor, use the required protocol version
4669 ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4670 AT_CAPTURE_FILE([monitor.log])
4671
4672 # Commit
4673 ovs-appctl -t ovs-ofctl ofctl/send "04 04 00 18 00 00 00 0a 4F 4E 46 00 00 00 08 FC 00 00 00 01 00 04 00 02"
4674 ovs-appctl -t ovs-ofctl ofctl/barrier
4675 ovs-appctl -t ovs-ofctl exit
4676
4677 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4678 send: ONFT_BUNDLE_CONTROL (OF1.3):
4679  bundle_id=0x1 type=COMMIT_REQUEST flags=ordered
4680 OFPT_ERROR (OF1.3): OFPBFC_BAD_ID
4681 ONFT_BUNDLE_CONTROL (OF1.3):
4682  bundle_id=0x1 type=COMMIT_REQUEST flags=ordered
4683 OFPT_BARRIER_REPLY (OF1.3):
4684 ])
4685
4686 OVS_VSWITCHD_STOP
4687 AT_CLEANUP
4688
4689 AT_SETUP([ofproto - bundle commit, different flags (OpenFlow 1.3)])
4690 AT_KEYWORDS([monitor])
4691 OVS_VSWITCHD_START
4692
4693 # Start a monitor, use the required protocol version
4694 ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4695 AT_CAPTURE_FILE([monitor.log])
4696
4697 # Open, Commit
4698 ovs-appctl -t ovs-ofctl ofctl/send "04 04 00 18 00 00 00 0a 4F 4E 46 00 00 00 08 FC 00 00 00 01 00 00 00 02"
4699 ovs-appctl -t ovs-ofctl ofctl/barrier
4700 ovs-appctl -t ovs-ofctl ofctl/send "04 04 00 18 00 00 00 0a 4F 4E 46 00 00 00 08 FC 00 00 00 01 00 04 00 01"
4701 ovs-appctl -t ovs-ofctl ofctl/barrier
4702 ovs-appctl -t ovs-ofctl exit
4703
4704 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4705 send: ONFT_BUNDLE_CONTROL (OF1.3):
4706  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4707 ONFT_BUNDLE_CONTROL (OF1.3):
4708  bundle_id=0x1 type=OPEN_REPLY flags=0
4709 OFPT_BARRIER_REPLY (OF1.3):
4710 send: ONFT_BUNDLE_CONTROL (OF1.3):
4711  bundle_id=0x1 type=COMMIT_REQUEST flags=atomic
4712 OFPT_ERROR (OF1.3): OFPBFC_BAD_FLAGS
4713 ONFT_BUNDLE_CONTROL (OF1.3):
4714  bundle_id=0x1 type=COMMIT_REQUEST flags=atomic
4715 OFPT_BARRIER_REPLY (OF1.3):
4716 ])
4717
4718 OVS_VSWITCHD_STOP
4719 AT_CLEANUP
4720
4721 AT_SETUP([ofproto - bundle discard without open (OpenFlow 1.3)])
4722 AT_KEYWORDS([monitor])
4723 OVS_VSWITCHD_START
4724
4725 # Start a monitor, use the required protocol version
4726 ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4727 AT_CAPTURE_FILE([monitor.log])
4728
4729 # Discard
4730 ovs-appctl -t ovs-ofctl ofctl/send "04 04 00 18 00 00 00 0a 4F 4E 46 00 00 00 08 FC 00 00 00 01 00 06 00 02"
4731 ovs-appctl -t ovs-ofctl ofctl/barrier
4732 ovs-appctl -t ovs-ofctl exit
4733
4734 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4735 send: ONFT_BUNDLE_CONTROL (OF1.3):
4736  bundle_id=0x1 type=DISCARD_REQUEST flags=ordered
4737 OFPT_ERROR (OF1.3): OFPBFC_BAD_ID
4738 ONFT_BUNDLE_CONTROL (OF1.3):
4739  bundle_id=0x1 type=DISCARD_REQUEST flags=ordered
4740 OFPT_BARRIER_REPLY (OF1.3):
4741 ])
4742
4743 OVS_VSWITCHD_STOP
4744 AT_CLEANUP
4745
4746
4747 AT_SETUP([ofproto - bundle with multiple flow mods (OpenFlow 1.3)])
4748 AT_KEYWORDS([monitor])
4749 OVS_VSWITCHD_START
4750
4751 AT_CHECK([ovs-appctl vlog/set vconn:dbg])
4752
4753 AT_CHECK([ovs-ofctl del-flows br0])
4754
4755 AT_DATA([flows.txt], [dnl
4756 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=1
4757 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=2
4758 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=3
4759 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=4
4760 delete
4761 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=5
4762 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=6
4763 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=7
4764 delete in_port=2 dl_src=00:88:99:aa:bb:cc
4765 ])
4766
4767 AT_CHECK([ovs-ofctl -O OpenFlow13 --bundle add-flows br0 flows.txt])
4768
4769 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4770  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:5
4771  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:6
4772 NXST_FLOW reply:
4773 ])
4774
4775 AT_DATA([flows.txt], [dnl
4776 modify actions=drop
4777 modify_strict in_port=2 dl_src=00:77:88:99:aa:bb actions=7
4778 ])
4779
4780 AT_CHECK([ovs-ofctl -O OpenFlow13 --bundle add-flows br0 flows.txt])
4781
4782 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4783  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4784  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:7
4785 NXST_FLOW reply:
4786 ])
4787
4788 # Adding an existing flow acts as a modify, and delete_strict also works.
4789 AT_DATA([flows.txt], [dnl
4790 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=8
4791 delete_strict in_port=2 dl_src=00:66:77:88:99:aa
4792 add in_port=2 dl_src=00:66:77:88:99:aa actions=drop
4793 ])
4794
4795 AT_CHECK([ovs-ofctl -O OpenFlow13 --bundle add-flows br0 flows.txt])
4796
4797 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4798  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:8
4799  in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4800 NXST_FLOW reply:
4801 ])
4802
4803 dnl Check logs for OpenFlow trace
4804 # Prevent race.
4805 OVS_WAIT_UNTIL([vconn_sub < ovs-vswitchd.log | test `grep -- "|vconn|DBG|unix: sent (Success): NXST_FLOW reply" | wc -l` -ge 3])
4806 AT_CHECK([print_vconn_debug | vconn_sub | ofctl_strip], [0], [dnl
4807 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4808  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4809 vconn|DBG|unix: received: OFPT_HELLO:
4810  version bitmap: 0x01
4811 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4812 vconn|DBG|unix: received: OFPT_FLOW_MOD: DEL actions=drop
4813 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4814 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4815 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4816  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4817 vconn|DBG|unix: received: OFPT_HELLO (OF1.3):
4818  version bitmap: 0x04
4819 vconn|DBG|unix: negotiated OpenFlow version 0x04 (we support version 0x06 and earlier, peer supports version 0x04)
4820 vconn|DBG|unix: received: ONFT_BUNDLE_CONTROL (OF1.3):
4821  bundle_id=0 type=OPEN_REQUEST flags=atomic ordered
4822 vconn|DBG|unix: sent (Success): ONFT_BUNDLE_CONTROL (OF1.3):
4823  bundle_id=0 type=OPEN_REPLY flags=0
4824 vconn|DBG|unix: received: ONFT_BUNDLE_ADD_MESSAGE (OF1.3):
4825  bundle_id=0 flags=atomic ordered
4826 OFPT_FLOW_MOD (OF1.3): ADD in_port=2,dl_src=00:66:77:88:99:aa idle:50 actions=output:1
4827 vconn|DBG|unix: received: ONFT_BUNDLE_ADD_MESSAGE (OF1.3):
4828  bundle_id=0 flags=atomic ordered
4829 OFPT_FLOW_MOD (OF1.3): ADD in_port=2,dl_src=00:77:88:99:aa:bb idle:60 actions=output:2
4830 vconn|DBG|unix: received: ONFT_BUNDLE_ADD_MESSAGE (OF1.3):
4831  bundle_id=0 flags=atomic ordered
4832 OFPT_FLOW_MOD (OF1.3): ADD in_port=2,dl_src=00:88:99:aa:bb:cc idle:70 actions=output:3
4833 vconn|DBG|unix: received: ONFT_BUNDLE_ADD_MESSAGE (OF1.3):
4834  bundle_id=0 flags=atomic ordered
4835 OFPT_FLOW_MOD (OF1.3): ADD in_port=2,dl_src=00:66:77:88:99:aa idle:50 actions=output:4
4836 vconn|DBG|unix: received: ONFT_BUNDLE_ADD_MESSAGE (OF1.3):
4837  bundle_id=0 flags=atomic ordered
4838 OFPT_FLOW_MOD (OF1.3): DEL table:255 actions=drop
4839 vconn|DBG|unix: received: ONFT_BUNDLE_ADD_MESSAGE (OF1.3):
4840  bundle_id=0 flags=atomic ordered
4841 OFPT_FLOW_MOD (OF1.3): ADD in_port=2,dl_src=00:66:77:88:99:aa idle:50 actions=output:5
4842 vconn|DBG|unix: received: ONFT_BUNDLE_ADD_MESSAGE (OF1.3):
4843  bundle_id=0 flags=atomic ordered
4844 OFPT_FLOW_MOD (OF1.3): ADD in_port=2,dl_src=00:77:88:99:aa:bb idle:60 actions=output:6
4845 vconn|DBG|unix: received: ONFT_BUNDLE_ADD_MESSAGE (OF1.3):
4846  bundle_id=0 flags=atomic ordered
4847 OFPT_FLOW_MOD (OF1.3): ADD in_port=2,dl_src=00:88:99:aa:bb:cc idle:70 actions=output:7
4848 vconn|DBG|unix: received: ONFT_BUNDLE_ADD_MESSAGE (OF1.3):
4849  bundle_id=0 flags=atomic ordered
4850 OFPT_FLOW_MOD (OF1.3): DEL table:255 in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
4851 vconn|DBG|unix: received: ONFT_BUNDLE_CONTROL (OF1.3):
4852  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4853 vconn|DBG|unix: sent (Success): ONFT_BUNDLE_CONTROL (OF1.3):
4854  bundle_id=0 type=COMMIT_REPLY flags=0
4855 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4856  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4857 vconn|DBG|unix: received: OFPT_HELLO:
4858  version bitmap: 0x01
4859 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4860 vconn|DBG|unix: received: NXT_SET_FLOW_FORMAT: format=nxm
4861 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4862 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4863 vconn|DBG|unix: received: NXST_FLOW request:
4864 vconn|DBG|unix: sent (Success): NXST_FLOW reply:
4865  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:5
4866  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:6
4867 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4868  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4869 vconn|DBG|unix: received: OFPT_HELLO (OF1.3):
4870  version bitmap: 0x04
4871 vconn|DBG|unix: negotiated OpenFlow version 0x04 (we support version 0x06 and earlier, peer supports version 0x04)
4872 vconn|DBG|unix: received: ONFT_BUNDLE_CONTROL (OF1.3):
4873  bundle_id=0 type=OPEN_REQUEST flags=atomic ordered
4874 vconn|DBG|unix: sent (Success): ONFT_BUNDLE_CONTROL (OF1.3):
4875  bundle_id=0 type=OPEN_REPLY flags=0
4876 vconn|DBG|unix: received: ONFT_BUNDLE_ADD_MESSAGE (OF1.3):
4877  bundle_id=0 flags=atomic ordered
4878 OFPT_FLOW_MOD (OF1.3): MOD actions=drop
4879 vconn|DBG|unix: received: ONFT_BUNDLE_ADD_MESSAGE (OF1.3):
4880  bundle_id=0 flags=atomic ordered
4881 OFPT_FLOW_MOD (OF1.3): MOD_STRICT in_port=2,dl_src=00:77:88:99:aa:bb actions=output:7
4882 vconn|DBG|unix: received: ONFT_BUNDLE_CONTROL (OF1.3):
4883  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4884 vconn|DBG|unix: sent (Success): ONFT_BUNDLE_CONTROL (OF1.3):
4885  bundle_id=0 type=COMMIT_REPLY flags=0
4886 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4887  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4888 vconn|DBG|unix: received: OFPT_HELLO:
4889  version bitmap: 0x01
4890 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4891 vconn|DBG|unix: received: NXT_SET_FLOW_FORMAT: format=nxm
4892 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4893 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4894 vconn|DBG|unix: received: NXST_FLOW request:
4895 vconn|DBG|unix: sent (Success): NXST_FLOW reply:
4896  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4897  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:7
4898 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4899  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4900 vconn|DBG|unix: received: OFPT_HELLO (OF1.3):
4901  version bitmap: 0x04
4902 vconn|DBG|unix: negotiated OpenFlow version 0x04 (we support version 0x06 and earlier, peer supports version 0x04)
4903 vconn|DBG|unix: received: ONFT_BUNDLE_CONTROL (OF1.3):
4904  bundle_id=0 type=OPEN_REQUEST flags=atomic ordered
4905 vconn|DBG|unix: sent (Success): ONFT_BUNDLE_CONTROL (OF1.3):
4906  bundle_id=0 type=OPEN_REPLY flags=0
4907 vconn|DBG|unix: received: ONFT_BUNDLE_ADD_MESSAGE (OF1.3):
4908  bundle_id=0 flags=atomic ordered
4909 OFPT_FLOW_MOD (OF1.3): ADD in_port=2,dl_src=00:77:88:99:aa:bb idle:60 actions=output:8
4910 vconn|DBG|unix: received: ONFT_BUNDLE_ADD_MESSAGE (OF1.3):
4911  bundle_id=0 flags=atomic ordered
4912 OFPT_FLOW_MOD (OF1.3): DEL_STRICT table:255 in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4913 vconn|DBG|unix: received: ONFT_BUNDLE_ADD_MESSAGE (OF1.3):
4914  bundle_id=0 flags=atomic ordered
4915 OFPT_FLOW_MOD (OF1.3): ADD in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4916 vconn|DBG|unix: received: ONFT_BUNDLE_CONTROL (OF1.3):
4917  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4918 vconn|DBG|unix: sent (Success): ONFT_BUNDLE_CONTROL (OF1.3):
4919  bundle_id=0 type=COMMIT_REPLY flags=0
4920 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4921  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4922 vconn|DBG|unix: received: OFPT_HELLO:
4923  version bitmap: 0x01
4924 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4925 vconn|DBG|unix: received: NXT_SET_FLOW_FORMAT: format=nxm
4926 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4927 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4928 vconn|DBG|unix: received: NXST_FLOW request: 
4929 vconn|DBG|unix: sent (Success): NXST_FLOW reply:
4930  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:8
4931  in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4932 ])
4933
4934 OVS_VSWITCHD_STOP
4935 AT_CLEANUP
4936
4937
4938 AT_SETUP([ofproto - failing bundle commit (OpenFlow 1.3)])
4939 AT_KEYWORDS([monitor])
4940 OVS_VSWITCHD_START
4941
4942 AT_CHECK([ovs-ofctl del-flows br0])
4943
4944 ovs-ofctl add-flows br0 - <<EOF
4945 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=11
4946 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=22
4947 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=33
4948 EOF
4949 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4950  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:11
4951  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:22
4952  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=output:33
4953 NXST_FLOW reply:
4954 ])
4955
4956 # last line uses illegal table number (OVS internal table)
4957 AT_DATA([flows.txt], [dnl
4958 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=1
4959 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=2
4960 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=3
4961 modify idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=4
4962 delete
4963 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=5
4964 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=6
4965 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=7
4966 delete in_port=2 dl_src=00:88:99:aa:bb:cc
4967 add table=254 actions=drop
4968 ])
4969
4970 AT_CHECK([ovs-ofctl -O OpenFlow13 --bundle add-flows br0 flows.txt 2>&1 | sed '/|WARN|/d
4971 s/unix:.*br0\.mgmt/unix:br0.mgmt/' | sed 's/(.* error)/(error)/'],
4972 [0], [dnl
4973 OFPT_ERROR (OF1.3) (xid=0xb): OFPBRC_EPERM
4974 OFPT_FLOW_MOD (OF1.3) (xid=0xb): ADD table:254 actions=drop
4975 OFPT_ERROR (OF1.3) (xid=0xd): OFPBFC_MSG_FAILED
4976 ONFT_BUNDLE_CONTROL (OF1.3) (xid=0xd):
4977  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4978 ovs-ofctl: talking to unix:br0.mgmt (error)
4979 ])
4980
4981 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4982  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:11
4983  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:22
4984  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=output:33
4985 NXST_FLOW reply:
4986 ])
4987
4988 OVS_VSWITCHD_STOP
4989 AT_CLEANUP