Add connection tracking label support.
[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 head_table() {
1311     printf 'OFPST_TABLE reply (xid=0x2):
1312   table 0 ("%s"):
1313     active=0, lookup=0, matched=0
1314     max_entries=1000000
1315     matching:
1316       in_port: exact match or wildcard
1317       eth_src: exact match or wildcard
1318       eth_dst: exact match or wildcard
1319       eth_type: exact match or wildcard
1320       vlan_vid: exact match or wildcard
1321       vlan_pcp: exact match or wildcard
1322       ip_src: exact match or wildcard
1323       ip_dst: exact match or wildcard
1324       nw_proto: exact match or wildcard
1325       nw_tos: exact match or wildcard
1326       tcp_src: exact match or wildcard
1327       tcp_dst: exact match or wildcard
1328
1329 ' $1
1330 }
1331 ditto() {
1332     for i in `seq $1 $2`; do
1333         printf '  table %d ("table%d"): ditto\n' $i $i
1334     done
1335 }
1336 (head_table classifier; ditto 1 253) > expout
1337 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
1338 # Change the configuration.
1339 AT_CHECK(
1340   [ovs-vsctl \
1341      -- --id=@t0 create Flow_Table name=main \
1342      -- --id=@t1 create Flow_Table flow-limit=1024 \
1343      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
1344    | ${PERL} $srcdir/uuidfilt.pl],
1345   [0], [<0>
1346 <1>
1347 ])
1348 # Check that the configuration was updated.
1349 (head_table main; echo '  table 1 ("table1"):
1350     active=0, lookup=0, matched=0
1351     max_entries=1024
1352     (same matching)
1353
1354   table 2 ("table2"):
1355     active=0, lookup=0, matched=0
1356     max_entries=1000000
1357     (same matching)
1358 '; ditto 3 253) > expout
1359 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
1360 OVS_VSWITCHD_STOP
1361 AT_CLEANUP
1362
1363 dnl In-band and fail-open add "hidden rules" to table 0.  These rules shouldn't
1364 dnl be visible to OpenFlow.  This test checks that "dump-flows" and
1365 dnl "dump-tables" don't make them visible.
1366 AT_SETUP([ofproto - hidden rules not in table stats])
1367 # Use an IP address for a controller that won't actually exist: we
1368 # want to create in-band rules but we do not want to actually connect
1369 # to a controller (because that could mess about with our test).  The
1370 # Class E range 240.0.0.0 - 255.255.255.255 seems like a good choice.
1371 OVS_VSWITCHD_START([set-controller br0 tcp:240.0.0.1:6653])
1372 for i in 1 2 3 4 5; do ovs-appctl time/warp 1000; done
1373
1374 # Check that no hidden flows are visible in OpenFlow.
1375 AT_CHECK([ovs-ofctl dump-flows br0], [0], [NXST_FLOW reply (xid=0x4):
1376 ])
1377
1378 # Check that some hidden flows related to 240.0.0.1 are actually in table 0.
1379 #
1380 # We discard flows that mention table_id because we only want table 0 flows,
1381 # which in OVS is implied by the absence of a table_id.
1382 AT_CHECK([ovs-appctl bridge/dump-flows br0], [0], [stdout])
1383 AT_CHECK([test `grep '240\.0\.0\.1' stdout | grep -v table_id= | wc -l` -gt 0])
1384
1385 # Check that dump-tables doesn't count the hidden flows.
1386 head_table() {
1387     printf 'OFPST_TABLE reply (xid=0x2):
1388   table 0 ("%s"):
1389     active=0, lookup=0, matched=0
1390     max_entries=1000000
1391     matching:
1392       in_port: exact match or wildcard
1393       eth_src: exact match or wildcard
1394       eth_dst: exact match or wildcard
1395       eth_type: exact match or wildcard
1396       vlan_vid: exact match or wildcard
1397       vlan_pcp: exact match or wildcard
1398       ip_src: exact match or wildcard
1399       ip_dst: exact match or wildcard
1400       nw_proto: exact match or wildcard
1401       nw_tos: exact match or wildcard
1402       tcp_src: exact match or wildcard
1403       tcp_dst: exact match or wildcard
1404
1405 ' $1
1406 }
1407 ditto() {
1408     for i in `seq $1 $2`; do
1409         printf '  table %d ("table%d"): ditto\n' $i $i
1410     done
1411 }
1412 (head_table classifier; ditto 1 253) > expout
1413 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
1414 OVS_VSWITCHD_STOP(["/240\.0\.0\.1/d"])
1415 AT_CLEANUP
1416
1417 AT_SETUP([ofproto - flow table configuration (OpenFlow 1.2)])
1418 OVS_VSWITCHD_START
1419 # Check the default configuration.
1420 head_table() {
1421     printf 'OFPST_TABLE reply (OF1.2) (xid=0x2):
1422   table 0 ("%s"):
1423     active=0, lookup=0, matched=0
1424     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1425     config=controller
1426     max_entries=1000000
1427     instructions (table miss and others):
1428       instructions: apply_actions,clear_actions,write_actions,write_metadata,goto_table
1429       Write-Actions and Apply-Actions features:
1430         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
1431         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
1432     matching:
1433       metadata: exact match or wildcard
1434       in_port_oxm: exact match or wildcard
1435       eth_src: exact match or wildcard
1436       eth_dst: exact match or wildcard
1437       eth_type: exact match or wildcard
1438       vlan_vid: exact match or wildcard
1439       vlan_pcp: exact match or wildcard
1440       mpls_label: exact match or wildcard
1441       mpls_tc: exact match or wildcard
1442       ip_src: exact match or wildcard
1443       ip_dst: exact match or wildcard
1444       ipv6_src: exact match or wildcard
1445       ipv6_dst: exact match or wildcard
1446       ipv6_label: exact match or wildcard
1447       nw_proto: exact match or wildcard
1448       ip_dscp: exact match or wildcard
1449       nw_ecn: exact match or wildcard
1450       arp_op: exact match or wildcard
1451       arp_spa: exact match or wildcard
1452       arp_tpa: exact match or wildcard
1453       arp_sha: exact match or wildcard
1454       arp_tha: exact match or wildcard
1455       tcp_src: exact match or wildcard
1456       tcp_dst: exact match or wildcard
1457       udp_src: exact match or wildcard
1458       udp_dst: exact match or wildcard
1459       sctp_src: exact match or wildcard
1460       sctp_dst: exact match or wildcard
1461       icmp_type: exact match or wildcard
1462       icmp_code: exact match or wildcard
1463       icmpv6_type: exact match or wildcard
1464       icmpv6_code: exact match or wildcard
1465       nd_target: exact match or wildcard
1466       nd_sll: exact match or wildcard
1467       nd_tll: exact match or wildcard
1468
1469 ' $1
1470 }
1471 ditto() {
1472     for i in `seq $1 $2`; do
1473         printf '  table %d ("table%d"): ditto\n' $i $i
1474     done
1475 }
1476 tail_table() {
1477     printf '  table 253 ("table253"):
1478     active=0, lookup=0, matched=0
1479     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1480     config=controller
1481     max_entries=1000000
1482     instructions (table miss and others):
1483       instructions: apply_actions,clear_actions,write_actions,write_metadata
1484       (same actions)
1485     (same matching)
1486 '
1487 }
1488 (head_table classifier; ditto 1 252; tail_table) > expout
1489 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
1490 # Change the configuration.
1491 AT_CHECK(
1492   [ovs-vsctl \
1493      -- --id=@t0 create Flow_Table name=main \
1494      -- --id=@t1 create Flow_Table flow-limit=1024 \
1495      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
1496    | ${PERL} $srcdir/uuidfilt.pl],
1497   [0], [<0>
1498 <1>
1499 ])
1500 # Check that the configuration was updated.
1501 (head_table main; echo '  table 1 ("table1"):
1502     active=0, lookup=0, matched=0
1503     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1504     config=controller
1505     max_entries=1024
1506     (same instructions)
1507     (same matching)
1508
1509   table 2 ("table2"):
1510     active=0, lookup=0, matched=0
1511     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1512     config=controller
1513     max_entries=1000000
1514     (same instructions)
1515     (same matching)
1516 '; ditto 3 252; tail_table) > expout
1517 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
1518 OVS_VSWITCHD_STOP
1519 AT_CLEANUP
1520
1521 AT_SETUP([ofproto - table features (OpenFlow 1.3)])
1522 OVS_VSWITCHD_START
1523 head_table () {
1524     printf '  table 0 ("%s"):
1525     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1526     max_entries=1000000
1527     instructions (table miss and others):
1528       next tables: 1-253
1529       instructions: meter,apply_actions,clear_actions,write_actions,write_metadata,goto_table
1530       Write-Actions and Apply-Actions features:
1531         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
1532         supported on Set-Field: tun_id tun_src tun_dst tun_flags tun_gbp_id tun_gbp_flags tun_metadata0 dnl
1533 tun_metadata1 tun_metadata2 tun_metadata3 tun_metadata4 tun_metadata5 tun_metadata6 tun_metadata7 tun_metadata8 tun_metadata9 tun_metadata10 tun_metadata11 tun_metadata12 tun_metadata13 tun_metadata14 tun_metadata15 tun_metadata16 tun_metadata17 tun_metadata18 tun_metadata19 tun_metadata20 tun_metadata21 tun_metadata22 tun_metadata23 tun_metadata24 tun_metadata25 tun_metadata26 tun_metadata27 tun_metadata28 tun_metadata29 tun_metadata30 tun_metadata31 tun_metadata32 tun_metadata33 tun_metadata34 tun_metadata35 tun_metadata36 tun_metadata37 tun_metadata38 tun_metadata39 tun_metadata40 tun_metadata41 tun_metadata42 tun_metadata43 tun_metadata44 tun_metadata45 tun_metadata46 tun_metadata47 tun_metadata48 tun_metadata49 tun_metadata50 tun_metadata51 tun_metadata52 tun_metadata53 tun_metadata54 tun_metadata55 tun_metadata56 tun_metadata57 tun_metadata58 tun_metadata59 tun_metadata60 tun_metadata61 tun_metadata62 tun_metadata63 dnl
1534 metadata in_port in_port_oxm pkt_mark ct_mark ct_label reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 xreg0 xreg1 xreg2 xreg3 eth_src eth_dst vlan_tci vlan_vid vlan_pcp mpls_label mpls_tc ip_src ip_dst ipv6_src ipv6_dst ipv6_label nw_tos ip_dscp nw_ecn nw_ttl arp_op arp_spa arp_tpa arp_sha arp_tha tcp_src tcp_dst udp_src udp_dst sctp_src sctp_dst nd_target nd_sll nd_tll
1535     matching:
1536       dp_hash: arbitrary mask
1537       recirc_id: exact match or wildcard
1538       conj_id: exact match or wildcard
1539       tun_id: arbitrary mask
1540       tun_src: arbitrary mask
1541       tun_dst: arbitrary mask
1542       tun_flags: arbitrary mask
1543       tun_gbp_id: arbitrary mask
1544       tun_gbp_flags: arbitrary mask
1545       tun_metadata0: arbitrary mask
1546       tun_metadata1: arbitrary mask
1547       tun_metadata2: arbitrary mask
1548       tun_metadata3: arbitrary mask
1549       tun_metadata4: arbitrary mask
1550       tun_metadata5: arbitrary mask
1551       tun_metadata6: arbitrary mask
1552       tun_metadata7: arbitrary mask
1553       tun_metadata8: arbitrary mask
1554       tun_metadata9: arbitrary mask
1555       tun_metadata10: arbitrary mask
1556       tun_metadata11: arbitrary mask
1557       tun_metadata12: arbitrary mask
1558       tun_metadata13: arbitrary mask
1559       tun_metadata14: arbitrary mask
1560       tun_metadata15: arbitrary mask
1561       tun_metadata16: arbitrary mask
1562       tun_metadata17: arbitrary mask
1563       tun_metadata18: arbitrary mask
1564       tun_metadata19: arbitrary mask
1565       tun_metadata20: arbitrary mask
1566       tun_metadata21: arbitrary mask
1567       tun_metadata22: arbitrary mask
1568       tun_metadata23: arbitrary mask
1569       tun_metadata24: arbitrary mask
1570       tun_metadata25: arbitrary mask
1571       tun_metadata26: arbitrary mask
1572       tun_metadata27: arbitrary mask
1573       tun_metadata28: arbitrary mask
1574       tun_metadata29: arbitrary mask
1575       tun_metadata30: arbitrary mask
1576       tun_metadata31: arbitrary mask
1577       tun_metadata32: arbitrary mask
1578       tun_metadata33: arbitrary mask
1579       tun_metadata34: arbitrary mask
1580       tun_metadata35: arbitrary mask
1581       tun_metadata36: arbitrary mask
1582       tun_metadata37: arbitrary mask
1583       tun_metadata38: arbitrary mask
1584       tun_metadata39: arbitrary mask
1585       tun_metadata40: arbitrary mask
1586       tun_metadata41: arbitrary mask
1587       tun_metadata42: arbitrary mask
1588       tun_metadata43: arbitrary mask
1589       tun_metadata44: arbitrary mask
1590       tun_metadata45: arbitrary mask
1591       tun_metadata46: arbitrary mask
1592       tun_metadata47: arbitrary mask
1593       tun_metadata48: arbitrary mask
1594       tun_metadata49: arbitrary mask
1595       tun_metadata50: arbitrary mask
1596       tun_metadata51: arbitrary mask
1597       tun_metadata52: arbitrary mask
1598       tun_metadata53: arbitrary mask
1599       tun_metadata54: arbitrary mask
1600       tun_metadata55: arbitrary mask
1601       tun_metadata56: arbitrary mask
1602       tun_metadata57: arbitrary mask
1603       tun_metadata58: arbitrary mask
1604       tun_metadata59: arbitrary mask
1605       tun_metadata60: arbitrary mask
1606       tun_metadata61: arbitrary mask
1607       tun_metadata62: arbitrary mask
1608       tun_metadata63: arbitrary mask
1609       metadata: arbitrary mask
1610       in_port: exact match or wildcard
1611       in_port_oxm: exact match or wildcard
1612       actset_output: exact match or wildcard
1613       pkt_mark: arbitrary mask
1614       ct_state: arbitrary mask
1615       ct_zone: exact match or wildcard
1616       ct_mark: arbitrary mask
1617       ct_label: arbitrary mask
1618       reg0: arbitrary mask
1619       reg1: arbitrary mask
1620       reg2: arbitrary mask
1621       reg3: arbitrary mask
1622       reg4: arbitrary mask
1623       reg5: arbitrary mask
1624       reg6: arbitrary mask
1625       reg7: arbitrary mask
1626       xreg0: arbitrary mask
1627       xreg1: arbitrary mask
1628       xreg2: arbitrary mask
1629       xreg3: arbitrary mask
1630       eth_src: arbitrary mask
1631       eth_dst: arbitrary mask
1632       eth_type: exact match or wildcard
1633       vlan_tci: arbitrary mask
1634       vlan_vid: arbitrary mask
1635       vlan_pcp: exact match or wildcard
1636       mpls_label: exact match or wildcard
1637       mpls_tc: exact match or wildcard
1638       mpls_bos: exact match or wildcard
1639       ip_src: arbitrary mask
1640       ip_dst: arbitrary mask
1641       ipv6_src: arbitrary mask
1642       ipv6_dst: arbitrary mask
1643       ipv6_label: arbitrary mask
1644       nw_proto: exact match or wildcard
1645       nw_tos: exact match or wildcard
1646       ip_dscp: exact match or wildcard
1647       nw_ecn: exact match or wildcard
1648       nw_ttl: exact match or wildcard
1649       ip_frag: arbitrary mask
1650       arp_op: exact match or wildcard
1651       arp_spa: arbitrary mask
1652       arp_tpa: arbitrary mask
1653       arp_sha: arbitrary mask
1654       arp_tha: arbitrary mask
1655       tcp_src: arbitrary mask
1656       tcp_dst: arbitrary mask
1657       tcp_flags: arbitrary mask
1658       udp_src: arbitrary mask
1659       udp_dst: arbitrary mask
1660       sctp_src: arbitrary mask
1661       sctp_dst: arbitrary mask
1662       icmp_type: exact match or wildcard
1663       icmp_code: exact match or wildcard
1664       icmpv6_type: exact match or wildcard
1665       icmpv6_code: exact match or wildcard
1666       nd_target: arbitrary mask
1667       nd_sll: arbitrary mask
1668       nd_tll: arbitrary mask
1669
1670 ' $1
1671 }
1672 ditto() {
1673     printf '  table %d ("%s"):
1674     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1675     max_entries=%d
1676     instructions (table miss and others):
1677       next tables: %d-253
1678       (same instructions)
1679       (same actions)
1680     (same matching)
1681
1682 ' $1 $2 $3 `expr $1 + 1`
1683 }
1684 tail_tables() {
1685 echo '  table 252 ("table252"):
1686     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1687     max_entries=1000000
1688     instructions (table miss and others):
1689       next tables: 253
1690       (same instructions)
1691       (same actions)
1692     (same matching)
1693
1694   table 253 ("table253"):
1695     metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1696     max_entries=1000000
1697     instructions (table miss and others):
1698       instructions: meter,apply_actions,clear_actions,write_actions,write_metadata
1699       (same actions)
1700     (same matching)
1701 '
1702 }
1703 (head_table classifier
1704  for i in `seq 1 251`; do
1705      ditto $i table$i 1000000
1706  done
1707  tail_tables) > expout
1708 AT_CHECK([ovs-ofctl -O OpenFlow13 dump-table-features br0], [0], [expout])
1709 # Change the configuration.
1710 AT_CHECK(
1711   [ovs-vsctl \
1712      -- --id=@t0 create Flow_Table name=main \
1713      -- --id=@t1 create Flow_Table flow-limit=1024 \
1714      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
1715    | ${PERL} $srcdir/uuidfilt.pl],
1716   [0], [<0>
1717 <1>
1718 ])
1719 # Check that the configuration was updated.
1720 (head_table main
1721  ditto 1 table1 1024
1722  for i in `seq 2 251`; do
1723      ditto $i table$i 1000000
1724  done
1725  tail_tables) > expout
1726 AT_CHECK([ovs-ofctl -O OpenFlow13 dump-table-features br0], [0], [expout])
1727 OVS_VSWITCHD_STOP
1728 AT_CLEANUP
1729
1730 AT_SETUP([ofproto - table description (OpenFlow 1.4)])
1731 OVS_VSWITCHD_START
1732 (x=0
1733  while test $x -lt 254; do
1734    y=`expr $x + 1`
1735    echo "  table $x:
1736    eviction=off eviction_flags=OTHER|IMPORTANCE|LIFETIME"
1737    x=$y
1738  done) > expout
1739 AT_CHECK([ovs-ofctl -O OpenFlow14 dump-table-desc br0 | sed '/^$/d
1740 /^OFPST_TABLE_DESC/d'], [0], [expout])
1741
1742 # Change the configuration.
1743 AT_CHECK([ovs-ofctl -O Openflow14 mod-table br0 0 evict])
1744 # Check that the configuration was updated.
1745 mv expout orig-expout
1746 sed -e '2s/eviction=off/eviction=on/' <orig-expout > expout
1747 AT_CHECK([ovs-ofctl -O OpenFlow14 dump-table-desc br0 | sed '/^$/d
1748 /^OFPST_TABLE_DESC/d'], [0], [expout])
1749 OVS_VSWITCHD_STOP
1750 AT_CLEANUP
1751
1752 AT_SETUP([ofproto - hard limits on flow table size (OpenFlow 1.0)])
1753 OVS_VSWITCHD_START
1754 # Configure a maximum of 4 flows.
1755 AT_CHECK(
1756   [ovs-vsctl \
1757      -- --id=@t0 create Flow_Table flow-limit=4 \
1758      -- set bridge br0 flow_tables:0=@t0 \
1759    | ${PERL} $srcdir/uuidfilt.pl],
1760   [0], [<0>
1761 ])
1762 # Add 4 flows.
1763 for in_port in 1 2 3 4; do
1764     ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
1765 done
1766 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1767  in_port=1 actions=drop
1768  in_port=2 actions=drop
1769  in_port=3 actions=drop
1770  in_port=4 actions=drop
1771 NXST_FLOW reply:
1772 ])
1773 # Adding another flow will be refused.
1774 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
1775 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1776   [OFPT_ERROR: OFPFMFC_TABLE_FULL
1777 ])
1778 # Also a mod-flow that would add a flow will be refused.
1779 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
1780 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1781   [OFPT_ERROR: OFPFMFC_TABLE_FULL
1782 ])
1783 # Replacing or modifying an existing flow is allowed.
1784 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
1785 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
1786 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1787  in_port=1 actions=drop
1788  in_port=2 actions=drop
1789  in_port=3 actions=output:1
1790  in_port=4 actions=NORMAL
1791 NXST_FLOW reply:
1792 ])
1793 OVS_VSWITCHD_STOP
1794 AT_CLEANUP
1795
1796 AT_SETUP([ofproto - hard limits on flow table size (OpenFlow 1.2)])
1797 OVS_VSWITCHD_START
1798 # Configure a maximum of 4 flows.
1799 AT_CHECK(
1800   [ovs-vsctl \
1801      -- --id=@t0 create Flow_Table flow-limit=4 \
1802      -- set bridge br0 flow_tables:0=@t0 \
1803    | ${PERL} $srcdir/uuidfilt.pl],
1804   [0], [<0>
1805 ])
1806 # Add 4 flows.
1807 for in_port in 1 2 3 4; do
1808     ovs-ofctl -O OpenFlow12 add-flow br0 in_port=$in_port,actions=drop
1809 done
1810 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1811  in_port=1 actions=drop
1812  in_port=2 actions=drop
1813  in_port=3 actions=drop
1814  in_port=4 actions=drop
1815 OFPST_FLOW reply (OF1.2):
1816 ])
1817 # Adding another flow will be refused.
1818 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
1819 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1820   [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
1821 ])
1822 # Replacing or modifying an existing flow is allowed.
1823 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
1824 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
1825 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1826  in_port=1 actions=drop
1827  in_port=2 actions=drop
1828  in_port=3 actions=output:1
1829  in_port=4 actions=NORMAL
1830 OFPST_FLOW reply (OF1.2):
1831 ])
1832 OVS_VSWITCHD_STOP
1833 AT_CLEANUP
1834
1835 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.0)])
1836 OVS_VSWITCHD_START
1837 # Configure a maximum of 4 flows.
1838 AT_CHECK(
1839   [ovs-vsctl \
1840      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
1841      -- set bridge br0 flow_tables:0=@t0 \
1842    | ${PERL} $srcdir/uuidfilt.pl],
1843   [0], [<0>
1844 ])
1845 # Add 4 flows.
1846 for in_port in 4 3 2 1; do
1847     ovs-ofctl add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
1848 done
1849 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1850  idle_timeout=10, in_port=1 actions=drop
1851  idle_timeout=20, in_port=2 actions=drop
1852  idle_timeout=30, in_port=3 actions=drop
1853  idle_timeout=40, in_port=4 actions=drop
1854 NXST_FLOW reply:
1855 ])
1856 # Adding another flow will cause the one that expires soonest to be evicted.
1857 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
1858 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1859  idle_timeout=20, in_port=2 actions=drop
1860  idle_timeout=30, in_port=3 actions=drop
1861  idle_timeout=40, in_port=4 actions=drop
1862  in_port=5 actions=drop
1863 NXST_FLOW reply:
1864 ])
1865 # A mod-flow that adds a flow also causes eviction, but replacing or
1866 # modifying an existing flow doesn't.
1867 AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
1868 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
1869 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
1870 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1871  idle_timeout=30, in_port=3 actions=output:1
1872  in_port=4 actions=NORMAL
1873  in_port=5 actions=drop
1874  in_port=6 actions=drop
1875 NXST_FLOW reply:
1876 ])
1877 # Flows with no timeouts at all cannot be evicted.
1878 AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
1879 AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
1880 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1881   [OFPT_ERROR: OFPFMFC_TABLE_FULL
1882 ])
1883 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1884  in_port=4 actions=NORMAL
1885  in_port=5 actions=drop
1886  in_port=6 actions=drop
1887  in_port=7 actions=NORMAL
1888 NXST_FLOW reply:
1889 ])
1890 OVS_VSWITCHD_STOP
1891 AT_CLEANUP
1892
1893 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.2)])
1894 OVS_VSWITCHD_START
1895 # Configure a maximum of 4 flows.
1896 AT_CHECK(
1897   [ovs-vsctl \
1898      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
1899      -- set bridge br0 flow_tables:0=@t0 \
1900    | ${PERL} $srcdir/uuidfilt.pl],
1901   [0], [<0>
1902 ])
1903 # Add 4 flows.
1904 for in_port in 4 3 2 1; do
1905     ovs-ofctl -O OpenFlow12 add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
1906 done
1907 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1908  idle_timeout=10, in_port=1 actions=drop
1909  idle_timeout=20, in_port=2 actions=drop
1910  idle_timeout=30, in_port=3 actions=drop
1911  idle_timeout=40, in_port=4 actions=drop
1912 OFPST_FLOW reply (OF1.2):
1913 ])
1914 # Adding another flow will cause the one that expires soonest to be evicted.
1915 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop])
1916 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1917  idle_timeout=20, in_port=2 actions=drop
1918  idle_timeout=30, in_port=3 actions=drop
1919  idle_timeout=40, in_port=4 actions=drop
1920  in_port=5 actions=drop
1921 OFPST_FLOW reply (OF1.2):
1922 ])
1923 # In OpenFlow 1.2 a mod-flow does not ever add a flow and thus
1924 # has no effect on eviction
1925 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=6,actions=drop])
1926 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
1927 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
1928 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1929  idle_timeout=20, in_port=2 actions=drop
1930  idle_timeout=30, in_port=3 actions=output:1
1931  in_port=4 actions=NORMAL
1932  in_port=5 actions=drop
1933 OFPST_FLOW reply (OF1.2):
1934 ])
1935 # Flows with no timeouts at all cannot be evicted.
1936 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=6,actions=drop])
1937 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=7,actions=normal])
1938 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
1939 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1940   [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
1941 ])
1942 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1943  in_port=4 actions=NORMAL
1944  in_port=5 actions=drop
1945  in_port=6 actions=drop
1946  in_port=7 actions=NORMAL
1947 OFPST_FLOW reply (OF1.2):
1948 ])
1949 OVS_VSWITCHD_STOP
1950 AT_CLEANUP
1951
1952 AT_SETUP([ofproto - eviction using importance upon table overflow (OpenFlow 1.4)])
1953 OVS_VSWITCHD_START
1954 # Configure a maximum of 4 flows.
1955 AT_CHECK(
1956   [ovs-vsctl \
1957      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
1958      -- set bridge br0 flow_tables:0=@t0 \
1959    | ${PERL} $srcdir/uuidfilt.pl],
1960   [0], [<0>
1961 ])
1962 # Use mod-table to turn on eviction just to demonstrate that it works.
1963 AT_CHECK([ovs-ofctl -O OpenFlow14 mod-table br0 0 evict])
1964 # Add 4 flows.
1965 for in_port in 4 3 2 1; do
1966     ovs-ofctl -O Openflow14 add-flow br0 importance=$((in_port + 30)),priority=$((in_port + 5)),hard_timeout=$((in_port + 500)),actions=drop
1967 done
1968 AT_CHECK([ovs-ofctl -O Openflow14 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1969  hard_timeout=501, importance=31, priority=6 actions=drop
1970  hard_timeout=502, importance=32, priority=7 actions=drop
1971  hard_timeout=503, importance=33, priority=8 actions=drop
1972  hard_timeout=504, importance=34, priority=9 actions=drop
1973 OFPST_FLOW reply (OF1.4):
1974 ])
1975 # Adding another flow will cause the one with lowest importance to be evicted.
1976 AT_CHECK([ovs-ofctl -O Openflow14 add-flow br0 hard_timeout=505,importance=35,priority=10,in_port=2,actions=drop])
1977 AT_CHECK([ovs-ofctl -O Openflow14 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1978  hard_timeout=502, importance=32, priority=7 actions=drop
1979  hard_timeout=503, importance=33, priority=8 actions=drop
1980  hard_timeout=504, importance=34, priority=9 actions=drop
1981  hard_timeout=505, importance=35, priority=10,in_port=2 actions=drop
1982 OFPST_FLOW reply (OF1.4):
1983 ])
1984 # Disable the Eviction configuration.
1985 AT_CHECK([ovs-ofctl -O OpenFlow14 mod-table br0 0 noevict])
1986 # Adding another flow will cause the system to give error for FULL TABLE.
1987 AT_CHECK([ovs-ofctl -O Openflow14 add-flow br0 hard_timeout=506,importance=36,priority=11,actions=drop],[1], [], [stderr])
1988 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1989  [OFPT_ERROR (OF1.4): OFPFMFC_TABLE_FULL
1990 ])
1991 #Dump flows. It should show only the old values
1992 AT_CHECK([ovs-ofctl -O Openflow14 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1993  hard_timeout=502, importance=32, priority=7 actions=drop
1994  hard_timeout=503, importance=33, priority=8 actions=drop
1995  hard_timeout=504, importance=34, priority=9 actions=drop
1996  hard_timeout=505, importance=35, priority=10,in_port=2 actions=drop
1997 OFPST_FLOW reply (OF1.4):
1998 ])
1999 # mod-flow that would modify a flow will be done successfully.
2000 AT_CHECK([ovs-ofctl -O Openflow14 mod-flows br0 in_port=2,actions=NORMAL])
2001 AT_CHECK([ovs-ofctl -O Openflow14 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2002  hard_timeout=502, importance=32, priority=7 actions=drop
2003  hard_timeout=503, importance=33, priority=8 actions=drop
2004  hard_timeout=504, importance=34, priority=9 actions=drop
2005  hard_timeout=505, importance=35, priority=10,in_port=2 actions=NORMAL
2006 OFPST_FLOW reply (OF1.4):
2007 ])
2008 # Also a mod-flow that would add a flow will be refused.
2009 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
2010 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
2011   [OFPT_ERROR: OFPFMFC_TABLE_FULL
2012 ])
2013 OVS_VSWITCHD_STOP
2014 AT_CLEANUP
2015
2016 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.0)])
2017 OVS_VSWITCHD_START
2018 # Configure a maximum of 4 flows.
2019 AT_CHECK(
2020   [ovs-vsctl \
2021      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
2022                                    overflow-policy=evict \
2023                                    groups='"NXM_OF_IN_PORT[[]]"' \
2024      -- set bridge br0 flow_tables:0=@t0 \
2025    | ${PERL} $srcdir/uuidfilt.pl],
2026   [0], [<0>
2027 ])
2028 # Add 4 flows.
2029 ovs-ofctl add-flows br0 - <<EOF
2030 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
2031 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
2032 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
2033 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
2034 EOF
2035 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2036  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2037  idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
2038  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2039  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2040 NXST_FLOW reply:
2041 ])
2042 # Adding another flow will cause the one that expires soonest within
2043 # the largest group (those with in_port=1) to be evicted.  In this
2044 # case this is not the same as the one that expires soonest overall
2045 # (which is what makes the test interesting):
2046 AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
2047 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2048  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2049  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2050  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2051  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2052 NXST_FLOW reply:
2053 ])
2054 # Enlarge the flow limit, change the eviction policy back to strictly
2055 # based on expiration, and and add some flows.
2056 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
2057 ovs-ofctl add-flows br0 - <<EOF
2058 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
2059 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
2060 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
2061 EOF
2062 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2063  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2064  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2065  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2066  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
2067  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2068  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2069  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2070 NXST_FLOW reply:
2071 ])
2072 # Adding another flow will cause the one that expires soonest overall
2073 # to be evicted.
2074 AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
2075 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2076  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2077  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2078  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
2079  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2080  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2081  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
2082  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2083 NXST_FLOW reply:
2084 ])
2085 # Reducing the flow limit also causes the flows that expire soonest
2086 # overall to be evicted.
2087 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
2088 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2089  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2090  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2091  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
2092  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2093 NXST_FLOW reply:
2094 ])
2095 OVS_VSWITCHD_STOP
2096 AT_CLEANUP
2097
2098 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.2)])
2099 OVS_VSWITCHD_START
2100 # Configure a maximum of 4 flows.
2101 AT_CHECK(
2102   [ovs-vsctl \
2103      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
2104                                    overflow-policy=evict \
2105                                    groups='"NXM_OF_IN_PORT[[]]"' \
2106      -- set bridge br0 flow_tables:0=@t0 \
2107    | ${PERL} $srcdir/uuidfilt.pl],
2108   [0], [<0>
2109 ])
2110 # Add 4 flows.
2111 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
2112 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
2113 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
2114 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
2115 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
2116 EOF
2117 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2118  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2119  idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
2120  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2121  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2122 OFPST_FLOW reply (OF1.2):
2123 ])
2124 # Adding another flow will cause the one that expires soonest within
2125 # the largest group (those with in_port=1) to be evicted.  In this
2126 # case this is not the same as the one that expires soonest overall
2127 # (which is what makes the test interesting):
2128 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
2129 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2130  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2131  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2132  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2133  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2134 OFPST_FLOW reply (OF1.2):
2135 ])
2136 # Enlarge the flow limit, change the eviction policy back to strictly
2137 # based on expiration, and and add some flows.
2138 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
2139 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
2140 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
2141 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
2142 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
2143 EOF
2144 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2145  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
2146  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2147  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2148  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
2149  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2150  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2151  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2152 OFPST_FLOW reply (OF1.2):
2153 ])
2154 # Adding another flow will cause the one that expires soonest overall
2155 # to be evicted.
2156 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'])
2157 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2158  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
2159  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
2160  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
2161  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2162  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2163  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
2164  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2165 OFPST_FLOW reply (OF1.2):
2166 ])
2167 # Reducing the flow limit also causes the flows that expire soonest
2168 # overall to be evicted.
2169 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
2170 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
2171  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
2172  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
2173  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
2174  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
2175 OFPST_FLOW reply (OF1.2):
2176 ])
2177 OVS_VSWITCHD_STOP
2178 AT_CLEANUP
2179
2180 AT_SETUP([ofproto - eviction upon table overflow, with modified hard timeout])
2181 OVS_VSWITCHD_START
2182 # Configure a maximum of 4 flows.
2183 AT_CHECK(
2184   [ovs-vsctl \
2185      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
2186      -- set bridge br0 flow_tables:0=@t0 \
2187    | ${PERL} $srcdir/uuidfilt.pl],
2188   [0], [<0>
2189 ])
2190 ovs-appctl time/stop
2191 # Add 4 flows.
2192 for in_port in 4 3 2 1; do
2193     ovs-ofctl add-flow br0 hard_timeout=$((10 + in_port * 3)),in_port=$in_port,actions=drop
2194 done
2195 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2196  hard_timeout=13, in_port=1 actions=drop
2197  hard_timeout=16, in_port=2 actions=drop
2198  hard_timeout=19, in_port=3 actions=drop
2199  hard_timeout=22, in_port=4 actions=drop
2200 NXST_FLOW reply:
2201 ])
2202 # Sleep and modify the one that expires soonest
2203 ovs-appctl time/warp 5000
2204 AT_CHECK([ovs-ofctl mod-flows br0 in_port=1,actions=drop])
2205 # At this point the table would looks like:
2206 #  in_port   seconds to expire
2207 #     1            13
2208 #     2            11
2209 #     3            14
2210 #     4            17
2211 ovs-appctl time/warp 2000
2212 # Adding another flow will cause the one that expires soonest to be evicted.
2213 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
2214 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2215  hard_timeout=13, in_port=1 actions=drop
2216  hard_timeout=19, in_port=3 actions=drop
2217  hard_timeout=22, in_port=4 actions=drop
2218  in_port=5 actions=drop
2219 NXST_FLOW reply:
2220 ])
2221 OVS_VSWITCHD_STOP
2222 AT_CLEANUP
2223
2224 AT_SETUP([ofproto - eviction upon table overflow, with modified idle timeout])
2225 OVS_VSWITCHD_START([add-port br0 p1 -- set interface p1 type=dummy ofport_request=1])
2226 # Configure a maximum of 4 flows.
2227 AT_CHECK(
2228   [ovs-vsctl \
2229      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
2230      -- set bridge br0 flow_tables:0=@t0 \
2231    | ${PERL} $srcdir/uuidfilt.pl],
2232   [0], [<0>
2233 ])
2234 # Add 4 flows.
2235 for in_port in 4 3 2 1; do
2236     ovs-ofctl add-flow br0 idle_timeout=$((10 + in_port * 3)),in_port=$in_port,actions=drop
2237 done
2238 ovs-appctl time/stop
2239 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2240  idle_timeout=13, in_port=1 actions=drop
2241  idle_timeout=16, in_port=2 actions=drop
2242  idle_timeout=19, in_port=3 actions=drop
2243  idle_timeout=22, in_port=4 actions=drop
2244 NXST_FLOW reply:
2245 ])
2246 # Sleep and receive on the flow that expires soonest
2247 ovs-appctl time/warp 5000
2248 AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1)'])
2249 # At this point the table would looks like:
2250 #  in_port   seconds to expire
2251 #     1            13
2252 #     2            11
2253 #     3            14
2254 #     4            17
2255 ovs-appctl time/warp 2000
2256 # Adding another flow will cause the one that expires soonest to be evicted.
2257 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
2258 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
2259  idle_timeout=19, in_port=3 actions=drop
2260  idle_timeout=22, in_port=4 actions=drop
2261  in_port=5 actions=drop
2262  n_packets=1, n_bytes=60, idle_timeout=13, in_port=1 actions=drop
2263 NXST_FLOW reply:
2264 ])
2265 OVS_VSWITCHD_STOP
2266 AT_CLEANUP
2267
2268 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.0)])
2269 OVS_VSWITCHD_START
2270 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
2271 check_async () {
2272     printf '\n\n--- check_async %d ---\n\n\n' $1
2273     shift
2274
2275     ovs-appctl -t ovs-ofctl ofctl/barrier
2276     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2277     : > expout
2278
2279     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
2280     ovs-ofctl -v packet-out br0 controller controller '0001020304050010203040501234'
2281     if test X"$1" = X"OFPR_ACTION"; then shift;
2282         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
2283 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2284     fi
2285
2286     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
2287     ovs-ofctl -v packet-out br0 controller 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
2288     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
2289         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via no_match) data_len=14 (unbuffered)
2290 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2291     fi
2292
2293     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
2294     ovs-ofctl packet-out br0 controller dec_ttl '002583dfb4000026b98cb0f908004500003eb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
2295     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
2296         echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=CONTROLLER (via invalid_ttl) data_len=76 (unbuffered)
2297 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"
2298     fi
2299
2300     # OFPT_PORT_STATUS, OFPPR_ADD
2301     ovs-vsctl add-port br0 test -- set Interface test type=dummy ofport_request=1
2302     if test X"$1" = X"OFPPR_ADD"; then shift;
2303         echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
2304      config:     PORT_DOWN
2305      state:      LINK_DOWN
2306      speed: 0 Mbps now, 0 Mbps max"
2307     fi
2308
2309     # OFPT_PORT_STATUS, OFPPR_DELETE
2310     ovs-vsctl del-port br0 test
2311     if test X"$1" = X"OFPPR_DELETE"; then shift;
2312         echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
2313      config:     PORT_DOWN
2314      state:      LINK_DOWN
2315      speed: 0 Mbps now, 0 Mbps max"
2316     fi
2317
2318     # OFPT_FLOW_REMOVED, OFPRR_DELETE
2319     ovs-ofctl add-flow br0 send_flow_rem,actions=drop
2320     ovs-ofctl --strict del-flows br0 ''
2321     if test X"$1" = X"OFPRR_DELETE"; then shift;
2322         echo >>expout "OFPT_FLOW_REMOVED:  reason=delete"
2323     fi
2324     AT_FAIL_IF([test X"$1" != X])
2325
2326     ovs-appctl -t ovs-ofctl ofctl/barrier
2327     echo >>expout "OFPT_BARRIER_REPLY:"
2328
2329     AT_CHECK(
2330       [[sed '
2331 s/ (xid=0x[0-9a-fA-F]*)//
2332 s/ *duration.*//
2333 s/00:0.$/00:0x/' < monitor.log]],
2334       [0], [expout])
2335 }
2336
2337 # It's a service connection so initially there should be no async messages.
2338 check_async 1
2339
2340 # Set miss_send_len to 128, turning on packet-ins for our service connection.
2341 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
2342 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2343
2344 # Set miss_send_len to 128 and enable invalid_ttl.
2345 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
2346 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2347
2348 # Become slave, which should disable everything except port status.
2349 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
2350 check_async 4 OFPPR_ADD OFPPR_DELETE
2351
2352 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
2353 ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
2354 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
2355
2356 # Set controller ID 123.
2357 ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
2358 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
2359
2360 # Restore controller ID 0.
2361 ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
2362
2363 # Become master.
2364 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
2365 check_async 7 OFPR_ACTION OFPPR_ADD
2366
2367 ovs-appctl -t ovs-ofctl exit
2368 OVS_VSWITCHD_STOP
2369 AT_CLEANUP
2370
2371 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.2)])
2372 OVS_VSWITCHD_START
2373 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
2374 check_async () {
2375     printf '\n\n--- check_async %d ---\n\n\n' $1
2376     INDEX=$1
2377     shift
2378
2379     ovs-appctl -t ovs-ofctl ofctl/barrier
2380     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2381     : > expout
2382
2383     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
2384     ovs-ofctl -O OpenFlow12 -v packet-out br0 none controller '0001020304050010203040501234'
2385     if test X"$1" = X"OFPR_ACTION"; then shift;
2386         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
2387 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2388     fi
2389
2390     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
2391     ovs-ofctl -O OpenFlow12 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
2392     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
2393         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
2394 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2395     fi
2396
2397     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
2398     ovs-ofctl -O OpenFlow12 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003eb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
2399     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
2400         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
2401 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"
2402     fi
2403
2404     # OFPT_PORT_STATUS, OFPPR_ADD
2405     ovs-vsctl add-port br0 test -- set Interface test type=dummy
2406     if test X"$1" = X"OFPPR_ADD"; then shift;
2407         echo >>expout "OFPT_PORT_STATUS (OF1.2): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2408      config:     PORT_DOWN
2409      state:      LINK_DOWN
2410      speed: 0 Mbps now, 0 Mbps max"
2411     fi
2412
2413     # OFPT_PORT_STATUS, OFPPR_DELETE
2414     ovs-vsctl del-port br0 test
2415     if test X"$1" = X"OFPPR_DELETE"; then shift;
2416         echo >>expout "OFPT_PORT_STATUS (OF1.2): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2417      config:     PORT_DOWN
2418      state:      LINK_DOWN
2419      speed: 0 Mbps now, 0 Mbps max"
2420     fi
2421
2422     # OFPT_FLOW_REMOVED, OFPRR_DELETE
2423     ovs-ofctl -O OpenFlow12 add-flow br0 send_flow_rem,actions=drop
2424     ovs-ofctl -O OpenFlow12 --strict del-flows br0 ''
2425     if test X"$1" = X"OFPRR_DELETE"; then shift;
2426         echo >>expout "OFPT_FLOW_REMOVED (OF1.2):  reason=delete table_id=0"
2427     fi
2428     AT_FAIL_IF([test X"$1" != X])
2429
2430     ovs-appctl -t ovs-ofctl ofctl/barrier
2431     echo >>expout "OFPT_BARRIER_REPLY (OF1.2):"
2432
2433     AT_CHECK(
2434       [[sed '
2435 s/ (xid=0x[0-9a-fA-F]*)//
2436 s/ *duration.*//
2437 s/00:0.$/00:0x/' < monitor.log]],
2438       [0], [expout])
2439 }
2440
2441 # It's a service connection so initially there should be no async messages.
2442 check_async 1
2443
2444 # Set miss_send_len to 128, turning on packet-ins for our service connection.
2445 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
2446 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2447
2448 # Set miss_send_len to 128 and enable invalid_ttl.
2449 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700040080
2450 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2451
2452 # Become slave (OF 1.2), which should disable everything except port status.
2453 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000200000003000000000000000000000001
2454 check_async 4 OFPPR_ADD OFPPR_DELETE
2455
2456 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
2457 ovs-appctl -t ovs-ofctl ofctl/send 03040028000000020000232000000013000000020000000500000005000000020000000200000005
2458 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
2459
2460 # Set controller ID 123.
2461 ovs-appctl -t ovs-ofctl ofctl/send 03040018000000030000232000000014000000000000007b
2462 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
2463
2464 # Restore controller ID 0.
2465 ovs-appctl -t ovs-ofctl ofctl/send 030400180000000300002320000000140000000000000000
2466
2467 # Become master (OF 1.2).
2468 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000400000002000000000000000000000002
2469 check_async 7 OFPR_ACTION OFPPR_ADD
2470
2471 ovs-appctl -t ovs-ofctl exit
2472 OVS_VSWITCHD_STOP
2473 AT_CLEANUP
2474
2475 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.3)])
2476 OVS_VSWITCHD_START
2477 AT_CHECK([ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile])
2478 check_async () {
2479     printf '\n\n--- check_async %d ---\n\n\n' $1
2480     INDEX=$1
2481     shift
2482
2483     ovs-appctl -t ovs-ofctl ofctl/barrier
2484     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2485     : > expout
2486
2487     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
2488     ovs-ofctl -O OpenFlow13 -v packet-out br0 none controller '0001020304050010203040501234'
2489     if test X"$1" = X"OFPR_ACTION"; then shift;
2490         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
2491 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2492     fi
2493
2494     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
2495     ovs-ofctl -O OpenFlow13 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
2496     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
2497         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
2498 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2499     fi
2500
2501     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
2502     ovs-ofctl -O OpenFlow13 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003eb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
2503     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
2504         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
2505 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"
2506     fi
2507
2508     # OFPT_PORT_STATUS, OFPPR_ADD
2509     ovs-vsctl add-port br0 test -- set Interface test type=dummy
2510     if test X"$1" = X"OFPPR_ADD"; then shift;
2511         echo >>expout "OFPT_PORT_STATUS (OF1.3): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2512      config:     PORT_DOWN
2513      state:      LINK_DOWN
2514      speed: 0 Mbps now, 0 Mbps max"
2515     fi
2516
2517     # OFPT_PORT_STATUS, OFPPR_DELETE
2518     ovs-vsctl del-port br0 test
2519     if test X"$1" = X"OFPPR_DELETE"; then shift;
2520         echo >>expout "OFPT_PORT_STATUS (OF1.3): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2521      config:     PORT_DOWN
2522      state:      LINK_DOWN
2523      speed: 0 Mbps now, 0 Mbps max"
2524     fi
2525
2526     # OFPT_FLOW_REMOVED, OFPRR_DELETE
2527     ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=drop
2528     ovs-ofctl -O OpenFlow13 --strict del-flows br0 ''
2529     if test X"$1" = X"OFPRR_DELETE"; then shift;
2530         echo >>expout "OFPT_FLOW_REMOVED (OF1.3):  reason=delete table_id=0"
2531     fi
2532
2533     # OFPT_FLOW_REMOVED, OFPRR_GROUP_DELETE
2534     ovs-ofctl -O OpenFlow13 add-group br0 group_id=1234,type=all,bucket=output:10
2535     ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=group:1234
2536     ovs-ofctl -O OpenFlow13 --strict del-groups br0 group_id=1234
2537     if test X"$1" = X"OFPRR_DELETE"; then shift;
2538         echo >>expout "OFPT_FLOW_REMOVED (OF1.3):  reason=gropu_delete table_id=0"
2539     fi
2540
2541     AT_FAIL_IF([test X"$1" != X])
2542
2543     ovs-appctl -t ovs-ofctl ofctl/barrier
2544     echo >>expout "OFPT_BARRIER_REPLY (OF1.3):"
2545
2546     AT_CHECK(
2547       [[sed '
2548 s/ (xid=0x[0-9a-fA-F]*)//
2549 s/ *duration.*//
2550 s/00:0.$/00:0x/' < monitor.log]],
2551       [0], [expout])
2552 }
2553
2554 # It's a service connection so initially there should be no async messages.
2555 check_async 1
2556
2557 # Set miss_send_len to 128, turning on packet-ins for our service connection.
2558 ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
2559 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2560
2561 # Become slave (OF 1.3), which should disable everything except port status.
2562 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000200000003000000000000000000000001
2563 check_async 3 OFPPR_ADD OFPPR_DELETE
2564
2565 # Use OF 1.3 OFPT_SET_ASYNC to enable a patchwork of asynchronous messages.
2566 ovs-appctl -t ovs-ofctl ofctl/send 041c002000000002000000020000000500000005000000020000000200000005
2567 check_async 4 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
2568
2569 # Set controller ID 123.
2570 ovs-appctl -t ovs-ofctl ofctl/send 04040018000000030000232000000014000000000000007b
2571 check_async 5 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
2572
2573 # Restore controller ID 0.
2574 ovs-appctl -t ovs-ofctl ofctl/send 040400180000000300002320000000140000000000000000
2575
2576 # Become master (OF 1.3).
2577 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000400000002000000000000000000000002
2578 check_async 6 OFPR_ACTION OFPPR_ADD
2579
2580 ovs-appctl -t ovs-ofctl exit
2581 OVS_VSWITCHD_STOP
2582 AT_CLEANUP
2583
2584 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.4)])
2585 OVS_VSWITCHD_START
2586 AT_CHECK([ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile])
2587 check_async () {
2588     printf '\n\n--- check_async %d ---\n\n\n' $1
2589     INDEX=$1
2590     shift
2591
2592     ovs-appctl -t ovs-ofctl ofctl/barrier
2593     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2594     : > expout
2595
2596     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
2597     ovs-ofctl -O OpenFlow14 -v packet-out br0 none controller '0001020304050010203040501234'
2598     if test X"$1" = X"OFPR_ACTION"; then shift;
2599         echo >>expout "OFPT_PACKET_IN (OF1.4): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
2600 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2601     fi
2602
2603     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
2604     ovs-ofctl -O OpenFlow14 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
2605     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
2606         echo >>expout "OFPT_PACKET_IN (OF1.4): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
2607 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
2608     fi
2609
2610     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
2611     ovs-ofctl -O OpenFlow14 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003eb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
2612     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
2613         echo >>expout "OFPT_PACKET_IN (OF1.4): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
2614 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"
2615     fi
2616
2617 # OFPT_PORT_STATUS, OFPPR_ADD
2618     ovs-vsctl add-port br0 test -- set Interface test type=dummy
2619     if test X"$1" = X"OFPPR_ADD"; then shift;
2620         echo >>expout "OFPT_PORT_STATUS (OF1.4): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2621      config:     PORT_DOWN
2622      state:      LINK_DOWN
2623      speed: 0 Mbps now, 0 Mbps max"
2624     fi
2625
2626     # OFPT_PORT_STATUS, OFPPR_MODIFY
2627     ovs-ofctl -O OpenFlow14 -vwarn mod-port br0 test up
2628     if test X"$1" = X"OFPPR_MODIFY"; then shift;
2629         echo >>expout "OFPT_PORT_STATUS (OF1.4): MOD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2630      config:     0
2631      state:      LINK_DOWN
2632      speed: 0 Mbps now, 0 Mbps max
2633 OFPT_PORT_STATUS (OF1.4): MOD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2634      config:     0
2635      state:      0
2636      speed: 0 Mbps now, 0 Mbps max"
2637     fi
2638
2639     # OFPT_PORT_STATUS, OFPPR_DELETE
2640     ovs-vsctl del-port br0 test
2641     if test X"$1" = X"OFPPR_DELETE"; then shift;
2642         echo >>expout "OFPT_PORT_STATUS (OF1.4): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2643      config:     0
2644      state:      0
2645      speed: 0 Mbps now, 0 Mbps max"
2646     fi
2647
2648     # OFPT_FLOW_REMOVED, OFPRR_DELETE
2649     ovs-ofctl -O OpenFlow14 add-flow br0 send_flow_rem,actions=drop
2650     ovs-ofctl -O OpenFlow14 --strict del-flows br0 ''
2651     if test X"$1" = X"OFPRR_DELETE"; then shift;
2652         echo >>expout "OFPT_FLOW_REMOVED (OF1.4):  reason=delete table_id=0"
2653     fi
2654
2655         # OFPT_FLOW_REMOVED, OFPRR_GROUP_DELETE
2656     ovs-ofctl -O OpenFlow14 add-group br0 group_id=1234,type=all,bucket=output:10
2657     ovs-ofctl -O OpenFlow14 add-flow br0 send_flow_rem,actions=group:1234
2658     ovs-ofctl -O OpenFlow14 --strict del-groups br0 group_id=1234
2659     if test X"$1" = X"OFPRR_GROUP_DELETE"; then shift;
2660         echo >>expout "OFPT_FLOW_REMOVED (OF1.4):  reason=group_delete table_id=0"
2661     fi
2662
2663     AT_FAIL_IF([test X"$1" != X])
2664
2665     ovs-appctl -t ovs-ofctl ofctl/barrier
2666     echo >>expout "OFPT_BARRIER_REPLY (OF1.4):"
2667
2668     AT_CHECK(
2669       [[sed '
2670 s/ (xid=0x[0-9a-fA-F]*)//
2671 s/ *duration.*//
2672 s/00:0.$/00:0x/' < monitor.log]],
2673       [0], [expout])
2674 }
2675
2676 # It's a service connection so initially there should be no async messages.
2677 check_async 1
2678
2679 # Set miss_send_len to 128, turning on packet-ins for our service connection.
2680 ovs-appctl -t ovs-ofctl ofctl/send 0509000c0123456700000080
2681 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_MODIFY OFPPR_DELETE OFPRR_DELETE OFPRR_GROUP_DELETE
2682
2683 # Become slave (OF 1.4), which should disable everything except port status.
2684 ovs-appctl -t ovs-ofctl ofctl/send 051800180000000200000003000000000000000000000001
2685 check_async 3 OFPPR_ADD OFPPR_MODIFY OFPPR_DELETE
2686
2687 # Use OF 1.4 OFPT_SET_ASYNC to enable a patchwork of asynchronous messages.
2688 ovs-appctl -t ovs-ofctl ofctl/send 051c0038000000020000000800000005000100080000000200020008000000020003000800000005000400080000001c0005000800000005
2689 check_async 4 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE OFPRR_GROUP_DELETE
2690
2691 # Set controller ID 123.
2692 ovs-appctl -t ovs-ofctl ofctl/send 05040018000000030000232000000014000000000000007b
2693 check_async 5 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE OFPRR_GROUP_DELETE
2694
2695 # Restore controller ID 0.
2696 ovs-appctl -t ovs-ofctl ofctl/send 050400180000000300002320000000140000000000000000
2697
2698 # Become master (OF 1.4).
2699 ovs-appctl -t ovs-ofctl ofctl/send 051800180000000400000002000000000000000000000002
2700 check_async 6 OFPR_ACTION OFPPR_ADD OFPPR_MODIFY OFPRR_DELETE
2701
2702 ovs-appctl -t ovs-ofctl exit
2703 OVS_VSWITCHD_STOP
2704 AT_CLEANUP
2705
2706 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.5)])
2707 OVS_VSWITCHD_START
2708 AT_CHECK([ovs-ofctl -O OpenFlow15 monitor br0 --detach --no-chdir --pidfile])
2709 check_async () {
2710     printf '\n\n--- check_async %d ---\n\n\n' $1
2711     INDEX=$1
2712     shift
2713
2714     ovs-appctl -t ovs-ofctl ofctl/barrier
2715     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2716     : > expout
2717
2718     # Other tests are not working with OF 1.5, and message
2719     # format may change, so leave them out.
2720
2721     # OFPT_PORT_STATUS, OFPPR_ADD
2722     ovs-vsctl add-port br0 test -- set Interface test type=dummy
2723     if test X"$1" = X"OFPPR_ADD"; then shift;
2724         echo >>expout "OFPT_PORT_STATUS (OF1.5): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2725      config:     PORT_DOWN
2726      state:      LINK_DOWN
2727      speed: 0 Mbps now, 0 Mbps max"
2728     fi
2729
2730     # OFPT_PORT_STATUS, OFPPR_MODIFY
2731     ovs-ofctl -O OpenFlow15 -vwarn mod-port br0 test up
2732     if test X"$1" = X"OFPPR_MODIFY"; then shift;
2733         echo >>expout "OFPT_PORT_STATUS (OF1.5): MOD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2734      config:     0
2735      state:      LINK_DOWN
2736      speed: 0 Mbps now, 0 Mbps max
2737 OFPT_PORT_STATUS (OF1.5): MOD: 2(test): addr:aa:55:aa:55:00:0x
2738      config:     0
2739      state:      0
2740      speed: 0 Mbps now, 0 Mbps max"
2741     fi
2742
2743     # OFPT_PORT_STATUS, OFPPR_DELETE
2744     ovs-vsctl del-port br0 test
2745     if test X"$1" = X"OFPPR_DELETE"; then shift;
2746         echo >>expout "OFPT_PORT_STATUS (OF1.5): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2747      config:     0
2748      state:      0
2749      speed: 0 Mbps now, 0 Mbps max"
2750     fi
2751
2752     AT_FAIL_IF([test X"$1" != X])
2753
2754     ovs-appctl -t ovs-ofctl ofctl/barrier
2755     echo >>expout "OFPT_BARRIER_REPLY (OF1.5):"
2756
2757     AT_CHECK(
2758       [[sed '
2759 s/ (xid=0x[0-9a-fA-F]*)//
2760 s/ *duration.*//
2761 s/00:0.$/00:0x/' < monitor.log]],
2762       [0], [expout])
2763 }
2764
2765 # It's a service connection so initially there should be no async messages.
2766 check_async 1
2767
2768 # If we don't set this, async messages are not received.
2769 # Set miss_send_len to 128, turning on packet-ins for our service connection.
2770 ovs-appctl -t ovs-ofctl ofctl/send 0609000c0123456700000080
2771 check_async 2 OFPPR_ADD OFPPR_MODIFY OFPPR_DELETE
2772
2773 # Set-async has changed in OF 1.4 and is not yet implemented.
2774
2775 ovs-appctl -t ovs-ofctl exit
2776 OVS_VSWITCHD_STOP
2777 AT_CLEANUP
2778
2779 dnl This test checks that the role request/response messaging works
2780 dnl and that generation_id is handled properly.
2781 AT_SETUP([ofproto - controller role (OpenFlow 1.2)])
2782 OVS_VSWITCHD_START
2783 on_exit 'kill `cat c1.pid c2.pid`'
2784
2785 # Start two ovs-ofctl controller processes.
2786 AT_CAPTURE_FILE([monitor1.log])
2787 AT_CAPTURE_FILE([expout1])
2788 AT_CAPTURE_FILE([experr1])
2789 AT_CAPTURE_FILE([monitor2.log])
2790 AT_CAPTURE_FILE([expout2])
2791 AT_CAPTURE_FILE([experr2])
2792 for i in 1 2; do
2793      AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile=`pwd`/c$i.pid --unixctl=`pwd`/c$i])
2794     ovs-appctl -t `pwd`/c$i ofctl/barrier
2795     ovs-appctl -t `pwd`/c$i ofctl/set-output-file monitor$i.log
2796     : > expout$i
2797     : > experr$i
2798
2799     # find out current role
2800     ovs-appctl -t `pwd`/c$i ofctl/send 031800180000000200000000000000000000000000000000
2801     echo >>experr$i "send: OFPT_ROLE_REQUEST (OF1.2): role=nochange"
2802     echo >>expout$i "OFPT_ROLE_REPLY (OF1.2): role=equal"
2803 done
2804
2805 # controller 1: Become slave (generation_id is initially undefined, so
2806 # 2^63+2 should not be stale)
2807 ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000300000003000000008000000000000002
2808 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=slave generation_id=9223372036854775810"
2809 echo >>expout1 "OFPT_ROLE_REPLY (OF1.2): role=slave generation_id=9223372036854775810"
2810
2811 # controller 2: Become master.
2812 ovs-appctl -t `pwd`/c2 ofctl/send 031800180000000300000002000000008000000000000003
2813 echo >>experr2 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=9223372036854775811"
2814 echo >>expout2 "OFPT_ROLE_REPLY (OF1.2): role=master generation_id=9223372036854775811"
2815
2816 # controller 1: Try to become the master using a stale generation ID
2817 ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000400000002000000000000000000000003
2818 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=3"
2819 echo >>expout1 "OFPT_ERROR (OF1.2): OFPRRFC_STALE"
2820 echo >>expout1 "OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=3"
2821
2822 # controller 1: Become master using a valid generation ID
2823 ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000500000002000000000000000000000001
2824 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=1"
2825 echo >>expout1 "OFPT_ROLE_REPLY (OF1.2): role=master generation_id=1"
2826
2827 for i in 1 2; do
2828     ovs-appctl -t `pwd`/c$i ofctl/barrier
2829     echo >>expout$i "OFPT_BARRIER_REPLY (OF1.2):"
2830 done
2831
2832 # Check output.
2833 for i in 1 2; do
2834     cp expout$i expout
2835     AT_CHECK([grep -v '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
2836     cp experr$i expout
2837     AT_CHECK([grep '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
2838 done
2839 OVS_VSWITCHD_STOP
2840 AT_CLEANUP
2841
2842 dnl This test checks that the role request/response messaging works,
2843 dnl that generation_id is handled properly, and that role status update
2844 dnl messages are sent when a controller's role gets changed from master
2845 dnl to slave.
2846 AT_SETUP([ofproto - controller role (OpenFlow 1.4)])
2847 OVS_VSWITCHD_START
2848 on_exit 'kill `cat c1.pid c2.pid`'
2849
2850 # Start two ovs-ofctl controller processes.
2851 AT_CAPTURE_FILE([monitor1.log])
2852 AT_CAPTURE_FILE([expout1])
2853 AT_CAPTURE_FILE([experr1])
2854 AT_CAPTURE_FILE([monitor2.log])
2855 AT_CAPTURE_FILE([expout2])
2856 AT_CAPTURE_FILE([experr2])
2857 for i in 1 2; do
2858      AT_CHECK([ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile=`pwd`/c$i.pid --unixctl=`pwd`/c$i])
2859     ovs-appctl -t `pwd`/c$i ofctl/barrier
2860     ovs-appctl -t `pwd`/c$i ofctl/set-output-file monitor$i.log
2861     : > expout$i
2862     : > experr$i
2863
2864     # find out current role
2865     ovs-appctl -t `pwd`/c$i ofctl/send 051800180000000200000000000000000000000000000000
2866     echo >>experr$i "send: OFPT_ROLE_REQUEST (OF1.4): role=nochange"
2867     echo >>expout$i "OFPT_ROLE_REPLY (OF1.4): role=equal"
2868 done
2869
2870 # controller 1: Become slave (generation_id is initially undefined, so
2871 # 2^63+2 should not be stale)
2872 ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000300000003000000008000000000000002
2873 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=slave generation_id=9223372036854775810"
2874 echo >>expout1 "OFPT_ROLE_REPLY (OF1.4): role=slave generation_id=9223372036854775810"
2875
2876 # controller 2: Become master.
2877 ovs-appctl -t `pwd`/c2 ofctl/send 051800180000000300000002000000008000000000000003
2878 echo >>experr2 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=9223372036854775811"
2879 echo >>expout2 "OFPT_ROLE_REPLY (OF1.4): role=master generation_id=9223372036854775811"
2880
2881 # controller 1: Try to become the master using a stale generation ID
2882 ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000400000002000000000000000000000003
2883 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=3"
2884 echo >>expout1 "OFPT_ERROR (OF1.4): OFPRRFC_STALE"
2885 echo >>expout1 "OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=3"
2886
2887 # controller 1: Become master using a valid generation ID
2888 ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000500000002000000000000000000000001
2889 echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=1"
2890 echo >>expout1 "OFPT_ROLE_REPLY (OF1.4): role=master generation_id=1"
2891 echo >>expout2 "OFPT_ROLE_STATUS (OF1.4): role=slave generation_id=1 reason=master_request"
2892
2893 for i in 1 2; do
2894     ovs-appctl -t `pwd`/c$i ofctl/barrier
2895     echo >>expout$i "OFPT_BARRIER_REPLY (OF1.4):"
2896 done
2897
2898 # Check output.
2899 for i in 1 2; do
2900     cp expout$i expout
2901     AT_CHECK([grep -v '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
2902     cp experr$i expout
2903     AT_CHECK([grep '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
2904 done
2905 OVS_VSWITCHD_STOP
2906 AT_CLEANUP
2907
2908 dnl This test checks the Group and meter notifications when a group mod
2909 dnl command is sent from one controller and the reply is received by
2910 dnl other controllers.
2911 AT_SETUP([ofproto - requestforward (OpenFlow 1.4)])
2912 OVS_VSWITCHD_START
2913 on_exit 'kill `cat c1.pid c2.pid c3.pid`'
2914
2915 # Start two ovs-ofctl controller processes.
2916 AT_CAPTURE_FILE([monitor1.log])
2917 AT_CAPTURE_FILE([expout1])
2918 AT_CAPTURE_FILE([monitor2.log])
2919 AT_CAPTURE_FILE([expout2])
2920 AT_CAPTURE_FILE([monitor3.log])
2921 AT_CAPTURE_FILE([expout3])
2922
2923 ovs-ofctl -O OpenFlow15 monitor br0 --detach --no-chdir --pidfile=`pwd`/c1.pid --unixctl=`pwd`/c1
2924 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile=`pwd`/c2.pid --unixctl=`pwd`/c2
2925 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile=`pwd`/c3.pid --unixctl=`pwd`/c3
2926
2927 check_async () {
2928     for i in 1 3; do
2929         ovs-appctl -t `pwd`/c$i ofctl/barrier
2930         ovs-appctl -t `pwd`/c$i ofctl/set-output-file monitor$i.log
2931         : > expout$i
2932     done
2933
2934     printf '\n\n--- check_async %d ---\n\n\n' $1
2935     INDEX=$1
2936     shift
2937
2938     # OFPGC_ADD
2939     ovs-appctl -t `pwd`/c2 ofctl/send 050f0010000000020000000000000001
2940     if test X"$1" = X"OFPGC_ADD"; then shift;
2941         echo >>expout2 "send: OFPT_GROUP_MOD (OF1.4):
2942  ADD group_id=1,type=all"
2943         echo >>expout1 "OFPT_REQUESTFORWARD (OF1.5): reason=group_mod
2944  ADD group_id=1,type=all"
2945         echo >>expout3 "OFPT_REQUESTFORWARD (OF1.4): reason=group_mod
2946  ADD group_id=1,type=all"
2947     fi
2948
2949     # OFPGC_MODIFY
2950     ovs-appctl -t `pwd`/c2 ofctl/send 050f0010000000020001010000000001
2951     if test X"$1" = X"OFPGC_MODIFY"; then shift;
2952         echo >>expout2 "send: OFPT_GROUP_MOD (OF1.4):
2953  MOD group_id=1,type=select"
2954         echo >>expout1 "OFPT_REQUESTFORWARD (OF1.5): reason=group_mod
2955  MOD group_id=1,type=select"
2956         echo >>expout3 "OFPT_REQUESTFORWARD (OF1.4): reason=group_mod
2957  MOD group_id=1,type=select"
2958     fi
2959
2960     ovs-appctl -t `pwd`/c1 ofctl/barrier
2961     echo >>expout1 "OFPT_BARRIER_REPLY (OF1.5):"
2962     ovs-appctl -t `pwd`/c2 ofctl/barrier
2963     echo >>expout2 "OFPT_BARRIER_REPLY (OF1.4):"
2964     ovs-appctl -t `pwd`/c3 ofctl/barrier
2965     echo >>expout3 "OFPT_BARRIER_REPLY (OF1.4):"
2966
2967     # Check output.
2968     for i in 1 3; do
2969         cp expout$i expout
2970         AT_CHECK(
2971       [[sed '
2972 s/ (xid=0x[0-9a-fA-F]*)//'< monitor$i.log]],
2973       [0], [expout])
2974     done
2975 }
2976
2977 # controller 1: Become slave
2978 ovs-appctl -t `pwd`/c1 ofctl/send 061800180000000300000003000000008000000000000002
2979
2980 # controller 2: Become master
2981 ovs-appctl -t `pwd`/c2 ofctl/send 051800180000000300000002000000008000000000000003
2982
2983 # controller 1: Become slave
2984 ovs-appctl -t `pwd`/c3 ofctl/send 051800180000000300000003000000008000000000000004
2985
2986 # controller 1: Enabled requestforward using set Asynchronous message
2987 ovs-appctl -t `pwd`/c1 ofctl/send 061c00280000000200000008000000050002000800000002000400080000001a000a000800000003
2988
2989 # controller 2: Enabled requestforward using set Asynchronous message
2990 ovs-appctl -t `pwd`/c2 ofctl/send 051c002800000002000100080000000200030008000000050005000800000005000b000800000003
2991
2992 # controller 1: Enabled requestforward using set Asynchronous message
2993 ovs-appctl -t `pwd`/c3 ofctl/send 051c00280000000200000008000000050002000800000002000400080000001a000a000800000003
2994 check_async 1 OFPGC_ADD OFPGC_MODIFY
2995
2996 OVS_VSWITCHD_STOP
2997 AT_CLEANUP
2998
2999 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
3000 dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
3001 dnl controllers despite the spec) as meaning a packet that was generated
3002 dnl by the controller.
3003 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.0)])
3004 OVS_VSWITCHD_START
3005 ADD_OF_PORTS([br0], [1])
3006
3007 # Start a monitor listening for packet-ins.
3008 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
3009 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
3010 ovs-appctl -t ovs-ofctl ofctl/barrier
3011 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3012 AT_CAPTURE_FILE([monitor.log])
3013
3014 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
3015 AT_CHECK([ovs-ofctl packet-out br0 none controller,1 '0001020304050010203040501234'])
3016 AT_CHECK([ovs-ofctl packet-out br0 controller controller,1 '0001020304050010203040505678'])
3017
3018 # Stop the monitor and check its output.
3019 ovs-appctl -t ovs-ofctl ofctl/barrier
3020 ovs-appctl -t ovs-ofctl exit
3021
3022 ovs-ofctl dump-ports br0
3023
3024 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3025 OFPT_PACKET_IN: total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
3026 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3027 OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
3028 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
3029 OFPT_BARRIER_REPLY:
3030 ])
3031
3032 OVS_VSWITCHD_STOP
3033 AT_CLEANUP
3034
3035 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
3036 dnl specified by OpenFlow 1.2) and OFPP_CONTROLLER (used by some
3037 dnl controllers despite the spec) as meaning a packet that was generated
3038 dnl by the controller.
3039 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.2)])
3040 OVS_VSWITCHD_START
3041
3042 # Start a monitor listening for packet-ins.
3043 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
3044 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
3045 ovs-appctl -t ovs-ofctl ofctl/barrier
3046 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3047 AT_CAPTURE_FILE([monitor.log])
3048
3049 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
3050 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none controller '0001020304050010203040501234'])
3051 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 4294967293 controller '0001020304050010203040505678'])
3052
3053 # Stop the monitor and check its output.
3054 ovs-appctl -t ovs-ofctl ofctl/barrier
3055 ovs-appctl -t ovs-ofctl exit
3056
3057 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3058 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
3059 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3060 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
3061 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
3062 OFPT_BARRIER_REPLY (OF1.2):
3063 ])
3064
3065 OVS_VSWITCHD_STOP
3066 AT_CLEANUP
3067
3068 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
3069 dnl specified by OpenFlow 1.1) and OFPP_CONTROLLER (used by some
3070 dnl controllers despite the spec) as meaning a packet that was generated
3071 dnl by the controller.
3072 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.1)])
3073 OVS_VSWITCHD_START
3074
3075 # Start a monitor listening for packet-ins.
3076 AT_CHECK([ovs-ofctl -O OpenFlow11 monitor br0 --detach --no-chdir --pidfile])
3077 ovs-appctl -t ovs-ofctl ofctl/send 0209000c0123456700000080
3078 ovs-appctl -t ovs-ofctl ofctl/barrier
3079 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3080 AT_CAPTURE_FILE([monitor.log])
3081
3082 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
3083 AT_CHECK([ovs-ofctl -O OpenFlow11 packet-out br0 none controller '0001020304050010203040501234'])
3084 AT_CHECK([ovs-ofctl -O OpenFlow11 packet-out br0 4294967293 controller '0001020304050010203040505678'])
3085
3086 # Stop the monitor and check its output.
3087 ovs-appctl -t ovs-ofctl ofctl/barrier
3088 ovs-appctl -t ovs-ofctl exit
3089
3090 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3091 OFPT_PACKET_IN (OF1.1): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
3092 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3093 OFPT_PACKET_IN (OF1.1): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
3094 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
3095 OFPT_BARRIER_REPLY (OF1.1):
3096 ])
3097
3098 OVS_VSWITCHD_STOP
3099 AT_CLEANUP
3100
3101 dnl This test checks that metadata is encoded in packet_in structures,
3102 dnl supported by NXAST.
3103 AT_SETUP([ofproto - packet-out with metadata (NXM)])
3104 OVS_VSWITCHD_START
3105
3106 # Start a monitor listening for packet-ins.
3107 AT_CHECK([ovs-ofctl -P nxm monitor br0 --detach --no-chdir --pidfile])
3108 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
3109 ovs-appctl -t ovs-ofctl ofctl/barrier
3110 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3111 AT_CAPTURE_FILE([monitor.log])
3112
3113 # Send a packet-out with a load action to set some metadata, and forward to controller
3114 AT_CHECK([ovs-ofctl packet-out br0 controller 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), load(0xaa->NXM_NX_PKT_MARK[[]]), controller' '0001020304050010203040501234'])
3115
3116 # Stop the monitor and check its output.
3117 ovs-appctl -t ovs-ofctl ofctl/barrier
3118 ovs-appctl -t ovs-ofctl exit
3119
3120 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3121 NXT_PACKET_IN: total_len=14 pkt_mark=0xaa,metadata=0xfafafafa5a5a5a5a,in_port=CONTROLLER (via action) data_len=14 (unbuffered)
3122 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3123 OFPT_BARRIER_REPLY:
3124 ])
3125
3126 OVS_VSWITCHD_STOP
3127 AT_CLEANUP
3128
3129 dnl This test checks that metadata is encoded in packet_in structures,
3130 dnl supported by NXAST.
3131 AT_SETUP([ofproto - packet-out with metadata (OpenFlow 1.2)])
3132 OVS_VSWITCHD_START
3133
3134 # Start a monitor listening for packet-ins.
3135 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
3136 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
3137 ovs-appctl -t ovs-ofctl ofctl/barrier
3138 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3139 AT_CAPTURE_FILE([monitor.log])
3140
3141 # Send a packet-out with a set-field action to set some metadata, and forward to controller
3142 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none 'set_field:0xfafafafa5a5a5a5a->metadata, controller' '0001020304050010203040501234'])
3143
3144 # Stop the monitor and check its output.
3145 ovs-appctl -t ovs-ofctl ofctl/barrier
3146 ovs-appctl -t ovs-ofctl exit
3147
3148 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3149 OFPT_PACKET_IN (OF1.2): total_len=14 metadata=0xfafafafa5a5a5a5a,in_port=ANY (via action) data_len=14 (unbuffered)
3150 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3151 OFPT_BARRIER_REPLY (OF1.2):
3152 ])
3153
3154 OVS_VSWITCHD_STOP
3155 AT_CLEANUP
3156
3157 dnl This test checks that metadata is encoded in packet_in structures,
3158 dnl supported by NXAST.
3159 AT_SETUP([ofproto - packet-out with metadata and dual set_field (OpenFlow 1.3)])
3160 OVS_VSWITCHD_START
3161
3162 # Start a monitor listening for packet-ins.
3163 AT_CHECK([ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile])
3164 ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
3165 ovs-appctl -t ovs-ofctl ofctl/barrier
3166 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3167 AT_CAPTURE_FILE([monitor.log])
3168
3169 # Send a packet-out with a couple of set-field action to set some metadata, and forward to controller
3170 AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 none 'set_field:0xfafafafa5a5a5a5a->metadata, set_field:0x6b->metadata, controller' '0001020304050010203040501234'])
3171
3172 # Stop the monitor and check its output.
3173 ovs-appctl -t ovs-ofctl ofctl/barrier
3174 ovs-appctl -t ovs-ofctl exit
3175
3176 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3177 OFPT_PACKET_IN (OF1.3): total_len=14 metadata=0x6b,in_port=ANY (via action) data_len=14 (unbuffered)
3178 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3179 OFPT_BARRIER_REPLY (OF1.3):
3180 ])
3181
3182 OVS_VSWITCHD_STOP
3183 AT_CLEANUP
3184
3185 dnl This test checks that tunnel metadata is encoded in packet_in structures.
3186 AT_SETUP([ofproto - packet-out with tunnel metadata (OpenFlow 1.2)])
3187 OVS_VSWITCHD_START
3188
3189 # Start a monitor listening for packet-ins.
3190 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
3191 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
3192 ovs-appctl -t ovs-ofctl ofctl/barrier
3193 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3194 AT_CAPTURE_FILE([monitor.log])
3195
3196 # Send a packet-out with set field actions to set some tunnel metadata, and forward to controller
3197 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'])
3198
3199 # Stop the monitor and check its output.
3200 ovs-appctl -t ovs-ofctl ofctl/barrier
3201 ovs-appctl -t ovs-ofctl exit
3202
3203 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
3204 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)
3205 vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
3206 OFPT_BARRIER_REPLY (OF1.2):
3207 ])
3208
3209 OVS_VSWITCHD_STOP
3210 AT_CLEANUP
3211
3212 m4_divert_push([PREPARE_TESTS])
3213 # Sorts groups of lines that start with a space, without moving them
3214 # past the nearest line that does not start with a space.
3215 multiline_sort () {
3216     ${PERL} -e '
3217         use warnings;
3218         use strict;
3219         my @buffer = ();
3220         while (<STDIN>) {
3221             if (/^ /) {
3222                 push(@buffer, $_);
3223             } else {
3224                 print $_ foreach sort(@buffer);
3225                 print $_;
3226                 @buffer = ();
3227             }
3228         }
3229         print $_ foreach sort(@buffer);
3230 '
3231 }
3232 m4_divert_pop([PREPARE_TESTS])
3233
3234 AT_SETUP([ofproto - flow monitoring])
3235 AT_KEYWORDS([monitor])
3236 OVS_VSWITCHD_START
3237
3238 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
3239
3240 # Start a monitor watching the flow table and check the initial reply.
3241 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
3242 AT_CAPTURE_FILE([monitor.log])
3243 ovs-appctl -t ovs-ofctl ofctl/barrier
3244 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3245   [NXST_FLOW_MONITOR reply:
3246  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
3247 OFPT_BARRIER_REPLY:
3248 ])
3249
3250 # Add, delete, and modify some flows and check the updates.
3251 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3252 ovs-ofctl add-flow br0 in_port=0,dl_vlan=124,actions=output:2
3253 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:5
3254 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=0,actions=output:6
3255 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=1,actions=output:7
3256 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:8
3257 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=0,actions=output:9
3258 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=1,actions=output:10
3259 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,actions=output:11
3260 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=0,actions=output:12
3261 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=1,actions=output:13
3262 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,actions=output:14
3263 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:15
3264 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:16
3265 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:17
3266 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:18
3267 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:19
3268 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:20
3269 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=0,actions=output:21
3270 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=1,actions=output:22
3271 ovs-ofctl add-flow br0 in_port=0,actions=output:23
3272 ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:3
3273 ovs-ofctl mod-flows br0 cookie=5,dl_vlan=123,actions=output:3
3274 ovs-ofctl del-flows br0 dl_vlan=123
3275 ovs-ofctl del-flows br0
3276 ovs-appctl -t ovs-ofctl ofctl/barrier
3277 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | multiline_sort], [0],
3278 [NXST_FLOW_MONITOR reply (xid=0x0):
3279  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
3280 NXST_FLOW_MONITOR reply (xid=0x0):
3281  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:5
3282 NXST_FLOW_MONITOR reply (xid=0x0):
3283  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:6
3284 NXST_FLOW_MONITOR reply (xid=0x0):
3285  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:7
3286 NXST_FLOW_MONITOR reply (xid=0x0):
3287  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:8
3288 NXST_FLOW_MONITOR reply (xid=0x0):
3289  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:9
3290 NXST_FLOW_MONITOR reply (xid=0x0):
3291  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:10
3292 NXST_FLOW_MONITOR reply (xid=0x0):
3293  event=ADDED table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
3294 NXST_FLOW_MONITOR reply (xid=0x0):
3295  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
3296 NXST_FLOW_MONITOR reply (xid=0x0):
3297  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
3298 NXST_FLOW_MONITOR reply (xid=0x0):
3299  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
3300 NXST_FLOW_MONITOR reply (xid=0x0):
3301  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:15
3302 NXST_FLOW_MONITOR reply (xid=0x0):
3303  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:16
3304 NXST_FLOW_MONITOR reply (xid=0x0):
3305  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:17
3306 NXST_FLOW_MONITOR reply (xid=0x0):
3307  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
3308 NXST_FLOW_MONITOR reply (xid=0x0):
3309  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
3310 NXST_FLOW_MONITOR reply (xid=0x0):
3311  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
3312 NXST_FLOW_MONITOR reply (xid=0x0):
3313  event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
3314 NXST_FLOW_MONITOR reply (xid=0x0):
3315  event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
3316 NXST_FLOW_MONITOR reply (xid=0x0):
3317  event=ADDED table=0 cookie=0 in_port=0 actions=output:23
3318 NXST_FLOW_MONITOR reply (xid=0x0):
3319  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:3
3320  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
3321  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
3322 NXST_FLOW_MONITOR reply (xid=0x0):
3323  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
3324  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
3325  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
3326 NXST_FLOW_MONITOR reply (xid=0x0):
3327  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
3328  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
3329  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
3330 NXST_FLOW_MONITOR reply (xid=0x0):
3331  event=DELETED reason=delete table=0 cookie=0 in_port=0 actions=output:23
3332  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
3333  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
3334  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
3335  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
3336  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
3337  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
3338  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
3339  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
3340  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
3341  event=DELETED reason=delete table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
3342 OFPT_BARRIER_REPLY:
3343 ])
3344
3345 # Check that our own changes are reported as full updates.
3346 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3347 ovs-ofctl add-flow br0 in_port=1,actions=output:2
3348 ovs-ofctl add-flow br0 in_port=2,actions=output:1
3349 ovs-appctl -t ovs-ofctl ofctl/barrier
3350 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
3351 ovs-appctl -t ovs-ofctl ofctl/barrier
3352 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
3353 ])
3354 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | multiline_sort], [0],
3355 [NXST_FLOW_MONITOR reply (xid=0x0):
3356  event=ADDED table=0 cookie=0 in_port=1 actions=output:2
3357 NXST_FLOW_MONITOR reply (xid=0x0):
3358  event=ADDED table=0 cookie=0 in_port=2 actions=output:1
3359 OFPT_BARRIER_REPLY:
3360 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
3361 NXST_FLOW_MONITOR reply (xid=0x0):
3362  event=DELETED reason=delete table=0 cookie=0 in_port=1 actions=output:2
3363  event=DELETED reason=delete table=0 cookie=0 in_port=2 actions=output:1
3364 OFPT_BARRIER_REPLY:
3365 ])
3366
3367 ovs-appctl -t ovs-ofctl exit
3368 OVS_VSWITCHD_STOP
3369 AT_CLEANUP
3370
3371 AT_SETUP([ofproto - flow monitoring with !own])
3372 AT_KEYWORDS([monitor])
3373 OVS_VSWITCHD_START
3374
3375 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
3376
3377 # Start a monitor watching the flow table and check the initial reply.
3378 ovs-ofctl monitor br0 watch:\!own --detach --no-chdir --pidfile >monitor.log 2>&1
3379 AT_CAPTURE_FILE([monitor.log])
3380 ovs-appctl -t ovs-ofctl ofctl/barrier
3381 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3382   [NXST_FLOW_MONITOR reply:
3383  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
3384 OFPT_BARRIER_REPLY:
3385 ])
3386
3387 # Check that our own changes are reported as abbreviations.
3388 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3389 ovs-ofctl add-flow br0 in_port=1,actions=output:2
3390 ovs-ofctl add-flow br0 in_port=2,actions=output:1
3391 ovs-appctl -t ovs-ofctl ofctl/barrier
3392 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
3393 ovs-appctl -t ovs-ofctl ofctl/barrier
3394 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
3395 ])
3396 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3397 [NXST_FLOW_MONITOR reply (xid=0x0):
3398  event=ADDED table=0 cookie=0 in_port=1 actions=output:2
3399 NXST_FLOW_MONITOR reply (xid=0x0):
3400  event=ADDED table=0 cookie=0 in_port=2 actions=output:1
3401 OFPT_BARRIER_REPLY:
3402 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
3403 NXST_FLOW_MONITOR reply (xid=0x0):
3404  event=ABBREV xid=0x12345678
3405 OFPT_BARRIER_REPLY:
3406 ])
3407
3408 ovs-appctl -t ovs-ofctl exit
3409 OVS_VSWITCHD_STOP
3410 AT_CLEANUP
3411
3412 AT_SETUP([ofproto - flow monitoring with out_port])
3413 AT_KEYWORDS([monitor])
3414 OVS_VSWITCHD_START
3415
3416 ovs-ofctl add-flow br0 in_port=0,dl_vlan=121,actions=output:1
3417 ovs-ofctl add-flow br0 in_port=0,dl_vlan=122,actions=output:1
3418 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:2
3419
3420 # Start a monitor watching the flow table and check the initial reply.
3421 ovs-ofctl monitor br0 watch:out_port=2 --detach --no-chdir --pidfile >monitor.log 2>&1
3422 AT_CAPTURE_FILE([monitor.log])
3423 ovs-appctl -t ovs-ofctl ofctl/barrier
3424 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3425   [NXST_FLOW_MONITOR reply:
3426  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:2
3427 OFPT_BARRIER_REPLY:
3428 ])
3429
3430 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
3431
3432 # Add, modify flows and check the updates.
3433 ovs-ofctl mod-flows br0 dl_vlan=121,actions=drop
3434 ovs-ofctl mod-flows br0 dl_vlan=122,actions=output:1,output:2
3435 ovs-appctl -t ovs-ofctl ofctl/barrier
3436
3437 ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:1,output:2
3438 ovs-appctl -t ovs-ofctl ofctl/barrier
3439
3440 ovs-ofctl mod-flows br0 dl_vlan=122,actions=output:1
3441 ovs-appctl -t ovs-ofctl ofctl/barrier
3442 ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:2
3443 ovs-appctl -t ovs-ofctl ofctl/barrier
3444
3445 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
3446 [NXST_FLOW_MONITOR reply (xid=0x0):
3447  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=122 actions=output:1,output:2
3448 OFPT_BARRIER_REPLY:
3449 NXST_FLOW_MONITOR reply (xid=0x0):
3450  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1,output:2
3451 OFPT_BARRIER_REPLY:
3452 NXST_FLOW_MONITOR reply (xid=0x0):
3453  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=122 actions=output:1
3454 OFPT_BARRIER_REPLY:
3455 NXST_FLOW_MONITOR reply (xid=0x0):
3456  event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:2
3457 OFPT_BARRIER_REPLY:
3458 ])
3459
3460 ovs-appctl -t ovs-ofctl exit
3461 OVS_VSWITCHD_STOP
3462 AT_CLEANUP
3463
3464 AT_SETUP([ofproto - flow monitoring pause and resume])
3465 AT_KEYWORDS([monitor])
3466
3467 # The maximum socket receive buffer size is important for this test, which
3468 # tests behavior when the receive buffer overflows.
3469 if test -e /proc/sys/net/core/rmem_max; then
3470     # Linux
3471     rmem_max=`cat /proc/sys/net/core/rmem_max`
3472 elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
3473     : # FreeBSD, NetBSD
3474 else
3475     # Don't know how to get maximum socket receive buffer on this OS
3476     AT_SKIP_IF([:])
3477 fi
3478 # Calculate the total amount of queuing: rmem_max in the kernel, 128 kB
3479 # in ofproto sending userspace (see ofmonitor_flush() in connmgr.c).
3480 queue_size=`expr $rmem_max + 128 \* 1024`
3481 echo rmem_max=$rmem_max queue_size=$queue_size
3482
3483 # If there's too much queuing skip the test to avoid timing out.
3484 AT_SKIP_IF([test $rmem_max -gt 1048576])
3485
3486 # Each flow update message takes up at least 48 bytes of space in queues
3487 # and in practice more than that.
3488 n_msgs=`expr $queue_size / 48`
3489 echo n_msgs=$n_msgs
3490
3491 OVS_VSWITCHD_START
3492
3493 # Start a monitor watching the flow table, then make it block.
3494 on_exit 'kill `cat ovs-ofctl.pid`'
3495 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
3496 AT_CAPTURE_FILE([monitor.log])
3497 ovs-appctl -t ovs-ofctl ofctl/block
3498
3499 # Add $n_msgs flows.
3500 (echo "in_port=2,actions=output:2"
3501 ${PERL} -e '
3502     for ($i = 0; $i < '$n_msgs'; $i++) {
3503         print "cookie=1,reg1=$i,actions=drop\n";
3504     }
3505 ') > flows.txt
3506 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
3507 # Check that multipart flow dumps work properly:
3508 AT_CHECK([ovs-ofctl diff-flows br0 flows.txt])
3509 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,cookie=3,actions=drop])
3510 AT_CHECK([ovs-ofctl mod-flows br0 in_port=2,cookie=2,actions=output:2])
3511 AT_CHECK([ovs-ofctl del-flows br0 cookie=1/-1])
3512
3513 ovs-appctl -t ovs-ofctl ofctl/unblock
3514
3515 # Wait for the connection resumed.
3516 # A barrier doesn't work for this purpose.
3517 #    https://www.mail-archive.com/dev@openvswitch.org/msg27013.html
3518 #    https://www.mail-archive.com/dev@openvswitch.org/msg27675.html
3519 OVS_WAIT_UNTIL([grep NXT_FLOW_MONITOR_RESUMED monitor.log])
3520
3521 ovs-appctl -t ovs-ofctl exit
3522
3523 # Check that the flow monitor reported the same number of flows
3524 # added and deleted, but fewer than we actually added and deleted.
3525 adds=`grep -c 'ADDED.*reg1=' monitor.log`
3526 deletes=`grep -c 'DELETED.*reg1=' monitor.log`
3527 echo adds=$adds deletes=$deletes
3528 AT_CHECK([test $adds -gt 100 && test $adds -lt $n_msgs])
3529 AT_CHECK([test $adds = $deletes])
3530
3531 # Check that the flow monitor reported everything in the expected order:
3532 #
3533 #     event=ADDED table=0 cookie=0x1 reg1=0x22
3534 # ...
3535 #    NXT_FLOW_MONITOR_PAUSED:
3536 # ...
3537 #     event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
3538 # ...
3539 #     event=ADDED table=0 cookie=0x3 in_port=1
3540 #     event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
3541 #    NXT_FLOW_MONITOR_RESUMED:
3542 #
3543 # except that, between the PAUSED and RESUMED, the order of the ADDED
3544 # and MODIFIED lines lines depends on hash order, that is, it varies
3545 # as we change the hash function or change architecture.  Therefore,
3546 # we use a couple of tests below to accept both orders.
3547 AT_CHECK([ofctl_strip < monitor.log | sed -n -e '
3548 /reg1=0x22$/p
3549 /cookie=0x[[23]]/p
3550 /NXT_FLOW_MONITOR_PAUSED:/p
3551 /NXT_FLOW_MONITOR_RESUMED:/p
3552 ' > monitor.log.subset])
3553 AT_CHECK([grep -v MODIFIED monitor.log.subset], [0], [dnl
3554  event=ADDED table=0 cookie=0x1 reg1=0x22
3555 NXT_FLOW_MONITOR_PAUSED:
3556  event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
3557  event=ADDED table=0 cookie=0x3 in_port=1
3558 NXT_FLOW_MONITOR_RESUMED:
3559 ])
3560 AT_CHECK([grep -v ADDED monitor.log.subset], [0], [dnl
3561 NXT_FLOW_MONITOR_PAUSED:
3562  event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
3563  event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
3564 NXT_FLOW_MONITOR_RESUMED:
3565 ])
3566
3567 OVS_VSWITCHD_STOP
3568 AT_CLEANUP
3569
3570 AT_SETUP([ofproto - event filtering (OpenFlow 1.3)])
3571 AT_KEYWORDS([monitor])
3572 OVS_VSWITCHD_START
3573
3574 # Start a monitor, use the required protocol version
3575 ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3576 AT_CAPTURE_FILE([monitor.log])
3577
3578 # Send an OpenFlow13 message (04), OFPT_GET_ASYNC_REQUEST (1a), length (8), xid (0a)
3579 ovs-appctl -t ovs-ofctl ofctl/send 041a00080000000a
3580 ovs-appctl -t ovs-ofctl ofctl/barrier
3581
3582 # Check default setting
3583 read -r -d '' expected <<'EOF'
3584 EOF
3585
3586 AT_CHECK([ofctl_strip < monitor.log], [], [dnl
3587 send: OFPT_GET_ASYNC_REQUEST (OF1.3):
3588 OFPT_GET_ASYNC_REPLY (OF1.3):
3589  master:
3590        PACKET_IN: no_match action
3591      PORT_STATUS: add delete modify
3592     FLOW_REMOVED: idle hard delete
3593
3594  slave:
3595        PACKET_IN: (off)
3596      PORT_STATUS: add delete modify
3597     FLOW_REMOVED: (off)
3598 OFPT_BARRIER_REPLY (OF1.3):
3599 ])
3600
3601 OVS_VSWITCHD_STOP
3602 AT_CLEANUP
3603
3604 AT_SETUP([ofproto - ofport_request])
3605 OVS_VSWITCHD_START
3606 ADD_OF_PORTS([br0], [1], [2], [3])
3607
3608 set_and_check_specific_ofports () {
3609     ovs-vsctl set Interface p1 ofport_request="$1" -- \
3610               set Interface p2 ofport_request="$2" -- \
3611               set Interface p3 ofport_request="$3"
3612     ofports=`ovs-vsctl get Interface p1 ofport -- \
3613                        get Interface p2 ofport -- \
3614                        get Interface p3 ofport`
3615     AT_CHECK_UNQUOTED([echo $ofports], [0], [$1 $2 $3
3616 ])
3617 }
3618 for pre in      '1 2 3' '1 3 2' '2 1 3' '2 3 1' '3 1 2' '3 2 1'; do
3619     for post in '1 2 3' '1 3 2' '2 1 3' '2 3 1' '3 1 2' '3 2 1'; do
3620         echo -----------------------------------------------------------
3621         echo "Check changing port numbers from $pre to $post"
3622         set_and_check_specific_ofports $pre
3623         set_and_check_specific_ofports $post
3624     done
3625 done
3626
3627 ovs-vsctl del-port p3
3628
3629 set_and_check_poorly_specified_ofports () {
3630     ovs-vsctl set Interface p1 ofport_request="$1" -- \
3631               set Interface p2 ofport_request="$2"
3632     p1=`ovs-vsctl get Interface p1 ofport`
3633     p2=`ovs-vsctl get Interface p2 ofport`
3634     echo $p1 $p2
3635
3636     AT_CHECK([test "$p1" != "$p2"])
3637     if test "$1" = "$2" && test "$1" != '[[]]'; then
3638         # One port number must be the requested one.
3639         AT_CHECK([test "$p1" = "$1" || test "$p2" = "$1"])
3640         # The other port number must be different (already tested above).
3641     else
3642         AT_CHECK([test "$1" = '[[]]' || test "$p1" == "$1"])
3643         AT_CHECK([test "$2" = '[[]]' || test "$p2" == "$2"])
3644     fi
3645 }
3646 for pre in      '1 2' '[[]] 2' '1 [[]]' '[[]] [[]]' '2 1' '[[]] 1' '2 [[]]' \
3647                 '1 1' '2 2'; do
3648     for post in '1 2' '[[]] 2' '1 [[]]' '[[]] [[]]' '2 1' '[[]] 1' '2 [[]]' \
3649                 '1 1' '2 2'; do
3650         echo -----------------------------------------------------------
3651         echo "Check changing port numbers from $pre to $post"
3652         set_and_check_poorly_specified_ofports $pre
3653         set_and_check_poorly_specified_ofports $post
3654     done
3655 done
3656 OVS_VSWITCHD_STOP
3657 AT_CLEANUP
3658
3659
3660 AT_SETUP([ofproto - bundles, open (OpenFlow 1.4)])
3661 AT_KEYWORDS([monitor])
3662 OVS_VSWITCHD_START
3663
3664 # Start a monitor, use the required protocol version
3665 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3666 AT_CAPTURE_FILE([monitor.log])
3667
3668 # Send an OpenFlow14 message (05), OFPT_BUNDLE_CONTROL (21), length (10), xid (0a)
3669 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
3670 ovs-appctl -t ovs-ofctl ofctl/barrier
3671 ovs-appctl -t ovs-ofctl exit
3672
3673 AT_CHECK([ofctl_strip < monitor.log], [], [dnl
3674 send: OFPT_BUNDLE_CONTROL (OF1.4):
3675  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
3676 OFPT_BUNDLE_CONTROL (OF1.4):
3677  bundle_id=0x1 type=OPEN_REPLY flags=0
3678 OFPT_BARRIER_REPLY (OF1.4):
3679 ])
3680
3681 OVS_VSWITCHD_STOP
3682 AT_CLEANUP
3683
3684 AT_SETUP([ofproto - bundles, double open (OpenFlow 1.4)])
3685 AT_KEYWORDS([monitor])
3686 OVS_VSWITCHD_START
3687
3688 # Start a monitor, use the required protocol version
3689 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3690 AT_CAPTURE_FILE([monitor.log])
3691
3692 # Send twice an OpenFlow14 message (05), OFPT_BUNDLE_CONTROL (21), length (10), xid (0a)
3693 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
3694 ovs-appctl -t ovs-ofctl ofctl/barrier
3695 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
3696 ovs-appctl -t ovs-ofctl ofctl/barrier
3697 ovs-appctl -t ovs-ofctl exit
3698
3699 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3700 send: OFPT_BUNDLE_CONTROL (OF1.4):
3701  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
3702 OFPT_BUNDLE_CONTROL (OF1.4):
3703  bundle_id=0x1 type=OPEN_REPLY flags=0
3704 OFPT_BARRIER_REPLY (OF1.4):
3705 send: OFPT_BUNDLE_CONTROL (OF1.4):
3706  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
3707 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
3708 OFPT_BUNDLE_CONTROL (OF1.4):
3709  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
3710 OFPT_BARRIER_REPLY (OF1.4):
3711 ])
3712
3713 OVS_VSWITCHD_STOP
3714 AT_CLEANUP
3715
3716 AT_SETUP([ofproto - bundle close without open (OpenFlow 1.4)])
3717 AT_KEYWORDS([monitor])
3718 OVS_VSWITCHD_START
3719
3720 # Start a monitor, use the required protocol version
3721 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3722 AT_CAPTURE_FILE([monitor.log])
3723
3724 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 02"
3725 ovs-appctl -t ovs-ofctl ofctl/barrier
3726 ovs-appctl -t ovs-ofctl exit
3727
3728 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3729 send: OFPT_BUNDLE_CONTROL (OF1.4):
3730  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
3731 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
3732 OFPT_BUNDLE_CONTROL (OF1.4):
3733  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
3734 OFPT_BARRIER_REPLY (OF1.4):
3735 ])
3736
3737 OVS_VSWITCHD_STOP
3738 AT_CLEANUP
3739
3740 AT_SETUP([ofproto - bundle double close (OpenFlow 1.4)])
3741 AT_KEYWORDS([monitor])
3742 OVS_VSWITCHD_START
3743
3744 # Start a monitor, use the required protocol version
3745 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3746 AT_CAPTURE_FILE([monitor.log])
3747
3748 # Open, Close, Close
3749 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
3750 ovs-appctl -t ovs-ofctl ofctl/barrier
3751 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 02"
3752 ovs-appctl -t ovs-ofctl ofctl/barrier
3753 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 02"
3754 ovs-appctl -t ovs-ofctl ofctl/barrier
3755 ovs-appctl -t ovs-ofctl exit
3756
3757 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3758 send: OFPT_BUNDLE_CONTROL (OF1.4):
3759  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
3760 OFPT_BUNDLE_CONTROL (OF1.4):
3761  bundle_id=0x1 type=OPEN_REPLY flags=0
3762 OFPT_BARRIER_REPLY (OF1.4):
3763 send: OFPT_BUNDLE_CONTROL (OF1.4):
3764  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
3765 OFPT_BUNDLE_CONTROL (OF1.4):
3766  bundle_id=0x1 type=CLOSE_REPLY flags=0
3767 OFPT_BARRIER_REPLY (OF1.4):
3768 send: OFPT_BUNDLE_CONTROL (OF1.4):
3769  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
3770 OFPT_ERROR (OF1.4): OFPBFC_BUNDLE_CLOSED
3771 OFPT_BUNDLE_CONTROL (OF1.4):
3772  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
3773 OFPT_BARRIER_REPLY (OF1.4):
3774 ])
3775
3776 OVS_VSWITCHD_STOP
3777 AT_CLEANUP
3778
3779 AT_SETUP([ofproto - bundle close, different flags (OpenFlow 1.4)])
3780 AT_KEYWORDS([monitor])
3781 OVS_VSWITCHD_START
3782
3783 # Start a monitor, use the required protocol version
3784 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3785 AT_CAPTURE_FILE([monitor.log])
3786
3787 # Open, Close, Close
3788 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
3789 ovs-appctl -t ovs-ofctl ofctl/barrier
3790 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 01"
3791 ovs-appctl -t ovs-ofctl ofctl/barrier
3792 ovs-appctl -t ovs-ofctl exit
3793
3794 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3795 send: OFPT_BUNDLE_CONTROL (OF1.4):
3796  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
3797 OFPT_BUNDLE_CONTROL (OF1.4):
3798  bundle_id=0x1 type=OPEN_REPLY flags=0
3799 OFPT_BARRIER_REPLY (OF1.4):
3800 send: OFPT_BUNDLE_CONTROL (OF1.4):
3801  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
3802 OFPT_ERROR (OF1.4): OFPBFC_BAD_FLAGS
3803 OFPT_BUNDLE_CONTROL (OF1.4):
3804  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
3805 OFPT_BARRIER_REPLY (OF1.4):
3806 ])
3807
3808 OVS_VSWITCHD_STOP
3809 AT_CLEANUP
3810
3811 AT_SETUP([ofproto - bundle commit without open (OpenFlow 1.4)])
3812 AT_KEYWORDS([monitor])
3813 OVS_VSWITCHD_START
3814
3815 # Start a monitor, use the required protocol version
3816 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3817 AT_CAPTURE_FILE([monitor.log])
3818
3819 # Open, Close, Close
3820 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 04 00 02"
3821 ovs-appctl -t ovs-ofctl ofctl/barrier
3822 ovs-appctl -t ovs-ofctl exit
3823
3824 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3825 send: OFPT_BUNDLE_CONTROL (OF1.4):
3826  bundle_id=0x1 type=COMMIT_REQUEST flags=ordered
3827 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
3828 OFPT_BUNDLE_CONTROL (OF1.4):
3829  bundle_id=0x1 type=COMMIT_REQUEST flags=ordered
3830 OFPT_BARRIER_REPLY (OF1.4):
3831 ])
3832
3833 OVS_VSWITCHD_STOP
3834 AT_CLEANUP
3835
3836 AT_SETUP([ofproto - bundle commit, different flags (OpenFlow 1.4)])
3837 AT_KEYWORDS([monitor])
3838 OVS_VSWITCHD_START
3839
3840 # Start a monitor, use the required protocol version
3841 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3842 AT_CAPTURE_FILE([monitor.log])
3843
3844 # Open, Close, Close
3845 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 02"
3846 ovs-appctl -t ovs-ofctl ofctl/barrier
3847 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 04 00 01"
3848 ovs-appctl -t ovs-ofctl ofctl/barrier
3849 ovs-appctl -t ovs-ofctl exit
3850
3851 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3852 send: OFPT_BUNDLE_CONTROL (OF1.4):
3853  bundle_id=0x1 type=OPEN_REQUEST flags=ordered
3854 OFPT_BUNDLE_CONTROL (OF1.4):
3855  bundle_id=0x1 type=OPEN_REPLY flags=0
3856 OFPT_BARRIER_REPLY (OF1.4):
3857 send: OFPT_BUNDLE_CONTROL (OF1.4):
3858  bundle_id=0x1 type=COMMIT_REQUEST flags=atomic
3859 OFPT_ERROR (OF1.4): OFPBFC_BAD_FLAGS
3860 OFPT_BUNDLE_CONTROL (OF1.4):
3861  bundle_id=0x1 type=COMMIT_REQUEST flags=atomic
3862 OFPT_BARRIER_REPLY (OF1.4):
3863 ])
3864
3865 OVS_VSWITCHD_STOP
3866 AT_CLEANUP
3867
3868 AT_SETUP([ofproto - bundle discard without open (OpenFlow 1.4)])
3869 AT_KEYWORDS([monitor])
3870 OVS_VSWITCHD_START
3871
3872 # Start a monitor, use the required protocol version
3873 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3874 AT_CAPTURE_FILE([monitor.log])
3875
3876 # Open, Close, Close
3877 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 06 00 02"
3878 ovs-appctl -t ovs-ofctl ofctl/barrier
3879 ovs-appctl -t ovs-ofctl exit
3880
3881 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3882 send: OFPT_BUNDLE_CONTROL (OF1.4):
3883  bundle_id=0x1 type=DISCARD_REQUEST flags=ordered
3884 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
3885 OFPT_BUNDLE_CONTROL (OF1.4):
3886  bundle_id=0x1 type=DISCARD_REQUEST flags=ordered
3887 OFPT_BARRIER_REPLY (OF1.4):
3888 ])
3889
3890 OVS_VSWITCHD_STOP
3891 AT_CLEANUP
3892
3893
3894 AT_SETUP([ofproto - bundle with multiple flow mods (OpenFlow 1.4)])
3895 AT_KEYWORDS([monitor])
3896 OVS_VSWITCHD_START
3897
3898 AT_CHECK([ovs-appctl vlog/set vconn:dbg])
3899
3900 AT_CHECK([ovs-ofctl del-flows br0])
3901
3902 AT_DATA([flows.txt], [dnl
3903 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=1
3904 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=2
3905 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=3
3906 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=4
3907 delete
3908 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=5
3909 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=6
3910 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=7
3911 delete in_port=2 dl_src=00:88:99:aa:bb:cc
3912 ])
3913
3914 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
3915
3916 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
3917  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:5
3918  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:6
3919 NXST_FLOW reply:
3920 ])
3921
3922 AT_DATA([flows.txt], [dnl
3923 modify actions=drop
3924 modify_strict in_port=2 dl_src=00:77:88:99:aa:bb actions=7
3925 ])
3926
3927 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
3928
3929 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
3930  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
3931  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:7
3932 NXST_FLOW reply:
3933 ])
3934
3935 # Adding an existing flow acts as a modify, and delete_strict also works.
3936 AT_DATA([flows.txt], [dnl
3937 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=8
3938 delete_strict in_port=2 dl_src=00:66:77:88:99:aa
3939 add in_port=2 dl_src=00:66:77:88:99:aa actions=drop
3940 ])
3941
3942 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt])
3943
3944 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
3945  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:8
3946  in_port=2,dl_src=00:66:77:88:99:aa actions=drop
3947 NXST_FLOW reply:
3948 ])
3949
3950 dnl Check logs for OpenFlow trace
3951 # Prevent race.
3952 OVS_WAIT_UNTIL([cat ovs-vswitchd.log | vconn_windows_sub | test `grep -- "|vconn|DBG|unix: sent (Success): NXST_FLOW reply" | wc -l` -ge 3])
3953 AT_CHECK([print_vconn_debug | vconn_windows_sub | ofctl_strip], [0], [dnl
3954 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
3955  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
3956 vconn|DBG|unix: received: OFPT_HELLO:
3957  version bitmap: 0x01
3958 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
3959 vconn|DBG|unix: received: OFPT_FLOW_MOD: DEL actions=drop
3960 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
3961 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
3962 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
3963  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
3964 vconn|DBG|unix: received: OFPT_HELLO (OF1.4):
3965  version bitmap: 0x01, 0x05
3966 vconn|DBG|unix: negotiated OpenFlow version 0x05 (we support version 0x06 and earlier, peer supports versions 0x01, 0x05)
3967 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
3968  bundle_id=0 type=OPEN_REQUEST flags=atomic ordered
3969 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
3970  bundle_id=0 type=OPEN_REPLY flags=0
3971 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
3972  bundle_id=0 flags=atomic ordered
3973 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:66:77:88:99:aa idle:50 actions=output:1
3974 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
3975  bundle_id=0 flags=atomic ordered
3976 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:77:88:99:aa:bb idle:60 actions=output:2
3977 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
3978  bundle_id=0 flags=atomic ordered
3979 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:88:99:aa:bb:cc idle:70 actions=output:3
3980 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
3981  bundle_id=0 flags=atomic ordered
3982 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:66:77:88:99:aa idle:50 actions=output:4
3983 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
3984  bundle_id=0 flags=atomic ordered
3985 OFPT_FLOW_MOD (OF1.4): DEL table:255 actions=drop
3986 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
3987  bundle_id=0 flags=atomic ordered
3988 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:66:77:88:99:aa idle:50 actions=output:5
3989 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
3990  bundle_id=0 flags=atomic ordered
3991 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:77:88:99:aa:bb idle:60 actions=output:6
3992 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
3993  bundle_id=0 flags=atomic ordered
3994 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:88:99:aa:bb:cc idle:70 actions=output:7
3995 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
3996  bundle_id=0 flags=atomic ordered
3997 OFPT_FLOW_MOD (OF1.4): DEL table:255 in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
3998 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
3999  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4000 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4001  bundle_id=0 type=COMMIT_REPLY flags=0
4002 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4003  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4004 vconn|DBG|unix: received: OFPT_HELLO:
4005  version bitmap: 0x01
4006 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4007 vconn|DBG|unix: received: NXT_SET_FLOW_FORMAT: format=nxm
4008 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4009 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4010 vconn|DBG|unix: received: NXST_FLOW request:
4011 vconn|DBG|unix: sent (Success): NXST_FLOW reply:
4012  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:5
4013  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:6
4014 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4015  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4016 vconn|DBG|unix: received: OFPT_HELLO (OF1.4):
4017  version bitmap: 0x01, 0x05
4018 vconn|DBG|unix: negotiated OpenFlow version 0x05 (we support version 0x06 and earlier, peer supports versions 0x01, 0x05)
4019 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4020  bundle_id=0 type=OPEN_REQUEST flags=atomic ordered
4021 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4022  bundle_id=0 type=OPEN_REPLY flags=0
4023 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4024  bundle_id=0 flags=atomic ordered
4025 OFPT_FLOW_MOD (OF1.4): MOD actions=drop
4026 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4027  bundle_id=0 flags=atomic ordered
4028 OFPT_FLOW_MOD (OF1.4): MOD_STRICT in_port=2,dl_src=00:77:88:99:aa:bb actions=output:7
4029 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4030  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4031 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4032  bundle_id=0 type=COMMIT_REPLY flags=0
4033 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4034  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4035 vconn|DBG|unix: received: OFPT_HELLO:
4036  version bitmap: 0x01
4037 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4038 vconn|DBG|unix: received: NXT_SET_FLOW_FORMAT: format=nxm
4039 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4040 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4041 vconn|DBG|unix: received: NXST_FLOW request:
4042 vconn|DBG|unix: sent (Success): NXST_FLOW reply:
4043  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4044  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:7
4045 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4046  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4047 vconn|DBG|unix: received: OFPT_HELLO (OF1.4):
4048  version bitmap: 0x01, 0x05
4049 vconn|DBG|unix: negotiated OpenFlow version 0x05 (we support version 0x06 and earlier, peer supports versions 0x01, 0x05)
4050 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4051  bundle_id=0 type=OPEN_REQUEST flags=atomic ordered
4052 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4053  bundle_id=0 type=OPEN_REPLY flags=0
4054 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4055  bundle_id=0 flags=atomic ordered
4056 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:77:88:99:aa:bb idle:60 actions=output:8
4057 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4058  bundle_id=0 flags=atomic ordered
4059 OFPT_FLOW_MOD (OF1.4): DEL_STRICT table:255 in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4060 vconn|DBG|unix: received: OFPT_BUNDLE_ADD_MESSAGE (OF1.4):
4061  bundle_id=0 flags=atomic ordered
4062 OFPT_FLOW_MOD (OF1.4): ADD in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4063 vconn|DBG|unix: received: OFPT_BUNDLE_CONTROL (OF1.4):
4064  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4065 vconn|DBG|unix: sent (Success): OFPT_BUNDLE_CONTROL (OF1.4):
4066  bundle_id=0 type=COMMIT_REPLY flags=0
4067 vconn|DBG|unix: sent (Success): OFPT_HELLO (OF1.5):
4068  version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
4069 vconn|DBG|unix: received: OFPT_HELLO:
4070  version bitmap: 0x01
4071 vconn|DBG|unix: negotiated OpenFlow version 0x01 (we support version 0x06 and earlier, peer supports version 0x01)
4072 vconn|DBG|unix: received: NXT_SET_FLOW_FORMAT: format=nxm
4073 vconn|DBG|unix: received: OFPT_BARRIER_REQUEST:
4074 vconn|DBG|unix: sent (Success): OFPT_BARRIER_REPLY:
4075 vconn|DBG|unix: received: NXST_FLOW request: 
4076 vconn|DBG|unix: sent (Success): NXST_FLOW reply:
4077  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:8
4078  in_port=2,dl_src=00:66:77:88:99:aa actions=drop
4079 ])
4080
4081 OVS_VSWITCHD_STOP
4082 AT_CLEANUP
4083
4084
4085 AT_SETUP([ofproto - failing bundle commit (OpenFlow 1.4)])
4086 AT_KEYWORDS([monitor])
4087 OVS_VSWITCHD_START
4088
4089 AT_CHECK([ovs-ofctl del-flows br0])
4090
4091 ovs-ofctl add-flows br0 - <<EOF
4092 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=11
4093 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=22
4094 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=33
4095 EOF
4096 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4097  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:11
4098  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:22
4099  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=output:33
4100 NXST_FLOW reply:
4101 ])
4102
4103 # last line uses illegal table number (OVS internal table)
4104 AT_DATA([flows.txt], [dnl
4105 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=1
4106 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=2
4107 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=3
4108 modify idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=4
4109 delete
4110 add idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=5
4111 add idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=6
4112 add idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=7
4113 delete in_port=2 dl_src=00:88:99:aa:bb:cc
4114 add table=254 actions=drop
4115 ])
4116
4117 AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt 2>&1 | sed '/|WARN|/d
4118 s/unix:.*br0\.mgmt/unix:br0.mgmt/' | sed 's/(.* error)/(error)/'],
4119 [0], [dnl
4120 OFPT_ERROR (OF1.4) (xid=0xb): OFPBRC_EPERM
4121 OFPT_FLOW_MOD (OF1.4) (xid=0xb): ADD table:254 actions=drop
4122 OFPT_ERROR (OF1.4) (xid=0xd): OFPBFC_MSG_FAILED
4123 OFPT_BUNDLE_CONTROL (OF1.4) (xid=0xd):
4124  bundle_id=0 type=COMMIT_REQUEST flags=atomic ordered
4125 ovs-ofctl: talking to unix:br0.mgmt (error)
4126 ])
4127
4128 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
4129  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=output:11
4130  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=output:22
4131  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=output:33
4132 NXST_FLOW reply:
4133 ])
4134
4135 OVS_VSWITCHD_STOP
4136 AT_CLEANUP