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