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