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