Implement OFPT_TABLE_STATUS Message.
[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 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       ip_src: arbitrary mask
1888       ip_dst: arbitrary mask
1889       ipv6_src: arbitrary mask
1890       ipv6_dst: arbitrary mask
1891       ipv6_label: arbitrary mask
1892       nw_proto: exact match or wildcard
1893       nw_tos: exact match or wildcard
1894       ip_dscp: exact match or wildcard
1895       nw_ecn: exact match or wildcard
1896       nw_ttl: exact match or wildcard
1897       ip_frag: arbitrary mask
1898       arp_op: exact match or wildcard
1899       arp_spa: arbitrary mask
1900       arp_tpa: arbitrary mask
1901       arp_sha: arbitrary mask
1902       arp_tha: arbitrary mask
1903       tcp_src: arbitrary mask
1904       tcp_dst: arbitrary mask
1905       tcp_flags: arbitrary mask
1906       udp_src: arbitrary mask
1907       udp_dst: arbitrary mask
1908       sctp_src: arbitrary mask
1909       sctp_dst: arbitrary mask
1910       icmp_type: exact match or wildcard
1911       icmp_code: exact match or wildcard
1912       icmpv6_type: exact match or wildcard
1913       icmpv6_code: exact match or wildcard
1914       nd_target: arbitrary mask
1915       nd_sll: arbitrary mask
1916       nd_tll: arbitrary mask
1917
1918 ' $1
1919 }
1920 ditto() {
1921     printf '  table %d ("%s"):
1922     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1923     max_entries=%d
1924     instructions (table miss and others):
1925       next tables: %d-253
1926       (same instructions)
1927       (same actions)
1928     (same matching)
1929
1930 ' $1 $2 $3 `expr $1 + 1`
1931 }
1932 tail_tables() {
1933 echo '  table 252 ("table252"):
1934     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1935     max_entries=1000000
1936     instructions (table miss and others):
1937       next tables: 253
1938       (same instructions)
1939       (same actions)
1940     (same matching)
1941
1942   table 253 ("table253"):
1943     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1944     max_entries=1000000
1945     instructions (table miss and others):
1946       instructions: meter,apply_actions,clear_actions,write_actions,write_metadata
1947       (same actions)
1948     (same matching)
1949 '
1950 }
1951 (head_table classifier
1952  for i in `seq 1 251`; do
1953      ditto $i table$i 1000000
1954  done
1955  tail_tables) > expout
1956 AT_CHECK([ovs-ofctl -O OpenFlow13 dump-table-features br0], [0], [expout])
1957 # Change the configuration.
1958 AT_CHECK(
1959   [ovs-vsctl \
1960      -- --id=@t0 create Flow_Table name=main \
1961      -- --id=@t1 create Flow_Table flow-limit=1024 \
1962      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
1963    | ${PERL} $srcdir/uuidfilt.pl],
1964   [0], [<0>
1965 <1>
1966 ])
1967 # Check that the configuration was updated.
1968 (head_table main
1969  ditto 1 table1 1024
1970  for i in `seq 2 251`; do
1971      ditto $i table$i 1000000
1972  done
1973  tail_tables) > expout
1974 AT_CHECK([ovs-ofctl -O OpenFlow13 dump-table-features br0], [0], [expout])
1975 OVS_VSWITCHD_STOP
1976 AT_CLEANUP
1977
1978 AT_SETUP([ofproto - table description (OpenFlow 1.4)])
1979 OVS_VSWITCHD_START
1980 (x=0
1981  while test $x -lt 254; do
1982    y=`expr $x + 1`
1983    echo "  table $x:
1984    eviction=off eviction_flags=OTHER|IMPORTANCE|LIFETIME
1985    vacancy=off"
1986    x=$y
1987  done) > expout
1988 AT_CHECK([ovs-ofctl -O OpenFlow14 dump-table-desc br0 | sed '/^$/d
1989 /^OFPST_TABLE_DESC/d'], [0], [expout])
1990
1991 # Change the configuration.
1992 AT_CHECK([ovs-ofctl -O Openflow14 mod-table br0 0 evict])
1993 # Check that the configuration was updated.
1994 mv expout orig-expout
1995 sed -e '2s/eviction=off/eviction=on/' <orig-expout > expout
1996 AT_CHECK([ovs-ofctl -O OpenFlow14 dump-table-desc br0 | sed '/^$/d
1997 /^OFPST_TABLE_DESC/d'], [0], [expout])
1998
1999 AT_CHECK([ovs-ofctl -O Openflow14 mod-table br0 0 vacancy:20,80])
2000 # Check that the configuration was updated.
2001 mv expout orig-expout
2002 sed -e '3s/vacancy=off/vacancy=on vacancy_down=20% vacancy_up=80% vacancy=100%/' <orig-expout > expout
2003 AT_CHECK([ovs-ofctl -O OpenFlow14 dump-table-desc br0 | sed '/^$/d
2004 /^OFPST_TABLE_DESC/d'], [0], [expout])
2005 OVS_VSWITCHD_STOP
2006 AT_CLEANUP
2007
2008 AT_SETUP([ofproto - hard limits on flow table size (OpenFlow 1.0)])
2009 OVS_VSWITCHD_START
2010 # Configure a maximum of 4 flows.
2011 AT_CHECK(
2012   [ovs-vsctl \
2013      -- --id=@t0 create Flow_Table flow-limit=4 \
2014      -- set bridge br0 flow_tables:0=@t0 \
2015    | ${PERL} $srcdir/uuidfilt.pl],
2016   [0], [<0>
2017 ])
2018 # Add 4 flows.
2019 for in_port in 1 2 3 4; do
2020     ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
2021 done
2022 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2023  in_port=1 actions=drop
2024  in_port=2 actions=drop
2025  in_port=3 actions=drop
2026  in_port=4 actions=drop
2027 NXST_FLOW reply:
2028 ])
2029 # Adding another flow will be refused.
2030 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
2031 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2032   [OFPT_ERROR: OFPFMFC_TABLE_FULL
2033 ])
2034 # Also a mod-flow that would add a flow will be refused.
2035 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
2036 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2037   [OFPT_ERROR: OFPFMFC_TABLE_FULL
2038 ])
2039 # Replacing or modifying an existing flow is allowed.
2040 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
2041 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
2042 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2043  in_port=1 actions=drop
2044  in_port=2 actions=drop
2045  in_port=3 actions=output:1
2046  in_port=4 actions=NORMAL
2047 NXST_FLOW reply:
2048 ])
2049 OVS_VSWITCHD_STOP
2050 AT_CLEANUP
2051
2052 AT_SETUP([ofproto - hard limits on flow table size (OpenFlow 1.2)])
2053 OVS_VSWITCHD_START
2054 # Configure a maximum of 4 flows.
2055 AT_CHECK(
2056   [ovs-vsctl \
2057      -- --id=@t0 create Flow_Table flow-limit=4 \
2058      -- set bridge br0 flow_tables:0=@t0 \
2059    | ${PERL} $srcdir/uuidfilt.pl],
2060   [0], [<0>
2061 ])
2062 # Add 4 flows.
2063 for in_port in 1 2 3 4; do
2064     ovs-ofctl -O OpenFlow12 add-flow br0 in_port=$in_port,actions=drop
2065 done
2066 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2067  in_port=1 actions=drop
2068  in_port=2 actions=drop
2069  in_port=3 actions=drop
2070  in_port=4 actions=drop
2071 OFPST_FLOW reply (OF1.2):
2072 ])
2073 # Adding another flow will be refused.
2074 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
2075 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2076   [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
2077 ])
2078 # Replacing or modifying an existing flow is allowed.
2079 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
2080 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
2081 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2082  in_port=1 actions=drop
2083  in_port=2 actions=drop
2084  in_port=3 actions=output:1
2085  in_port=4 actions=NORMAL
2086 OFPST_FLOW reply (OF1.2):
2087 ])
2088 OVS_VSWITCHD_STOP
2089 AT_CLEANUP
2090
2091 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.0)])
2092 OVS_VSWITCHD_START
2093 # Configure a maximum of 4 flows.
2094 AT_CHECK(
2095   [ovs-vsctl \
2096      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
2097      -- set bridge br0 flow_tables:0=@t0 \
2098    | ${PERL} $srcdir/uuidfilt.pl],
2099   [0], [<0>
2100 ])
2101 # Add 4 flows.
2102 for in_port in 4 3 2 1; do
2103     ovs-ofctl add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
2104 done
2105 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2106  idle_timeout=10, in_port=1 actions=drop
2107  idle_timeout=20, in_port=2 actions=drop
2108  idle_timeout=30, in_port=3 actions=drop
2109  idle_timeout=40, in_port=4 actions=drop
2110 NXST_FLOW reply:
2111 ])
2112 # Adding another flow will cause the one that expires soonest to be evicted.
2113 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
2114 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2115  idle_timeout=20, in_port=2 actions=drop
2116  idle_timeout=30, in_port=3 actions=drop
2117  idle_timeout=40, in_port=4 actions=drop
2118  in_port=5 actions=drop
2119 NXST_FLOW reply:
2120 ])
2121 # A mod-flow that adds a flow also causes eviction, but replacing or
2122 # modifying an existing flow doesn't.
2123 AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
2124 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
2125 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
2126 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2127  idle_timeout=30, in_port=3 actions=output:1
2128  in_port=4 actions=NORMAL
2129  in_port=5 actions=drop
2130  in_port=6 actions=drop
2131 NXST_FLOW reply:
2132 ])
2133 # Flows with no timeouts at all cannot be evicted.
2134 AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
2135 AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
2136 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2137   [OFPT_ERROR: OFPFMFC_TABLE_FULL
2138 ])
2139 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2140  in_port=4 actions=NORMAL
2141  in_port=5 actions=drop
2142  in_port=6 actions=drop
2143  in_port=7 actions=NORMAL
2144 NXST_FLOW reply:
2145 ])
2146 OVS_VSWITCHD_STOP
2147 AT_CLEANUP
2148
2149 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.2)])
2150 OVS_VSWITCHD_START
2151 # Configure a maximum of 4 flows.
2152 AT_CHECK(
2153   [ovs-vsctl \
2154      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
2155      -- set bridge br0 flow_tables:0=@t0 \
2156    | ${PERL} $srcdir/uuidfilt.pl],
2157   [0], [<0>
2158 ])
2159 # Add 4 flows.
2160 for in_port in 4 3 2 1; do
2161     ovs-ofctl -O OpenFlow12 add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
2162 done
2163 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2164  idle_timeout=10, in_port=1 actions=drop
2165  idle_timeout=20, in_port=2 actions=drop
2166  idle_timeout=30, in_port=3 actions=drop
2167  idle_timeout=40, in_port=4 actions=drop
2168 OFPST_FLOW reply (OF1.2):
2169 ])
2170 # Adding another flow will cause the one that expires soonest to be evicted.
2171 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop])
2172 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2173  idle_timeout=20, in_port=2 actions=drop
2174  idle_timeout=30, in_port=3 actions=drop
2175  idle_timeout=40, in_port=4 actions=drop
2176  in_port=5 actions=drop
2177 OFPST_FLOW reply (OF1.2):
2178 ])
2179 # In OpenFlow 1.2 a mod-flow does not ever add a flow and thus
2180 # has no effect on eviction
2181 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=6,actions=drop])
2182 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
2183 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
2184 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2185  idle_timeout=20, in_port=2 actions=drop
2186  idle_timeout=30, in_port=3 actions=output:1
2187  in_port=4 actions=NORMAL
2188  in_port=5 actions=drop
2189 OFPST_FLOW reply (OF1.2):
2190 ])
2191 # Flows with no timeouts at all cannot be evicted.
2192 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=6,actions=drop])
2193 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=7,actions=normal])
2194 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
2195 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2196   [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
2197 ])
2198 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2199  in_port=4 actions=NORMAL
2200  in_port=5 actions=drop
2201  in_port=6 actions=drop
2202  in_port=7 actions=NORMAL
2203 OFPST_FLOW reply (OF1.2):
2204 ])
2205 OVS_VSWITCHD_STOP
2206 AT_CLEANUP
2207
2208 AT_SETUP([ofproto - eviction using importance upon table overflow (OpenFlow 1.4)])
2209 OVS_VSWITCHD_START
2210 # Configure a maximum of 4 flows.
2211 AT_CHECK(
2212   [ovs-vsctl \
2213      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
2214      -- set bridge br0 flow_tables:0=@t0 \
2215    | ${PERL} $srcdir/uuidfilt.pl],
2216   [0], [<0>
2217 ])
2218 # Use mod-table to turn on eviction just to demonstrate that it works.
2219 AT_CHECK([ovs-ofctl -O OpenFlow14 mod-table br0 0 evict])
2220 # Add 4 flows.
2221 for in_port in 4 3 2 1; do
2222     ovs-ofctl -O Openflow14 add-flow br0 importance=$((in_port + 30)),priority=$((in_port + 5)),hard_timeout=$((in_port + 500)),actions=drop
2223 done
2224 AT_CHECK([ovs-ofctl -O Openflow14 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2225  hard_timeout=501, importance=31, priority=6 actions=drop
2226  hard_timeout=502, importance=32, priority=7 actions=drop
2227  hard_timeout=503, importance=33, priority=8 actions=drop
2228  hard_timeout=504, importance=34, priority=9 actions=drop
2229 OFPST_FLOW reply (OF1.4):
2230 ])
2231 # Adding another flow will cause the one with lowest importance to be evicted.
2232 AT_CHECK([ovs-ofctl -O Openflow14 add-flow br0 hard_timeout=505,importance=35,priority=10,in_port=2,actions=drop])
2233 AT_CHECK([ovs-ofctl -O Openflow14 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2234  hard_timeout=502, importance=32, priority=7 actions=drop
2235  hard_timeout=503, importance=33, priority=8 actions=drop
2236  hard_timeout=504, importance=34, priority=9 actions=drop
2237  hard_timeout=505, importance=35, priority=10,in_port=2 actions=drop
2238 OFPST_FLOW reply (OF1.4):
2239 ])
2240 # Disable the Eviction configuration.
2241 AT_CHECK([ovs-ofctl -O OpenFlow14 mod-table br0 0 noevict])
2242 # Adding another flow will cause the system to give error for FULL TABLE.
2243 AT_CHECK([ovs-ofctl -O Openflow14 add-flow br0 hard_timeout=506,importance=36,priority=11,actions=drop],[1], [], [stderr])
2244 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2245  [OFPT_ERROR (OF1.4): OFPFMFC_TABLE_FULL
2246 ])
2247 #Dump flows. It should show only the old values
2248 AT_CHECK([ovs-ofctl -O Openflow14 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2249  hard_timeout=502, importance=32, priority=7 actions=drop
2250  hard_timeout=503, importance=33, priority=8 actions=drop
2251  hard_timeout=504, importance=34, priority=9 actions=drop
2252  hard_timeout=505, importance=35, priority=10,in_port=2 actions=drop
2253 OFPST_FLOW reply (OF1.4):
2254 ])
2255 # mod-flow that would modify a flow will be done successfully.
2256 AT_CHECK([ovs-ofctl -O Openflow14 mod-flows br0 in_port=2,actions=NORMAL])
2257 AT_CHECK([ovs-ofctl -O Openflow14 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2258  hard_timeout=502, importance=32, priority=7 actions=drop
2259  hard_timeout=503, importance=33, priority=8 actions=drop
2260  hard_timeout=504, importance=34, priority=9 actions=drop
2261  hard_timeout=505, importance=35, priority=10,in_port=2 actions=NORMAL
2262 OFPST_FLOW reply (OF1.4):
2263 ])
2264 # Also a mod-flow that would add a flow will be refused.
2265 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
2266 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2267   [OFPT_ERROR: OFPFMFC_TABLE_FULL
2268 ])
2269 OVS_VSWITCHD_STOP
2270 AT_CLEANUP
2271
2272 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.0)])
2273 OVS_VSWITCHD_START
2274 # Configure a maximum of 4 flows.
2275 AT_CHECK(
2276   [ovs-vsctl \
2277      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
2278                                    overflow-policy=evict \
2279                                    groups='"NXM_OF_IN_PORT[[]]"' \
2280      -- set bridge br0 flow_tables:0=@t0 \
2281    | ${PERL} $srcdir/uuidfilt.pl],
2282   [0], [<0>
2283 ])
2284 # Add 4 flows.
2285 ovs-ofctl add-flows br0 - <<EOF
2286 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
2287 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
2288 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
2289 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
2290 EOF
2291 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2292  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2293  idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
2294  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2295  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2296 NXST_FLOW reply:
2297 ])
2298 # Adding another flow will cause the one that expires soonest within
2299 # the largest group (those with in_port=1) to be evicted.  In this
2300 # case this is not the same as the one that expires soonest overall
2301 # (which is what makes the test interesting):
2302 AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
2303 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2304  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2305  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2306  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2307  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2308 NXST_FLOW reply:
2309 ])
2310 # Enlarge the flow limit, change the eviction policy back to strictly
2311 # based on expiration, and and add some flows.
2312 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
2313 ovs-ofctl add-flows br0 - <<EOF
2314 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
2315 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
2316 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
2317 EOF
2318 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2319  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2320  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2321  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2322  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
2323  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2324  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2325  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2326 NXST_FLOW reply:
2327 ])
2328 # Adding another flow will cause the one that expires soonest overall
2329 # to be evicted.
2330 AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
2331 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2332  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2333  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2334  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
2335  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2336  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2337  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
2338  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2339 NXST_FLOW reply:
2340 ])
2341 # Reducing the flow limit also causes the flows that expire soonest
2342 # overall to be evicted.
2343 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
2344 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2345  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2346  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2347  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
2348  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2349 NXST_FLOW reply:
2350 ])
2351 OVS_VSWITCHD_STOP
2352 AT_CLEANUP
2353
2354 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.2)])
2355 OVS_VSWITCHD_START
2356 # Configure a maximum of 4 flows.
2357 AT_CHECK(
2358   [ovs-vsctl \
2359      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
2360                                    overflow-policy=evict \
2361                                    groups='"NXM_OF_IN_PORT[[]]"' \
2362      -- set bridge br0 flow_tables:0=@t0 \
2363    | ${PERL} $srcdir/uuidfilt.pl],
2364   [0], [<0>
2365 ])
2366 # Add 4 flows.
2367 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
2368 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
2369 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
2370 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
2371 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
2372 EOF
2373 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2374  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2375  idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
2376  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2377  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2378 OFPST_FLOW reply (OF1.2):
2379 ])
2380 # Adding another flow will cause the one that expires soonest within
2381 # the largest group (those with in_port=1) to be evicted.  In this
2382 # case this is not the same as the one that expires soonest overall
2383 # (which is what makes the test interesting):
2384 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
2385 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2386  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2387  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2388  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2389  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2390 OFPST_FLOW reply (OF1.2):
2391 ])
2392 # Enlarge the flow limit, change the eviction policy back to strictly
2393 # based on expiration, and and add some flows.
2394 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
2395 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
2396 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
2397 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
2398 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
2399 EOF
2400 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2401  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2402  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2403  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2404  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
2405  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2406  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2407  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2408 OFPST_FLOW reply (OF1.2):
2409 ])
2410 # Adding another flow will cause the one that expires soonest overall
2411 # to be evicted.
2412 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'])
2413 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2414  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2415  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2416  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
2417  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2418  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2419  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
2420  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2421 OFPST_FLOW reply (OF1.2):
2422 ])
2423 # Reducing the flow limit also causes the flows that expire soonest
2424 # overall to be evicted.
2425 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
2426 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2427  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2428  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2429  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
2430  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2431 OFPST_FLOW reply (OF1.2):
2432 ])
2433 OVS_VSWITCHD_STOP
2434 AT_CLEANUP
2435
2436 AT_SETUP([ofproto - eviction upon table overflow, with modified hard timeout])
2437 OVS_VSWITCHD_START
2438 # Configure a maximum of 4 flows.
2439 AT_CHECK(
2440   [ovs-vsctl \
2441      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
2442      -- set bridge br0 flow_tables:0=@t0 \
2443    | ${PERL} $srcdir/uuidfilt.pl],
2444   [0], [<0>
2445 ])
2446 ovs-appctl time/stop
2447 # Add 4 flows.
2448 for in_port in 4 3 2 1; do
2449     ovs-ofctl add-flow br0 hard_timeout=$((10 + in_port * 3)),in_port=$in_port,actions=drop
2450 done
2451 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2452  hard_timeout=13, in_port=1 actions=drop
2453  hard_timeout=16, in_port=2 actions=drop
2454  hard_timeout=19, in_port=3 actions=drop
2455  hard_timeout=22, in_port=4 actions=drop
2456 NXST_FLOW reply:
2457 ])
2458 # Sleep and modify the one that expires soonest
2459 ovs-appctl time/warp 5000
2460 AT_CHECK([ovs-ofctl mod-flows br0 in_port=1,actions=drop])
2461 # At this point the table would looks like:
2462 #  in_port   seconds to expire
2463 #     1            13
2464 #     2            11
2465 #     3            14
2466 #     4            17
2467 ovs-appctl time/warp 2000
2468 # Adding another flow will cause the one that expires soonest to be evicted.
2469 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
2470 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2471  hard_timeout=13, in_port=1 actions=drop
2472  hard_timeout=19, in_port=3 actions=drop
2473  hard_timeout=22, in_port=4 actions=drop
2474  in_port=5 actions=drop
2475 NXST_FLOW reply:
2476 ])
2477 OVS_VSWITCHD_STOP
2478 AT_CLEANUP
2479
2480 AT_SETUP([ofproto - eviction upon table overflow, with modified idle timeout])
2481 OVS_VSWITCHD_START([add-port br0 p1 -- set interface p1 type=dummy ofport_request=1])
2482 # Configure a maximum of 4 flows.
2483 AT_CHECK(
2484   [ovs-vsctl \
2485      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
2486      -- set bridge br0 flow_tables:0=@t0 \
2487    | ${PERL} $srcdir/uuidfilt.pl],
2488   [0], [<0>
2489 ])
2490 # Add 4 flows.
2491 for in_port in 4 3 2 1; do
2492     ovs-ofctl add-flow br0 idle_timeout=$((10 + in_port * 3)),in_port=$in_port,actions=drop
2493 done
2494 ovs-appctl time/stop
2495 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2496  idle_timeout=13, in_port=1 actions=drop
2497  idle_timeout=16, in_port=2 actions=drop
2498  idle_timeout=19, in_port=3 actions=drop
2499  idle_timeout=22, in_port=4 actions=drop
2500 NXST_FLOW reply:
2501 ])
2502 # Sleep and receive on the flow that expires soonest
2503 ovs-appctl time/warp 5000
2504 AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1)'])
2505 # At this point the table would looks like:
2506 #  in_port   seconds to expire
2507 #     1            13
2508 #     2            11
2509 #     3            14
2510 #     4            17
2511 ovs-appctl time/warp 2000
2512 # Adding another flow will cause the one that expires soonest to be evicted.
2513 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
2514 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2515  idle_timeout=19, in_port=3 actions=drop
2516  idle_timeout=22, in_port=4 actions=drop
2517  in_port=5 actions=drop
2518  n_packets=1, n_bytes=60, idle_timeout=13, in_port=1 actions=drop
2519 NXST_FLOW reply:
2520 ])
2521 OVS_VSWITCHD_STOP
2522 AT_CLEANUP
2523
2524 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.0)])
2525 OVS_VSWITCHD_START
2526 AT_CHECK([ovs-ofctl -P standard monitor br0 --detach --no-chdir --pidfile])
2527 check_async () {
2528     printf '\n\n--- check_async %d ---\n\n\n' $1
2529     shift
2530
2531     ovs-appctl -t ovs-ofctl ofctl/barrier
2532     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2533     : > expout
2534
2535     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
2536     ovs-ofctl -v packet-out br0 controller controller '0001020304050010203040501234'
2537     if test X"$1" = X"OFPR_ACTION"; then shift;
2538         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
2539 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2540     fi
2541
2542     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
2543     ovs-ofctl -v packet-out br0 controller 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
2544     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
2545         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via no_match) data_len=14 (unbuffered)
2546 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2547     fi
2548
2549     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
2550     ovs-ofctl packet-out br0 controller dec_ttl '002583dfb4000026b98cb0f908004500003eb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
2551     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
2552         echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=CONTROLLER (via invalid_ttl) data_len=76 (unbuffered)
2553 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"
2554     fi
2555
2556     # OFPT_PORT_STATUS, OFPPR_ADD
2557     ovs-vsctl add-port br0 test -- set Interface test type=dummy ofport_request=1
2558     if test X"$1" = X"OFPPR_ADD"; then shift;
2559         echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
2560      config:     PORT_DOWN
2561      state:      LINK_DOWN
2562      speed: 0 Mbps now, 0 Mbps max"
2563     fi
2564
2565     # OFPT_PORT_STATUS, OFPPR_DELETE
2566     ovs-vsctl del-port br0 test
2567     if test X"$1" = X"OFPPR_DELETE"; then shift;
2568         echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
2569      config:     PORT_DOWN
2570      state:      LINK_DOWN
2571      speed: 0 Mbps now, 0 Mbps max"
2572     fi
2573
2574     # OFPT_FLOW_REMOVED, OFPRR_DELETE
2575     ovs-ofctl add-flow br0 send_flow_rem,actions=drop
2576     ovs-ofctl --strict del-flows br0 ''
2577     if test X"$1" = X"OFPRR_DELETE"; then shift;
2578         echo >>expout "OFPT_FLOW_REMOVED:  reason=delete"
2579     fi
2580     AT_FAIL_IF([test X"$1" != X])
2581
2582     ovs-appctl -t ovs-ofctl ofctl/barrier
2583     echo >>expout "OFPT_BARRIER_REPLY:"
2584
2585     AT_CHECK(
2586       [[sed '
2587 s/ (xid=0x[0-9a-fA-F]*)//
2588 s/ *duration.*//
2589 s/00:0.$/00:0x/' < monitor.log]],
2590       [0], [expout])
2591 }
2592
2593 # It's a service connection so initially there should be no async messages.
2594 check_async 1
2595
2596 # Set miss_send_len to 128, turning on packet-ins for our service connection.
2597 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
2598 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2599
2600 # Set miss_send_len to 128 and enable invalid_ttl.
2601 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
2602 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2603
2604 # Become slave, which should disable everything except port status.
2605 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
2606 check_async 4 OFPPR_ADD OFPPR_DELETE
2607
2608 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
2609 ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
2610 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
2611
2612 # Set controller ID 123.
2613 ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
2614 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
2615
2616 # Restore controller ID 0.
2617 ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
2618
2619 # Become master.
2620 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
2621 check_async 7 OFPR_ACTION OFPPR_ADD
2622
2623 ovs-appctl -t ovs-ofctl exit
2624 OVS_VSWITCHD_STOP
2625 AT_CLEANUP
2626
2627 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.2)])
2628 OVS_VSWITCHD_START
2629 AT_CHECK([ovs-ofctl -O OpenFlow12 -P standard monitor br0 --detach --no-chdir --pidfile])
2630 check_async () {
2631     printf '\n\n--- check_async %d ---\n\n\n' $1
2632     INDEX=$1
2633     shift
2634
2635     ovs-appctl -t ovs-ofctl ofctl/barrier
2636     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2637     : > expout
2638
2639     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
2640     ovs-ofctl -O OpenFlow12 -v packet-out br0 none controller '0001020304050010203040501234'
2641     if test X"$1" = X"OFPR_ACTION"; then shift;
2642         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
2643 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2644     fi
2645
2646     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
2647     ovs-ofctl -O OpenFlow12 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
2648     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
2649         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
2650 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2651     fi
2652
2653     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
2654     ovs-ofctl -O OpenFlow12 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003eb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
2655     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
2656         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
2657 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"
2658     fi
2659
2660     # OFPT_PORT_STATUS, OFPPR_ADD
2661     ovs-vsctl add-port br0 test -- set Interface test type=dummy
2662     if test X"$1" = X"OFPPR_ADD"; then shift;
2663         echo >>expout "OFPT_PORT_STATUS (OF1.2): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2664      config:     PORT_DOWN
2665      state:      LINK_DOWN
2666      speed: 0 Mbps now, 0 Mbps max"
2667     fi
2668
2669     # OFPT_PORT_STATUS, OFPPR_DELETE
2670     ovs-vsctl del-port br0 test
2671     if test X"$1" = X"OFPPR_DELETE"; then shift;
2672         echo >>expout "OFPT_PORT_STATUS (OF1.2): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2673      config:     PORT_DOWN
2674      state:      LINK_DOWN
2675      speed: 0 Mbps now, 0 Mbps max"
2676     fi
2677
2678     # OFPT_FLOW_REMOVED, OFPRR_DELETE
2679     ovs-ofctl -O OpenFlow12 add-flow br0 send_flow_rem,actions=drop
2680     ovs-ofctl -O OpenFlow12 --strict del-flows br0 ''
2681     if test X"$1" = X"OFPRR_DELETE"; then shift;
2682         echo >>expout "OFPT_FLOW_REMOVED (OF1.2):  reason=delete table_id=0"
2683     fi
2684     AT_FAIL_IF([test X"$1" != X])
2685
2686     sleep 1
2687
2688     AT_CHECK(
2689       [[sed '
2690 s/ (xid=0x[0-9a-fA-F]*)//
2691 s/ *duration.*//
2692 s/00:0.$/00:0x/' < monitor.log]],
2693       [0], [expout])
2694 }
2695
2696 # It's a service connection so initially there should be no async messages.
2697 check_async 1
2698
2699 # Set miss_send_len to 128, turning on packet-ins for our service connection.
2700 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
2701 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2702
2703 # Set miss_send_len to 128 and enable invalid_ttl.
2704 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700040080
2705 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2706
2707 # Become slave (OF 1.2), which should disable everything except port status.
2708 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000200000003000000000000000000000001
2709 check_async 4 OFPPR_ADD OFPPR_DELETE
2710
2711 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
2712 ovs-appctl -t ovs-ofctl ofctl/send 03040028000000020000232000000013000000020000000500000005000000020000000200000005
2713 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
2714
2715 # Set controller ID 123.
2716 ovs-appctl -t ovs-ofctl ofctl/send 03040018000000030000232000000014000000000000007b
2717 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
2718
2719 # Restore controller ID 0.
2720 ovs-appctl -t ovs-ofctl ofctl/send 030400180000000300002320000000140000000000000000
2721
2722 # Become master (OF 1.2).
2723 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000400000002000000000000000000000002
2724 check_async 7 OFPR_ACTION OFPPR_ADD
2725
2726 ovs-appctl -t ovs-ofctl exit
2727 OVS_VSWITCHD_STOP
2728 AT_CLEANUP
2729
2730 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.3)])
2731 OVS_VSWITCHD_START
2732 AT_CHECK([ovs-ofctl -O OpenFlow13 -P standard monitor br0 --detach --no-chdir --pidfile])
2733 check_async () {
2734     printf '\n\n--- check_async %d ---\n\n\n' $1
2735     INDEX=$1
2736     shift
2737
2738     ovs-appctl -t ovs-ofctl ofctl/barrier
2739     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2740     : > expout
2741
2742     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
2743     ovs-ofctl -O OpenFlow13 -v packet-out br0 none controller '0001020304050010203040501234'
2744     if test X"$1" = X"OFPR_ACTION"; then shift;
2745         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
2746 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2747     fi
2748
2749     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
2750     ovs-ofctl -O OpenFlow13 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
2751     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
2752         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
2753 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2754     fi
2755
2756     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
2757     ovs-ofctl -O OpenFlow13 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003eb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
2758     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
2759         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
2760 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"
2761     fi
2762
2763     # OFPT_PORT_STATUS, OFPPR_ADD
2764     ovs-vsctl add-port br0 test -- set Interface test type=dummy
2765     if test X"$1" = X"OFPPR_ADD"; then shift;
2766         echo >>expout "OFPT_PORT_STATUS (OF1.3): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2767      config:     PORT_DOWN
2768      state:      LINK_DOWN
2769      speed: 0 Mbps now, 0 Mbps max"
2770     fi
2771
2772     # OFPT_PORT_STATUS, OFPPR_DELETE
2773     ovs-vsctl del-port br0 test
2774     if test X"$1" = X"OFPPR_DELETE"; then shift;
2775         echo >>expout "OFPT_PORT_STATUS (OF1.3): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2776      config:     PORT_DOWN
2777      state:      LINK_DOWN
2778      speed: 0 Mbps now, 0 Mbps max"
2779     fi
2780
2781     # OFPT_FLOW_REMOVED, OFPRR_DELETE
2782     ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=drop
2783     ovs-ofctl -O OpenFlow13 --strict del-flows br0 ''
2784     if test X"$1" = X"OFPRR_DELETE"; then shift;
2785         echo >>expout "OFPT_FLOW_REMOVED (OF1.3):  reason=delete table_id=0"
2786     fi
2787
2788     # OFPT_FLOW_REMOVED, OFPRR_GROUP_DELETE
2789     ovs-ofctl -O OpenFlow13 add-group br0 group_id=1234,type=all,bucket=output:10
2790     ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=group:1234
2791     ovs-ofctl -O OpenFlow13 --strict del-groups br0 group_id=1234
2792     if test X"$1" = X"OFPRR_DELETE"; then shift;
2793         echo >>expout "OFPT_FLOW_REMOVED (OF1.3):  reason=gropu_delete table_id=0"
2794     fi
2795
2796     AT_FAIL_IF([test X"$1" != X])
2797
2798     ovs-appctl -t ovs-ofctl ofctl/barrier
2799     echo >>expout "OFPT_BARRIER_REPLY (OF1.3):"
2800
2801     AT_CHECK(
2802       [[sed '
2803 s/ (xid=0x[0-9a-fA-F]*)//
2804 s/ *duration.*//
2805 s/00:0.$/00:0x/' < monitor.log]],
2806       [0], [expout])
2807 }
2808
2809 # It's a service connection so initially there should be no async messages.
2810 check_async 1
2811
2812 # Set miss_send_len to 128, turning on packet-ins for our service connection.
2813 ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
2814 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2815
2816 # Become slave (OF 1.3), which should disable everything except port status.
2817 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000200000003000000000000000000000001
2818 check_async 3 OFPPR_ADD OFPPR_DELETE
2819
2820 # Use OF 1.3 OFPT_SET_ASYNC to enable a patchwork of asynchronous messages.
2821 ovs-appctl -t ovs-ofctl ofctl/send 041c002000000002000000020000000500000005000000020000000200000005
2822 check_async 4 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
2823
2824 # Set controller ID 123.
2825 ovs-appctl -t ovs-ofctl ofctl/send 04040018000000030000232000000014000000000000007b
2826 check_async 5 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
2827
2828 # Restore controller ID 0.
2829 ovs-appctl -t ovs-ofctl ofctl/send 040400180000000300002320000000140000000000000000
2830
2831 # Become master (OF 1.3).
2832 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000400000002000000000000000000000002
2833 check_async 6 OFPR_ACTION OFPPR_ADD
2834
2835 ovs-appctl -t ovs-ofctl exit
2836 OVS_VSWITCHD_STOP
2837 AT_CLEANUP
2838
2839 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.4)])
2840 OVS_VSWITCHD_START
2841 AT_CHECK([ovs-ofctl -O OpenFlow14 -P standard monitor br0 --detach --no-chdir --pidfile])
2842 check_async () {
2843     printf '\n\n--- check_async %d ---\n\n\n' $1
2844     INDEX=$1
2845     shift
2846
2847     ovs-appctl -t ovs-ofctl ofctl/barrier
2848     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2849     : > expout
2850
2851     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
2852     ovs-ofctl -O OpenFlow14 -v packet-out br0 none controller '0001020304050010203040501234'
2853     if test X"$1" = X"OFPR_ACTION"; then shift;
2854         echo >>expout "OFPT_PACKET_IN (OF1.4): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
2855 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2856     fi
2857
2858     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
2859     ovs-ofctl -O OpenFlow14 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
2860     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
2861         echo >>expout "OFPT_PACKET_IN (OF1.4): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
2862 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2863     fi
2864
2865     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
2866     ovs-ofctl -O OpenFlow14 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003eb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
2867     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
2868         echo >>expout "OFPT_PACKET_IN (OF1.4): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
2869 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"
2870     fi
2871
2872 # OFPT_PORT_STATUS, OFPPR_ADD
2873     ovs-vsctl add-port br0 test -- set Interface test type=dummy
2874     if test X"$1" = X"OFPPR_ADD"; then shift;
2875         echo >>expout "OFPT_PORT_STATUS (OF1.4): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2876      config:     PORT_DOWN
2877      state:      LINK_DOWN
2878      speed: 0 Mbps now, 0 Mbps max"
2879     fi
2880
2881     # OFPT_PORT_STATUS, OFPPR_MODIFY
2882     ovs-ofctl -O OpenFlow14 -vwarn mod-port br0 test up
2883     if test X"$1" = X"OFPPR_MODIFY"; then shift;
2884         echo >>expout "OFPT_PORT_STATUS (OF1.4): MOD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2885      config:     0
2886      state:      LINK_DOWN
2887      speed: 0 Mbps now, 0 Mbps max
2888 OFPT_PORT_STATUS (OF1.4): MOD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2889      config:     0
2890      state:      0
2891      speed: 0 Mbps now, 0 Mbps max"
2892     fi
2893
2894     # OFPT_PORT_STATUS, OFPPR_DELETE
2895     ovs-vsctl del-port br0 test
2896     if test X"$1" = X"OFPPR_DELETE"; then shift;
2897         echo >>expout "OFPT_PORT_STATUS (OF1.4): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2898      config:     0
2899      state:      0
2900      speed: 0 Mbps now, 0 Mbps max"
2901     fi
2902
2903     # OFPT_FLOW_REMOVED, OFPRR_DELETE
2904     ovs-ofctl -O OpenFlow14 add-flow br0 send_flow_rem,actions=drop
2905     ovs-ofctl -O OpenFlow14 --strict del-flows br0 ''
2906     if test X"$1" = X"OFPRR_DELETE"; then shift;
2907         echo >>expout "OFPT_FLOW_REMOVED (OF1.4):  reason=delete table_id=0"
2908     fi
2909
2910     # OFPT_FLOW_REMOVED, OFPRR_GROUP_DELETE
2911     ovs-ofctl -O OpenFlow14 add-group br0 group_id=1234,type=all,bucket=output:10
2912     ovs-ofctl -O OpenFlow14 add-flow br0 send_flow_rem,actions=group:1234
2913     ovs-ofctl -O OpenFlow14 --strict del-groups br0 group_id=1234
2914     if test X"$1" = X"OFPRR_GROUP_DELETE"; then shift;
2915         echo >>expout "OFPT_FLOW_REMOVED (OF1.4):  reason=group_delete table_id=0"
2916     fi
2917
2918     # OFPT_TABLE_STATUS, OFPTR_VACANCY_UP
2919     if test X"$1" = X"OFPTR_VACANCY_UP"; then shift;
2920         ovs-vsctl -- --id=@t1 create Flow_Table flow-limit=10 -- set bridge br0 flow_tables:1=@t1
2921
2922         # Turn on vacancy events, then add flows until we're full.
2923         # With initial vacancy of 100% and vacancy_up of 80%, so that
2924         # vacancy >= vacancy_up, this enables VACANY_DOWN events, so
2925         # we get a single such message when vacancy dips below 20%.
2926         ovs-ofctl -O OpenFlow14 mod-table br0 1 vacancy:20,80
2927         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=1,actions=2
2928         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=2,actions=2
2929         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=3,actions=2
2930         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=4,actions=2
2931         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=5,actions=2
2932         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=6,actions=2
2933         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=7,actions=2
2934         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=8,actions=2
2935         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=9,actions=2
2936         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=10,actions=2
2937         echo >>expout "OFPT_TABLE_STATUS (OF1.4): reason=VACANCY_DOWN
2938 table_desc:-
2939   table 1:
2940    eviction=off eviction_flags=OTHER|IMPORTANCE|LIFETIME
2941    vacancy=on vacancy_down=20% vacancy_up=80% vacancy=10%"
2942         # Then delete flows until we're empty.  Sending the
2943         # VACANCY_DOWN message enabled VACANCY_UP events, so we get a
2944         # single such message when vacancy rises above 80%.
2945         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=1
2946         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=2
2947         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=3
2948         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=4
2949         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=5
2950         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=6
2951         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=7
2952         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=8
2953         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=9
2954         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=10
2955         echo >>expout "OFPT_TABLE_STATUS (OF1.4): reason=VACANCY_UP
2956 table_desc:-
2957   table 1:
2958    eviction=off eviction_flags=OTHER|IMPORTANCE|LIFETIME
2959    vacancy=on vacancy_down=20% vacancy_up=80% vacancy=90%"
2960
2961         # Now approach vacancy from the other direction.  First
2962         # disable vacancy events.  With initial vacancy of 70%, so
2963         # that vacancy < vacancy_up, this enables VACANCY_UP events.
2964         # That means that filling up the table generates no message,
2965         # but deleting all the flows generates VACANCY_UP at the point
2966         # vacancy rises above 80%.
2967         ovs-ofctl -O OpenFlow14 mod-table br0 1 novacancy
2968         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=1,actions=2
2969         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=2,actions=2
2970         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=3,actions=2
2971         ovs-ofctl -O OpenFlow14 mod-table br0 1 vacancy:20,80
2972         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=4,actions=2
2973         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=5,actions=2
2974         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=6,actions=2
2975         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=7,actions=2
2976         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=8,actions=2
2977         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=9,actions=2
2978         ovs-ofctl -O OpenFlow14 add-flow br0 table=1,in_port=10,actions=2
2979         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=1
2980         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=2
2981         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=3
2982         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=4
2983         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=5
2984         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=6
2985         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=7
2986         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=8
2987         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=9
2988         ovs-ofctl -O OpenFlow14 del-flows br0 table=1,in_port=10
2989         echo >>expout "OFPT_TABLE_STATUS (OF1.4): reason=VACANCY_UP
2990 table_desc:-
2991   table 1:
2992    eviction=off eviction_flags=OTHER|IMPORTANCE|LIFETIME
2993    vacancy=on vacancy_down=20% vacancy_up=80% vacancy=90%"
2994     fi
2995
2996     AT_FAIL_IF([test X"$1" != X])
2997
2998     ovs-appctl -t ovs-ofctl ofctl/barrier
2999     echo >>expout "OFPT_BARRIER_REPLY (OF1.4):"
3000
3001     AT_CHECK(
3002       [[sed '
3003 s/ (xid=0x[0-9a-fA-F]*)//
3004 s/ *duration.*//
3005 s/00:0.$/00:0x/' < monitor.log]],
3006       [0], [expout])
3007 }
3008
3009 # It's a service connection so initially there should be no async messages.
3010 check_async 1
3011
3012 # Set miss_send_len to 128, turning on packet-ins for our service connection.
3013 ovs-appctl -t ovs-ofctl ofctl/send 0509000c0123456700000080
3014 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_MODIFY OFPPR_DELETE OFPRR_DELETE OFPRR_GROUP_DELETE
3015
3016 # Become slave (OF 1.4), which should disable everything except port status.
3017 ovs-appctl -t ovs-ofctl ofctl/send 051800180000000200000003000000000000000000000001
3018 check_async 3 OFPPR_ADD OFPPR_MODIFY OFPPR_DELETE
3019
3020 # Use OF 1.4 OFPT_SET_ASYNC to enable a patchwork of asynchronous messages.
3021 ovs-appctl -t ovs-ofctl ofctl/send 051c0040000000020000000800000005000100080000000200020008000000020003000800000005000400080000001c00050008000000050008000800000018
3022 check_async 4 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE OFPRR_GROUP_DELETE OFPTR_VACANCY_UP
3023
3024 # Set controller ID 123.
3025 ovs-appctl -t ovs-ofctl ofctl/send 05040018000000030000232000000014000000000000007b
3026 check_async 5 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE OFPRR_GROUP_DELETE
3027
3028 # Restore controller ID 0.
3029 ovs-appctl -t ovs-ofctl ofctl/send 050400180000000300002320000000140000000000000000
3030
3031 # Become master (OF 1.4).
3032 ovs-appctl -t ovs-ofctl ofctl/send 051800180000000400000002000000000000000000000002
3033 check_async 6 OFPR_ACTION OFPPR_ADD OFPPR_MODIFY OFPRR_DELETE
3034
3035 ovs-appctl -t ovs-ofctl exit
3036 OVS_VSWITCHD_STOP
3037 AT_CLEANUP
3038
3039 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.5)])
3040 OVS_VSWITCHD_START
3041 AT_CHECK([ovs-ofctl -O OpenFlow15 -P standard monitor br0 --detach --no-chdir --pidfile])
3042 check_async () {
3043     printf '\n\n--- check_async %d ---\n\n\n' $1
3044     INDEX=$1
3045     shift
3046
3047     ovs-appctl -t ovs-ofctl ofctl/barrier
3048     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3049     : > expout
3050
3051     # Other tests are not working with OF 1.5, and message
3052     # format may change, so leave them out.
3053
3054     # OFPT_PORT_STATUS, OFPPR_ADD
3055     ovs-vsctl add-port br0 test -- set Interface test type=dummy
3056     if test X"$1" = X"OFPPR_ADD"; then shift;
3057         echo >>expout "OFPT_PORT_STATUS (OF1.5): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
3058      config:     PORT_DOWN
3059      state:      LINK_DOWN
3060      speed: 0 Mbps now, 0 Mbps max"
3061     fi
3062
3063     # OFPT_PORT_STATUS, OFPPR_MODIFY
3064     ovs-ofctl -O OpenFlow15 -vwarn mod-port br0 test up
3065     if test X"$1" = X"OFPPR_MODIFY"; then shift;
3066         echo >>expout "OFPT_PORT_STATUS (OF1.5): MOD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
3067      config:     0
3068      state:      LINK_DOWN
3069      speed: 0 Mbps now, 0 Mbps max
3070 OFPT_PORT_STATUS (OF1.5): MOD: 2(test): addr:aa:55:aa:55:00:0x
3071      config:     0
3072      state:      0
3073      speed: 0 Mbps now, 0 Mbps max"
3074     fi
3075
3076     # OFPT_PORT_STATUS, OFPPR_DELETE
3077     ovs-vsctl del-port br0 test
3078     if test X"$1" = X"OFPPR_DELETE"; then shift;
3079         echo >>expout "OFPT_PORT_STATUS (OF1.5): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
3080      config:     0
3081      state:      0
3082      speed: 0 Mbps now, 0 Mbps max"
3083     fi
3084
3085     AT_FAIL_IF([test X"$1" != X])
3086
3087     ovs-appctl -t ovs-ofctl ofctl/barrier
3088     echo >>expout "OFPT_BARRIER_REPLY (OF1.5):"
3089
3090     AT_CHECK(
3091       [[sed '
3092 s/ (xid=0x[0-9a-fA-F]*)//
3093 s/ *duration.*//
3094 s/00:0.$/00:0x/' < monitor.log]],
3095       [0], [expout])
3096 }
3097
3098 # It's a service connection so initially there should be no async messages.
3099 check_async 1
3100
3101 # If we don't set this, async messages are not received.
3102 # Set miss_send_len to 128, turning on packet-ins for our service connection.
3103 ovs-appctl -t ovs-ofctl ofctl/send 0609000c0123456700000080
3104 check_async 2 OFPPR_ADD OFPPR_MODIFY OFPPR_DELETE
3105
3106 # Set-async has changed in OF 1.4 and is not yet implemented.
3107
3108 ovs-appctl -t ovs-ofctl exit
3109 OVS_VSWITCHD_STOP
3110 AT_CLEANUP
3111
3112 dnl This test checks that the role request/response messaging works
3113 dnl and that generation_id is handled properly.
3114 AT_SETUP([ofproto - controller role (OpenFlow 1.2)])
3115 OVS_VSWITCHD_START
3116 on_exit 'kill `cat c1.pid c2.pid`'
3117
3118 # Start two ovs-ofctl controller processes.
3119 AT_CAPTURE_FILE([monitor1.log])
3120 AT_CAPTURE_FILE([expout1])
3121 AT_CAPTURE_FILE([experr1])
3122 AT_CAPTURE_FILE([monitor2.log])
3123 AT_CAPTURE_FILE([expout2])
3124 AT_CAPTURE_FILE([experr2])
3125 for i in 1 2; do
3126      AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile=`pwd`/c$i.pid --unixctl=`pwd`/c$i])
3127     ovs-appctl -t `pwd`/c$i ofctl/barrier
3128     ovs-appctl -t `pwd`/c$i ofctl/set-output-file monitor$i.log
3129     : > expout$i
3130     : > experr$i
3131
3132     # find out current role
3133     ovs-appctl -t `pwd`/c$i ofctl/send 031800180000000200000000000000000000000000000000
3134     echo >>experr$i "send: OFPT_ROLE_REQUEST (OF1.2): role=nochange"
3135     echo >>expout$i "OFPT_ROLE_REPLY (OF1.2): role=equal"
3136 done
3137
3138 # controller 1: Become slave (generation_id is initially undefined, so
3139 # 2^63+2 should not be stale)
3140 ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000300000003000000008000000000000002
3141 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=slave generation_id=9223372036854775810"
3142 echo >>expout1 "OFPT_ROLE_REPLY (OF1.2): role=slave generation_id=9223372036854775810"
3143
3144 # controller 2: Become master.
3145 ovs-appctl -t `pwd`/c2 ofctl/send 031800180000000300000002000000008000000000000003
3146 echo >>experr2 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=9223372036854775811"
3147 echo >>expout2 "OFPT_ROLE_REPLY (OF1.2): role=master generation_id=9223372036854775811"
3148
3149 # controller 1: Try to become the master using a stale generation ID
3150 ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000400000002000000000000000000000003
3151 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=3"
3152 echo >>expout1 "OFPT_ERROR (OF1.2): OFPRRFC_STALE"
3153 echo >>expout1 "OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=3"
3154
3155 # controller 1: Become master using a valid generation ID
3156 ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000500000002000000000000000000000001
3157 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=1"
3158 echo >>expout1 "OFPT_ROLE_REPLY (OF1.2): role=master generation_id=1"
3159
3160 for i in 1 2; do
3161     ovs-appctl -t `pwd`/c$i ofctl/barrier
3162     echo >>expout$i "OFPT_BARRIER_REPLY (OF1.2):"
3163 done
3164
3165 # Check output.
3166 for i in 1 2; do
3167     cp expout$i expout
3168     AT_CHECK([grep -v '^send:' monitor$i.log | strip_xids], [0], [expout])
3169     cp experr$i expout
3170     AT_CHECK([grep '^send:' monitor$i.log | strip_xids], [0], [expout])
3171 done
3172 OVS_VSWITCHD_STOP
3173 AT_CLEANUP
3174
3175 dnl This test checks that the role request/response messaging works,
3176 dnl that generation_id is handled properly, and that role status update
3177 dnl messages are sent when a controller's role gets changed from master
3178 dnl to slave.
3179 AT_SETUP([ofproto - controller role (OpenFlow 1.4)])
3180 OVS_VSWITCHD_START
3181 on_exit 'kill `cat c1.pid c2.pid`'
3182
3183 # Start two ovs-ofctl controller processes.
3184 AT_CAPTURE_FILE([monitor1.log])
3185 AT_CAPTURE_FILE([expout1])
3186 AT_CAPTURE_FILE([experr1])
3187 AT_CAPTURE_FILE([monitor2.log])
3188 AT_CAPTURE_FILE([expout2])
3189 AT_CAPTURE_FILE([experr2])
3190 for i in 1 2; do
3191      AT_CHECK([ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile=`pwd`/c$i.pid --unixctl=`pwd`/c$i])
3192     ovs-appctl -t `pwd`/c$i ofctl/barrier
3193     ovs-appctl -t `pwd`/c$i ofctl/set-output-file monitor$i.log
3194     : > expout$i
3195     : > experr$i
3196
3197     # find out current role
3198     ovs-appctl -t `pwd`/c$i ofctl/send 051800180000000200000000000000000000000000000000
3199     echo >>experr$i "send: OFPT_ROLE_REQUEST (OF1.4): role=nochange"
3200     echo >>expout$i "OFPT_ROLE_REPLY (OF1.4): role=equal"
3201 done
3202
3203 # controller 1: Become slave (generation_id is initially undefined, so
3204 # 2^63+2 should not be stale)
3205 ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000300000003000000008000000000000002
3206 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=slave generation_id=9223372036854775810"
3207 echo >>expout1 "OFPT_ROLE_REPLY (OF1.4): role=slave generation_id=9223372036854775810"
3208
3209 # controller 2: Become master.
3210 ovs-appctl -t `pwd`/c2 ofctl/send 051800180000000300000002000000008000000000000003
3211 echo >>experr2 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=9223372036854775811"
3212 echo >>expout2 "OFPT_ROLE_REPLY (OF1.4): role=master generation_id=9223372036854775811"
3213
3214 # controller 1: Try to become the master using a stale generation ID
3215 ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000400000002000000000000000000000003
3216 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=3"
3217 echo >>expout1 "OFPT_ERROR (OF1.4): OFPRRFC_STALE"
3218 echo >>expout1 "OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=3"
3219
3220 # controller 1: Become master using a valid generation ID
3221 ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000500000002000000000000000000000001
3222 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=1"
3223 echo >>expout1 "OFPT_ROLE_REPLY (OF1.4): role=master generation_id=1"
3224 echo >>expout2 "OFPT_ROLE_STATUS (OF1.4): role=slave generation_id=1 reason=master_request"
3225
3226 for i in 1 2; do
3227     ovs-appctl -t `pwd`/c$i ofctl/barrier
3228     echo >>expout$i "OFPT_BARRIER_REPLY (OF1.4):"
3229 done
3230
3231 # Check output.
3232 for i in 1 2; do
3233     cp expout$i expout
3234     AT_CHECK([grep -v '^send:' monitor$i.log | strip_xids], [0], [expout])
3235     cp experr$i expout
3236     AT_CHECK([grep '^send:' monitor$i.log | strip_xids], [0], [expout])
3237 done
3238 OVS_VSWITCHD_STOP
3239 AT_CLEANUP
3240
3241 dnl This test checks the Group and meter notifications when a group mod
3242 dnl command is sent from one controller and the reply is received by
3243 dnl other controllers.
3244 AT_SETUP([ofproto - requestforward (OpenFlow 1.4)])
3245 OVS_VSWITCHD_START
3246 on_exit 'kill `cat c1.pid c2.pid c3.pid`'
3247
3248 # Start two ovs-ofctl controller processes.
3249 AT_CAPTURE_FILE([monitor1.log])
3250 AT_CAPTURE_FILE([expout1])
3251 AT_CAPTURE_FILE([monitor2.log])
3252 AT_CAPTURE_FILE([expout2])
3253 AT_CAPTURE_FILE([monitor3.log])
3254 AT_CAPTURE_FILE([expout3])
3255
3256 ovs-ofctl -O OpenFlow15 monitor br0 --detach --no-chdir --pidfile=`pwd`/c1.pid --unixctl=`pwd`/c1
3257 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile=`pwd`/c2.pid --unixctl=`pwd`/c2
3258 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile=`pwd`/c3.pid --unixctl=`pwd`/c3
3259
3260 check_async () {
3261     for i in 1 3; do
3262         ovs-appctl -t `pwd`/c$i ofctl/barrier
3263         ovs-appctl -t `pwd`/c$i ofctl/set-output-file monitor$i.log
3264         : > expout$i
3265     done
3266
3267     printf '\n\n--- check_async %d ---\n\n\n' $1
3268     INDEX=$1
3269     shift
3270
3271     # OFPGC_ADD
3272     ovs-appctl -t `pwd`/c2 ofctl/send "050f0020000000020000000000000001 00100000 ffffffffffffffff 00000000"
3273     if test X"$1" = X"OFPGC_ADD"; then shift;
3274         echo >>expout2 "send: OFPT_GROUP_MOD (OF1.4):
3275  ADD group_id=1,type=all,bucket=actions=drop"
3276         echo >>expout1 "OFPT_REQUESTFORWARD (OF1.5): reason=group_mod
3277  ADD group_id=1,type=all,bucket=bucket_id:0,actions=drop"
3278         echo >>expout3 "OFPT_REQUESTFORWARD (OF1.4): reason=group_mod
3279  ADD group_id=1,type=all,bucket=actions=drop"
3280     fi
3281
3282     # OFPGC_MODIFY
3283     ovs-appctl -t `pwd`/c2 ofctl/send "050f0020000000020001010000000001 00100000 ffffffffffffffff 00000000"
3284     if test X"$1" = X"OFPGC_MODIFY"; then shift;
3285         echo >>expout2 "send: OFPT_GROUP_MOD (OF1.4):
3286  MOD group_id=1,type=select,bucket=weight:0,actions=drop"
3287         echo >>expout1 "OFPT_REQUESTFORWARD (OF1.5): reason=group_mod
3288  MOD group_id=1,type=select,bucket=bucket_id:0,weight:0,actions=drop"
3289         echo >>expout3 "OFPT_REQUESTFORWARD (OF1.4): reason=group_mod
3290  MOD group_id=1,type=select,bucket=weight:0,actions=drop"
3291     fi
3292
3293     ovs-appctl -t `pwd`/c1 ofctl/barrier
3294     echo >>expout1 "OFPT_BARRIER_REPLY (OF1.5):"
3295     ovs-appctl -t `pwd`/c2 ofctl/barrier
3296     echo >>expout2 "OFPT_BARRIER_REPLY (OF1.4):"
3297     ovs-appctl -t `pwd`/c3 ofctl/barrier
3298     echo >>expout3 "OFPT_BARRIER_REPLY (OF1.4):"
3299
3300     # Check output.
3301     for i in 1 3; do
3302         cp expout$i expout
3303         AT_CHECK(
3304       [[sed '
3305 s/ (xid=0x[0-9a-fA-F]*)//'< monitor$i.log]],
3306       [0], [expout])
3307     done
3308 }
3309
3310 # controller 1: Become slave
3311 ovs-appctl -t `pwd`/c1 ofctl/send 061800180000000300000003000000008000000000000002
3312
3313 # controller 2: Become master
3314 ovs-appctl -t `pwd`/c2 ofctl/send 051800180000000300000002000000008000000000000003
3315
3316 # controller 1: Become slave
3317 ovs-appctl -t `pwd`/c3 ofctl/send 051800180000000300000003000000008000000000000004
3318
3319 # controller 1: Enabled requestforward using set Asynchronous message
3320 ovs-appctl -t `pwd`/c1 ofctl/send 061c00280000000200000008000000050002000800000002000400080000001a000a000800000003
3321
3322 # controller 2: Enabled requestforward using set Asynchronous message
3323 ovs-appctl -t `pwd`/c2 ofctl/send 051c002800000002000100080000000200030008000000050005000800000005000b000800000003
3324
3325 # controller 1: Enabled requestforward using set Asynchronous message
3326 ovs-appctl -t `pwd`/c3 ofctl/send 051c00280000000200000008000000050002000800000002000400080000001a000a000800000003
3327 check_async 1 OFPGC_ADD OFPGC_MODIFY
3328
3329 OVS_VSWITCHD_STOP
3330 AT_CLEANUP
3331
3332 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
3333 dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
3334 dnl controllers despite the spec) as meaning a packet that was generated
3335 dnl by the controller.
3336 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.0)])
3337 OVS_VSWITCHD_START
3338 add_of_ports br0 1
3339
3340 # Start a monitor listening for packet-ins.
3341 AT_CHECK([ovs-ofctl -P standard monitor br0 --detach --no-chdir --pidfile])
3342 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
3343 ovs-appctl -t ovs-ofctl ofctl/barrier
3344 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3345 AT_CAPTURE_FILE([monitor.log])
3346
3347 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
3348 AT_CHECK([ovs-ofctl packet-out br0 none controller,1 '0001020304050010203040501234'])
3349 AT_CHECK([ovs-ofctl packet-out br0 controller controller,1 '0001020304050010203040505678'])
3350
3351 # Stop the monitor and check its output.
3352 ovs-appctl -t ovs-ofctl ofctl/barrier
3353 ovs-appctl -t ovs-ofctl exit
3354
3355 ovs-ofctl dump-ports br0
3356
3357 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3358 OFPT_PACKET_IN: total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
3359 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3360 OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
3361 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
3362 OFPT_BARRIER_REPLY:
3363 ])
3364
3365 OVS_VSWITCHD_STOP
3366 AT_CLEANUP
3367
3368 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
3369 dnl specified by OpenFlow 1.2) and OFPP_CONTROLLER (used by some
3370 dnl controllers despite the spec) as meaning a packet that was generated
3371 dnl by the controller.
3372 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.2)])
3373 OVS_VSWITCHD_START
3374
3375 # Start a monitor listening for packet-ins.
3376 AT_CHECK([ovs-ofctl -O OpenFlow12 -P standard monitor br0 --detach --no-chdir --pidfile])
3377 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
3378 ovs-appctl -t ovs-ofctl ofctl/barrier
3379 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3380 AT_CAPTURE_FILE([monitor.log])
3381
3382 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
3383 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none controller '0001020304050010203040501234'])
3384 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 4294967293 controller '0001020304050010203040505678'])
3385
3386 # Stop the monitor and check its output.
3387 ovs-appctl -t ovs-ofctl ofctl/barrier
3388 ovs-appctl -t ovs-ofctl exit
3389
3390 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3391 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
3392 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3393 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
3394 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
3395 OFPT_BARRIER_REPLY (OF1.2):
3396 ])
3397
3398 OVS_VSWITCHD_STOP
3399 AT_CLEANUP
3400
3401 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
3402 dnl specified by OpenFlow 1.1) and OFPP_CONTROLLER (used by some
3403 dnl controllers despite the spec) as meaning a packet that was generated
3404 dnl by the controller.
3405 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.1)])
3406 OVS_VSWITCHD_START
3407
3408 # Start a monitor listening for packet-ins.
3409 AT_CHECK([ovs-ofctl -O OpenFlow11 -P standard monitor br0 --detach --no-chdir --pidfile])
3410 ovs-appctl -t ovs-ofctl ofctl/send 0209000c0123456700000080
3411 ovs-appctl -t ovs-ofctl ofctl/barrier
3412 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3413 AT_CAPTURE_FILE([monitor.log])
3414
3415 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
3416 AT_CHECK([ovs-ofctl -O OpenFlow11 packet-out br0 none controller '0001020304050010203040501234'])
3417 AT_CHECK([ovs-ofctl -O OpenFlow11 packet-out br0 4294967293 controller '0001020304050010203040505678'])
3418
3419 # Stop the monitor and check its output.
3420 ovs-appctl -t ovs-ofctl ofctl/barrier
3421 ovs-appctl -t ovs-ofctl exit
3422
3423 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3424 OFPT_PACKET_IN (OF1.1): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
3425 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3426 OFPT_PACKET_IN (OF1.1): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
3427 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
3428 OFPT_BARRIER_REPLY (OF1.1):
3429 ])
3430
3431 OVS_VSWITCHD_STOP
3432 AT_CLEANUP
3433
3434 dnl This test checks that metadata and userdata are encoded in NXT_PACKET_IN2.
3435 AT_SETUP([ofproto - packet-out with metadata and userdata (NXT_PACKET_IN2)])
3436 OVS_VSWITCHD_START
3437
3438 # Start a monitor listening for packet-ins.
3439 AT_CHECK([ovs-ofctl -P nxt_packet_in2 monitor br0 --detach --no-chdir --pidfile])
3440 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
3441 ovs-appctl -t ovs-ofctl ofctl/barrier
3442 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3443 AT_CAPTURE_FILE([monitor.log])
3444
3445 # Send a packet-out with a load action to set some metadata, and forward to controller
3446 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'])
3447
3448 # Stop the monitor and check its output.
3449 ovs-appctl -t ovs-ofctl ofctl/barrier
3450 ovs-appctl -t ovs-ofctl exit
3451
3452 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3453 NXT_PACKET_IN2: total_len=14 pkt_mark=0xaa,metadata=0xfafafafa5a5a5a5a,in_port=CONTROLLER (via action) data_len=14 (unbuffered)
3454  userdata=01.02.03.04.05
3455 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3456 OFPT_BARRIER_REPLY:
3457 ])
3458
3459 OVS_VSWITCHD_STOP
3460 AT_CLEANUP
3461
3462 dnl This test checks that metadata is encoded in packet_in structures,
3463 dnl supported by NXAST.
3464 AT_SETUP([ofproto - packet-out with metadata (NXM)])
3465 OVS_VSWITCHD_START
3466
3467 # Start a monitor listening for packet-ins.
3468 AT_CHECK([ovs-ofctl -P nxt_packet_in monitor br0 --detach --no-chdir --pidfile])
3469 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
3470 ovs-appctl -t ovs-ofctl ofctl/barrier
3471 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3472 AT_CAPTURE_FILE([monitor.log])
3473
3474 # Send a packet-out with a load action to set some metadata, and forward to controller
3475 AT_CHECK([ovs-ofctl packet-out br0 controller 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), load(0xaa->NXM_NX_PKT_MARK[[]]), controller' '0001020304050010203040501234'])
3476
3477 # Stop the monitor and check its output.
3478 ovs-appctl -t ovs-ofctl ofctl/barrier
3479 ovs-appctl -t ovs-ofctl exit
3480
3481 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3482 NXT_PACKET_IN: total_len=14 pkt_mark=0xaa,metadata=0xfafafafa5a5a5a5a,in_port=CONTROLLER (via action) data_len=14 (unbuffered)
3483 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3484 OFPT_BARRIER_REPLY:
3485 ])
3486
3487 OVS_VSWITCHD_STOP
3488 AT_CLEANUP
3489
3490 dnl This test checks that metadata is encoded in packet_in structures,
3491 dnl supported by NXAST.
3492 AT_SETUP([ofproto - packet-out with metadata (OpenFlow 1.2)])
3493 OVS_VSWITCHD_START
3494
3495 # Start a monitor listening for packet-ins.
3496 AT_CHECK([ovs-ofctl -O OpenFlow12 -P standard monitor br0 --detach --no-chdir --pidfile])
3497 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
3498 ovs-appctl -t ovs-ofctl ofctl/barrier
3499 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3500 AT_CAPTURE_FILE([monitor.log])
3501
3502 # Send a packet-out with a set-field action to set some metadata, and forward to controller
3503 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none 'set_field:0xfafafafa5a5a5a5a->metadata, controller' '0001020304050010203040501234'])
3504
3505 # Stop the monitor and check its output.
3506 ovs-appctl -t ovs-ofctl ofctl/barrier
3507 ovs-appctl -t ovs-ofctl exit
3508
3509 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3510 OFPT_PACKET_IN (OF1.2): total_len=14 metadata=0xfafafafa5a5a5a5a,in_port=ANY (via action) data_len=14 (unbuffered)
3511 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3512 OFPT_BARRIER_REPLY (OF1.2):
3513 ])
3514
3515 OVS_VSWITCHD_STOP
3516 AT_CLEANUP
3517
3518 dnl This test checks that metadata is encoded in packet_in structures,
3519 dnl supported by NXAST.
3520 AT_SETUP([ofproto - packet-out with metadata and dual set_field (OpenFlow 1.3)])
3521 OVS_VSWITCHD_START
3522
3523 # Start a monitor listening for packet-ins.
3524 AT_CHECK([ovs-ofctl -O OpenFlow13 -P standard monitor br0 --detach --no-chdir --pidfile])
3525 ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
3526 ovs-appctl -t ovs-ofctl ofctl/barrier
3527 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3528 AT_CAPTURE_FILE([monitor.log])
3529
3530 # Send a packet-out with a couple of set-field action to set some metadata, and forward to controller
3531 AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 none 'set_field:0xfafafafa5a5a5a5a->metadata, set_field:0x6b->metadata, controller' '0001020304050010203040501234'])
3532
3533 # Stop the monitor and check its output.
3534 ovs-appctl -t ovs-ofctl ofctl/barrier
3535 ovs-appctl -t ovs-ofctl exit
3536
3537 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3538 OFPT_PACKET_IN (OF1.3): total_len=14 metadata=0x6b,in_port=ANY (via action) data_len=14 (unbuffered)
3539 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3540 OFPT_BARRIER_REPLY (OF1.3):
3541 ])
3542
3543 OVS_VSWITCHD_STOP
3544 AT_CLEANUP
3545
3546 dnl This test checks that tunnel metadata is encoded in packet_in structures.
3547 AT_SETUP([ofproto - packet-out with tunnel metadata (OpenFlow 1.2)])
3548 OVS_VSWITCHD_START
3549
3550 # Start a monitor listening for packet-ins.
3551 AT_CHECK([ovs-ofctl -O OpenFlow12 -P standard monitor br0 --detach --no-chdir --pidfile])
3552 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
3553 ovs-appctl -t ovs-ofctl ofctl/barrier
3554 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3555 AT_CAPTURE_FILE([monitor.log])
3556
3557 # Send a packet-out with set field actions to set some tunnel metadata, and forward to controller
3558 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'])
3559
3560 # Stop the monitor and check its output.
3561 ovs-appctl -t ovs-ofctl ofctl/barrier
3562 ovs-appctl -t ovs-ofctl exit
3563
3564 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3565 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)
3566 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3567 OFPT_BARRIER_REPLY (OF1.2):
3568 ])
3569
3570 OVS_VSWITCHD_STOP
3571 AT_CLEANUP
3572
3573 m4_divert_push([PREPARE_TESTS])
3574 # Sorts groups of lines that start with a space, without moving them
3575 # past the nearest line that does not start with a space.
3576 multiline_sort () {
3577     ${PERL} -e '
3578         use warnings;
3579         use strict;
3580         my @buffer = ();
3581         while (<STDIN>) {
3582             if (/^ /) {
3583                 push(@buffer, $_);
3584             } else {
3585                 print $_ foreach sort(@buffer);
3586                 print $_;
3587                 @buffer = ();
3588             }
3589         }
3590         print $_ foreach sort(@buffer);
3591 '
3592 }
3593 m4_divert_pop([PREPARE_TESTS])
3594
3595 AT_SETUP([ofproto - flow monitoring])
3596 AT_KEYWORDS([monitor])
3597 OVS_VSWITCHD_START
3598
3599 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
3600
3601 # Start a monitor watching the flow table and check the initial reply.
3602 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
3603 AT_CAPTURE_FILE([monitor.log])
3604 ovs-appctl -t ovs-ofctl ofctl/barrier
3605 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3606   [NXST_FLOW_MONITOR reply:
3607  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
3608 OFPT_BARRIER_REPLY:
3609 ])
3610
3611 # Add, delete, and modify some flows and check the updates.
3612 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3613 ovs-ofctl add-flow br0 in_port=0,dl_vlan=124,actions=output:2
3614 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:5
3615 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=0,actions=output:6
3616 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=1,actions=output:7
3617 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:8
3618 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=0,actions=output:9
3619 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=1,actions=output:10
3620 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,actions=output:11
3621 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=0,actions=output:12
3622 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=1,actions=output:13
3623 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,actions=output:14
3624 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:15
3625 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:16
3626 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:17
3627 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:18
3628 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:19
3629 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:20
3630 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=0,actions=output:21
3631 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=1,actions=output:22
3632 ovs-ofctl add-flow br0 in_port=0,actions=output:23
3633 ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:3
3634 ovs-ofctl mod-flows br0 cookie=5,dl_vlan=123,actions=output:3
3635 ovs-ofctl del-flows br0 dl_vlan=123
3636 ovs-ofctl del-flows br0
3637 ovs-appctl -t ovs-ofctl ofctl/barrier
3638 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | multiline_sort], [0],
3639 [NXST_FLOW_MONITOR reply (xid=0x0):
3640  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
3641 NXST_FLOW_MONITOR reply (xid=0x0):
3642  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:5
3643 NXST_FLOW_MONITOR reply (xid=0x0):
3644  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:6
3645 NXST_FLOW_MONITOR reply (xid=0x0):
3646  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:7
3647 NXST_FLOW_MONITOR reply (xid=0x0):
3648  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:8
3649 NXST_FLOW_MONITOR reply (xid=0x0):
3650  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:9
3651 NXST_FLOW_MONITOR reply (xid=0x0):
3652  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:10
3653 NXST_FLOW_MONITOR reply (xid=0x0):
3654  event=ADDED table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
3655 NXST_FLOW_MONITOR reply (xid=0x0):
3656  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
3657 NXST_FLOW_MONITOR reply (xid=0x0):
3658  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
3659 NXST_FLOW_MONITOR reply (xid=0x0):
3660  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
3661 NXST_FLOW_MONITOR reply (xid=0x0):
3662  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:15
3663 NXST_FLOW_MONITOR reply (xid=0x0):
3664  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:16
3665 NXST_FLOW_MONITOR reply (xid=0x0):
3666  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:17
3667 NXST_FLOW_MONITOR reply (xid=0x0):
3668  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
3669 NXST_FLOW_MONITOR reply (xid=0x0):
3670  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
3671 NXST_FLOW_MONITOR reply (xid=0x0):
3672  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
3673 NXST_FLOW_MONITOR reply (xid=0x0):
3674  event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
3675 NXST_FLOW_MONITOR reply (xid=0x0):
3676  event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
3677 NXST_FLOW_MONITOR reply (xid=0x0):
3678  event=ADDED table=0 cookie=0 in_port=0 actions=output:23
3679 NXST_FLOW_MONITOR reply (xid=0x0):
3680  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:3
3681  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
3682  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
3683 NXST_FLOW_MONITOR reply (xid=0x0):
3684  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
3685  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
3686  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
3687 NXST_FLOW_MONITOR reply (xid=0x0):
3688  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
3689  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
3690  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
3691 NXST_FLOW_MONITOR reply (xid=0x0):
3692  event=DELETED reason=delete table=0 cookie=0 in_port=0 actions=output:23
3693  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
3694  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
3695  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
3696  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
3697  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
3698  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
3699  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
3700  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
3701  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
3702  event=DELETED reason=delete table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
3703 OFPT_BARRIER_REPLY:
3704 ])
3705
3706 # Check that our own changes are reported as full updates.
3707 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3708 ovs-ofctl add-flow br0 in_port=1,actions=output:2
3709 ovs-ofctl add-flow br0 in_port=2,actions=output:1
3710 ovs-appctl -t ovs-ofctl ofctl/barrier
3711 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
3712 ovs-appctl -t ovs-ofctl ofctl/barrier
3713 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
3714 ])
3715 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | multiline_sort], [0],
3716 [NXST_FLOW_MONITOR reply (xid=0x0):
3717  event=ADDED table=0 cookie=0 in_port=1 actions=output:2
3718 NXST_FLOW_MONITOR reply (xid=0x0):
3719  event=ADDED table=0 cookie=0 in_port=2 actions=output:1
3720 OFPT_BARRIER_REPLY:
3721 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
3722 NXST_FLOW_MONITOR reply (xid=0x0):
3723  event=DELETED reason=delete table=0 cookie=0 in_port=1 actions=output:2
3724  event=DELETED reason=delete table=0 cookie=0 in_port=2 actions=output:1
3725 OFPT_BARRIER_REPLY:
3726 ])
3727
3728 ovs-appctl -t ovs-ofctl exit
3729 OVS_VSWITCHD_STOP
3730 AT_CLEANUP
3731
3732 AT_SETUP([ofproto - flow monitoring with !own])
3733 AT_KEYWORDS([monitor])
3734 OVS_VSWITCHD_START
3735
3736 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
3737
3738 # Start a monitor watching the flow table and check the initial reply.
3739 ovs-ofctl monitor br0 watch:\!own --detach --no-chdir --pidfile >monitor.log 2>&1
3740 AT_CAPTURE_FILE([monitor.log])
3741 ovs-appctl -t ovs-ofctl ofctl/barrier
3742 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3743   [NXST_FLOW_MONITOR reply:
3744  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
3745 OFPT_BARRIER_REPLY:
3746 ])
3747
3748 # Check that our own changes are reported as abbreviations.
3749 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3750 ovs-ofctl add-flow br0 in_port=1,actions=output:2
3751 ovs-ofctl add-flow br0 in_port=2,actions=output:1
3752 ovs-appctl -t ovs-ofctl ofctl/barrier
3753 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
3754 ovs-appctl -t ovs-ofctl ofctl/barrier
3755 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
3756 ])
3757 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3758 [NXST_FLOW_MONITOR reply (xid=0x0):
3759  event=ADDED table=0 cookie=0 in_port=1 actions=output:2
3760 NXST_FLOW_MONITOR reply (xid=0x0):
3761  event=ADDED table=0 cookie=0 in_port=2 actions=output:1
3762 OFPT_BARRIER_REPLY:
3763 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
3764 NXST_FLOW_MONITOR reply (xid=0x0):
3765  event=ABBREV xid=0x12345678
3766 OFPT_BARRIER_REPLY:
3767 ])
3768
3769 ovs-appctl -t ovs-ofctl exit
3770 OVS_VSWITCHD_STOP
3771 AT_CLEANUP
3772
3773 AT_SETUP([ofproto - flow monitoring with out_port])
3774 AT_KEYWORDS([monitor])
3775 OVS_VSWITCHD_START
3776
3777 ovs-ofctl add-flow br0 in_port=0,dl_vlan=121,actions=output:1
3778 ovs-ofctl add-flow br0 in_port=0,dl_vlan=122,actions=output:1
3779 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:2
3780
3781 # Start a monitor watching the flow table and check the initial reply.
3782 ovs-ofctl monitor br0 watch:out_port=2 --detach --no-chdir --pidfile >monitor.log 2>&1
3783 AT_CAPTURE_FILE([monitor.log])
3784 ovs-appctl -t ovs-ofctl ofctl/barrier
3785 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3786   [NXST_FLOW_MONITOR reply:
3787  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:2
3788 OFPT_BARRIER_REPLY:
3789 ])
3790
3791 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3792
3793 # Add, modify flows and check the updates.
3794 ovs-ofctl mod-flows br0 dl_vlan=121,actions=drop
3795 ovs-ofctl mod-flows br0 dl_vlan=122,actions=output:1,output:2
3796 ovs-appctl -t ovs-ofctl ofctl/barrier
3797
3798 ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:1,output:2
3799 ovs-appctl -t ovs-ofctl ofctl/barrier
3800
3801 ovs-ofctl mod-flows br0 dl_vlan=122,actions=output:1
3802 ovs-appctl -t ovs-ofctl ofctl/barrier
3803 ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:2
3804 ovs-appctl -t ovs-ofctl ofctl/barrier
3805
3806 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3807 [NXST_FLOW_MONITOR reply (xid=0x0):
3808  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=122 actions=output:1,output:2
3809 OFPT_BARRIER_REPLY:
3810 NXST_FLOW_MONITOR reply (xid=0x0):
3811  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1,output:2
3812 OFPT_BARRIER_REPLY:
3813 NXST_FLOW_MONITOR reply (xid=0x0):
3814  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=122 actions=output:1
3815 OFPT_BARRIER_REPLY:
3816 NXST_FLOW_MONITOR reply (xid=0x0):
3817  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:2
3818 OFPT_BARRIER_REPLY:
3819 ])
3820
3821 ovs-appctl -t ovs-ofctl exit
3822 OVS_VSWITCHD_STOP
3823 AT_CLEANUP
3824
3825 AT_SETUP([ofproto - flow monitoring pause and resume])
3826 AT_KEYWORDS([monitor])
3827
3828 # The maximum socket receive buffer size is important for this test, which
3829 # tests behavior when the receive buffer overflows.
3830 if test -e /proc/sys/net/core/rmem_max; then
3831     # Linux
3832     rmem_max=`cat /proc/sys/net/core/rmem_max`
3833 elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
3834     : # FreeBSD, NetBSD
3835 else
3836     # Don't know how to get maximum socket receive buffer on this OS
3837     AT_SKIP_IF([:])
3838 fi
3839 # Calculate the total amount of queuing: rmem_max in the kernel, 128 kB
3840 # in ofproto sending userspace (see ofmonitor_flush() in connmgr.c).
3841 queue_size=`expr $rmem_max + 128 \* 1024`
3842 echo rmem_max=$rmem_max queue_size=$queue_size
3843
3844 # If there's too much queuing skip the test to avoid timing out.
3845 AT_SKIP_IF([test $rmem_max -gt 1048576])
3846
3847 # Each flow update message takes up at least 48 bytes of space in queues
3848 # and in practice more than that.
3849 n_msgs=`expr $queue_size / 48`
3850 echo n_msgs=$n_msgs
3851
3852 OVS_VSWITCHD_START
3853
3854 # Start a monitor watching the flow table, then make it block.
3855 on_exit 'kill `cat ovs-ofctl.pid`'
3856 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
3857 AT_CAPTURE_FILE([monitor.log])
3858 ovs-appctl -t ovs-ofctl ofctl/block
3859
3860 # Add $n_msgs flows.
3861 (echo "in_port=2,actions=output:2"
3862 ${PERL} -e '
3863     for ($i = 0; $i < '$n_msgs'; $i++) {
3864         print "cookie=1,reg1=$i,actions=drop\n";
3865     }
3866 ') > flows.txt
3867 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
3868 # Check that multipart flow dumps work properly:
3869 AT_CHECK([ovs-ofctl diff-flows br0 flows.txt])
3870 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,cookie=3,actions=drop])
3871 AT_CHECK([ovs-ofctl mod-flows br0 in_port=2,cookie=2,actions=output:2])
3872 AT_CHECK([ovs-ofctl del-flows br0 cookie=1/-1])
3873
3874 ovs-appctl -t ovs-ofctl ofctl/unblock
3875
3876 # Wait for the connection resumed.
3877 # A barrier doesn't work for this purpose.
3878 #    https://www.mail-archive.com/dev@openvswitch.org/msg27013.html
3879 #    https://www.mail-archive.com/dev@openvswitch.org/msg27675.html
3880 OVS_WAIT_UNTIL([grep NXT_FLOW_MONITOR_RESUMED monitor.log])
3881
3882 ovs-appctl -t ovs-ofctl exit
3883
3884 # Check that the flow monitor reported the same number of flows
3885 # added and deleted, but fewer than we actually added and deleted.
3886 adds=`grep -c 'ADDED.*reg1=' monitor.log`
3887 deletes=`grep -c 'DELETED.*reg1=' monitor.log`
3888 echo adds=$adds deletes=$deletes
3889 AT_CHECK([test $adds -gt 100 && test $adds -lt $n_msgs])
3890 AT_CHECK([test $adds = $deletes])
3891
3892 # Check that the flow monitor reported everything in the expected order:
3893 #
3894 #     event=ADDED table=0 cookie=0x1 reg1=0x22
3895 # ...
3896 #    NXT_FLOW_MONITOR_PAUSED:
3897 # ...
3898 #     event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
3899 # ...
3900 #     event=ADDED table=0 cookie=0x3 in_port=1
3901 #     event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
3902 #    NXT_FLOW_MONITOR_RESUMED:
3903 #
3904 # except that, between the PAUSED and RESUMED, the order of the ADDED
3905 # and MODIFIED lines lines depends on hash order, that is, it varies
3906 # as we change the hash function or change architecture.  Therefore,
3907 # we use a couple of tests below to accept both orders.
3908 AT_CHECK([ofctl_strip < monitor.log | sed -n -e '
3909 /reg1=0x22$/p
3910 /cookie=0x[[23]]/p
3911 /NXT_FLOW_MONITOR_PAUSED:/p
3912 /NXT_FLOW_MONITOR_RESUMED:/p
3913 ' > monitor.log.subset])
3914 AT_CHECK([grep -v MODIFIED monitor.log.subset], [0], [dnl
3915  event=ADDED table=0 cookie=0x1 reg1=0x22
3916 NXT_FLOW_MONITOR_PAUSED:
3917  event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
3918  event=ADDED table=0 cookie=0x3 in_port=1
3919 NXT_FLOW_MONITOR_RESUMED:
3920 ])
3921 AT_CHECK([grep -v ADDED monitor.log.subset], [0], [dnl
3922 NXT_FLOW_MONITOR_PAUSED:
3923  event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
3924  event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
3925 NXT_FLOW_MONITOR_RESUMED:
3926 ])
3927
3928 OVS_VSWITCHD_STOP
3929 AT_CLEANUP
3930
3931 AT_SETUP([ofproto - event filtering (OpenFlow 1.3)])
3932 AT_KEYWORDS([monitor])
3933 OVS_VSWITCHD_START
3934
3935 # Start a monitor, use the required protocol version
3936 ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3937 AT_CAPTURE_FILE([monitor.log])
3938
3939 # Send an OpenFlow13 message (04), OFPT_GET_ASYNC_REQUEST (1a), length (8), xid (0a)
3940 ovs-appctl -t ovs-ofctl ofctl/send 041a00080000000a
3941 ovs-appctl -t ovs-ofctl ofctl/barrier
3942
3943 # Check default setting
3944 read -r -d '' expected <<'EOF'
3945 EOF
3946
3947 AT_CHECK([ofctl_strip < monitor.log], [], [dnl
3948 send: OFPT_GET_ASYNC_REQUEST (OF1.3):
3949 OFPT_GET_ASYNC_REPLY (OF1.3):
3950  master:
3951        PACKET_IN: no_match action
3952      PORT_STATUS: add delete modify
3953     FLOW_REMOVED: idle hard delete
3954      ROLE_STATUS: (off)
3955     TABLE_STATUS: (off)
3956   REQUESTFORWARD: (off)
3957
3958  slave:
3959        PACKET_IN: (off)
3960      PORT_STATUS: add delete modify
3961     FLOW_REMOVED: (off)
3962      ROLE_STATUS: (off)
3963     TABLE_STATUS: (off)
3964   REQUESTFORWARD: (off)
3965 OFPT_BARRIER_REPLY (OF1.3):
3966 ])
3967
3968 OVS_VSWITCHD_STOP
3969 AT_CLEANUP
3970
3971 AT_SETUP([ofproto - ofport_request])
3972 OVS_VSWITCHD_START
3973 add_of_ports br0 1 2 3
3974
3975 set_and_check_specific_ofports () {
3976     ovs-vsctl set Interface p1 ofport_request="$1" -- \
3977               set Interface p2 ofport_request="$2" -- \
3978               set Interface p3 ofport_request="$3"
3979     ofports=`ovs-vsctl get Interface p1 ofport -- \
3980                        get Interface p2 ofport -- \
3981                        get Interface p3 ofport`
3982     AT_CHECK_UNQUOTED([echo $ofports], [0], [$1 $2 $3
3983 ])
3984 }
3985 for pre in      '1 2 3' '1 3 2' '2 1 3' '2 3 1' '3 1 2' '3 2 1'; do
3986     for post in '1 2 3' '1 3 2' '2 1 3' '2 3 1' '3 1 2' '3 2 1'; do
3987         echo -----------------------------------------------------------
3988         echo "Check changing port numbers from $pre to $post"
3989         set_and_check_specific_ofports $pre
3990         set_and_check_specific_ofports $post
3991     done
3992 done
3993
3994 ovs-vsctl del-port p3
3995
3996 set_and_check_poorly_specified_ofports () {
3997     ovs-vsctl set Interface p1 ofport_request="$1" -- \
3998               set Interface p2 ofport_request="$2"
3999     p1=`ovs-vsctl get Interface p1 ofport`
4000     p2=`ovs-vsctl get Interface p2 ofport`
4001     echo $p1 $p2
4002
4003     AT_CHECK([test "$p1" != "$p2"])
4004     if test "$1" = "$2" && test "$1" != '[[]]'; then
4005         # One port number must be the requested one.
4006         AT_CHECK([test "$p1" = "$1" || test "$p2" = "$1"])
4007         # The other port number must be different (already tested above).
4008     else
4009         AT_CHECK([test "$1" = '[[]]' || test "$p1" = "$1"])
4010         AT_CHECK([test "$2" = '[[]]' || test "$p2" = "$2"])
4011     fi
4012 }
4013 for pre in      '1 2' '[[]] 2' '1 [[]]' '[[]] [[]]' '2 1' '[[]] 1' '2 [[]]' \
4014                 '1 1' '2 2'; do
4015     for post in '1 2' '[[]] 2' '1 [[]]' '[[]] [[]]' '2 1' '[[]] 1' '2 [[]]' \
4016                 '1 1' '2 2'; do
4017         echo -----------------------------------------------------------
4018         echo "Check changing port numbers from $pre to $post"
4019         set_and_check_poorly_specified_ofports $pre
4020         set_and_check_poorly_specified_ofports $post
4021     done
4022 done
4023 OVS_VSWITCHD_STOP
4024 AT_CLEANUP
4025
4026
4027 AT_SETUP([ofproto - bundles, open (OpenFlow 1.4)])
4028 AT_KEYWORDS([monitor])
4029 OVS_VSWITCHD_START
4030
4031 # Start a monitor, use the required protocol version
4032 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4033 AT_CAPTURE_FILE([monitor.log])
4034
4035 # Send an OpenFlow14 message (05), OFPT_BUNDLE_CONTROL (21), length (10), xid (0a)
4036 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
4037 ovs-appctl -t ovs-ofctl ofctl/barrier
4038 ovs-appctl -t ovs-ofctl exit
4039
4040 AT_CHECK([ofctl_strip < monitor.log], [], [dnl
4041 send: OFPT_BUNDLE_CONTROL (OF1.4):
4042  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4043 OFPT_BUNDLE_CONTROL (OF1.4):
4044  bundle_id=0x1 type=OPEN_REPLY flags=0
4045 OFPT_BARRIER_REPLY (OF1.4):
4046 ])
4047
4048 OVS_VSWITCHD_STOP
4049 AT_CLEANUP
4050
4051 AT_SETUP([ofproto - bundles, double open (OpenFlow 1.4)])
4052 AT_KEYWORDS([monitor])
4053 OVS_VSWITCHD_START
4054
4055 # Start a monitor, use the required protocol version
4056 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4057 AT_CAPTURE_FILE([monitor.log])
4058
4059 # Send twice an OpenFlow14 message (05), OFPT_BUNDLE_CONTROL (21), length (10), xid (0a)
4060 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
4061 ovs-appctl -t ovs-ofctl ofctl/barrier
4062 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
4063 ovs-appctl -t ovs-ofctl ofctl/barrier
4064 ovs-appctl -t ovs-ofctl exit
4065
4066 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4067 send: OFPT_BUNDLE_CONTROL (OF1.4):
4068  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4069 OFPT_BUNDLE_CONTROL (OF1.4):
4070  bundle_id=0x1 type=OPEN_REPLY flags=0
4071 OFPT_BARRIER_REPLY (OF1.4):
4072 send: OFPT_BUNDLE_CONTROL (OF1.4):
4073  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4074 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
4075 OFPT_BUNDLE_CONTROL (OF1.4):
4076  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4077 OFPT_BARRIER_REPLY (OF1.4):
4078 ])
4079
4080 OVS_VSWITCHD_STOP
4081 AT_CLEANUP
4082
4083 AT_SETUP([ofproto - bundle close without open (OpenFlow 1.4)])
4084 AT_KEYWORDS([monitor])
4085 OVS_VSWITCHD_START
4086
4087 # Start a monitor, use the required protocol version
4088 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4089 AT_CAPTURE_FILE([monitor.log])
4090
4091 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 02"
4092 ovs-appctl -t ovs-ofctl ofctl/barrier
4093 ovs-appctl -t ovs-ofctl exit
4094
4095 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4096 send: OFPT_BUNDLE_CONTROL (OF1.4):
4097  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
4098 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
4099 OFPT_BUNDLE_CONTROL (OF1.4):
4100  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
4101 OFPT_BARRIER_REPLY (OF1.4):
4102 ])
4103
4104 OVS_VSWITCHD_STOP
4105 AT_CLEANUP
4106
4107 AT_SETUP([ofproto - bundle double close (OpenFlow 1.4)])
4108 AT_KEYWORDS([monitor])
4109 OVS_VSWITCHD_START
4110
4111 # Start a monitor, use the required protocol version
4112 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4113 AT_CAPTURE_FILE([monitor.log])
4114
4115 # Open, Close, Close
4116 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
4117 ovs-appctl -t ovs-ofctl ofctl/barrier
4118 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 02"
4119 ovs-appctl -t ovs-ofctl ofctl/barrier
4120 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 02"
4121 ovs-appctl -t ovs-ofctl ofctl/barrier
4122 ovs-appctl -t ovs-ofctl exit
4123
4124 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4125 send: OFPT_BUNDLE_CONTROL (OF1.4):
4126  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4127 OFPT_BUNDLE_CONTROL (OF1.4):
4128  bundle_id=0x1 type=OPEN_REPLY flags=0
4129 OFPT_BARRIER_REPLY (OF1.4):
4130 send: OFPT_BUNDLE_CONTROL (OF1.4):
4131  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
4132 OFPT_BUNDLE_CONTROL (OF1.4):
4133  bundle_id=0x1 type=CLOSE_REPLY flags=0
4134 OFPT_BARRIER_REPLY (OF1.4):
4135 send: OFPT_BUNDLE_CONTROL (OF1.4):
4136  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
4137 OFPT_ERROR (OF1.4): OFPBFC_BUNDLE_CLOSED
4138 OFPT_BUNDLE_CONTROL (OF1.4):
4139  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
4140 OFPT_BARRIER_REPLY (OF1.4):
4141 ])
4142
4143 OVS_VSWITCHD_STOP
4144 AT_CLEANUP
4145
4146 AT_SETUP([ofproto - bundle close, different flags (OpenFlow 1.4)])
4147 AT_KEYWORDS([monitor])
4148 OVS_VSWITCHD_START
4149
4150 # Start a monitor, use the required protocol version
4151 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4152 AT_CAPTURE_FILE([monitor.log])
4153
4154 # Open, Close, Close
4155 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
4156 ovs-appctl -t ovs-ofctl ofctl/barrier
4157 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 01"
4158 ovs-appctl -t ovs-ofctl ofctl/barrier
4159 ovs-appctl -t ovs-ofctl exit
4160
4161 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4162 send: OFPT_BUNDLE_CONTROL (OF1.4):
4163  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4164 OFPT_BUNDLE_CONTROL (OF1.4):
4165  bundle_id=0x1 type=OPEN_REPLY flags=0
4166 OFPT_BARRIER_REPLY (OF1.4):
4167 send: OFPT_BUNDLE_CONTROL (OF1.4):
4168  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
4169 OFPT_ERROR (OF1.4): OFPBFC_BAD_FLAGS
4170 OFPT_BUNDLE_CONTROL (OF1.4):
4171  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
4172 OFPT_BARRIER_REPLY (OF1.4):
4173 ])
4174
4175 OVS_VSWITCHD_STOP
4176 AT_CLEANUP
4177
4178 AT_SETUP([ofproto - bundle commit without open (OpenFlow 1.4)])
4179 AT_KEYWORDS([monitor])
4180 OVS_VSWITCHD_START
4181
4182 # Start a monitor, use the required protocol version
4183 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4184 AT_CAPTURE_FILE([monitor.log])
4185
4186 # Open, Close, Close
4187 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 04 00 02"
4188 ovs-appctl -t ovs-ofctl ofctl/barrier
4189 ovs-appctl -t ovs-ofctl exit
4190
4191 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4192 send: OFPT_BUNDLE_CONTROL (OF1.4):
4193  bundle_id=0x1 type=COMMIT_REQUEST flags=ordered
4194 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
4195 OFPT_BUNDLE_CONTROL (OF1.4):
4196  bundle_id=0x1 type=COMMIT_REQUEST flags=ordered
4197 OFPT_BARRIER_REPLY (OF1.4):
4198 ])
4199
4200 OVS_VSWITCHD_STOP
4201 AT_CLEANUP
4202
4203 AT_SETUP([ofproto - bundle commit, different flags (OpenFlow 1.4)])
4204 AT_KEYWORDS([monitor])
4205 OVS_VSWITCHD_START
4206
4207 # Start a monitor, use the required protocol version
4208 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4209 AT_CAPTURE_FILE([monitor.log])
4210
4211 # Open, Close, Close
4212 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
4213 ovs-appctl -t ovs-ofctl ofctl/barrier
4214 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 04 00 01"
4215 ovs-appctl -t ovs-ofctl ofctl/barrier
4216 ovs-appctl -t ovs-ofctl exit
4217
4218 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4219 send: OFPT_BUNDLE_CONTROL (OF1.4):
4220  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4221 OFPT_BUNDLE_CONTROL (OF1.4):
4222  bundle_id=0x1 type=OPEN_REPLY flags=0
4223 OFPT_BARRIER_REPLY (OF1.4):
4224 send: OFPT_BUNDLE_CONTROL (OF1.4):
4225  bundle_id=0x1 type=COMMIT_REQUEST flags=atomic
4226 OFPT_ERROR (OF1.4): OFPBFC_BAD_FLAGS
4227 OFPT_BUNDLE_CONTROL (OF1.4):
4228  bundle_id=0x1 type=COMMIT_REQUEST flags=atomic
4229 OFPT_BARRIER_REPLY (OF1.4):
4230 ])
4231
4232 OVS_VSWITCHD_STOP
4233 AT_CLEANUP
4234
4235 AT_SETUP([ofproto - bundle discard without open (OpenFlow 1.4)])
4236 AT_KEYWORDS([monitor])
4237 OVS_VSWITCHD_START
4238
4239 # Start a monitor, use the required protocol version
4240 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4241 AT_CAPTURE_FILE([monitor.log])
4242
4243 # Open, Close, Close
4244 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 06 00 02"
4245 ovs-appctl -t ovs-ofctl ofctl/barrier
4246 ovs-appctl -t ovs-ofctl exit
4247
4248 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4249 send: OFPT_BUNDLE_CONTROL (OF1.4):
4250  bundle_id=0x1 type=DISCARD_REQUEST flags=ordered
4251 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
4252 OFPT_BUNDLE_CONTROL (OF1.4):
4253  bundle_id=0x1 type=DISCARD_REQUEST flags=ordered
4254 OFPT_BARRIER_REPLY (OF1.4):
4255 ])
4256
4257 OVS_VSWITCHD_STOP
4258 AT_CLEANUP
4259
4260
4261 AT_SETUP([ofproto - bundle with multiple flow mods (OpenFlow 1.4)])
4262 AT_KEYWORDS([monitor])
4263 OVS_VSWITCHD_START
4264
4265 AT_CHECK([ovs-appctl vlog/set vconn:dbg])
4266
4267 AT_CHECK([ovs-ofctl del-flows br0])
4268
4269 AT_DATA([flows.txt], [dnl
4270 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=1
4271 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=2
4272 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=3
4273 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=4
4274 delete
4275 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=5
4276 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=6
4277 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=7
4278 delete in_port=2 dl_src=00:88:99:aa:bb:cc
4279 ])
4280
4281 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
4282
4283 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4284  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:5
4285  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:6
4286 NXST_FLOW reply:
4287 ])
4288
4289 AT_DATA([flows.txt], [dnl
4290 modify actions=drop
4291 modify_strict in_port=2 dl_src=00:77:88:99:aa:bb actions=7
4292 ])
4293
4294 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
4295
4296 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4297  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4298  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:7
4299 NXST_FLOW reply:
4300 ])
4301
4302 # Adding an existing flow acts as a modify, and delete_strict also works.
4303 AT_DATA([flows.txt], [dnl
4304 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=8
4305 delete_strict in_port=2 dl_src=00:66:77:88:99:aa
4306 add in_port=2 dl_src=00:66:77:88:99:aa actions=drop
4307 ])
4308
4309 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
4310
4311 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4312  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:8
4313  in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4314 NXST_FLOW reply:
4315 ])
4316
4317 dnl Check logs for OpenFlow trace
4318 # Prevent race.
4319 OVS_WAIT_UNTIL([vconn_sub < ovs-vswitchd.log | test `grep -- "|vconn|DBG|unix: sent (Success): NXST_FLOW reply" | wc -l` -ge 3])
4320 AT_CHECK([print_vconn_debug | vconn_sub | ofctl_strip], [0], [dnl
4321 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4322  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4323 vconn|DBG|unix: received: OFPT_HELLO:
4324  version bitmap: 0x01
4325 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4326 vconn|DBG|unix: received: OFPT_FLOW_MOD: DEL actions=drop
4327 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4328 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4329 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4330  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4331 vconn|DBG|unix: received: OFPT_HELLO (OF1.4):
4332  version bitmap: 0x05
4333 vconn|DBG|unix: negotiated OpenFlow version 0x05 (we support version 0x06 and earlier, peer supports version 0x05)
4334 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4335  bundle_id=0 type=OPEN_REQUEST flags=atomic ordered
4336 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4337  bundle_id=0 type=OPEN_REPLY flags=0
4338 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4339  bundle_id=0 flags=atomic ordered
4340 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:66:77:88:99:aa idle:50 actions=output:1
4341 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4342  bundle_id=0 flags=atomic ordered
4343 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:77:88:99:aa:bb idle:60 actions=output:2
4344 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4345  bundle_id=0 flags=atomic ordered
4346 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:88:99:aa:bb:cc idle:70 actions=output:3
4347 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4348  bundle_id=0 flags=atomic ordered
4349 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:66:77:88:99:aa idle:50 actions=output:4
4350 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4351  bundle_id=0 flags=atomic ordered
4352 OFPT_FLOW_MOD (OF1.4): DEL table:255 actions=drop
4353 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4354  bundle_id=0 flags=atomic ordered
4355 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:66:77:88:99:aa idle:50 actions=output:5
4356 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4357  bundle_id=0 flags=atomic ordered
4358 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:77:88:99:aa:bb idle:60 actions=output:6
4359 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4360  bundle_id=0 flags=atomic ordered
4361 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:88:99:aa:bb:cc idle:70 actions=output:7
4362 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4363  bundle_id=0 flags=atomic ordered
4364 OFPT_FLOW_MOD (OF1.4): DEL table:255 in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
4365 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4366  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4367 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4368  bundle_id=0 type=COMMIT_REPLY flags=0
4369 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4370  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4371 vconn|DBG|unix: received: OFPT_HELLO:
4372  version bitmap: 0x01
4373 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4374 vconn|DBG|unix: received: NXT_SET_FLOW_FORMAT: format=nxm
4375 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4376 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4377 vconn|DBG|unix: received: NXST_FLOW request:
4378 vconn|DBG|unix: sent (Success): NXST_FLOW reply:
4379  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:5
4380  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:6
4381 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4382  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4383 vconn|DBG|unix: received: OFPT_HELLO (OF1.4):
4384  version bitmap: 0x05
4385 vconn|DBG|unix: negotiated OpenFlow version 0x05 (we support version 0x06 and earlier, peer supports version 0x05)
4386 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4387  bundle_id=0 type=OPEN_REQUEST flags=atomic ordered
4388 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4389  bundle_id=0 type=OPEN_REPLY flags=0
4390 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4391  bundle_id=0 flags=atomic ordered
4392 OFPT_FLOW_MOD (OF1.4): MOD actions=drop
4393 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4394  bundle_id=0 flags=atomic ordered
4395 OFPT_FLOW_MOD (OF1.4): MOD_STRICT in_port=2,dl_src=00:77:88:99:aa:bb actions=output:7
4396 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4397  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4398 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4399  bundle_id=0 type=COMMIT_REPLY flags=0
4400 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4401  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4402 vconn|DBG|unix: received: OFPT_HELLO:
4403  version bitmap: 0x01
4404 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4405 vconn|DBG|unix: received: NXT_SET_FLOW_FORMAT: format=nxm
4406 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4407 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4408 vconn|DBG|unix: received: NXST_FLOW request:
4409 vconn|DBG|unix: sent (Success): NXST_FLOW reply:
4410  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4411  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:7
4412 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4413  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4414 vconn|DBG|unix: received: OFPT_HELLO (OF1.4):
4415  version bitmap: 0x05
4416 vconn|DBG|unix: negotiated OpenFlow version 0x05 (we support version 0x06 and earlier, peer supports version 0x05)
4417 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4418  bundle_id=0 type=OPEN_REQUEST flags=atomic ordered
4419 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4420  bundle_id=0 type=OPEN_REPLY flags=0
4421 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4422  bundle_id=0 flags=atomic ordered
4423 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:77:88:99:aa:bb idle:60 actions=output:8
4424 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4425  bundle_id=0 flags=atomic ordered
4426 OFPT_FLOW_MOD (OF1.4): DEL_STRICT table:255 in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4427 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4428  bundle_id=0 flags=atomic ordered
4429 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4430 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4431  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4432 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4433  bundle_id=0 type=COMMIT_REPLY flags=0
4434 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4435  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4436 vconn|DBG|unix: received: OFPT_HELLO:
4437  version bitmap: 0x01
4438 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4439 vconn|DBG|unix: received: NXT_SET_FLOW_FORMAT: format=nxm
4440 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4441 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4442 vconn|DBG|unix: received: NXST_FLOW request: 
4443 vconn|DBG|unix: sent (Success): NXST_FLOW reply:
4444  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:8
4445  in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4446 ])
4447
4448 OVS_VSWITCHD_STOP
4449 AT_CLEANUP
4450
4451
4452 AT_SETUP([ofproto - failing bundle commit (OpenFlow 1.4)])
4453 AT_KEYWORDS([monitor])
4454 OVS_VSWITCHD_START
4455
4456 AT_CHECK([ovs-ofctl del-flows br0])
4457
4458 ovs-ofctl add-flows br0 - <<EOF
4459 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=11
4460 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=22
4461 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=33
4462 EOF
4463 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4464  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:11
4465  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:22
4466  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=output:33
4467 NXST_FLOW reply:
4468 ])
4469
4470 # last line uses illegal table number (OVS internal table)
4471 AT_DATA([flows.txt], [dnl
4472 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=1
4473 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=2
4474 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=3
4475 modify idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=4
4476 delete
4477 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=5
4478 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=6
4479 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=7
4480 delete in_port=2 dl_src=00:88:99:aa:bb:cc
4481 add table=254 actions=drop
4482 ])
4483
4484 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt 2>&1 | sed '/|WARN|/d
4485 s/unix:.*br0\.mgmt/unix:br0.mgmt/' | sed 's/(.* error)/(error)/'],
4486 [0], [dnl
4487 OFPT_ERROR (OF1.4) (xid=0xb): OFPBRC_EPERM
4488 OFPT_FLOW_MOD (OF1.4) (xid=0xb): ADD table:254 actions=drop
4489 OFPT_ERROR (OF1.4) (xid=0xd): OFPBFC_MSG_FAILED
4490 OFPT_BUNDLE_CONTROL (OF1.4) (xid=0xd):
4491  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4492 ovs-ofctl: talking to unix:br0.mgmt (error)
4493 ])
4494
4495 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4496  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:11
4497  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:22
4498  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=output:33
4499 NXST_FLOW reply:
4500 ])
4501
4502 OVS_VSWITCHD_STOP
4503 AT_CLEANUP