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