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