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