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