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