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