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=0x1): OFPQOFC_BAD_QUEUE
64 OFPST_QUEUE request (xid=0x1):port=ALL queue=5
66 AT_CHECK([ovs-ofctl -vwarn queue-stats br0 10], [0],
67 [OFPT_ERROR (xid=0x1): OFPQOFC_BAD_PORT
68 OFPST_QUEUE request (xid=0x1):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=1,actions=0' | ovs-ofctl add-flows br0 -])
112 AT_CHECK([ovs-ofctl add-flow br0 in_port=0,actions=1])
113 AT_CHECK([ovs-ofctl -F nxm add-flow br0 table=1,in_port=3,actions=2])
114 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
115 in_port=0 actions=output:1
116 in_port=1 actions=output:0
117 table=1, in_port=3 actions=output:2
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=1,actions=0' | ovs-ofctl -F openflow10 add-flows br0 -])
134 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 in_port=0,actions=1])
135 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 table=1,in_port=3,actions=2])
136 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
137 in_port=0 actions=output:1
138 in_port=1 actions=output:0
139 table=1, in_port=3 actions=output:2
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 - dump flows with cookie])
153 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=0])
154 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=0])
155 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=0])
156 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
157 cookie=0x1, in_port=1 actions=output:0
158 cookie=0x2, in_port=2 actions=output:0
159 cookie=0x3, in_port=3 actions=output:0
162 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
163 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
165 AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/-1 | ofctl_strip | sort], [0], [dnl
166 cookie=0x3, in_port=3 actions=output:0
169 AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/-1 | STRIP_XIDS], [0], [dnl
170 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=1
175 AT_SETUP([ofproto - dump flows with cookie mask])
177 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=0])
178 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=0])
179 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=0])
180 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
181 cookie=0x1, in_port=1 actions=output:0
182 cookie=0x2, in_port=2 actions=output:0
183 cookie=0x3, in_port=3 actions=output:0
186 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
187 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
189 AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/0x1 | ofctl_strip | sort], [0], [dnl
190 cookie=0x1, in_port=1 actions=output:0
191 cookie=0x3, in_port=3 actions=output:0
194 AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/0x1 | STRIP_XIDS], [0], [dnl
195 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
200 AT_SETUP([ofproto - mod flow with cookie change (OpenFlow 1.0)])
202 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 cookie=0x1,in_port=1,actions=0])
203 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
204 cookie=0x1, in_port=1 actions=output:0
208 AT_CHECK([ovs-ofctl -F openflow10 mod-flows br0 cookie=0x2,in_port=1,actions=0])
209 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
210 cookie=0x2, in_port=1 actions=output:0
216 AT_SETUP([ofproto - mod flow with cookie change (NXM)])
218 AT_CHECK([ovs-ofctl -F nxm add-flow br0 cookie=0x1,in_port=1,actions=0])
219 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
220 cookie=0x1, in_port=1 actions=output:0
224 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x2,in_port=1,actions=0])
225 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
226 cookie=0x2, in_port=1 actions=output:0
232 AT_SETUP([ofproto - mod flows based on cookie mask])
234 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=0])
235 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=0])
236 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=0])
237 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
238 cookie=0x1, in_port=1 actions=output:0
239 cookie=0x1, in_port=2 actions=output:0
240 cookie=0x2, in_port=3 actions=output:0
244 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x1/0xff,actions=4])
245 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
246 cookie=0x1, in_port=1 actions=output:4
247 cookie=0x1, in_port=2 actions=output:4
248 cookie=0x2, in_port=3 actions=output:0
254 AT_SETUP([ofproto - mod flows based on cookie mask with cookie change])
256 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=0])
257 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=0])
258 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=0])
259 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
260 cookie=0x1, in_port=1 actions=output:0
261 cookie=0x1, in_port=2 actions=output:0
262 cookie=0x2, in_port=3 actions=output:0
266 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/-1,cookie=4,actions=4])
267 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
268 cookie=0x2, in_port=3 actions=output:0
269 cookie=0x4, in_port=1 actions=output:4
270 cookie=0x4, in_port=2 actions=output:4
276 AT_SETUP([ofproto - mod flow with cookie miss (mask==0)])
278 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 in_port=1,actions=0])
279 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
280 in_port=1 actions=output:0
286 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0)])
288 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/1,in_port=1,actions=0])
289 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
295 AT_SETUP([ofproto - del flows with cookies])
297 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=0])
298 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=0])
299 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=0])
300 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
301 cookie=0x1, in_port=1 actions=output:0
302 cookie=0x2, in_port=2 actions=output:0
303 cookie=0x3, in_port=3 actions=output:0
307 AT_CHECK([ovs-ofctl del-flows br0])
308 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
314 AT_SETUP([ofproto - del flows based on cookie])
316 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=0])
317 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=0])
318 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=0])
319 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
320 cookie=0x1, in_port=1 actions=output:0
321 cookie=0x2, in_port=2 actions=output:0
322 cookie=0x3, in_port=3 actions=output:0
326 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/-1])
327 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
328 cookie=0x1, in_port=1 actions=output:0
329 cookie=0x2, in_port=2 actions=output:0
335 AT_SETUP([ofproto - del flows based on cookie mask])
337 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=0])
338 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=0])
339 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=0])
340 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
341 cookie=0x1, in_port=1 actions=output:0
342 cookie=0x2, in_port=2 actions=output:0
343 cookie=0x3, in_port=3 actions=output:0
346 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/0x1])
347 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
348 cookie=0x2, in_port=2 actions=output:0
354 AT_SETUP([ofproto - flow table configuration])
356 # Check the default configuration.
357 (echo "OFPST_TABLE reply (xid=0x1): 255 tables
358 0: classifier: wild=0x3fffff, max=1000000, active=0
361 while test $x -lt 254; do
362 printf " %d: %-8s: wild=0x3fffff, max=1000000, active=0
367 echo " 254: table254: wild=0x3fffff, max=1000000, active=2
368 lookup=0, matched=0") > expout
369 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
370 # Change the configuration.
373 -- --id=@t0 create Flow_Table name=main \
374 -- --id=@t1 create Flow_Table flow-limit=1024 \
375 -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
376 | perl $srcdir/uuidfilt.pl],
380 # Check that the configuration was updated.
381 mv expout orig-expout
382 (echo "OFPST_TABLE reply (xid=0x1): 255 tables
383 0: main : wild=0x3fffff, max=1000000, active=0
385 1: table1 : wild=0x3fffff, max= 1024, active=0
387 tail -n +6 orig-expout) > expout
388 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
392 AT_SETUP([ofproto - hard limits on flow table size])
394 # Configure a maximum of 4 flows.
397 -- --id=@t0 create Flow_Table flow-limit=4 \
398 -- set bridge br0 flow_tables:0=@t0 \
399 | perl $srcdir/uuidfilt.pl],
403 for in_port in 1 2 3 4; do
404 ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
406 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
407 in_port=1 actions=drop
408 in_port=2 actions=drop
409 in_port=3 actions=drop
410 in_port=4 actions=drop
413 # Adding another flow will be refused.
414 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
415 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
416 [OFPT_ERROR: OFPFMFC_ALL_TABLES_FULL
418 # Also a mod-flow that would add a flow will be refused.
419 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
420 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
421 [OFPT_ERROR: OFPFMFC_ALL_TABLES_FULL
423 # Replacing or modifying an existing flow is allowed.
424 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
425 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
426 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
427 in_port=1 actions=drop
428 in_port=2 actions=drop
429 in_port=3 actions=output:1
430 in_port=4 actions=NORMAL
436 AT_SETUP([ofproto - eviction upon table overflow])
438 # Configure a maximum of 4 flows.
441 -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
442 -- set bridge br0 flow_tables:0=@t0 \
443 | perl $srcdir/uuidfilt.pl],
447 for in_port in 4 3 2 1; do
448 ovs-ofctl add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
450 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
451 idle_timeout=10, in_port=1 actions=drop
452 idle_timeout=20, in_port=2 actions=drop
453 idle_timeout=30, in_port=3 actions=drop
454 idle_timeout=40, in_port=4 actions=drop
457 # Adding another flow will cause the one that expires soonest to be evicted.
458 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
459 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
460 idle_timeout=20, in_port=2 actions=drop
461 idle_timeout=30, in_port=3 actions=drop
462 idle_timeout=40, in_port=4 actions=drop
463 in_port=5 actions=drop
466 # A mod-flow that adds a flow also causes eviction, but replacing or
467 # modifying an existing flow doesn't.
468 AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
469 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
470 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
471 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
472 idle_timeout=30, in_port=3 actions=output:1
473 in_port=4 actions=NORMAL
474 in_port=5 actions=drop
475 in_port=6 actions=drop
478 # Flows with no timeouts at all cannot be evicted.
479 AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
480 AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
481 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
482 [OFPT_ERROR: OFPFMFC_ALL_TABLES_FULL
484 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
485 in_port=4 actions=NORMAL
486 in_port=5 actions=drop
487 in_port=6 actions=drop
488 in_port=7 actions=NORMAL
494 AT_SETUP([ofproto - eviction upon table overflow, with fairness])
496 # Configure a maximum of 4 flows.
499 -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
500 overflow-policy=evict \
501 groups='"NXM_OF_IN_PORT[[]]"' \
502 -- set bridge br0 flow_tables:0=@t0 \
503 | perl $srcdir/uuidfilt.pl],
507 ovs-ofctl add-flows br0 - <<EOF
508 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
509 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
510 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
511 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
513 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
514 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
515 idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
516 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
517 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
520 # Adding another flow will cause the one that expires soonest within
521 # the largest group (those with in_port=1) to be evicted. In this
522 # case this is not the same as the one that expires soonest overall
523 # (which is what makes the test interesting):
524 AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
525 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
526 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
527 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
528 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
529 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
532 # Enlarge the flow limit, change the eviction policy back to strictly
533 # based on expiration, and and add some flows.
534 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
535 ovs-ofctl add-flows br0 - <<EOF
536 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
537 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
538 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
540 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
541 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
542 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
543 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
544 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
545 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
546 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
547 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
550 # Adding another flow will cause the one that expires soonest overall
552 AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
553 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
554 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
555 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
556 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
557 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
558 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
559 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
560 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
563 # Reducing the flow limit also causes the flows that expire soonest
564 # overall to be evicted.
565 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
566 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
567 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
568 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
569 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
570 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
576 AT_SETUP([ofproto - asynchronous message control])
578 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
580 printf '\n\n--- check_async %d ---\n\n\n' $1
583 ovs-appctl -t ovs-ofctl ofctl/barrier
584 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
587 # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
588 ovs-ofctl -v packet-out br0 none controller '0001020304050010203040501234'
589 if test X"$1" = X"OFPR_ACTION"; then shift;
590 echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=NONE (via action) data_len=14 (unbuffered)
591 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 proto:0 tos:0 ttl:0 ip(0.0.0.0->0.0.0.0)"
594 # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
595 ovs-ofctl -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
596 if test X"$1" = X"OFPR_NO_MATCH"; then shift;
597 echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=NONE (via no_match) data_len=14 (unbuffered)
598 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 proto:0 tos:0 ttl:0 ip(0.0.0.0->0.0.0.0)"
601 # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
602 ovs-ofctl packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
603 if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
604 echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=NONE (via invalid_ttl) data_len=76 (unbuffered)
605 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"
608 # OFPT_PORT_STATUS, OFPPR_ADD
609 ovs-vsctl add-port br0 test -- set Interface test type=dummy
610 if test X"$1" = X"OFPPR_ADD"; then shift;
611 echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
614 speed: 100 Mbps now, 100 Mbps max"
617 # OFPT_PORT_STATUS, OFPPR_DELETE
618 ovs-vsctl del-port br0 test
619 if test X"$1" = X"OFPPR_DELETE"; then shift;
620 echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
623 speed: 100 Mbps now, 100 Mbps max"
626 # OFPT_FLOW_REMOVED, OFPRR_DELETE
627 ovs-ofctl add-flow br0 send_flow_rem,actions=drop
628 ovs-ofctl --strict del-flows br0 ''
629 if test X"$1" = X"OFPRR_DELETE"; then shift;
630 echo >>expout "OFPT_FLOW_REMOVED: reason=delete"
632 AT_FAIL_IF([test X"$1" != X])
634 ovs-appctl -t ovs-ofctl ofctl/barrier
635 echo >>expout "OFPT_BARRIER_REPLY:"
639 s/ (xid=0x[0-9a-fA-F]*)//
641 s/00:0.$/00:0x/' < monitor.log]],
645 # It's a service connection so initially there should be no async messages.
648 # Set miss_send_len to 128, turning on packet-ins for our service connection.
649 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
650 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
652 # Set miss_send_len to 128 and enable invalid_ttl.
653 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
654 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
656 # Become slave, which should disable everything except port status.
657 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
658 check_async 4 OFPPR_ADD OFPPR_DELETE
660 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
661 ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
662 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
664 # Set controller ID 123.
665 ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
666 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
668 # Restore controller ID 0.
669 ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
672 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
673 check_async 7 OFPR_ACTION OFPPR_ADD
675 ovs-appctl -t ovs-ofctl exit
679 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
680 dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
681 dnl controllers despite the spec) as meaning a packet that was generated
682 dnl by the controller.
683 AT_SETUP([ofproto - packet-out from controller])
686 # Start a monitor listening for packet-ins.
687 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
688 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
689 ovs-appctl -t ovs-ofctl ofctl/barrier
690 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
691 AT_CAPTURE_FILE([monitor.log])
693 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
694 AT_CHECK([ovs-ofctl packet-out br0 none controller '0001020304050010203040501234'])
695 AT_CHECK([ovs-ofctl packet-out br0 65533 controller '0001020304050010203040505678'])
697 # Stop the monitor and check its output.
698 ovs-appctl -t ovs-ofctl ofctl/barrier
699 ovs-appctl -t ovs-ofctl exit
701 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
702 OFPT_PACKET_IN: total_len=14 in_port=NONE (via action) data_len=14 (unbuffered)
703 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 proto:0 tos:0 ttl:0 ip(0.0.0.0->0.0.0.0)
704 OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
705 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 proto:0 tos:0 ttl:0 ip(0.0.0.0->0.0.0.0)
712 dnl This test checks that metadata is encoded in packet_in structures,
713 dnl supported by NXAST.
714 AT_SETUP([ofproto - packet-out with metadata (NXM)])
717 # Start a monitor listening for packet-ins.
718 AT_CHECK([ovs-ofctl -P nxm monitor br0 --detach --no-chdir --pidfile])
719 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
720 ovs-appctl -t ovs-ofctl ofctl/barrier
721 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
722 AT_CAPTURE_FILE([monitor.log])
724 # Send a packet-out with a load action to set some metadata, and forward to controller
725 AT_CHECK([ovs-ofctl packet-out br0 none 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), controller' '0001020304050010203040501234'])
727 # Stop the monitor and check its output.
728 ovs-appctl -t ovs-ofctl ofctl/barrier
729 ovs-appctl -t ovs-ofctl exit
731 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
732 NXT_PACKET_IN: total_len=14 in_port=NONE tun_id=0x0 metadata=0xfafafafa5a5a5a5a reg0=0x0 reg1=0x0 reg2=0x0 reg3=0x0 reg4=0x0 reg5=0x0 reg6=0x0 reg7=0x0 (via action) data_len=14 (unbuffered)
733 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 proto:0 tos:0 ttl:0 ip(0.0.0.0->0.0.0.0)
740 AT_SETUP([ofproto - flow monitoring])
741 AT_KEYWORDS([monitor])
744 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
746 # Start a monitor watching the flow table and check the initial reply.
747 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
748 AT_CAPTURE_FILE([monitor.log])
749 ovs-appctl -t ovs-ofctl ofctl/barrier
750 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
751 [NXST_FLOW_MONITOR reply:
752 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
756 # Add, delete, and modify some flows and check the updates.
757 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
758 ovs-ofctl add-flow br0 in_port=0,dl_vlan=124,actions=output:2
759 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:5
760 ovs-ofctl mod-flows br0 cookie=5,dl_vlan=123,actions=output:3
761 ovs-ofctl del-flows br0 dl_vlan=123
762 ovs-ofctl del-flows br0
763 ovs-appctl -t ovs-ofctl ofctl/barrier
764 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
765 [NXST_FLOW_MONITOR reply (xid=0x0):
766 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
767 NXST_FLOW_MONITOR reply (xid=0x0):
768 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:5
769 NXST_FLOW_MONITOR reply (xid=0x0):
770 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
771 NXST_FLOW_MONITOR reply (xid=0x0):
772 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
773 NXST_FLOW_MONITOR reply (xid=0x0):
774 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
778 # Check that our own changes are reported as abbreviations.
779 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
780 ovs-ofctl add-flow br0 in_port=1,actions=output:2
781 ovs-ofctl add-flow br0 in_port=2,actions=output:1
782 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
783 ovs-appctl -t ovs-ofctl ofctl/barrier
784 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
786 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
787 [NXST_FLOW_MONITOR reply (xid=0x0):
788 event=ADDED table=0 cookie=0 in_port=1 actions=output:2
789 NXST_FLOW_MONITOR reply (xid=0x0):
790 event=ADDED table=0 cookie=0 in_port=2 actions=output:1
791 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
792 NXST_FLOW_MONITOR reply (xid=0x0):
793 event=ABBREV xid=0x12345678
797 ovs-appctl -t ovs-ofctl exit
801 AT_SETUP([ofproto - flow monitoring pause and resume])
802 AT_KEYWORDS([monitor])
804 # With a Linux kernel, this file has the maximum socket receive buffer
805 # size. That's important for this test, which tests behavior when the
806 # receive buffer overflows.
807 AT_SKIP_IF([test ! -e /proc/sys/net/core/rmem_max])
809 # Calculate the total amount of queuing: rmem_max in the kernel, 128 kB
810 # in ofproto sending userspace (see ofmonitor_flush() in connmgr.c).
811 rmem_max=`cat /proc/sys/net/core/rmem_max`
812 queue_size=`expr $rmem_max + 128 \* 1024`
813 echo rmem_max=$rmem_max queue_size=$queue_size
815 # Each flow update message takes up at least 48 bytes of space in queues
816 # and in practice more than that.
817 n_msgs=`expr $queue_size / 48`
822 # Start a monitor watching the flow table, then make it block.
823 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
824 AT_CAPTURE_FILE([monitor.log])
825 ovs-appctl -t ovs-ofctl ofctl/block
828 (echo "in_port=2,actions=output:2"
830 for ($i = 0; $i < '$n_msgs'; $i++) {
831 print "cookie=1,reg1=$i,actions=drop\n";
834 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
835 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,cookie=3,actions=drop])
836 AT_CHECK([ovs-ofctl mod-flows br0 in_port=2,cookie=2,actions=output:2])
837 AT_CHECK([ovs-ofctl del-flows br0 cookie=1/-1])
839 ovs-appctl -t ovs-ofctl ofctl/unblock
840 ovs-appctl -t ovs-ofctl ofctl/barrier
842 ovs-appctl -t ovs-ofctl exit
844 # Check that the flow monitor reported the same number of flows
845 # added and deleted, but fewer than we actually added and deleted.
846 adds=`grep -c 'ADDED.*reg1=' monitor.log`
847 deletes=`grep -c 'DELETED.*reg1=' monitor.log`
848 echo adds=$adds deletes=$deletes
849 AT_CHECK([test $adds -gt 100 && test $adds -lt $n_msgs])
850 AT_CHECK([test $adds = $deletes])
852 # Check that the flow monitor reported everything in the expected order.
853 AT_CHECK([ofctl_strip < monitor.log | sed -n -e '
856 /NXT_FLOW_MONITOR_PAUSED:/p
857 /NXT_FLOW_MONITOR_RESUMED:/p
859 [ event=ADDED table=0 cookie=0x1 reg1=0x22
860 NXT_FLOW_MONITOR_PAUSED:
861 event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
862 event=ADDED table=0 cookie=0x3 in_port=1
863 event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
864 NXT_FLOW_MONITOR_RESUMED: