ofproto: Fix memory leak and memory exhaustion bugs in group_mod.
[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], [0], [stdout])
244 AT_CHECK([STRIP_XIDS stdout | sort], [0], [dnl
245 OFPT_QUEUE_GET_CONFIG_REPLY: port=1
246 OFPT_QUEUE_GET_CONFIG_REPLY: port=2
247 ])
248 AT_CHECK([ovs-ofctl queue-get-config br0 10], [0],
249   [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_PORT
250 OFPT_QUEUE_GET_CONFIG_REQUEST (xid=0x2): port=10
251 ])
252 OVS_VSWITCHD_STOP
253 AT_CLEANUP
254
255 AT_SETUP([ofproto - queue configuration - (OpenFlow 1.2)])
256 OVS_VSWITCHD_START
257 ADD_OF_PORTS([br0], [1], [2])
258 AT_CHECK([ovs-ofctl -O OpenFlow12 queue-get-config br0 1], [0], [stdout])
259 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
260 OFPT_QUEUE_GET_CONFIG_REPLY (OF1.2): port=1
261 ])
262 AT_CHECK([ovs-ofctl -O OpenFlow12 queue-get-config br0 ANY], [0], [stdout])
263 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
264 OFPT_QUEUE_GET_CONFIG_REPLY (OF1.2): port=ANY
265 ])
266 AT_CHECK([ovs-ofctl -O OpenFlow12 queue-get-config br0 10], [0],
267   [OFPT_ERROR (OF1.2) (xid=0x2): OFPQOFC_BAD_PORT
268 OFPT_QUEUE_GET_CONFIG_REQUEST (OF1.2) (xid=0x2): port=10
269 ])
270 OVS_VSWITCHD_STOP
271 AT_CLEANUP
272
273 dnl This is really bare-bones.
274 dnl It at least checks request and reply serialization and deserialization.
275 dnl Actions definition listed in both supported formats (w/ actions=)
276 AT_SETUP([ofproto - no group support (OpenFlow 1.0)])
277 OVS_VSWITCHD_START
278 AT_DATA([groups.txt], [dnl
279 group_id=1234,type=all,bucket=output:10
280 group_id=1235,type=all,bucket=actions=output:10
281 ])
282 AT_DATA([stderr], [dnl
283 ovs-ofctl: none of the usable flow formats (OXM,OpenFlow11) is among the allowed flow formats (OpenFlow10,NXM)
284 ])
285 AT_CHECK([ovs-ofctl -O OpenFlow10 -vwarn add-groups br0 groups.txt], [1], ,[stderr])
286 AT_CHECK([ovs-ofctl -O OpenFlow10 -vwarn mod-group br0 'group_id=1234,type=all,bucket=output:10'], [1], ,[stderr])
287 AT_CHECK([ovs-ofctl -O OpenFlow10 -vwarn del-groups br0], [1], ,[stderr])
288 AT_CHECK([ovs-ofctl -O OpenFlow10 -vwarn dump-groups br0 ], [1], ,[stderr])
289 OVS_VSWITCHD_STOP
290 AT_CLEANUP
291
292 dnl This is really bare-bones.
293 dnl It at least checks request and reply serialization and deserialization.
294 dnl Actions definition listed in both supported formats (w/ actions=)
295 AT_SETUP([ofproto - del group (OpenFlow 1.1)])
296 OVS_VSWITCHD_START
297 AT_DATA([groups.txt], [dnl
298 group_id=1234,type=all,bucket=output:10
299 group_id=1235,type=all,bucket=actions=output:10
300 ])
301 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-groups br0 groups.txt])
302 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0 ], [0], [stdout])
303 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
304 OFPST_GROUP_DESC reply (OF1.1):
305  group_id=1234,type=all,bucket=actions=output:10
306  group_id=1235,type=all,bucket=actions=output:10
307 ])
308 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
309 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
310 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
311 OFPST_GROUP_DESC reply (OF1.1):
312  group_id=1235,type=all,bucket=actions=output:10
313 ])
314 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
315 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
316 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
317 OFPST_GROUP_DESC reply (OF1.1):
318  group_id=1235,type=all,bucket=actions=output:10
319 ])
320 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0], [0])
321 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
322 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
323 OFPST_GROUP_DESC reply (OF1.1):
324 ])
325
326 # Negative test.
327 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=0xfffffff0],
328   [1], [], [ovs-ofctl: invalid group id 4294967280
329 ])
330 OVS_VSWITCHD_STOP
331 AT_CLEANUP
332
333 dnl This is really bare-bones.
334 dnl It at least checks request and reply serialization and deserialization.
335 dnl Actions definition listed in both supported formats (w/ actions=)
336 AT_SETUP([ofproto - add indirect group])
337 OVS_VSWITCHD_START
338 dnl indirect group must have exactly one bucket
339 AT_DATA([stderr], [dnl
340 OFPT_ERROR (OF1.1) (xid=0x2): OFPGMFC_INVALID_GROUP
341 OFPT_GROUP_MOD (OF1.1) (xid=0x2): ***decode error: OFPGMFC_INVALID_GROUP***
342 ])
343 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 'group_id=1234,type=indirect'], [1], , [stderr])
344 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 'group_id=1235,type=indirect,bucket=output:10'])
345 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 'group_id=1236,type=indirect,bucket=output:10,bucket=output:11'], [1], , [stderr])
346 OVS_VSWITCHD_STOP
347 AT_CLEANUP
348
349 dnl This is really bare-bones.
350 dnl It at least checks request and reply serialization and deserialization.
351 dnl Actions definition listed in both supported formats (w/ actions=)
352 AT_SETUP([ofproto - del group (OpenFlow 1.5)])
353 OVS_VSWITCHD_START
354 AT_DATA([groups.txt], [dnl
355 group_id=1233,type=select,selection_method=hash,bucket=output:10,bucket=output:11
356 group_id=1234,type=select,selection_method=hash,fields(eth_dst,ip_dst,tcp_dst),bucket=output:10,bucket=output:11
357 group_id=1235,type=all,bucket=actions=output:12,bucket=bucket_id:0,actions=output:10,bucket=bucket_id:1,actions=output:11
358 ])
359 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn add-groups br0 groups.txt])
360 AT_CHECK([ovs-ofctl -F OXM-OpenFlow15 -O OpenFlow15 -vwarn dump-groups br0 1234], [0], [stdout])
361 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
362 OFPST_GROUP_DESC reply (OF1.5):
363  group_id=1234,type=select,selection_method=hash,fields(eth_dst,ip_dst,tcp_dst),bucket=bucket_id:0,actions=output:10,bucket=bucket_id:1,actions=output:11
364 ])
365 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn del-groups br0 group_id=1234])
366 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
367 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
368 OFPST_GROUP_DESC reply (OF1.5):
369  group_id=1235,type=all,bucket=bucket_id:2,actions=output:12,bucket=bucket_id:0,actions=output:10,bucket=bucket_id:1,actions=output:11
370  group_id=1233,type=select,selection_method=hash,bucket=bucket_id:0,actions=output:10,bucket=bucket_id:1,actions=output:11
371 ])
372 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn del-groups br0 group_id=1234])
373 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
374 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
375 OFPST_GROUP_DESC reply (OF1.5):
376  group_id=1235,type=all,bucket=bucket_id:2,actions=output:12,bucket=bucket_id:0,actions=output:10,bucket=bucket_id:1,actions=output:11
377  group_id=1233,type=select,selection_method=hash,bucket=bucket_id:0,actions=output:10,bucket=bucket_id:1,actions=output:11
378 ])
379 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn del-groups br0], [0])
380 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
381 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
382 OFPST_GROUP_DESC reply (OF1.5):
383 ])
384 OVS_VSWITCHD_STOP
385 AT_CLEANUP
386
387 dnl This is really bare-bones.
388 dnl It at least checks request and reply serialization and deserialization.
389 AT_SETUP([ofproto - del group deletes flows])
390 OVS_VSWITCHD_START
391 AT_DATA([groups.txt], [dnl
392 group_id=1234,type=all,bucket=output:10
393 group_id=1235,type=all,bucket=output:10
394 ])
395 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-groups br0 groups.txt])
396 AT_DATA([flows.txt], [dnl
397 tcp actions=group:1234
398 table=2 udp actions=group:1235
399 ])
400 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flows br0 flows.txt])
401 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
402 [0], [dnl
403  table=2, udp actions=group:1235
404  tcp actions=group:1234
405 OFPST_FLOW reply (OF1.1):
406 ])
407 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
408 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
409 [0], [dnl
410  table=2, udp actions=group:1235
411 OFPST_FLOW reply (OF1.1):
412 ])
413 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
414 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
415 [0], [dnl
416  table=2, udp actions=group:1235
417 OFPST_FLOW reply (OF1.1):
418 ])
419 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0])
420 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
421 [0], [dnl
422 OFPST_FLOW reply (OF1.1):
423 ])
424 OVS_VSWITCHD_STOP
425 AT_CLEANUP
426
427 dnl This is really bare-bones.
428 dnl It at least checks request and reply serialization and deserialization.
429 dnl Actions definition listed in both supported formats (w/ actions=)
430 AT_SETUP([ofproto - insert buckets])
431 OVS_VSWITCHD_START
432 # Add group with no buckets.
433 AT_DATA([groups.txt], [dnl
434 group_id=1234,type=all
435 ])
436 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn add-groups br0 groups.txt])
437 AT_CHECK([ovs-ofctl -F OXM-OpenFlow15 -O OpenFlow15 -vwarn dump-groups br0 1234], [0], [stdout])
438 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
439 OFPST_GROUP_DESC reply (OF1.5):
440  group_id=1234,type=all
441 ])
442
443 # Add two buckets, using "last".
444 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=last,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11])
445 AT_CHECK([ovs-ofctl -F OXM-OpenFlow15 -O OpenFlow15 -vwarn dump-groups br0 1234], [0], [stdout])
446 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
447 OFPST_GROUP_DESC reply (OF1.5):
448  group_id=1234,type=all,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11
449 ])
450
451 # Start over again, then add two buckets using "first".
452 AT_CHECK([ovs-ofctl -O OpenFlow15 --strict del-groups br0 group_id=1234])
453 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn add-group br0 group_id=1234,type=all])
454 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=first,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11])
455 AT_CHECK([ovs-ofctl -F OXM-OpenFlow15 -O OpenFlow15 -vwarn dump-groups br0 1234], [0], [stdout])
456 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
457 OFPST_GROUP_DESC reply (OF1.5):
458  group_id=1234,type=all,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11
459 ])
460
461 # Add two more buckets before the existing ones.
462 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=first,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1])
463 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
464 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
465 OFPST_GROUP_DESC reply (OF1.5):
466  group_id=1234,type=all,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11
467 ])
468
469 # Add another bucket at the end.
470 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=last,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15])
471 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
472 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
473 OFPST_GROUP_DESC reply (OF1.5):
474  group_id=1234,type=all,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15
475 ])
476
477 # Verify that duplicate bucket IDs are rejected.
478 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=last,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15], [1], [], [stderr])
479 AT_CHECK([STRIP_XIDS stderr | sed '/truncated/,$d'], [0], [dnl
480 OFPT_ERROR (OF1.5): OFPGMFC_BUCKET_EXISTS
481 OFPT_GROUP_MOD (OF1.5):
482 ])
483
484
485 # Add another bucket just before bucket 15.
486 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=15])
487 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
488 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
489 OFPST_GROUP_DESC reply (OF1.5):
490  group_id=1234,type=all,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15
491 ])
492
493 # Add two more buckets just before bucket 11,
494 # getting the command from a file.
495 AT_DATA([buckets.txt], [dnl
496 group_id=1234,command_bucket_id=11,bucket=bucket_id:12,actions=output:12,bucket=bucket_id:13,actions=output:13
497 ])
498 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 - < buckets.txt])
499 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
500 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
501 OFPST_GROUP_DESC reply (OF1.5):
502  group_id=1234,type=all,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:12,actions=output:12,bucket=bucket_id:13,actions=output:13,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15
503 ])
504
505 # Add yet two more buckets.
506 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=15,bucket=bucket_id:20,actions=output:20,bucket=bucket_id:21,actions=output:21])
507 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
508 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
509 OFPST_GROUP_DESC reply (OF1.5):
510  group_id=1234,type=all,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:12,actions=output:12,bucket=bucket_id:13,actions=output:13,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15,bucket=bucket_id:20,actions=output:20,bucket=bucket_id:21,actions=output:21
511 ])
512
513 # Negative tests.
514 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=0xffffff01,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1], [1], [],
515   [ovs-ofctl: invalid command bucket id 4294967041
516 ])
517 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn insert-buckets br0 group_id=1234,command_bucket_id=first,bucket=bucket_id:0,actions=output:0,bucket=bucket_id:1,actions=output:1], [1], [],
518   [ovs-ofctl: insert-bucket needs OpenFlow 1.5 or later ('-O OpenFlow15')
519 ])
520 OVS_VSWITCHD_STOP
521 AT_CLEANUP
522
523 dnl This is really bare-bones.
524 dnl It at least checks request and reply serialization and deserialization.
525 dnl Actions definition listed in both supported formats (w/ actions=)
526 AT_SETUP([ofproto - remove buckets])
527 OVS_VSWITCHD_START
528 AT_DATA([groups.txt], [dnl
529 group_id=1234,type=all,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:12,actions=output:12,bucket=bucket_id:13,actions=output:13,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15,bucket=bucket_id:16,actions=output:16
530 ])
531 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn add-groups br0 groups.txt])
532 AT_CHECK([ovs-ofctl -F OXM-OpenFlow15 -O OpenFlow15 -vwarn dump-groups br0 1234], [0], [stdout])
533 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
534 OFPST_GROUP_DESC reply (OF1.5):
535  group_id=1234,type=all,bucket=bucket_id:10,actions=output:10,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:12,actions=output:12,bucket=bucket_id:13,actions=output:13,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15,bucket=bucket_id:16,actions=output:16
536 ])
537 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn remove-buckets br0 group_id=1234,command_bucket_id=first])
538 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
539 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
540 OFPST_GROUP_DESC reply (OF1.5):
541  group_id=1234,type=all,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:12,actions=output:12,bucket=bucket_id:13,actions=output:13,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15,bucket=bucket_id:16,actions=output:16
542 ])
543 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn remove-buckets br0 group_id=1234,command_bucket_id=last])
544 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
545 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
546 OFPST_GROUP_DESC reply (OF1.5):
547  group_id=1234,type=all,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:12,actions=output:12,bucket=bucket_id:13,actions=output:13,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15
548 ])
549 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn remove-buckets br0 group_id=1234,command_bucket_id=13])
550 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
551 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
552 OFPST_GROUP_DESC reply (OF1.5):
553  group_id=1234,type=all,bucket=bucket_id:11,actions=output:11,bucket=bucket_id:12,actions=output:12,bucket=bucket_id:14,actions=output:14,bucket=bucket_id:15,actions=output:15
554 ])
555 AT_DATA([buckets.txt], [dnl
556 group_id=1234
557 ])
558 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn remove-buckets br0 - < buckets.txt])
559 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-groups br0], [0], [stdout])
560 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
561 OFPST_GROUP_DESC reply (OF1.5):
562  group_id=1234,type=all
563 ])
564 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn remove-buckets br0 group_id=1234,command_bucket_id=first])
565 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn remove-buckets br0 group_id=1234,command_bucket_id=last])
566 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn remove-buckets br0 group_id=1234,command_bucket_id=all])
567 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn remove-buckets br0 group_id=1234,command_bucket_id=1], [1], [], [stderr])
568 AT_CHECK([cat stderr | ofctl_strip], [0], [dnl
569 OFPT_ERROR (OF1.5): OFPGMFC_UNKNOWN_BUCKET
570 OFPT_GROUP_MOD (OF1.5):
571  REMOVE_BUCKET command_bucket_id:1,group_id=1234
572 ])
573 # Negative test.
574 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn remove-buckets br0 group_id=1234,command_bucket_id=last], [1], [],
575   [ovs-ofctl: remove-bucket needs OpenFlow 1.5 or later ('-O OpenFlow15')
576 ])
577 OVS_VSWITCHD_STOP
578 AT_CLEANUP
579
580 dnl This is really bare-bones.
581 dnl It at least checks request and reply serialization and deserialization.
582 AT_SETUP([ofproto - flow mod checks group availability])
583 OVS_VSWITCHD_START
584 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 group_id=1234,type=all,bucket=output:10])
585 AT_DATA([flows.txt], [dnl
586 tcp actions=group:1234
587 udp actions=group:1235
588 ])
589 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=group:1234'])
590 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=group:1235'], [1], [], [stderr])
591
592 # The output should look like this:
593 #
594 # 00000000  02 0e 00 98 00 00 00 02-00 00 00 00 00 00 00 00 |................|
595 # 00000010  00 00 00 00 00 00 00 00-ff 00 00 00 00 00 80 00 |................|
596 # 00000020  ff ff ff ff ff ff ff ff-ff ff ff ff 00 00 00 00 |................|
597 # 00000030  00 00 00 58 00 00 00 00-00 00 03 d7 00 00 00 00 |...X............|
598 #
599 # This 'sed' command captures the error message but drops details.
600 AT_CHECK([sed '/truncated/d
601 /^000000.0/d' stderr | STRIP_XIDS], [0],
602   [OFPT_ERROR (OF1.1): OFPBAC_BAD_OUT_GROUP
603 OFPT_FLOW_MOD (OF1.1):
604 ])
605 OVS_VSWITCHD_STOP
606 AT_CLEANUP
607
608 dnl This is really bare-bones.
609 dnl It at least checks request and reply serialization and deserialization.
610 AT_SETUP([ofproto - group description])
611 OVS_VSWITCHD_START
612 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 group_id=1234,type=all,bucket=output:10], [0], [stdout])
613 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
614 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
615 OFPST_GROUP_DESC reply (OF1.1):
616  group_id=1234,type=all,bucket=actions=output:10
617 ])
618 OVS_VSWITCHD_STOP
619 AT_CLEANUP
620
621 dnl This is really bare-bones.
622 dnl It at least checks request and reply serialization and deserialization.
623 AT_SETUP([ofproto - group description])
624 OVS_VSWITCHD_START
625 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 group_id=1234,type=all,bucket=output:10])
626 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
627 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
628 OFPST_GROUP_DESC reply (OF1.1):
629  group_id=1234,type=all,bucket=actions=output:10
630 ])
631 OVS_VSWITCHD_STOP
632 AT_CLEANUP
633
634 dnl This is really bare-bones.
635 dnl It at least checks request and reply serialization and deserialization.
636 AT_SETUP([ofproto - group features])
637 OVS_VSWITCHD_START
638 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn dump-group-features br0], [0], [stdout])
639 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
640 OFPST_GROUP_FEATURES reply (OF1.2):
641  Group table:
642     Types:  0xf
643     Capabilities:  0x7
644     all group:
645        max_groups=0xffffff00
646        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
647     select group:
648        max_groups=0xffffff00
649        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
650     indirect group:
651        max_groups=0xffffff00
652        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
653     fast failover group:
654        max_groups=0xffffff00
655        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
656 ])
657 OVS_VSWITCHD_STOP
658 AT_CLEANUP
659
660 dnl This is really bare-bones.
661 dnl It at least checks request and reply serialization and deserialization.
662 AT_SETUP([ofproto - group stats (OpenFlow 1.1)])
663 OVS_VSWITCHD_START
664 AT_DATA([groups.txt], [dnl
665 group_id=1234,type=all,bucket=output:10
666 group_id=1235,type=all,bucket=output:10
667 ])
668 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-groups br0 groups.txt])
669 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=group:1234'])
670 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-group-stats br0 group_id=1234], [0], [stdout])
671 AT_CHECK([STRIP_XIDS stdout | sort], [0], [dnl
672  group_id=1234,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
673 OFPST_GROUP reply (OF1.1):
674 ])
675 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-group-stats br0], [0], [stdout])
676 AT_CHECK([STRIP_XIDS stdout | sort], [0], [dnl
677  group_id=1234,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
678  group_id=1235,ref_count=0,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
679 OFPST_GROUP reply (OF1.1):
680 ])
681 OVS_VSWITCHD_STOP
682 AT_CLEANUP
683
684 dnl This is really bare-bones.
685 dnl It at least checks request and reply serialization and deserialization.
686 AT_SETUP([ofproto - group stats (OpenFlow 1.3)])
687 OVS_VSWITCHD_START
688 AT_DATA([groups.txt], [dnl
689 group_id=1234,type=all,bucket=output:10
690 group_id=1235,type=all,bucket=output:10
691 ])
692 AT_CHECK([ovs-ofctl -O OpenFlow13 -vwarn add-groups br0 groups.txt])
693 AT_CHECK([ovs-ofctl -O OpenFlow13 -vwarn add-flow br0 'tcp actions=group:1234'])
694 AT_CHECK([ovs-ofctl -O OpenFlow13 -vwarn dump-group-stats br0 group_id=1234], [0], [stdout])
695 AT_CHECK([STRIP_XIDS stdout | sed 's/duration=[[0-9.]]*s/duration=?s/' | sort], [0], [dnl
696  group_id=1234,duration=?s,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
697 OFPST_GROUP reply (OF1.3):
698 ])
699 AT_CHECK([ovs-ofctl -O OpenFlow13 -vwarn dump-group-stats br0], [0], [stdout])
700 AT_CHECK([STRIP_XIDS stdout | sed 's/duration=[[0-9.]]*s/duration=?s/' | sort], [0], [dnl
701  group_id=1234,duration=?s,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
702  group_id=1235,duration=?s,ref_count=0,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
703 OFPST_GROUP reply (OF1.3):
704 ])
705 OVS_VSWITCHD_STOP
706 AT_CLEANUP
707
708 dnl This is really bare-bones.
709 dnl It at least checks request and reply serialization and deserialization.
710 AT_SETUP([ofproto - group stats (OpenFlow 1.5)])
711 OVS_VSWITCHD_START
712 AT_DATA([groups.txt], [dnl
713 group_id=1234,type=all,bucket=output:10
714 group_id=1235,type=all,bucket=output:10
715 ])
716 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn add-groups br0 groups.txt])
717 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn add-flow br0 'tcp actions=group:1234'])
718 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-group-stats br0 group_id=1234], [0], [stdout])
719 AT_CHECK([STRIP_XIDS stdout | sed 's/duration=[[0-9.]]*s/duration=?s/' | sort], [0], [dnl
720  group_id=1234,duration=?s,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
721 OFPST_GROUP reply (OF1.5):
722 ])
723 AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn dump-group-stats br0], [0], [stdout])
724 AT_CHECK([STRIP_XIDS stdout | sed 's/duration=[[0-9.]]*s/duration=?s/' | sort], [0], [dnl
725  group_id=1234,duration=?s,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
726  group_id=1235,duration=?s,ref_count=0,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
727 OFPST_GROUP reply (OF1.5):
728 ])
729 OVS_VSWITCHD_STOP
730 AT_CLEANUP
731
732 dnl This found a use-after-free error in bridge destruction in the
733 dnl presence of groups.
734 AT_SETUP([ofproto - group add then bridge delete (OpenFlow 1.3)])
735 OVS_VSWITCHD_START
736 AT_DATA([groups.txt], [dnl
737 group_id=1234,type=all,bucket=output:10
738 group_id=1235,type=all,bucket=output:10
739 ])
740 AT_CHECK([ovs-ofctl -O OpenFlow13 -vwarn add-groups br0 groups.txt])
741 AT_CHECK([ovs-vsctl del-br br0])
742 OVS_VSWITCHD_STOP
743 AT_CLEANUP
744
745 AT_SETUP([ofproto - mod-port (OpenFlow 1.0)])
746 OVS_VSWITCHD_START
747 for command_config_state in \
748     'up 0 0' \
749     'noflood NO_FLOOD 0' \
750     'down PORT_DOWN,NO_FLOOD LINK_DOWN' \
751     'flood PORT_DOWN LINK_DOWN' \
752     'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
753     'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
754     'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
755     'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
756     'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
757     'up NO_RECV 0' \
758     'receive 0 0'
759 do
760     set $command_config_state
761     command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
762     AT_CHECK([ovs-ofctl -vwarn mod-port br0 br0 $command])
763     AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
764     AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
765 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
766 n_tables:254, n_buffers:256
767 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
768 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
769  LOCAL(br0): addr:aa:55:aa:55:00:00
770      config:     $config
771      state:      $state
772      speed: 0 Mbps now, 0 Mbps max
773 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
774 ])
775 done
776 OVS_VSWITCHD_STOP
777 AT_CLEANUP
778
779 AT_SETUP([ofproto - mod-port (OpenFlow 1.2)])
780 OVS_VSWITCHD_START
781 for command_config_state in \
782     'up 0 0' \
783     'down PORT_DOWN LINK_DOWN' \
784     'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
785     'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
786     'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
787     'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
788     'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
789     'up NO_RECV 0' \
790     'receive 0 0'
791 do
792     set $command_config_state
793     command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
794     AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn mod-port br0 br0 $command])
795     AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn show br0], [0], [stdout])
796     AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
797 OFPT_FEATURES_REPLY (OF1.2): dpid:fedcba9876543210
798 n_tables:254, n_buffers:256
799 capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS QUEUE_STATS
800  LOCAL(br0): addr:aa:55:aa:55:00:00
801      config:     $config
802      state:      $state
803      speed: 0 Mbps now, 0 Mbps max
804 OFPT_GET_CONFIG_REPLY (OF1.2): frags=normal miss_send_len=0
805 ])
806 done
807 OVS_VSWITCHD_STOP
808 AT_CLEANUP
809
810 AT_SETUP([ofproto - mod-port (OpenFlow 1.4)])
811 OVS_VSWITCHD_START
812 for command_config_state in \
813     'up 0 0' \
814     'down PORT_DOWN LINK_DOWN' \
815     'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
816     'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
817     'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
818     'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
819     'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
820     'up NO_RECV 0' \
821     'receive 0 0'
822 do
823     set $command_config_state
824     command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
825     AT_CHECK([ovs-ofctl -O OpenFlow14 -vwarn mod-port br0 br0 $command])
826     AT_CHECK([ovs-ofctl -O OpenFlow14 -vwarn show br0], [0], [stdout])
827     AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
828 OFPT_FEATURES_REPLY (OF1.4): dpid:fedcba9876543210
829 n_tables:254, n_buffers:256
830 capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS QUEUE_STATS
831 OFPST_PORT_DESC reply (OF1.4):
832  LOCAL(br0): addr:aa:55:aa:55:00:00
833      config:     $config
834      state:      $state
835      speed: 0 Mbps now, 0 Mbps max
836 OFPT_GET_CONFIG_REPLY (OF1.4): frags=normal miss_send_len=0
837 ])
838 done
839 OVS_VSWITCHD_STOP
840 AT_CLEANUP
841
842 AT_SETUP([ofproto - basic flow_mod commands (NXM)])
843 OVS_VSWITCHD_START
844 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
845 ])
846 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl add-flows br0 -])
847 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=2])
848 AT_CHECK([ovs-ofctl -F nxm add-flow br0 table=1,in_port=4,actions=3])
849 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
850  in_port=1 actions=output:2
851  in_port=2 actions=output:1
852  table=1, in_port=4 actions=output:3
853 NXST_FLOW reply:
854 ])
855 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
856 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
857 ])
858 AT_CHECK([ovs-ofctl del-flows br0])
859 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
860 ])
861 OVS_VSWITCHD_STOP
862 AT_CLEANUP
863
864 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.0)])
865 OVS_VSWITCHD_START
866 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
867 ])
868 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -F openflow10 add-flows br0 -])
869 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 in_port=1,actions=2])
870 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 table=1,in_port=4,actions=3])
871 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
872  in_port=1 actions=output:2
873  in_port=2 actions=output:1
874  table=1, in_port=4 actions=output:3
875 OFPST_FLOW reply:
876 ])
877 AT_CHECK([ovs-ofctl -F openflow10 dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
878 OFPST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
879 ])
880 AT_CHECK([ovs-ofctl -F openflow10 del-flows br0])
881 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
882 ])
883 OVS_VSWITCHD_STOP
884 AT_CLEANUP
885
886 # It's really dumb that check_overlap and reset_counts are considered
887 # part of flow state, but OpenFlow implies that it is, and OFTest and
888 # some users insist on it.
889 AT_SETUP([ofproto - add-flow and flags])
890 OVS_VSWITCHD_START
891 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 check_overlap,in_port=1,actions=drop])
892 # Prior to OF1.3, flow dumps didn't include a "flags" field.
893 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [dnl
894 OFPST_FLOW reply:
895  in_port=1 actions=drop
896 ])
897 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
898 OFPST_FLOW reply (OF1.1):
899  in_port=1 actions=drop
900 ])
901 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [dnl
902 OFPST_FLOW reply (OF1.2):
903  in_port=1 actions=drop
904 ])
905 # OF1.3 makes the flags visible.
906 AT_CHECK([ovs-ofctl -O OpenFlow13 dump-flows br0 | ofctl_strip], [0], [dnl
907 OFPST_FLOW reply (OF1.3):
908  check_overlap reset_counts in_port=1 actions=drop
909 ])
910 AT_CHECK([ovs-ofctl -O OpenFlow14 dump-flows br0 | ofctl_strip], [0], [dnl
911 OFPST_FLOW reply (OF1.4):
912  check_overlap reset_counts in_port=1 actions=drop
913 ])
914 AT_CHECK([ovs-ofctl -O OpenFlow15 dump-flows br0 | ofctl_strip], [0], [dnl
915 OFPST_FLOW reply (OF1.5):
916  check_overlap reset_counts in_port=1 actions=drop
917 ])
918 OVS_VSWITCHD_STOP
919 AT_CLEANUP
920
921 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.1)])
922 OVS_VSWITCHD_START
923 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.1):
924 ])
925 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -O OpenFlow11 add-flows br0 -])
926 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 in_port=1,actions=2])
927 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 table=1,in_port=4,actions=3])
928 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
929  in_port=1 actions=output:2
930  in_port=2 actions=output:1
931  table=1, in_port=4 actions=output:3
932 OFPST_FLOW reply (OF1.1):
933 ])
934 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
935 OFPST_AGGREGATE reply (OF1.1): packet_count=0 byte_count=0 flow_count=2
936 ])
937 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0])
938 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.1):
939  table=1, in_port=4 actions=output:3
940 ])
941 OVS_VSWITCHD_STOP
942 AT_CLEANUP
943
944 AT_SETUP([ofproto - flow_mod negative test (OpenFlow 1.1)])
945 OVS_VSWITCHD_START(
946   [set bridge br0 protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13])
947 AT_CHECK([ovs-ofctl add-flow -O OpenFlow11 br0 table=1,action=goto_table:2])
948
949 # The error message here actually comes from ovs-ofctl, not from ovs-vswitchd,
950 # but at least it's the same code in ofpacts_check() that issues the error.
951 AT_CHECK([ovs-ofctl add-flow -O OpenFlow11 br0 table=1,action=goto_table:1],
952   [1], [],
953   [ovs-ofctl: actions are invalid with specified match (OFPBIC_BAD_TABLE_ID)
954 ])
955 OVS_VSWITCHD_STOP
956 AT_CLEANUP
957
958 AT_SETUP([ofproto - set-field flow_mod commands (NXM)])
959 OVS_VSWITCHD_START
960 AT_CHECK([ovs-ofctl add-flow br0 ipv6,table=1,in_port=3,actions=drop])
961 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])
962 AT_CHECK([ovs-ofctl add-flow br0 icmp6,icmp_type=136,table=1,in_port=3,actions=set_field:fe80:8675:3097:890a:a6ba:dbff:f00d:59fa-\>nd_target,set_field:cc:dd:ee:ff:00:11-\>nd_tll])
963 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
964  table=1, icmp6,in_port=3,icmp_type=136 actions=load:0xa6badbfff00d59fa->NXM_NX_ND_TARGET[[0..63]],load:0xfe8086753097890a->NXM_NX_ND_TARGET[[64..127]],load:0xccddeeff0011->NXM_NX_ND_TLL[[]]
965  table=1, ipv6,in_port=3 actions=load:0xa6badbfffefe59fa->NXM_NX_IPV6_SRC[[0..63]],load:0xfe8001234567890a->NXM_NX_IPV6_SRC[[64..127]]
966 NXST_FLOW reply:
967 ])
968 OVS_VSWITCHD_STOP
969 AT_CLEANUP
970
971 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.2)])
972 OVS_VSWITCHD_START
973 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.2):
974 ])
975 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -O OpenFlow12 add-flows br0 -])
976 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=1,actions=2])
977 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 table=1,in_port=4,actions=3])
978 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
979  in_port=1 actions=output:2
980  in_port=2 actions=output:1
981  table=1, in_port=4 actions=output:3
982 OFPST_FLOW reply (OF1.2):
983 ])
984 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0])
985 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.2):
986 ])
987 OVS_VSWITCHD_STOP
988 AT_CLEANUP
989
990 AT_SETUP([ofproto - set-field flow_mod commands (OF1.2)])
991 OVS_VSWITCHD_START
992 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 ipv6,table=1,in_port=3,actions=drop])
993 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 ipv6,table=1,in_port=3,actions=set_field:fe80:0123:4567:890a:a6ba:dbff:fefe:59fa-\>ipv6_src])
994 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 icmp6,icmp_type=136,table=1,in_port=3,actions=set_field:fe80:8675:3097:890a:a6ba:dbff:f00d:59fa-\>nd_target,set_field:cc:dd:ee:ff:00:11-\>nd_tll])
995 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
996  table=1, icmp6,in_port=3,icmp_type=136 actions=set_field:fe80:8675:3097:890a:a6ba:dbff:f00d:59fa->nd_target,set_field:cc:dd:ee:ff:00:11->nd_tll
997  table=1, ipv6,in_port=3 actions=set_field:fe80:123:4567:890a:a6ba:dbff:fefe:59fa->ipv6_src
998 OFPST_FLOW reply (OF1.2):
999 ])
1000 OVS_VSWITCHD_STOP
1001 AT_CLEANUP
1002
1003 AT_SETUP([ofproto - dump flows with cookie])
1004 OVS_VSWITCHD_START
1005 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
1006 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
1007 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
1008 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1009  cookie=0x1, in_port=1 actions=output:1
1010  cookie=0x2, in_port=2 actions=output:1
1011  cookie=0x3, in_port=3 actions=output:1
1012 NXST_FLOW reply:
1013 ])
1014 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
1015 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
1016 ])
1017 AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/-1 | ofctl_strip | sort], [0], [dnl
1018  cookie=0x3, in_port=3 actions=output:1
1019 NXST_FLOW reply:
1020 ])
1021 AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/-1 | STRIP_XIDS], [0], [dnl
1022 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=1
1023 ])
1024 OVS_VSWITCHD_STOP
1025 AT_CLEANUP
1026
1027 AT_SETUP([ofproto - mod flow with cookie change (OpenFlow 1.0)])
1028 OVS_VSWITCHD_START
1029 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 cookie=0x1,in_port=1,actions=1])
1030 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1031  cookie=0x1, in_port=1 actions=output:1
1032 OFPST_FLOW reply:
1033 ])
1034
1035 AT_CHECK([ovs-ofctl -F openflow10 mod-flows br0 cookie=0x2,in_port=1,actions=1])
1036 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1037  cookie=0x2, in_port=1 actions=output:1
1038 OFPST_FLOW reply:
1039 ])
1040 OVS_VSWITCHD_STOP
1041 AT_CLEANUP
1042
1043 AT_SETUP([ofproto - mod flow with cookie change (NXM)])
1044 OVS_VSWITCHD_START
1045 AT_CHECK([ovs-ofctl -F nxm add-flow br0 cookie=0x1,in_port=1,actions=1])
1046 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
1047  cookie=0x1, in_port=1 actions=output:1
1048 NXST_FLOW reply:
1049 ])
1050
1051 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x2,in_port=1,actions=1])
1052 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
1053  cookie=0x2, in_port=1 actions=output:1
1054 NXST_FLOW reply:
1055 ])
1056 OVS_VSWITCHD_STOP
1057 AT_CLEANUP
1058
1059 AT_SETUP([ofproto - no mod flow with cookie change (OpenFlow 1.1)])
1060 OVS_VSWITCHD_START
1061 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
1062 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1063  cookie=0x1, in_port=1 actions=output:1
1064 OFPST_FLOW reply (OF1.1):
1065 ])
1066 AT_CHECK([ovs-ofctl -O OpenFlow11 mod-flows br0 cookie=0x2,in_port=1,actions=1])
1067 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1068  cookie=0x1, in_port=1 actions=output:1
1069 OFPST_FLOW reply (OF1.1):
1070 ])
1071 OVS_VSWITCHD_STOP
1072 AT_CLEANUP
1073
1074 dnl The OpenFlow 1.2 spec states that the cookie may not be modified
1075 AT_SETUP([ofproto - no mod flow with cookie change (OpenFlow 1.2)])
1076 OVS_VSWITCHD_START
1077 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
1078 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1079  cookie=0x1, in_port=1 actions=output:1
1080 OFPST_FLOW reply (OF1.2):
1081 ])
1082
1083 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 cookie=0x2,in_port=1,actions=1])
1084 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1085  cookie=0x1, in_port=1 actions=output:1
1086 OFPST_FLOW reply (OF1.2):
1087 ])
1088 OVS_VSWITCHD_STOP
1089 AT_CLEANUP
1090
1091 AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.0)])
1092 OVS_VSWITCHD_START
1093 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
1094 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
1095 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
1096 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1097  cookie=0x1, in_port=1 actions=output:1
1098  cookie=0x1, in_port=2 actions=output:1
1099  cookie=0x2, in_port=3 actions=output:1
1100 NXST_FLOW reply:
1101 ])
1102
1103 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x1/0xff,actions=4])
1104 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
1105  cookie=0x1, in_port=1 actions=output:4
1106  cookie=0x1, in_port=2 actions=output:4
1107  cookie=0x2, in_port=3 actions=output:1
1108 NXST_FLOW reply:
1109 ])
1110 OVS_VSWITCHD_STOP
1111 AT_CLEANUP
1112
1113 AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.1)])
1114 OVS_VSWITCHD_START
1115 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
1116 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=2,actions=1])
1117 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x2,in_port=3,actions=1])
1118 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1119  cookie=0x1, in_port=1 actions=output:1
1120  cookie=0x1, in_port=2 actions=output:1
1121  cookie=0x2, in_port=3 actions=output:1
1122 OFPST_FLOW reply (OF1.1):
1123 ])
1124
1125 AT_CHECK([ovs-ofctl -O OpenFlow11 mod-flows br0 cookie=0x1/0xff,actions=4])
1126 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1127  cookie=0x1, in_port=1 actions=output:4
1128  cookie=0x1, in_port=2 actions=output:4
1129  cookie=0x2, in_port=3 actions=output:1
1130 OFPST_FLOW reply (OF1.1):
1131 ])
1132 OVS_VSWITCHD_STOP
1133 AT_CLEANUP
1134
1135 AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.2)])
1136 OVS_VSWITCHD_START
1137 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
1138 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=2,actions=1])
1139 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=3,actions=1])
1140 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1141  cookie=0x1, in_port=1 actions=output:1
1142  cookie=0x1, in_port=2 actions=output:1
1143  cookie=0x2, in_port=3 actions=output:1
1144 OFPST_FLOW reply (OF1.2):
1145 ])
1146
1147 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 cookie=0x1/0xff,actions=4])
1148 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1149  cookie=0x1, in_port=1 actions=output:4
1150  cookie=0x1, in_port=2 actions=output:4
1151  cookie=0x2, in_port=3 actions=output:1
1152 OFPST_FLOW reply (OF1.2):
1153 ])
1154 OVS_VSWITCHD_STOP
1155 AT_CLEANUP
1156
1157 dnl The OpenFlow 1.2 spec states that the cookie may not be modified
1158 AT_SETUP([ofproto - mod flows based on cookie mask with cookie change])
1159 OVS_VSWITCHD_START
1160 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
1161 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
1162 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
1163 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1164  cookie=0x1, in_port=1 actions=output:1
1165  cookie=0x1, in_port=2 actions=output:1
1166  cookie=0x2, in_port=3 actions=output:1
1167 NXST_FLOW reply:
1168 ])
1169
1170 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/-1,cookie=4,actions=4])
1171 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
1172  cookie=0x2, in_port=3 actions=output:1
1173  cookie=0x4, in_port=1 actions=output:4
1174  cookie=0x4, in_port=2 actions=output:4
1175 NXST_FLOW reply:
1176 ])
1177 OVS_VSWITCHD_STOP
1178 AT_CLEANUP
1179
1180 AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - NXM])
1181 OVS_VSWITCHD_START
1182 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 in_port=1,actions=1])
1183 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
1184  in_port=1 actions=output:1
1185 NXST_FLOW reply:
1186 ])
1187 OVS_VSWITCHD_STOP
1188 AT_CLEANUP
1189
1190 AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - OF1.1])
1191 OVS_VSWITCHD_START
1192 AT_CHECK([ovs-ofctl -O openflow11 mod-flows br0 in_port=1,actions=1])
1193 AT_CHECK([ovs-ofctl -O openflow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1194  in_port=1 actions=output:1
1195 OFPST_FLOW reply (OF1.1):
1196 ])
1197 OVS_VSWITCHD_STOP
1198 AT_CLEANUP
1199
1200 AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - OF1.2])
1201 OVS_VSWITCHD_START
1202 AT_CHECK([ovs-ofctl -O openflow12 mod-flows br0 in_port=1,actions=1])
1203 AT_CHECK([ovs-ofctl -O openflow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1204 OFPST_FLOW reply (OF1.2):
1205 ])
1206 OVS_VSWITCHD_STOP
1207 AT_CLEANUP
1208
1209 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - NXM])
1210 OVS_VSWITCHD_START
1211 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/1,in_port=1,actions=1])
1212 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
1213 NXST_FLOW reply:
1214 ])
1215 OVS_VSWITCHD_STOP
1216 AT_CLEANUP
1217
1218 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - OF1.1])
1219 OVS_VSWITCHD_START
1220 AT_CHECK([ovs-ofctl -O openflow11 mod-flows br0 cookie=1/1,in_port=1,actions=1])
1221 AT_CHECK([ovs-ofctl -O openflow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1222 OFPST_FLOW reply (OF1.1):
1223 ])
1224 OVS_VSWITCHD_STOP
1225 AT_CLEANUP
1226
1227 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - OF1.2])
1228 OVS_VSWITCHD_START
1229 AT_CHECK([ovs-ofctl -O openflow12 mod-flows br0 cookie=1/1,in_port=1,actions=1])
1230 AT_CHECK([ovs-ofctl -O openflow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1231 OFPST_FLOW reply (OF1.2):
1232 ])
1233 OVS_VSWITCHD_STOP
1234 AT_CLEANUP
1235
1236 AT_SETUP([ofproto - del flows with cookies])
1237 OVS_VSWITCHD_START
1238 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
1239 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
1240 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
1241 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1242  cookie=0x1, in_port=1 actions=output:1
1243  cookie=0x2, in_port=2 actions=output:1
1244  cookie=0x3, in_port=3 actions=output:1
1245 NXST_FLOW reply:
1246 ])
1247
1248 AT_CHECK([ovs-ofctl del-flows br0])
1249 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1250 NXST_FLOW reply:
1251 ])
1252 OVS_VSWITCHD_STOP
1253 AT_CLEANUP
1254
1255 AT_SETUP([ofproto - del flows based on cookie])
1256 OVS_VSWITCHD_START
1257 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
1258 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
1259 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
1260 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1261  cookie=0x1, in_port=1 actions=output:1
1262  cookie=0x2, in_port=2 actions=output:1
1263  cookie=0x3, in_port=3 actions=output:1
1264 NXST_FLOW reply:
1265 ])
1266
1267 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/-1])
1268 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1269  cookie=0x1, in_port=1 actions=output:1
1270  cookie=0x2, in_port=2 actions=output:1
1271 NXST_FLOW reply:
1272 ])
1273 OVS_VSWITCHD_STOP
1274 AT_CLEANUP
1275
1276 AT_SETUP([ofproto - del flows based on cookie mask])
1277 OVS_VSWITCHD_START
1278 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
1279 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
1280 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
1281 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1282  cookie=0x1, in_port=1 actions=output:1
1283  cookie=0x2, in_port=2 actions=output:1
1284  cookie=0x3, in_port=3 actions=output:1
1285 NXST_FLOW reply:
1286 ])
1287 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/0x1])
1288 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1289  cookie=0x2, in_port=2 actions=output:1
1290 NXST_FLOW reply:
1291 ])
1292 OVS_VSWITCHD_STOP
1293 AT_CLEANUP
1294
1295 AT_SETUP([ofproto - del flows based on table id (NXM)])
1296 OVS_VSWITCHD_START
1297 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
1298 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
1299 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1300  cookie=0x1, in_port=1 actions=output:1
1301  cookie=0x2, table=1, in_port=2 actions=output:1
1302 NXST_FLOW reply:
1303 ])
1304 AT_CHECK([ovs-ofctl del-flows br0 table=0])
1305 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1306  cookie=0x2, table=1, in_port=2 actions=output:1
1307 NXST_FLOW reply:
1308 ])
1309 AT_CHECK([ovs-ofctl del-flows br0 table=1])
1310 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1311 NXST_FLOW reply:
1312 ])
1313 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
1314 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
1315 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1316  cookie=0x1, in_port=1 actions=output:1
1317  cookie=0x2, table=1, in_port=2 actions=output:1
1318 NXST_FLOW reply:
1319 ])
1320 AT_CHECK([ovs-ofctl del-flows br0])
1321 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1322 NXST_FLOW reply:
1323 ])
1324 OVS_VSWITCHD_STOP
1325 AT_CLEANUP
1326
1327 AT_SETUP([ofproto - del flows based on table id (OpenFlow 1.1)])
1328 OVS_VSWITCHD_START
1329 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
1330 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
1331 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1332  cookie=0x1, in_port=1 actions=output:1
1333  cookie=0x2, table=1, in_port=2 actions=output:1
1334 OFPST_FLOW reply (OF1.1):
1335 ])
1336 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 table=0])
1337 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1338  cookie=0x2, table=1, in_port=2 actions=output:1
1339 OFPST_FLOW reply (OF1.1):
1340 ])
1341 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 table=1])
1342 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1343 OFPST_FLOW reply (OF1.1):
1344 ])
1345 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
1346 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
1347 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1348  cookie=0x1, in_port=1 actions=output:1
1349  cookie=0x2, table=1, in_port=2 actions=output:1
1350 OFPST_FLOW reply (OF1.1):
1351 ])
1352 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0])
1353 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
1354 OFPST_FLOW reply (OF1.1):
1355  cookie=0x2, table=1, in_port=2 actions=output:1
1356 ])
1357 OVS_VSWITCHD_STOP
1358 AT_CLEANUP
1359
1360 AT_SETUP([ofproto - del flows based on table id (OpenFlow 1.2)])
1361 OVS_VSWITCHD_START
1362 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
1363 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
1364 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1365  cookie=0x1, in_port=1 actions=output:1
1366  cookie=0x2, table=1, in_port=2 actions=output:1
1367 OFPST_FLOW reply (OF1.2):
1368 ])
1369 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0 table=0])
1370 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1371  cookie=0x2, table=1, in_port=2 actions=output:1
1372 OFPST_FLOW reply (OF1.2):
1373 ])
1374 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0 table=1])
1375 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1376 OFPST_FLOW reply (OF1.2):
1377 ])
1378 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
1379 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
1380 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1381  cookie=0x1, in_port=1 actions=output:1
1382  cookie=0x2, table=1, in_port=2 actions=output:1
1383 OFPST_FLOW reply (OF1.2):
1384 ])
1385 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0])
1386 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1387 OFPST_FLOW reply (OF1.2):
1388 ])
1389 OVS_VSWITCHD_STOP
1390 AT_CLEANUP
1391
1392 AT_SETUP([ofproto - flow_mod with out_port matching (OpenFlow 1.0)])
1393 OVS_VSWITCHD_START
1394 AT_DATA([flows.txt], [dnl
1395  in_port=1 actions=output:2
1396  in_port=2 actions=output:1,output:2,output:3
1397  in_port=3 actions=output:3,output:1,output:2
1398  in_port=4 actions=drop
1399  in_port=5 actions=output:3
1400  in_port=6 actions=output:1
1401 ])
1402 AT_CHECK([ovs-ofctl -F openflow10 add-flows br0 flows.txt])
1403 (cat flows.txt; echo 'OFPST_FLOW reply:') > expout
1404 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0],
1405   [expout])
1406
1407 (grep 'output:2' flows.txt; echo 'OFPST_FLOW reply:') > expout
1408 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 out_port=2 | ofctl_strip | sort], [0], [expout])
1409
1410 AT_CHECK([ovs-ofctl -F openflow10 del-flows br0 out_port=2])
1411 (grep -v 'output:2' flows.txt; echo 'OFPST_FLOW reply:') > expout
1412 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0],
1413   [expout])
1414
1415 AT_CHECK([ovs-ofctl -F openflow10 del-flows br0 out_port=3])
1416 (grep -v 'output:[[23]]' flows.txt; echo 'OFPST_FLOW reply:') > expout
1417 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0],
1418   [expout])
1419
1420 AT_CHECK([ovs-ofctl -F openflow10 del-flows br0 out_port=1])
1421 (grep -v 'output:[[123]]' flows.txt; echo 'OFPST_FLOW reply:') > expout
1422 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0],
1423   [expout])
1424
1425 OVS_VSWITCHD_STOP
1426 AT_CLEANUP
1427
1428 AT_SETUP([ofproto - flow_mod with out_port matching (OpenFlow 1.1)])
1429 OVS_VSWITCHD_START
1430 AT_DATA([flows.txt], [dnl
1431  in_port=1 actions=output:2
1432  in_port=2 actions=output:1,write_actions(output:2,output:3)
1433  in_port=3 actions=output:3,output:1,write_actions(output:2)
1434  in_port=4 actions=drop
1435  in_port=5 actions=write_actions(output:3)
1436  in_port=6 actions=output:1
1437 ])
1438 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flows br0 flows.txt])
1439 (cat flows.txt; echo 'OFPST_FLOW reply (OF1.1):') > expout
1440 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0],
1441   [expout])
1442
1443 (grep 'output:2' flows.txt; echo 'OFPST_FLOW reply (OF1.1):') > expout
1444 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 out_port=2 | ofctl_strip | sort], [0], [expout])
1445
1446 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 out_port=2])
1447 (grep -v 'output:2' flows.txt; echo 'OFPST_FLOW reply (OF1.1):') > expout
1448 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0],
1449   [expout])
1450
1451 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 out_port=3])
1452 (grep -v 'output:[[23]]' flows.txt; echo 'OFPST_FLOW reply (OF1.1):') > expout
1453 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0],
1454   [expout])
1455
1456 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 out_port=1])
1457 (grep -v 'output:[[123]]' flows.txt; echo 'OFPST_FLOW reply (OF1.1):') > expout
1458 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0],
1459   [expout])
1460
1461 OVS_VSWITCHD_STOP
1462 AT_CLEANUP
1463
1464 AT_SETUP([ofproto - flow_mod with out_group matching (OpenFlow 1.1)])
1465 OVS_VSWITCHD_START
1466 AT_DATA([groups.txt], [dnl
1467 group_id=1,type=all,bucket=output:10
1468 group_id=2,type=all,bucket=output:10
1469 group_id=3,type=all,bucket=output:10
1470 ])
1471 AT_CHECK([ovs-ofctl -O OpenFlow11 add-groups br0 groups.txt])
1472 AT_DATA([flows.txt], [dnl
1473  in_port=1 actions=group:2,output:5
1474  in_port=2 actions=group:1,write_actions(group:2,group:3,output:6)
1475  in_port=3 actions=group:3,group:1,write_actions(group:2,output:3)
1476  in_port=4 actions=output:4
1477  in_port=5 actions=write_actions(output:4,group:3)
1478  in_port=6 actions=group:1
1479 ])
1480 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flows br0 flows.txt])
1481 (cat flows.txt; echo 'OFPST_FLOW reply (OF1.1):') > expout
1482 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0],
1483   [expout])
1484
1485 (grep 'output:3' flows.txt | grep 'group:2'; echo 'OFPST_FLOW reply (OF1.1):') > expout
1486 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 out_port=3,out_group=2 | ofctl_strip | sort], [0], [expout])
1487
1488 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 out_group=2])
1489 (grep -v 'group:2' flows.txt; echo 'OFPST_FLOW reply (OF1.1):') > expout
1490 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0],
1491   [expout])
1492
1493 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 out_group=3])
1494 (grep -v 'group:[[23]]' flows.txt; echo 'OFPST_FLOW reply (OF1.1):') > expout
1495 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0],
1496   [expout])
1497
1498 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 out_group=1])
1499 (grep -v 'group:[[123]]' flows.txt; echo 'OFPST_FLOW reply (OF1.1):') > expout
1500 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0],
1501   [expout])
1502
1503 OVS_VSWITCHD_STOP
1504 AT_CLEANUP
1505
1506 AT_SETUP([ofproto - flow table configuration (OpenFlow 1.0)])
1507 OVS_VSWITCHD_START
1508 # Check the default configuration.
1509 head_table() {
1510     printf 'OFPST_TABLE reply (xid=0x2):
1511   table 0 ("%s"):
1512     active=0, lookup=0, matched=0
1513     max_entries=1000000
1514     matching:
1515       in_port: exact match or wildcard
1516       eth_src: exact match or wildcard
1517       eth_dst: exact match or wildcard
1518       eth_type: exact match or wildcard
1519       vlan_vid: exact match or wildcard
1520       vlan_pcp: exact match or wildcard
1521       ip_src: exact match or wildcard
1522       ip_dst: exact match or wildcard
1523       nw_proto: exact match or wildcard
1524       nw_tos: exact match or wildcard
1525       tcp_src: exact match or wildcard
1526       tcp_dst: exact match or wildcard
1527
1528 ' $1
1529 }
1530 ditto() {
1531     for i in `seq $1 $2`; do
1532         printf '  table %d ("table%d"): ditto\n' $i $i
1533     done
1534 }
1535 (head_table classifier; ditto 1 253) > expout
1536 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
1537 # Change the configuration.
1538 AT_CHECK(
1539   [ovs-vsctl \
1540      -- --id=@t0 create Flow_Table name=main \
1541      -- --id=@t1 create Flow_Table flow-limit=1024 \
1542      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
1543    | ${PERL} $srcdir/uuidfilt.pl],
1544   [0], [<0>
1545 <1>
1546 ])
1547 # Check that the configuration was updated.
1548 (head_table main; echo '  table 1 ("table1"):
1549     active=0, lookup=0, matched=0
1550     max_entries=1024
1551     (same matching)
1552
1553   table 2 ("table2"):
1554     active=0, lookup=0, matched=0
1555     max_entries=1000000
1556     (same matching)
1557 '; ditto 3 253) > expout
1558 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
1559 OVS_VSWITCHD_STOP
1560 AT_CLEANUP
1561
1562 dnl In-band and fail-open add "hidden rules" to table 0.  These rules shouldn't
1563 dnl be visible to OpenFlow.  This test checks that "dump-flows" and
1564 dnl "dump-tables" don't make them visible.
1565 AT_SETUP([ofproto - hidden rules not in table stats])
1566 # Use an IP address for a controller that won't actually exist: we
1567 # want to create in-band rules but we do not want to actually connect
1568 # to a controller (because that could mess about with our test).  The
1569 # Class E range 240.0.0.0 - 255.255.255.255 seems like a good choice.
1570 OVS_VSWITCHD_START([set-controller br0 tcp:240.0.0.1:6653])
1571 for i in 1 2 3 4 5; do ovs-appctl time/warp 1000; done
1572
1573 # Check that no hidden flows are visible in OpenFlow.
1574 AT_CHECK([ovs-ofctl dump-flows br0], [0], [NXST_FLOW reply (xid=0x4):
1575 ])
1576
1577 # Check that some hidden flows related to 240.0.0.1 are actually in table 0.
1578 #
1579 # We discard flows that mention table_id because we only want table 0 flows,
1580 # which in OVS is implied by the absence of a table_id.
1581 AT_CHECK([ovs-appctl bridge/dump-flows br0], [0], [stdout])
1582 AT_CHECK([test `grep '240\.0\.0\.1' stdout | grep -v table_id= | wc -l` -gt 0])
1583
1584 # Check that dump-tables doesn't count the hidden flows.
1585 head_table() {
1586     printf 'OFPST_TABLE reply (xid=0x2):
1587   table 0 ("%s"):
1588     active=0, lookup=0, matched=0
1589     max_entries=1000000
1590     matching:
1591       in_port: exact match or wildcard
1592       eth_src: exact match or wildcard
1593       eth_dst: exact match or wildcard
1594       eth_type: exact match or wildcard
1595       vlan_vid: exact match or wildcard
1596       vlan_pcp: exact match or wildcard
1597       ip_src: exact match or wildcard
1598       ip_dst: exact match or wildcard
1599       nw_proto: exact match or wildcard
1600       nw_tos: exact match or wildcard
1601       tcp_src: exact match or wildcard
1602       tcp_dst: exact match or wildcard
1603
1604 ' $1
1605 }
1606 ditto() {
1607     for i in `seq $1 $2`; do
1608         printf '  table %d ("table%d"): ditto\n' $i $i
1609     done
1610 }
1611 (head_table classifier; ditto 1 253) > expout
1612 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
1613 OVS_VSWITCHD_STOP(["/240\.0\.0\.1/d"])
1614 AT_CLEANUP
1615
1616 AT_SETUP([ofproto - flow table configuration (OpenFlow 1.2)])
1617 OVS_VSWITCHD_START
1618 # Check the default configuration.
1619 head_table() {
1620     printf 'OFPST_TABLE reply (OF1.2) (xid=0x2):
1621   table 0 ("%s"):
1622     active=0, lookup=0, matched=0
1623     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1624     config=controller
1625     max_entries=1000000
1626     instructions (table miss and others):
1627       instructions: apply_actions,clear_actions,write_actions,write_metadata,goto_table
1628       Write-Actions and Apply-Actions features:
1629         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
1630         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 ipv6_label 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 icmp_type icmp_code icmpv6_type icmpv6_code nd_target nd_sll nd_tll
1631     matching:
1632       metadata: exact match or wildcard
1633       in_port_oxm: exact match or wildcard
1634       eth_src: exact match or wildcard
1635       eth_dst: exact match or wildcard
1636       eth_type: exact match or wildcard
1637       vlan_vid: exact match or wildcard
1638       vlan_pcp: exact match or wildcard
1639       mpls_label: exact match or wildcard
1640       mpls_tc: exact match or wildcard
1641       ip_src: exact match or wildcard
1642       ip_dst: exact match or wildcard
1643       ipv6_src: exact match or wildcard
1644       ipv6_dst: exact match or wildcard
1645       ipv6_label: exact match or wildcard
1646       nw_proto: exact match or wildcard
1647       ip_dscp: exact match or wildcard
1648       nw_ecn: exact match or wildcard
1649       arp_op: exact match or wildcard
1650       arp_spa: exact match or wildcard
1651       arp_tpa: exact match or wildcard
1652       arp_sha: exact match or wildcard
1653       arp_tha: exact match or wildcard
1654       tcp_src: exact match or wildcard
1655       tcp_dst: exact match or wildcard
1656       udp_src: exact match or wildcard
1657       udp_dst: exact match or wildcard
1658       sctp_src: exact match or wildcard
1659       sctp_dst: exact match or wildcard
1660       icmp_type: exact match or wildcard
1661       icmp_code: exact match or wildcard
1662       icmpv6_type: exact match or wildcard
1663       icmpv6_code: exact match or wildcard
1664       nd_target: exact match or wildcard
1665       nd_sll: exact match or wildcard
1666       nd_tll: exact match or wildcard
1667
1668 ' $1
1669 }
1670 ditto() {
1671     for i in `seq $1 $2`; do
1672         printf '  table %d ("table%d"): ditto\n' $i $i
1673     done
1674 }
1675 tail_table() {
1676     printf '  table 253 ("table253"):
1677     active=0, lookup=0, matched=0
1678     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1679     config=controller
1680     max_entries=1000000
1681     instructions (table miss and others):
1682       instructions: apply_actions,clear_actions,write_actions,write_metadata
1683       (same actions)
1684     (same matching)
1685 '
1686 }
1687 (head_table classifier; ditto 1 252; tail_table) > expout
1688 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
1689 # Change the configuration.
1690 AT_CHECK(
1691   [ovs-vsctl \
1692      -- --id=@t0 create Flow_Table name=main \
1693      -- --id=@t1 create Flow_Table flow-limit=1024 \
1694      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
1695    | ${PERL} $srcdir/uuidfilt.pl],
1696   [0], [<0>
1697 <1>
1698 ])
1699 # Check that the configuration was updated.
1700 (head_table main; echo '  table 1 ("table1"):
1701     active=0, lookup=0, matched=0
1702     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1703     config=controller
1704     max_entries=1024
1705     (same instructions)
1706     (same matching)
1707
1708   table 2 ("table2"):
1709     active=0, lookup=0, matched=0
1710     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1711     config=controller
1712     max_entries=1000000
1713     (same instructions)
1714     (same matching)
1715 '; ditto 3 252; tail_table) > expout
1716 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
1717 OVS_VSWITCHD_STOP
1718 AT_CLEANUP
1719
1720 AT_SETUP([ofproto - table features (OpenFlow 1.3)])
1721 OVS_VSWITCHD_START
1722 head_table () {
1723     printf '  table 0 ("%s"):
1724     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1725     max_entries=1000000
1726     instructions (table miss and others):
1727       next tables: 1-253
1728       instructions: meter,apply_actions,clear_actions,write_actions,write_metadata,goto_table
1729       Write-Actions and Apply-Actions features:
1730         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
1731         supported on Set-Field: tun_id tun_src tun_dst tun_ipv6_src tun_ipv6_dst tun_flags tun_gbp_id tun_gbp_flags tun_metadata0 dnl
1732 tun_metadata1 tun_metadata2 tun_metadata3 tun_metadata4 tun_metadata5 tun_metadata6 tun_metadata7 tun_metadata8 tun_metadata9 tun_metadata10 tun_metadata11 tun_metadata12 tun_metadata13 tun_metadata14 tun_metadata15 tun_metadata16 tun_metadata17 tun_metadata18 tun_metadata19 tun_metadata20 tun_metadata21 tun_metadata22 tun_metadata23 tun_metadata24 tun_metadata25 tun_metadata26 tun_metadata27 tun_metadata28 tun_metadata29 tun_metadata30 tun_metadata31 tun_metadata32 tun_metadata33 tun_metadata34 tun_metadata35 tun_metadata36 tun_metadata37 tun_metadata38 tun_metadata39 tun_metadata40 tun_metadata41 tun_metadata42 tun_metadata43 tun_metadata44 tun_metadata45 tun_metadata46 tun_metadata47 tun_metadata48 tun_metadata49 tun_metadata50 tun_metadata51 tun_metadata52 tun_metadata53 tun_metadata54 tun_metadata55 tun_metadata56 tun_metadata57 tun_metadata58 tun_metadata59 tun_metadata60 tun_metadata61 tun_metadata62 tun_metadata63 dnl
1733 metadata in_port in_port_oxm pkt_mark ct_mark ct_label 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 ipv6_label 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 icmp_type icmp_code icmpv6_type icmpv6_code nd_target nd_sll nd_tll
1734     matching:
1735       dp_hash: arbitrary mask
1736       recirc_id: exact match or wildcard
1737       conj_id: exact match or wildcard
1738       tun_id: arbitrary mask
1739       tun_src: arbitrary mask
1740       tun_dst: arbitrary mask
1741       tun_ipv6_src: arbitrary mask
1742       tun_ipv6_dst: arbitrary mask
1743       tun_flags: arbitrary mask
1744       tun_gbp_id: arbitrary mask
1745       tun_gbp_flags: arbitrary mask
1746       tun_metadata0: arbitrary mask
1747       tun_metadata1: arbitrary mask
1748       tun_metadata2: arbitrary mask
1749       tun_metadata3: arbitrary mask
1750       tun_metadata4: arbitrary mask
1751       tun_metadata5: arbitrary mask
1752       tun_metadata6: arbitrary mask
1753       tun_metadata7: arbitrary mask
1754       tun_metadata8: arbitrary mask
1755       tun_metadata9: arbitrary mask
1756       tun_metadata10: arbitrary mask
1757       tun_metadata11: arbitrary mask
1758       tun_metadata12: arbitrary mask
1759       tun_metadata13: arbitrary mask
1760       tun_metadata14: arbitrary mask
1761       tun_metadata15: arbitrary mask
1762       tun_metadata16: arbitrary mask
1763       tun_metadata17: arbitrary mask
1764       tun_metadata18: arbitrary mask
1765       tun_metadata19: arbitrary mask
1766       tun_metadata20: arbitrary mask
1767       tun_metadata21: arbitrary mask
1768       tun_metadata22: arbitrary mask
1769       tun_metadata23: arbitrary mask
1770       tun_metadata24: arbitrary mask
1771       tun_metadata25: arbitrary mask
1772       tun_metadata26: arbitrary mask
1773       tun_metadata27: arbitrary mask
1774       tun_metadata28: arbitrary mask
1775       tun_metadata29: arbitrary mask
1776       tun_metadata30: arbitrary mask
1777       tun_metadata31: arbitrary mask
1778       tun_metadata32: arbitrary mask
1779       tun_metadata33: arbitrary mask
1780       tun_metadata34: arbitrary mask
1781       tun_metadata35: arbitrary mask
1782       tun_metadata36: arbitrary mask
1783       tun_metadata37: arbitrary mask
1784       tun_metadata38: arbitrary mask
1785       tun_metadata39: arbitrary mask
1786       tun_metadata40: arbitrary mask
1787       tun_metadata41: arbitrary mask
1788       tun_metadata42: arbitrary mask
1789       tun_metadata43: arbitrary mask
1790       tun_metadata44: arbitrary mask
1791       tun_metadata45: arbitrary mask
1792       tun_metadata46: arbitrary mask
1793       tun_metadata47: arbitrary mask
1794       tun_metadata48: arbitrary mask
1795       tun_metadata49: arbitrary mask
1796       tun_metadata50: arbitrary mask
1797       tun_metadata51: arbitrary mask
1798       tun_metadata52: arbitrary mask
1799       tun_metadata53: arbitrary mask
1800       tun_metadata54: arbitrary mask
1801       tun_metadata55: arbitrary mask
1802       tun_metadata56: arbitrary mask
1803       tun_metadata57: arbitrary mask
1804       tun_metadata58: arbitrary mask
1805       tun_metadata59: arbitrary mask
1806       tun_metadata60: arbitrary mask
1807       tun_metadata61: arbitrary mask
1808       tun_metadata62: arbitrary mask
1809       tun_metadata63: arbitrary mask
1810       metadata: arbitrary mask
1811       in_port: exact match or wildcard
1812       in_port_oxm: exact match or wildcard
1813       actset_output: exact match or wildcard
1814       pkt_mark: arbitrary mask
1815       ct_state: arbitrary mask
1816       ct_zone: exact match or wildcard
1817       ct_mark: arbitrary mask
1818       ct_label: arbitrary mask
1819       reg0: arbitrary mask
1820       reg1: arbitrary mask
1821       reg2: arbitrary mask
1822       reg3: arbitrary mask
1823       reg4: arbitrary mask
1824       reg5: arbitrary mask
1825       reg6: arbitrary mask
1826       reg7: arbitrary mask
1827       xreg0: arbitrary mask
1828       xreg1: arbitrary mask
1829       xreg2: arbitrary mask
1830       xreg3: arbitrary mask
1831       eth_src: arbitrary mask
1832       eth_dst: arbitrary mask
1833       eth_type: exact match or wildcard
1834       vlan_tci: arbitrary mask
1835       vlan_vid: arbitrary mask
1836       vlan_pcp: exact match or wildcard
1837       mpls_label: exact match or wildcard
1838       mpls_tc: exact match or wildcard
1839       mpls_bos: exact match or wildcard
1840       ip_src: arbitrary mask
1841       ip_dst: arbitrary mask
1842       ipv6_src: arbitrary mask
1843       ipv6_dst: arbitrary mask
1844       ipv6_label: arbitrary mask
1845       nw_proto: exact match or wildcard
1846       nw_tos: exact match or wildcard
1847       ip_dscp: exact match or wildcard
1848       nw_ecn: exact match or wildcard
1849       nw_ttl: exact match or wildcard
1850       ip_frag: arbitrary mask
1851       arp_op: exact match or wildcard
1852       arp_spa: arbitrary mask
1853       arp_tpa: arbitrary mask
1854       arp_sha: arbitrary mask
1855       arp_tha: arbitrary mask
1856       tcp_src: arbitrary mask
1857       tcp_dst: arbitrary mask
1858       tcp_flags: arbitrary mask
1859       udp_src: arbitrary mask
1860       udp_dst: arbitrary mask
1861       sctp_src: arbitrary mask
1862       sctp_dst: arbitrary mask
1863       icmp_type: exact match or wildcard
1864       icmp_code: exact match or wildcard
1865       icmpv6_type: exact match or wildcard
1866       icmpv6_code: exact match or wildcard
1867       nd_target: arbitrary mask
1868       nd_sll: arbitrary mask
1869       nd_tll: arbitrary mask
1870
1871 ' $1
1872 }
1873 ditto() {
1874     printf '  table %d ("%s"):
1875     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1876     max_entries=%d
1877     instructions (table miss and others):
1878       next tables: %d-253
1879       (same instructions)
1880       (same actions)
1881     (same matching)
1882
1883 ' $1 $2 $3 `expr $1 + 1`
1884 }
1885 tail_tables() {
1886 echo '  table 252 ("table252"):
1887     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1888     max_entries=1000000
1889     instructions (table miss and others):
1890       next tables: 253
1891       (same instructions)
1892       (same actions)
1893     (same matching)
1894
1895   table 253 ("table253"):
1896     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1897     max_entries=1000000
1898     instructions (table miss and others):
1899       instructions: meter,apply_actions,clear_actions,write_actions,write_metadata
1900       (same actions)
1901     (same matching)
1902 '
1903 }
1904 (head_table classifier
1905  for i in `seq 1 251`; do
1906      ditto $i table$i 1000000
1907  done
1908  tail_tables) > expout
1909 AT_CHECK([ovs-ofctl -O OpenFlow13 dump-table-features br0], [0], [expout])
1910 # Change the configuration.
1911 AT_CHECK(
1912   [ovs-vsctl \
1913      -- --id=@t0 create Flow_Table name=main \
1914      -- --id=@t1 create Flow_Table flow-limit=1024 \
1915      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
1916    | ${PERL} $srcdir/uuidfilt.pl],
1917   [0], [<0>
1918 <1>
1919 ])
1920 # Check that the configuration was updated.
1921 (head_table main
1922  ditto 1 table1 1024
1923  for i in `seq 2 251`; do
1924      ditto $i table$i 1000000
1925  done
1926  tail_tables) > expout
1927 AT_CHECK([ovs-ofctl -O OpenFlow13 dump-table-features br0], [0], [expout])
1928 OVS_VSWITCHD_STOP
1929 AT_CLEANUP
1930
1931 AT_SETUP([ofproto - table description (OpenFlow 1.4)])
1932 OVS_VSWITCHD_START
1933 (x=0
1934  while test $x -lt 254; do
1935    y=`expr $x + 1`
1936    echo "  table $x:
1937    eviction=off eviction_flags=OTHER|IMPORTANCE|LIFETIME
1938    vacancy=off"
1939    x=$y
1940  done) > expout
1941 AT_CHECK([ovs-ofctl -O OpenFlow14 dump-table-desc br0 | sed '/^$/d
1942 /^OFPST_TABLE_DESC/d'], [0], [expout])
1943
1944 # Change the configuration.
1945 AT_CHECK([ovs-ofctl -O Openflow14 mod-table br0 0 evict])
1946 # Check that the configuration was updated.
1947 mv expout orig-expout
1948 sed -e '2s/eviction=off/eviction=on/' <orig-expout > expout
1949 AT_CHECK([ovs-ofctl -O OpenFlow14 dump-table-desc br0 | sed '/^$/d
1950 /^OFPST_TABLE_DESC/d'], [0], [expout])
1951
1952 AT_CHECK([ovs-ofctl -O Openflow14 mod-table br0 0 vacancy:20,80])
1953 # Check that the configuration was updated.
1954 mv expout orig-expout
1955 sed -e '3s/vacancy=off/vacancy=on vacancy_down=20% vacancy_up=80% vacancy=0%/' <orig-expout > expout
1956 AT_CHECK([ovs-ofctl -O OpenFlow14 dump-table-desc br0 | sed '/^$/d
1957 /^OFPST_TABLE_DESC/d'], [0], [expout])
1958 OVS_VSWITCHD_STOP
1959 AT_CLEANUP
1960
1961 AT_SETUP([ofproto - hard limits on flow table size (OpenFlow 1.0)])
1962 OVS_VSWITCHD_START
1963 # Configure a maximum of 4 flows.
1964 AT_CHECK(
1965   [ovs-vsctl \
1966      -- --id=@t0 create Flow_Table flow-limit=4 \
1967      -- set bridge br0 flow_tables:0=@t0 \
1968    | ${PERL} $srcdir/uuidfilt.pl],
1969   [0], [<0>
1970 ])
1971 # Add 4 flows.
1972 for in_port in 1 2 3 4; do
1973     ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
1974 done
1975 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1976  in_port=1 actions=drop
1977  in_port=2 actions=drop
1978  in_port=3 actions=drop
1979  in_port=4 actions=drop
1980 NXST_FLOW reply:
1981 ])
1982 # Adding another flow will be refused.
1983 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
1984 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1985   [OFPT_ERROR: OFPFMFC_TABLE_FULL
1986 ])
1987 # Also a mod-flow that would add a flow will be refused.
1988 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
1989 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1990   [OFPT_ERROR: OFPFMFC_TABLE_FULL
1991 ])
1992 # Replacing or modifying an existing flow is allowed.
1993 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
1994 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
1995 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1996  in_port=1 actions=drop
1997  in_port=2 actions=drop
1998  in_port=3 actions=output:1
1999  in_port=4 actions=NORMAL
2000 NXST_FLOW reply:
2001 ])
2002 OVS_VSWITCHD_STOP
2003 AT_CLEANUP
2004
2005 AT_SETUP([ofproto - hard limits on flow table size (OpenFlow 1.2)])
2006 OVS_VSWITCHD_START
2007 # Configure a maximum of 4 flows.
2008 AT_CHECK(
2009   [ovs-vsctl \
2010      -- --id=@t0 create Flow_Table flow-limit=4 \
2011      -- set bridge br0 flow_tables:0=@t0 \
2012    | ${PERL} $srcdir/uuidfilt.pl],
2013   [0], [<0>
2014 ])
2015 # Add 4 flows.
2016 for in_port in 1 2 3 4; do
2017     ovs-ofctl -O OpenFlow12 add-flow br0 in_port=$in_port,actions=drop
2018 done
2019 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2020  in_port=1 actions=drop
2021  in_port=2 actions=drop
2022  in_port=3 actions=drop
2023  in_port=4 actions=drop
2024 OFPST_FLOW reply (OF1.2):
2025 ])
2026 # Adding another flow will be refused.
2027 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
2028 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2029   [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
2030 ])
2031 # Replacing or modifying an existing flow is allowed.
2032 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
2033 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
2034 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2035  in_port=1 actions=drop
2036  in_port=2 actions=drop
2037  in_port=3 actions=output:1
2038  in_port=4 actions=NORMAL
2039 OFPST_FLOW reply (OF1.2):
2040 ])
2041 OVS_VSWITCHD_STOP
2042 AT_CLEANUP
2043
2044 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.0)])
2045 OVS_VSWITCHD_START
2046 # Configure a maximum of 4 flows.
2047 AT_CHECK(
2048   [ovs-vsctl \
2049      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
2050      -- set bridge br0 flow_tables:0=@t0 \
2051    | ${PERL} $srcdir/uuidfilt.pl],
2052   [0], [<0>
2053 ])
2054 # Add 4 flows.
2055 for in_port in 4 3 2 1; do
2056     ovs-ofctl add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
2057 done
2058 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2059  idle_timeout=10, in_port=1 actions=drop
2060  idle_timeout=20, in_port=2 actions=drop
2061  idle_timeout=30, in_port=3 actions=drop
2062  idle_timeout=40, in_port=4 actions=drop
2063 NXST_FLOW reply:
2064 ])
2065 # Adding another flow will cause the one that expires soonest to be evicted.
2066 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
2067 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2068  idle_timeout=20, in_port=2 actions=drop
2069  idle_timeout=30, in_port=3 actions=drop
2070  idle_timeout=40, in_port=4 actions=drop
2071  in_port=5 actions=drop
2072 NXST_FLOW reply:
2073 ])
2074 # A mod-flow that adds a flow also causes eviction, but replacing or
2075 # modifying an existing flow doesn't.
2076 AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
2077 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
2078 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
2079 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2080  idle_timeout=30, in_port=3 actions=output:1
2081  in_port=4 actions=NORMAL
2082  in_port=5 actions=drop
2083  in_port=6 actions=drop
2084 NXST_FLOW reply:
2085 ])
2086 # Flows with no timeouts at all cannot be evicted.
2087 AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
2088 AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
2089 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2090   [OFPT_ERROR: OFPFMFC_TABLE_FULL
2091 ])
2092 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2093  in_port=4 actions=NORMAL
2094  in_port=5 actions=drop
2095  in_port=6 actions=drop
2096  in_port=7 actions=NORMAL
2097 NXST_FLOW reply:
2098 ])
2099 OVS_VSWITCHD_STOP
2100 AT_CLEANUP
2101
2102 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.2)])
2103 OVS_VSWITCHD_START
2104 # Configure a maximum of 4 flows.
2105 AT_CHECK(
2106   [ovs-vsctl \
2107      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
2108      -- set bridge br0 flow_tables:0=@t0 \
2109    | ${PERL} $srcdir/uuidfilt.pl],
2110   [0], [<0>
2111 ])
2112 # Add 4 flows.
2113 for in_port in 4 3 2 1; do
2114     ovs-ofctl -O OpenFlow12 add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
2115 done
2116 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2117  idle_timeout=10, in_port=1 actions=drop
2118  idle_timeout=20, in_port=2 actions=drop
2119  idle_timeout=30, in_port=3 actions=drop
2120  idle_timeout=40, in_port=4 actions=drop
2121 OFPST_FLOW reply (OF1.2):
2122 ])
2123 # Adding another flow will cause the one that expires soonest to be evicted.
2124 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop])
2125 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2126  idle_timeout=20, in_port=2 actions=drop
2127  idle_timeout=30, in_port=3 actions=drop
2128  idle_timeout=40, in_port=4 actions=drop
2129  in_port=5 actions=drop
2130 OFPST_FLOW reply (OF1.2):
2131 ])
2132 # In OpenFlow 1.2 a mod-flow does not ever add a flow and thus
2133 # has no effect on eviction
2134 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=6,actions=drop])
2135 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
2136 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
2137 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2138  idle_timeout=20, in_port=2 actions=drop
2139  idle_timeout=30, in_port=3 actions=output:1
2140  in_port=4 actions=NORMAL
2141  in_port=5 actions=drop
2142 OFPST_FLOW reply (OF1.2):
2143 ])
2144 # Flows with no timeouts at all cannot be evicted.
2145 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=6,actions=drop])
2146 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=7,actions=normal])
2147 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
2148 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2149   [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
2150 ])
2151 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2152  in_port=4 actions=NORMAL
2153  in_port=5 actions=drop
2154  in_port=6 actions=drop
2155  in_port=7 actions=NORMAL
2156 OFPST_FLOW reply (OF1.2):
2157 ])
2158 OVS_VSWITCHD_STOP
2159 AT_CLEANUP
2160
2161 AT_SETUP([ofproto - eviction using importance upon table overflow (OpenFlow 1.4)])
2162 OVS_VSWITCHD_START
2163 # Configure a maximum of 4 flows.
2164 AT_CHECK(
2165   [ovs-vsctl \
2166      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
2167      -- set bridge br0 flow_tables:0=@t0 \
2168    | ${PERL} $srcdir/uuidfilt.pl],
2169   [0], [<0>
2170 ])
2171 # Use mod-table to turn on eviction just to demonstrate that it works.
2172 AT_CHECK([ovs-ofctl -O OpenFlow14 mod-table br0 0 evict])
2173 # Add 4 flows.
2174 for in_port in 4 3 2 1; do
2175     ovs-ofctl -O Openflow14 add-flow br0 importance=$((in_port + 30)),priority=$((in_port + 5)),hard_timeout=$((in_port + 500)),actions=drop
2176 done
2177 AT_CHECK([ovs-ofctl -O Openflow14 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2178  hard_timeout=501, importance=31, priority=6 actions=drop
2179  hard_timeout=502, importance=32, priority=7 actions=drop
2180  hard_timeout=503, importance=33, priority=8 actions=drop
2181  hard_timeout=504, importance=34, priority=9 actions=drop
2182 OFPST_FLOW reply (OF1.4):
2183 ])
2184 # Adding another flow will cause the one with lowest importance to be evicted.
2185 AT_CHECK([ovs-ofctl -O Openflow14 add-flow br0 hard_timeout=505,importance=35,priority=10,in_port=2,actions=drop])
2186 AT_CHECK([ovs-ofctl -O Openflow14 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2187  hard_timeout=502, importance=32, priority=7 actions=drop
2188  hard_timeout=503, importance=33, priority=8 actions=drop
2189  hard_timeout=504, importance=34, priority=9 actions=drop
2190  hard_timeout=505, importance=35, priority=10,in_port=2 actions=drop
2191 OFPST_FLOW reply (OF1.4):
2192 ])
2193 # Disable the Eviction configuration.
2194 AT_CHECK([ovs-ofctl -O OpenFlow14 mod-table br0 0 noevict])
2195 # Adding another flow will cause the system to give error for FULL TABLE.
2196 AT_CHECK([ovs-ofctl -O Openflow14 add-flow br0 hard_timeout=506,importance=36,priority=11,actions=drop],[1], [], [stderr])
2197 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2198  [OFPT_ERROR (OF1.4): OFPFMFC_TABLE_FULL
2199 ])
2200 #Dump flows. It should show only the old values
2201 AT_CHECK([ovs-ofctl -O Openflow14 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2202  hard_timeout=502, importance=32, priority=7 actions=drop
2203  hard_timeout=503, importance=33, priority=8 actions=drop
2204  hard_timeout=504, importance=34, priority=9 actions=drop
2205  hard_timeout=505, importance=35, priority=10,in_port=2 actions=drop
2206 OFPST_FLOW reply (OF1.4):
2207 ])
2208 # mod-flow that would modify a flow will be done successfully.
2209 AT_CHECK([ovs-ofctl -O Openflow14 mod-flows br0 in_port=2,actions=NORMAL])
2210 AT_CHECK([ovs-ofctl -O Openflow14 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2211  hard_timeout=502, importance=32, priority=7 actions=drop
2212  hard_timeout=503, importance=33, priority=8 actions=drop
2213  hard_timeout=504, importance=34, priority=9 actions=drop
2214  hard_timeout=505, importance=35, priority=10,in_port=2 actions=NORMAL
2215 OFPST_FLOW reply (OF1.4):
2216 ])
2217 # Also a mod-flow that would add a flow will be refused.
2218 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
2219 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2220   [OFPT_ERROR: OFPFMFC_TABLE_FULL
2221 ])
2222 OVS_VSWITCHD_STOP
2223 AT_CLEANUP
2224
2225 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.0)])
2226 OVS_VSWITCHD_START
2227 # Configure a maximum of 4 flows.
2228 AT_CHECK(
2229   [ovs-vsctl \
2230      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
2231                                    overflow-policy=evict \
2232                                    groups='"NXM_OF_IN_PORT[[]]"' \
2233      -- set bridge br0 flow_tables:0=@t0 \
2234    | ${PERL} $srcdir/uuidfilt.pl],
2235   [0], [<0>
2236 ])
2237 # Add 4 flows.
2238 ovs-ofctl add-flows br0 - <<EOF
2239 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
2240 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
2241 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
2242 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
2243 EOF
2244 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2245  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2246  idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
2247  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2248  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2249 NXST_FLOW reply:
2250 ])
2251 # Adding another flow will cause the one that expires soonest within
2252 # the largest group (those with in_port=1) to be evicted.  In this
2253 # case this is not the same as the one that expires soonest overall
2254 # (which is what makes the test interesting):
2255 AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
2256 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2257  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2258  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2259  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2260  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2261 NXST_FLOW reply:
2262 ])
2263 # Enlarge the flow limit, change the eviction policy back to strictly
2264 # based on expiration, and and add some flows.
2265 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
2266 ovs-ofctl add-flows br0 - <<EOF
2267 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
2268 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
2269 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
2270 EOF
2271 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2272  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2273  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2274  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2275  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
2276  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2277  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2278  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2279 NXST_FLOW reply:
2280 ])
2281 # Adding another flow will cause the one that expires soonest overall
2282 # to be evicted.
2283 AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
2284 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2285  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2286  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2287  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
2288  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2289  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2290  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
2291  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2292 NXST_FLOW reply:
2293 ])
2294 # Reducing the flow limit also causes the flows that expire soonest
2295 # overall to be evicted.
2296 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
2297 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2298  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2299  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2300  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
2301  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2302 NXST_FLOW reply:
2303 ])
2304 OVS_VSWITCHD_STOP
2305 AT_CLEANUP
2306
2307 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.2)])
2308 OVS_VSWITCHD_START
2309 # Configure a maximum of 4 flows.
2310 AT_CHECK(
2311   [ovs-vsctl \
2312      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
2313                                    overflow-policy=evict \
2314                                    groups='"NXM_OF_IN_PORT[[]]"' \
2315      -- set bridge br0 flow_tables:0=@t0 \
2316    | ${PERL} $srcdir/uuidfilt.pl],
2317   [0], [<0>
2318 ])
2319 # Add 4 flows.
2320 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
2321 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
2322 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
2323 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
2324 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
2325 EOF
2326 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2327  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2328  idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
2329  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2330  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2331 OFPST_FLOW reply (OF1.2):
2332 ])
2333 # Adding another flow will cause the one that expires soonest within
2334 # the largest group (those with in_port=1) to be evicted.  In this
2335 # case this is not the same as the one that expires soonest overall
2336 # (which is what makes the test interesting):
2337 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
2338 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2339  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2340  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2341  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2342  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2343 OFPST_FLOW reply (OF1.2):
2344 ])
2345 # Enlarge the flow limit, change the eviction policy back to strictly
2346 # based on expiration, and and add some flows.
2347 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
2348 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
2349 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
2350 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
2351 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
2352 EOF
2353 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2354  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2355  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2356  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2357  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
2358  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2359  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2360  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2361 OFPST_FLOW reply (OF1.2):
2362 ])
2363 # Adding another flow will cause the one that expires soonest overall
2364 # to be evicted.
2365 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'])
2366 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2367  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2368  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2369  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
2370  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2371  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2372  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
2373  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2374 OFPST_FLOW reply (OF1.2):
2375 ])
2376 # Reducing the flow limit also causes the flows that expire soonest
2377 # overall to be evicted.
2378 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
2379 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2380  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2381  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2382  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
2383  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2384 OFPST_FLOW reply (OF1.2):
2385 ])
2386 OVS_VSWITCHD_STOP
2387 AT_CLEANUP
2388
2389 AT_SETUP([ofproto - eviction upon table overflow, with modified hard timeout])
2390 OVS_VSWITCHD_START
2391 # Configure a maximum of 4 flows.
2392 AT_CHECK(
2393   [ovs-vsctl \
2394      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
2395      -- set bridge br0 flow_tables:0=@t0 \
2396    | ${PERL} $srcdir/uuidfilt.pl],
2397   [0], [<0>
2398 ])
2399 ovs-appctl time/stop
2400 # Add 4 flows.
2401 for in_port in 4 3 2 1; do
2402     ovs-ofctl add-flow br0 hard_timeout=$((10 + in_port * 3)),in_port=$in_port,actions=drop
2403 done
2404 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2405  hard_timeout=13, in_port=1 actions=drop
2406  hard_timeout=16, in_port=2 actions=drop
2407  hard_timeout=19, in_port=3 actions=drop
2408  hard_timeout=22, in_port=4 actions=drop
2409 NXST_FLOW reply:
2410 ])
2411 # Sleep and modify the one that expires soonest
2412 ovs-appctl time/warp 5000
2413 AT_CHECK([ovs-ofctl mod-flows br0 in_port=1,actions=drop])
2414 # At this point the table would looks like:
2415 #  in_port   seconds to expire
2416 #     1            13
2417 #     2            11
2418 #     3            14
2419 #     4            17
2420 ovs-appctl time/warp 2000
2421 # Adding another flow will cause the one that expires soonest to be evicted.
2422 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
2423 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2424  hard_timeout=13, in_port=1 actions=drop
2425  hard_timeout=19, in_port=3 actions=drop
2426  hard_timeout=22, in_port=4 actions=drop
2427  in_port=5 actions=drop
2428 NXST_FLOW reply:
2429 ])
2430 OVS_VSWITCHD_STOP
2431 AT_CLEANUP
2432
2433 AT_SETUP([ofproto - eviction upon table overflow, with modified idle timeout])
2434 OVS_VSWITCHD_START([add-port br0 p1 -- set interface p1 type=dummy ofport_request=1])
2435 # Configure a maximum of 4 flows.
2436 AT_CHECK(
2437   [ovs-vsctl \
2438      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
2439      -- set bridge br0 flow_tables:0=@t0 \
2440    | ${PERL} $srcdir/uuidfilt.pl],
2441   [0], [<0>
2442 ])
2443 # Add 4 flows.
2444 for in_port in 4 3 2 1; do
2445     ovs-ofctl add-flow br0 idle_timeout=$((10 + in_port * 3)),in_port=$in_port,actions=drop
2446 done
2447 ovs-appctl time/stop
2448 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2449  idle_timeout=13, in_port=1 actions=drop
2450  idle_timeout=16, in_port=2 actions=drop
2451  idle_timeout=19, in_port=3 actions=drop
2452  idle_timeout=22, in_port=4 actions=drop
2453 NXST_FLOW reply:
2454 ])
2455 # Sleep and receive on the flow that expires soonest
2456 ovs-appctl time/warp 5000
2457 AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1)'])
2458 # At this point the table would looks like:
2459 #  in_port   seconds to expire
2460 #     1            13
2461 #     2            11
2462 #     3            14
2463 #     4            17
2464 ovs-appctl time/warp 2000
2465 # Adding another flow will cause the one that expires soonest to be evicted.
2466 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
2467 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2468  idle_timeout=19, in_port=3 actions=drop
2469  idle_timeout=22, in_port=4 actions=drop
2470  in_port=5 actions=drop
2471  n_packets=1, n_bytes=60, idle_timeout=13, in_port=1 actions=drop
2472 NXST_FLOW reply:
2473 ])
2474 OVS_VSWITCHD_STOP
2475 AT_CLEANUP
2476
2477 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.0)])
2478 OVS_VSWITCHD_START
2479 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
2480 check_async () {
2481     printf '\n\n--- check_async %d ---\n\n\n' $1
2482     shift
2483
2484     ovs-appctl -t ovs-ofctl ofctl/barrier
2485     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2486     : > expout
2487
2488     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
2489     ovs-ofctl -v packet-out br0 controller controller '0001020304050010203040501234'
2490     if test X"$1" = X"OFPR_ACTION"; then shift;
2491         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
2492 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2493     fi
2494
2495     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
2496     ovs-ofctl -v packet-out br0 controller 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
2497     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
2498         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via no_match) data_len=14 (unbuffered)
2499 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2500     fi
2501
2502     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
2503     ovs-ofctl packet-out br0 controller dec_ttl '002583dfb4000026b98cb0f908004500003eb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
2504     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
2505         echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=CONTROLLER (via invalid_ttl) data_len=76 (unbuffered)
2506 udp,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"
2507     fi
2508
2509     # OFPT_PORT_STATUS, OFPPR_ADD
2510     ovs-vsctl add-port br0 test -- set Interface test type=dummy ofport_request=1
2511     if test X"$1" = X"OFPPR_ADD"; then shift;
2512         echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
2513      config:     PORT_DOWN
2514      state:      LINK_DOWN
2515      speed: 0 Mbps now, 0 Mbps max"
2516     fi
2517
2518     # OFPT_PORT_STATUS, OFPPR_DELETE
2519     ovs-vsctl del-port br0 test
2520     if test X"$1" = X"OFPPR_DELETE"; then shift;
2521         echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
2522      config:     PORT_DOWN
2523      state:      LINK_DOWN
2524      speed: 0 Mbps now, 0 Mbps max"
2525     fi
2526
2527     # OFPT_FLOW_REMOVED, OFPRR_DELETE
2528     ovs-ofctl add-flow br0 send_flow_rem,actions=drop
2529     ovs-ofctl --strict del-flows br0 ''
2530     if test X"$1" = X"OFPRR_DELETE"; then shift;
2531         echo >>expout "OFPT_FLOW_REMOVED:  reason=delete"
2532     fi
2533     AT_FAIL_IF([test X"$1" != X])
2534
2535     ovs-appctl -t ovs-ofctl ofctl/barrier
2536     echo >>expout "OFPT_BARRIER_REPLY:"
2537
2538     AT_CHECK(
2539       [[sed '
2540 s/ (xid=0x[0-9a-fA-F]*)//
2541 s/ *duration.*//
2542 s/00:0.$/00:0x/' < monitor.log]],
2543       [0], [expout])
2544 }
2545
2546 # It's a service connection so initially there should be no async messages.
2547 check_async 1
2548
2549 # Set miss_send_len to 128, turning on packet-ins for our service connection.
2550 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
2551 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2552
2553 # Set miss_send_len to 128 and enable invalid_ttl.
2554 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
2555 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2556
2557 # Become slave, which should disable everything except port status.
2558 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
2559 check_async 4 OFPPR_ADD OFPPR_DELETE
2560
2561 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
2562 ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
2563 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
2564
2565 # Set controller ID 123.
2566 ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
2567 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
2568
2569 # Restore controller ID 0.
2570 ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
2571
2572 # Become master.
2573 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
2574 check_async 7 OFPR_ACTION OFPPR_ADD
2575
2576 ovs-appctl -t ovs-ofctl exit
2577 OVS_VSWITCHD_STOP
2578 AT_CLEANUP
2579
2580 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.2)])
2581 OVS_VSWITCHD_START
2582 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
2583 check_async () {
2584     printf '\n\n--- check_async %d ---\n\n\n' $1
2585     INDEX=$1
2586     shift
2587
2588     ovs-appctl -t ovs-ofctl ofctl/barrier
2589     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2590     : > expout
2591
2592     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
2593     ovs-ofctl -O OpenFlow12 -v packet-out br0 none controller '0001020304050010203040501234'
2594     if test X"$1" = X"OFPR_ACTION"; then shift;
2595         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
2596 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2597     fi
2598
2599     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
2600     ovs-ofctl -O OpenFlow12 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
2601     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
2602         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
2603 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2604     fi
2605
2606     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
2607     ovs-ofctl -O OpenFlow12 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003eb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
2608     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
2609         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
2610 udp,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"
2611     fi
2612
2613     # OFPT_PORT_STATUS, OFPPR_ADD
2614     ovs-vsctl add-port br0 test -- set Interface test type=dummy
2615     if test X"$1" = X"OFPPR_ADD"; then shift;
2616         echo >>expout "OFPT_PORT_STATUS (OF1.2): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2617      config:     PORT_DOWN
2618      state:      LINK_DOWN
2619      speed: 0 Mbps now, 0 Mbps max"
2620     fi
2621
2622     # OFPT_PORT_STATUS, OFPPR_DELETE
2623     ovs-vsctl del-port br0 test
2624     if test X"$1" = X"OFPPR_DELETE"; then shift;
2625         echo >>expout "OFPT_PORT_STATUS (OF1.2): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2626      config:     PORT_DOWN
2627      state:      LINK_DOWN
2628      speed: 0 Mbps now, 0 Mbps max"
2629     fi
2630
2631     # OFPT_FLOW_REMOVED, OFPRR_DELETE
2632     ovs-ofctl -O OpenFlow12 add-flow br0 send_flow_rem,actions=drop
2633     ovs-ofctl -O OpenFlow12 --strict del-flows br0 ''
2634     if test X"$1" = X"OFPRR_DELETE"; then shift;
2635         echo >>expout "OFPT_FLOW_REMOVED (OF1.2):  reason=delete table_id=0"
2636     fi
2637     AT_FAIL_IF([test X"$1" != X])
2638
2639     sleep 1
2640
2641     AT_CHECK(
2642       [[sed '
2643 s/ (xid=0x[0-9a-fA-F]*)//
2644 s/ *duration.*//
2645 s/00:0.$/00:0x/' < monitor.log]],
2646       [0], [expout])
2647 }
2648
2649 # It's a service connection so initially there should be no async messages.
2650 check_async 1
2651
2652 # Set miss_send_len to 128, turning on packet-ins for our service connection.
2653 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
2654 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2655
2656 # Set miss_send_len to 128 and enable invalid_ttl.
2657 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700040080
2658 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2659
2660 # Become slave (OF 1.2), which should disable everything except port status.
2661 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000200000003000000000000000000000001
2662 check_async 4 OFPPR_ADD OFPPR_DELETE
2663
2664 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
2665 ovs-appctl -t ovs-ofctl ofctl/send 03040028000000020000232000000013000000020000000500000005000000020000000200000005
2666 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
2667
2668 # Set controller ID 123.
2669 ovs-appctl -t ovs-ofctl ofctl/send 03040018000000030000232000000014000000000000007b
2670 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
2671
2672 # Restore controller ID 0.
2673 ovs-appctl -t ovs-ofctl ofctl/send 030400180000000300002320000000140000000000000000
2674
2675 # Become master (OF 1.2).
2676 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000400000002000000000000000000000002
2677 check_async 7 OFPR_ACTION OFPPR_ADD
2678
2679 ovs-appctl -t ovs-ofctl exit
2680 OVS_VSWITCHD_STOP
2681 AT_CLEANUP
2682
2683 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.3)])
2684 OVS_VSWITCHD_START
2685 AT_CHECK([ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile])
2686 check_async () {
2687     printf '\n\n--- check_async %d ---\n\n\n' $1
2688     INDEX=$1
2689     shift
2690
2691     ovs-appctl -t ovs-ofctl ofctl/barrier
2692     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2693     : > expout
2694
2695     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
2696     ovs-ofctl -O OpenFlow13 -v packet-out br0 none controller '0001020304050010203040501234'
2697     if test X"$1" = X"OFPR_ACTION"; then shift;
2698         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
2699 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2700     fi
2701
2702     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
2703     ovs-ofctl -O OpenFlow13 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
2704     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
2705         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
2706 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2707     fi
2708
2709     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
2710     ovs-ofctl -O OpenFlow13 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003eb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
2711     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
2712         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
2713 udp,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"
2714     fi
2715
2716     # OFPT_PORT_STATUS, OFPPR_ADD
2717     ovs-vsctl add-port br0 test -- set Interface test type=dummy
2718     if test X"$1" = X"OFPPR_ADD"; then shift;
2719         echo >>expout "OFPT_PORT_STATUS (OF1.3): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2720      config:     PORT_DOWN
2721      state:      LINK_DOWN
2722      speed: 0 Mbps now, 0 Mbps max"
2723     fi
2724
2725     # OFPT_PORT_STATUS, OFPPR_DELETE
2726     ovs-vsctl del-port br0 test
2727     if test X"$1" = X"OFPPR_DELETE"; then shift;
2728         echo >>expout "OFPT_PORT_STATUS (OF1.3): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2729      config:     PORT_DOWN
2730      state:      LINK_DOWN
2731      speed: 0 Mbps now, 0 Mbps max"
2732     fi
2733
2734     # OFPT_FLOW_REMOVED, OFPRR_DELETE
2735     ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=drop
2736     ovs-ofctl -O OpenFlow13 --strict del-flows br0 ''
2737     if test X"$1" = X"OFPRR_DELETE"; then shift;
2738         echo >>expout "OFPT_FLOW_REMOVED (OF1.3):  reason=delete table_id=0"
2739     fi
2740
2741     # OFPT_FLOW_REMOVED, OFPRR_GROUP_DELETE
2742     ovs-ofctl -O OpenFlow13 add-group br0 group_id=1234,type=all,bucket=output:10
2743     ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=group:1234
2744     ovs-ofctl -O OpenFlow13 --strict del-groups br0 group_id=1234
2745     if test X"$1" = X"OFPRR_DELETE"; then shift;
2746         echo >>expout "OFPT_FLOW_REMOVED (OF1.3):  reason=gropu_delete table_id=0"
2747     fi
2748
2749     AT_FAIL_IF([test X"$1" != X])
2750
2751     ovs-appctl -t ovs-ofctl ofctl/barrier
2752     echo >>expout "OFPT_BARRIER_REPLY (OF1.3):"
2753
2754     AT_CHECK(
2755       [[sed '
2756 s/ (xid=0x[0-9a-fA-F]*)//
2757 s/ *duration.*//
2758 s/00:0.$/00:0x/' < monitor.log]],
2759       [0], [expout])
2760 }
2761
2762 # It's a service connection so initially there should be no async messages.
2763 check_async 1
2764
2765 # Set miss_send_len to 128, turning on packet-ins for our service connection.
2766 ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
2767 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2768
2769 # Become slave (OF 1.3), which should disable everything except port status.
2770 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000200000003000000000000000000000001
2771 check_async 3 OFPPR_ADD OFPPR_DELETE
2772
2773 # Use OF 1.3 OFPT_SET_ASYNC to enable a patchwork of asynchronous messages.
2774 ovs-appctl -t ovs-ofctl ofctl/send 041c002000000002000000020000000500000005000000020000000200000005
2775 check_async 4 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
2776
2777 # Set controller ID 123.
2778 ovs-appctl -t ovs-ofctl ofctl/send 04040018000000030000232000000014000000000000007b
2779 check_async 5 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
2780
2781 # Restore controller ID 0.
2782 ovs-appctl -t ovs-ofctl ofctl/send 040400180000000300002320000000140000000000000000
2783
2784 # Become master (OF 1.3).
2785 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000400000002000000000000000000000002
2786 check_async 6 OFPR_ACTION OFPPR_ADD
2787
2788 ovs-appctl -t ovs-ofctl exit
2789 OVS_VSWITCHD_STOP
2790 AT_CLEANUP
2791
2792 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.4)])
2793 OVS_VSWITCHD_START
2794 AT_CHECK([ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile])
2795 check_async () {
2796     printf '\n\n--- check_async %d ---\n\n\n' $1
2797     INDEX=$1
2798     shift
2799
2800     ovs-appctl -t ovs-ofctl ofctl/barrier
2801     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2802     : > expout
2803
2804     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
2805     ovs-ofctl -O OpenFlow14 -v packet-out br0 none controller '0001020304050010203040501234'
2806     if test X"$1" = X"OFPR_ACTION"; then shift;
2807         echo >>expout "OFPT_PACKET_IN (OF1.4): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
2808 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2809     fi
2810
2811     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
2812     ovs-ofctl -O OpenFlow14 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
2813     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
2814         echo >>expout "OFPT_PACKET_IN (OF1.4): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
2815 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2816     fi
2817
2818     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
2819     ovs-ofctl -O OpenFlow14 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003eb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
2820     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
2821         echo >>expout "OFPT_PACKET_IN (OF1.4): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
2822 udp,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"
2823     fi
2824
2825 # OFPT_PORT_STATUS, OFPPR_ADD
2826     ovs-vsctl add-port br0 test -- set Interface test type=dummy
2827     if test X"$1" = X"OFPPR_ADD"; then shift;
2828         echo >>expout "OFPT_PORT_STATUS (OF1.4): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2829      config:     PORT_DOWN
2830      state:      LINK_DOWN
2831      speed: 0 Mbps now, 0 Mbps max"
2832     fi
2833
2834     # OFPT_PORT_STATUS, OFPPR_MODIFY
2835     ovs-ofctl -O OpenFlow14 -vwarn mod-port br0 test up
2836     if test X"$1" = X"OFPPR_MODIFY"; then shift;
2837         echo >>expout "OFPT_PORT_STATUS (OF1.4): MOD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2838      config:     0
2839      state:      LINK_DOWN
2840      speed: 0 Mbps now, 0 Mbps max
2841 OFPT_PORT_STATUS (OF1.4): MOD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2842      config:     0
2843      state:      0
2844      speed: 0 Mbps now, 0 Mbps max"
2845     fi
2846
2847     # OFPT_PORT_STATUS, OFPPR_DELETE
2848     ovs-vsctl del-port br0 test
2849     if test X"$1" = X"OFPPR_DELETE"; then shift;
2850         echo >>expout "OFPT_PORT_STATUS (OF1.4): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2851      config:     0
2852      state:      0
2853      speed: 0 Mbps now, 0 Mbps max"
2854     fi
2855
2856     # OFPT_FLOW_REMOVED, OFPRR_DELETE
2857     ovs-ofctl -O OpenFlow14 add-flow br0 send_flow_rem,actions=drop
2858     ovs-ofctl -O OpenFlow14 --strict del-flows br0 ''
2859     if test X"$1" = X"OFPRR_DELETE"; then shift;
2860         echo >>expout "OFPT_FLOW_REMOVED (OF1.4):  reason=delete table_id=0"
2861     fi
2862
2863         # OFPT_FLOW_REMOVED, OFPRR_GROUP_DELETE
2864     ovs-ofctl -O OpenFlow14 add-group br0 group_id=1234,type=all,bucket=output:10
2865     ovs-ofctl -O OpenFlow14 add-flow br0 send_flow_rem,actions=group:1234
2866     ovs-ofctl -O OpenFlow14 --strict del-groups br0 group_id=1234
2867     if test X"$1" = X"OFPRR_GROUP_DELETE"; then shift;
2868         echo >>expout "OFPT_FLOW_REMOVED (OF1.4):  reason=group_delete table_id=0"
2869     fi
2870
2871     AT_FAIL_IF([test X"$1" != X])
2872
2873     ovs-appctl -t ovs-ofctl ofctl/barrier
2874     echo >>expout "OFPT_BARRIER_REPLY (OF1.4):"
2875
2876     AT_CHECK(
2877       [[sed '
2878 s/ (xid=0x[0-9a-fA-F]*)//
2879 s/ *duration.*//
2880 s/00:0.$/00:0x/' < monitor.log]],
2881       [0], [expout])
2882 }
2883
2884 # It's a service connection so initially there should be no async messages.
2885 check_async 1
2886
2887 # Set miss_send_len to 128, turning on packet-ins for our service connection.
2888 ovs-appctl -t ovs-ofctl ofctl/send 0509000c0123456700000080
2889 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_MODIFY OFPPR_DELETE OFPRR_DELETE OFPRR_GROUP_DELETE
2890
2891 # Become slave (OF 1.4), which should disable everything except port status.
2892 ovs-appctl -t ovs-ofctl ofctl/send 051800180000000200000003000000000000000000000001
2893 check_async 3 OFPPR_ADD OFPPR_MODIFY OFPPR_DELETE
2894
2895 # Use OF 1.4 OFPT_SET_ASYNC to enable a patchwork of asynchronous messages.
2896 ovs-appctl -t ovs-ofctl ofctl/send 051c0038000000020000000800000005000100080000000200020008000000020003000800000005000400080000001c0005000800000005
2897 check_async 4 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE OFPRR_GROUP_DELETE
2898
2899 # Set controller ID 123.
2900 ovs-appctl -t ovs-ofctl ofctl/send 05040018000000030000232000000014000000000000007b
2901 check_async 5 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE OFPRR_GROUP_DELETE
2902
2903 # Restore controller ID 0.
2904 ovs-appctl -t ovs-ofctl ofctl/send 050400180000000300002320000000140000000000000000
2905
2906 # Become master (OF 1.4).
2907 ovs-appctl -t ovs-ofctl ofctl/send 051800180000000400000002000000000000000000000002
2908 check_async 6 OFPR_ACTION OFPPR_ADD OFPPR_MODIFY OFPRR_DELETE
2909
2910 ovs-appctl -t ovs-ofctl exit
2911 OVS_VSWITCHD_STOP
2912 AT_CLEANUP
2913
2914 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.5)])
2915 OVS_VSWITCHD_START
2916 AT_CHECK([ovs-ofctl -O OpenFlow15 monitor br0 --detach --no-chdir --pidfile])
2917 check_async () {
2918     printf '\n\n--- check_async %d ---\n\n\n' $1
2919     INDEX=$1
2920     shift
2921
2922     ovs-appctl -t ovs-ofctl ofctl/barrier
2923     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2924     : > expout
2925
2926     # Other tests are not working with OF 1.5, and message
2927     # format may change, so leave them out.
2928
2929     # OFPT_PORT_STATUS, OFPPR_ADD
2930     ovs-vsctl add-port br0 test -- set Interface test type=dummy
2931     if test X"$1" = X"OFPPR_ADD"; then shift;
2932         echo >>expout "OFPT_PORT_STATUS (OF1.5): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2933      config:     PORT_DOWN
2934      state:      LINK_DOWN
2935      speed: 0 Mbps now, 0 Mbps max"
2936     fi
2937
2938     # OFPT_PORT_STATUS, OFPPR_MODIFY
2939     ovs-ofctl -O OpenFlow15 -vwarn mod-port br0 test up
2940     if test X"$1" = X"OFPPR_MODIFY"; then shift;
2941         echo >>expout "OFPT_PORT_STATUS (OF1.5): MOD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2942      config:     0
2943      state:      LINK_DOWN
2944      speed: 0 Mbps now, 0 Mbps max
2945 OFPT_PORT_STATUS (OF1.5): MOD: 2(test): addr:aa:55:aa:55:00:0x
2946      config:     0
2947      state:      0
2948      speed: 0 Mbps now, 0 Mbps max"
2949     fi
2950
2951     # OFPT_PORT_STATUS, OFPPR_DELETE
2952     ovs-vsctl del-port br0 test
2953     if test X"$1" = X"OFPPR_DELETE"; then shift;
2954         echo >>expout "OFPT_PORT_STATUS (OF1.5): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2955      config:     0
2956      state:      0
2957      speed: 0 Mbps now, 0 Mbps max"
2958     fi
2959
2960     AT_FAIL_IF([test X"$1" != X])
2961
2962     ovs-appctl -t ovs-ofctl ofctl/barrier
2963     echo >>expout "OFPT_BARRIER_REPLY (OF1.5):"
2964
2965     AT_CHECK(
2966       [[sed '
2967 s/ (xid=0x[0-9a-fA-F]*)//
2968 s/ *duration.*//
2969 s/00:0.$/00:0x/' < monitor.log]],
2970       [0], [expout])
2971 }
2972
2973 # It's a service connection so initially there should be no async messages.
2974 check_async 1
2975
2976 # If we don't set this, async messages are not received.
2977 # Set miss_send_len to 128, turning on packet-ins for our service connection.
2978 ovs-appctl -t ovs-ofctl ofctl/send 0609000c0123456700000080
2979 check_async 2 OFPPR_ADD OFPPR_MODIFY OFPPR_DELETE
2980
2981 # Set-async has changed in OF 1.4 and is not yet implemented.
2982
2983 ovs-appctl -t ovs-ofctl exit
2984 OVS_VSWITCHD_STOP
2985 AT_CLEANUP
2986
2987 dnl This test checks that the role request/response messaging works
2988 dnl and that generation_id is handled properly.
2989 AT_SETUP([ofproto - controller role (OpenFlow 1.2)])
2990 OVS_VSWITCHD_START
2991 on_exit 'kill `cat c1.pid c2.pid`'
2992
2993 # Start two ovs-ofctl controller processes.
2994 AT_CAPTURE_FILE([monitor1.log])
2995 AT_CAPTURE_FILE([expout1])
2996 AT_CAPTURE_FILE([experr1])
2997 AT_CAPTURE_FILE([monitor2.log])
2998 AT_CAPTURE_FILE([expout2])
2999 AT_CAPTURE_FILE([experr2])
3000 for i in 1 2; do
3001      AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile=`pwd`/c$i.pid --unixctl=`pwd`/c$i])
3002     ovs-appctl -t `pwd`/c$i ofctl/barrier
3003     ovs-appctl -t `pwd`/c$i ofctl/set-output-file monitor$i.log
3004     : > expout$i
3005     : > experr$i
3006
3007     # find out current role
3008     ovs-appctl -t `pwd`/c$i ofctl/send 031800180000000200000000000000000000000000000000
3009     echo >>experr$i "send: OFPT_ROLE_REQUEST (OF1.2): role=nochange"
3010     echo >>expout$i "OFPT_ROLE_REPLY (OF1.2): role=equal"
3011 done
3012
3013 # controller 1: Become slave (generation_id is initially undefined, so
3014 # 2^63+2 should not be stale)
3015 ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000300000003000000008000000000000002
3016 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=slave generation_id=9223372036854775810"
3017 echo >>expout1 "OFPT_ROLE_REPLY (OF1.2): role=slave generation_id=9223372036854775810"
3018
3019 # controller 2: Become master.
3020 ovs-appctl -t `pwd`/c2 ofctl/send 031800180000000300000002000000008000000000000003
3021 echo >>experr2 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=9223372036854775811"
3022 echo >>expout2 "OFPT_ROLE_REPLY (OF1.2): role=master generation_id=9223372036854775811"
3023
3024 # controller 1: Try to become the master using a stale generation ID
3025 ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000400000002000000000000000000000003
3026 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=3"
3027 echo >>expout1 "OFPT_ERROR (OF1.2): OFPRRFC_STALE"
3028 echo >>expout1 "OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=3"
3029
3030 # controller 1: Become master using a valid generation ID
3031 ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000500000002000000000000000000000001
3032 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=1"
3033 echo >>expout1 "OFPT_ROLE_REPLY (OF1.2): role=master generation_id=1"
3034
3035 for i in 1 2; do
3036     ovs-appctl -t `pwd`/c$i ofctl/barrier
3037     echo >>expout$i "OFPT_BARRIER_REPLY (OF1.2):"
3038 done
3039
3040 # Check output.
3041 for i in 1 2; do
3042     cp expout$i expout
3043     AT_CHECK([grep -v '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
3044     cp experr$i expout
3045     AT_CHECK([grep '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
3046 done
3047 OVS_VSWITCHD_STOP
3048 AT_CLEANUP
3049
3050 dnl This test checks that the role request/response messaging works,
3051 dnl that generation_id is handled properly, and that role status update
3052 dnl messages are sent when a controller's role gets changed from master
3053 dnl to slave.
3054 AT_SETUP([ofproto - controller role (OpenFlow 1.4)])
3055 OVS_VSWITCHD_START
3056 on_exit 'kill `cat c1.pid c2.pid`'
3057
3058 # Start two ovs-ofctl controller processes.
3059 AT_CAPTURE_FILE([monitor1.log])
3060 AT_CAPTURE_FILE([expout1])
3061 AT_CAPTURE_FILE([experr1])
3062 AT_CAPTURE_FILE([monitor2.log])
3063 AT_CAPTURE_FILE([expout2])
3064 AT_CAPTURE_FILE([experr2])
3065 for i in 1 2; do
3066      AT_CHECK([ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile=`pwd`/c$i.pid --unixctl=`pwd`/c$i])
3067     ovs-appctl -t `pwd`/c$i ofctl/barrier
3068     ovs-appctl -t `pwd`/c$i ofctl/set-output-file monitor$i.log
3069     : > expout$i
3070     : > experr$i
3071
3072     # find out current role
3073     ovs-appctl -t `pwd`/c$i ofctl/send 051800180000000200000000000000000000000000000000
3074     echo >>experr$i "send: OFPT_ROLE_REQUEST (OF1.4): role=nochange"
3075     echo >>expout$i "OFPT_ROLE_REPLY (OF1.4): role=equal"
3076 done
3077
3078 # controller 1: Become slave (generation_id is initially undefined, so
3079 # 2^63+2 should not be stale)
3080 ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000300000003000000008000000000000002
3081 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=slave generation_id=9223372036854775810"
3082 echo >>expout1 "OFPT_ROLE_REPLY (OF1.4): role=slave generation_id=9223372036854775810"
3083
3084 # controller 2: Become master.
3085 ovs-appctl -t `pwd`/c2 ofctl/send 051800180000000300000002000000008000000000000003
3086 echo >>experr2 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=9223372036854775811"
3087 echo >>expout2 "OFPT_ROLE_REPLY (OF1.4): role=master generation_id=9223372036854775811"
3088
3089 # controller 1: Try to become the master using a stale generation ID
3090 ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000400000002000000000000000000000003
3091 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=3"
3092 echo >>expout1 "OFPT_ERROR (OF1.4): OFPRRFC_STALE"
3093 echo >>expout1 "OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=3"
3094
3095 # controller 1: Become master using a valid generation ID
3096 ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000500000002000000000000000000000001
3097 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=1"
3098 echo >>expout1 "OFPT_ROLE_REPLY (OF1.4): role=master generation_id=1"
3099 echo >>expout2 "OFPT_ROLE_STATUS (OF1.4): role=slave generation_id=1 reason=master_request"
3100
3101 for i in 1 2; do
3102     ovs-appctl -t `pwd`/c$i ofctl/barrier
3103     echo >>expout$i "OFPT_BARRIER_REPLY (OF1.4):"
3104 done
3105
3106 # Check output.
3107 for i in 1 2; do
3108     cp expout$i expout
3109     AT_CHECK([grep -v '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
3110     cp experr$i expout
3111     AT_CHECK([grep '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
3112 done
3113 OVS_VSWITCHD_STOP
3114 AT_CLEANUP
3115
3116 dnl This test checks the Group and meter notifications when a group mod
3117 dnl command is sent from one controller and the reply is received by
3118 dnl other controllers.
3119 AT_SETUP([ofproto - requestforward (OpenFlow 1.4)])
3120 OVS_VSWITCHD_START
3121 on_exit 'kill `cat c1.pid c2.pid c3.pid`'
3122
3123 # Start two ovs-ofctl controller processes.
3124 AT_CAPTURE_FILE([monitor1.log])
3125 AT_CAPTURE_FILE([expout1])
3126 AT_CAPTURE_FILE([monitor2.log])
3127 AT_CAPTURE_FILE([expout2])
3128 AT_CAPTURE_FILE([monitor3.log])
3129 AT_CAPTURE_FILE([expout3])
3130
3131 ovs-ofctl -O OpenFlow15 monitor br0 --detach --no-chdir --pidfile=`pwd`/c1.pid --unixctl=`pwd`/c1
3132 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile=`pwd`/c2.pid --unixctl=`pwd`/c2
3133 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile=`pwd`/c3.pid --unixctl=`pwd`/c3
3134
3135 check_async () {
3136     for i in 1 3; do
3137         ovs-appctl -t `pwd`/c$i ofctl/barrier
3138         ovs-appctl -t `pwd`/c$i ofctl/set-output-file monitor$i.log
3139         : > expout$i
3140     done
3141
3142     printf '\n\n--- check_async %d ---\n\n\n' $1
3143     INDEX=$1
3144     shift
3145
3146     # OFPGC_ADD
3147     ovs-appctl -t `pwd`/c2 ofctl/send "050f0020000000020000000000000001 00100000 ffffffffffffffff 00000000"
3148     if test X"$1" = X"OFPGC_ADD"; then shift;
3149         echo >>expout2 "send: OFPT_GROUP_MOD (OF1.4):
3150  ADD group_id=1,type=all,bucket=actions=drop"
3151         echo >>expout1 "OFPT_REQUESTFORWARD (OF1.5): reason=group_mod
3152  ADD group_id=1,type=all,bucket=bucket_id:0,actions=drop"
3153         echo >>expout3 "OFPT_REQUESTFORWARD (OF1.4): reason=group_mod
3154  ADD group_id=1,type=all,bucket=actions=drop"
3155     fi
3156
3157     # OFPGC_MODIFY
3158     ovs-appctl -t `pwd`/c2 ofctl/send "050f0020000000020001010000000001 00100000 ffffffffffffffff 00000000"
3159     if test X"$1" = X"OFPGC_MODIFY"; then shift;
3160         echo >>expout2 "send: OFPT_GROUP_MOD (OF1.4):
3161  MOD group_id=1,type=select,bucket=weight:0,actions=drop"
3162         echo >>expout1 "OFPT_REQUESTFORWARD (OF1.5): reason=group_mod
3163  MOD group_id=1,type=select,bucket=bucket_id:0,weight:0,actions=drop"
3164         echo >>expout3 "OFPT_REQUESTFORWARD (OF1.4): reason=group_mod
3165  MOD group_id=1,type=select,bucket=weight:0,actions=drop"
3166     fi
3167
3168     ovs-appctl -t `pwd`/c1 ofctl/barrier
3169     echo >>expout1 "OFPT_BARRIER_REPLY (OF1.5):"
3170     ovs-appctl -t `pwd`/c2 ofctl/barrier
3171     echo >>expout2 "OFPT_BARRIER_REPLY (OF1.4):"
3172     ovs-appctl -t `pwd`/c3 ofctl/barrier
3173     echo >>expout3 "OFPT_BARRIER_REPLY (OF1.4):"
3174
3175     # Check output.
3176     for i in 1 3; do
3177         cp expout$i expout
3178         AT_CHECK(
3179       [[sed '
3180 s/ (xid=0x[0-9a-fA-F]*)//'< monitor$i.log]],
3181       [0], [expout])
3182     done
3183 }
3184
3185 # controller 1: Become slave
3186 ovs-appctl -t `pwd`/c1 ofctl/send 061800180000000300000003000000008000000000000002
3187
3188 # controller 2: Become master
3189 ovs-appctl -t `pwd`/c2 ofctl/send 051800180000000300000002000000008000000000000003
3190
3191 # controller 1: Become slave
3192 ovs-appctl -t `pwd`/c3 ofctl/send 051800180000000300000003000000008000000000000004
3193
3194 # controller 1: Enabled requestforward using set Asynchronous message
3195 ovs-appctl -t `pwd`/c1 ofctl/send 061c00280000000200000008000000050002000800000002000400080000001a000a000800000003
3196
3197 # controller 2: Enabled requestforward using set Asynchronous message
3198 ovs-appctl -t `pwd`/c2 ofctl/send 051c002800000002000100080000000200030008000000050005000800000005000b000800000003
3199
3200 # controller 1: Enabled requestforward using set Asynchronous message
3201 ovs-appctl -t `pwd`/c3 ofctl/send 051c00280000000200000008000000050002000800000002000400080000001a000a000800000003
3202 check_async 1 OFPGC_ADD OFPGC_MODIFY
3203
3204 OVS_VSWITCHD_STOP
3205 AT_CLEANUP
3206
3207 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
3208 dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
3209 dnl controllers despite the spec) as meaning a packet that was generated
3210 dnl by the controller.
3211 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.0)])
3212 OVS_VSWITCHD_START
3213 ADD_OF_PORTS([br0], [1])
3214
3215 # Start a monitor listening for packet-ins.
3216 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
3217 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
3218 ovs-appctl -t ovs-ofctl ofctl/barrier
3219 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3220 AT_CAPTURE_FILE([monitor.log])
3221
3222 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
3223 AT_CHECK([ovs-ofctl packet-out br0 none controller,1 '0001020304050010203040501234'])
3224 AT_CHECK([ovs-ofctl packet-out br0 controller controller,1 '0001020304050010203040505678'])
3225
3226 # Stop the monitor and check its output.
3227 ovs-appctl -t ovs-ofctl ofctl/barrier
3228 ovs-appctl -t ovs-ofctl exit
3229
3230 ovs-ofctl dump-ports br0
3231
3232 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3233 OFPT_PACKET_IN: total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
3234 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3235 OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
3236 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
3237 OFPT_BARRIER_REPLY:
3238 ])
3239
3240 OVS_VSWITCHD_STOP
3241 AT_CLEANUP
3242
3243 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
3244 dnl specified by OpenFlow 1.2) and OFPP_CONTROLLER (used by some
3245 dnl controllers despite the spec) as meaning a packet that was generated
3246 dnl by the controller.
3247 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.2)])
3248 OVS_VSWITCHD_START
3249
3250 # Start a monitor listening for packet-ins.
3251 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
3252 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
3253 ovs-appctl -t ovs-ofctl ofctl/barrier
3254 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3255 AT_CAPTURE_FILE([monitor.log])
3256
3257 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
3258 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none controller '0001020304050010203040501234'])
3259 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 4294967293 controller '0001020304050010203040505678'])
3260
3261 # Stop the monitor and check its output.
3262 ovs-appctl -t ovs-ofctl ofctl/barrier
3263 ovs-appctl -t ovs-ofctl exit
3264
3265 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3266 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
3267 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3268 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
3269 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
3270 OFPT_BARRIER_REPLY (OF1.2):
3271 ])
3272
3273 OVS_VSWITCHD_STOP
3274 AT_CLEANUP
3275
3276 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
3277 dnl specified by OpenFlow 1.1) and OFPP_CONTROLLER (used by some
3278 dnl controllers despite the spec) as meaning a packet that was generated
3279 dnl by the controller.
3280 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.1)])
3281 OVS_VSWITCHD_START
3282
3283 # Start a monitor listening for packet-ins.
3284 AT_CHECK([ovs-ofctl -O OpenFlow11 monitor br0 --detach --no-chdir --pidfile])
3285 ovs-appctl -t ovs-ofctl ofctl/send 0209000c0123456700000080
3286 ovs-appctl -t ovs-ofctl ofctl/barrier
3287 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3288 AT_CAPTURE_FILE([monitor.log])
3289
3290 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
3291 AT_CHECK([ovs-ofctl -O OpenFlow11 packet-out br0 none controller '0001020304050010203040501234'])
3292 AT_CHECK([ovs-ofctl -O OpenFlow11 packet-out br0 4294967293 controller '0001020304050010203040505678'])
3293
3294 # Stop the monitor and check its output.
3295 ovs-appctl -t ovs-ofctl ofctl/barrier
3296 ovs-appctl -t ovs-ofctl exit
3297
3298 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3299 OFPT_PACKET_IN (OF1.1): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
3300 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3301 OFPT_PACKET_IN (OF1.1): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
3302 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
3303 OFPT_BARRIER_REPLY (OF1.1):
3304 ])
3305
3306 OVS_VSWITCHD_STOP
3307 AT_CLEANUP
3308
3309 dnl This test checks that metadata is encoded in packet_in structures,
3310 dnl supported by NXAST.
3311 AT_SETUP([ofproto - packet-out with metadata (NXM)])
3312 OVS_VSWITCHD_START
3313
3314 # Start a monitor listening for packet-ins.
3315 AT_CHECK([ovs-ofctl -P nxm monitor br0 --detach --no-chdir --pidfile])
3316 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
3317 ovs-appctl -t ovs-ofctl ofctl/barrier
3318 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3319 AT_CAPTURE_FILE([monitor.log])
3320
3321 # Send a packet-out with a load action to set some metadata, and forward to controller
3322 AT_CHECK([ovs-ofctl packet-out br0 controller 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), load(0xaa->NXM_NX_PKT_MARK[[]]), controller' '0001020304050010203040501234'])
3323
3324 # Stop the monitor and check its output.
3325 ovs-appctl -t ovs-ofctl ofctl/barrier
3326 ovs-appctl -t ovs-ofctl exit
3327
3328 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3329 NXT_PACKET_IN: total_len=14 pkt_mark=0xaa,metadata=0xfafafafa5a5a5a5a,in_port=CONTROLLER (via action) data_len=14 (unbuffered)
3330 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3331 OFPT_BARRIER_REPLY:
3332 ])
3333
3334 OVS_VSWITCHD_STOP
3335 AT_CLEANUP
3336
3337 dnl This test checks that metadata is encoded in packet_in structures,
3338 dnl supported by NXAST.
3339 AT_SETUP([ofproto - packet-out with metadata (OpenFlow 1.2)])
3340 OVS_VSWITCHD_START
3341
3342 # Start a monitor listening for packet-ins.
3343 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
3344 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
3345 ovs-appctl -t ovs-ofctl ofctl/barrier
3346 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3347 AT_CAPTURE_FILE([monitor.log])
3348
3349 # Send a packet-out with a set-field action to set some metadata, and forward to controller
3350 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none 'set_field:0xfafafafa5a5a5a5a->metadata, controller' '0001020304050010203040501234'])
3351
3352 # Stop the monitor and check its output.
3353 ovs-appctl -t ovs-ofctl ofctl/barrier
3354 ovs-appctl -t ovs-ofctl exit
3355
3356 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3357 OFPT_PACKET_IN (OF1.2): total_len=14 metadata=0xfafafafa5a5a5a5a,in_port=ANY (via action) data_len=14 (unbuffered)
3358 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3359 OFPT_BARRIER_REPLY (OF1.2):
3360 ])
3361
3362 OVS_VSWITCHD_STOP
3363 AT_CLEANUP
3364
3365 dnl This test checks that metadata is encoded in packet_in structures,
3366 dnl supported by NXAST.
3367 AT_SETUP([ofproto - packet-out with metadata and dual set_field (OpenFlow 1.3)])
3368 OVS_VSWITCHD_START
3369
3370 # Start a monitor listening for packet-ins.
3371 AT_CHECK([ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile])
3372 ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
3373 ovs-appctl -t ovs-ofctl ofctl/barrier
3374 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3375 AT_CAPTURE_FILE([monitor.log])
3376
3377 # Send a packet-out with a couple of set-field action to set some metadata, and forward to controller
3378 AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 none 'set_field:0xfafafafa5a5a5a5a->metadata, set_field:0x6b->metadata, controller' '0001020304050010203040501234'])
3379
3380 # Stop the monitor and check its output.
3381 ovs-appctl -t ovs-ofctl ofctl/barrier
3382 ovs-appctl -t ovs-ofctl exit
3383
3384 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3385 OFPT_PACKET_IN (OF1.3): total_len=14 metadata=0x6b,in_port=ANY (via action) data_len=14 (unbuffered)
3386 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3387 OFPT_BARRIER_REPLY (OF1.3):
3388 ])
3389
3390 OVS_VSWITCHD_STOP
3391 AT_CLEANUP
3392
3393 dnl This test checks that tunnel metadata is encoded in packet_in structures.
3394 AT_SETUP([ofproto - packet-out with tunnel metadata (OpenFlow 1.2)])
3395 OVS_VSWITCHD_START
3396
3397 # Start a monitor listening for packet-ins.
3398 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
3399 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
3400 ovs-appctl -t ovs-ofctl ofctl/barrier
3401 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3402 AT_CAPTURE_FILE([monitor.log])
3403
3404 # Send a packet-out with set field actions to set some tunnel metadata, and forward to controller
3405 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'])
3406
3407 # Stop the monitor and check its output.
3408 ovs-appctl -t ovs-ofctl ofctl/barrier
3409 ovs-appctl -t ovs-ofctl exit
3410
3411 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3412 OFPT_PACKET_IN (OF1.2): total_len=14 tun_id=0x1020304,tun_src=127.0.0.1,tun_dst=192.168.0.1,in_port=ANY (via action) data_len=14 (unbuffered)
3413 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3414 OFPT_BARRIER_REPLY (OF1.2):
3415 ])
3416
3417 OVS_VSWITCHD_STOP
3418 AT_CLEANUP
3419
3420 m4_divert_push([PREPARE_TESTS])
3421 # Sorts groups of lines that start with a space, without moving them
3422 # past the nearest line that does not start with a space.
3423 multiline_sort () {
3424     ${PERL} -e '
3425         use warnings;
3426         use strict;
3427         my @buffer = ();
3428         while (<STDIN>) {
3429             if (/^ /) {
3430                 push(@buffer, $_);
3431             } else {
3432                 print $_ foreach sort(@buffer);
3433                 print $_;
3434                 @buffer = ();
3435             }
3436         }
3437         print $_ foreach sort(@buffer);
3438 '
3439 }
3440 m4_divert_pop([PREPARE_TESTS])
3441
3442 AT_SETUP([ofproto - flow monitoring])
3443 AT_KEYWORDS([monitor])
3444 OVS_VSWITCHD_START
3445
3446 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
3447
3448 # Start a monitor watching the flow table and check the initial reply.
3449 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
3450 AT_CAPTURE_FILE([monitor.log])
3451 ovs-appctl -t ovs-ofctl ofctl/barrier
3452 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3453   [NXST_FLOW_MONITOR reply:
3454  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
3455 OFPT_BARRIER_REPLY:
3456 ])
3457
3458 # Add, delete, and modify some flows and check the updates.
3459 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3460 ovs-ofctl add-flow br0 in_port=0,dl_vlan=124,actions=output:2
3461 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:5
3462 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=0,actions=output:6
3463 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=1,actions=output:7
3464 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:8
3465 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=0,actions=output:9
3466 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=1,actions=output:10
3467 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,actions=output:11
3468 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=0,actions=output:12
3469 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=1,actions=output:13
3470 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,actions=output:14
3471 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:15
3472 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:16
3473 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:17
3474 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:18
3475 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:19
3476 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:20
3477 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=0,actions=output:21
3478 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=1,actions=output:22
3479 ovs-ofctl add-flow br0 in_port=0,actions=output:23
3480 ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:3
3481 ovs-ofctl mod-flows br0 cookie=5,dl_vlan=123,actions=output:3
3482 ovs-ofctl del-flows br0 dl_vlan=123
3483 ovs-ofctl del-flows br0
3484 ovs-appctl -t ovs-ofctl ofctl/barrier
3485 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | multiline_sort], [0],
3486 [NXST_FLOW_MONITOR reply (xid=0x0):
3487  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
3488 NXST_FLOW_MONITOR reply (xid=0x0):
3489  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:5
3490 NXST_FLOW_MONITOR reply (xid=0x0):
3491  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:6
3492 NXST_FLOW_MONITOR reply (xid=0x0):
3493  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:7
3494 NXST_FLOW_MONITOR reply (xid=0x0):
3495  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:8
3496 NXST_FLOW_MONITOR reply (xid=0x0):
3497  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:9
3498 NXST_FLOW_MONITOR reply (xid=0x0):
3499  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:10
3500 NXST_FLOW_MONITOR reply (xid=0x0):
3501  event=ADDED table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
3502 NXST_FLOW_MONITOR reply (xid=0x0):
3503  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
3504 NXST_FLOW_MONITOR reply (xid=0x0):
3505  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
3506 NXST_FLOW_MONITOR reply (xid=0x0):
3507  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
3508 NXST_FLOW_MONITOR reply (xid=0x0):
3509  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:15
3510 NXST_FLOW_MONITOR reply (xid=0x0):
3511  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:16
3512 NXST_FLOW_MONITOR reply (xid=0x0):
3513  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:17
3514 NXST_FLOW_MONITOR reply (xid=0x0):
3515  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
3516 NXST_FLOW_MONITOR reply (xid=0x0):
3517  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
3518 NXST_FLOW_MONITOR reply (xid=0x0):
3519  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
3520 NXST_FLOW_MONITOR reply (xid=0x0):
3521  event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
3522 NXST_FLOW_MONITOR reply (xid=0x0):
3523  event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
3524 NXST_FLOW_MONITOR reply (xid=0x0):
3525  event=ADDED table=0 cookie=0 in_port=0 actions=output:23
3526 NXST_FLOW_MONITOR reply (xid=0x0):
3527  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:3
3528  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
3529  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
3530 NXST_FLOW_MONITOR reply (xid=0x0):
3531  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
3532  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
3533  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
3534 NXST_FLOW_MONITOR reply (xid=0x0):
3535  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
3536  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
3537  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
3538 NXST_FLOW_MONITOR reply (xid=0x0):
3539  event=DELETED reason=delete table=0 cookie=0 in_port=0 actions=output:23
3540  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
3541  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
3542  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
3543  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
3544  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
3545  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
3546  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
3547  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
3548  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
3549  event=DELETED reason=delete table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
3550 OFPT_BARRIER_REPLY:
3551 ])
3552
3553 # Check that our own changes are reported as full updates.
3554 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3555 ovs-ofctl add-flow br0 in_port=1,actions=output:2
3556 ovs-ofctl add-flow br0 in_port=2,actions=output:1
3557 ovs-appctl -t ovs-ofctl ofctl/barrier
3558 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
3559 ovs-appctl -t ovs-ofctl ofctl/barrier
3560 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
3561 ])
3562 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | multiline_sort], [0],
3563 [NXST_FLOW_MONITOR reply (xid=0x0):
3564  event=ADDED table=0 cookie=0 in_port=1 actions=output:2
3565 NXST_FLOW_MONITOR reply (xid=0x0):
3566  event=ADDED table=0 cookie=0 in_port=2 actions=output:1
3567 OFPT_BARRIER_REPLY:
3568 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
3569 NXST_FLOW_MONITOR reply (xid=0x0):
3570  event=DELETED reason=delete table=0 cookie=0 in_port=1 actions=output:2
3571  event=DELETED reason=delete table=0 cookie=0 in_port=2 actions=output:1
3572 OFPT_BARRIER_REPLY:
3573 ])
3574
3575 ovs-appctl -t ovs-ofctl exit
3576 OVS_VSWITCHD_STOP
3577 AT_CLEANUP
3578
3579 AT_SETUP([ofproto - flow monitoring with !own])
3580 AT_KEYWORDS([monitor])
3581 OVS_VSWITCHD_START
3582
3583 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
3584
3585 # Start a monitor watching the flow table and check the initial reply.
3586 ovs-ofctl monitor br0 watch:\!own --detach --no-chdir --pidfile >monitor.log 2>&1
3587 AT_CAPTURE_FILE([monitor.log])
3588 ovs-appctl -t ovs-ofctl ofctl/barrier
3589 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3590   [NXST_FLOW_MONITOR reply:
3591  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
3592 OFPT_BARRIER_REPLY:
3593 ])
3594
3595 # Check that our own changes are reported as abbreviations.
3596 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3597 ovs-ofctl add-flow br0 in_port=1,actions=output:2
3598 ovs-ofctl add-flow br0 in_port=2,actions=output:1
3599 ovs-appctl -t ovs-ofctl ofctl/barrier
3600 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
3601 ovs-appctl -t ovs-ofctl ofctl/barrier
3602 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
3603 ])
3604 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3605 [NXST_FLOW_MONITOR reply (xid=0x0):
3606  event=ADDED table=0 cookie=0 in_port=1 actions=output:2
3607 NXST_FLOW_MONITOR reply (xid=0x0):
3608  event=ADDED table=0 cookie=0 in_port=2 actions=output:1
3609 OFPT_BARRIER_REPLY:
3610 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
3611 NXST_FLOW_MONITOR reply (xid=0x0):
3612  event=ABBREV xid=0x12345678
3613 OFPT_BARRIER_REPLY:
3614 ])
3615
3616 ovs-appctl -t ovs-ofctl exit
3617 OVS_VSWITCHD_STOP
3618 AT_CLEANUP
3619
3620 AT_SETUP([ofproto - flow monitoring with out_port])
3621 AT_KEYWORDS([monitor])
3622 OVS_VSWITCHD_START
3623
3624 ovs-ofctl add-flow br0 in_port=0,dl_vlan=121,actions=output:1
3625 ovs-ofctl add-flow br0 in_port=0,dl_vlan=122,actions=output:1
3626 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:2
3627
3628 # Start a monitor watching the flow table and check the initial reply.
3629 ovs-ofctl monitor br0 watch:out_port=2 --detach --no-chdir --pidfile >monitor.log 2>&1
3630 AT_CAPTURE_FILE([monitor.log])
3631 ovs-appctl -t ovs-ofctl ofctl/barrier
3632 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3633   [NXST_FLOW_MONITOR reply:
3634  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:2
3635 OFPT_BARRIER_REPLY:
3636 ])
3637
3638 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3639
3640 # Add, modify flows and check the updates.
3641 ovs-ofctl mod-flows br0 dl_vlan=121,actions=drop
3642 ovs-ofctl mod-flows br0 dl_vlan=122,actions=output:1,output:2
3643 ovs-appctl -t ovs-ofctl ofctl/barrier
3644
3645 ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:1,output:2
3646 ovs-appctl -t ovs-ofctl ofctl/barrier
3647
3648 ovs-ofctl mod-flows br0 dl_vlan=122,actions=output:1
3649 ovs-appctl -t ovs-ofctl ofctl/barrier
3650 ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:2
3651 ovs-appctl -t ovs-ofctl ofctl/barrier
3652
3653 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3654 [NXST_FLOW_MONITOR reply (xid=0x0):
3655  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=122 actions=output:1,output:2
3656 OFPT_BARRIER_REPLY:
3657 NXST_FLOW_MONITOR reply (xid=0x0):
3658  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1,output:2
3659 OFPT_BARRIER_REPLY:
3660 NXST_FLOW_MONITOR reply (xid=0x0):
3661  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=122 actions=output:1
3662 OFPT_BARRIER_REPLY:
3663 NXST_FLOW_MONITOR reply (xid=0x0):
3664  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:2
3665 OFPT_BARRIER_REPLY:
3666 ])
3667
3668 ovs-appctl -t ovs-ofctl exit
3669 OVS_VSWITCHD_STOP
3670 AT_CLEANUP
3671
3672 AT_SETUP([ofproto - flow monitoring pause and resume])
3673 AT_KEYWORDS([monitor])
3674
3675 # The maximum socket receive buffer size is important for this test, which
3676 # tests behavior when the receive buffer overflows.
3677 if test -e /proc/sys/net/core/rmem_max; then
3678     # Linux
3679     rmem_max=`cat /proc/sys/net/core/rmem_max`
3680 elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
3681     : # FreeBSD, NetBSD
3682 else
3683     # Don't know how to get maximum socket receive buffer on this OS
3684     AT_SKIP_IF([:])
3685 fi
3686 # Calculate the total amount of queuing: rmem_max in the kernel, 128 kB
3687 # in ofproto sending userspace (see ofmonitor_flush() in connmgr.c).
3688 queue_size=`expr $rmem_max + 128 \* 1024`
3689 echo rmem_max=$rmem_max queue_size=$queue_size
3690
3691 # If there's too much queuing skip the test to avoid timing out.
3692 AT_SKIP_IF([test $rmem_max -gt 1048576])
3693
3694 # Each flow update message takes up at least 48 bytes of space in queues
3695 # and in practice more than that.
3696 n_msgs=`expr $queue_size / 48`
3697 echo n_msgs=$n_msgs
3698
3699 OVS_VSWITCHD_START
3700
3701 # Start a monitor watching the flow table, then make it block.
3702 on_exit 'kill `cat ovs-ofctl.pid`'
3703 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
3704 AT_CAPTURE_FILE([monitor.log])
3705 ovs-appctl -t ovs-ofctl ofctl/block
3706
3707 # Add $n_msgs flows.
3708 (echo "in_port=2,actions=output:2"
3709 ${PERL} -e '
3710     for ($i = 0; $i < '$n_msgs'; $i++) {
3711         print "cookie=1,reg1=$i,actions=drop\n";
3712     }
3713 ') > flows.txt
3714 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
3715 # Check that multipart flow dumps work properly:
3716 AT_CHECK([ovs-ofctl diff-flows br0 flows.txt])
3717 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,cookie=3,actions=drop])
3718 AT_CHECK([ovs-ofctl mod-flows br0 in_port=2,cookie=2,actions=output:2])
3719 AT_CHECK([ovs-ofctl del-flows br0 cookie=1/-1])
3720
3721 ovs-appctl -t ovs-ofctl ofctl/unblock
3722
3723 # Wait for the connection resumed.
3724 # A barrier doesn't work for this purpose.
3725 #    https://www.mail-archive.com/dev@openvswitch.org/msg27013.html
3726 #    https://www.mail-archive.com/dev@openvswitch.org/msg27675.html
3727 OVS_WAIT_UNTIL([grep NXT_FLOW_MONITOR_RESUMED monitor.log])
3728
3729 ovs-appctl -t ovs-ofctl exit
3730
3731 # Check that the flow monitor reported the same number of flows
3732 # added and deleted, but fewer than we actually added and deleted.
3733 adds=`grep -c 'ADDED.*reg1=' monitor.log`
3734 deletes=`grep -c 'DELETED.*reg1=' monitor.log`
3735 echo adds=$adds deletes=$deletes
3736 AT_CHECK([test $adds -gt 100 && test $adds -lt $n_msgs])
3737 AT_CHECK([test $adds = $deletes])
3738
3739 # Check that the flow monitor reported everything in the expected order:
3740 #
3741 #     event=ADDED table=0 cookie=0x1 reg1=0x22
3742 # ...
3743 #    NXT_FLOW_MONITOR_PAUSED:
3744 # ...
3745 #     event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
3746 # ...
3747 #     event=ADDED table=0 cookie=0x3 in_port=1
3748 #     event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
3749 #    NXT_FLOW_MONITOR_RESUMED:
3750 #
3751 # except that, between the PAUSED and RESUMED, the order of the ADDED
3752 # and MODIFIED lines lines depends on hash order, that is, it varies
3753 # as we change the hash function or change architecture.  Therefore,
3754 # we use a couple of tests below to accept both orders.
3755 AT_CHECK([ofctl_strip < monitor.log | sed -n -e '
3756 /reg1=0x22$/p
3757 /cookie=0x[[23]]/p
3758 /NXT_FLOW_MONITOR_PAUSED:/p
3759 /NXT_FLOW_MONITOR_RESUMED:/p
3760 ' > monitor.log.subset])
3761 AT_CHECK([grep -v MODIFIED monitor.log.subset], [0], [dnl
3762  event=ADDED table=0 cookie=0x1 reg1=0x22
3763 NXT_FLOW_MONITOR_PAUSED:
3764  event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
3765  event=ADDED table=0 cookie=0x3 in_port=1
3766 NXT_FLOW_MONITOR_RESUMED:
3767 ])
3768 AT_CHECK([grep -v ADDED monitor.log.subset], [0], [dnl
3769 NXT_FLOW_MONITOR_PAUSED:
3770  event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
3771  event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
3772 NXT_FLOW_MONITOR_RESUMED:
3773 ])
3774
3775 OVS_VSWITCHD_STOP
3776 AT_CLEANUP
3777
3778 AT_SETUP([ofproto - event filtering (OpenFlow 1.3)])
3779 AT_KEYWORDS([monitor])
3780 OVS_VSWITCHD_START
3781
3782 # Start a monitor, use the required protocol version
3783 ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3784 AT_CAPTURE_FILE([monitor.log])
3785
3786 # Send an OpenFlow13 message (04), OFPT_GET_ASYNC_REQUEST (1a), length (8), xid (0a)
3787 ovs-appctl -t ovs-ofctl ofctl/send 041a00080000000a
3788 ovs-appctl -t ovs-ofctl ofctl/barrier
3789
3790 # Check default setting
3791 read -r -d '' expected <<'EOF'
3792 EOF
3793
3794 AT_CHECK([ofctl_strip < monitor.log], [], [dnl
3795 send: OFPT_GET_ASYNC_REQUEST (OF1.3):
3796 OFPT_GET_ASYNC_REPLY (OF1.3):
3797  master:
3798        PACKET_IN: no_match action
3799      PORT_STATUS: add delete modify
3800     FLOW_REMOVED: idle hard delete
3801
3802  slave:
3803        PACKET_IN: (off)
3804      PORT_STATUS: add delete modify
3805     FLOW_REMOVED: (off)
3806 OFPT_BARRIER_REPLY (OF1.3):
3807 ])
3808
3809 OVS_VSWITCHD_STOP
3810 AT_CLEANUP
3811
3812 AT_SETUP([ofproto - ofport_request])
3813 OVS_VSWITCHD_START
3814 ADD_OF_PORTS([br0], [1], [2], [3])
3815
3816 set_and_check_specific_ofports () {
3817     ovs-vsctl set Interface p1 ofport_request="$1" -- \
3818               set Interface p2 ofport_request="$2" -- \
3819               set Interface p3 ofport_request="$3"
3820     ofports=`ovs-vsctl get Interface p1 ofport -- \
3821                        get Interface p2 ofport -- \
3822                        get Interface p3 ofport`
3823     AT_CHECK_UNQUOTED([echo $ofports], [0], [$1 $2 $3
3824 ])
3825 }
3826 for pre in      '1 2 3' '1 3 2' '2 1 3' '2 3 1' '3 1 2' '3 2 1'; do
3827     for post in '1 2 3' '1 3 2' '2 1 3' '2 3 1' '3 1 2' '3 2 1'; do
3828         echo -----------------------------------------------------------
3829         echo "Check changing port numbers from $pre to $post"
3830         set_and_check_specific_ofports $pre
3831         set_and_check_specific_ofports $post
3832     done
3833 done
3834
3835 ovs-vsctl del-port p3
3836
3837 set_and_check_poorly_specified_ofports () {
3838     ovs-vsctl set Interface p1 ofport_request="$1" -- \
3839               set Interface p2 ofport_request="$2"
3840     p1=`ovs-vsctl get Interface p1 ofport`
3841     p2=`ovs-vsctl get Interface p2 ofport`
3842     echo $p1 $p2
3843
3844     AT_CHECK([test "$p1" != "$p2"])
3845     if test "$1" = "$2" && test "$1" != '[[]]'; then
3846         # One port number must be the requested one.
3847         AT_CHECK([test "$p1" = "$1" || test "$p2" = "$1"])
3848         # The other port number must be different (already tested above).
3849     else
3850         AT_CHECK([test "$1" = '[[]]' || test "$p1" = "$1"])
3851         AT_CHECK([test "$2" = '[[]]' || test "$p2" = "$2"])
3852     fi
3853 }
3854 for pre in      '1 2' '[[]] 2' '1 [[]]' '[[]] [[]]' '2 1' '[[]] 1' '2 [[]]' \
3855                 '1 1' '2 2'; do
3856     for post in '1 2' '[[]] 2' '1 [[]]' '[[]] [[]]' '2 1' '[[]] 1' '2 [[]]' \
3857                 '1 1' '2 2'; do
3858         echo -----------------------------------------------------------
3859         echo "Check changing port numbers from $pre to $post"
3860         set_and_check_poorly_specified_ofports $pre
3861         set_and_check_poorly_specified_ofports $post
3862     done
3863 done
3864 OVS_VSWITCHD_STOP
3865 AT_CLEANUP
3866
3867
3868 AT_SETUP([ofproto - bundles, open (OpenFlow 1.4)])
3869 AT_KEYWORDS([monitor])
3870 OVS_VSWITCHD_START
3871
3872 # Start a monitor, use the required protocol version
3873 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3874 AT_CAPTURE_FILE([monitor.log])
3875
3876 # Send an OpenFlow14 message (05), OFPT_BUNDLE_CONTROL (21), length (10), xid (0a)
3877 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
3878 ovs-appctl -t ovs-ofctl ofctl/barrier
3879 ovs-appctl -t ovs-ofctl exit
3880
3881 AT_CHECK([ofctl_strip < monitor.log], [], [dnl
3882 send: OFPT_BUNDLE_CONTROL (OF1.4):
3883  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
3884 OFPT_BUNDLE_CONTROL (OF1.4):
3885  bundle_id=0x1 type=OPEN_REPLY flags=0
3886 OFPT_BARRIER_REPLY (OF1.4):
3887 ])
3888
3889 OVS_VSWITCHD_STOP
3890 AT_CLEANUP
3891
3892 AT_SETUP([ofproto - bundles, double open (OpenFlow 1.4)])
3893 AT_KEYWORDS([monitor])
3894 OVS_VSWITCHD_START
3895
3896 # Start a monitor, use the required protocol version
3897 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3898 AT_CAPTURE_FILE([monitor.log])
3899
3900 # Send twice an OpenFlow14 message (05), OFPT_BUNDLE_CONTROL (21), length (10), xid (0a)
3901 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
3902 ovs-appctl -t ovs-ofctl ofctl/barrier
3903 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
3904 ovs-appctl -t ovs-ofctl ofctl/barrier
3905 ovs-appctl -t ovs-ofctl exit
3906
3907 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3908 send: OFPT_BUNDLE_CONTROL (OF1.4):
3909  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
3910 OFPT_BUNDLE_CONTROL (OF1.4):
3911  bundle_id=0x1 type=OPEN_REPLY flags=0
3912 OFPT_BARRIER_REPLY (OF1.4):
3913 send: OFPT_BUNDLE_CONTROL (OF1.4):
3914  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
3915 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
3916 OFPT_BUNDLE_CONTROL (OF1.4):
3917  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
3918 OFPT_BARRIER_REPLY (OF1.4):
3919 ])
3920
3921 OVS_VSWITCHD_STOP
3922 AT_CLEANUP
3923
3924 AT_SETUP([ofproto - bundle close without open (OpenFlow 1.4)])
3925 AT_KEYWORDS([monitor])
3926 OVS_VSWITCHD_START
3927
3928 # Start a monitor, use the required protocol version
3929 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3930 AT_CAPTURE_FILE([monitor.log])
3931
3932 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 02"
3933 ovs-appctl -t ovs-ofctl ofctl/barrier
3934 ovs-appctl -t ovs-ofctl exit
3935
3936 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3937 send: OFPT_BUNDLE_CONTROL (OF1.4):
3938  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
3939 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
3940 OFPT_BUNDLE_CONTROL (OF1.4):
3941  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
3942 OFPT_BARRIER_REPLY (OF1.4):
3943 ])
3944
3945 OVS_VSWITCHD_STOP
3946 AT_CLEANUP
3947
3948 AT_SETUP([ofproto - bundle double close (OpenFlow 1.4)])
3949 AT_KEYWORDS([monitor])
3950 OVS_VSWITCHD_START
3951
3952 # Start a monitor, use the required protocol version
3953 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3954 AT_CAPTURE_FILE([monitor.log])
3955
3956 # Open, Close, Close
3957 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
3958 ovs-appctl -t ovs-ofctl ofctl/barrier
3959 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 02"
3960 ovs-appctl -t ovs-ofctl ofctl/barrier
3961 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 02"
3962 ovs-appctl -t ovs-ofctl ofctl/barrier
3963 ovs-appctl -t ovs-ofctl exit
3964
3965 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3966 send: OFPT_BUNDLE_CONTROL (OF1.4):
3967  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
3968 OFPT_BUNDLE_CONTROL (OF1.4):
3969  bundle_id=0x1 type=OPEN_REPLY flags=0
3970 OFPT_BARRIER_REPLY (OF1.4):
3971 send: OFPT_BUNDLE_CONTROL (OF1.4):
3972  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
3973 OFPT_BUNDLE_CONTROL (OF1.4):
3974  bundle_id=0x1 type=CLOSE_REPLY flags=0
3975 OFPT_BARRIER_REPLY (OF1.4):
3976 send: OFPT_BUNDLE_CONTROL (OF1.4):
3977  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
3978 OFPT_ERROR (OF1.4): OFPBFC_BUNDLE_CLOSED
3979 OFPT_BUNDLE_CONTROL (OF1.4):
3980  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
3981 OFPT_BARRIER_REPLY (OF1.4):
3982 ])
3983
3984 OVS_VSWITCHD_STOP
3985 AT_CLEANUP
3986
3987 AT_SETUP([ofproto - bundle close, different flags (OpenFlow 1.4)])
3988 AT_KEYWORDS([monitor])
3989 OVS_VSWITCHD_START
3990
3991 # Start a monitor, use the required protocol version
3992 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3993 AT_CAPTURE_FILE([monitor.log])
3994
3995 # Open, Close, Close
3996 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
3997 ovs-appctl -t ovs-ofctl ofctl/barrier
3998 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 01"
3999 ovs-appctl -t ovs-ofctl ofctl/barrier
4000 ovs-appctl -t ovs-ofctl exit
4001
4002 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4003 send: OFPT_BUNDLE_CONTROL (OF1.4):
4004  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4005 OFPT_BUNDLE_CONTROL (OF1.4):
4006  bundle_id=0x1 type=OPEN_REPLY flags=0
4007 OFPT_BARRIER_REPLY (OF1.4):
4008 send: OFPT_BUNDLE_CONTROL (OF1.4):
4009  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
4010 OFPT_ERROR (OF1.4): OFPBFC_BAD_FLAGS
4011 OFPT_BUNDLE_CONTROL (OF1.4):
4012  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
4013 OFPT_BARRIER_REPLY (OF1.4):
4014 ])
4015
4016 OVS_VSWITCHD_STOP
4017 AT_CLEANUP
4018
4019 AT_SETUP([ofproto - bundle commit without open (OpenFlow 1.4)])
4020 AT_KEYWORDS([monitor])
4021 OVS_VSWITCHD_START
4022
4023 # Start a monitor, use the required protocol version
4024 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4025 AT_CAPTURE_FILE([monitor.log])
4026
4027 # Open, Close, Close
4028 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 04 00 02"
4029 ovs-appctl -t ovs-ofctl ofctl/barrier
4030 ovs-appctl -t ovs-ofctl exit
4031
4032 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4033 send: OFPT_BUNDLE_CONTROL (OF1.4):
4034  bundle_id=0x1 type=COMMIT_REQUEST flags=ordered
4035 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
4036 OFPT_BUNDLE_CONTROL (OF1.4):
4037  bundle_id=0x1 type=COMMIT_REQUEST flags=ordered
4038 OFPT_BARRIER_REPLY (OF1.4):
4039 ])
4040
4041 OVS_VSWITCHD_STOP
4042 AT_CLEANUP
4043
4044 AT_SETUP([ofproto - bundle commit, different flags (OpenFlow 1.4)])
4045 AT_KEYWORDS([monitor])
4046 OVS_VSWITCHD_START
4047
4048 # Start a monitor, use the required protocol version
4049 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4050 AT_CAPTURE_FILE([monitor.log])
4051
4052 # Open, Close, Close
4053 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
4054 ovs-appctl -t ovs-ofctl ofctl/barrier
4055 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 04 00 01"
4056 ovs-appctl -t ovs-ofctl ofctl/barrier
4057 ovs-appctl -t ovs-ofctl exit
4058
4059 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4060 send: OFPT_BUNDLE_CONTROL (OF1.4):
4061  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
4062 OFPT_BUNDLE_CONTROL (OF1.4):
4063  bundle_id=0x1 type=OPEN_REPLY flags=0
4064 OFPT_BARRIER_REPLY (OF1.4):
4065 send: OFPT_BUNDLE_CONTROL (OF1.4):
4066  bundle_id=0x1 type=COMMIT_REQUEST flags=atomic
4067 OFPT_ERROR (OF1.4): OFPBFC_BAD_FLAGS
4068 OFPT_BUNDLE_CONTROL (OF1.4):
4069  bundle_id=0x1 type=COMMIT_REQUEST flags=atomic
4070 OFPT_BARRIER_REPLY (OF1.4):
4071 ])
4072
4073 OVS_VSWITCHD_STOP
4074 AT_CLEANUP
4075
4076 AT_SETUP([ofproto - bundle discard without open (OpenFlow 1.4)])
4077 AT_KEYWORDS([monitor])
4078 OVS_VSWITCHD_START
4079
4080 # Start a monitor, use the required protocol version
4081 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
4082 AT_CAPTURE_FILE([monitor.log])
4083
4084 # Open, Close, Close
4085 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 06 00 02"
4086 ovs-appctl -t ovs-ofctl ofctl/barrier
4087 ovs-appctl -t ovs-ofctl exit
4088
4089 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
4090 send: OFPT_BUNDLE_CONTROL (OF1.4):
4091  bundle_id=0x1 type=DISCARD_REQUEST flags=ordered
4092 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
4093 OFPT_BUNDLE_CONTROL (OF1.4):
4094  bundle_id=0x1 type=DISCARD_REQUEST flags=ordered
4095 OFPT_BARRIER_REPLY (OF1.4):
4096 ])
4097
4098 OVS_VSWITCHD_STOP
4099 AT_CLEANUP
4100
4101
4102 AT_SETUP([ofproto - bundle with multiple flow mods (OpenFlow 1.4)])
4103 AT_KEYWORDS([monitor])
4104 OVS_VSWITCHD_START
4105
4106 AT_CHECK([ovs-appctl vlog/set vconn:dbg])
4107
4108 AT_CHECK([ovs-ofctl del-flows br0])
4109
4110 AT_DATA([flows.txt], [dnl
4111 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=1
4112 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=2
4113 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=3
4114 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=4
4115 delete
4116 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=5
4117 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=6
4118 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=7
4119 delete in_port=2 dl_src=00:88:99:aa:bb:cc
4120 ])
4121
4122 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
4123
4124 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4125  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:5
4126  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:6
4127 NXST_FLOW reply:
4128 ])
4129
4130 AT_DATA([flows.txt], [dnl
4131 modify actions=drop
4132 modify_strict in_port=2 dl_src=00:77:88:99:aa:bb actions=7
4133 ])
4134
4135 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
4136
4137 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4138  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4139  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:7
4140 NXST_FLOW reply:
4141 ])
4142
4143 # Adding an existing flow acts as a modify, and delete_strict also works.
4144 AT_DATA([flows.txt], [dnl
4145 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=8
4146 delete_strict in_port=2 dl_src=00:66:77:88:99:aa
4147 add in_port=2 dl_src=00:66:77:88:99:aa actions=drop
4148 ])
4149
4150 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
4151
4152 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4153  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:8
4154  in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4155 NXST_FLOW reply:
4156 ])
4157
4158 dnl Check logs for OpenFlow trace
4159 # Prevent race.
4160 OVS_WAIT_UNTIL([cat ovs-vswitchd.log | vconn_sub | test `grep -- "|vconn|DBG|unix: sent (Success): NXST_FLOW reply" | wc -l` -ge 3])
4161 AT_CHECK([print_vconn_debug | vconn_sub | ofctl_strip], [0], [dnl
4162 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4163  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4164 vconn|DBG|unix: received: OFPT_HELLO:
4165  version bitmap: 0x01
4166 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4167 vconn|DBG|unix: received: OFPT_FLOW_MOD: DEL actions=drop
4168 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4169 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4170 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4171  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4172 vconn|DBG|unix: received: OFPT_HELLO (OF1.4):
4173  version bitmap: 0x05
4174 vconn|DBG|unix: negotiated OpenFlow version 0x05 (we support version 0x06 and earlier, peer supports version 0x05)
4175 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4176  bundle_id=0 type=OPEN_REQUEST flags=atomic ordered
4177 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4178  bundle_id=0 type=OPEN_REPLY flags=0
4179 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4180  bundle_id=0 flags=atomic ordered
4181 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:66:77:88:99:aa idle:50 actions=output:1
4182 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4183  bundle_id=0 flags=atomic ordered
4184 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:77:88:99:aa:bb idle:60 actions=output:2
4185 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4186  bundle_id=0 flags=atomic ordered
4187 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:88:99:aa:bb:cc idle:70 actions=output:3
4188 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4189  bundle_id=0 flags=atomic ordered
4190 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:66:77:88:99:aa idle:50 actions=output:4
4191 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4192  bundle_id=0 flags=atomic ordered
4193 OFPT_FLOW_MOD (OF1.4): DEL table:255 actions=drop
4194 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4195  bundle_id=0 flags=atomic ordered
4196 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:66:77:88:99:aa idle:50 actions=output:5
4197 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4198  bundle_id=0 flags=atomic ordered
4199 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:77:88:99:aa:bb idle:60 actions=output:6
4200 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4201  bundle_id=0 flags=atomic ordered
4202 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:88:99:aa:bb:cc idle:70 actions=output:7
4203 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4204  bundle_id=0 flags=atomic ordered
4205 OFPT_FLOW_MOD (OF1.4): DEL table:255 in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
4206 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4207  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4208 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4209  bundle_id=0 type=COMMIT_REPLY flags=0
4210 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4211  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4212 vconn|DBG|unix: received: OFPT_HELLO:
4213  version bitmap: 0x01
4214 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4215 vconn|DBG|unix: received: NXT_SET_FLOW_FORMAT: format=nxm
4216 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4217 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4218 vconn|DBG|unix: received: NXST_FLOW request:
4219 vconn|DBG|unix: sent (Success): NXST_FLOW reply:
4220  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:5
4221  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:6
4222 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4223  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4224 vconn|DBG|unix: received: OFPT_HELLO (OF1.4):
4225  version bitmap: 0x05
4226 vconn|DBG|unix: negotiated OpenFlow version 0x05 (we support version 0x06 and earlier, peer supports version 0x05)
4227 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4228  bundle_id=0 type=OPEN_REQUEST flags=atomic ordered
4229 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4230  bundle_id=0 type=OPEN_REPLY flags=0
4231 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4232  bundle_id=0 flags=atomic ordered
4233 OFPT_FLOW_MOD (OF1.4): MOD actions=drop
4234 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4235  bundle_id=0 flags=atomic ordered
4236 OFPT_FLOW_MOD (OF1.4): MOD_STRICT in_port=2,dl_src=00:77:88:99:aa:bb actions=output:7
4237 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4238  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4239 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4240  bundle_id=0 type=COMMIT_REPLY flags=0
4241 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4242  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4243 vconn|DBG|unix: received: OFPT_HELLO:
4244  version bitmap: 0x01
4245 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4246 vconn|DBG|unix: received: NXT_SET_FLOW_FORMAT: format=nxm
4247 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4248 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4249 vconn|DBG|unix: received: NXST_FLOW request:
4250 vconn|DBG|unix: sent (Success): NXST_FLOW reply:
4251  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4252  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:7
4253 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4254  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4255 vconn|DBG|unix: received: OFPT_HELLO (OF1.4):
4256  version bitmap: 0x05
4257 vconn|DBG|unix: negotiated OpenFlow version 0x05 (we support version 0x06 and earlier, peer supports version 0x05)
4258 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4259  bundle_id=0 type=OPEN_REQUEST flags=atomic ordered
4260 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4261  bundle_id=0 type=OPEN_REPLY flags=0
4262 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4263  bundle_id=0 flags=atomic ordered
4264 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:77:88:99:aa:bb idle:60 actions=output:8
4265 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4266  bundle_id=0 flags=atomic ordered
4267 OFPT_FLOW_MOD (OF1.4): DEL_STRICT table:255 in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4268 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4269  bundle_id=0 flags=atomic ordered
4270 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4271 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4272  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4273 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4274  bundle_id=0 type=COMMIT_REPLY flags=0
4275 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4276  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4277 vconn|DBG|unix: received: OFPT_HELLO:
4278  version bitmap: 0x01
4279 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4280 vconn|DBG|unix: received: NXT_SET_FLOW_FORMAT: format=nxm
4281 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4282 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4283 vconn|DBG|unix: received: NXST_FLOW request: 
4284 vconn|DBG|unix: sent (Success): NXST_FLOW reply:
4285  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:8
4286  in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4287 ])
4288
4289 OVS_VSWITCHD_STOP
4290 AT_CLEANUP
4291
4292
4293 AT_SETUP([ofproto - failing bundle commit (OpenFlow 1.4)])
4294 AT_KEYWORDS([monitor])
4295 OVS_VSWITCHD_START
4296
4297 AT_CHECK([ovs-ofctl del-flows br0])
4298
4299 ovs-ofctl add-flows br0 - <<EOF
4300 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=11
4301 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=22
4302 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=33
4303 EOF
4304 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4305  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:11
4306  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:22
4307  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=output:33
4308 NXST_FLOW reply:
4309 ])
4310
4311 # last line uses illegal table number (OVS internal table)
4312 AT_DATA([flows.txt], [dnl
4313 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=1
4314 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=2
4315 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=3
4316 modify idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=4
4317 delete
4318 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=5
4319 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=6
4320 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=7
4321 delete in_port=2 dl_src=00:88:99:aa:bb:cc
4322 add table=254 actions=drop
4323 ])
4324
4325 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt 2>&1 | sed '/|WARN|/d
4326 s/unix:.*br0\.mgmt/unix:br0.mgmt/' | sed 's/(.* error)/(error)/'],
4327 [0], [dnl
4328 OFPT_ERROR (OF1.4) (xid=0xb): OFPBRC_EPERM
4329 OFPT_FLOW_MOD (OF1.4) (xid=0xb): ADD table:254 actions=drop
4330 OFPT_ERROR (OF1.4) (xid=0xd): OFPBFC_MSG_FAILED
4331 OFPT_BUNDLE_CONTROL (OF1.4) (xid=0xd):
4332  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4333 ovs-ofctl: talking to unix:br0.mgmt (error)
4334 ])
4335
4336 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4337  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:11
4338  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:22
4339  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=output:33
4340 NXST_FLOW reply:
4341 ])
4342
4343 OVS_VSWITCHD_STOP
4344 AT_CLEANUP