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