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