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