ofproto: Report support for group stats.
[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 - del group])
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_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-groups br0 groups.txt])
274 AT_CHECK([ovs-ofctl -F OXM-OpenFlow15 -O OpenFlow15 -vwarn dump-groups br0 1234], [0], [stdout])
275 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
276 OFPST_GROUP_DESC reply (OF1.5):
277  group_id=1234,type=all,bucket=actions=output:10
278 ])
279 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
280 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
281 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
282 OFPST_GROUP_DESC reply (OF1.1):
283  group_id=1235,type=all,bucket=actions=output:10
284 ])
285 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
286 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
287 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
288 OFPST_GROUP_DESC reply (OF1.1):
289  group_id=1235,type=all,bucket=actions=output:10
290 ])
291 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0], [0])
292 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
293 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
294 OFPST_GROUP_DESC reply (OF1.1):
295 ])
296 OVS_VSWITCHD_STOP
297 AT_CLEANUP
298
299 dnl This is really bare-bones.
300 dnl It at least checks request and reply serialization and deserialization.
301 AT_SETUP([ofproto - del group deletes flows])
302 OVS_VSWITCHD_START
303 AT_DATA([groups.txt], [dnl
304 group_id=1234,type=all,bucket=output:10
305 group_id=1235,type=all,bucket=output:10
306 ])
307 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-groups br0 groups.txt])
308 AT_DATA([flows.txt], [dnl
309 tcp actions=group:1234
310 udp actions=group:1235
311 ])
312 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flows br0 flows.txt])
313 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
314 [0], [dnl
315  tcp actions=group:1234
316  udp actions=group:1235
317 OFPST_FLOW reply (OF1.1):
318 ])
319 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
320 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
321 [0], [dnl
322  udp actions=group:1235
323 OFPST_FLOW reply (OF1.1):
324 ])
325 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
326 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
327 [0], [dnl
328  udp actions=group:1235
329 OFPST_FLOW reply (OF1.1):
330 ])
331 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0])
332 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
333 [0], [dnl
334 OFPST_FLOW reply (OF1.1):
335 ])
336 OVS_VSWITCHD_STOP
337 AT_CLEANUP
338
339 dnl This is really bare-bones.
340 dnl It at least checks request and reply serialization and deserialization.
341 AT_SETUP([ofproto - flow mod checks group availability])
342 OVS_VSWITCHD_START
343 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 group_id=1234,type=all,bucket=output:10])
344 AT_DATA([flows.txt], [dnl
345 tcp actions=group:1234
346 udp actions=group:1235
347 ])
348 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=group:1234'])
349 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=group:1235'], [1], [], [stderr])
350
351 # The output should look like this:
352 #
353 # 00000000  02 0e 00 98 00 00 00 02-00 00 00 00 00 00 00 00 |................|
354 # 00000010  00 00 00 00 00 00 00 00-ff 00 00 00 00 00 80 00 |................|
355 # 00000020  ff ff ff ff ff ff ff ff-ff ff ff ff 00 00 00 00 |................|
356 # 00000030  00 00 00 58 00 00 00 00-00 00 03 d7 00 00 00 00 |...X............|
357 #
358 # This 'sed' command captures the error message but drops details.
359 AT_CHECK([sed '/truncated/d
360 /^000000.0/d' stderr | STRIP_XIDS], [0],
361   [OFPT_ERROR (OF1.1): OFPBAC_BAD_OUT_GROUP
362 OFPT_FLOW_MOD (OF1.1):
363 ])
364 OVS_VSWITCHD_STOP
365 AT_CLEANUP
366
367 dnl This is really bare-bones.
368 dnl It at least checks request and reply serialization and deserialization.
369 AT_SETUP([ofproto - group description])
370 OVS_VSWITCHD_START
371 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 group_id=1234,type=all,bucket=output:10], [0], [stdout])
372 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
373 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
374 OFPST_GROUP_DESC reply (OF1.1):
375  group_id=1234,type=all,bucket=actions=output:10
376 ])
377 OVS_VSWITCHD_STOP
378 AT_CLEANUP
379
380 dnl This is really bare-bones.
381 dnl It at least checks request and reply serialization and deserialization.
382 AT_SETUP([ofproto - group description])
383 OVS_VSWITCHD_START
384 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 group_id=1234,type=all,bucket=output:10])
385 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
386 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
387 OFPST_GROUP_DESC reply (OF1.1):
388  group_id=1234,type=all,bucket=actions=output:10
389 ])
390 OVS_VSWITCHD_STOP
391 AT_CLEANUP
392
393 dnl This is really bare-bones.
394 dnl It at least checks request and reply serialization and deserialization.
395 AT_SETUP([ofproto - group features])
396 OVS_VSWITCHD_START
397 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn dump-group-features br0], [0], [stdout])
398 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
399 OFPST_GROUP_FEATURES reply (OF1.2):
400  Group table:
401     Types:  0x0
402     Capabilities:  0x7
403 ])
404 OVS_VSWITCHD_STOP
405 AT_CLEANUP
406
407 dnl This is really bare-bones.
408 dnl It at least checks request and reply serialization and deserialization.
409 AT_SETUP([ofproto - group stats])
410 OVS_VSWITCHD_START
411 AT_DATA([groups.txt], [dnl
412 group_id=1234,type=all,bucket=output:10
413 group_id=1235,type=all,bucket=output:10
414 ])
415 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-groups br0 groups.txt])
416 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=group:1234'])
417 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-group-stats br0 group_id=1234], [0], [stdout])
418 AT_CHECK([STRIP_XIDS stdout | sort], [0], [dnl
419  group_id=1234,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
420 OFPST_GROUP reply (OF1.1):
421 ])
422 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-group-stats br0], [0], [stdout])
423 AT_CHECK([STRIP_XIDS stdout | sort], [0], [dnl
424  group_id=1234,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
425  group_id=1235,ref_count=0,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
426 OFPST_GROUP reply (OF1.1):
427 ])
428 OVS_VSWITCHD_STOP
429 AT_CLEANUP
430
431 AT_SETUP([ofproto - mod-port (OpenFlow 1.0)])
432 OVS_VSWITCHD_START
433 for command_config_state in \
434     'up 0 0' \
435     'noflood NO_FLOOD 0' \
436     'down PORT_DOWN,NO_FLOOD LINK_DOWN' \
437     'flood PORT_DOWN LINK_DOWN' \
438     'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
439     'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
440     'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
441     'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
442     'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
443     'up NO_RECV 0' \
444     'receive 0 0'
445 do
446     set $command_config_state
447     command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
448     AT_CHECK([ovs-ofctl -vwarn mod-port br0 br0 $command])
449     AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
450     AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
451 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
452 n_tables:254, n_buffers:256
453 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
454 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
455  LOCAL(br0): addr:aa:55:aa:55:00:00
456      config:     $config
457      state:      $state
458      speed: 0 Mbps now, 0 Mbps max
459 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
460 ])
461 done
462 OVS_VSWITCHD_STOP
463 AT_CLEANUP
464
465 AT_SETUP([ofproto - mod-port (OpenFlow 1.2)])
466 OVS_VSWITCHD_START
467 for command_config_state in \
468     'up 0 0' \
469     'down PORT_DOWN LINK_DOWN' \
470     'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
471     'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
472     'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
473     'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
474     'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
475     'up NO_RECV 0' \
476     'receive 0 0'
477 do
478     set $command_config_state
479     command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
480     AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn mod-port br0 br0 $command])
481     AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn show br0], [0], [stdout])
482     AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
483 OFPT_FEATURES_REPLY (OF1.2): dpid:fedcba9876543210
484 n_tables:254, n_buffers:256
485 capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS QUEUE_STATS
486  LOCAL(br0): addr:aa:55:aa:55:00:00
487      config:     $config
488      state:      $state
489      speed: 0 Mbps now, 0 Mbps max
490 OFPT_GET_CONFIG_REPLY (OF1.2): frags=normal miss_send_len=0
491 ])
492 done
493 OVS_VSWITCHD_STOP
494 AT_CLEANUP
495
496 AT_SETUP([ofproto - mod-port (OpenFlow 1.4)])
497 OVS_VSWITCHD_START
498 for command_config_state in \
499     'up 0 0' \
500     'down PORT_DOWN LINK_DOWN' \
501     'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
502     'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
503     'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
504     'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
505     'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
506     'up NO_RECV 0' \
507     'receive 0 0'
508 do
509     set $command_config_state
510     command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
511     AT_CHECK([ovs-ofctl -O OpenFlow14 -vwarn mod-port br0 br0 $command])
512     AT_CHECK([ovs-ofctl -O OpenFlow14 -vwarn show br0], [0], [stdout])
513     AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
514 OFPT_FEATURES_REPLY (OF1.4): dpid:fedcba9876543210
515 n_tables:254, n_buffers:256
516 capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS QUEUE_STATS
517 OFPST_PORT_DESC reply (OF1.4):
518  LOCAL(br0): addr:aa:55:aa:55:00:00
519      config:     $config
520      state:      $state
521      speed: 0 Mbps now, 0 Mbps max
522 OFPT_GET_CONFIG_REPLY (OF1.4): frags=normal miss_send_len=0
523 ])
524 done
525 OVS_VSWITCHD_STOP
526 AT_CLEANUP
527
528 AT_SETUP([ofproto - basic flow_mod commands (NXM)])
529 OVS_VSWITCHD_START
530 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
531 ])
532 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl add-flows br0 -])
533 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=2])
534 AT_CHECK([ovs-ofctl -F nxm add-flow br0 table=1,in_port=4,actions=3])
535 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
536  in_port=1 actions=output:2
537  in_port=2 actions=output:1
538  table=1, in_port=4 actions=output:3
539 NXST_FLOW reply:
540 ])
541 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
542 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
543 ])
544 AT_CHECK([ovs-ofctl del-flows br0])
545 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
546 ])
547 OVS_VSWITCHD_STOP
548 AT_CLEANUP
549
550 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.0)])
551 OVS_VSWITCHD_START
552 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
553 ])
554 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -F openflow10 add-flows br0 -])
555 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 in_port=1,actions=2])
556 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 table=1,in_port=4,actions=3])
557 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
558  in_port=1 actions=output:2
559  in_port=2 actions=output:1
560  table=1, in_port=4 actions=output:3
561 OFPST_FLOW reply:
562 ])
563 AT_CHECK([ovs-ofctl -F openflow10 dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
564 OFPST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
565 ])
566 AT_CHECK([ovs-ofctl -F openflow10 del-flows br0])
567 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
568 ])
569 OVS_VSWITCHD_STOP
570 AT_CLEANUP
571
572 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.1)])
573 OVS_VSWITCHD_START
574 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.1):
575 ])
576 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -O OpenFlow11 add-flows br0 -])
577 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 in_port=1,actions=2])
578 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 table=1,in_port=4,actions=3])
579 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
580  in_port=1 actions=output:2
581  in_port=2 actions=output:1
582  table=1, in_port=4 actions=output:3
583 OFPST_FLOW reply (OF1.1):
584 ])
585 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
586 OFPST_AGGREGATE reply (OF1.1): packet_count=0 byte_count=0 flow_count=2
587 ])
588 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0])
589 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.1):
590  table=1, in_port=4 actions=output:3
591 ])
592 OVS_VSWITCHD_STOP
593 AT_CLEANUP
594
595 AT_SETUP([ofproto - flow_mod negative test (OpenFlow 1.1)])
596 OVS_VSWITCHD_START(
597   [set bridge br0 protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13])
598 AT_CHECK([ovs-ofctl add-flow -O OpenFlow11 br0 table=1,action=goto_table:2])
599
600 # The error message here actually comes from ovs-ofctl, not from ovs-vswitchd,
601 # but at least it's the same code in ofpacts_check() that issues the error.
602 AT_CHECK([ovs-ofctl add-flow -O OpenFlow11 br0 table=1,action=goto_table:1],
603   [1], [],
604   [ovs-ofctl: actions are invalid with specified match (OFPBIC_BAD_TABLE_ID)
605 ])
606 OVS_VSWITCHD_STOP
607 AT_CLEANUP
608
609 AT_SETUP([ofproto - set-field flow_mod commands (NXM)])
610 OVS_VSWITCHD_START
611 AT_CHECK([ovs-ofctl add-flow br0 ipv6,table=1,in_port=3,actions=drop])
612 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])
613 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
614  table=1, ipv6,in_port=3 actions=load:0xa6badbfffefe59fa->NXM_NX_IPV6_SRC[[0..63]],load:0xfe8001234567890a->NXM_NX_IPV6_SRC[[64..127]]
615 NXST_FLOW reply:
616 ])
617 OVS_VSWITCHD_STOP
618 AT_CLEANUP
619
620 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.2)])
621 OVS_VSWITCHD_START
622 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.2):
623 ])
624 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -O OpenFlow12 add-flows br0 -])
625 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=1,actions=2])
626 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 table=1,in_port=4,actions=3])
627 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
628  in_port=1 actions=output:2
629  in_port=2 actions=output:1
630  table=1, in_port=4 actions=output:3
631 OFPST_FLOW reply (OF1.2):
632 ])
633 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0])
634 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.2):
635 ])
636 OVS_VSWITCHD_STOP
637 AT_CLEANUP
638
639 AT_SETUP([ofproto - dump flows with cookie])
640 OVS_VSWITCHD_START
641 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
642 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
643 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
644 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
645  cookie=0x1, in_port=1 actions=output:1
646  cookie=0x2, in_port=2 actions=output:1
647  cookie=0x3, in_port=3 actions=output:1
648 NXST_FLOW reply:
649 ])
650 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
651 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
652 ])
653 AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/-1 | ofctl_strip | sort], [0], [dnl
654  cookie=0x3, in_port=3 actions=output:1
655 NXST_FLOW reply:
656 ])
657 AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/-1 | STRIP_XIDS], [0], [dnl
658 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=1
659 ])
660 OVS_VSWITCHD_STOP
661 AT_CLEANUP
662
663 AT_SETUP([ofproto - mod flow with cookie change (OpenFlow 1.0)])
664 OVS_VSWITCHD_START
665 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 cookie=0x1,in_port=1,actions=1])
666 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
667  cookie=0x1, in_port=1 actions=output:1
668 OFPST_FLOW reply:
669 ])
670
671 AT_CHECK([ovs-ofctl -F openflow10 mod-flows br0 cookie=0x2,in_port=1,actions=1])
672 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
673  cookie=0x2, in_port=1 actions=output:1
674 OFPST_FLOW reply:
675 ])
676 OVS_VSWITCHD_STOP
677 AT_CLEANUP
678
679 AT_SETUP([ofproto - mod flow with cookie change (NXM)])
680 OVS_VSWITCHD_START
681 AT_CHECK([ovs-ofctl -F nxm add-flow br0 cookie=0x1,in_port=1,actions=1])
682 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
683  cookie=0x1, in_port=1 actions=output:1
684 NXST_FLOW reply:
685 ])
686
687 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x2,in_port=1,actions=1])
688 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
689  cookie=0x2, in_port=1 actions=output:1
690 NXST_FLOW reply:
691 ])
692 OVS_VSWITCHD_STOP
693 AT_CLEANUP
694
695 AT_SETUP([ofproto - no mod flow with cookie change (OpenFlow 1.1)])
696 OVS_VSWITCHD_START
697 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
698 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
699  cookie=0x1, in_port=1 actions=output:1
700 OFPST_FLOW reply (OF1.1):
701 ])
702 AT_CHECK([ovs-ofctl -O OpenFlow11 mod-flows br0 cookie=0x2,in_port=1,actions=1])
703 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
704  cookie=0x1, in_port=1 actions=output:1
705 OFPST_FLOW reply (OF1.1):
706 ])
707 OVS_VSWITCHD_STOP
708 AT_CLEANUP
709
710 dnl The OpenFlow 1.2 spec states that the cookie may not be modified
711 AT_SETUP([ofproto - no mod flow with cookie change (OpenFlow 1.2)])
712 OVS_VSWITCHD_START
713 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
714 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
715  cookie=0x1, in_port=1 actions=output:1
716 OFPST_FLOW reply (OF1.2):
717 ])
718
719 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 cookie=0x2,in_port=1,actions=1])
720 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
721  cookie=0x1, in_port=1 actions=output:1
722 OFPST_FLOW reply (OF1.2):
723 ])
724 OVS_VSWITCHD_STOP
725 AT_CLEANUP
726
727 AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.0)])
728 OVS_VSWITCHD_START
729 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
730 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
731 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
732 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
733  cookie=0x1, in_port=1 actions=output:1
734  cookie=0x1, in_port=2 actions=output:1
735  cookie=0x2, in_port=3 actions=output:1
736 NXST_FLOW reply:
737 ])
738
739 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x1/0xff,actions=4])
740 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
741  cookie=0x1, in_port=1 actions=output:4
742  cookie=0x1, in_port=2 actions=output:4
743  cookie=0x2, in_port=3 actions=output:1
744 NXST_FLOW reply:
745 ])
746 OVS_VSWITCHD_STOP
747 AT_CLEANUP
748
749 AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.1)])
750 OVS_VSWITCHD_START
751 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
752 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=2,actions=1])
753 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x2,in_port=3,actions=1])
754 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
755  cookie=0x1, in_port=1 actions=output:1
756  cookie=0x1, in_port=2 actions=output:1
757  cookie=0x2, in_port=3 actions=output:1
758 OFPST_FLOW reply (OF1.1):
759 ])
760
761 AT_CHECK([ovs-ofctl -O OpenFlow11 mod-flows br0 cookie=0x1/0xff,actions=4])
762 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
763  cookie=0x1, in_port=1 actions=output:4
764  cookie=0x1, in_port=2 actions=output:4
765  cookie=0x2, in_port=3 actions=output:1
766 OFPST_FLOW reply (OF1.1):
767 ])
768 OVS_VSWITCHD_STOP
769 AT_CLEANUP
770
771 AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.2)])
772 OVS_VSWITCHD_START
773 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
774 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=2,actions=1])
775 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=3,actions=1])
776 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
777  cookie=0x1, in_port=1 actions=output:1
778  cookie=0x1, in_port=2 actions=output:1
779  cookie=0x2, in_port=3 actions=output:1
780 OFPST_FLOW reply (OF1.2):
781 ])
782
783 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 cookie=0x1/0xff,actions=4])
784 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
785  cookie=0x1, in_port=1 actions=output:4
786  cookie=0x1, in_port=2 actions=output:4
787  cookie=0x2, in_port=3 actions=output:1
788 OFPST_FLOW reply (OF1.2):
789 ])
790 OVS_VSWITCHD_STOP
791 AT_CLEANUP
792
793 dnl The OpenFlow 1.2 spec states that the cookie may not be modified
794 AT_SETUP([ofproto - mod flows based on cookie mask with cookie change])
795 OVS_VSWITCHD_START
796 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
797 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
798 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
799 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
800  cookie=0x1, in_port=1 actions=output:1
801  cookie=0x1, in_port=2 actions=output:1
802  cookie=0x2, in_port=3 actions=output:1
803 NXST_FLOW reply:
804 ])
805
806 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/-1,cookie=4,actions=4])
807 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
808  cookie=0x2, in_port=3 actions=output:1
809  cookie=0x4, in_port=1 actions=output:4
810  cookie=0x4, in_port=2 actions=output:4
811 NXST_FLOW reply:
812 ])
813 OVS_VSWITCHD_STOP
814 AT_CLEANUP
815
816 AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - NXM])
817 OVS_VSWITCHD_START
818 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 in_port=1,actions=1])
819 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
820  in_port=1 actions=output:1
821 NXST_FLOW reply:
822 ])
823 OVS_VSWITCHD_STOP
824 AT_CLEANUP
825
826 AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - OF1.1])
827 OVS_VSWITCHD_START
828 AT_CHECK([ovs-ofctl -O openflow11 mod-flows br0 in_port=1,actions=1])
829 AT_CHECK([ovs-ofctl -O openflow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
830  in_port=1 actions=output:1
831 OFPST_FLOW reply (OF1.1):
832 ])
833 OVS_VSWITCHD_STOP
834 AT_CLEANUP
835
836 AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - OF1.2])
837 OVS_VSWITCHD_START
838 AT_CHECK([ovs-ofctl -O openflow12 mod-flows br0 in_port=1,actions=1])
839 AT_CHECK([ovs-ofctl -O openflow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
840 OFPST_FLOW reply (OF1.2):
841 ])
842 OVS_VSWITCHD_STOP
843 AT_CLEANUP
844
845 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - NXM])
846 OVS_VSWITCHD_START
847 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/1,in_port=1,actions=1])
848 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
849 NXST_FLOW reply:
850 ])
851 OVS_VSWITCHD_STOP
852 AT_CLEANUP
853
854 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - OF1.1])
855 OVS_VSWITCHD_START
856 AT_CHECK([ovs-ofctl -O openflow11 mod-flows br0 cookie=1/1,in_port=1,actions=1])
857 AT_CHECK([ovs-ofctl -O openflow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
858 OFPST_FLOW reply (OF1.1):
859 ])
860 OVS_VSWITCHD_STOP
861 AT_CLEANUP
862
863 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - OF1.2])
864 OVS_VSWITCHD_START
865 AT_CHECK([ovs-ofctl -O openflow12 mod-flows br0 cookie=1/1,in_port=1,actions=1])
866 AT_CHECK([ovs-ofctl -O openflow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
867 OFPST_FLOW reply (OF1.2):
868 ])
869 OVS_VSWITCHD_STOP
870 AT_CLEANUP
871
872 AT_SETUP([ofproto - del flows with cookies])
873 OVS_VSWITCHD_START
874 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
875 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
876 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
877 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
878  cookie=0x1, in_port=1 actions=output:1
879  cookie=0x2, in_port=2 actions=output:1
880  cookie=0x3, in_port=3 actions=output:1
881 NXST_FLOW reply:
882 ])
883
884 AT_CHECK([ovs-ofctl del-flows br0])
885 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
886 NXST_FLOW reply:
887 ])
888 OVS_VSWITCHD_STOP
889 AT_CLEANUP
890
891 AT_SETUP([ofproto - del flows based on cookie])
892 OVS_VSWITCHD_START
893 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
894 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
895 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
896 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
897  cookie=0x1, in_port=1 actions=output:1
898  cookie=0x2, in_port=2 actions=output:1
899  cookie=0x3, in_port=3 actions=output:1
900 NXST_FLOW reply:
901 ])
902
903 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/-1])
904 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
905  cookie=0x1, in_port=1 actions=output:1
906  cookie=0x2, in_port=2 actions=output:1
907 NXST_FLOW reply:
908 ])
909 OVS_VSWITCHD_STOP
910 AT_CLEANUP
911
912 AT_SETUP([ofproto - del flows based on cookie mask])
913 OVS_VSWITCHD_START
914 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
915 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
916 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
917 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
918  cookie=0x1, in_port=1 actions=output:1
919  cookie=0x2, in_port=2 actions=output:1
920  cookie=0x3, in_port=3 actions=output:1
921 NXST_FLOW reply:
922 ])
923 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/0x1])
924 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
925  cookie=0x2, in_port=2 actions=output:1
926 NXST_FLOW reply:
927 ])
928 OVS_VSWITCHD_STOP
929 AT_CLEANUP
930
931 AT_SETUP([ofproto - del flows based on table id (NXM)])
932 OVS_VSWITCHD_START
933 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
934 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
935 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
936  cookie=0x1, in_port=1 actions=output:1
937  cookie=0x2, table=1, in_port=2 actions=output:1
938 NXST_FLOW reply:
939 ])
940 AT_CHECK([ovs-ofctl del-flows br0 table=0])
941 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
942  cookie=0x2, table=1, in_port=2 actions=output:1
943 NXST_FLOW reply:
944 ])
945 AT_CHECK([ovs-ofctl del-flows br0 table=1])
946 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
947 NXST_FLOW reply:
948 ])
949 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
950 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
951 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
952  cookie=0x1, in_port=1 actions=output:1
953  cookie=0x2, table=1, in_port=2 actions=output:1
954 NXST_FLOW reply:
955 ])
956 AT_CHECK([ovs-ofctl del-flows br0])
957 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
958 NXST_FLOW reply:
959 ])
960 OVS_VSWITCHD_STOP
961 AT_CLEANUP
962
963 AT_SETUP([ofproto - del flows based on table id (OpenFlow 1.1)])
964 OVS_VSWITCHD_START
965 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
966 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
967 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
968  cookie=0x1, in_port=1 actions=output:1
969  cookie=0x2, table=1, in_port=2 actions=output:1
970 OFPST_FLOW reply (OF1.1):
971 ])
972 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 table=0])
973 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
974  cookie=0x2, table=1, in_port=2 actions=output:1
975 OFPST_FLOW reply (OF1.1):
976 ])
977 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 table=1])
978 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
979 OFPST_FLOW reply (OF1.1):
980 ])
981 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
982 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
983 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
984  cookie=0x1, in_port=1 actions=output:1
985  cookie=0x2, table=1, in_port=2 actions=output:1
986 OFPST_FLOW reply (OF1.1):
987 ])
988 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0])
989 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
990 OFPST_FLOW reply (OF1.1):
991  cookie=0x2, table=1, in_port=2 actions=output:1
992 ])
993 OVS_VSWITCHD_STOP
994 AT_CLEANUP
995
996 AT_SETUP([ofproto - del flows based on table id (OpenFlow 1.2)])
997 OVS_VSWITCHD_START
998 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
999 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
1000 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1001  cookie=0x1, in_port=1 actions=output:1
1002  cookie=0x2, table=1, in_port=2 actions=output:1
1003 OFPST_FLOW reply (OF1.2):
1004 ])
1005 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0 table=0])
1006 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1007  cookie=0x2, table=1, in_port=2 actions=output:1
1008 OFPST_FLOW reply (OF1.2):
1009 ])
1010 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0 table=1])
1011 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1012 OFPST_FLOW reply (OF1.2):
1013 ])
1014 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
1015 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
1016 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1017  cookie=0x1, in_port=1 actions=output:1
1018  cookie=0x2, table=1, in_port=2 actions=output:1
1019 OFPST_FLOW reply (OF1.2):
1020 ])
1021 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0])
1022 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1023 OFPST_FLOW reply (OF1.2):
1024 ])
1025 OVS_VSWITCHD_STOP
1026 AT_CLEANUP
1027
1028 AT_SETUP([ofproto - flow table configuration (OpenFlow 1.0)])
1029 OVS_VSWITCHD_START
1030 # Check the default configuration.
1031 (printf "OFPST_TABLE reply (xid=0x2):"
1032  x=0
1033  name=classifier
1034  while test $x -lt 254; do
1035    printf "
1036   table %d (\"%s\"):
1037     active=0, lookup=0, matched=0
1038     max_entries=1000000
1039     matching:
1040       in_port: exact match or wildcard
1041       eth_src: exact match or wildcard
1042       eth_dst: exact match or wildcard
1043       eth_type: exact match or wildcard
1044       vlan_vid: exact match or wildcard
1045       vlan_pcp: exact match or wildcard
1046       ip_src: exact match or wildcard
1047       ip_dst: exact match or wildcard
1048       nw_proto: exact match or wildcard
1049       nw_tos: exact match or wildcard
1050       tcp_src: exact match or wildcard
1051       tcp_dst: exact match or wildcard
1052 " $x $name
1053    x=`expr $x + 1`
1054    name=table$x
1055  done) > expout
1056 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
1057 # Change the configuration.
1058 AT_CHECK(
1059   [ovs-vsctl \
1060      -- --id=@t0 create Flow_Table name=main \
1061      -- --id=@t1 create Flow_Table flow-limit=1024 \
1062      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
1063    | ${PERL} $srcdir/uuidfilt.pl],
1064   [0], [<0>
1065 <1>
1066 ])
1067 # Check that the configuration was updated.
1068 mv expout orig-expout
1069 sed -e 's/classifier/main/
1070 21s/1000000/1024/' orig-expout > expout
1071 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
1072 OVS_VSWITCHD_STOP
1073 AT_CLEANUP
1074
1075 AT_SETUP([ofproto - flow table configuration (OpenFlow 1.2)])
1076 OVS_VSWITCHD_START
1077 # Check the default configuration.
1078 (printf "OFPST_TABLE reply (OF1.2) (xid=0x2):"
1079  x=0
1080  name=classifier
1081  while test $x -lt 254; do
1082    echo "
1083   table $x (\"$name\"):
1084     active=0, lookup=0, matched=0
1085     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1086     config=controller
1087     max_entries=1000000
1088     instructions (table miss and others):
1089       instructions: apply_actions,clear_actions,write_actions,write_metadata,goto_table
1090       Write-Actions and Apply-Actions features:
1091         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
1092         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 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
1093     matching:
1094       metadata: exact match or wildcard
1095       in_port_oxm: exact match or wildcard
1096       eth_src: exact match or wildcard
1097       eth_dst: exact match or wildcard
1098       eth_type: exact match or wildcard
1099       vlan_vid: exact match or wildcard
1100       vlan_pcp: exact match or wildcard
1101       mpls_label: exact match or wildcard
1102       mpls_tc: exact match or wildcard
1103       ip_src: exact match or wildcard
1104       ip_dst: exact match or wildcard
1105       ipv6_src: exact match or wildcard
1106       ipv6_dst: exact match or wildcard
1107       ipv6_label: exact match or wildcard
1108       nw_proto: exact match or wildcard
1109       ip_dscp: exact match or wildcard
1110       nw_ecn: exact match or wildcard
1111       arp_op: exact match or wildcard
1112       arp_spa: exact match or wildcard
1113       arp_tpa: exact match or wildcard
1114       arp_sha: exact match or wildcard
1115       arp_tha: exact match or wildcard
1116       tcp_src: exact match or wildcard
1117       tcp_dst: exact match or wildcard
1118       udp_src: exact match or wildcard
1119       udp_dst: exact match or wildcard
1120       sctp_src: exact match or wildcard
1121       sctp_dst: exact match or wildcard
1122       icmp_type: exact match or wildcard
1123       icmp_code: exact match or wildcard
1124       icmpv6_type: exact match or wildcard
1125       icmpv6_code: exact match or wildcard
1126       nd_target: exact match or wildcard
1127       nd_sll: exact match or wildcard
1128       nd_tll: exact match or wildcard"
1129    x=`expr $x + 1`
1130    name=table$x
1131  done) > expout
1132 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
1133 # Change the configuration.
1134 AT_CHECK(
1135   [ovs-vsctl \
1136      -- --id=@t0 create Flow_Table name=main \
1137      -- --id=@t1 create Flow_Table flow-limit=1024 \
1138      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
1139    | ${PERL} $srcdir/uuidfilt.pl],
1140   [0], [<0>
1141 <1>
1142 ])
1143 # Check that the configuration was updated.
1144 mv expout orig-expout
1145 sed 's/classifier/main/
1146 53s/1000000/1024/' < orig-expout > expout
1147 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
1148 OVS_VSWITCHD_STOP
1149 AT_CLEANUP
1150
1151 AT_SETUP([ofproto - table features (OpenFlow 1.3)])
1152 OVS_VSWITCHD_START
1153 (x=0
1154  name=classifier
1155  while test $x -lt 254; do
1156    y=`expr $x + 1`
1157    if test $x = 253; then
1158        next=254
1159    else
1160        next=$y-254
1161    fi
1162    echo "  table $x (\"$name\"):
1163     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1164     max_entries=1000000
1165     instructions (table miss and others):
1166       next tables: $next
1167       instructions: meter,apply_actions,clear_actions,write_actions,write_metadata,goto_table
1168       Write-Actions and Apply-Actions features:
1169         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
1170         supported on Set-Field: tun_id tun_src tun_dst metadata in_port in_port_oxm pkt_mark 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 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
1171     matching:
1172       dp_hash: arbitrary mask
1173       recirc_id: exact match or wildcard
1174       tun_id: arbitrary mask
1175       tun_src: arbitrary mask
1176       tun_dst: arbitrary mask
1177       metadata: arbitrary mask
1178       in_port: exact match or wildcard
1179       in_port_oxm: exact match or wildcard
1180       pkt_mark: arbitrary mask
1181       reg0: arbitrary mask
1182       reg1: arbitrary mask
1183       reg2: arbitrary mask
1184       reg3: arbitrary mask
1185       reg4: arbitrary mask
1186       reg5: arbitrary mask
1187       reg6: arbitrary mask
1188       reg7: arbitrary mask
1189       xreg0: arbitrary mask
1190       xreg1: arbitrary mask
1191       xreg2: arbitrary mask
1192       xreg3: arbitrary mask
1193       eth_src: arbitrary mask
1194       eth_dst: arbitrary mask
1195       eth_type: exact match or wildcard
1196       vlan_tci: arbitrary mask
1197       vlan_vid: arbitrary mask
1198       vlan_pcp: exact match or wildcard
1199       mpls_label: exact match or wildcard
1200       mpls_tc: exact match or wildcard
1201       mpls_bos: exact match or wildcard
1202       ip_src: arbitrary mask
1203       ip_dst: arbitrary mask
1204       ipv6_src: arbitrary mask
1205       ipv6_dst: arbitrary mask
1206       ipv6_label: arbitrary mask
1207       nw_proto: exact match or wildcard
1208       nw_tos: exact match or wildcard
1209       ip_dscp: exact match or wildcard
1210       nw_ecn: exact match or wildcard
1211       nw_ttl: exact match or wildcard
1212       ip_frag: arbitrary mask
1213       arp_op: exact match or wildcard
1214       arp_spa: arbitrary mask
1215       arp_tpa: arbitrary mask
1216       arp_sha: arbitrary mask
1217       arp_tha: arbitrary mask
1218       tcp_src: arbitrary mask
1219       tcp_dst: arbitrary mask
1220       tcp_flags: arbitrary mask
1221       udp_src: arbitrary mask
1222       udp_dst: arbitrary mask
1223       sctp_src: arbitrary mask
1224       sctp_dst: arbitrary mask
1225       icmp_type: exact match or wildcard
1226       icmp_code: exact match or wildcard
1227       icmpv6_type: exact match or wildcard
1228       icmpv6_code: exact match or wildcard
1229       nd_target: arbitrary mask
1230       nd_sll: arbitrary mask
1231       nd_tll: arbitrary mask"
1232    x=$y
1233    name=table$x
1234  done) > expout
1235 AT_CHECK([ovs-ofctl -O OpenFlow13 dump-table-features br0 | sed '/^$/d
1236 /^OFPST_TABLE_FEATURES/d'], [0], [expout])
1237 # Change the configuration.
1238 AT_CHECK(
1239   [ovs-vsctl \
1240      -- --id=@t0 create Flow_Table name=main \
1241      -- --id=@t1 create Flow_Table flow-limit=1024 \
1242      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
1243    | ${PERL} $srcdir/uuidfilt.pl],
1244   [0], [<0>
1245 <1>
1246 ])
1247 # Check that the configuration was updated.
1248 mv expout orig-expout
1249 sed 's/classifier/main/
1250 73s/1000000/1024/' < orig-expout > expout
1251 AT_CHECK([ovs-ofctl -O OpenFlow13 dump-table-features br0 | sed '/^$/d
1252 /^OFPST_TABLE_FEATURES/d'], [0], [expout])
1253 OVS_VSWITCHD_STOP
1254 AT_CLEANUP
1255
1256 AT_SETUP([ofproto - hard limits on flow table size (OpenFlow 1.0)])
1257 OVS_VSWITCHD_START
1258 # Configure a maximum of 4 flows.
1259 AT_CHECK(
1260   [ovs-vsctl \
1261      -- --id=@t0 create Flow_Table flow-limit=4 \
1262      -- set bridge br0 flow_tables:0=@t0 \
1263    | ${PERL} $srcdir/uuidfilt.pl],
1264   [0], [<0>
1265 ])
1266 # Add 4 flows.
1267 for in_port in 1 2 3 4; do
1268     ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
1269 done
1270 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1271  in_port=1 actions=drop
1272  in_port=2 actions=drop
1273  in_port=3 actions=drop
1274  in_port=4 actions=drop
1275 NXST_FLOW reply:
1276 ])
1277 # Adding another flow will be refused.
1278 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
1279 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1280   [OFPT_ERROR: OFPFMFC_TABLE_FULL
1281 ])
1282 # Also a mod-flow that would add a flow will be refused.
1283 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
1284 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1285   [OFPT_ERROR: OFPFMFC_TABLE_FULL
1286 ])
1287 # Replacing or modifying an existing flow is allowed.
1288 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
1289 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
1290 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1291  in_port=1 actions=drop
1292  in_port=2 actions=drop
1293  in_port=3 actions=output:1
1294  in_port=4 actions=NORMAL
1295 NXST_FLOW reply:
1296 ])
1297 OVS_VSWITCHD_STOP
1298 AT_CLEANUP
1299
1300 AT_SETUP([ofproto - hard limits on flow table size (OpenFlow 1.2)])
1301 OVS_VSWITCHD_START
1302 # Configure a maximum of 4 flows.
1303 AT_CHECK(
1304   [ovs-vsctl \
1305      -- --id=@t0 create Flow_Table flow-limit=4 \
1306      -- set bridge br0 flow_tables:0=@t0 \
1307    | ${PERL} $srcdir/uuidfilt.pl],
1308   [0], [<0>
1309 ])
1310 # Add 4 flows.
1311 for in_port in 1 2 3 4; do
1312     ovs-ofctl -O OpenFlow12 add-flow br0 in_port=$in_port,actions=drop
1313 done
1314 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1315  in_port=1 actions=drop
1316  in_port=2 actions=drop
1317  in_port=3 actions=drop
1318  in_port=4 actions=drop
1319 OFPST_FLOW reply (OF1.2):
1320 ])
1321 # Adding another flow will be refused.
1322 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
1323 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1324   [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
1325 ])
1326 # Replacing or modifying an existing flow is allowed.
1327 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
1328 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
1329 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1330  in_port=1 actions=drop
1331  in_port=2 actions=drop
1332  in_port=3 actions=output:1
1333  in_port=4 actions=NORMAL
1334 OFPST_FLOW reply (OF1.2):
1335 ])
1336 OVS_VSWITCHD_STOP
1337 AT_CLEANUP
1338
1339 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.0)])
1340 OVS_VSWITCHD_START
1341 # Configure a maximum of 4 flows.
1342 AT_CHECK(
1343   [ovs-vsctl \
1344      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
1345      -- set bridge br0 flow_tables:0=@t0 \
1346    | ${PERL} $srcdir/uuidfilt.pl],
1347   [0], [<0>
1348 ])
1349 # Add 4 flows.
1350 for in_port in 4 3 2 1; do
1351     ovs-ofctl add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
1352 done
1353 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1354  idle_timeout=10, in_port=1 actions=drop
1355  idle_timeout=20, in_port=2 actions=drop
1356  idle_timeout=30, in_port=3 actions=drop
1357  idle_timeout=40, in_port=4 actions=drop
1358 NXST_FLOW reply:
1359 ])
1360 # Adding another flow will cause the one that expires soonest to be evicted.
1361 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
1362 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1363  idle_timeout=20, in_port=2 actions=drop
1364  idle_timeout=30, in_port=3 actions=drop
1365  idle_timeout=40, in_port=4 actions=drop
1366  in_port=5 actions=drop
1367 NXST_FLOW reply:
1368 ])
1369 # A mod-flow that adds a flow also causes eviction, but replacing or
1370 # modifying an existing flow doesn't.
1371 AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
1372 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
1373 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
1374 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1375  idle_timeout=30, in_port=3 actions=output:1
1376  in_port=4 actions=NORMAL
1377  in_port=5 actions=drop
1378  in_port=6 actions=drop
1379 NXST_FLOW reply:
1380 ])
1381 # Flows with no timeouts at all cannot be evicted.
1382 AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
1383 AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
1384 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1385   [OFPT_ERROR: OFPFMFC_TABLE_FULL
1386 ])
1387 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1388  in_port=4 actions=NORMAL
1389  in_port=5 actions=drop
1390  in_port=6 actions=drop
1391  in_port=7 actions=NORMAL
1392 NXST_FLOW reply:
1393 ])
1394 OVS_VSWITCHD_STOP
1395 AT_CLEANUP
1396
1397 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.2)])
1398 OVS_VSWITCHD_START
1399 # Configure a maximum of 4 flows.
1400 AT_CHECK(
1401   [ovs-vsctl \
1402      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
1403      -- set bridge br0 flow_tables:0=@t0 \
1404    | ${PERL} $srcdir/uuidfilt.pl],
1405   [0], [<0>
1406 ])
1407 # Add 4 flows.
1408 for in_port in 4 3 2 1; do
1409     ovs-ofctl -O OpenFlow12 add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
1410 done
1411 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1412  idle_timeout=10, in_port=1 actions=drop
1413  idle_timeout=20, in_port=2 actions=drop
1414  idle_timeout=30, in_port=3 actions=drop
1415  idle_timeout=40, in_port=4 actions=drop
1416 OFPST_FLOW reply (OF1.2):
1417 ])
1418 # Adding another flow will cause the one that expires soonest to be evicted.
1419 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop])
1420 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1421  idle_timeout=20, in_port=2 actions=drop
1422  idle_timeout=30, in_port=3 actions=drop
1423  idle_timeout=40, in_port=4 actions=drop
1424  in_port=5 actions=drop
1425 OFPST_FLOW reply (OF1.2):
1426 ])
1427 # In Open Flow 1.2 a mod-flow does not ever add a flow and thus
1428 # has no effect on eviction
1429 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=6,actions=drop])
1430 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
1431 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
1432 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1433  idle_timeout=20, in_port=2 actions=drop
1434  idle_timeout=30, in_port=3 actions=output:1
1435  in_port=4 actions=NORMAL
1436  in_port=5 actions=drop
1437 OFPST_FLOW reply (OF1.2):
1438 ])
1439 # Flows with no timeouts at all cannot be evicted.
1440 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=6,actions=drop])
1441 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=7,actions=normal])
1442 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
1443 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1444   [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
1445 ])
1446 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1447  in_port=4 actions=NORMAL
1448  in_port=5 actions=drop
1449  in_port=6 actions=drop
1450  in_port=7 actions=NORMAL
1451 OFPST_FLOW reply (OF1.2):
1452 ])
1453 OVS_VSWITCHD_STOP
1454 AT_CLEANUP
1455
1456 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.0)])
1457 OVS_VSWITCHD_START
1458 # Configure a maximum of 4 flows.
1459 AT_CHECK(
1460   [ovs-vsctl \
1461      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
1462                                    overflow-policy=evict \
1463                                    groups='"NXM_OF_IN_PORT[[]]"' \
1464      -- set bridge br0 flow_tables:0=@t0 \
1465    | ${PERL} $srcdir/uuidfilt.pl],
1466   [0], [<0>
1467 ])
1468 # Add 4 flows.
1469 ovs-ofctl add-flows br0 - <<EOF
1470 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
1471 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
1472 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
1473 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
1474 EOF
1475 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1476  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1477  idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
1478  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1479  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1480 NXST_FLOW reply:
1481 ])
1482 # Adding another flow will cause the one that expires soonest within
1483 # the largest group (those with in_port=1) to be evicted.  In this
1484 # case this is not the same as the one that expires soonest overall
1485 # (which is what makes the test interesting):
1486 AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
1487 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1488  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1489  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1490  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1491  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1492 NXST_FLOW reply:
1493 ])
1494 # Enlarge the flow limit, change the eviction policy back to strictly
1495 # based on expiration, and and add some flows.
1496 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
1497 ovs-ofctl add-flows br0 - <<EOF
1498 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
1499 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
1500 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
1501 EOF
1502 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1503  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1504  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1505  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1506  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
1507  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1508  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1509  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1510 NXST_FLOW reply:
1511 ])
1512 # Adding another flow will cause the one that expires soonest overall
1513 # to be evicted.
1514 AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
1515 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1516  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1517  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1518  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
1519  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1520  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1521  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1522  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1523 NXST_FLOW reply:
1524 ])
1525 # Reducing the flow limit also causes the flows that expire soonest
1526 # overall to be evicted.
1527 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
1528 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1529  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1530  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1531  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1532  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1533 NXST_FLOW reply:
1534 ])
1535 OVS_VSWITCHD_STOP
1536 AT_CLEANUP
1537
1538 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.2)])
1539 OVS_VSWITCHD_START
1540 # Configure a maximum of 4 flows.
1541 AT_CHECK(
1542   [ovs-vsctl \
1543      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
1544                                    overflow-policy=evict \
1545                                    groups='"NXM_OF_IN_PORT[[]]"' \
1546      -- set bridge br0 flow_tables:0=@t0 \
1547    | ${PERL} $srcdir/uuidfilt.pl],
1548   [0], [<0>
1549 ])
1550 # Add 4 flows.
1551 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
1552 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
1553 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
1554 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
1555 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
1556 EOF
1557 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1558  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1559  idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
1560  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1561  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1562 OFPST_FLOW reply (OF1.2):
1563 ])
1564 # Adding another flow will cause the one that expires soonest within
1565 # the largest group (those with in_port=1) to be evicted.  In this
1566 # case this is not the same as the one that expires soonest overall
1567 # (which is what makes the test interesting):
1568 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
1569 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1570  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1571  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1572  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1573  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1574 OFPST_FLOW reply (OF1.2):
1575 ])
1576 # Enlarge the flow limit, change the eviction policy back to strictly
1577 # based on expiration, and and add some flows.
1578 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
1579 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
1580 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
1581 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
1582 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
1583 EOF
1584 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1585  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1586  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1587  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1588  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
1589  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1590  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1591  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1592 OFPST_FLOW reply (OF1.2):
1593 ])
1594 # Adding another flow will cause the one that expires soonest overall
1595 # to be evicted.
1596 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'])
1597 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1598  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1599  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1600  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
1601  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1602  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1603  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1604  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1605 OFPST_FLOW reply (OF1.2):
1606 ])
1607 # Reducing the flow limit also causes the flows that expire soonest
1608 # overall to be evicted.
1609 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
1610 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1611  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1612  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1613  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1614  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1615 OFPST_FLOW reply (OF1.2):
1616 ])
1617 OVS_VSWITCHD_STOP
1618 AT_CLEANUP
1619
1620 AT_SETUP([ofproto - eviction upon table overflow, with modified hard timeout])
1621 OVS_VSWITCHD_START
1622 # Configure a maximum of 4 flows.
1623 AT_CHECK(
1624   [ovs-vsctl \
1625      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
1626      -- set bridge br0 flow_tables:0=@t0 \
1627    | ${PERL} $srcdir/uuidfilt.pl],
1628   [0], [<0>
1629 ])
1630 ovs-appctl time/stop
1631 # Add 4 flows.
1632 for in_port in 4 3 2 1; do
1633     ovs-ofctl add-flow br0 hard_timeout=$((10 + in_port * 3)),in_port=$in_port,actions=drop
1634 done
1635 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1636  hard_timeout=13, in_port=1 actions=drop
1637  hard_timeout=16, in_port=2 actions=drop
1638  hard_timeout=19, in_port=3 actions=drop
1639  hard_timeout=22, in_port=4 actions=drop
1640 NXST_FLOW reply:
1641 ])
1642 # Sleep and modify the one that expires soonest
1643 ovs-appctl time/warp 5000
1644 AT_CHECK([ovs-ofctl mod-flows br0 in_port=1,actions=drop])
1645 # At this point the table would looks like:
1646 #  in_port   seconds to expire
1647 #     1            13
1648 #     2            11
1649 #     3            14
1650 #     4            17
1651 ovs-appctl time/warp 2000
1652 # Adding another flow will cause the one that expires soonest to be evicted.
1653 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
1654 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1655  hard_timeout=13, in_port=1 actions=drop
1656  hard_timeout=19, in_port=3 actions=drop
1657  hard_timeout=22, in_port=4 actions=drop
1658  in_port=5 actions=drop
1659 NXST_FLOW reply:
1660 ])
1661 OVS_VSWITCHD_STOP
1662 AT_CLEANUP
1663
1664 AT_SETUP([ofproto - eviction upon table overflow, with modified idle timeout])
1665 OVS_VSWITCHD_START([add-port br0 p1 -- set interface p1 type=dummy ofport_request=1])
1666 # Configure a maximum of 4 flows.
1667 AT_CHECK(
1668   [ovs-vsctl \
1669      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
1670      -- set bridge br0 flow_tables:0=@t0 \
1671    | ${PERL} $srcdir/uuidfilt.pl],
1672   [0], [<0>
1673 ])
1674 # Add 4 flows.
1675 for in_port in 4 3 2 1; do
1676     ovs-ofctl add-flow br0 idle_timeout=$((10 + in_port * 3)),in_port=$in_port,actions=drop
1677 done
1678 ovs-appctl time/stop
1679 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1680  idle_timeout=13, in_port=1 actions=drop
1681  idle_timeout=16, in_port=2 actions=drop
1682  idle_timeout=19, in_port=3 actions=drop
1683  idle_timeout=22, in_port=4 actions=drop
1684 NXST_FLOW reply:
1685 ])
1686 # Sleep and receive on the flow that expires soonest
1687 ovs-appctl time/warp 5000
1688 AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1)'])
1689 # At this point the table would looks like:
1690 #  in_port   seconds to expire
1691 #     1            13
1692 #     2            11
1693 #     3            14
1694 #     4            17
1695 ovs-appctl time/warp 2000
1696 # Adding another flow will cause the one that expires soonest to be evicted.
1697 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
1698 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1699  idle_timeout=19, in_port=3 actions=drop
1700  idle_timeout=22, in_port=4 actions=drop
1701  in_port=5 actions=drop
1702  n_packets=1, n_bytes=60, idle_timeout=13, in_port=1 actions=drop
1703 NXST_FLOW reply:
1704 ])
1705 OVS_VSWITCHD_STOP
1706 AT_CLEANUP
1707
1708 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.0)])
1709 OVS_VSWITCHD_START
1710 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
1711 check_async () {
1712     printf '\n\n--- check_async %d ---\n\n\n' $1
1713     shift
1714
1715     ovs-appctl -t ovs-ofctl ofctl/barrier
1716     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1717     : > expout
1718
1719     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1720     ovs-ofctl -v packet-out br0 controller controller '0001020304050010203040501234'
1721     if test X"$1" = X"OFPR_ACTION"; then shift;
1722         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
1723 in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
1724     fi
1725
1726     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1727     ovs-ofctl -v packet-out br0 controller 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1728     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1729         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via no_match) data_len=14 (unbuffered)
1730 in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
1731     fi
1732
1733     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1734     ovs-ofctl packet-out br0 controller dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1735     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1736         echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=CONTROLLER (via invalid_ttl) data_len=76 (unbuffered)
1737 udp,in_port=0,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"
1738     fi
1739
1740     # OFPT_PORT_STATUS, OFPPR_ADD
1741     ovs-vsctl add-port br0 test -- set Interface test type=dummy ofport_request=1
1742     if test X"$1" = X"OFPPR_ADD"; then shift;
1743         echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
1744      config:     PORT_DOWN
1745      state:      LINK_DOWN
1746      speed: 0 Mbps now, 0 Mbps max"
1747     fi
1748
1749     # OFPT_PORT_STATUS, OFPPR_DELETE
1750     ovs-vsctl del-port br0 test
1751     if test X"$1" = X"OFPPR_DELETE"; then shift;
1752         echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
1753      config:     PORT_DOWN
1754      state:      LINK_DOWN
1755      speed: 0 Mbps now, 0 Mbps max"
1756     fi
1757
1758     # OFPT_FLOW_REMOVED, OFPRR_DELETE
1759     ovs-ofctl add-flow br0 send_flow_rem,actions=drop
1760     ovs-ofctl --strict del-flows br0 ''
1761     if test X"$1" = X"OFPRR_DELETE"; then shift;
1762         echo >>expout "OFPT_FLOW_REMOVED:  reason=delete"
1763     fi
1764     AT_FAIL_IF([test X"$1" != X])
1765
1766     ovs-appctl -t ovs-ofctl ofctl/barrier
1767     echo >>expout "OFPT_BARRIER_REPLY:"
1768
1769     AT_CHECK(
1770       [[sed '
1771 s/ (xid=0x[0-9a-fA-F]*)//
1772 s/ *duration.*//
1773 s/00:0.$/00:0x/' < monitor.log]],
1774       [0], [expout])
1775 }
1776
1777 # It's a service connection so initially there should be no async messages.
1778 check_async 1
1779
1780 # Set miss_send_len to 128, turning on packet-ins for our service connection.
1781 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
1782 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1783
1784 # Set miss_send_len to 128 and enable invalid_ttl.
1785 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
1786 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1787
1788 # Become slave, which should disable everything except port status.
1789 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
1790 check_async 4 OFPPR_ADD OFPPR_DELETE
1791
1792 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
1793 ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
1794 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1795
1796 # Set controller ID 123.
1797 ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
1798 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1799
1800 # Restore controller ID 0.
1801 ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
1802
1803 # Become master.
1804 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
1805 check_async 7 OFPR_ACTION OFPPR_ADD
1806
1807 ovs-appctl -t ovs-ofctl exit
1808 OVS_VSWITCHD_STOP
1809 AT_CLEANUP
1810
1811 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.2)])
1812 OVS_VSWITCHD_START
1813 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1814 check_async () {
1815     printf '\n\n--- check_async %d ---\n\n\n' $1
1816     INDEX=$1
1817     shift
1818
1819     ovs-appctl -t ovs-ofctl ofctl/barrier
1820     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1821     : > expout
1822
1823     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1824     ovs-ofctl -O OpenFlow12 -v packet-out br0 none controller '0001020304050010203040501234'
1825     if test X"$1" = X"OFPR_ACTION"; then shift;
1826         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1827 in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
1828     fi
1829
1830     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1831     ovs-ofctl -O OpenFlow12 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1832     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1833         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
1834 in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
1835     fi
1836
1837     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1838     ovs-ofctl -O OpenFlow12 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1839     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1840         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
1841 udp,in_port=0,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"
1842     fi
1843
1844     # OFPT_PORT_STATUS, OFPPR_ADD
1845     ovs-vsctl add-port br0 test -- set Interface test type=dummy
1846     if test X"$1" = X"OFPPR_ADD"; then shift;
1847         echo >>expout "OFPT_PORT_STATUS (OF1.2): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1848      config:     PORT_DOWN
1849      state:      LINK_DOWN
1850      speed: 0 Mbps now, 0 Mbps max"
1851     fi
1852
1853     # OFPT_PORT_STATUS, OFPPR_DELETE
1854     ovs-vsctl del-port br0 test
1855     if test X"$1" = X"OFPPR_DELETE"; then shift;
1856         echo >>expout "OFPT_PORT_STATUS (OF1.2): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1857      config:     PORT_DOWN
1858      state:      LINK_DOWN
1859      speed: 0 Mbps now, 0 Mbps max"
1860     fi
1861
1862     # OFPT_FLOW_REMOVED, OFPRR_DELETE
1863     ovs-ofctl -O OpenFlow12 add-flow br0 send_flow_rem,actions=drop
1864     ovs-ofctl -O OpenFlow12 --strict del-flows br0 ''
1865     if test X"$1" = X"OFPRR_DELETE"; then shift;
1866         echo >>expout "OFPT_FLOW_REMOVED (OF1.2):  reason=delete table_id=0"
1867     fi
1868     AT_FAIL_IF([test X"$1" != X])
1869
1870     ovs-appctl -t ovs-ofctl ofctl/barrier
1871     echo >>expout "OFPT_BARRIER_REPLY (OF1.2):"
1872
1873     AT_CHECK(
1874       [[sed '
1875 s/ (xid=0x[0-9a-fA-F]*)//
1876 s/ *duration.*//
1877 s/00:0.$/00:0x/' < monitor.log]],
1878       [0], [expout])
1879 }
1880
1881 # It's a service connection so initially there should be no async messages.
1882 check_async 1
1883
1884 # Set miss_send_len to 128, turning on packet-ins for our service connection.
1885 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
1886 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1887
1888 # Set miss_send_len to 128 and enable invalid_ttl.
1889 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700040080
1890 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1891
1892 # Become slave (OF 1.2), which should disable everything except port status.
1893 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000200000003000000000000000000000001
1894 check_async 4 OFPPR_ADD OFPPR_DELETE
1895
1896 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
1897 ovs-appctl -t ovs-ofctl ofctl/send 03040028000000020000232000000013000000020000000500000005000000020000000200000005
1898 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1899
1900 # Set controller ID 123.
1901 ovs-appctl -t ovs-ofctl ofctl/send 03040018000000030000232000000014000000000000007b
1902 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1903
1904 # Restore controller ID 0.
1905 ovs-appctl -t ovs-ofctl ofctl/send 030400180000000300002320000000140000000000000000
1906
1907 # Become master (OF 1.2).
1908 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000400000002000000000000000000000002
1909 check_async 7 OFPR_ACTION OFPPR_ADD
1910
1911 ovs-appctl -t ovs-ofctl exit
1912 OVS_VSWITCHD_STOP
1913 AT_CLEANUP
1914
1915 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.3)])
1916 OVS_VSWITCHD_START
1917 AT_CHECK([ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile])
1918 check_async () {
1919     printf '\n\n--- check_async %d ---\n\n\n' $1
1920     INDEX=$1
1921     shift
1922
1923     ovs-appctl -t ovs-ofctl ofctl/barrier
1924     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1925     : > expout
1926
1927     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1928     ovs-ofctl -O OpenFlow13 -v packet-out br0 none controller '0001020304050010203040501234'
1929     if test X"$1" = X"OFPR_ACTION"; then shift;
1930         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1931 in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
1932     fi
1933
1934     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1935     ovs-ofctl -O OpenFlow13 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1936     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1937         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
1938 in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
1939     fi
1940
1941     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1942     ovs-ofctl -O OpenFlow13 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1943     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1944         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
1945 udp,in_port=0,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"
1946     fi
1947
1948     # OFPT_PORT_STATUS, OFPPR_ADD
1949     ovs-vsctl add-port br0 test -- set Interface test type=dummy
1950     if test X"$1" = X"OFPPR_ADD"; then shift;
1951         echo >>expout "OFPT_PORT_STATUS (OF1.3): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1952      config:     PORT_DOWN
1953      state:      LINK_DOWN
1954      speed: 0 Mbps now, 0 Mbps max"
1955     fi
1956
1957     # OFPT_PORT_STATUS, OFPPR_DELETE
1958     ovs-vsctl del-port br0 test
1959     if test X"$1" = X"OFPPR_DELETE"; then shift;
1960         echo >>expout "OFPT_PORT_STATUS (OF1.3): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1961      config:     PORT_DOWN
1962      state:      LINK_DOWN
1963      speed: 0 Mbps now, 0 Mbps max"
1964     fi
1965
1966     # OFPT_FLOW_REMOVED, OFPRR_DELETE
1967     ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=drop
1968     ovs-ofctl -O OpenFlow13 --strict del-flows br0 ''
1969     if test X"$1" = X"OFPRR_DELETE"; then shift;
1970         echo >>expout "OFPT_FLOW_REMOVED (OF1.3):  reason=delete table_id=0"
1971     fi
1972
1973     # OFPT_FLOW_REMOVED, OFPRR_GROUP_DELETE
1974     ovs-ofctl -O OpenFlow13 add-group br0 group_id=1234,type=all,bucket=output:10
1975     ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=group:1234
1976     ovs-ofctl -O OpenFlow13 --strict del-groups br0 group_id=1234
1977     if test X"$1" = X"OFPRR_DELETE"; then shift;
1978         echo >>expout "OFPT_FLOW_REMOVED (OF1.3):  reason=gropu_delete table_id=0"
1979     fi
1980
1981     AT_FAIL_IF([test X"$1" != X])
1982
1983     ovs-appctl -t ovs-ofctl ofctl/barrier
1984     echo >>expout "OFPT_BARRIER_REPLY (OF1.3):"
1985
1986     AT_CHECK(
1987       [[sed '
1988 s/ (xid=0x[0-9a-fA-F]*)//
1989 s/ *duration.*//
1990 s/00:0.$/00:0x/' < monitor.log]],
1991       [0], [expout])
1992 }
1993
1994 # It's a service connection so initially there should be no async messages.
1995 check_async 1
1996
1997 # Set miss_send_len to 128, turning on packet-ins for our service connection.
1998 ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
1999 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2000
2001 # Become slave (OF 1.3), which should disable everything except port status.
2002 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000200000003000000000000000000000001
2003 check_async 3 OFPPR_ADD OFPPR_DELETE
2004
2005 # Use OF 1.3 OFPT_SET_ASYNC to enable a patchwork of asynchronous messages.
2006 ovs-appctl -t ovs-ofctl ofctl/send 041c002000000002000000020000000500000005000000020000000200000005
2007 check_async 4 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
2008
2009 # Set controller ID 123.
2010 ovs-appctl -t ovs-ofctl ofctl/send 04040018000000030000232000000014000000000000007b
2011 check_async 5 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
2012
2013 # Restore controller ID 0.
2014 ovs-appctl -t ovs-ofctl ofctl/send 040400180000000300002320000000140000000000000000
2015
2016 # Become master (OF 1.3).
2017 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000400000002000000000000000000000002
2018 check_async 6 OFPR_ACTION OFPPR_ADD
2019
2020 ovs-appctl -t ovs-ofctl exit
2021 OVS_VSWITCHD_STOP
2022 AT_CLEANUP
2023
2024 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.5)])
2025 OVS_VSWITCHD_START
2026 AT_CHECK([ovs-ofctl -O OpenFlow15 monitor br0 --detach --no-chdir --pidfile])
2027 check_async () {
2028     printf '\n\n--- check_async %d ---\n\n\n' $1
2029     INDEX=$1
2030     shift
2031
2032     ovs-appctl -t ovs-ofctl ofctl/barrier
2033     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2034     : > expout
2035
2036     # Other tests are not working with OF 1.5, and message
2037     # format may change, so leave them out.
2038
2039     # OFPT_PORT_STATUS, OFPPR_ADD
2040     ovs-vsctl add-port br0 test -- set Interface test type=dummy
2041     if test X"$1" = X"OFPPR_ADD"; then shift;
2042         echo >>expout "OFPT_PORT_STATUS (OF1.5): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2043      config:     PORT_DOWN
2044      state:      LINK_DOWN
2045      speed: 0 Mbps now, 0 Mbps max"
2046     fi
2047
2048     # OFPT_PORT_STATUS, OFPPR_MODIFY
2049     ovs-ofctl -O OpenFlow15 -vwarn mod-port br0 test up
2050     if test X"$1" = X"OFPPR_MODIFY"; then shift;
2051         echo >>expout "OFPT_PORT_STATUS (OF1.5): MOD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2052      config:     0
2053      state:      LINK_DOWN
2054      speed: 0 Mbps now, 0 Mbps max
2055 OFPT_PORT_STATUS (OF1.5): MOD: 2(test): addr:aa:55:aa:55:00:0x
2056      config:     0
2057      state:      0
2058      speed: 0 Mbps now, 0 Mbps max"
2059     fi
2060
2061     # OFPT_PORT_STATUS, OFPPR_DELETE
2062     ovs-vsctl del-port br0 test
2063     if test X"$1" = X"OFPPR_DELETE"; then shift;
2064         echo >>expout "OFPT_PORT_STATUS (OF1.5): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2065      config:     0
2066      state:      0
2067      speed: 0 Mbps now, 0 Mbps max"
2068     fi
2069
2070     AT_FAIL_IF([test X"$1" != X])
2071
2072     ovs-appctl -t ovs-ofctl ofctl/barrier
2073     echo >>expout "OFPT_BARRIER_REPLY (OF1.5):"
2074
2075     AT_CHECK(
2076       [[sed '
2077 s/ (xid=0x[0-9a-fA-F]*)//
2078 s/ *duration.*//
2079 s/00:0.$/00:0x/' < monitor.log]],
2080       [0], [expout])
2081 }
2082
2083 # It's a service connection so initially there should be no async messages.
2084 check_async 1
2085
2086 # If we don't set this, async messages are not received.
2087 # Set miss_send_len to 128, turning on packet-ins for our service connection.
2088 ovs-appctl -t ovs-ofctl ofctl/send 0609000c0123456700000080
2089 check_async 2 OFPPR_ADD OFPPR_MODIFY OFPPR_DELETE
2090
2091 # Set-async has changed in OF 1.4 and is not yet implemented.
2092
2093 ovs-appctl -t ovs-ofctl exit
2094 OVS_VSWITCHD_STOP
2095 AT_CLEANUP
2096
2097 dnl This test checks that the role request/response messaging works
2098 dnl and that generation_id is handled properly.
2099 AT_SETUP([ofproto - controller role (OpenFlow 1.2)])
2100 OVS_VSWITCHD_START
2101 ON_EXIT([kill `cat c1.pid c2.pid`])
2102
2103 # Start two ovs-ofctl controller processes.
2104 AT_CAPTURE_FILE([monitor1.log])
2105 AT_CAPTURE_FILE([expout1])
2106 AT_CAPTURE_FILE([experr1])
2107 AT_CAPTURE_FILE([monitor2.log])
2108 AT_CAPTURE_FILE([expout2])
2109 AT_CAPTURE_FILE([experr2])
2110 for i in 1 2; do
2111      AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile=`pwd`/c$i.pid --unixctl=`pwd`/c$i])
2112     ovs-appctl -t `pwd`/c$i ofctl/barrier
2113     ovs-appctl -t `pwd`/c$i ofctl/set-output-file monitor$i.log
2114     : > expout$i
2115     : > experr$i
2116
2117     # find out current role
2118     ovs-appctl -t `pwd`/c$i ofctl/send 031800180000000200000000000000000000000000000000
2119     echo >>experr$i "send: OFPT_ROLE_REQUEST (OF1.2): role=nochange"
2120     echo >>expout$i "OFPT_ROLE_REPLY (OF1.2): role=equal"
2121 done
2122
2123 # controller 1: Become slave (generation_id is initially undefined, so
2124 # 2^63+2 should not be stale)
2125 ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000300000003000000008000000000000002
2126 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=slave generation_id=9223372036854775810"
2127 echo >>expout1 "OFPT_ROLE_REPLY (OF1.2): role=slave generation_id=9223372036854775810"
2128
2129 # controller 2: Become master.
2130 ovs-appctl -t `pwd`/c2 ofctl/send 031800180000000300000002000000008000000000000003
2131 echo >>experr2 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=9223372036854775811"
2132 echo >>expout2 "OFPT_ROLE_REPLY (OF1.2): role=master generation_id=9223372036854775811"
2133
2134 # controller 1: Try to become the master using a stale generation ID
2135 ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000400000002000000000000000000000003
2136 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=3"
2137 echo >>expout1 "OFPT_ERROR (OF1.2): OFPRRFC_STALE"
2138 echo >>expout1 "OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=3"
2139
2140 # controller 1: Become master using a valid generation ID
2141 ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000500000002000000000000000000000001
2142 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=1"
2143 echo >>expout1 "OFPT_ROLE_REPLY (OF1.2): role=master generation_id=1"
2144
2145 for i in 1 2; do
2146     ovs-appctl -t `pwd`/c$i ofctl/barrier
2147     echo >>expout$i "OFPT_BARRIER_REPLY (OF1.2):"
2148 done
2149
2150 # Check output.
2151 for i in 1 2; do
2152     cp expout$i expout
2153     AT_CHECK([grep -v '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
2154     cp experr$i expout
2155     AT_CHECK([grep '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
2156 done
2157 OVS_VSWITCHD_STOP
2158 AT_CLEANUP
2159
2160 dnl This test checks that the role request/response messaging works,
2161 dnl that generation_id is handled properly, and that role status update
2162 dnl messages are sent when a controller's role gets changed from master
2163 dnl to slave.
2164 AT_SETUP([ofproto - controller role (OpenFlow 1.4)])
2165 OVS_VSWITCHD_START
2166 ON_EXIT([kill `cat c1.pid c2.pid`])
2167
2168 # Start two ovs-ofctl controller processes.
2169 AT_CAPTURE_FILE([monitor1.log])
2170 AT_CAPTURE_FILE([expout1])
2171 AT_CAPTURE_FILE([experr1])
2172 AT_CAPTURE_FILE([monitor2.log])
2173 AT_CAPTURE_FILE([expout2])
2174 AT_CAPTURE_FILE([experr2])
2175 for i in 1 2; do
2176      AT_CHECK([ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile=`pwd`/c$i.pid --unixctl=`pwd`/c$i])
2177     ovs-appctl -t `pwd`/c$i ofctl/barrier
2178     ovs-appctl -t `pwd`/c$i ofctl/set-output-file monitor$i.log
2179     : > expout$i
2180     : > experr$i
2181
2182     # find out current role
2183     ovs-appctl -t `pwd`/c$i ofctl/send 051800180000000200000000000000000000000000000000
2184     echo >>experr$i "send: OFPT_ROLE_REQUEST (OF1.4): role=nochange"
2185     echo >>expout$i "OFPT_ROLE_REPLY (OF1.4): role=equal"
2186 done
2187
2188 # controller 1: Become slave (generation_id is initially undefined, so
2189 # 2^63+2 should not be stale)
2190 ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000300000003000000008000000000000002
2191 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=slave generation_id=9223372036854775810"
2192 echo >>expout1 "OFPT_ROLE_REPLY (OF1.4): role=slave generation_id=9223372036854775810"
2193
2194 # controller 2: Become master.
2195 ovs-appctl -t `pwd`/c2 ofctl/send 051800180000000300000002000000008000000000000003
2196 echo >>experr2 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=9223372036854775811"
2197 echo >>expout2 "OFPT_ROLE_REPLY (OF1.4): role=master generation_id=9223372036854775811"
2198
2199 # controller 1: Try to become the master using a stale generation ID
2200 ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000400000002000000000000000000000003
2201 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=3"
2202 echo >>expout1 "OFPT_ERROR (OF1.4): OFPRRFC_STALE"
2203 echo >>expout1 "OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=3"
2204
2205 # controller 1: Become master using a valid generation ID
2206 ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000500000002000000000000000000000001
2207 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=1"
2208 echo >>expout1 "OFPT_ROLE_REPLY (OF1.4): role=master generation_id=1"
2209 echo >>expout2 "OFPT_ROLE_STATUS (OF1.4): role=slave generation_id=1 reason=master_request"
2210
2211 for i in 1 2; do
2212     ovs-appctl -t `pwd`/c$i ofctl/barrier
2213     echo >>expout$i "OFPT_BARRIER_REPLY (OF1.4):"
2214 done
2215
2216 # Check output.
2217 for i in 1 2; do
2218     cp expout$i expout
2219     AT_CHECK([grep -v '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
2220     cp experr$i expout
2221     AT_CHECK([grep '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
2222 done
2223 OVS_VSWITCHD_STOP
2224 AT_CLEANUP
2225
2226 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
2227 dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
2228 dnl controllers despite the spec) as meaning a packet that was generated
2229 dnl by the controller.
2230 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.0)])
2231 OVS_VSWITCHD_START
2232 ADD_OF_PORTS([br0], [1])
2233
2234 # Start a monitor listening for packet-ins.
2235 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
2236 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
2237 ovs-appctl -t ovs-ofctl ofctl/barrier
2238 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2239 AT_CAPTURE_FILE([monitor.log])
2240
2241 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
2242 AT_CHECK([ovs-ofctl packet-out br0 none controller,1 '0001020304050010203040501234'])
2243 AT_CHECK([ovs-ofctl packet-out br0 controller controller,1 '0001020304050010203040505678'])
2244
2245 # Stop the monitor and check its output.
2246 ovs-appctl -t ovs-ofctl ofctl/barrier
2247 ovs-appctl -t ovs-ofctl exit
2248
2249 ovs-ofctl dump-ports br0
2250
2251 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2252 OFPT_PACKET_IN: total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
2253 in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
2254 OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
2255 in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
2256 OFPT_BARRIER_REPLY:
2257 ])
2258
2259 OVS_VSWITCHD_STOP
2260 AT_CLEANUP
2261
2262 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
2263 dnl specified by OpenFlow 1.2) and OFPP_CONTROLLER (used by some
2264 dnl controllers despite the spec) as meaning a packet that was generated
2265 dnl by the controller.
2266 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.2)])
2267 OVS_VSWITCHD_START
2268
2269 # Start a monitor listening for packet-ins.
2270 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
2271 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
2272 ovs-appctl -t ovs-ofctl ofctl/barrier
2273 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2274 AT_CAPTURE_FILE([monitor.log])
2275
2276 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
2277 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none controller '0001020304050010203040501234'])
2278 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 4294967293 controller '0001020304050010203040505678'])
2279
2280 # Stop the monitor and check its output.
2281 ovs-appctl -t ovs-ofctl ofctl/barrier
2282 ovs-appctl -t ovs-ofctl exit
2283
2284 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2285 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
2286 in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
2287 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
2288 in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
2289 OFPT_BARRIER_REPLY (OF1.2):
2290 ])
2291
2292 OVS_VSWITCHD_STOP
2293 AT_CLEANUP
2294
2295 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
2296 dnl specified by OpenFlow 1.1) and OFPP_CONTROLLER (used by some
2297 dnl controllers despite the spec) as meaning a packet that was generated
2298 dnl by the controller.
2299 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.1)])
2300 OVS_VSWITCHD_START
2301
2302 # Start a monitor listening for packet-ins.
2303 AT_CHECK([ovs-ofctl -O OpenFlow11 monitor br0 --detach --no-chdir --pidfile])
2304 ovs-appctl -t ovs-ofctl ofctl/send 0209000c0123456700000080
2305 ovs-appctl -t ovs-ofctl ofctl/barrier
2306 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2307 AT_CAPTURE_FILE([monitor.log])
2308
2309 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
2310 AT_CHECK([ovs-ofctl -O OpenFlow11 packet-out br0 none controller '0001020304050010203040501234'])
2311 AT_CHECK([ovs-ofctl -O OpenFlow11 packet-out br0 4294967293 controller '0001020304050010203040505678'])
2312
2313 # Stop the monitor and check its output.
2314 ovs-appctl -t ovs-ofctl ofctl/barrier
2315 ovs-appctl -t ovs-ofctl exit
2316
2317 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2318 OFPT_PACKET_IN (OF1.1): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
2319 in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
2320 OFPT_PACKET_IN (OF1.1): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
2321 in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
2322 OFPT_BARRIER_REPLY (OF1.1):
2323 ])
2324
2325 OVS_VSWITCHD_STOP
2326 AT_CLEANUP
2327
2328 dnl This test checks that metadata is encoded in packet_in structures,
2329 dnl supported by NXAST.
2330 AT_SETUP([ofproto - packet-out with metadata (NXM)])
2331 OVS_VSWITCHD_START
2332
2333 # Start a monitor listening for packet-ins.
2334 AT_CHECK([ovs-ofctl -P nxm monitor br0 --detach --no-chdir --pidfile])
2335 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
2336 ovs-appctl -t ovs-ofctl ofctl/barrier
2337 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2338 AT_CAPTURE_FILE([monitor.log])
2339
2340 # Send a packet-out with a load action to set some metadata, and forward to controller
2341 AT_CHECK([ovs-ofctl packet-out br0 controller 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), load(0xaa->NXM_NX_PKT_MARK[[]]), controller' '0001020304050010203040501234'])
2342
2343 # Stop the monitor and check its output.
2344 ovs-appctl -t ovs-ofctl ofctl/barrier
2345 ovs-appctl -t ovs-ofctl exit
2346
2347 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2348 NXT_PACKET_IN: total_len=14 in_port=CONTROLLER metadata=0xfafafafa5a5a5a5a pkt_mark=0xaa (via action) data_len=14 (unbuffered)
2349 in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
2350 OFPT_BARRIER_REPLY:
2351 ])
2352
2353 OVS_VSWITCHD_STOP
2354 AT_CLEANUP
2355
2356 dnl This test checks that metadata is encoded in packet_in structures,
2357 dnl supported by NXAST.
2358 AT_SETUP([ofproto - packet-out with metadata (OpenFlow 1.2)])
2359 OVS_VSWITCHD_START
2360
2361 # Start a monitor listening for packet-ins.
2362 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
2363 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
2364 ovs-appctl -t ovs-ofctl ofctl/barrier
2365 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2366 AT_CAPTURE_FILE([monitor.log])
2367
2368 # Send a packet-out with a set-field action to set some metadata, and forward to controller
2369 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none 'set_field:0xfafafafa5a5a5a5a->metadata, controller' '0001020304050010203040501234'])
2370
2371 # Stop the monitor and check its output.
2372 ovs-appctl -t ovs-ofctl ofctl/barrier
2373 ovs-appctl -t ovs-ofctl exit
2374
2375 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2376 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY metadata=0xfafafafa5a5a5a5a (via action) data_len=14 (unbuffered)
2377 in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
2378 OFPT_BARRIER_REPLY (OF1.2):
2379 ])
2380
2381 OVS_VSWITCHD_STOP
2382 AT_CLEANUP
2383
2384 dnl This test checks that metadata is encoded in packet_in structures,
2385 dnl supported by NXAST.
2386 AT_SETUP([ofproto - packet-out with metadata and dual set_field (OpenFlow 1.3)])
2387 OVS_VSWITCHD_START
2388
2389 # Start a monitor listening for packet-ins.
2390 AT_CHECK([ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile])
2391 ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
2392 ovs-appctl -t ovs-ofctl ofctl/barrier
2393 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2394 AT_CAPTURE_FILE([monitor.log])
2395
2396 # Send a packet-out with a couple of set-field action to set some metadata, and forward to controller
2397 AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 none 'set_field:0xfafafafa5a5a5a5a->metadata, set_field:0x6b->metadata, controller' '0001020304050010203040501234'])
2398
2399 # Stop the monitor and check its output.
2400 ovs-appctl -t ovs-ofctl ofctl/barrier
2401 ovs-appctl -t ovs-ofctl exit
2402
2403 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2404 OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY metadata=0x6b (via action) data_len=14 (unbuffered)
2405 in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
2406 OFPT_BARRIER_REPLY (OF1.3):
2407 ])
2408
2409 OVS_VSWITCHD_STOP
2410 AT_CLEANUP
2411
2412 dnl This test checks that tunnel metadata is encoded in packet_in structures.
2413 AT_SETUP([ofproto - packet-out with tunnel metadata (OpenFlow 1.2)])
2414 OVS_VSWITCHD_START
2415
2416 # Start a monitor listening for packet-ins.
2417 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
2418 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
2419 ovs-appctl -t ovs-ofctl ofctl/barrier
2420 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2421 AT_CAPTURE_FILE([monitor.log])
2422
2423 # Send a packet-out with set field actions to set some tunnel metadata, and forward to controller
2424 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'])
2425
2426 # Stop the monitor and check its output.
2427 ovs-appctl -t ovs-ofctl ofctl/barrier
2428 ovs-appctl -t ovs-ofctl exit
2429
2430 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2431 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY tun_id=0x1020304 tun_src=127.0.0.1 tun_dst=192.168.0.1 (via action) data_len=14 (unbuffered)
2432 in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
2433 OFPT_BARRIER_REPLY (OF1.2):
2434 ])
2435
2436 OVS_VSWITCHD_STOP
2437 AT_CLEANUP
2438
2439 m4_divert_push([PREPARE_TESTS])
2440 # Sorts groups of lines that start with a space, without moving them
2441 # past the nearest line that does not start with a space.
2442 multiline_sort () {
2443     ${PERL} -e '
2444         use warnings;
2445         use strict;
2446         my @buffer = ();
2447         while (<STDIN>) {
2448             if (/^ /) {
2449                 push(@buffer, $_);
2450             } else {
2451                 print $_ foreach sort(@buffer);
2452                 print $_;
2453                 @buffer = ();
2454             }
2455         }
2456         print $_ foreach sort(@buffer);
2457 '
2458 }
2459 m4_divert_pop([PREPARE_TESTS])
2460
2461 AT_SETUP([ofproto - flow monitoring])
2462 AT_KEYWORDS([monitor])
2463 OVS_VSWITCHD_START
2464
2465 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
2466
2467 # Start a monitor watching the flow table and check the initial reply.
2468 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
2469 AT_CAPTURE_FILE([monitor.log])
2470 ovs-appctl -t ovs-ofctl ofctl/barrier
2471 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
2472   [NXST_FLOW_MONITOR reply:
2473  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
2474 OFPT_BARRIER_REPLY:
2475 ])
2476
2477 # Add, delete, and modify some flows and check the updates.
2478 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2479 ovs-ofctl add-flow br0 in_port=0,dl_vlan=124,actions=output:2
2480 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:5
2481 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=0,actions=output:6
2482 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=1,actions=output:7
2483 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:8
2484 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=0,actions=output:9
2485 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=1,actions=output:10
2486 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,actions=output:11
2487 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=0,actions=output:12
2488 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=1,actions=output:13
2489 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,actions=output:14
2490 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:15
2491 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:16
2492 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:17
2493 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:18
2494 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:19
2495 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:20
2496 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=0,actions=output:21
2497 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=1,actions=output:22
2498 ovs-ofctl add-flow br0 in_port=0,actions=output:23
2499 ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:3
2500 ovs-ofctl mod-flows br0 cookie=5,dl_vlan=123,actions=output:3
2501 ovs-ofctl del-flows br0 dl_vlan=123
2502 ovs-ofctl del-flows br0
2503 ovs-appctl -t ovs-ofctl ofctl/barrier
2504 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | multiline_sort], [0],
2505 [NXST_FLOW_MONITOR reply (xid=0x0):
2506  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
2507 NXST_FLOW_MONITOR reply (xid=0x0):
2508  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:5
2509 NXST_FLOW_MONITOR reply (xid=0x0):
2510  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:6
2511 NXST_FLOW_MONITOR reply (xid=0x0):
2512  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:7
2513 NXST_FLOW_MONITOR reply (xid=0x0):
2514  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:8
2515 NXST_FLOW_MONITOR reply (xid=0x0):
2516  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:9
2517 NXST_FLOW_MONITOR reply (xid=0x0):
2518  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:10
2519 NXST_FLOW_MONITOR reply (xid=0x0):
2520  event=ADDED table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
2521 NXST_FLOW_MONITOR reply (xid=0x0):
2522  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
2523 NXST_FLOW_MONITOR reply (xid=0x0):
2524  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
2525 NXST_FLOW_MONITOR reply (xid=0x0):
2526  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
2527 NXST_FLOW_MONITOR reply (xid=0x0):
2528  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:15
2529 NXST_FLOW_MONITOR reply (xid=0x0):
2530  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:16
2531 NXST_FLOW_MONITOR reply (xid=0x0):
2532  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:17
2533 NXST_FLOW_MONITOR reply (xid=0x0):
2534  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
2535 NXST_FLOW_MONITOR reply (xid=0x0):
2536  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
2537 NXST_FLOW_MONITOR reply (xid=0x0):
2538  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
2539 NXST_FLOW_MONITOR reply (xid=0x0):
2540  event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
2541 NXST_FLOW_MONITOR reply (xid=0x0):
2542  event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
2543 NXST_FLOW_MONITOR reply (xid=0x0):
2544  event=ADDED table=0 cookie=0 in_port=0 actions=output:23
2545 NXST_FLOW_MONITOR reply (xid=0x0):
2546  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:3
2547  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
2548  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
2549 NXST_FLOW_MONITOR reply (xid=0x0):
2550  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
2551  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
2552  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
2553 NXST_FLOW_MONITOR reply (xid=0x0):
2554  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
2555  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
2556  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
2557 NXST_FLOW_MONITOR reply (xid=0x0):
2558  event=DELETED reason=delete table=0 cookie=0 in_port=0 actions=output:23
2559  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
2560  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
2561  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
2562  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
2563  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
2564  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
2565  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
2566  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
2567  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
2568  event=DELETED reason=delete table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
2569 OFPT_BARRIER_REPLY:
2570 ])
2571
2572 # Check that our own changes are reported as full updates.
2573 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2574 ovs-ofctl add-flow br0 in_port=1,actions=output:2
2575 ovs-ofctl add-flow br0 in_port=2,actions=output:1
2576 ovs-appctl -t ovs-ofctl ofctl/barrier
2577 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
2578 ovs-appctl -t ovs-ofctl ofctl/barrier
2579 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
2580 ])
2581 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | multiline_sort], [0],
2582 [NXST_FLOW_MONITOR reply (xid=0x0):
2583  event=ADDED table=0 cookie=0 in_port=1 actions=output:2
2584 NXST_FLOW_MONITOR reply (xid=0x0):
2585  event=ADDED table=0 cookie=0 in_port=2 actions=output:1
2586 OFPT_BARRIER_REPLY:
2587 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
2588 NXST_FLOW_MONITOR reply (xid=0x0):
2589  event=DELETED reason=delete table=0 cookie=0 in_port=1 actions=output:2
2590  event=DELETED reason=delete table=0 cookie=0 in_port=2 actions=output:1
2591 OFPT_BARRIER_REPLY:
2592 ])
2593
2594 ovs-appctl -t ovs-ofctl exit
2595 OVS_VSWITCHD_STOP
2596 AT_CLEANUP
2597
2598 AT_SETUP([ofproto - flow monitoring with !own])
2599 AT_KEYWORDS([monitor])
2600 OVS_VSWITCHD_START
2601
2602 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
2603
2604 # Start a monitor watching the flow table and check the initial reply.
2605 ovs-ofctl monitor br0 watch:\!own --detach --no-chdir --pidfile >monitor.log 2>&1
2606 AT_CAPTURE_FILE([monitor.log])
2607 ovs-appctl -t ovs-ofctl ofctl/barrier
2608 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
2609   [NXST_FLOW_MONITOR reply:
2610  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
2611 OFPT_BARRIER_REPLY:
2612 ])
2613
2614 # Check that our own changes are reported as abbreviations.
2615 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2616 ovs-ofctl add-flow br0 in_port=1,actions=output:2
2617 ovs-ofctl add-flow br0 in_port=2,actions=output:1
2618 ovs-appctl -t ovs-ofctl ofctl/barrier
2619 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
2620 ovs-appctl -t ovs-ofctl ofctl/barrier
2621 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
2622 ])
2623 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
2624 [NXST_FLOW_MONITOR reply (xid=0x0):
2625  event=ADDED table=0 cookie=0 in_port=1 actions=output:2
2626 NXST_FLOW_MONITOR reply (xid=0x0):
2627  event=ADDED table=0 cookie=0 in_port=2 actions=output:1
2628 OFPT_BARRIER_REPLY:
2629 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
2630 NXST_FLOW_MONITOR reply (xid=0x0):
2631  event=ABBREV xid=0x12345678
2632 OFPT_BARRIER_REPLY:
2633 ])
2634
2635 ovs-appctl -t ovs-ofctl exit
2636 OVS_VSWITCHD_STOP
2637 AT_CLEANUP
2638
2639 AT_SETUP([ofproto - flow monitoring with out_port])
2640 AT_KEYWORDS([monitor])
2641 OVS_VSWITCHD_START
2642
2643 ovs-ofctl add-flow br0 in_port=0,dl_vlan=121,actions=output:1
2644 ovs-ofctl add-flow br0 in_port=0,dl_vlan=122,actions=output:1
2645 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:2
2646
2647 # Start a monitor watching the flow table and check the initial reply.
2648 ovs-ofctl monitor br0 watch:out_port=2 --detach --no-chdir --pidfile >monitor.log 2>&1
2649 AT_CAPTURE_FILE([monitor.log])
2650 ovs-appctl -t ovs-ofctl ofctl/barrier
2651 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
2652   [NXST_FLOW_MONITOR reply:
2653  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:2
2654 OFPT_BARRIER_REPLY:
2655 ])
2656
2657 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2658
2659 # Add, modify flows and check the updates.
2660 ovs-ofctl mod-flows br0 dl_vlan=121,actions=drop
2661 ovs-ofctl mod-flows br0 dl_vlan=122,actions=output:1,output:2
2662 ovs-appctl -t ovs-ofctl ofctl/barrier
2663
2664 ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:1,output:2
2665 ovs-appctl -t ovs-ofctl ofctl/barrier
2666
2667 ovs-ofctl mod-flows br0 dl_vlan=122,actions=output:1
2668 ovs-appctl -t ovs-ofctl ofctl/barrier
2669 ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:2
2670 ovs-appctl -t ovs-ofctl ofctl/barrier
2671
2672 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
2673 [NXST_FLOW_MONITOR reply (xid=0x0):
2674  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=122 actions=output:1,output:2
2675 OFPT_BARRIER_REPLY:
2676 NXST_FLOW_MONITOR reply (xid=0x0):
2677  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1,output:2
2678 OFPT_BARRIER_REPLY:
2679 NXST_FLOW_MONITOR reply (xid=0x0):
2680  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=122 actions=output:1
2681 OFPT_BARRIER_REPLY:
2682 NXST_FLOW_MONITOR reply (xid=0x0):
2683  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:2
2684 OFPT_BARRIER_REPLY:
2685 ])
2686
2687 ovs-appctl -t ovs-ofctl exit
2688 OVS_VSWITCHD_STOP
2689 AT_CLEANUP
2690
2691 AT_SETUP([ofproto - flow monitoring pause and resume])
2692 AT_KEYWORDS([monitor])
2693
2694 # The maximum socket receive buffer size is important for this test, which
2695 # tests behavior when the receive buffer overflows.
2696 if test -e /proc/sys/net/core/rmem_max; then
2697     # Linux
2698     rmem_max=`cat /proc/sys/net/core/rmem_max`
2699 elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
2700     : # FreeBSD, NetBSD
2701 else
2702     # Don't know how to get maximum socket receive buffer on this OS
2703     AT_SKIP_IF([:])
2704 fi
2705 # Calculate the total amount of queuing: rmem_max in the kernel, 128 kB
2706 # in ofproto sending userspace (see ofmonitor_flush() in connmgr.c).
2707 queue_size=`expr $rmem_max + 128 \* 1024`
2708 echo rmem_max=$rmem_max queue_size=$queue_size
2709
2710 # If there's too much queuing skip the test to avoid timing out.
2711 AT_SKIP_IF([test $rmem_max -gt 1048576])
2712
2713 # Each flow update message takes up at least 48 bytes of space in queues
2714 # and in practice more than that.
2715 n_msgs=`expr $queue_size / 48`
2716 echo n_msgs=$n_msgs
2717
2718 OVS_VSWITCHD_START
2719
2720 # Start a monitor watching the flow table, then make it block.
2721 ON_EXIT([kill `cat ovs-ofctl.pid`])
2722 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
2723 AT_CAPTURE_FILE([monitor.log])
2724 ovs-appctl -t ovs-ofctl ofctl/block
2725
2726 # Add $n_msgs flows.
2727 (echo "in_port=2,actions=output:2"
2728 ${PERL} -e '
2729     for ($i = 0; $i < '$n_msgs'; $i++) {
2730         print "cookie=1,reg1=$i,actions=drop\n";
2731     }
2732 ') > flows.txt
2733 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
2734 # Check that multipart flow dumps work properly:
2735 AT_CHECK([ovs-ofctl diff-flows br0 flows.txt])
2736 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,cookie=3,actions=drop])
2737 AT_CHECK([ovs-ofctl mod-flows br0 in_port=2,cookie=2,actions=output:2])
2738 AT_CHECK([ovs-ofctl del-flows br0 cookie=1/-1])
2739
2740 ovs-appctl -t ovs-ofctl ofctl/unblock
2741
2742 # Wait for the connection resumed.
2743 # A barrier doesn't work for this purpose.
2744 #    https://www.mail-archive.com/dev@openvswitch.org/msg27013.html
2745 #    https://www.mail-archive.com/dev@openvswitch.org/msg27675.html
2746 OVS_WAIT_UNTIL([grep NXT_FLOW_MONITOR_RESUMED monitor.log])
2747
2748 ovs-appctl -t ovs-ofctl exit
2749
2750 # Check that the flow monitor reported the same number of flows
2751 # added and deleted, but fewer than we actually added and deleted.
2752 adds=`grep -c 'ADDED.*reg1=' monitor.log`
2753 deletes=`grep -c 'DELETED.*reg1=' monitor.log`
2754 echo adds=$adds deletes=$deletes
2755 AT_CHECK([test $adds -gt 100 && test $adds -lt $n_msgs])
2756 AT_CHECK([test $adds = $deletes])
2757
2758 # Check that the flow monitor reported everything in the expected order:
2759 #
2760 #     event=ADDED table=0 cookie=0x1 reg1=0x22
2761 # ...
2762 #    NXT_FLOW_MONITOR_PAUSED:
2763 # ...
2764 #     event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
2765 # ...
2766 #     event=ADDED table=0 cookie=0x3 in_port=1
2767 #     event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
2768 #    NXT_FLOW_MONITOR_RESUMED:
2769 #
2770 # except that, between the PAUSED and RESUMED, the order of the ADDED
2771 # and MODIFIED lines lines depends on hash order, that is, it varies
2772 # as we change the hash function or change architecture.  Therefore,
2773 # we use a couple of tests below to accept both orders.
2774 AT_CHECK([ofctl_strip < monitor.log | sed -n -e '
2775 /reg1=0x22$/p
2776 /cookie=0x[[23]]/p
2777 /NXT_FLOW_MONITOR_PAUSED:/p
2778 /NXT_FLOW_MONITOR_RESUMED:/p
2779 ' > monitor.log.subset])
2780 AT_CHECK([grep -v MODIFIED monitor.log.subset], [0], [dnl
2781  event=ADDED table=0 cookie=0x1 reg1=0x22
2782 NXT_FLOW_MONITOR_PAUSED:
2783  event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
2784  event=ADDED table=0 cookie=0x3 in_port=1
2785 NXT_FLOW_MONITOR_RESUMED:
2786 ])
2787 AT_CHECK([grep -v ADDED monitor.log.subset], [0], [dnl
2788 NXT_FLOW_MONITOR_PAUSED:
2789  event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
2790  event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
2791 NXT_FLOW_MONITOR_RESUMED:
2792 ])
2793
2794 OVS_VSWITCHD_STOP
2795 AT_CLEANUP
2796
2797 AT_SETUP([ofproto - event filtering (OpenFlow 1.3)])
2798 AT_KEYWORDS([monitor])
2799 OVS_VSWITCHD_START
2800
2801 # Start a monitor, use the required protocol version
2802 ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2803 AT_CAPTURE_FILE([monitor.log])
2804
2805 # Send an OpenFlow13 message (04), OFPT_GET_ASYNC_REQUEST (1a), length (8), xid (0a)
2806 ovs-appctl -t ovs-ofctl ofctl/send 041a00080000000a
2807 ovs-appctl -t ovs-ofctl ofctl/barrier
2808
2809 # Check default setting
2810 read -r -d '' expected <<'EOF'
2811 EOF
2812
2813 AT_CHECK([ofctl_strip < monitor.log], [], [dnl
2814 send: OFPT_GET_ASYNC_REQUEST (OF1.3):
2815 OFPT_GET_ASYNC_REPLY (OF1.3):
2816  master:
2817        PACKET_IN: no_match action
2818      PORT_STATUS: add delete modify
2819     FLOW_REMOVED: idle hard delete
2820
2821  slave:
2822        PACKET_IN: (off)
2823      PORT_STATUS: add delete modify
2824     FLOW_REMOVED: (off)
2825 OFPT_BARRIER_REPLY (OF1.3):
2826 ])
2827
2828 OVS_VSWITCHD_STOP
2829 AT_CLEANUP
2830
2831 AT_SETUP([ofproto - ofport_request])
2832 OVS_VSWITCHD_START
2833 ADD_OF_PORTS([br0], [1], [2], [3])
2834
2835 set_and_check_specific_ofports () {
2836     ovs-vsctl set Interface p1 ofport_request="$1" -- \
2837               set Interface p2 ofport_request="$2" -- \
2838               set Interface p3 ofport_request="$3"
2839     ofports=`ovs-vsctl get Interface p1 ofport -- \
2840                        get Interface p2 ofport -- \
2841                        get Interface p3 ofport`
2842     AT_CHECK_UNQUOTED([echo $ofports], [0], [$1 $2 $3
2843 ])
2844 }
2845 for pre in      '1 2 3' '1 3 2' '2 1 3' '2 3 1' '3 1 2' '3 2 1'; do
2846     for post in '1 2 3' '1 3 2' '2 1 3' '2 3 1' '3 1 2' '3 2 1'; do
2847         echo -----------------------------------------------------------
2848         echo "Check changing port numbers from $pre to $post"
2849         set_and_check_specific_ofports $pre
2850         set_and_check_specific_ofports $post
2851     done
2852 done
2853
2854 ovs-vsctl del-port p3
2855
2856 set_and_check_poorly_specified_ofports () {
2857     ovs-vsctl set Interface p1 ofport_request="$1" -- \
2858               set Interface p2 ofport_request="$2"
2859     p1=`ovs-vsctl get Interface p1 ofport`
2860     p2=`ovs-vsctl get Interface p2 ofport`
2861     echo $p1 $p2
2862
2863     AT_CHECK([test "$p1" != "$p2"])
2864     if test "$1" = "$2" && test "$1" != '[[]]'; then
2865         # One port number must be the requested one.
2866         AT_CHECK([test "$p1" = "$1" || test "$p2" = "$1"])
2867         # The other port number must be different (already tested above).
2868     else
2869         AT_CHECK([test "$1" = '[[]]' || test "$p1" == "$1"])
2870         AT_CHECK([test "$2" = '[[]]' || test "$p2" == "$2"])
2871     fi
2872 }
2873 for pre in      '1 2' '[[]] 2' '1 [[]]' '[[]] [[]]' '2 1' '[[]] 1' '2 [[]]' \
2874                 '1 1' '2 2'; do
2875     for post in '1 2' '[[]] 2' '1 [[]]' '[[]] [[]]' '2 1' '[[]] 1' '2 [[]]' \
2876                 '1 1' '2 2'; do
2877         echo -----------------------------------------------------------
2878         echo "Check changing port numbers from $pre to $post"
2879         set_and_check_poorly_specified_ofports $pre
2880         set_and_check_poorly_specified_ofports $post
2881     done
2882 done
2883 OVS_VSWITCHD_STOP
2884 AT_CLEANUP
2885
2886
2887 AT_SETUP([ofproto - bundles, open (OpenFlow 1.4)])
2888 AT_KEYWORDS([monitor])
2889 OVS_VSWITCHD_START
2890
2891 # Start a monitor, use the required protocol version
2892 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2893 AT_CAPTURE_FILE([monitor.log])
2894
2895 # Send an OpenFlow14 message (05), OFPT_BUNDLE_CONTROL (21), length (10), xid (0a)
2896 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2897 ovs-appctl -t ovs-ofctl ofctl/barrier
2898 ovs-appctl -t ovs-ofctl exit
2899
2900 AT_CHECK([ofctl_strip < monitor.log], [], [dnl
2901 send: OFPT_BUNDLE_CONTROL (OF1.4):
2902  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2903 OFPT_BUNDLE_CONTROL (OF1.4):
2904  bundle_id=0x1 type=OPEN_REPLY flags=0
2905 OFPT_BARRIER_REPLY (OF1.4):
2906 ])
2907
2908 OVS_VSWITCHD_STOP
2909 AT_CLEANUP
2910
2911 AT_SETUP([ofproto - bundles, double open (OpenFlow 1.4)])
2912 AT_KEYWORDS([monitor])
2913 OVS_VSWITCHD_START
2914
2915 # Start a monitor, use the required protocol version
2916 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2917 AT_CAPTURE_FILE([monitor.log])
2918
2919 # Send twice an OpenFlow14 message (05), OFPT_BUNDLE_CONTROL (21), length (10), xid (0a)
2920 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2921 ovs-appctl -t ovs-ofctl ofctl/barrier
2922 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2923 ovs-appctl -t ovs-ofctl ofctl/barrier
2924 ovs-appctl -t ovs-ofctl exit
2925
2926 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2927 send: OFPT_BUNDLE_CONTROL (OF1.4):
2928  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2929 OFPT_BUNDLE_CONTROL (OF1.4):
2930  bundle_id=0x1 type=OPEN_REPLY flags=0
2931 OFPT_BARRIER_REPLY (OF1.4):
2932 send: OFPT_BUNDLE_CONTROL (OF1.4):
2933  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2934 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
2935 OFPT_BUNDLE_CONTROL (OF1.4):
2936  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2937 OFPT_BARRIER_REPLY (OF1.4):
2938 ])
2939
2940 OVS_VSWITCHD_STOP
2941 AT_CLEANUP
2942
2943 AT_SETUP([ofproto - bundle close without open (OpenFlow 1.4)])
2944 AT_KEYWORDS([monitor])
2945 OVS_VSWITCHD_START
2946
2947 # Start a monitor, use the required protocol version
2948 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2949 AT_CAPTURE_FILE([monitor.log])
2950
2951 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 01"
2952 ovs-appctl -t ovs-ofctl ofctl/barrier
2953 ovs-appctl -t ovs-ofctl exit
2954
2955 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2956 send: OFPT_BUNDLE_CONTROL (OF1.4):
2957  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
2958 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
2959 OFPT_BUNDLE_CONTROL (OF1.4):
2960  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
2961 OFPT_BARRIER_REPLY (OF1.4):
2962 ])
2963
2964 OVS_VSWITCHD_STOP
2965 AT_CLEANUP
2966
2967 AT_SETUP([ofproto - bundle double close (OpenFlow 1.4)])
2968 AT_KEYWORDS([monitor])
2969 OVS_VSWITCHD_START
2970
2971 # Start a monitor, use the required protocol version
2972 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2973 AT_CAPTURE_FILE([monitor.log])
2974
2975 # Open, Close, Close
2976 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2977 ovs-appctl -t ovs-ofctl ofctl/barrier
2978 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 01"
2979 ovs-appctl -t ovs-ofctl ofctl/barrier
2980 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 01"
2981 ovs-appctl -t ovs-ofctl ofctl/barrier
2982 ovs-appctl -t ovs-ofctl exit
2983
2984 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2985 send: OFPT_BUNDLE_CONTROL (OF1.4):
2986  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2987 OFPT_BUNDLE_CONTROL (OF1.4):
2988  bundle_id=0x1 type=OPEN_REPLY flags=0
2989 OFPT_BARRIER_REPLY (OF1.4):
2990 send: OFPT_BUNDLE_CONTROL (OF1.4):
2991  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
2992 OFPT_BUNDLE_CONTROL (OF1.4):
2993  bundle_id=0x1 type=CLOSE_REPLY flags=0
2994 OFPT_BARRIER_REPLY (OF1.4):
2995 send: OFPT_BUNDLE_CONTROL (OF1.4):
2996  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
2997 OFPT_ERROR (OF1.4): OFPBFC_BUNDLE_CLOSED
2998 OFPT_BUNDLE_CONTROL (OF1.4):
2999  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
3000 OFPT_BARRIER_REPLY (OF1.4):
3001 ])
3002
3003 OVS_VSWITCHD_STOP
3004 AT_CLEANUP
3005
3006 AT_SETUP([ofproto - bundle close, different flags (OpenFlow 1.4)])
3007 AT_KEYWORDS([monitor])
3008 OVS_VSWITCHD_START
3009
3010 # Start a monitor, use the required protocol version
3011 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3012 AT_CAPTURE_FILE([monitor.log])
3013
3014 # Open, Close, Close
3015 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
3016 ovs-appctl -t ovs-ofctl ofctl/barrier
3017 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 02"
3018 ovs-appctl -t ovs-ofctl ofctl/barrier
3019 ovs-appctl -t ovs-ofctl exit
3020
3021 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3022 send: OFPT_BUNDLE_CONTROL (OF1.4):
3023  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
3024 OFPT_BUNDLE_CONTROL (OF1.4):
3025  bundle_id=0x1 type=OPEN_REPLY flags=0
3026 OFPT_BARRIER_REPLY (OF1.4):
3027 send: OFPT_BUNDLE_CONTROL (OF1.4):
3028  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
3029 OFPT_ERROR (OF1.4): OFPBFC_BAD_FLAGS
3030 OFPT_BUNDLE_CONTROL (OF1.4):
3031  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
3032 OFPT_BARRIER_REPLY (OF1.4):
3033 ])
3034
3035 OVS_VSWITCHD_STOP
3036 AT_CLEANUP
3037
3038 AT_SETUP([ofproto - bundle commit without open (OpenFlow 1.4)])
3039 AT_KEYWORDS([monitor])
3040 OVS_VSWITCHD_START
3041
3042 # Start a monitor, use the required protocol version
3043 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3044 AT_CAPTURE_FILE([monitor.log])
3045
3046 # Open, Close, Close
3047 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 04 00 01"
3048 ovs-appctl -t ovs-ofctl ofctl/barrier
3049 ovs-appctl -t ovs-ofctl exit
3050
3051 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3052 send: OFPT_BUNDLE_CONTROL (OF1.4):
3053  bundle_id=0x1 type=COMMIT_REQUEST flags=atomic
3054 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
3055 OFPT_BUNDLE_CONTROL (OF1.4):
3056  bundle_id=0x1 type=COMMIT_REQUEST flags=atomic
3057 OFPT_BARRIER_REPLY (OF1.4):
3058 ])
3059
3060 OVS_VSWITCHD_STOP
3061 AT_CLEANUP
3062
3063 AT_SETUP([ofproto - bundle commit, different flags (OpenFlow 1.4)])
3064 AT_KEYWORDS([monitor])
3065 OVS_VSWITCHD_START
3066
3067 # Start a monitor, use the required protocol version
3068 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3069 AT_CAPTURE_FILE([monitor.log])
3070
3071 # Open, Close, Close
3072 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
3073 ovs-appctl -t ovs-ofctl ofctl/barrier
3074 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 04 00 02"
3075 ovs-appctl -t ovs-ofctl ofctl/barrier
3076 ovs-appctl -t ovs-ofctl exit
3077
3078 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3079 send: OFPT_BUNDLE_CONTROL (OF1.4):
3080  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
3081 OFPT_BUNDLE_CONTROL (OF1.4):
3082  bundle_id=0x1 type=OPEN_REPLY flags=0
3083 OFPT_BARRIER_REPLY (OF1.4):
3084 send: OFPT_BUNDLE_CONTROL (OF1.4):
3085  bundle_id=0x1 type=COMMIT_REQUEST flags=ordered
3086 OFPT_ERROR (OF1.4): OFPBFC_BAD_FLAGS
3087 OFPT_BUNDLE_CONTROL (OF1.4):
3088  bundle_id=0x1 type=COMMIT_REQUEST flags=ordered
3089 OFPT_BARRIER_REPLY (OF1.4):
3090 ])
3091
3092 OVS_VSWITCHD_STOP
3093 AT_CLEANUP
3094
3095 AT_SETUP([ofproto - bundle discard without open (OpenFlow 1.4)])
3096 AT_KEYWORDS([monitor])
3097 OVS_VSWITCHD_START
3098
3099 # Start a monitor, use the required protocol version
3100 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3101 AT_CAPTURE_FILE([monitor.log])
3102
3103 # Open, Close, Close
3104 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 06 00 01"
3105 ovs-appctl -t ovs-ofctl ofctl/barrier
3106 ovs-appctl -t ovs-ofctl exit
3107
3108 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3109 send: OFPT_BUNDLE_CONTROL (OF1.4):
3110  bundle_id=0x1 type=DISCARD_REQUEST flags=atomic
3111 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
3112 OFPT_BUNDLE_CONTROL (OF1.4):
3113  bundle_id=0x1 type=DISCARD_REQUEST flags=atomic
3114 OFPT_BARRIER_REPLY (OF1.4):
3115 ])
3116
3117 OVS_VSWITCHD_STOP
3118 AT_CLEANUP