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