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