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