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