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 AT_SETUP([ofproto - set OpenFlow port number])
28 [add-port br0 p1 -- set Interface p1 type=dummy --\
29 add-port br0 p2 -- set Interface p2 type=dummy ofport_request=99])
30 AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
31 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
32 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
33 n_tables:255, n_buffers:256
34 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
35 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
36 1(p1): addr:aa:55:aa:55:00:01
39 speed: 100 Mbps now, 100 Mbps max
40 99(p2): addr:aa:55:aa:55:00:02
43 speed: 100 Mbps now, 100 Mbps max
44 LOCAL(br0): addr:aa:55:aa:55:00:00
47 speed: 100 Mbps now, 100 Mbps max
48 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
53 dnl This is really bare-bones.
54 dnl It at least checks request and reply serialization and deserialization.
55 AT_SETUP([ofproto - port stats])
57 AT_CHECK([ovs-ofctl -vwarn dump-ports br0], [0], [stdout])
58 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
59 OFPST_PORT reply: 1 ports
60 port 65534: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
61 tx pkts=0, bytes=0, drop=0, errs=0, coll=0
66 dnl This is really bare-bones.
67 dnl It at least checks request and reply serialization and deserialization.
68 AT_SETUP([ofproto - port-desc stats])
70 AT_CHECK([ovs-ofctl -vwarn dump-ports-desc br0], [0], [stdout])
71 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
72 OFPST_PORT_DESC reply:
73 LOCAL(br0): addr:aa:55:aa:55:00:00
76 speed: 100 Mbps now, 100 Mbps max
81 dnl This is really bare-bones.
82 dnl It at least checks request and reply serialization and deserialization.
83 AT_SETUP([ofproto - queue stats])
85 AT_CHECK([ovs-ofctl -vwarn queue-stats br0], [0], [stdout])
86 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
87 OFPST_QUEUE reply: 0 queues
89 AT_CHECK([ovs-ofctl -vwarn queue-stats br0 ALL 5], [0],
90 [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_QUEUE
91 OFPST_QUEUE request (xid=0x2):port=ALL queue=5
93 AT_CHECK([ovs-ofctl -vwarn queue-stats br0 10], [0],
94 [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_PORT
95 OFPST_QUEUE request (xid=0x2):port=10 queue=ALL
100 AT_SETUP([ofproto - mod-port])
102 for command_config_state in \
104 'noflood NO_FLOOD 0' \
105 'down PORT_DOWN,NO_FLOOD LINK_DOWN' \
106 'flood PORT_DOWN LINK_DOWN' \
107 'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
108 'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
109 'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
110 'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
111 'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
115 set $command_config_state
116 command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
117 AT_CHECK([ovs-ofctl -vwarn mod-port br0 br0 $command])
118 AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
119 AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
120 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
121 n_tables:255, n_buffers:256
122 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
123 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
124 LOCAL(br0): addr:aa:55:aa:55:00:00
127 speed: 100 Mbps now, 100 Mbps max
128 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
134 AT_SETUP([ofproto - basic flow_mod commands (NXM)])
136 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
138 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl add-flows br0 -])
139 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=2])
140 AT_CHECK([ovs-ofctl -F nxm add-flow br0 table=1,in_port=4,actions=3])
141 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
142 in_port=1 actions=output:2
143 in_port=2 actions=output:1
144 table=1, in_port=4 actions=output:3
147 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
148 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
150 AT_CHECK([ovs-ofctl del-flows br0])
151 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
156 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.0)])
158 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
160 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -F openflow10 add-flows br0 -])
161 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 in_port=1,actions=2])
162 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 table=1,in_port=4,actions=3])
163 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
164 in_port=1 actions=output:2
165 in_port=2 actions=output:1
166 table=1, in_port=4 actions=output:3
169 AT_CHECK([ovs-ofctl -F openflow10 dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
170 OFPST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
172 AT_CHECK([ovs-ofctl -F openflow10 del-flows br0])
173 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
178 AT_SETUP([ofproto - set-field flow_mod commands (NXM)])
180 AT_CHECK([ovs-ofctl add-flow br0 ipv6,table=1,in_port=3,actions=drop])
181 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])
182 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
183 table=1, ipv6,in_port=3 actions=load:0xa6badbfffefe59fa->NXM_NX_IPV6_SRC[[0..63]],load:0xfe8001234567890a->NXM_NX_IPV6_SRC[[64..127]]
189 AT_SETUP([ofproto - dump flows with cookie])
191 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
192 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
193 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
194 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
195 cookie=0x1, in_port=1 actions=output:1
196 cookie=0x2, in_port=2 actions=output:1
197 cookie=0x3, in_port=3 actions=output:1
200 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
201 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
203 AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/-1 | ofctl_strip | sort], [0], [dnl
204 cookie=0x3, in_port=3 actions=output:1
207 AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/-1 | STRIP_XIDS], [0], [dnl
208 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=1
213 AT_SETUP([ofproto - dump flows with cookie mask])
215 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
216 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
217 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
218 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
219 cookie=0x1, in_port=1 actions=output:1
220 cookie=0x2, in_port=2 actions=output:1
221 cookie=0x3, in_port=3 actions=output:1
224 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
225 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
227 AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/0x1 | ofctl_strip | sort], [0], [dnl
228 cookie=0x1, in_port=1 actions=output:1
229 cookie=0x3, in_port=3 actions=output:1
232 AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/0x1 | STRIP_XIDS], [0], [dnl
233 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
238 AT_SETUP([ofproto - mod flow with cookie change (OpenFlow 1.0)])
240 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 cookie=0x1,in_port=1,actions=1])
241 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
242 cookie=0x1, in_port=1 actions=output:1
246 AT_CHECK([ovs-ofctl -F openflow10 mod-flows br0 cookie=0x2,in_port=1,actions=1])
247 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
248 cookie=0x2, in_port=1 actions=output:1
254 AT_SETUP([ofproto - mod flow with cookie change (NXM)])
256 AT_CHECK([ovs-ofctl -F nxm add-flow br0 cookie=0x1,in_port=1,actions=1])
257 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
258 cookie=0x1, in_port=1 actions=output:1
262 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x2,in_port=1,actions=1])
263 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
264 cookie=0x2, in_port=1 actions=output:1
270 AT_SETUP([ofproto - mod flows based on cookie mask])
272 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
273 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
274 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
275 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
276 cookie=0x1, in_port=1 actions=output:1
277 cookie=0x1, in_port=2 actions=output:1
278 cookie=0x2, in_port=3 actions=output:1
282 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x1/0xff,actions=4])
283 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
284 cookie=0x1, in_port=1 actions=output:4
285 cookie=0x1, in_port=2 actions=output:4
286 cookie=0x2, in_port=3 actions=output:1
292 AT_SETUP([ofproto - mod flows based on cookie mask with cookie change])
294 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
295 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
296 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
297 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
298 cookie=0x1, in_port=1 actions=output:1
299 cookie=0x1, in_port=2 actions=output:1
300 cookie=0x2, in_port=3 actions=output:1
304 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/-1,cookie=4,actions=4])
305 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
306 cookie=0x2, in_port=3 actions=output:1
307 cookie=0x4, in_port=1 actions=output:4
308 cookie=0x4, in_port=2 actions=output:4
314 AT_SETUP([ofproto - mod flow with cookie miss (mask==0)])
316 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 in_port=1,actions=1])
317 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
318 in_port=1 actions=output:1
324 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0)])
326 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/1,in_port=1,actions=1])
327 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
333 AT_SETUP([ofproto - del flows with cookies])
335 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
336 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
337 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=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
341 cookie=0x3, in_port=3 actions=output:1
345 AT_CHECK([ovs-ofctl del-flows br0])
346 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
352 AT_SETUP([ofproto - del flows based on cookie])
354 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
355 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
356 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
357 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
358 cookie=0x1, in_port=1 actions=output:1
359 cookie=0x2, in_port=2 actions=output:1
360 cookie=0x3, in_port=3 actions=output:1
364 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/-1])
365 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
366 cookie=0x1, in_port=1 actions=output:1
367 cookie=0x2, in_port=2 actions=output:1
373 AT_SETUP([ofproto - del flows based on cookie mask])
375 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
376 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
377 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
378 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
379 cookie=0x1, in_port=1 actions=output:1
380 cookie=0x2, in_port=2 actions=output:1
381 cookie=0x3, in_port=3 actions=output:1
384 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/0x1])
385 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
386 cookie=0x2, in_port=2 actions=output:1
392 AT_SETUP([ofproto - del flows based on table id])
394 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
395 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
396 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
397 cookie=0x1, in_port=1 actions=output:1
398 cookie=0x2, table=1, in_port=2 actions=output:1
401 AT_CHECK([ovs-ofctl del-flows br0 table=0])
402 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
403 cookie=0x2, table=1, in_port=2 actions=output:1
406 AT_CHECK([ovs-ofctl del-flows br0 table=1])
407 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
410 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
411 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
412 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
413 cookie=0x1, in_port=1 actions=output:1
414 cookie=0x2, table=1, in_port=2 actions=output:1
417 AT_CHECK([ovs-ofctl del-flows br0])
418 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
424 AT_SETUP([ofproto - flow table configuration])
426 # Check the default configuration.
427 (echo "OFPST_TABLE reply (xid=0x2): 255 tables
428 0: classifier: wild=0x3fffff, max=1000000, active=0
431 while test $x -lt 254; do
432 printf " %d: %-8s: wild=0x3fffff, max=1000000, active=0
437 echo " 254: table254: wild=0x3fffff, max=1000000, active=2
438 lookup=0, matched=0") > expout
439 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
440 # Change the configuration.
443 -- --id=@t0 create Flow_Table name=main \
444 -- --id=@t1 create Flow_Table flow-limit=1024 \
445 -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
446 | perl $srcdir/uuidfilt.pl],
450 # Check that the configuration was updated.
451 mv expout orig-expout
452 (echo "OFPST_TABLE reply (xid=0x2): 255 tables
453 0: main : wild=0x3fffff, max=1000000, active=0
455 1: table1 : wild=0x3fffff, max= 1024, active=0
457 tail -n +6 orig-expout) > expout
458 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
462 AT_SETUP([ofproto - hard limits on flow table size])
464 # Configure a maximum of 4 flows.
467 -- --id=@t0 create Flow_Table flow-limit=4 \
468 -- set bridge br0 flow_tables:0=@t0 \
469 | perl $srcdir/uuidfilt.pl],
473 for in_port in 1 2 3 4; do
474 ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
476 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
477 in_port=1 actions=drop
478 in_port=2 actions=drop
479 in_port=3 actions=drop
480 in_port=4 actions=drop
483 # Adding another flow will be refused.
484 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
485 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
486 [OFPT_ERROR: OFPFMFC_TABLE_FULL
488 # Also a mod-flow that would add a flow will be refused.
489 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
490 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
491 [OFPT_ERROR: OFPFMFC_TABLE_FULL
493 # Replacing or modifying an existing flow is allowed.
494 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
495 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
496 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
497 in_port=1 actions=drop
498 in_port=2 actions=drop
499 in_port=3 actions=output:1
500 in_port=4 actions=NORMAL
506 AT_SETUP([ofproto - eviction upon table overflow])
508 # Configure a maximum of 4 flows.
511 -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
512 -- set bridge br0 flow_tables:0=@t0 \
513 | perl $srcdir/uuidfilt.pl],
517 for in_port in 4 3 2 1; do
518 ovs-ofctl add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
520 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
521 idle_timeout=10, in_port=1 actions=drop
522 idle_timeout=20, in_port=2 actions=drop
523 idle_timeout=30, in_port=3 actions=drop
524 idle_timeout=40, in_port=4 actions=drop
527 # Adding another flow will cause the one that expires soonest to be evicted.
528 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
529 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
530 idle_timeout=20, in_port=2 actions=drop
531 idle_timeout=30, in_port=3 actions=drop
532 idle_timeout=40, in_port=4 actions=drop
533 in_port=5 actions=drop
536 # A mod-flow that adds a flow also causes eviction, but replacing or
537 # modifying an existing flow doesn't.
538 AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
539 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
540 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
541 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
542 idle_timeout=30, in_port=3 actions=output:1
543 in_port=4 actions=NORMAL
544 in_port=5 actions=drop
545 in_port=6 actions=drop
548 # Flows with no timeouts at all cannot be evicted.
549 AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
550 AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
551 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
552 [OFPT_ERROR: OFPFMFC_TABLE_FULL
554 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
555 in_port=4 actions=NORMAL
556 in_port=5 actions=drop
557 in_port=6 actions=drop
558 in_port=7 actions=NORMAL
564 AT_SETUP([ofproto - eviction upon table overflow, with fairness])
566 # Configure a maximum of 4 flows.
569 -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
570 overflow-policy=evict \
571 groups='"NXM_OF_IN_PORT[[]]"' \
572 -- set bridge br0 flow_tables:0=@t0 \
573 | perl $srcdir/uuidfilt.pl],
577 ovs-ofctl add-flows br0 - <<EOF
578 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
579 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
580 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
581 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 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=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
586 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
587 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
590 # Adding another flow will cause the one that expires soonest within
591 # the largest group (those with in_port=1) to be evicted. In this
592 # case this is not the same as the one that expires soonest overall
593 # (which is what makes the test interesting):
594 AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
595 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
596 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
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 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
602 # Enlarge the flow limit, change the eviction policy back to strictly
603 # based on expiration, and and add some flows.
604 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
605 ovs-ofctl add-flows br0 - <<EOF
606 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
607 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
608 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
610 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
611 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
612 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
613 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
614 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
615 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
616 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
617 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
620 # Adding another flow will cause the one that expires soonest overall
622 AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
623 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
624 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
625 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
626 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
627 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
628 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
629 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
630 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
633 # Reducing the flow limit also causes the flows that expire soonest
634 # overall to be evicted.
635 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
636 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
637 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
638 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
639 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
640 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
646 AT_SETUP([ofproto - asynchronous message control])
648 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
650 printf '\n\n--- check_async %d ---\n\n\n' $1
653 ovs-appctl -t ovs-ofctl ofctl/barrier
654 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
657 # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
658 ovs-ofctl -v packet-out br0 none controller '0001020304050010203040501234'
659 if test X"$1" = X"OFPR_ACTION"; then shift;
660 echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=NONE (via action) data_len=14 (unbuffered)
661 priority=0,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"
664 # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
665 ovs-ofctl -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
666 if test X"$1" = X"OFPR_NO_MATCH"; then shift;
667 echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=NONE (via no_match) data_len=14 (unbuffered)
668 priority=0,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"
671 # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
672 ovs-ofctl packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
673 if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
674 echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=NONE (via invalid_ttl) data_len=76 (unbuffered)
675 priority=0,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"
678 # OFPT_PORT_STATUS, OFPPR_ADD
679 ovs-vsctl add-port br0 test -- set Interface test type=dummy
680 if test X"$1" = X"OFPPR_ADD"; then shift;
681 echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
684 speed: 100 Mbps now, 100 Mbps max"
687 # OFPT_PORT_STATUS, OFPPR_DELETE
688 ovs-vsctl del-port br0 test
689 if test X"$1" = X"OFPPR_DELETE"; then shift;
690 echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
693 speed: 100 Mbps now, 100 Mbps max"
696 # OFPT_FLOW_REMOVED, OFPRR_DELETE
697 ovs-ofctl add-flow br0 send_flow_rem,actions=drop
698 ovs-ofctl --strict del-flows br0 ''
699 if test X"$1" = X"OFPRR_DELETE"; then shift;
700 echo >>expout "OFPT_FLOW_REMOVED: reason=delete"
702 AT_FAIL_IF([test X"$1" != X])
704 ovs-appctl -t ovs-ofctl ofctl/barrier
705 echo >>expout "OFPT_BARRIER_REPLY:"
709 s/ (xid=0x[0-9a-fA-F]*)//
711 s/00:0.$/00:0x/' < monitor.log]],
715 # It's a service connection so initially there should be no async messages.
718 # Set miss_send_len to 128, turning on packet-ins for our service connection.
719 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
720 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
722 # Set miss_send_len to 128 and enable invalid_ttl.
723 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
724 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
726 # Become slave, which should disable everything except port status.
727 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
728 check_async 4 OFPPR_ADD OFPPR_DELETE
730 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
731 ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
732 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
734 # Set controller ID 123.
735 ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
736 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
738 # Restore controller ID 0.
739 ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
742 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
743 check_async 7 OFPR_ACTION OFPPR_ADD
745 ovs-appctl -t ovs-ofctl exit
749 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
750 dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
751 dnl controllers despite the spec) as meaning a packet that was generated
752 dnl by the controller.
753 AT_SETUP([ofproto - packet-out from controller])
756 # Start a monitor listening for packet-ins.
757 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
758 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
759 ovs-appctl -t ovs-ofctl ofctl/barrier
760 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
761 AT_CAPTURE_FILE([monitor.log])
763 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
764 AT_CHECK([ovs-ofctl packet-out br0 none controller '0001020304050010203040501234'])
765 AT_CHECK([ovs-ofctl packet-out br0 controller controller '0001020304050010203040505678'])
767 # Stop the monitor and check its output.
768 ovs-appctl -t ovs-ofctl ofctl/barrier
769 ovs-appctl -t ovs-ofctl exit
771 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
772 OFPT_PACKET_IN: total_len=14 in_port=NONE (via action) data_len=14 (unbuffered)
773 priority=0,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
774 OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
775 priority=0,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
782 dnl This test checks that metadata is encoded in packet_in structures,
783 dnl supported by NXAST.
784 AT_SETUP([ofproto - packet-out with metadata (NXM)])
787 # Start a monitor listening for packet-ins.
788 AT_CHECK([ovs-ofctl -P nxm monitor br0 --detach --no-chdir --pidfile])
789 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
790 ovs-appctl -t ovs-ofctl ofctl/barrier
791 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
792 AT_CAPTURE_FILE([monitor.log])
794 # Send a packet-out with a load action to set some metadata, and forward to controller
795 AT_CHECK([ovs-ofctl packet-out br0 none 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), controller' '0001020304050010203040501234'])
797 # Stop the monitor and check its output.
798 ovs-appctl -t ovs-ofctl ofctl/barrier
799 ovs-appctl -t ovs-ofctl exit
801 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
802 NXT_PACKET_IN: total_len=14 in_port=NONE metadata=0xfafafafa5a5a5a5a (via action) data_len=14 (unbuffered)
803 priority=0,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
810 AT_SETUP([ofproto - flow monitoring])
811 AT_KEYWORDS([monitor])
814 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
816 # Start a monitor watching the flow table and check the initial reply.
817 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
818 AT_CAPTURE_FILE([monitor.log])
819 ovs-appctl -t ovs-ofctl ofctl/barrier
820 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
821 [NXST_FLOW_MONITOR reply:
822 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
826 # Add, delete, and modify some flows and check the updates.
827 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
828 ovs-ofctl add-flow br0 in_port=0,dl_vlan=124,actions=output:2
829 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:5
830 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=0,actions=output:6
831 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=1,actions=output:7
832 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:8
833 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=0,actions=output:9
834 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=1,actions=output:10
835 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,actions=output:11
836 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=0,actions=output:12
837 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=1,actions=output:13
838 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,actions=output:14
839 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:15
840 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:16
841 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:17
842 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:18
843 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:19
844 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:20
845 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=0,actions=output:21
846 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=1,actions=output:22
847 ovs-ofctl add-flow br0 in_port=0,actions=output:23
848 ovs-ofctl mod-flows br0 cookie=5,dl_vlan=123,actions=output:3
849 ovs-ofctl del-flows br0 dl_vlan=123
850 ovs-ofctl del-flows br0
851 ovs-appctl -t ovs-ofctl ofctl/barrier
853 # Sorts groups of lines that start with a space, without moving them
854 # past the nearest line that does not start with a space.
862 print $_ foreach sort(@buffer);
867 print $_ foreach sort(@buffer);
869 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | perl -e "$sort"], [0],
870 [NXST_FLOW_MONITOR reply (xid=0x0):
871 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
872 NXST_FLOW_MONITOR reply (xid=0x0):
873 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:5
874 NXST_FLOW_MONITOR reply (xid=0x0):
875 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:6
876 NXST_FLOW_MONITOR reply (xid=0x0):
877 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:7
878 NXST_FLOW_MONITOR reply (xid=0x0):
879 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:8
880 NXST_FLOW_MONITOR reply (xid=0x0):
881 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:9
882 NXST_FLOW_MONITOR reply (xid=0x0):
883 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:10
884 NXST_FLOW_MONITOR reply (xid=0x0):
885 event=ADDED table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
886 NXST_FLOW_MONITOR reply (xid=0x0):
887 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
888 NXST_FLOW_MONITOR reply (xid=0x0):
889 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
890 NXST_FLOW_MONITOR reply (xid=0x0):
891 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
892 NXST_FLOW_MONITOR reply (xid=0x0):
893 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:15
894 NXST_FLOW_MONITOR reply (xid=0x0):
895 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:16
896 NXST_FLOW_MONITOR reply (xid=0x0):
897 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:17
898 NXST_FLOW_MONITOR reply (xid=0x0):
899 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
900 NXST_FLOW_MONITOR reply (xid=0x0):
901 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
902 NXST_FLOW_MONITOR reply (xid=0x0):
903 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
904 NXST_FLOW_MONITOR reply (xid=0x0):
905 event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
906 NXST_FLOW_MONITOR reply (xid=0x0):
907 event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
908 NXST_FLOW_MONITOR reply (xid=0x0):
909 event=ADDED table=0 cookie=0 in_port=0 actions=output:23
910 NXST_FLOW_MONITOR reply (xid=0x0):
911 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
912 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
913 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
914 NXST_FLOW_MONITOR reply (xid=0x0):
915 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
916 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
917 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
918 NXST_FLOW_MONITOR reply (xid=0x0):
919 event=DELETED reason=delete table=0 cookie=0 in_port=0 actions=output:23
920 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
921 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
922 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
923 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
924 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
925 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
926 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
927 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
928 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
929 event=DELETED reason=delete table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
933 # Check that our own changes are reported as abbreviations.
934 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
935 ovs-ofctl add-flow br0 in_port=1,actions=output:2
936 ovs-ofctl add-flow br0 in_port=2,actions=output:1
937 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
938 ovs-appctl -t ovs-ofctl ofctl/barrier
939 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
941 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
942 [NXST_FLOW_MONITOR reply (xid=0x0):
943 event=ADDED table=0 cookie=0 in_port=1 actions=output:2
944 NXST_FLOW_MONITOR reply (xid=0x0):
945 event=ADDED table=0 cookie=0 in_port=2 actions=output:1
946 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
947 NXST_FLOW_MONITOR reply (xid=0x0):
948 event=ABBREV xid=0x12345678
952 ovs-appctl -t ovs-ofctl exit
956 AT_SETUP([ofproto - flow monitoring pause and resume])
957 AT_KEYWORDS([monitor])
959 # The maximum socket receive buffer size is important for this test, which
960 # tests behavior when the receive buffer overflows.
961 if test -e /proc/sys/net/core/rmem_max; then
963 rmem_max=`cat /proc/sys/net/core/rmem_max`
964 elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
967 # Don't know how to get maximum socket receive buffer on this OS
970 # Calculate the total amount of queuing: rmem_max in the kernel, 128 kB
971 # in ofproto sending userspace (see ofmonitor_flush() in connmgr.c).
972 queue_size=`expr $rmem_max + 128 \* 1024`
973 echo rmem_max=$rmem_max queue_size=$queue_size
975 # Each flow update message takes up at least 48 bytes of space in queues
976 # and in practice more than that.
977 n_msgs=`expr $queue_size / 48`
982 # Start a monitor watching the flow table, then make it block.
983 ON_EXIT([kill `cat ovs-ofctl.pid`])
984 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
985 AT_CAPTURE_FILE([monitor.log])
986 ovs-appctl -t ovs-ofctl ofctl/block
989 (echo "in_port=2,actions=output:2"
991 for ($i = 0; $i < '$n_msgs'; $i++) {
992 print "cookie=1,reg1=$i,actions=drop\n";
995 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
996 # Check that multipart flow dumps work properly:
997 AT_CHECK([ovs-ofctl diff-flows br0 flows.txt])
998 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,cookie=3,actions=drop])
999 AT_CHECK([ovs-ofctl mod-flows br0 in_port=2,cookie=2,actions=output:2])
1000 AT_CHECK([ovs-ofctl del-flows br0 cookie=1/-1])
1002 ovs-appctl -t ovs-ofctl ofctl/unblock
1003 ovs-appctl -t ovs-ofctl ofctl/barrier
1005 ovs-appctl -t ovs-ofctl exit
1007 # Check that the flow monitor reported the same number of flows
1008 # added and deleted, but fewer than we actually added and deleted.
1009 adds=`grep -c 'ADDED.*reg1=' monitor.log`
1010 deletes=`grep -c 'DELETED.*reg1=' monitor.log`
1011 echo adds=$adds deletes=$deletes
1012 AT_CHECK([test $adds -gt 100 && test $adds -lt $n_msgs])
1013 AT_CHECK([test $adds = $deletes])
1015 # Check that the flow monitor reported everything in the expected order:
1017 # event=ADDED table=0 cookie=0x1 reg1=0x22
1019 # NXT_FLOW_MONITOR_PAUSED:
1021 # event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1023 # event=ADDED table=0 cookie=0x3 in_port=1
1024 # event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
1025 # NXT_FLOW_MONITOR_RESUMED:
1027 # except that, between the PAUSED and RESUMED, the order of the ADDED
1028 # and MODIFIED lines lines depends on hash order, that is, it varies
1029 # as we change the hash function or change architecture. Therefore,
1030 # we use a couple of tests below to accept both orders.
1031 AT_CHECK([ofctl_strip < monitor.log | sed -n -e '
1034 /NXT_FLOW_MONITOR_PAUSED:/p
1035 /NXT_FLOW_MONITOR_RESUMED:/p
1036 ' > monitor.log.subset])
1037 AT_CHECK([grep -v MODIFIED monitor.log.subset], [0], [dnl
1038 event=ADDED table=0 cookie=0x1 reg1=0x22
1039 NXT_FLOW_MONITOR_PAUSED:
1040 event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1041 event=ADDED table=0 cookie=0x3 in_port=1
1042 NXT_FLOW_MONITOR_RESUMED:
1044 AT_CHECK([grep -v ADDED monitor.log.subset], [0], [dnl
1045 NXT_FLOW_MONITOR_PAUSED:
1046 event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1047 event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
1048 NXT_FLOW_MONITOR_RESUMED: