3 AT_SETUP([ofproto - echo request])
5 AT_CHECK([ovs-ofctl -vwarn probe br0])
9 AT_SETUP([ofproto - feature request, config request])
11 AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
12 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
13 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
14 n_tables:255, n_buffers:256
15 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
16 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
17 LOCAL(br0): addr:aa:55:aa:55:00:00
20 speed: 100 Mbps now, 100 Mbps max
21 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
26 dnl This is really bare-bones.
27 dnl It at least checks request and reply serialization and deserialization.
28 AT_SETUP([ofproto - port stats])
30 AT_CHECK([ovs-ofctl -vwarn dump-ports br0], [0], [stdout])
31 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
32 OFPST_PORT reply: 1 ports
33 port 65534: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
34 tx pkts=0, bytes=0, drop=0, errs=0, coll=0
39 dnl This is really bare-bones.
40 dnl It at least checks request and reply serialization and deserialization.
41 AT_SETUP([ofproto - port-desc stats])
43 AT_CHECK([ovs-ofctl -vwarn dump-ports-desc br0], [0], [stdout])
44 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
45 OFPST_PORT_DESC reply:
46 LOCAL(br0): addr:aa:55:aa:55:00:00
49 speed: 100 Mbps now, 100 Mbps max
54 dnl This is really bare-bones.
55 dnl It at least checks request and reply serialization and deserialization.
56 AT_SETUP([ofproto - queue stats])
58 AT_CHECK([ovs-ofctl -vwarn queue-stats br0], [0], [stdout])
59 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
60 OFPST_QUEUE reply: 0 queues
62 AT_CHECK([ovs-ofctl -vwarn queue-stats br0 ALL 5], [0],
63 [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_QUEUE
64 OFPST_QUEUE request (xid=0x2):port=ALL queue=5
66 AT_CHECK([ovs-ofctl -vwarn queue-stats br0 10], [0],
67 [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_PORT
68 OFPST_QUEUE request (xid=0x2):port=10 queue=ALL
73 AT_SETUP([ofproto - mod-port])
75 for command_config_state in \
77 'noflood NO_FLOOD 0' \
78 'down PORT_DOWN,NO_FLOOD LINK_DOWN' \
79 'flood PORT_DOWN LINK_DOWN' \
80 'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
81 'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
82 'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
83 'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
84 'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
88 set $command_config_state
89 command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
90 AT_CHECK([ovs-ofctl -vwarn mod-port br0 br0 $command])
91 AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
92 AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
93 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
94 n_tables:255, n_buffers:256
95 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
96 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
97 LOCAL(br0): addr:aa:55:aa:55:00:00
100 speed: 100 Mbps now, 100 Mbps max
101 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
107 AT_SETUP([ofproto - basic flow_mod commands (NXM)])
109 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
111 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl add-flows br0 -])
112 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=2])
113 AT_CHECK([ovs-ofctl -F nxm add-flow br0 table=1,in_port=4,actions=3])
114 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
115 in_port=1 actions=output:2
116 in_port=2 actions=output:1
117 table=1, in_port=4 actions=output:3
120 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
121 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
123 AT_CHECK([ovs-ofctl del-flows br0])
124 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
129 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.0)])
131 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
133 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -F openflow10 add-flows br0 -])
134 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 in_port=1,actions=2])
135 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 table=1,in_port=4,actions=3])
136 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
137 in_port=1 actions=output:2
138 in_port=2 actions=output:1
139 table=1, in_port=4 actions=output:3
142 AT_CHECK([ovs-ofctl -F openflow10 dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
143 OFPST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
145 AT_CHECK([ovs-ofctl -F openflow10 del-flows br0])
146 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
151 AT_SETUP([ofproto - set-field flow_mod commands (NXM)])
153 AT_CHECK([ovs-ofctl add-flow br0 ipv6,table=1,in_port=3,actions=drop])
154 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])
155 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
156 table=1, ipv6,in_port=3 actions=load:0xa6badbfffefe59fa->NXM_NX_IPV6_SRC[[0..63]],load:0xfe8001234567890a->NXM_NX_IPV6_SRC[[64..127]]
162 AT_SETUP([ofproto - dump flows with cookie])
164 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
165 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
166 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
167 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
168 cookie=0x1, in_port=1 actions=output:1
169 cookie=0x2, in_port=2 actions=output:1
170 cookie=0x3, in_port=3 actions=output:1
173 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
174 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
176 AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/-1 | ofctl_strip | sort], [0], [dnl
177 cookie=0x3, in_port=3 actions=output:1
180 AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/-1 | STRIP_XIDS], [0], [dnl
181 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=1
186 AT_SETUP([ofproto - dump flows with cookie mask])
188 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
189 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
190 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
191 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
192 cookie=0x1, in_port=1 actions=output:1
193 cookie=0x2, in_port=2 actions=output:1
194 cookie=0x3, in_port=3 actions=output:1
197 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
198 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
200 AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/0x1 | ofctl_strip | sort], [0], [dnl
201 cookie=0x1, in_port=1 actions=output:1
202 cookie=0x3, in_port=3 actions=output:1
205 AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/0x1 | STRIP_XIDS], [0], [dnl
206 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
211 AT_SETUP([ofproto - mod flow with cookie change (OpenFlow 1.0)])
213 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 cookie=0x1,in_port=1,actions=1])
214 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
215 cookie=0x1, in_port=1 actions=output:1
219 AT_CHECK([ovs-ofctl -F openflow10 mod-flows br0 cookie=0x2,in_port=1,actions=1])
220 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
221 cookie=0x2, in_port=1 actions=output:1
227 AT_SETUP([ofproto - mod flow with cookie change (NXM)])
229 AT_CHECK([ovs-ofctl -F nxm add-flow br0 cookie=0x1,in_port=1,actions=1])
230 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
231 cookie=0x1, in_port=1 actions=output:1
235 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x2,in_port=1,actions=1])
236 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
237 cookie=0x2, in_port=1 actions=output:1
243 AT_SETUP([ofproto - mod flows based on cookie mask])
245 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
246 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
247 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
248 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
249 cookie=0x1, in_port=1 actions=output:1
250 cookie=0x1, in_port=2 actions=output:1
251 cookie=0x2, in_port=3 actions=output:1
255 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x1/0xff,actions=4])
256 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
257 cookie=0x1, in_port=1 actions=output:4
258 cookie=0x1, in_port=2 actions=output:4
259 cookie=0x2, in_port=3 actions=output:1
265 AT_SETUP([ofproto - mod flows based on cookie mask with cookie change])
267 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
268 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
269 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
270 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
271 cookie=0x1, in_port=1 actions=output:1
272 cookie=0x1, in_port=2 actions=output:1
273 cookie=0x2, in_port=3 actions=output:1
277 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/-1,cookie=4,actions=4])
278 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
279 cookie=0x2, in_port=3 actions=output:1
280 cookie=0x4, in_port=1 actions=output:4
281 cookie=0x4, in_port=2 actions=output:4
287 AT_SETUP([ofproto - mod flow with cookie miss (mask==0)])
289 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 in_port=1,actions=1])
290 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
291 in_port=1 actions=output:1
297 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0)])
299 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/1,in_port=1,actions=1])
300 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
306 AT_SETUP([ofproto - del flows with cookies])
308 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
309 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
310 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
311 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
312 cookie=0x1, in_port=1 actions=output:1
313 cookie=0x2, in_port=2 actions=output:1
314 cookie=0x3, in_port=3 actions=output:1
318 AT_CHECK([ovs-ofctl del-flows br0])
319 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
325 AT_SETUP([ofproto - del flows based on cookie])
327 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
328 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
329 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
330 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
331 cookie=0x1, in_port=1 actions=output:1
332 cookie=0x2, in_port=2 actions=output:1
333 cookie=0x3, in_port=3 actions=output:1
337 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/-1])
338 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
339 cookie=0x1, in_port=1 actions=output:1
340 cookie=0x2, in_port=2 actions=output:1
346 AT_SETUP([ofproto - del flows based on cookie mask])
348 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
349 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
350 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
351 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
352 cookie=0x1, in_port=1 actions=output:1
353 cookie=0x2, in_port=2 actions=output:1
354 cookie=0x3, in_port=3 actions=output:1
357 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/0x1])
358 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
359 cookie=0x2, in_port=2 actions=output:1
365 AT_SETUP([ofproto - del flows based on table id])
367 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
368 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
369 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
370 cookie=0x1, in_port=1 actions=output:1
371 cookie=0x2, table=1, in_port=2 actions=output:1
374 AT_CHECK([ovs-ofctl del-flows br0 table=0])
375 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
376 cookie=0x2, table=1, in_port=2 actions=output:1
379 AT_CHECK([ovs-ofctl del-flows br0 table=1])
380 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
383 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
384 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
385 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
386 cookie=0x1, in_port=1 actions=output:1
387 cookie=0x2, table=1, in_port=2 actions=output:1
390 AT_CHECK([ovs-ofctl del-flows br0])
391 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
397 AT_SETUP([ofproto - flow table configuration])
399 # Check the default configuration.
400 (echo "OFPST_TABLE reply (xid=0x2): 255 tables
401 0: classifier: wild=0x3fffff, max=1000000, active=0
404 while test $x -lt 254; do
405 printf " %d: %-8s: wild=0x3fffff, max=1000000, active=0
410 echo " 254: table254: wild=0x3fffff, max=1000000, active=2
411 lookup=0, matched=0") > expout
412 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
413 # Change the configuration.
416 -- --id=@t0 create Flow_Table name=main \
417 -- --id=@t1 create Flow_Table flow-limit=1024 \
418 -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
419 | perl $srcdir/uuidfilt.pl],
423 # Check that the configuration was updated.
424 mv expout orig-expout
425 (echo "OFPST_TABLE reply (xid=0x2): 255 tables
426 0: main : wild=0x3fffff, max=1000000, active=0
428 1: table1 : wild=0x3fffff, max= 1024, active=0
430 tail -n +6 orig-expout) > expout
431 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
435 AT_SETUP([ofproto - hard limits on flow table size])
437 # Configure a maximum of 4 flows.
440 -- --id=@t0 create Flow_Table flow-limit=4 \
441 -- set bridge br0 flow_tables:0=@t0 \
442 | perl $srcdir/uuidfilt.pl],
446 for in_port in 1 2 3 4; do
447 ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
449 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
450 in_port=1 actions=drop
451 in_port=2 actions=drop
452 in_port=3 actions=drop
453 in_port=4 actions=drop
456 # Adding another flow will be refused.
457 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
458 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
459 [OFPT_ERROR: OFPFMFC_ALL_TABLES_FULL
461 # Also a mod-flow that would add a flow will be refused.
462 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
463 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
464 [OFPT_ERROR: OFPFMFC_ALL_TABLES_FULL
466 # Replacing or modifying an existing flow is allowed.
467 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
468 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
469 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
470 in_port=1 actions=drop
471 in_port=2 actions=drop
472 in_port=3 actions=output:1
473 in_port=4 actions=NORMAL
479 AT_SETUP([ofproto - eviction upon table overflow])
481 # Configure a maximum of 4 flows.
484 -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
485 -- set bridge br0 flow_tables:0=@t0 \
486 | perl $srcdir/uuidfilt.pl],
490 for in_port in 4 3 2 1; do
491 ovs-ofctl add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
493 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
494 idle_timeout=10, in_port=1 actions=drop
495 idle_timeout=20, in_port=2 actions=drop
496 idle_timeout=30, in_port=3 actions=drop
497 idle_timeout=40, in_port=4 actions=drop
500 # Adding another flow will cause the one that expires soonest to be evicted.
501 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
502 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
503 idle_timeout=20, in_port=2 actions=drop
504 idle_timeout=30, in_port=3 actions=drop
505 idle_timeout=40, in_port=4 actions=drop
506 in_port=5 actions=drop
509 # A mod-flow that adds a flow also causes eviction, but replacing or
510 # modifying an existing flow doesn't.
511 AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
512 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
513 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
514 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
515 idle_timeout=30, in_port=3 actions=output:1
516 in_port=4 actions=NORMAL
517 in_port=5 actions=drop
518 in_port=6 actions=drop
521 # Flows with no timeouts at all cannot be evicted.
522 AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
523 AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
524 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
525 [OFPT_ERROR: OFPFMFC_ALL_TABLES_FULL
527 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
528 in_port=4 actions=NORMAL
529 in_port=5 actions=drop
530 in_port=6 actions=drop
531 in_port=7 actions=NORMAL
537 AT_SETUP([ofproto - eviction upon table overflow, with fairness])
539 # Configure a maximum of 4 flows.
542 -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
543 overflow-policy=evict \
544 groups='"NXM_OF_IN_PORT[[]]"' \
545 -- set bridge br0 flow_tables:0=@t0 \
546 | perl $srcdir/uuidfilt.pl],
550 ovs-ofctl add-flows br0 - <<EOF
551 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
552 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
553 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
554 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
556 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
557 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
558 idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
559 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
560 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
563 # Adding another flow will cause the one that expires soonest within
564 # the largest group (those with in_port=1) to be evicted. In this
565 # case this is not the same as the one that expires soonest overall
566 # (which is what makes the test interesting):
567 AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
568 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
569 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
570 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
571 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
572 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
575 # Enlarge the flow limit, change the eviction policy back to strictly
576 # based on expiration, and and add some flows.
577 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
578 ovs-ofctl add-flows br0 - <<EOF
579 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
580 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
581 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
583 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
584 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
585 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
586 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
587 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
588 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
589 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
590 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
593 # Adding another flow will cause the one that expires soonest overall
595 AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
596 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
597 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
598 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
599 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
600 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
601 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
602 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
603 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
606 # Reducing the flow limit also causes the flows that expire soonest
607 # overall to be evicted.
608 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
609 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
610 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
611 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
612 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
613 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
619 AT_SETUP([ofproto - asynchronous message control])
621 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
623 printf '\n\n--- check_async %d ---\n\n\n' $1
626 ovs-appctl -t ovs-ofctl ofctl/barrier
627 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
630 # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
631 ovs-ofctl -v packet-out br0 none controller '0001020304050010203040501234'
632 if test X"$1" = X"OFPR_ACTION"; then shift;
633 echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=NONE (via action) data_len=14 (unbuffered)
634 priority:0,tunnel:0,metadata:0,in_port:0000,tci(0) mac(00:10:20:30:40:50->00:01:02:03:04:05) type:1234"
637 # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
638 ovs-ofctl -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
639 if test X"$1" = X"OFPR_NO_MATCH"; then shift;
640 echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=NONE (via no_match) data_len=14 (unbuffered)
641 priority:0,tunnel:0,metadata:0,in_port:0000,tci(0) mac(00:10:20:30:40:50->00:01:02:03:04:05) type:1234"
644 # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
645 ovs-ofctl packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
646 if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
647 echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=NONE (via invalid_ttl) data_len=76 (unbuffered)
648 priority:0,tunnel:0,metadata:0,in_port:0000,tci(0) mac(00:26:b9:8c:b0:f9->00:25:83:df:b4:00) type:0800 proto:17 tos:0 ttl:0 ip(172.17.55.13->172.16.0.2) port(55155->53) udp_csum:8f6d"
651 # OFPT_PORT_STATUS, OFPPR_ADD
652 ovs-vsctl add-port br0 test -- set Interface test type=dummy
653 if test X"$1" = X"OFPPR_ADD"; then shift;
654 echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
657 speed: 100 Mbps now, 100 Mbps max"
660 # OFPT_PORT_STATUS, OFPPR_DELETE
661 ovs-vsctl del-port br0 test
662 if test X"$1" = X"OFPPR_DELETE"; then shift;
663 echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
666 speed: 100 Mbps now, 100 Mbps max"
669 # OFPT_FLOW_REMOVED, OFPRR_DELETE
670 ovs-ofctl add-flow br0 send_flow_rem,actions=drop
671 ovs-ofctl --strict del-flows br0 ''
672 if test X"$1" = X"OFPRR_DELETE"; then shift;
673 echo >>expout "OFPT_FLOW_REMOVED: reason=delete"
675 AT_FAIL_IF([test X"$1" != X])
677 ovs-appctl -t ovs-ofctl ofctl/barrier
678 echo >>expout "OFPT_BARRIER_REPLY:"
682 s/ (xid=0x[0-9a-fA-F]*)//
684 s/00:0.$/00:0x/' < monitor.log]],
688 # It's a service connection so initially there should be no async messages.
691 # Set miss_send_len to 128, turning on packet-ins for our service connection.
692 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
693 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
695 # Set miss_send_len to 128 and enable invalid_ttl.
696 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
697 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
699 # Become slave, which should disable everything except port status.
700 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
701 check_async 4 OFPPR_ADD OFPPR_DELETE
703 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
704 ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
705 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
707 # Set controller ID 123.
708 ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
709 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
711 # Restore controller ID 0.
712 ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
715 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
716 check_async 7 OFPR_ACTION OFPPR_ADD
718 ovs-appctl -t ovs-ofctl exit
722 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
723 dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
724 dnl controllers despite the spec) as meaning a packet that was generated
725 dnl by the controller.
726 AT_SETUP([ofproto - packet-out from controller])
729 # Start a monitor listening for packet-ins.
730 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
731 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
732 ovs-appctl -t ovs-ofctl ofctl/barrier
733 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
734 AT_CAPTURE_FILE([monitor.log])
736 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
737 AT_CHECK([ovs-ofctl packet-out br0 none controller '0001020304050010203040501234'])
738 AT_CHECK([ovs-ofctl packet-out br0 controller controller '0001020304050010203040505678'])
740 # Stop the monitor and check its output.
741 ovs-appctl -t ovs-ofctl ofctl/barrier
742 ovs-appctl -t ovs-ofctl exit
744 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
745 OFPT_PACKET_IN: total_len=14 in_port=NONE (via action) data_len=14 (unbuffered)
746 priority:0,tunnel:0,metadata:0,in_port:0000,tci(0) mac(00:10:20:30:40:50->00:01:02:03:04:05) type:1234
747 OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
748 priority:0,tunnel:0,metadata:0,in_port:0000,tci(0) mac(00:10:20:30:40:50->00:01:02:03:04:05) type:5678
755 dnl This test checks that metadata is encoded in packet_in structures,
756 dnl supported by NXAST.
757 AT_SETUP([ofproto - packet-out with metadata (NXM)])
760 # Start a monitor listening for packet-ins.
761 AT_CHECK([ovs-ofctl -P nxm monitor br0 --detach --no-chdir --pidfile])
762 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
763 ovs-appctl -t ovs-ofctl ofctl/barrier
764 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
765 AT_CAPTURE_FILE([monitor.log])
767 # Send a packet-out with a load action to set some metadata, and forward to controller
768 AT_CHECK([ovs-ofctl packet-out br0 none 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), controller' '0001020304050010203040501234'])
770 # Stop the monitor and check its output.
771 ovs-appctl -t ovs-ofctl ofctl/barrier
772 ovs-appctl -t ovs-ofctl exit
774 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
775 NXT_PACKET_IN: total_len=14 in_port=NONE metadata=0xfafafafa5a5a5a5a (via action) data_len=14 (unbuffered)
776 priority:0,tunnel:0,metadata:0,in_port:0000,tci(0) mac(00:10:20:30:40:50->00:01:02:03:04:05) type:1234
783 AT_SETUP([ofproto - flow monitoring])
784 AT_KEYWORDS([monitor])
787 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
789 # Start a monitor watching the flow table and check the initial reply.
790 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
791 AT_CAPTURE_FILE([monitor.log])
792 ovs-appctl -t ovs-ofctl ofctl/barrier
793 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
794 [NXST_FLOW_MONITOR reply:
795 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
799 # Add, delete, and modify some flows and check the updates.
800 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
801 ovs-ofctl add-flow br0 in_port=0,dl_vlan=124,actions=output:2
802 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:5
803 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=0,actions=output:6
804 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=1,actions=output:7
805 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:8
806 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=0,actions=output:9
807 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=1,actions=output:10
808 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,actions=output:11
809 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=0,actions=output:12
810 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=1,actions=output:13
811 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,actions=output:14
812 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:15
813 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:16
814 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:17
815 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:18
816 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:19
817 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:20
818 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=0,actions=output:21
819 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=1,actions=output:22
820 ovs-ofctl add-flow br0 in_port=0,actions=output:23
821 ovs-ofctl mod-flows br0 cookie=5,dl_vlan=123,actions=output:3
822 ovs-ofctl del-flows br0 dl_vlan=123
823 ovs-ofctl del-flows br0
824 ovs-appctl -t ovs-ofctl ofctl/barrier
826 # Sorts groups of lines that start with a space, without moving them
827 # past the nearest line that does not start with a space.
835 print $_ foreach sort(@buffer);
840 print $_ foreach sort(@buffer);
842 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | perl -e "$sort"], [0],
843 [NXST_FLOW_MONITOR reply (xid=0x0):
844 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
845 NXST_FLOW_MONITOR reply (xid=0x0):
846 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:5
847 NXST_FLOW_MONITOR reply (xid=0x0):
848 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:6
849 NXST_FLOW_MONITOR reply (xid=0x0):
850 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:7
851 NXST_FLOW_MONITOR reply (xid=0x0):
852 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:8
853 NXST_FLOW_MONITOR reply (xid=0x0):
854 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:9
855 NXST_FLOW_MONITOR reply (xid=0x0):
856 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:10
857 NXST_FLOW_MONITOR reply (xid=0x0):
858 event=ADDED table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
859 NXST_FLOW_MONITOR reply (xid=0x0):
860 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
861 NXST_FLOW_MONITOR reply (xid=0x0):
862 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
863 NXST_FLOW_MONITOR reply (xid=0x0):
864 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
865 NXST_FLOW_MONITOR reply (xid=0x0):
866 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:15
867 NXST_FLOW_MONITOR reply (xid=0x0):
868 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:16
869 NXST_FLOW_MONITOR reply (xid=0x0):
870 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:17
871 NXST_FLOW_MONITOR reply (xid=0x0):
872 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
873 NXST_FLOW_MONITOR reply (xid=0x0):
874 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
875 NXST_FLOW_MONITOR reply (xid=0x0):
876 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
877 NXST_FLOW_MONITOR reply (xid=0x0):
878 event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
879 NXST_FLOW_MONITOR reply (xid=0x0):
880 event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
881 NXST_FLOW_MONITOR reply (xid=0x0):
882 event=ADDED table=0 cookie=0 in_port=0 actions=output:23
883 NXST_FLOW_MONITOR reply (xid=0x0):
884 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
885 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
886 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
887 NXST_FLOW_MONITOR reply (xid=0x0):
888 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
889 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
890 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
891 NXST_FLOW_MONITOR reply (xid=0x0):
892 event=DELETED reason=delete table=0 cookie=0 in_port=0 actions=output:23
893 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
894 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
895 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
896 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
897 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
898 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
899 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
900 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
901 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
902 event=DELETED reason=delete table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
906 # Check that our own changes are reported as abbreviations.
907 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
908 ovs-ofctl add-flow br0 in_port=1,actions=output:2
909 ovs-ofctl add-flow br0 in_port=2,actions=output:1
910 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
911 ovs-appctl -t ovs-ofctl ofctl/barrier
912 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
914 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
915 [NXST_FLOW_MONITOR reply (xid=0x0):
916 event=ADDED table=0 cookie=0 in_port=1 actions=output:2
917 NXST_FLOW_MONITOR reply (xid=0x0):
918 event=ADDED table=0 cookie=0 in_port=2 actions=output:1
919 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
920 NXST_FLOW_MONITOR reply (xid=0x0):
921 event=ABBREV xid=0x12345678
925 ovs-appctl -t ovs-ofctl exit
929 AT_SETUP([ofproto - flow monitoring pause and resume])
930 AT_KEYWORDS([monitor])
932 # The maximum socket receive buffer size is important for this test, which
933 # tests behavior when the receive buffer overflows.
934 if test -e /proc/sys/net/core/rmem_max; then
936 rmem_max=`cat /proc/sys/net/core/rmem_max`
937 elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
940 # Don't know how to get maximum socket receive buffer on this OS
943 # Calculate the total amount of queuing: rmem_max in the kernel, 128 kB
944 # in ofproto sending userspace (see ofmonitor_flush() in connmgr.c).
945 queue_size=`expr $rmem_max + 128 \* 1024`
946 echo rmem_max=$rmem_max queue_size=$queue_size
948 # Each flow update message takes up at least 48 bytes of space in queues
949 # and in practice more than that.
950 n_msgs=`expr $queue_size / 48`
955 # Start a monitor watching the flow table, then make it block.
956 ON_EXIT([kill `cat ovs-ofctl.pid`])
957 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
958 AT_CAPTURE_FILE([monitor.log])
959 ovs-appctl -t ovs-ofctl ofctl/block
962 (echo "in_port=2,actions=output:2"
964 for ($i = 0; $i < '$n_msgs'; $i++) {
965 print "cookie=1,reg1=$i,actions=drop\n";
968 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
969 # Check that multipart flow dumps work properly:
970 AT_CHECK([ovs-ofctl diff-flows br0 flows.txt])
971 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,cookie=3,actions=drop])
972 AT_CHECK([ovs-ofctl mod-flows br0 in_port=2,cookie=2,actions=output:2])
973 AT_CHECK([ovs-ofctl del-flows br0 cookie=1/-1])
975 ovs-appctl -t ovs-ofctl ofctl/unblock
976 ovs-appctl -t ovs-ofctl ofctl/barrier
978 ovs-appctl -t ovs-ofctl exit
980 # Check that the flow monitor reported the same number of flows
981 # added and deleted, but fewer than we actually added and deleted.
982 adds=`grep -c 'ADDED.*reg1=' monitor.log`
983 deletes=`grep -c 'DELETED.*reg1=' monitor.log`
984 echo adds=$adds deletes=$deletes
985 AT_CHECK([test $adds -gt 100 && test $adds -lt $n_msgs])
986 AT_CHECK([test $adds = $deletes])
988 # Check that the flow monitor reported everything in the expected order:
990 # event=ADDED table=0 cookie=0x1 reg1=0x22
992 # NXT_FLOW_MONITOR_PAUSED:
994 # event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
996 # event=ADDED table=0 cookie=0x3 in_port=1
997 # event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
998 # NXT_FLOW_MONITOR_RESUMED:
1000 # except that, between the PAUSED and RESUMED, the order of the ADDED
1001 # and MODIFIED lines lines depends on hash order, that is, it varies
1002 # as we change the hash function or change architecture. Therefore,
1003 # we use a couple of tests below to accept both orders.
1004 AT_CHECK([ofctl_strip < monitor.log | sed -n -e '
1007 /NXT_FLOW_MONITOR_PAUSED:/p
1008 /NXT_FLOW_MONITOR_RESUMED:/p
1009 ' > monitor.log.subset])
1010 AT_CHECK([grep -v MODIFIED monitor.log.subset], [0], [dnl
1011 event=ADDED table=0 cookie=0x1 reg1=0x22
1012 NXT_FLOW_MONITOR_PAUSED:
1013 event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1014 event=ADDED table=0 cookie=0x3 in_port=1
1015 NXT_FLOW_MONITOR_RESUMED:
1017 AT_CHECK([grep -v ADDED monitor.log.subset], [0], [dnl
1018 NXT_FLOW_MONITOR_PAUSED:
1019 event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1020 event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
1021 NXT_FLOW_MONITOR_RESUMED: