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