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