ofp-actions: Add action bitmap abstraction.
[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 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 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 (OFPBRC_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 (echo "OFPST_TABLE reply (xid=0x2): 254 tables
1032   0: classifier: wild=0x3fffff, max=1000000, active=0
1033                lookup=0, matched=0"
1034  x=1
1035  while test $x -lt 254; do
1036    printf "  %d: %-8s: wild=0x3fffff, max=1000000, active=0
1037                lookup=0, matched=0
1038 " $x table$x
1039    x=`expr $x + 1`
1040  done) > expout
1041 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
1042 # Change the configuration.
1043 AT_CHECK(
1044   [ovs-vsctl \
1045      -- --id=@t0 create Flow_Table name=main \
1046      -- --id=@t1 create Flow_Table flow-limit=1024 \
1047      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
1048    | ${PERL} $srcdir/uuidfilt.pl],
1049   [0], [<0>
1050 <1>
1051 ])
1052 # Check that the configuration was updated.
1053 mv expout orig-expout
1054 (echo "OFPST_TABLE reply (xid=0x2): 254 tables
1055   0: main    : wild=0x3fffff, max=1000000, active=0
1056                lookup=0, matched=0
1057   1: table1  : wild=0x3fffff, max=  1024, active=0
1058                lookup=0, matched=0"
1059  tail -n +6 orig-expout) > expout
1060 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
1061 OVS_VSWITCHD_STOP
1062 AT_CLEANUP
1063
1064 AT_SETUP([ofproto - flow table configuration (OpenFlow 1.2)])
1065 OVS_VSWITCHD_START
1066 # Check the default configuration.
1067 (mid="wild=0x1ffffffffd, max=1000000,"
1068  tail="
1069                lookup=0, matched=0
1070                match=0x1ffffffffd, instructions=0x00000007, config=0x00000003
1071                write_actions=0x03ff8001, apply_actions=0x03ff8001
1072                write_setfields=0x0000000c0fe7fbdd
1073                apply_setfields=0x0000000c0fe7fbdd
1074                metadata_match=0xffffffffffffffff
1075                metadata_write=0xffffffffffffffff"
1076  echo "OFPST_TABLE reply (OF1.2) (xid=0x2): 254 tables
1077   0: classifier: $mid active=0$tail"
1078  x=1
1079  while test $x -lt 254; do
1080    printf "  %d: %-8s: $mid active=0$tail
1081 " $x table$x
1082    x=`expr $x + 1`
1083  done) > expout
1084 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
1085 # Change the configuration.
1086 AT_CHECK(
1087   [ovs-vsctl \
1088      -- --id=@t0 create Flow_Table name=main \
1089      -- --id=@t1 create Flow_Table flow-limit=1024 \
1090      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
1091    | ${PERL} $srcdir/uuidfilt.pl],
1092   [0], [<0>
1093 <1>
1094 ])
1095 # Check that the configuration was updated.
1096 mv expout orig-expout
1097 (echo "OFPST_TABLE reply (OF1.2) (xid=0x2): 254 tables
1098   0: main    : wild=0x1ffffffffd, max=1000000, active=0"
1099  tail -n +3 orig-expout | head -7
1100  echo "  1: table1  : wild=0x1ffffffffd, max=  1024, active=0"
1101  tail -n +11 orig-expout) > expout
1102 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
1103 OVS_VSWITCHD_STOP
1104 AT_CLEANUP
1105
1106 AT_SETUP([ofproto - hard limits on flow table size (OpenFlow 1.0)])
1107 OVS_VSWITCHD_START
1108 # Configure a maximum of 4 flows.
1109 AT_CHECK(
1110   [ovs-vsctl \
1111      -- --id=@t0 create Flow_Table flow-limit=4 \
1112      -- set bridge br0 flow_tables:0=@t0 \
1113    | ${PERL} $srcdir/uuidfilt.pl],
1114   [0], [<0>
1115 ])
1116 # Add 4 flows.
1117 for in_port in 1 2 3 4; do
1118     ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
1119 done
1120 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1121  in_port=1 actions=drop
1122  in_port=2 actions=drop
1123  in_port=3 actions=drop
1124  in_port=4 actions=drop
1125 NXST_FLOW reply:
1126 ])
1127 # Adding another flow will be refused.
1128 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
1129 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1130   [OFPT_ERROR: OFPFMFC_TABLE_FULL
1131 ])
1132 # Also a mod-flow that would add a flow will be refused.
1133 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
1134 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1135   [OFPT_ERROR: OFPFMFC_TABLE_FULL
1136 ])
1137 # Replacing or modifying an existing flow is allowed.
1138 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
1139 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
1140 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1141  in_port=1 actions=drop
1142  in_port=2 actions=drop
1143  in_port=3 actions=output:1
1144  in_port=4 actions=NORMAL
1145 NXST_FLOW reply:
1146 ])
1147 OVS_VSWITCHD_STOP
1148 AT_CLEANUP
1149
1150 AT_SETUP([ofproto - hard limits on flow table size (OpenFlow 1.2)])
1151 OVS_VSWITCHD_START
1152 # Configure a maximum of 4 flows.
1153 AT_CHECK(
1154   [ovs-vsctl \
1155      -- --id=@t0 create Flow_Table flow-limit=4 \
1156      -- set bridge br0 flow_tables:0=@t0 \
1157    | ${PERL} $srcdir/uuidfilt.pl],
1158   [0], [<0>
1159 ])
1160 # Add 4 flows.
1161 for in_port in 1 2 3 4; do
1162     ovs-ofctl -O OpenFlow12 add-flow br0 in_port=$in_port,actions=drop
1163 done
1164 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1165  in_port=1 actions=drop
1166  in_port=2 actions=drop
1167  in_port=3 actions=drop
1168  in_port=4 actions=drop
1169 OFPST_FLOW reply (OF1.2):
1170 ])
1171 # Adding another flow will be refused.
1172 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
1173 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1174   [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
1175 ])
1176 # Replacing or modifying an existing flow is allowed.
1177 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
1178 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
1179 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1180  in_port=1 actions=drop
1181  in_port=2 actions=drop
1182  in_port=3 actions=output:1
1183  in_port=4 actions=NORMAL
1184 OFPST_FLOW reply (OF1.2):
1185 ])
1186 OVS_VSWITCHD_STOP
1187 AT_CLEANUP
1188
1189 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.0)])
1190 OVS_VSWITCHD_START
1191 # Configure a maximum of 4 flows.
1192 AT_CHECK(
1193   [ovs-vsctl \
1194      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
1195      -- set bridge br0 flow_tables:0=@t0 \
1196    | ${PERL} $srcdir/uuidfilt.pl],
1197   [0], [<0>
1198 ])
1199 # Add 4 flows.
1200 for in_port in 4 3 2 1; do
1201     ovs-ofctl add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
1202 done
1203 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1204  idle_timeout=10, in_port=1 actions=drop
1205  idle_timeout=20, in_port=2 actions=drop
1206  idle_timeout=30, in_port=3 actions=drop
1207  idle_timeout=40, in_port=4 actions=drop
1208 NXST_FLOW reply:
1209 ])
1210 # Adding another flow will cause the one that expires soonest to be evicted.
1211 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
1212 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1213  idle_timeout=20, in_port=2 actions=drop
1214  idle_timeout=30, in_port=3 actions=drop
1215  idle_timeout=40, in_port=4 actions=drop
1216  in_port=5 actions=drop
1217 NXST_FLOW reply:
1218 ])
1219 # A mod-flow that adds a flow also causes eviction, but replacing or
1220 # modifying an existing flow doesn't.
1221 AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
1222 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
1223 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
1224 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1225  idle_timeout=30, in_port=3 actions=output:1
1226  in_port=4 actions=NORMAL
1227  in_port=5 actions=drop
1228  in_port=6 actions=drop
1229 NXST_FLOW reply:
1230 ])
1231 # Flows with no timeouts at all cannot be evicted.
1232 AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
1233 AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
1234 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1235   [OFPT_ERROR: OFPFMFC_TABLE_FULL
1236 ])
1237 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1238  in_port=4 actions=NORMAL
1239  in_port=5 actions=drop
1240  in_port=6 actions=drop
1241  in_port=7 actions=NORMAL
1242 NXST_FLOW reply:
1243 ])
1244 OVS_VSWITCHD_STOP
1245 AT_CLEANUP
1246
1247 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.2)])
1248 OVS_VSWITCHD_START
1249 # Configure a maximum of 4 flows.
1250 AT_CHECK(
1251   [ovs-vsctl \
1252      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
1253      -- set bridge br0 flow_tables:0=@t0 \
1254    | ${PERL} $srcdir/uuidfilt.pl],
1255   [0], [<0>
1256 ])
1257 # Add 4 flows.
1258 for in_port in 4 3 2 1; do
1259     ovs-ofctl -O OpenFlow12 add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
1260 done
1261 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1262  idle_timeout=10, in_port=1 actions=drop
1263  idle_timeout=20, in_port=2 actions=drop
1264  idle_timeout=30, in_port=3 actions=drop
1265  idle_timeout=40, in_port=4 actions=drop
1266 OFPST_FLOW reply (OF1.2):
1267 ])
1268 # Adding another flow will cause the one that expires soonest to be evicted.
1269 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop])
1270 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1271  idle_timeout=20, in_port=2 actions=drop
1272  idle_timeout=30, in_port=3 actions=drop
1273  idle_timeout=40, in_port=4 actions=drop
1274  in_port=5 actions=drop
1275 OFPST_FLOW reply (OF1.2):
1276 ])
1277 # In Open Flow 1.2 a mod-flow does not ever add a flow and thus
1278 # has no effect on eviction
1279 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=6,actions=drop])
1280 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
1281 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
1282 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1283  idle_timeout=20, in_port=2 actions=drop
1284  idle_timeout=30, in_port=3 actions=output:1
1285  in_port=4 actions=NORMAL
1286  in_port=5 actions=drop
1287 OFPST_FLOW reply (OF1.2):
1288 ])
1289 # Flows with no timeouts at all cannot be evicted.
1290 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=6,actions=drop])
1291 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=7,actions=normal])
1292 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
1293 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1294   [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
1295 ])
1296 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1297  in_port=4 actions=NORMAL
1298  in_port=5 actions=drop
1299  in_port=6 actions=drop
1300  in_port=7 actions=NORMAL
1301 OFPST_FLOW reply (OF1.2):
1302 ])
1303 OVS_VSWITCHD_STOP
1304 AT_CLEANUP
1305
1306 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.0)])
1307 OVS_VSWITCHD_START
1308 # Configure a maximum of 4 flows.
1309 AT_CHECK(
1310   [ovs-vsctl \
1311      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
1312                                    overflow-policy=evict \
1313                                    groups='"NXM_OF_IN_PORT[[]]"' \
1314      -- set bridge br0 flow_tables:0=@t0 \
1315    | ${PERL} $srcdir/uuidfilt.pl],
1316   [0], [<0>
1317 ])
1318 # Add 4 flows.
1319 ovs-ofctl add-flows br0 - <<EOF
1320 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
1321 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
1322 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
1323 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
1324 EOF
1325 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1326  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1327  idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
1328  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1329  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1330 NXST_FLOW reply:
1331 ])
1332 # Adding another flow will cause the one that expires soonest within
1333 # the largest group (those with in_port=1) to be evicted.  In this
1334 # case this is not the same as the one that expires soonest overall
1335 # (which is what makes the test interesting):
1336 AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
1337 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1338  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1339  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1340  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1341  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1342 NXST_FLOW reply:
1343 ])
1344 # Enlarge the flow limit, change the eviction policy back to strictly
1345 # based on expiration, and and add some flows.
1346 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
1347 ovs-ofctl add-flows br0 - <<EOF
1348 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
1349 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
1350 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
1351 EOF
1352 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1353  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1354  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1355  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1356  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
1357  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1358  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1359  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1360 NXST_FLOW reply:
1361 ])
1362 # Adding another flow will cause the one that expires soonest overall
1363 # to be evicted.
1364 AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
1365 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1366  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1367  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1368  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
1369  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1370  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1371  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1372  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1373 NXST_FLOW reply:
1374 ])
1375 # Reducing the flow limit also causes the flows that expire soonest
1376 # overall to be evicted.
1377 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
1378 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1379  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1380  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1381  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1382  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1383 NXST_FLOW reply:
1384 ])
1385 OVS_VSWITCHD_STOP
1386 AT_CLEANUP
1387
1388 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.2)])
1389 OVS_VSWITCHD_START
1390 # Configure a maximum of 4 flows.
1391 AT_CHECK(
1392   [ovs-vsctl \
1393      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
1394                                    overflow-policy=evict \
1395                                    groups='"NXM_OF_IN_PORT[[]]"' \
1396      -- set bridge br0 flow_tables:0=@t0 \
1397    | ${PERL} $srcdir/uuidfilt.pl],
1398   [0], [<0>
1399 ])
1400 # Add 4 flows.
1401 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
1402 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
1403 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
1404 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
1405 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
1406 EOF
1407 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1408  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1409  idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
1410  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1411  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1412 OFPST_FLOW reply (OF1.2):
1413 ])
1414 # Adding another flow will cause the one that expires soonest within
1415 # the largest group (those with in_port=1) to be evicted.  In this
1416 # case this is not the same as the one that expires soonest overall
1417 # (which is what makes the test interesting):
1418 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
1419 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1420  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1421  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1422  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1423  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1424 OFPST_FLOW reply (OF1.2):
1425 ])
1426 # Enlarge the flow limit, change the eviction policy back to strictly
1427 # based on expiration, and and add some flows.
1428 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
1429 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
1430 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
1431 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
1432 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
1433 EOF
1434 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1435  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1436  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1437  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1438  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
1439  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1440  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1441  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1442 OFPST_FLOW reply (OF1.2):
1443 ])
1444 # Adding another flow will cause the one that expires soonest overall
1445 # to be evicted.
1446 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'])
1447 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1448  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1449  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1450  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
1451  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1452  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1453  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1454  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1455 OFPST_FLOW reply (OF1.2):
1456 ])
1457 # Reducing the flow limit also causes the flows that expire soonest
1458 # overall to be evicted.
1459 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
1460 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1461  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1462  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1463  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1464  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1465 OFPST_FLOW reply (OF1.2):
1466 ])
1467 OVS_VSWITCHD_STOP
1468 AT_CLEANUP
1469
1470 AT_SETUP([ofproto - eviction upon table overflow, with modified hard timeout])
1471 OVS_VSWITCHD_START
1472 # Configure a maximum of 4 flows.
1473 AT_CHECK(
1474   [ovs-vsctl \
1475      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
1476      -- set bridge br0 flow_tables:0=@t0 \
1477    | ${PERL} $srcdir/uuidfilt.pl],
1478   [0], [<0>
1479 ])
1480 ovs-appctl time/stop
1481 # Add 4 flows.
1482 for in_port in 4 3 2 1; do
1483     ovs-ofctl add-flow br0 hard_timeout=$((10 + in_port * 3)),in_port=$in_port,actions=drop
1484 done
1485 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1486  hard_timeout=13, in_port=1 actions=drop
1487  hard_timeout=16, in_port=2 actions=drop
1488  hard_timeout=19, in_port=3 actions=drop
1489  hard_timeout=22, in_port=4 actions=drop
1490 NXST_FLOW reply:
1491 ])
1492 # Sleep and modify the one that expires soonest
1493 ovs-appctl time/warp 5000
1494 AT_CHECK([ovs-ofctl mod-flows br0 in_port=1,actions=drop])
1495 # At this point the table would looks like:
1496 #  in_port   seconds to expire
1497 #     1            13
1498 #     2            11
1499 #     3            14
1500 #     4            17
1501 ovs-appctl time/warp 2000
1502 # Adding another flow will cause the one that expires soonest to be evicted.
1503 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
1504 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1505  hard_timeout=13, in_port=1 actions=drop
1506  hard_timeout=19, in_port=3 actions=drop
1507  hard_timeout=22, in_port=4 actions=drop
1508  in_port=5 actions=drop
1509 NXST_FLOW reply:
1510 ])
1511 OVS_VSWITCHD_STOP
1512 AT_CLEANUP
1513
1514 AT_SETUP([ofproto - eviction upon table overflow, with modified idle timeout])
1515 OVS_VSWITCHD_START([add-port br0 p1 -- set interface p1 type=dummy ofport_request=1])
1516 # Configure a maximum of 4 flows.
1517 AT_CHECK(
1518   [ovs-vsctl \
1519      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
1520      -- set bridge br0 flow_tables:0=@t0 \
1521    | ${PERL} $srcdir/uuidfilt.pl],
1522   [0], [<0>
1523 ])
1524 # Add 4 flows.
1525 for in_port in 4 3 2 1; do
1526     ovs-ofctl add-flow br0 idle_timeout=$((10 + in_port * 3)),in_port=$in_port,actions=drop
1527 done
1528 ovs-appctl time/stop
1529 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1530  idle_timeout=13, in_port=1 actions=drop
1531  idle_timeout=16, in_port=2 actions=drop
1532  idle_timeout=19, in_port=3 actions=drop
1533  idle_timeout=22, in_port=4 actions=drop
1534 NXST_FLOW reply:
1535 ])
1536 # Sleep and receive on the flow that expires soonest
1537 ovs-appctl time/warp 5000
1538 AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1)'])
1539 # At this point the table would looks like:
1540 #  in_port   seconds to expire
1541 #     1            13
1542 #     2            11
1543 #     3            14
1544 #     4            17
1545 ovs-appctl time/warp 2000
1546 # Adding another flow will cause the one that expires soonest to be evicted.
1547 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
1548 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1549  idle_timeout=19, in_port=3 actions=drop
1550  idle_timeout=22, in_port=4 actions=drop
1551  in_port=5 actions=drop
1552  n_packets=1, n_bytes=60, idle_timeout=13, in_port=1 actions=drop
1553 NXST_FLOW reply:
1554 ])
1555 OVS_VSWITCHD_STOP
1556 AT_CLEANUP
1557
1558 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.0)])
1559 OVS_VSWITCHD_START
1560 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
1561 check_async () {
1562     printf '\n\n--- check_async %d ---\n\n\n' $1
1563     shift
1564
1565     ovs-appctl -t ovs-ofctl ofctl/barrier
1566     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1567     : > expout
1568
1569     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1570     ovs-ofctl -v packet-out br0 controller controller '0001020304050010203040501234'
1571     if test X"$1" = X"OFPR_ACTION"; then shift;
1572         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
1573 metadata=0,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"
1574     fi
1575
1576     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1577     ovs-ofctl -v packet-out br0 controller 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1578     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1579         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via no_match) data_len=14 (unbuffered)
1580 metadata=0,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"
1581     fi
1582
1583     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1584     ovs-ofctl packet-out br0 controller dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1585     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1586         echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=CONTROLLER (via invalid_ttl) data_len=76 (unbuffered)
1587 udp,metadata=0,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"
1588     fi
1589
1590     # OFPT_PORT_STATUS, OFPPR_ADD
1591     ovs-vsctl add-port br0 test -- set Interface test type=dummy ofport_request=1
1592     if test X"$1" = X"OFPPR_ADD"; then shift;
1593         echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
1594      config:     PORT_DOWN
1595      state:      LINK_DOWN
1596      speed: 0 Mbps now, 0 Mbps max"
1597     fi
1598
1599     # OFPT_PORT_STATUS, OFPPR_DELETE
1600     ovs-vsctl del-port br0 test
1601     if test X"$1" = X"OFPPR_DELETE"; then shift;
1602         echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
1603      config:     PORT_DOWN
1604      state:      LINK_DOWN
1605      speed: 0 Mbps now, 0 Mbps max"
1606     fi
1607
1608     # OFPT_FLOW_REMOVED, OFPRR_DELETE
1609     ovs-ofctl add-flow br0 send_flow_rem,actions=drop
1610     ovs-ofctl --strict del-flows br0 ''
1611     if test X"$1" = X"OFPRR_DELETE"; then shift;
1612         echo >>expout "OFPT_FLOW_REMOVED:  reason=delete"
1613     fi
1614     AT_FAIL_IF([test X"$1" != X])
1615
1616     ovs-appctl -t ovs-ofctl ofctl/barrier
1617     echo >>expout "OFPT_BARRIER_REPLY:"
1618
1619     AT_CHECK(
1620       [[sed '
1621 s/ (xid=0x[0-9a-fA-F]*)//
1622 s/ *duration.*//
1623 s/00:0.$/00:0x/' < monitor.log]],
1624       [0], [expout])
1625 }
1626
1627 # It's a service connection so initially there should be no async messages.
1628 check_async 1
1629
1630 # Set miss_send_len to 128, turning on packet-ins for our service connection.
1631 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
1632 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1633
1634 # Set miss_send_len to 128 and enable invalid_ttl.
1635 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
1636 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1637
1638 # Become slave, which should disable everything except port status.
1639 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
1640 check_async 4 OFPPR_ADD OFPPR_DELETE
1641
1642 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
1643 ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
1644 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1645
1646 # Set controller ID 123.
1647 ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
1648 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1649
1650 # Restore controller ID 0.
1651 ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
1652
1653 # Become master.
1654 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
1655 check_async 7 OFPR_ACTION OFPPR_ADD
1656
1657 ovs-appctl -t ovs-ofctl exit
1658 OVS_VSWITCHD_STOP
1659 AT_CLEANUP
1660
1661 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.2)])
1662 OVS_VSWITCHD_START
1663 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1664 check_async () {
1665     printf '\n\n--- check_async %d ---\n\n\n' $1
1666     INDEX=$1
1667     shift
1668
1669     ovs-appctl -t ovs-ofctl ofctl/barrier
1670     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1671     : > expout
1672
1673     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1674     ovs-ofctl -O OpenFlow12 -v packet-out br0 none controller '0001020304050010203040501234'
1675     if test X"$1" = X"OFPR_ACTION"; then shift;
1676         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1677 metadata=0,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"
1678     fi
1679
1680     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1681     ovs-ofctl -O OpenFlow12 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1682     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1683         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
1684 metadata=0,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"
1685     fi
1686
1687     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1688     ovs-ofctl -O OpenFlow12 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1689     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1690         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
1691 udp,metadata=0,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"
1692     fi
1693
1694     # OFPT_PORT_STATUS, OFPPR_ADD
1695     ovs-vsctl add-port br0 test -- set Interface test type=dummy
1696     if test X"$1" = X"OFPPR_ADD"; then shift;
1697         echo >>expout "OFPT_PORT_STATUS (OF1.2): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1698      config:     PORT_DOWN
1699      state:      LINK_DOWN
1700      speed: 0 Mbps now, 0 Mbps max"
1701     fi
1702
1703     # OFPT_PORT_STATUS, OFPPR_DELETE
1704     ovs-vsctl del-port br0 test
1705     if test X"$1" = X"OFPPR_DELETE"; then shift;
1706         echo >>expout "OFPT_PORT_STATUS (OF1.2): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1707      config:     PORT_DOWN
1708      state:      LINK_DOWN
1709      speed: 0 Mbps now, 0 Mbps max"
1710     fi
1711
1712     # OFPT_FLOW_REMOVED, OFPRR_DELETE
1713     ovs-ofctl -O OpenFlow12 add-flow br0 send_flow_rem,actions=drop
1714     ovs-ofctl -O OpenFlow12 --strict del-flows br0 ''
1715     if test X"$1" = X"OFPRR_DELETE"; then shift;
1716         echo >>expout "OFPT_FLOW_REMOVED (OF1.2):  reason=delete table_id=0"
1717     fi
1718     AT_FAIL_IF([test X"$1" != X])
1719
1720     ovs-appctl -t ovs-ofctl ofctl/barrier
1721     echo >>expout "OFPT_BARRIER_REPLY (OF1.2):"
1722
1723     AT_CHECK(
1724       [[sed '
1725 s/ (xid=0x[0-9a-fA-F]*)//
1726 s/ *duration.*//
1727 s/00:0.$/00:0x/' < monitor.log]],
1728       [0], [expout])
1729 }
1730
1731 # It's a service connection so initially there should be no async messages.
1732 check_async 1
1733
1734 # Set miss_send_len to 128, turning on packet-ins for our service connection.
1735 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
1736 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1737
1738 # Set miss_send_len to 128 and enable invalid_ttl.
1739 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700040080
1740 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1741
1742 # Become slave (OF 1.2), which should disable everything except port status.
1743 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000200000003000000000000000000000001
1744 check_async 4 OFPPR_ADD OFPPR_DELETE
1745
1746 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
1747 ovs-appctl -t ovs-ofctl ofctl/send 03040028000000020000232000000013000000020000000500000005000000020000000200000005
1748 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1749
1750 # Set controller ID 123.
1751 ovs-appctl -t ovs-ofctl ofctl/send 03040018000000030000232000000014000000000000007b
1752 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1753
1754 # Restore controller ID 0.
1755 ovs-appctl -t ovs-ofctl ofctl/send 030400180000000300002320000000140000000000000000
1756
1757 # Become master (OF 1.2).
1758 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000400000002000000000000000000000002
1759 check_async 7 OFPR_ACTION OFPPR_ADD
1760
1761 ovs-appctl -t ovs-ofctl exit
1762 OVS_VSWITCHD_STOP
1763 AT_CLEANUP
1764
1765 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.3)])
1766 OVS_VSWITCHD_START
1767 AT_CHECK([ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile])
1768 check_async () {
1769     printf '\n\n--- check_async %d ---\n\n\n' $1
1770     INDEX=$1
1771     shift
1772
1773     ovs-appctl -t ovs-ofctl ofctl/barrier
1774     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1775     : > expout
1776
1777     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1778     ovs-ofctl -O OpenFlow13 -v packet-out br0 none controller '0001020304050010203040501234'
1779     if test X"$1" = X"OFPR_ACTION"; then shift;
1780         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1781 metadata=0,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"
1782     fi
1783
1784     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1785     ovs-ofctl -O OpenFlow13 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1786     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1787         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
1788 metadata=0,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"
1789     fi
1790
1791     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1792     ovs-ofctl -O OpenFlow13 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1793     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1794         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
1795 udp,metadata=0,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"
1796     fi
1797
1798     # OFPT_PORT_STATUS, OFPPR_ADD
1799     ovs-vsctl add-port br0 test -- set Interface test type=dummy
1800     if test X"$1" = X"OFPPR_ADD"; then shift;
1801         echo >>expout "OFPT_PORT_STATUS (OF1.3): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1802      config:     PORT_DOWN
1803      state:      LINK_DOWN
1804      speed: 0 Mbps now, 0 Mbps max"
1805     fi
1806
1807     # OFPT_PORT_STATUS, OFPPR_DELETE
1808     ovs-vsctl del-port br0 test
1809     if test X"$1" = X"OFPPR_DELETE"; then shift;
1810         echo >>expout "OFPT_PORT_STATUS (OF1.3): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1811      config:     PORT_DOWN
1812      state:      LINK_DOWN
1813      speed: 0 Mbps now, 0 Mbps max"
1814     fi
1815
1816     # OFPT_FLOW_REMOVED, OFPRR_DELETE
1817     ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=drop
1818     ovs-ofctl -O OpenFlow13 --strict del-flows br0 ''
1819     if test X"$1" = X"OFPRR_DELETE"; then shift;
1820         echo >>expout "OFPT_FLOW_REMOVED (OF1.3):  reason=delete table_id=0"
1821     fi
1822
1823     # OFPT_FLOW_REMOVED, OFPRR_GROUP_DELETE
1824     ovs-ofctl -O OpenFlow13 add-group br0 group_id=1234,type=all,bucket=output:10
1825     ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=group:1234
1826     ovs-ofctl -O OpenFlow13 --strict del-groups br0 group_id=1234
1827     if test X"$1" = X"OFPRR_DELETE"; then shift;
1828         echo >>expout "OFPT_FLOW_REMOVED (OF1.3):  reason=gropu_delete table_id=0"
1829     fi
1830
1831     AT_FAIL_IF([test X"$1" != X])
1832
1833     ovs-appctl -t ovs-ofctl ofctl/barrier
1834     echo >>expout "OFPT_BARRIER_REPLY (OF1.3):"
1835
1836     AT_CHECK(
1837       [[sed '
1838 s/ (xid=0x[0-9a-fA-F]*)//
1839 s/ *duration.*//
1840 s/00:0.$/00:0x/' < monitor.log]],
1841       [0], [expout])
1842 }
1843
1844 # It's a service connection so initially there should be no async messages.
1845 check_async 1
1846
1847 # Set miss_send_len to 128, turning on packet-ins for our service connection.
1848 ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
1849 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1850
1851 # Become slave (OF 1.3), which should disable everything except port status.
1852 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000200000003000000000000000000000001
1853 check_async 3 OFPPR_ADD OFPPR_DELETE
1854
1855 # Use OF 1.3 OFPT_SET_ASYNC to enable a patchwork of asynchronous messages.
1856 ovs-appctl -t ovs-ofctl ofctl/send 041c002000000002000000020000000500000005000000020000000200000005
1857 check_async 4 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1858
1859 # Set controller ID 123.
1860 ovs-appctl -t ovs-ofctl ofctl/send 04040018000000030000232000000014000000000000007b
1861 check_async 5 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1862
1863 # Restore controller ID 0.
1864 ovs-appctl -t ovs-ofctl ofctl/send 040400180000000300002320000000140000000000000000
1865
1866 # Become master (OF 1.3).
1867 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000400000002000000000000000000000002
1868 check_async 6 OFPR_ACTION OFPPR_ADD
1869
1870 ovs-appctl -t ovs-ofctl exit
1871 OVS_VSWITCHD_STOP
1872 AT_CLEANUP
1873
1874 dnl This test checks that the role request/response messaging works
1875 dnl and that generation_id is handled properly.
1876 AT_SETUP([ofproto - controller role (OpenFlow 1.2)])
1877 OVS_VSWITCHD_START
1878 ON_EXIT([kill `cat c1.pid c2.pid`])
1879
1880 # Start two ovs-ofctl controller processes.
1881 AT_CAPTURE_FILE([monitor1.log])
1882 AT_CAPTURE_FILE([expout1])
1883 AT_CAPTURE_FILE([experr1])
1884 AT_CAPTURE_FILE([monitor2.log])
1885 AT_CAPTURE_FILE([expout2])
1886 AT_CAPTURE_FILE([experr2])
1887 for i in 1 2; do
1888      AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile=`pwd`/c$i.pid --unixctl=`pwd`/c$i])
1889     ovs-appctl -t `pwd`/c$i ofctl/barrier
1890     ovs-appctl -t `pwd`/c$i ofctl/set-output-file monitor$i.log
1891     : > expout$i
1892     : > experr$i
1893
1894     # find out current role
1895     ovs-appctl -t `pwd`/c$i ofctl/send 031800180000000200000000000000000000000000000000
1896     echo >>experr$i "send: OFPT_ROLE_REQUEST (OF1.2): role=nochange"
1897     echo >>expout$i "OFPT_ROLE_REPLY (OF1.2): role=equal"
1898 done
1899
1900 # controller 1: Become slave (generation_id is initially undefined, so
1901 # 2^63+2 should not be stale)
1902 ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000300000003000000008000000000000002
1903 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=slave generation_id=9223372036854775810"
1904 echo >>expout1 "OFPT_ROLE_REPLY (OF1.2): role=slave generation_id=9223372036854775810"
1905
1906 # controller 2: Become master.
1907 ovs-appctl -t `pwd`/c2 ofctl/send 031800180000000300000002000000008000000000000003
1908 echo >>experr2 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=9223372036854775811"
1909 echo >>expout2 "OFPT_ROLE_REPLY (OF1.2): role=master generation_id=9223372036854775811"
1910
1911 # controller 1: Try to become the master using a stale generation ID
1912 ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000400000002000000000000000000000003
1913 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=3"
1914 echo >>expout1 "OFPT_ERROR (OF1.2): OFPRRFC_STALE"
1915 echo >>expout1 "OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=3"
1916
1917 # controller 1: Become master using a valid generation ID
1918 ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000500000002000000000000000000000001
1919 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=1"
1920 echo >>expout1 "OFPT_ROLE_REPLY (OF1.2): role=master generation_id=1"
1921
1922 for i in 1 2; do
1923     ovs-appctl -t `pwd`/c$i ofctl/barrier
1924     echo >>expout$i "OFPT_BARRIER_REPLY (OF1.2):"
1925 done
1926
1927 # Check output.
1928 for i in 1 2; do
1929     cp expout$i expout
1930     AT_CHECK([grep -v '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
1931     cp experr$i expout
1932     AT_CHECK([grep '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
1933 done
1934 OVS_VSWITCHD_STOP
1935 AT_CLEANUP
1936
1937 dnl This test checks that the role request/response messaging works,
1938 dnl that generation_id is handled properly, and that role status update
1939 dnl messages are sent when a controller's role gets changed from master
1940 dnl to slave.
1941 AT_SETUP([ofproto - controller role (OpenFlow 1.4)])
1942 OVS_VSWITCHD_START
1943 ON_EXIT([kill `cat c1.pid c2.pid`])
1944
1945 # Start two ovs-ofctl controller processes.
1946 AT_CAPTURE_FILE([monitor1.log])
1947 AT_CAPTURE_FILE([expout1])
1948 AT_CAPTURE_FILE([experr1])
1949 AT_CAPTURE_FILE([monitor2.log])
1950 AT_CAPTURE_FILE([expout2])
1951 AT_CAPTURE_FILE([experr2])
1952 for i in 1 2; do
1953      AT_CHECK([ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile=`pwd`/c$i.pid --unixctl=`pwd`/c$i])
1954     ovs-appctl -t `pwd`/c$i ofctl/barrier
1955     ovs-appctl -t `pwd`/c$i ofctl/set-output-file monitor$i.log
1956     : > expout$i
1957     : > experr$i
1958
1959     # find out current role
1960     ovs-appctl -t `pwd`/c$i ofctl/send 051800180000000200000000000000000000000000000000
1961     echo >>experr$i "send: OFPT_ROLE_REQUEST (OF1.4): role=nochange"
1962     echo >>expout$i "OFPT_ROLE_REPLY (OF1.4): role=equal"
1963 done
1964
1965 # controller 1: Become slave (generation_id is initially undefined, so
1966 # 2^63+2 should not be stale)
1967 ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000300000003000000008000000000000002
1968 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=slave generation_id=9223372036854775810"
1969 echo >>expout1 "OFPT_ROLE_REPLY (OF1.4): role=slave generation_id=9223372036854775810"
1970
1971 # controller 2: Become master.
1972 ovs-appctl -t `pwd`/c2 ofctl/send 051800180000000300000002000000008000000000000003
1973 echo >>experr2 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=9223372036854775811"
1974 echo >>expout2 "OFPT_ROLE_REPLY (OF1.4): role=master generation_id=9223372036854775811"
1975
1976 # controller 1: Try to become the master using a stale generation ID
1977 ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000400000002000000000000000000000003
1978 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=3"
1979 echo >>expout1 "OFPT_ERROR (OF1.4): OFPRRFC_STALE"
1980 echo >>expout1 "OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=3"
1981
1982 # controller 1: Become master using a valid generation ID
1983 ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000500000002000000000000000000000001
1984 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=1"
1985 echo >>expout1 "OFPT_ROLE_REPLY (OF1.4): role=master generation_id=1"
1986 echo >>expout2 "OFPT_ROLE_STATUS (OF1.4): role=slave generation_id=1 reason=master_request"
1987
1988 for i in 1 2; do
1989     ovs-appctl -t `pwd`/c$i ofctl/barrier
1990     echo >>expout$i "OFPT_BARRIER_REPLY (OF1.4):"
1991 done
1992
1993 # Check output.
1994 for i in 1 2; do
1995     cp expout$i expout
1996     AT_CHECK([grep -v '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
1997     cp experr$i expout
1998     AT_CHECK([grep '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
1999 done
2000 OVS_VSWITCHD_STOP
2001 AT_CLEANUP
2002
2003 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
2004 dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
2005 dnl controllers despite the spec) as meaning a packet that was generated
2006 dnl by the controller.
2007 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.0)])
2008 OVS_VSWITCHD_START
2009 ADD_OF_PORTS([br0], [1])
2010
2011 # Start a monitor listening for packet-ins.
2012 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
2013 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
2014 ovs-appctl -t ovs-ofctl ofctl/barrier
2015 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2016 AT_CAPTURE_FILE([monitor.log])
2017
2018 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
2019 AT_CHECK([ovs-ofctl packet-out br0 none controller,1 '0001020304050010203040501234'])
2020 AT_CHECK([ovs-ofctl packet-out br0 controller controller,1 '0001020304050010203040505678'])
2021
2022 # Stop the monitor and check its output.
2023 ovs-appctl -t ovs-ofctl ofctl/barrier
2024 ovs-appctl -t ovs-ofctl exit
2025
2026 ovs-ofctl dump-ports br0
2027
2028 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2029 OFPT_PACKET_IN: total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
2030 metadata=0,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
2031 OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
2032 metadata=0,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
2033 OFPT_BARRIER_REPLY:
2034 ])
2035
2036 OVS_VSWITCHD_STOP
2037 AT_CLEANUP
2038
2039 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
2040 dnl specified by OpenFlow 1.2) and OFPP_CONTROLLER (used by some
2041 dnl controllers despite the spec) as meaning a packet that was generated
2042 dnl by the controller.
2043 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.2)])
2044 OVS_VSWITCHD_START
2045
2046 # Start a monitor listening for packet-ins.
2047 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
2048 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
2049 ovs-appctl -t ovs-ofctl ofctl/barrier
2050 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2051 AT_CAPTURE_FILE([monitor.log])
2052
2053 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
2054 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none controller '0001020304050010203040501234'])
2055 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 4294967293 controller '0001020304050010203040505678'])
2056
2057 # Stop the monitor and check its output.
2058 ovs-appctl -t ovs-ofctl ofctl/barrier
2059 ovs-appctl -t ovs-ofctl exit
2060
2061 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2062 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
2063 metadata=0,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
2064 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
2065 metadata=0,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
2066 OFPT_BARRIER_REPLY (OF1.2):
2067 ])
2068
2069 OVS_VSWITCHD_STOP
2070 AT_CLEANUP
2071
2072 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
2073 dnl specified by OpenFlow 1.1) and OFPP_CONTROLLER (used by some
2074 dnl controllers despite the spec) as meaning a packet that was generated
2075 dnl by the controller.
2076 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.1)])
2077 OVS_VSWITCHD_START
2078
2079 # Start a monitor listening for packet-ins.
2080 AT_CHECK([ovs-ofctl -O OpenFlow11 monitor br0 --detach --no-chdir --pidfile])
2081 ovs-appctl -t ovs-ofctl ofctl/send 0209000c0123456700000080
2082 ovs-appctl -t ovs-ofctl ofctl/barrier
2083 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2084 AT_CAPTURE_FILE([monitor.log])
2085
2086 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
2087 AT_CHECK([ovs-ofctl -O OpenFlow11 packet-out br0 none controller '0001020304050010203040501234'])
2088 AT_CHECK([ovs-ofctl -O OpenFlow11 packet-out br0 4294967293 controller '0001020304050010203040505678'])
2089
2090 # Stop the monitor and check its output.
2091 ovs-appctl -t ovs-ofctl ofctl/barrier
2092 ovs-appctl -t ovs-ofctl exit
2093
2094 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2095 OFPT_PACKET_IN (OF1.1): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
2096 metadata=0,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
2097 OFPT_PACKET_IN (OF1.1): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
2098 metadata=0,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
2099 OFPT_BARRIER_REPLY (OF1.1):
2100 ])
2101
2102 OVS_VSWITCHD_STOP
2103 AT_CLEANUP
2104
2105 dnl This test checks that metadata is encoded in packet_in structures,
2106 dnl supported by NXAST.
2107 AT_SETUP([ofproto - packet-out with metadata (NXM)])
2108 OVS_VSWITCHD_START
2109
2110 # Start a monitor listening for packet-ins.
2111 AT_CHECK([ovs-ofctl -P nxm monitor br0 --detach --no-chdir --pidfile])
2112 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
2113 ovs-appctl -t ovs-ofctl ofctl/barrier
2114 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2115 AT_CAPTURE_FILE([monitor.log])
2116
2117 # Send a packet-out with a load action to set some metadata, and forward to controller
2118 AT_CHECK([ovs-ofctl packet-out br0 controller 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), load(0xaa->NXM_NX_PKT_MARK[[]]), controller' '0001020304050010203040501234'])
2119
2120 # Stop the monitor and check its output.
2121 ovs-appctl -t ovs-ofctl ofctl/barrier
2122 ovs-appctl -t ovs-ofctl exit
2123
2124 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2125 NXT_PACKET_IN: total_len=14 in_port=CONTROLLER metadata=0xfafafafa5a5a5a5a pkt_mark=0xaa (via action) data_len=14 (unbuffered)
2126 metadata=0,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
2127 OFPT_BARRIER_REPLY:
2128 ])
2129
2130 OVS_VSWITCHD_STOP
2131 AT_CLEANUP
2132
2133 dnl This test checks that metadata is encoded in packet_in structures,
2134 dnl supported by NXAST.
2135 AT_SETUP([ofproto - packet-out with metadata (OpenFlow 1.2)])
2136 OVS_VSWITCHD_START
2137
2138 # Start a monitor listening for packet-ins.
2139 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
2140 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
2141 ovs-appctl -t ovs-ofctl ofctl/barrier
2142 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2143 AT_CAPTURE_FILE([monitor.log])
2144
2145 # Send a packet-out with a set-field action to set some metadata, and forward to controller
2146 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none 'set_field:0xfafafafa5a5a5a5a->metadata, controller' '0001020304050010203040501234'])
2147
2148 # Stop the monitor and check its output.
2149 ovs-appctl -t ovs-ofctl ofctl/barrier
2150 ovs-appctl -t ovs-ofctl exit
2151
2152 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2153 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY metadata=0xfafafafa5a5a5a5a (via action) data_len=14 (unbuffered)
2154 metadata=0,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
2155 OFPT_BARRIER_REPLY (OF1.2):
2156 ])
2157
2158 OVS_VSWITCHD_STOP
2159 AT_CLEANUP
2160
2161 dnl This test checks that tunnel metadata is encoded in packet_in structures.
2162 AT_SETUP([ofproto - packet-out with tunnel metadata (OpenFlow 1.2)])
2163 OVS_VSWITCHD_START
2164
2165 # Start a monitor listening for packet-ins.
2166 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
2167 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
2168 ovs-appctl -t ovs-ofctl ofctl/barrier
2169 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2170 AT_CAPTURE_FILE([monitor.log])
2171
2172 # Send a packet-out with set field actions to set some tunnel metadata, and forward to controller
2173 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'])
2174
2175 # Stop the monitor and check its output.
2176 ovs-appctl -t ovs-ofctl ofctl/barrier
2177 ovs-appctl -t ovs-ofctl exit
2178
2179 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2180 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)
2181 metadata=0,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
2182 OFPT_BARRIER_REPLY (OF1.2):
2183 ])
2184
2185 OVS_VSWITCHD_STOP
2186 AT_CLEANUP
2187
2188 m4_divert_push([PREPARE_TESTS])
2189 # Sorts groups of lines that start with a space, without moving them
2190 # past the nearest line that does not start with a space.
2191 multiline_sort () {
2192     ${PERL} -e '
2193         use warnings;
2194         use strict;
2195         my @buffer = ();
2196         while (<STDIN>) {
2197             if (/^ /) {
2198                 push(@buffer, $_);
2199             } else {
2200                 print $_ foreach sort(@buffer);
2201                 print $_;
2202                 @buffer = ();
2203             }
2204         }
2205         print $_ foreach sort(@buffer);
2206 '
2207 }
2208 m4_divert_pop([PREPARE_TESTS])
2209
2210 AT_SETUP([ofproto - flow monitoring])
2211 AT_KEYWORDS([monitor])
2212 OVS_VSWITCHD_START
2213
2214 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
2215
2216 # Start a monitor watching the flow table and check the initial reply.
2217 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
2218 AT_CAPTURE_FILE([monitor.log])
2219 ovs-appctl -t ovs-ofctl ofctl/barrier
2220 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
2221   [NXST_FLOW_MONITOR reply:
2222  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
2223 OFPT_BARRIER_REPLY:
2224 ])
2225
2226 # Add, delete, and modify some flows and check the updates.
2227 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2228 ovs-ofctl add-flow br0 in_port=0,dl_vlan=124,actions=output:2
2229 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:5
2230 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=0,actions=output:6
2231 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=1,actions=output:7
2232 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:8
2233 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=0,actions=output:9
2234 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=1,actions=output:10
2235 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,actions=output:11
2236 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=0,actions=output:12
2237 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=1,actions=output:13
2238 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,actions=output:14
2239 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:15
2240 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:16
2241 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:17
2242 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:18
2243 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:19
2244 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:20
2245 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=0,actions=output:21
2246 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=1,actions=output:22
2247 ovs-ofctl add-flow br0 in_port=0,actions=output:23
2248 ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:3
2249 ovs-ofctl mod-flows br0 cookie=5,dl_vlan=123,actions=output:3
2250 ovs-ofctl del-flows br0 dl_vlan=123
2251 ovs-ofctl del-flows br0
2252 ovs-appctl -t ovs-ofctl ofctl/barrier
2253 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | multiline_sort], [0],
2254 [NXST_FLOW_MONITOR reply (xid=0x0):
2255  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
2256 NXST_FLOW_MONITOR reply (xid=0x0):
2257  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:5
2258 NXST_FLOW_MONITOR reply (xid=0x0):
2259  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:6
2260 NXST_FLOW_MONITOR reply (xid=0x0):
2261  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:7
2262 NXST_FLOW_MONITOR reply (xid=0x0):
2263  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:8
2264 NXST_FLOW_MONITOR reply (xid=0x0):
2265  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:9
2266 NXST_FLOW_MONITOR reply (xid=0x0):
2267  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:10
2268 NXST_FLOW_MONITOR reply (xid=0x0):
2269  event=ADDED table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
2270 NXST_FLOW_MONITOR reply (xid=0x0):
2271  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
2272 NXST_FLOW_MONITOR reply (xid=0x0):
2273  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
2274 NXST_FLOW_MONITOR reply (xid=0x0):
2275  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
2276 NXST_FLOW_MONITOR reply (xid=0x0):
2277  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:15
2278 NXST_FLOW_MONITOR reply (xid=0x0):
2279  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:16
2280 NXST_FLOW_MONITOR reply (xid=0x0):
2281  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:17
2282 NXST_FLOW_MONITOR reply (xid=0x0):
2283  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
2284 NXST_FLOW_MONITOR reply (xid=0x0):
2285  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
2286 NXST_FLOW_MONITOR reply (xid=0x0):
2287  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
2288 NXST_FLOW_MONITOR reply (xid=0x0):
2289  event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
2290 NXST_FLOW_MONITOR reply (xid=0x0):
2291  event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
2292 NXST_FLOW_MONITOR reply (xid=0x0):
2293  event=ADDED table=0 cookie=0 in_port=0 actions=output:23
2294 NXST_FLOW_MONITOR reply (xid=0x0):
2295  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:3
2296  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
2297  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
2298 NXST_FLOW_MONITOR reply (xid=0x0):
2299  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
2300  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
2301  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
2302 NXST_FLOW_MONITOR reply (xid=0x0):
2303  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
2304  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
2305  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
2306 NXST_FLOW_MONITOR reply (xid=0x0):
2307  event=DELETED reason=delete table=0 cookie=0 in_port=0 actions=output:23
2308  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
2309  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
2310  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
2311  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
2312  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
2313  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
2314  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
2315  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
2316  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
2317  event=DELETED reason=delete table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
2318 OFPT_BARRIER_REPLY:
2319 ])
2320
2321 # Check that our own changes are reported as full updates.
2322 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2323 ovs-ofctl add-flow br0 in_port=1,actions=output:2
2324 ovs-ofctl add-flow br0 in_port=2,actions=output:1
2325 ovs-appctl -t ovs-ofctl ofctl/barrier
2326 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
2327 ovs-appctl -t ovs-ofctl ofctl/barrier
2328 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
2329 ])
2330 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | multiline_sort], [0],
2331 [NXST_FLOW_MONITOR reply (xid=0x0):
2332  event=ADDED table=0 cookie=0 in_port=1 actions=output:2
2333 NXST_FLOW_MONITOR reply (xid=0x0):
2334  event=ADDED table=0 cookie=0 in_port=2 actions=output:1
2335 OFPT_BARRIER_REPLY:
2336 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
2337 NXST_FLOW_MONITOR reply (xid=0x0):
2338  event=DELETED reason=delete table=0 cookie=0 in_port=1 actions=output:2
2339  event=DELETED reason=delete table=0 cookie=0 in_port=2 actions=output:1
2340 OFPT_BARRIER_REPLY:
2341 ])
2342
2343 ovs-appctl -t ovs-ofctl exit
2344 OVS_VSWITCHD_STOP
2345 AT_CLEANUP
2346
2347 AT_SETUP([ofproto - flow monitoring with !own])
2348 AT_KEYWORDS([monitor])
2349 OVS_VSWITCHD_START
2350
2351 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
2352
2353 # Start a monitor watching the flow table and check the initial reply.
2354 ovs-ofctl monitor br0 watch:\!own --detach --no-chdir --pidfile >monitor.log 2>&1
2355 AT_CAPTURE_FILE([monitor.log])
2356 ovs-appctl -t ovs-ofctl ofctl/barrier
2357 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
2358   [NXST_FLOW_MONITOR reply:
2359  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
2360 OFPT_BARRIER_REPLY:
2361 ])
2362
2363 # Check that our own changes are reported as abbreviations.
2364 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2365 ovs-ofctl add-flow br0 in_port=1,actions=output:2
2366 ovs-ofctl add-flow br0 in_port=2,actions=output:1
2367 ovs-appctl -t ovs-ofctl ofctl/barrier
2368 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
2369 ovs-appctl -t ovs-ofctl ofctl/barrier
2370 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
2371 ])
2372 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
2373 [NXST_FLOW_MONITOR reply (xid=0x0):
2374  event=ADDED table=0 cookie=0 in_port=1 actions=output:2
2375 NXST_FLOW_MONITOR reply (xid=0x0):
2376  event=ADDED table=0 cookie=0 in_port=2 actions=output:1
2377 OFPT_BARRIER_REPLY:
2378 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
2379 NXST_FLOW_MONITOR reply (xid=0x0):
2380  event=ABBREV xid=0x12345678
2381 OFPT_BARRIER_REPLY:
2382 ])
2383
2384 ovs-appctl -t ovs-ofctl exit
2385 OVS_VSWITCHD_STOP
2386 AT_CLEANUP
2387
2388 AT_SETUP([ofproto - flow monitoring with out_port])
2389 AT_KEYWORDS([monitor])
2390 OVS_VSWITCHD_START
2391
2392 ovs-ofctl add-flow br0 in_port=0,dl_vlan=121,actions=output:1
2393 ovs-ofctl add-flow br0 in_port=0,dl_vlan=122,actions=output:1
2394 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:2
2395
2396 # Start a monitor watching the flow table and check the initial reply.
2397 ovs-ofctl monitor br0 watch:out_port=2 --detach --no-chdir --pidfile >monitor.log 2>&1
2398 AT_CAPTURE_FILE([monitor.log])
2399 ovs-appctl -t ovs-ofctl ofctl/barrier
2400 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
2401   [NXST_FLOW_MONITOR reply:
2402  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:2
2403 OFPT_BARRIER_REPLY:
2404 ])
2405
2406 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2407
2408 # Add, modify flows and check the updates.
2409 ovs-ofctl mod-flows br0 dl_vlan=121,actions=drop
2410 ovs-ofctl mod-flows br0 dl_vlan=122,actions=output:1,output:2
2411 ovs-appctl -t ovs-ofctl ofctl/barrier
2412
2413 ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:1,output:2
2414 ovs-appctl -t ovs-ofctl ofctl/barrier
2415
2416 ovs-ofctl mod-flows br0 dl_vlan=122,actions=output:1
2417 ovs-appctl -t ovs-ofctl ofctl/barrier
2418 ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:2
2419 ovs-appctl -t ovs-ofctl ofctl/barrier
2420
2421 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
2422 [NXST_FLOW_MONITOR reply (xid=0x0):
2423  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=122 actions=output:1,output:2
2424 OFPT_BARRIER_REPLY:
2425 NXST_FLOW_MONITOR reply (xid=0x0):
2426  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1,output:2
2427 OFPT_BARRIER_REPLY:
2428 NXST_FLOW_MONITOR reply (xid=0x0):
2429  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=122 actions=output:1
2430 OFPT_BARRIER_REPLY:
2431 NXST_FLOW_MONITOR reply (xid=0x0):
2432  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:2
2433 OFPT_BARRIER_REPLY:
2434 ])
2435
2436 ovs-appctl -t ovs-ofctl exit
2437 OVS_VSWITCHD_STOP
2438 AT_CLEANUP
2439
2440 AT_SETUP([ofproto - flow monitoring pause and resume])
2441 AT_KEYWORDS([monitor])
2442
2443 # The maximum socket receive buffer size is important for this test, which
2444 # tests behavior when the receive buffer overflows.
2445 if test -e /proc/sys/net/core/rmem_max; then
2446     # Linux
2447     rmem_max=`cat /proc/sys/net/core/rmem_max`
2448 elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
2449     : # FreeBSD, NetBSD
2450 else
2451     # Don't know how to get maximum socket receive buffer on this OS
2452     AT_SKIP_IF([:])
2453 fi
2454 # Calculate the total amount of queuing: rmem_max in the kernel, 128 kB
2455 # in ofproto sending userspace (see ofmonitor_flush() in connmgr.c).
2456 queue_size=`expr $rmem_max + 128 \* 1024`
2457 echo rmem_max=$rmem_max queue_size=$queue_size
2458
2459 # If there's too much queuing skip the test to avoid timing out.
2460 AT_SKIP_IF([test $rmem_max -gt 1048576])
2461
2462 # Each flow update message takes up at least 48 bytes of space in queues
2463 # and in practice more than that.
2464 n_msgs=`expr $queue_size / 48`
2465 echo n_msgs=$n_msgs
2466
2467 OVS_VSWITCHD_START
2468
2469 # Start a monitor watching the flow table, then make it block.
2470 ON_EXIT([kill `cat ovs-ofctl.pid`])
2471 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
2472 AT_CAPTURE_FILE([monitor.log])
2473 ovs-appctl -t ovs-ofctl ofctl/block
2474
2475 # Add $n_msgs flows.
2476 (echo "in_port=2,actions=output:2"
2477 ${PERL} -e '
2478     for ($i = 0; $i < '$n_msgs'; $i++) {
2479         print "cookie=1,reg1=$i,actions=drop\n";
2480     }
2481 ') > flows.txt
2482 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
2483 # Check that multipart flow dumps work properly:
2484 AT_CHECK([ovs-ofctl diff-flows br0 flows.txt])
2485 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,cookie=3,actions=drop])
2486 AT_CHECK([ovs-ofctl mod-flows br0 in_port=2,cookie=2,actions=output:2])
2487 AT_CHECK([ovs-ofctl del-flows br0 cookie=1/-1])
2488
2489 ovs-appctl -t ovs-ofctl ofctl/unblock
2490
2491 # Wait for the connection resumed.
2492 # A barrier doesn't work for this purpose.
2493 #    https://www.mail-archive.com/dev@openvswitch.org/msg27013.html
2494 #    https://www.mail-archive.com/dev@openvswitch.org/msg27675.html
2495 OVS_WAIT_UNTIL([grep NXT_FLOW_MONITOR_RESUMED monitor.log])
2496
2497 ovs-appctl -t ovs-ofctl exit
2498
2499 # Check that the flow monitor reported the same number of flows
2500 # added and deleted, but fewer than we actually added and deleted.
2501 adds=`grep -c 'ADDED.*reg1=' monitor.log`
2502 deletes=`grep -c 'DELETED.*reg1=' monitor.log`
2503 echo adds=$adds deletes=$deletes
2504 AT_CHECK([test $adds -gt 100 && test $adds -lt $n_msgs])
2505 AT_CHECK([test $adds = $deletes])
2506
2507 # Check that the flow monitor reported everything in the expected order:
2508 #
2509 #     event=ADDED table=0 cookie=0x1 reg1=0x22
2510 # ...
2511 #    NXT_FLOW_MONITOR_PAUSED:
2512 # ...
2513 #     event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
2514 # ...
2515 #     event=ADDED table=0 cookie=0x3 in_port=1
2516 #     event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
2517 #    NXT_FLOW_MONITOR_RESUMED:
2518 #
2519 # except that, between the PAUSED and RESUMED, the order of the ADDED
2520 # and MODIFIED lines lines depends on hash order, that is, it varies
2521 # as we change the hash function or change architecture.  Therefore,
2522 # we use a couple of tests below to accept both orders.
2523 AT_CHECK([ofctl_strip < monitor.log | sed -n -e '
2524 /reg1=0x22$/p
2525 /cookie=0x[[23]]/p
2526 /NXT_FLOW_MONITOR_PAUSED:/p
2527 /NXT_FLOW_MONITOR_RESUMED:/p
2528 ' > monitor.log.subset])
2529 AT_CHECK([grep -v MODIFIED monitor.log.subset], [0], [dnl
2530  event=ADDED table=0 cookie=0x1 reg1=0x22
2531 NXT_FLOW_MONITOR_PAUSED:
2532  event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
2533  event=ADDED table=0 cookie=0x3 in_port=1
2534 NXT_FLOW_MONITOR_RESUMED:
2535 ])
2536 AT_CHECK([grep -v ADDED monitor.log.subset], [0], [dnl
2537 NXT_FLOW_MONITOR_PAUSED:
2538  event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
2539  event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
2540 NXT_FLOW_MONITOR_RESUMED:
2541 ])
2542
2543 OVS_VSWITCHD_STOP
2544 AT_CLEANUP
2545
2546 AT_SETUP([ofproto - event filtering (OpenFlow 1.3)])
2547 AT_KEYWORDS([monitor])
2548 OVS_VSWITCHD_START
2549
2550 # Start a monitor, use the required protocol version
2551 ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2552 AT_CAPTURE_FILE([monitor.log])
2553
2554 # Send an OpenFlow13 message (04), OFPT_GET_ASYNC_REQUEST (1a), length (8), xid (0a)
2555 ovs-appctl -t ovs-ofctl ofctl/send 041a00080000000a
2556 ovs-appctl -t ovs-ofctl ofctl/barrier
2557
2558 # Check default setting
2559 read -r -d '' expected <<'EOF'
2560 EOF
2561
2562 AT_CHECK([ofctl_strip < monitor.log], [], [dnl
2563 send: OFPT_GET_ASYNC_REQUEST (OF1.3):
2564 OFPT_GET_ASYNC_REPLY (OF1.3):
2565  master:
2566        PACKET_IN: no_match action
2567      PORT_STATUS: add delete modify
2568     FLOW_REMOVED: idle hard delete
2569
2570  slave:
2571        PACKET_IN: (off)
2572      PORT_STATUS: add delete modify
2573     FLOW_REMOVED: (off)
2574 OFPT_BARRIER_REPLY (OF1.3):
2575 ])
2576
2577 OVS_VSWITCHD_STOP
2578 AT_CLEANUP
2579
2580 AT_SETUP([ofproto - ofport_request])
2581 OVS_VSWITCHD_START
2582 ADD_OF_PORTS([br0], [1], [2], [3])
2583
2584 set_and_check_specific_ofports () {
2585     ovs-vsctl set Interface p1 ofport_request="$1" -- \
2586               set Interface p2 ofport_request="$2" -- \
2587               set Interface p3 ofport_request="$3"
2588     ofports=`ovs-vsctl get Interface p1 ofport -- \
2589                        get Interface p2 ofport -- \
2590                        get Interface p3 ofport`
2591     AT_CHECK_UNQUOTED([echo $ofports], [0], [$1 $2 $3
2592 ])
2593 }
2594 for pre in      '1 2 3' '1 3 2' '2 1 3' '2 3 1' '3 1 2' '3 2 1'; do
2595     for post in '1 2 3' '1 3 2' '2 1 3' '2 3 1' '3 1 2' '3 2 1'; do
2596         echo -----------------------------------------------------------
2597         echo "Check changing port numbers from $pre to $post"
2598         set_and_check_specific_ofports $pre
2599         set_and_check_specific_ofports $post
2600     done
2601 done
2602
2603 ovs-vsctl del-port p3
2604
2605 set_and_check_poorly_specified_ofports () {
2606     ovs-vsctl set Interface p1 ofport_request="$1" -- \
2607               set Interface p2 ofport_request="$2"
2608     p1=`ovs-vsctl get Interface p1 ofport`
2609     p2=`ovs-vsctl get Interface p2 ofport`
2610     echo $p1 $p2
2611
2612     AT_CHECK([test "$p1" != "$p2"])
2613     if test "$1" = "$2" && test "$1" != '[[]]'; then
2614         # One port number must be the requested one.
2615         AT_CHECK([test "$p1" = "$1" || test "$p2" = "$1"])
2616         # The other port number must be different (already tested above).
2617     else
2618         AT_CHECK([test "$1" = '[[]]' || test "$p1" == "$1"])
2619         AT_CHECK([test "$2" = '[[]]' || test "$p2" == "$2"])
2620     fi
2621 }
2622 for pre in      '1 2' '[[]] 2' '1 [[]]' '[[]] [[]]' '2 1' '[[]] 1' '2 [[]]' \
2623                 '1 1' '2 2'; do
2624     for post in '1 2' '[[]] 2' '1 [[]]' '[[]] [[]]' '2 1' '[[]] 1' '2 [[]]' \
2625                 '1 1' '2 2'; do
2626         echo -----------------------------------------------------------
2627         echo "Check changing port numbers from $pre to $post"
2628         set_and_check_poorly_specified_ofports $pre
2629         set_and_check_poorly_specified_ofports $post
2630     done
2631 done
2632 OVS_VSWITCHD_STOP
2633 AT_CLEANUP
2634
2635
2636 AT_SETUP([ofproto - bundles, open (OpenFlow 1.4)])
2637 AT_KEYWORDS([monitor])
2638 OVS_VSWITCHD_START
2639
2640 # Start a monitor, use the required protocol version
2641 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2642 AT_CAPTURE_FILE([monitor.log])
2643
2644 # Send an OpenFlow14 message (05), OFPT_BUNDLE_CONTROL (21), length (10), xid (0a)
2645 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2646 ovs-appctl -t ovs-ofctl ofctl/barrier
2647 ovs-appctl -t ovs-ofctl exit
2648
2649 AT_CHECK([ofctl_strip < monitor.log], [], [dnl
2650 send: OFPT_BUNDLE_CONTROL (OF1.4):
2651  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2652 OFPT_BUNDLE_CONTROL (OF1.4):
2653  bundle_id=0x1 type=OPEN_REPLY flags=0
2654 OFPT_BARRIER_REPLY (OF1.4):
2655 ])
2656
2657 OVS_VSWITCHD_STOP
2658 AT_CLEANUP
2659
2660 AT_SETUP([ofproto - bundles, double open (OpenFlow 1.4)])
2661 AT_KEYWORDS([monitor])
2662 OVS_VSWITCHD_START
2663
2664 # Start a monitor, use the required protocol version
2665 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2666 AT_CAPTURE_FILE([monitor.log])
2667
2668 # Send twice an OpenFlow14 message (05), OFPT_BUNDLE_CONTROL (21), length (10), xid (0a)
2669 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2670 ovs-appctl -t ovs-ofctl ofctl/barrier
2671 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2672 ovs-appctl -t ovs-ofctl ofctl/barrier
2673 ovs-appctl -t ovs-ofctl exit
2674
2675 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2676 send: OFPT_BUNDLE_CONTROL (OF1.4):
2677  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2678 OFPT_BUNDLE_CONTROL (OF1.4):
2679  bundle_id=0x1 type=OPEN_REPLY flags=0
2680 OFPT_BARRIER_REPLY (OF1.4):
2681 send: OFPT_BUNDLE_CONTROL (OF1.4):
2682  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2683 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
2684 OFPT_BUNDLE_CONTROL (OF1.4):
2685  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2686 OFPT_BARRIER_REPLY (OF1.4):
2687 ])
2688
2689 OVS_VSWITCHD_STOP
2690 AT_CLEANUP
2691
2692 AT_SETUP([ofproto - bundle close without open (OpenFlow 1.4)])
2693 AT_KEYWORDS([monitor])
2694 OVS_VSWITCHD_START
2695
2696 # Start a monitor, use the required protocol version
2697 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2698 AT_CAPTURE_FILE([monitor.log])
2699
2700 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 01"
2701 ovs-appctl -t ovs-ofctl ofctl/barrier
2702 ovs-appctl -t ovs-ofctl exit
2703
2704 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2705 send: OFPT_BUNDLE_CONTROL (OF1.4):
2706  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
2707 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
2708 OFPT_BUNDLE_CONTROL (OF1.4):
2709  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
2710 OFPT_BARRIER_REPLY (OF1.4):
2711 ])
2712
2713 OVS_VSWITCHD_STOP
2714 AT_CLEANUP
2715
2716 AT_SETUP([ofproto - bundle double close (OpenFlow 1.4)])
2717 AT_KEYWORDS([monitor])
2718 OVS_VSWITCHD_START
2719
2720 # Start a monitor, use the required protocol version
2721 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2722 AT_CAPTURE_FILE([monitor.log])
2723
2724 # Open, Close, Close
2725 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2726 ovs-appctl -t ovs-ofctl ofctl/barrier
2727 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 01"
2728 ovs-appctl -t ovs-ofctl ofctl/barrier
2729 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 01"
2730 ovs-appctl -t ovs-ofctl ofctl/barrier
2731 ovs-appctl -t ovs-ofctl exit
2732
2733 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2734 send: OFPT_BUNDLE_CONTROL (OF1.4):
2735  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2736 OFPT_BUNDLE_CONTROL (OF1.4):
2737  bundle_id=0x1 type=OPEN_REPLY flags=0
2738 OFPT_BARRIER_REPLY (OF1.4):
2739 send: OFPT_BUNDLE_CONTROL (OF1.4):
2740  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
2741 OFPT_BUNDLE_CONTROL (OF1.4):
2742  bundle_id=0x1 type=CLOSE_REPLY flags=0
2743 OFPT_BARRIER_REPLY (OF1.4):
2744 send: OFPT_BUNDLE_CONTROL (OF1.4):
2745  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
2746 OFPT_ERROR (OF1.4): OFPBFC_BUNDLE_CLOSED
2747 OFPT_BUNDLE_CONTROL (OF1.4):
2748  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
2749 OFPT_BARRIER_REPLY (OF1.4):
2750 ])
2751
2752 OVS_VSWITCHD_STOP
2753 AT_CLEANUP
2754
2755 AT_SETUP([ofproto - bundle close, different flags (OpenFlow 1.4)])
2756 AT_KEYWORDS([monitor])
2757 OVS_VSWITCHD_START
2758
2759 # Start a monitor, use the required protocol version
2760 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2761 AT_CAPTURE_FILE([monitor.log])
2762
2763 # Open, Close, Close
2764 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2765 ovs-appctl -t ovs-ofctl ofctl/barrier
2766 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 02"
2767 ovs-appctl -t ovs-ofctl ofctl/barrier
2768 ovs-appctl -t ovs-ofctl exit
2769
2770 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2771 send: OFPT_BUNDLE_CONTROL (OF1.4):
2772  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2773 OFPT_BUNDLE_CONTROL (OF1.4):
2774  bundle_id=0x1 type=OPEN_REPLY flags=0
2775 OFPT_BARRIER_REPLY (OF1.4):
2776 send: OFPT_BUNDLE_CONTROL (OF1.4):
2777  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
2778 OFPT_ERROR (OF1.4): OFPBFC_BAD_FLAGS
2779 OFPT_BUNDLE_CONTROL (OF1.4):
2780  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
2781 OFPT_BARRIER_REPLY (OF1.4):
2782 ])
2783
2784 OVS_VSWITCHD_STOP
2785 AT_CLEANUP
2786
2787 AT_SETUP([ofproto - bundle commit without open (OpenFlow 1.4)])
2788 AT_KEYWORDS([monitor])
2789 OVS_VSWITCHD_START
2790
2791 # Start a monitor, use the required protocol version
2792 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2793 AT_CAPTURE_FILE([monitor.log])
2794
2795 # Open, Close, Close
2796 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 04 00 01"
2797 ovs-appctl -t ovs-ofctl ofctl/barrier
2798 ovs-appctl -t ovs-ofctl exit
2799
2800 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2801 send: OFPT_BUNDLE_CONTROL (OF1.4):
2802  bundle_id=0x1 type=COMMIT_REQUEST flags=atomic
2803 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
2804 OFPT_BUNDLE_CONTROL (OF1.4):
2805  bundle_id=0x1 type=COMMIT_REQUEST flags=atomic
2806 OFPT_BARRIER_REPLY (OF1.4):
2807 ])
2808
2809 OVS_VSWITCHD_STOP
2810 AT_CLEANUP
2811
2812 AT_SETUP([ofproto - bundle commit, different flags (OpenFlow 1.4)])
2813 AT_KEYWORDS([monitor])
2814 OVS_VSWITCHD_START
2815
2816 # Start a monitor, use the required protocol version
2817 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2818 AT_CAPTURE_FILE([monitor.log])
2819
2820 # Open, Close, Close
2821 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2822 ovs-appctl -t ovs-ofctl ofctl/barrier
2823 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 04 00 02"
2824 ovs-appctl -t ovs-ofctl ofctl/barrier
2825 ovs-appctl -t ovs-ofctl exit
2826
2827 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2828 send: OFPT_BUNDLE_CONTROL (OF1.4):
2829  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2830 OFPT_BUNDLE_CONTROL (OF1.4):
2831  bundle_id=0x1 type=OPEN_REPLY flags=0
2832 OFPT_BARRIER_REPLY (OF1.4):
2833 send: OFPT_BUNDLE_CONTROL (OF1.4):
2834  bundle_id=0x1 type=COMMIT_REQUEST flags=ordered
2835 OFPT_ERROR (OF1.4): OFPBFC_BAD_FLAGS
2836 OFPT_BUNDLE_CONTROL (OF1.4):
2837  bundle_id=0x1 type=COMMIT_REQUEST flags=ordered
2838 OFPT_BARRIER_REPLY (OF1.4):
2839 ])
2840
2841 OVS_VSWITCHD_STOP
2842 AT_CLEANUP
2843
2844 AT_SETUP([ofproto - bundle discard without open (OpenFlow 1.4)])
2845 AT_KEYWORDS([monitor])
2846 OVS_VSWITCHD_START
2847
2848 # Start a monitor, use the required protocol version
2849 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2850 AT_CAPTURE_FILE([monitor.log])
2851
2852 # Open, Close, Close
2853 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 06 00 01"
2854 ovs-appctl -t ovs-ofctl ofctl/barrier
2855 ovs-appctl -t ovs-ofctl exit
2856
2857 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2858 send: OFPT_BUNDLE_CONTROL (OF1.4):
2859  bundle_id=0x1 type=DISCARD_REQUEST flags=atomic
2860 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
2861 OFPT_BUNDLE_CONTROL (OF1.4):
2862  bundle_id=0x1 type=DISCARD_REQUEST flags=atomic
2863 OFPT_BARRIER_REPLY (OF1.4):
2864 ])
2865
2866 OVS_VSWITCHD_STOP
2867 AT_CLEANUP