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