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