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