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:254, 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: 0 Mbps now, 0 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])
32 s/ (xid=0x[0-9a-fA-F]*)//
33 s/00:0.$/00:0x/' < stdout]],
35 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
36 n_tables:254, n_buffers:256
37 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
38 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
39 1(p1): addr:aa:55:aa:55:00:0x
42 speed: 0 Mbps now, 0 Mbps max
43 99(p2): addr:aa:55:aa:55:00:0x
46 speed: 0 Mbps now, 0 Mbps max
47 LOCAL(br0): addr:aa:55:aa:55:00:0x
50 speed: 0 Mbps now, 0 Mbps max
51 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
57 dnl This is really bare-bones.
58 dnl It at least checks request and reply serialization and deserialization.
59 AT_SETUP([ofproto - port stats - (OpenFlow 1.0)])
61 AT_CHECK([ovs-ofctl -vwarn dump-ports br0], [0], [stdout])
62 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
63 OFPST_PORT reply: 1 ports
64 port LOCAL: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
65 tx pkts=0, bytes=0, drop=0, errs=0, coll=0
70 AT_SETUP([ofproto - port stats - (OpenFlow 1.2)])
72 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn dump-ports br0], [0], [stdout])
73 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
74 OFPST_PORT reply (OF1.2): 1 ports
75 port LOCAL: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
76 tx pkts=0, bytes=0, drop=0, errs=0, coll=0
81 dnl This is really bare-bones.
82 dnl It at least checks request and reply serialization and deserialization.
83 AT_SETUP([ofproto - port-desc stats (OpenFlow 1.0)])
85 AT_CHECK([ovs-ofctl -vwarn dump-ports-desc br0], [0], [stdout])
86 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
87 OFPST_PORT_DESC reply:
88 LOCAL(br0): addr:aa:55:aa:55:00:00
91 speed: 0 Mbps now, 0 Mbps max
96 dnl This is really bare-bones.
97 dnl It at least checks request and reply serialization and deserialization.
98 AT_SETUP([ofproto - port-desc stats (OpenFlow 1.2)])
100 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn dump-ports-desc br0], [0], [stdout])
101 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
102 OFPST_PORT_DESC reply (OF1.2):
103 LOCAL(br0): addr:aa:55:aa:55:00:00
106 speed: 0 Mbps now, 0 Mbps max
111 dnl This is really bare-bones.
112 dnl It at least checks request and reply serialization and deserialization.
113 AT_SETUP([ofproto - queue stats - (OpenFlow 1.0)])
115 AT_CHECK([ovs-ofctl -vwarn queue-stats br0], [0], [stdout])
116 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
117 OFPST_QUEUE reply: 0 queues
119 AT_CHECK([ovs-ofctl -vwarn queue-stats br0 ANY 5], [0],
120 [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_QUEUE
121 OFPST_QUEUE request (xid=0x2):port=ANY queue=5
123 AT_CHECK([ovs-ofctl -vwarn queue-stats br0 10], [0],
124 [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_PORT
125 OFPST_QUEUE request (xid=0x2):port=10 queue=ALL
130 AT_SETUP([ofproto - queue stats - (OpenFlow 1.2)])
132 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn queue-stats br0], [0], [stdout])
133 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
134 OFPST_QUEUE reply (OF1.2): 0 queues
136 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn queue-stats br0 ALL 5], [0],
137 [OFPT_ERROR (OF1.2) (xid=0x2): OFPQOFC_BAD_QUEUE
138 OFPST_QUEUE request (OF1.2) (xid=0x2):port=ANY queue=5
140 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn queue-stats br0 10], [0],
141 [OFPT_ERROR (OF1.2) (xid=0x2): OFPQOFC_BAD_PORT
142 OFPST_QUEUE request (OF1.2) (xid=0x2):port=10 queue=ALL
147 AT_SETUP([ofproto - mod-port (OpenFlow 1.0)])
149 for command_config_state in \
151 'noflood NO_FLOOD 0' \
152 'down PORT_DOWN,NO_FLOOD LINK_DOWN' \
153 'flood PORT_DOWN LINK_DOWN' \
154 'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
155 'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
156 'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
157 'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
158 'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
162 set $command_config_state
163 command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
164 AT_CHECK([ovs-ofctl -vwarn mod-port br0 br0 $command])
165 AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
166 AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
167 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
168 n_tables:254, n_buffers:256
169 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
170 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
171 LOCAL(br0): addr:aa:55:aa:55:00:00
174 speed: 0 Mbps now, 0 Mbps max
175 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
181 AT_SETUP([ofproto - mod-port (OpenFlow 1.2)])
183 for command_config_state in \
185 'down PORT_DOWN LINK_DOWN' \
186 'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
187 'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
188 'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
189 'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
190 'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
194 set $command_config_state
195 command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
196 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn mod-port br0 br0 $command])
197 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn show br0], [0], [stdout])
198 AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
199 OFPT_FEATURES_REPLY (OF1.2): dpid:fedcba9876543210
200 n_tables:254, n_buffers:256
201 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS
202 LOCAL(br0): addr:aa:55:aa:55:00:00
205 speed: 0 Mbps now, 0 Mbps max
206 OFPT_GET_CONFIG_REPLY (OF1.2): frags=normal miss_send_len=0
212 AT_SETUP([ofproto - basic flow_mod commands (NXM)])
214 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
216 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl add-flows br0 -])
217 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=2])
218 AT_CHECK([ovs-ofctl -F nxm add-flow br0 table=1,in_port=4,actions=3])
219 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
220 in_port=1 actions=output:2
221 in_port=2 actions=output:1
222 table=1, in_port=4 actions=output:3
225 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
226 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
228 AT_CHECK([ovs-ofctl del-flows br0])
229 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
234 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.0)])
236 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
238 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -F openflow10 add-flows br0 -])
239 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 in_port=1,actions=2])
240 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 table=1,in_port=4,actions=3])
241 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
242 in_port=1 actions=output:2
243 in_port=2 actions=output:1
244 table=1, in_port=4 actions=output:3
247 AT_CHECK([ovs-ofctl -F openflow10 dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
248 OFPST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
250 AT_CHECK([ovs-ofctl -F openflow10 del-flows br0])
251 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
256 AT_SETUP([ofproto - set-field flow_mod commands (NXM)])
258 AT_CHECK([ovs-ofctl add-flow br0 ipv6,table=1,in_port=3,actions=drop])
259 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])
260 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
261 table=1, ipv6,in_port=3 actions=load:0xa6badbfffefe59fa->NXM_NX_IPV6_SRC[[0..63]],load:0xfe8001234567890a->NXM_NX_IPV6_SRC[[64..127]]
267 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.2)])
269 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.2):
271 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -O OpenFlow12 add-flows br0 -])
272 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=1,actions=2])
273 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 table=1,in_port=4,actions=3])
274 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
275 in_port=1 actions=output:2
276 in_port=2 actions=output:1
277 table=1, in_port=4 actions=output:3
278 OFPST_FLOW reply (OF1.2):
280 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0])
281 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.2):
286 AT_SETUP([ofproto - dump flows with cookie])
288 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
289 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
290 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
291 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
292 cookie=0x1, in_port=1 actions=output:1
293 cookie=0x2, in_port=2 actions=output:1
294 cookie=0x3, in_port=3 actions=output:1
297 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
298 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
300 AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/-1 | ofctl_strip | sort], [0], [dnl
301 cookie=0x3, in_port=3 actions=output:1
304 AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/-1 | STRIP_XIDS], [0], [dnl
305 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=1
310 AT_SETUP([ofproto - mod flow with cookie change (OpenFlow 1.0)])
312 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 cookie=0x1,in_port=1,actions=1])
313 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
314 cookie=0x1, in_port=1 actions=output:1
318 AT_CHECK([ovs-ofctl -F openflow10 mod-flows br0 cookie=0x2,in_port=1,actions=1])
319 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
320 cookie=0x2, in_port=1 actions=output:1
326 AT_SETUP([ofproto - mod flow with cookie change (NXM)])
328 AT_CHECK([ovs-ofctl -F nxm add-flow br0 cookie=0x1,in_port=1,actions=1])
329 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
330 cookie=0x1, in_port=1 actions=output:1
334 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x2,in_port=1,actions=1])
335 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
336 cookie=0x2, in_port=1 actions=output:1
342 dnl The OpenFlow 1.2 spec states that the cookie may not be modified
343 AT_SETUP([ofproto - no mod flow with cookie change (OpenFlow 1.2)])
345 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
346 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
347 cookie=0x1, in_port=1 actions=output:1
348 OFPST_FLOW reply (OF1.2):
351 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 cookie=0x2,in_port=1,actions=1])
352 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
353 cookie=0x1, in_port=1 actions=output:1
354 OFPST_FLOW reply (OF1.2):
359 AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.0)])
361 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
362 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
363 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
364 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
365 cookie=0x1, in_port=1 actions=output:1
366 cookie=0x1, in_port=2 actions=output:1
367 cookie=0x2, in_port=3 actions=output:1
371 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x1/0xff,actions=4])
372 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
373 cookie=0x1, in_port=1 actions=output:4
374 cookie=0x1, in_port=2 actions=output:4
375 cookie=0x2, in_port=3 actions=output:1
381 AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.2)])
383 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
384 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=2,actions=1])
385 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=3,actions=1])
386 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
387 cookie=0x1, in_port=1 actions=output:1
388 cookie=0x1, in_port=2 actions=output:1
389 cookie=0x2, in_port=3 actions=output:1
390 OFPST_FLOW reply (OF1.2):
393 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 cookie=0x1/0xff,actions=4])
394 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
395 cookie=0x1, in_port=1 actions=output:4
396 cookie=0x1, in_port=2 actions=output:4
397 cookie=0x2, in_port=3 actions=output:1
398 OFPST_FLOW reply (OF1.2):
403 dnl The OpenFlow 1.2 spec states that the cookie may not be modified
404 AT_SETUP([ofproto - mod flows based on cookie mask with cookie change])
406 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
407 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
408 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
409 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
410 cookie=0x1, in_port=1 actions=output:1
411 cookie=0x1, in_port=2 actions=output:1
412 cookie=0x2, in_port=3 actions=output:1
416 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/-1,cookie=4,actions=4])
417 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
418 cookie=0x2, in_port=3 actions=output:1
419 cookie=0x4, in_port=1 actions=output:4
420 cookie=0x4, in_port=2 actions=output:4
426 AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - NXM])
428 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 in_port=1,actions=1])
429 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
430 in_port=1 actions=output:1
436 AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - OF1.2])
438 AT_CHECK([ovs-ofctl -O openflow12 mod-flows br0 in_port=1,actions=1])
439 AT_CHECK([ovs-ofctl -O openflow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
440 OFPST_FLOW reply (OF1.2):
445 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - NXM])
447 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/1,in_port=1,actions=1])
448 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
454 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - OF1.2])
456 AT_CHECK([ovs-ofctl -O openflow12 mod-flows br0 cookie=1/1,in_port=1,actions=1])
457 AT_CHECK([ovs-ofctl -O openflow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
458 OFPST_FLOW reply (OF1.2):
463 AT_SETUP([ofproto - del flows with cookies])
465 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
466 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
467 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
468 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
469 cookie=0x1, in_port=1 actions=output:1
470 cookie=0x2, in_port=2 actions=output:1
471 cookie=0x3, in_port=3 actions=output:1
475 AT_CHECK([ovs-ofctl del-flows br0])
476 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
482 AT_SETUP([ofproto - del flows based on cookie])
484 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
485 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
486 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
487 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
488 cookie=0x1, in_port=1 actions=output:1
489 cookie=0x2, in_port=2 actions=output:1
490 cookie=0x3, in_port=3 actions=output:1
494 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/-1])
495 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
496 cookie=0x1, in_port=1 actions=output:1
497 cookie=0x2, in_port=2 actions=output:1
503 AT_SETUP([ofproto - del flows based on cookie mask])
505 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
506 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
507 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
508 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
509 cookie=0x1, in_port=1 actions=output:1
510 cookie=0x2, in_port=2 actions=output:1
511 cookie=0x3, in_port=3 actions=output:1
514 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/0x1])
515 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
516 cookie=0x2, in_port=2 actions=output:1
522 AT_SETUP([ofproto - del flows based on table id (NXM)])
524 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
525 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
526 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
527 cookie=0x1, in_port=1 actions=output:1
528 cookie=0x2, table=1, in_port=2 actions=output:1
531 AT_CHECK([ovs-ofctl del-flows br0 table=0])
532 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
533 cookie=0x2, table=1, in_port=2 actions=output:1
536 AT_CHECK([ovs-ofctl del-flows br0 table=1])
537 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
540 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
541 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
542 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
543 cookie=0x1, in_port=1 actions=output:1
544 cookie=0x2, table=1, in_port=2 actions=output:1
547 AT_CHECK([ovs-ofctl del-flows br0])
548 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
554 AT_SETUP([ofproto - del flows based on table id (OpenFlow 1.2)])
556 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
557 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
558 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
559 cookie=0x1, in_port=1 actions=output:1
560 cookie=0x2, table=1, in_port=2 actions=output:1
561 OFPST_FLOW reply (OF1.2):
563 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0 table=0])
564 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
565 cookie=0x2, table=1, in_port=2 actions=output:1
566 OFPST_FLOW reply (OF1.2):
568 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0 table=1])
569 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
570 OFPST_FLOW reply (OF1.2):
572 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
573 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
574 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
575 cookie=0x1, in_port=1 actions=output:1
576 cookie=0x2, table=1, in_port=2 actions=output:1
577 OFPST_FLOW reply (OF1.2):
579 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0])
580 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
581 OFPST_FLOW reply (OF1.2):
586 AT_SETUP([ofproto - flow table configuration (OpenFlow 1.0)])
588 # Check the default configuration.
589 (echo "OFPST_TABLE reply (xid=0x2): 254 tables
590 0: classifier: wild=0x3fffff, max=1000000, active=0
593 while test $x -lt 254; do
594 printf " %d: %-8s: wild=0x3fffff, max=1000000, active=0
599 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
600 # Change the configuration.
603 -- --id=@t0 create Flow_Table name=main \
604 -- --id=@t1 create Flow_Table flow-limit=1024 \
605 -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
606 | ${PERL} $srcdir/uuidfilt.pl],
610 # Check that the configuration was updated.
611 mv expout orig-expout
612 (echo "OFPST_TABLE reply (xid=0x2): 254 tables
613 0: main : wild=0x3fffff, max=1000000, active=0
615 1: table1 : wild=0x3fffff, max= 1024, active=0
617 tail -n +6 orig-expout) > expout
618 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
622 AT_SETUP([ofproto - flow table configuration (OpenFlow 1.2)])
624 # Check the default configuration.
625 (mid="wild=0xffffffffff, max=1000000,"
628 match=0xffffffffff, instructions=0x00000007, config=0x00000003
629 write_actions=0x00000000, apply_actions=0x00000000
630 write_setfields=0x000000ffffffffff
631 apply_setfields=0x000000ffffffffff
632 metadata_match=0xffffffffffffffff
633 metadata_write=0xffffffffffffffff"
634 echo "OFPST_TABLE reply (OF1.2) (xid=0x2): 254 tables
635 0: classifier: $mid active=0$tail"
637 while test $x -lt 254; do
638 printf " %d: %-8s: $mid active=0$tail
642 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
643 # Change the configuration.
646 -- --id=@t0 create Flow_Table name=main \
647 -- --id=@t1 create Flow_Table flow-limit=1024 \
648 -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
649 | ${PERL} $srcdir/uuidfilt.pl],
653 # Check that the configuration was updated.
654 mv expout orig-expout
655 (echo "OFPST_TABLE reply (OF1.2) (xid=0x2): 254 tables
656 0: main : wild=0xffffffffff, max=1000000, active=0"
657 tail -n +3 orig-expout | head -7
658 echo " 1: table1 : wild=0xffffffffff, max= 1024, active=0"
659 tail -n +11 orig-expout) > expout
660 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
664 AT_SETUP([ofproto - hard limits on flow table size (OpenFLow 1.0)])
666 # Configure a maximum of 4 flows.
669 -- --id=@t0 create Flow_Table flow-limit=4 \
670 -- set bridge br0 flow_tables:0=@t0 \
671 | ${PERL} $srcdir/uuidfilt.pl],
675 for in_port in 1 2 3 4; do
676 ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
678 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
679 in_port=1 actions=drop
680 in_port=2 actions=drop
681 in_port=3 actions=drop
682 in_port=4 actions=drop
685 # Adding another flow will be refused.
686 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
687 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
688 [OFPT_ERROR: OFPFMFC_TABLE_FULL
690 # Also a mod-flow that would add a flow will be refused.
691 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
692 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
693 [OFPT_ERROR: OFPFMFC_TABLE_FULL
695 # Replacing or modifying an existing flow is allowed.
696 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
697 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
698 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
699 in_port=1 actions=drop
700 in_port=2 actions=drop
701 in_port=3 actions=output:1
702 in_port=4 actions=NORMAL
708 AT_SETUP([ofproto - hard limits on flow table size (OpenFLow 1.2)])
710 # Configure a maximum of 4 flows.
713 -- --id=@t0 create Flow_Table flow-limit=4 \
714 -- set bridge br0 flow_tables:0=@t0 \
715 | ${PERL} $srcdir/uuidfilt.pl],
719 for in_port in 1 2 3 4; do
720 ovs-ofctl -O OpenFlow12 add-flow br0 in_port=$in_port,actions=drop
722 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
723 in_port=1 actions=drop
724 in_port=2 actions=drop
725 in_port=3 actions=drop
726 in_port=4 actions=drop
727 OFPST_FLOW reply (OF1.2):
729 # Adding another flow will be refused.
730 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
731 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
732 [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
734 # Replacing or modifying an existing flow is allowed.
735 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
736 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
737 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
738 in_port=1 actions=drop
739 in_port=2 actions=drop
740 in_port=3 actions=output:1
741 in_port=4 actions=NORMAL
742 OFPST_FLOW reply (OF1.2):
747 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.0)])
749 # Configure a maximum of 4 flows.
752 -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
753 -- set bridge br0 flow_tables:0=@t0 \
754 | ${PERL} $srcdir/uuidfilt.pl],
758 for in_port in 4 3 2 1; do
759 ovs-ofctl add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
761 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
762 idle_timeout=10, in_port=1 actions=drop
763 idle_timeout=20, in_port=2 actions=drop
764 idle_timeout=30, in_port=3 actions=drop
765 idle_timeout=40, in_port=4 actions=drop
768 # Adding another flow will cause the one that expires soonest to be evicted.
769 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
770 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
771 idle_timeout=20, in_port=2 actions=drop
772 idle_timeout=30, in_port=3 actions=drop
773 idle_timeout=40, in_port=4 actions=drop
774 in_port=5 actions=drop
777 # A mod-flow that adds a flow also causes eviction, but replacing or
778 # modifying an existing flow doesn't.
779 AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
780 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
781 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
782 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
783 idle_timeout=30, in_port=3 actions=output:1
784 in_port=4 actions=NORMAL
785 in_port=5 actions=drop
786 in_port=6 actions=drop
789 # Flows with no timeouts at all cannot be evicted.
790 AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
791 AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
792 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
793 [OFPT_ERROR: OFPFMFC_TABLE_FULL
795 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
796 in_port=4 actions=NORMAL
797 in_port=5 actions=drop
798 in_port=6 actions=drop
799 in_port=7 actions=NORMAL
805 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.2)])
807 # Configure a maximum of 4 flows.
810 -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
811 -- set bridge br0 flow_tables:0=@t0 \
812 | ${PERL} $srcdir/uuidfilt.pl],
816 for in_port in 4 3 2 1; do
817 ovs-ofctl -O OpenFlow12 add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
819 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
820 idle_timeout=10, in_port=1 actions=drop
821 idle_timeout=20, in_port=2 actions=drop
822 idle_timeout=30, in_port=3 actions=drop
823 idle_timeout=40, in_port=4 actions=drop
824 OFPST_FLOW reply (OF1.2):
826 # Adding another flow will cause the one that expires soonest to be evicted.
827 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop])
828 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
829 idle_timeout=20, in_port=2 actions=drop
830 idle_timeout=30, in_port=3 actions=drop
831 idle_timeout=40, in_port=4 actions=drop
832 in_port=5 actions=drop
833 OFPST_FLOW reply (OF1.2):
835 # In Open Flow 1.2 a mod-flow does not ever add a flow and thus
836 # has no effect on eviction
837 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=6,actions=drop])
838 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
839 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
840 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
841 idle_timeout=20, in_port=2 actions=drop
842 idle_timeout=30, in_port=3 actions=output:1
843 in_port=4 actions=NORMAL
844 in_port=5 actions=drop
845 OFPST_FLOW reply (OF1.2):
847 # Flows with no timeouts at all cannot be evicted.
848 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=6,actions=drop])
849 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=7,actions=normal])
850 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
851 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
852 [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
854 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
855 in_port=4 actions=NORMAL
856 in_port=5 actions=drop
857 in_port=6 actions=drop
858 in_port=7 actions=NORMAL
859 OFPST_FLOW reply (OF1.2):
864 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.0)])
866 # Configure a maximum of 4 flows.
869 -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
870 overflow-policy=evict \
871 groups='"NXM_OF_IN_PORT[[]]"' \
872 -- set bridge br0 flow_tables:0=@t0 \
873 | ${PERL} $srcdir/uuidfilt.pl],
877 ovs-ofctl add-flows br0 - <<EOF
878 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
879 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
880 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
881 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
883 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
884 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
885 idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
886 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
887 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
890 # Adding another flow will cause the one that expires soonest within
891 # the largest group (those with in_port=1) to be evicted. In this
892 # case this is not the same as the one that expires soonest overall
893 # (which is what makes the test interesting):
894 AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
895 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
896 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
897 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
898 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
899 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
902 # Enlarge the flow limit, change the eviction policy back to strictly
903 # based on expiration, and and add some flows.
904 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
905 ovs-ofctl add-flows br0 - <<EOF
906 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
907 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
908 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
910 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
911 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
912 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
913 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
914 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
915 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
916 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
917 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
920 # Adding another flow will cause the one that expires soonest overall
922 AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
923 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
924 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
925 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
926 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
927 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
928 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
929 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
930 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
933 # Reducing the flow limit also causes the flows that expire soonest
934 # overall to be evicted.
935 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
936 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
937 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
938 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
939 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
940 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
946 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.2)])
948 # Configure a maximum of 4 flows.
951 -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
952 overflow-policy=evict \
953 groups='"NXM_OF_IN_PORT[[]]"' \
954 -- set bridge br0 flow_tables:0=@t0 \
955 | ${PERL} $srcdir/uuidfilt.pl],
959 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
960 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
961 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
962 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
963 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
965 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
966 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
967 idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
968 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
969 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
970 OFPST_FLOW reply (OF1.2):
972 # Adding another flow will cause the one that expires soonest within
973 # the largest group (those with in_port=1) to be evicted. In this
974 # case this is not the same as the one that expires soonest overall
975 # (which is what makes the test interesting):
976 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
977 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
978 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
979 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
980 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
981 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
982 OFPST_FLOW reply (OF1.2):
984 # Enlarge the flow limit, change the eviction policy back to strictly
985 # based on expiration, and and add some flows.
986 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
987 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
988 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
989 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
990 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
992 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
993 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
994 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
995 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
996 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
997 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
998 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
999 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1000 OFPST_FLOW reply (OF1.2):
1002 # Adding another flow will cause the one that expires soonest overall
1004 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
1005 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1006 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1007 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1008 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
1009 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1010 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1011 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1012 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1013 OFPST_FLOW reply (OF1.2):
1015 # Reducing the flow limit also causes the flows that expire soonest
1016 # overall to be evicted.
1017 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
1018 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1019 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1020 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1021 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1022 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1023 OFPST_FLOW reply (OF1.2):
1028 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.0)])
1030 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
1032 printf '\n\n--- check_async %d ---\n\n\n' $1
1035 ovs-appctl -t ovs-ofctl ofctl/barrier
1036 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1039 # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1040 ovs-ofctl -v packet-out br0 controller controller '0001020304050010203040501234'
1041 if test X"$1" = X"OFPR_ACTION"; then shift;
1042 echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
1043 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"
1046 # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1047 ovs-ofctl -v packet-out br0 controller 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1048 if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1049 echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via no_match) data_len=14 (unbuffered)
1050 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"
1053 # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1054 ovs-ofctl packet-out br0 controller dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1055 if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1056 echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=CONTROLLER (via invalid_ttl) data_len=76 (unbuffered)
1057 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"
1060 # OFPT_PORT_STATUS, OFPPR_ADD
1061 ovs-vsctl add-port br0 test -- set Interface test type=dummy ofport_request=1
1062 if test X"$1" = X"OFPPR_ADD"; then shift;
1063 echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
1066 speed: 0 Mbps now, 0 Mbps max"
1069 # OFPT_PORT_STATUS, OFPPR_DELETE
1070 ovs-vsctl del-port br0 test
1071 if test X"$1" = X"OFPPR_DELETE"; then shift;
1072 echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
1075 speed: 0 Mbps now, 0 Mbps max"
1078 # OFPT_FLOW_REMOVED, OFPRR_DELETE
1079 ovs-ofctl add-flow br0 send_flow_rem,actions=drop
1080 ovs-ofctl --strict del-flows br0 ''
1081 if test X"$1" = X"OFPRR_DELETE"; then shift;
1082 echo >>expout "OFPT_FLOW_REMOVED: reason=delete"
1084 AT_FAIL_IF([test X"$1" != X])
1086 ovs-appctl -t ovs-ofctl ofctl/barrier
1087 echo >>expout "OFPT_BARRIER_REPLY:"
1091 s/ (xid=0x[0-9a-fA-F]*)//
1093 s/00:0.$/00:0x/' < monitor.log]],
1097 # It's a service connection so initially there should be no async messages.
1100 # Set miss_send_len to 128, turning on packet-ins for our service connection.
1101 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
1102 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1104 # Set miss_send_len to 128 and enable invalid_ttl.
1105 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
1106 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1108 # Become slave, which should disable everything except port status.
1109 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
1110 check_async 4 OFPPR_ADD OFPPR_DELETE
1112 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
1113 ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
1114 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1116 # Set controller ID 123.
1117 ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
1118 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1120 # Restore controller ID 0.
1121 ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
1124 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
1125 check_async 7 OFPR_ACTION OFPPR_ADD
1127 ovs-appctl -t ovs-ofctl exit
1131 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.2)])
1133 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1135 printf '\n\n--- check_async %d ---\n\n\n' $1
1139 ovs-appctl -t ovs-ofctl ofctl/barrier
1140 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1143 # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1144 ovs-ofctl -O OpenFlow12 -v packet-out br0 none controller '0001020304050010203040501234'
1145 if test X"$1" = X"OFPR_ACTION"; then shift;
1146 echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1147 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"
1150 # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1151 ovs-ofctl -O OpenFlow12 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1152 if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1153 echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
1154 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"
1157 # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1158 ovs-ofctl -O OpenFlow12 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1159 if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1160 echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
1161 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"
1164 # OFPT_PORT_STATUS, OFPPR_ADD
1165 ovs-vsctl add-port br0 test -- set Interface test type=dummy
1166 if test X"$1" = X"OFPPR_ADD"; then shift;
1167 echo >>expout "OFPT_PORT_STATUS (OF1.2): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1170 speed: 0 Mbps now, 0 Mbps max"
1173 # OFPT_PORT_STATUS, OFPPR_DELETE
1174 ovs-vsctl del-port br0 test
1175 if test X"$1" = X"OFPPR_DELETE"; then shift;
1176 echo >>expout "OFPT_PORT_STATUS (OF1.2): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1179 speed: 0 Mbps now, 0 Mbps max"
1182 # OFPT_FLOW_REMOVED, OFPRR_DELETE
1183 ovs-ofctl -O OpenFlow12 add-flow br0 send_flow_rem,actions=drop
1184 ovs-ofctl -O OpenFlow12 --strict del-flows br0 ''
1185 if test X"$1" = X"OFPRR_DELETE"; then shift;
1186 echo >>expout "OFPT_FLOW_REMOVED (OF1.2): reason=delete table_id=0"
1188 AT_FAIL_IF([test X"$1" != X])
1190 ovs-appctl -t ovs-ofctl ofctl/barrier
1191 echo >>expout "OFPT_BARRIER_REPLY (OF1.2):"
1195 s/ (xid=0x[0-9a-fA-F]*)//
1197 s/00:0.$/00:0x/' < monitor.log]],
1201 # It's a service connection so initially there should be no async messages.
1204 # Set miss_send_len to 128, turning on packet-ins for our service connection.
1205 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
1206 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1208 # Set miss_send_len to 128 and enable invalid_ttl.
1209 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700040080
1210 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1212 # Become slave (OF 1.2), which should disable everything except port status.
1213 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000200000003000000000000000000000001
1214 check_async 4 OFPPR_ADD OFPPR_DELETE
1216 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
1217 ovs-appctl -t ovs-ofctl ofctl/send 03040028000000020000232000000013000000020000000500000005000000020000000200000005
1218 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1220 # Set controller ID 123.
1221 ovs-appctl -t ovs-ofctl ofctl/send 03040018000000030000232000000014000000000000007b
1222 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1224 # Restore controller ID 0.
1225 ovs-appctl -t ovs-ofctl ofctl/send 030400180000000300002320000000140000000000000000
1227 # Become master (OF 1.2).
1228 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000400000002000000000000000000000002
1229 check_async 7 OFPR_ACTION OFPPR_ADD
1231 ovs-appctl -t ovs-ofctl exit
1235 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.3)])
1237 AT_CHECK([ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile])
1239 printf '\n\n--- check_async %d ---\n\n\n' $1
1243 ovs-appctl -t ovs-ofctl ofctl/barrier
1244 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1247 # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1248 ovs-ofctl -O OpenFlow13 -v packet-out br0 none controller '0001020304050010203040501234'
1249 if test X"$1" = X"OFPR_ACTION"; then shift;
1250 echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1251 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"
1254 # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1255 ovs-ofctl -O OpenFlow13 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1256 if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1257 echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
1258 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"
1261 # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1262 ovs-ofctl -O OpenFlow13 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1263 if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1264 echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
1265 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"
1268 # OFPT_PORT_STATUS, OFPPR_ADD
1269 ovs-vsctl add-port br0 test -- set Interface test type=dummy
1270 if test X"$1" = X"OFPPR_ADD"; then shift;
1271 echo >>expout "OFPT_PORT_STATUS (OF1.3): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1274 speed: 0 Mbps now, 0 Mbps max"
1277 # OFPT_PORT_STATUS, OFPPR_DELETE
1278 ovs-vsctl del-port br0 test
1279 if test X"$1" = X"OFPPR_DELETE"; then shift;
1280 echo >>expout "OFPT_PORT_STATUS (OF1.3): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1283 speed: 0 Mbps now, 0 Mbps max"
1286 # OFPT_FLOW_REMOVED, OFPRR_DELETE
1287 ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=drop
1288 ovs-ofctl -O OpenFlow13 --strict del-flows br0 ''
1289 if test X"$1" = X"OFPRR_DELETE"; then shift;
1290 echo >>expout "OFPT_FLOW_REMOVED (OF1.3): reason=delete table_id=0"
1292 AT_FAIL_IF([test X"$1" != X])
1294 ovs-appctl -t ovs-ofctl ofctl/barrier
1295 echo >>expout "OFPT_BARRIER_REPLY (OF1.3):"
1299 s/ (xid=0x[0-9a-fA-F]*)//
1301 s/00:0.$/00:0x/' < monitor.log]],
1305 # It's a service connection so initially there should be no async messages.
1308 # Set miss_send_len to 128, turning on packet-ins for our service connection.
1309 ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
1310 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1312 # Become slave (OF 1.3), which should disable everything except port status.
1313 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000200000003000000000000000000000001
1314 check_async 3 OFPPR_ADD OFPPR_DELETE
1316 # Use OF 1.3 OFPT_SET_ASYNC to enable a patchwork of asynchronous messages.
1317 ovs-appctl -t ovs-ofctl ofctl/send 041c002000000002000000020000000500000005000000020000000200000005
1318 check_async 4 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1320 # Set controller ID 123.
1321 ovs-appctl -t ovs-ofctl ofctl/send 04040018000000030000232000000014000000000000007b
1322 check_async 5 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1324 # Restore controller ID 0.
1325 ovs-appctl -t ovs-ofctl ofctl/send 040400180000000300002320000000140000000000000000
1327 # Become master (OF 1.3).
1328 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000400000002000000000000000000000002
1329 check_async 6 OFPR_ACTION OFPPR_ADD
1331 ovs-appctl -t ovs-ofctl exit
1335 dnl This test checks that the role request/response messaging works
1336 dnl and that generation_id is handled properly.
1337 AT_SETUP([ofproto - controller role (OpenFlow 1.2)])
1339 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1341 ovs-appctl -t ovs-ofctl ofctl/barrier
1342 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1345 # find out current role
1346 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000200000000000000000000000000000000
1347 echo >>expout "send: OFPT_ROLE_REQUEST (OF1.2) (xid=0x2): role=nochange"
1348 echo >>expout "OFPT_ROLE_REPLY (OF1.2) (xid=0x2): role=equal"
1350 # Become slave (generation_id is initially undefined, so 2^63+2 should not be stale)
1351 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000300000003000000008000000000000002
1352 echo >>expout "send: OFPT_ROLE_REQUEST (OF1.2) (xid=0x3): role=slave generation_id=9223372036854775810"
1353 echo >>expout "OFPT_ROLE_REPLY (OF1.2) (xid=0x3): role=slave generation_id=9223372036854775810"
1355 # Try to become the master using a stale generation ID
1356 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000400000002000000000000000000000002
1357 echo >>expout "send: OFPT_ROLE_REQUEST (OF1.2) (xid=0x4): role=master generation_id=2"
1358 echo >>expout "OFPT_ERROR (OF1.2) (xid=0x4): OFPRRFC_STALE"
1359 echo >>expout "OFPT_ROLE_REQUEST (OF1.2) (xid=0x4): role=master generation_id=2"
1361 # Become master using a valid generation ID
1362 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000500000002000000000000000000000001
1363 echo >>expout "send: OFPT_ROLE_REQUEST (OF1.2) (xid=0x5): role=master generation_id=1"
1364 echo >>expout "OFPT_ROLE_REPLY (OF1.2) (xid=0x5): role=master generation_id=1"
1365 ovs-appctl -t ovs-ofctl ofctl/barrier
1366 echo >>expout "OFPT_BARRIER_REPLY (OF1.2) (xid=0x3):"
1368 AT_CHECK([cat monitor.log], [0], [expout])
1370 ovs-appctl -t ovs-ofctl exit
1374 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
1375 dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
1376 dnl controllers despite the spec) as meaning a packet that was generated
1377 dnl by the controller.
1378 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.0)])
1381 # Start a monitor listening for packet-ins.
1382 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
1383 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
1384 ovs-appctl -t ovs-ofctl ofctl/barrier
1385 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1386 AT_CAPTURE_FILE([monitor.log])
1388 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
1389 AT_CHECK([ovs-ofctl packet-out br0 none controller '0001020304050010203040501234'])
1390 AT_CHECK([ovs-ofctl packet-out br0 controller controller '0001020304050010203040505678'])
1392 # Stop the monitor and check its output.
1393 ovs-appctl -t ovs-ofctl ofctl/barrier
1394 ovs-appctl -t ovs-ofctl exit
1396 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
1397 OFPT_PACKET_IN: total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1398 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
1399 OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
1400 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
1407 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
1408 dnl specified by OpenFlow 1.2) and OFPP_CONTROLLER (used by some
1409 dnl controllers despite the spec) as meaning a packet that was generated
1410 dnl by the controller.
1411 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.2)])
1414 # Start a monitor listening for packet-ins.
1415 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1416 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
1417 ovs-appctl -t ovs-ofctl ofctl/barrier
1418 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1419 AT_CAPTURE_FILE([monitor.log])
1421 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
1422 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none controller '0001020304050010203040501234'])
1423 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 4294967293 controller '0001020304050010203040505678'])
1425 # Stop the monitor and check its output.
1426 ovs-appctl -t ovs-ofctl ofctl/barrier
1427 ovs-appctl -t ovs-ofctl exit
1429 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
1430 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1431 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
1432 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
1433 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
1434 OFPT_BARRIER_REPLY (OF1.2):
1440 dnl This test checks that metadata is encoded in packet_in structures,
1441 dnl supported by NXAST.
1442 AT_SETUP([ofproto - packet-out with metadata (NXM)])
1445 # Start a monitor listening for packet-ins.
1446 AT_CHECK([ovs-ofctl -P nxm monitor br0 --detach --no-chdir --pidfile])
1447 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
1448 ovs-appctl -t ovs-ofctl ofctl/barrier
1449 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1450 AT_CAPTURE_FILE([monitor.log])
1452 # Send a packet-out with a load action to set some metadata, and forward to controller
1453 AT_CHECK([ovs-ofctl packet-out br0 controller 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), controller' '0001020304050010203040501234'])
1455 # Stop the monitor and check its output.
1456 ovs-appctl -t ovs-ofctl ofctl/barrier
1457 ovs-appctl -t ovs-ofctl exit
1459 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
1460 NXT_PACKET_IN: total_len=14 in_port=CONTROLLER metadata=0xfafafafa5a5a5a5a (via action) data_len=14 (unbuffered)
1461 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
1468 dnl This test checks that metadata is encoded in packet_in structures,
1469 dnl supported by NXAST.
1470 AT_SETUP([ofproto - packet-out with metadata (OpenFlow 1.2)])
1473 # Start a monitor listening for packet-ins.
1474 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1475 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
1476 ovs-appctl -t ovs-ofctl ofctl/barrier
1477 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1478 AT_CAPTURE_FILE([monitor.log])
1480 # Send a packet-out with a load action to set some metadata, and forward to controller
1481 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), controller' '0001020304050010203040501234'])
1483 # Stop the monitor and check its output.
1484 ovs-appctl -t ovs-ofctl ofctl/barrier
1485 ovs-appctl -t ovs-ofctl exit
1487 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
1488 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY metadata=0xfafafafa5a5a5a5a (via action) data_len=14 (unbuffered)
1489 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
1490 OFPT_BARRIER_REPLY (OF1.2):
1496 dnl This test checks that tunnel metadata is encoded in packet_in structures.
1497 AT_SETUP([ofproto - packet-out with tunnel metadata (OpenFlow 1.2)])
1500 # Start a monitor listening for packet-ins.
1501 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1502 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
1503 ovs-appctl -t ovs-ofctl ofctl/barrier
1504 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1505 AT_CAPTURE_FILE([monitor.log])
1507 # Send a packet-out with set field actions to set some tunnel metadata, and forward to controller
1508 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none 'set_field:127.0.0.1->tun_src,set_field:0x01020304->tun_id,set_field:192.168.0.1->tun_dst, controller' '0001020304050010203040501234'])
1510 # Stop the monitor and check its output.
1511 ovs-appctl -t ovs-ofctl ofctl/barrier
1512 ovs-appctl -t ovs-ofctl exit
1514 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
1515 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY tun_id=0x1020304 tun_src=127.0.0.1 tun_dst=192.168.0.1 (via action) data_len=14 (unbuffered)
1516 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
1517 OFPT_BARRIER_REPLY (OF1.2):
1523 AT_SETUP([ofproto - flow monitoring])
1524 AT_KEYWORDS([monitor])
1527 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
1529 # Start a monitor watching the flow table and check the initial reply.
1530 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
1531 AT_CAPTURE_FILE([monitor.log])
1532 ovs-appctl -t ovs-ofctl ofctl/barrier
1533 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
1534 [NXST_FLOW_MONITOR reply:
1535 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
1539 # Add, delete, and modify some flows and check the updates.
1540 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1541 ovs-ofctl add-flow br0 in_port=0,dl_vlan=124,actions=output:2
1542 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:5
1543 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=0,actions=output:6
1544 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=1,actions=output:7
1545 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:8
1546 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=0,actions=output:9
1547 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=1,actions=output:10
1548 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,actions=output:11
1549 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=0,actions=output:12
1550 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=1,actions=output:13
1551 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,actions=output:14
1552 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:15
1553 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:16
1554 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:17
1555 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:18
1556 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:19
1557 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:20
1558 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=0,actions=output:21
1559 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=1,actions=output:22
1560 ovs-ofctl add-flow br0 in_port=0,actions=output:23
1561 ovs-ofctl mod-flows br0 cookie=5,dl_vlan=123,actions=output:3
1562 ovs-ofctl del-flows br0 dl_vlan=123
1563 ovs-ofctl del-flows br0
1564 ovs-appctl -t ovs-ofctl ofctl/barrier
1566 # Sorts groups of lines that start with a space, without moving them
1567 # past the nearest line that does not start with a space.
1575 print $_ foreach sort(@buffer);
1580 print $_ foreach sort(@buffer);
1582 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | ${PERL} -e "$sort"], [0],
1583 [NXST_FLOW_MONITOR reply (xid=0x0):
1584 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
1585 NXST_FLOW_MONITOR reply (xid=0x0):
1586 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:5
1587 NXST_FLOW_MONITOR reply (xid=0x0):
1588 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:6
1589 NXST_FLOW_MONITOR reply (xid=0x0):
1590 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:7
1591 NXST_FLOW_MONITOR reply (xid=0x0):
1592 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:8
1593 NXST_FLOW_MONITOR reply (xid=0x0):
1594 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:9
1595 NXST_FLOW_MONITOR reply (xid=0x0):
1596 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:10
1597 NXST_FLOW_MONITOR reply (xid=0x0):
1598 event=ADDED table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
1599 NXST_FLOW_MONITOR reply (xid=0x0):
1600 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
1601 NXST_FLOW_MONITOR reply (xid=0x0):
1602 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
1603 NXST_FLOW_MONITOR reply (xid=0x0):
1604 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
1605 NXST_FLOW_MONITOR reply (xid=0x0):
1606 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:15
1607 NXST_FLOW_MONITOR reply (xid=0x0):
1608 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:16
1609 NXST_FLOW_MONITOR reply (xid=0x0):
1610 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:17
1611 NXST_FLOW_MONITOR reply (xid=0x0):
1612 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
1613 NXST_FLOW_MONITOR reply (xid=0x0):
1614 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
1615 NXST_FLOW_MONITOR reply (xid=0x0):
1616 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
1617 NXST_FLOW_MONITOR reply (xid=0x0):
1618 event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
1619 NXST_FLOW_MONITOR reply (xid=0x0):
1620 event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
1621 NXST_FLOW_MONITOR reply (xid=0x0):
1622 event=ADDED table=0 cookie=0 in_port=0 actions=output:23
1623 NXST_FLOW_MONITOR reply (xid=0x0):
1624 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
1625 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
1626 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
1627 NXST_FLOW_MONITOR reply (xid=0x0):
1628 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
1629 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
1630 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
1631 NXST_FLOW_MONITOR reply (xid=0x0):
1632 event=DELETED reason=delete table=0 cookie=0 in_port=0 actions=output:23
1633 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
1634 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
1635 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
1636 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
1637 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
1638 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
1639 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
1640 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
1641 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
1642 event=DELETED reason=delete table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
1646 # Check that our own changes are reported as abbreviations.
1647 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1648 ovs-ofctl add-flow br0 in_port=1,actions=output:2
1649 ovs-ofctl add-flow br0 in_port=2,actions=output:1
1650 ovs-appctl -t ovs-ofctl ofctl/barrier
1651 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
1652 ovs-appctl -t ovs-ofctl ofctl/barrier
1653 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
1655 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
1656 [NXST_FLOW_MONITOR reply (xid=0x0):
1657 event=ADDED table=0 cookie=0 in_port=1 actions=output:2
1658 NXST_FLOW_MONITOR reply (xid=0x0):
1659 event=ADDED table=0 cookie=0 in_port=2 actions=output:1
1661 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
1662 NXST_FLOW_MONITOR reply (xid=0x0):
1663 event=ABBREV xid=0x12345678
1667 ovs-appctl -t ovs-ofctl exit
1671 AT_SETUP([ofproto - flow monitoring pause and resume])
1672 AT_KEYWORDS([monitor])
1674 # The maximum socket receive buffer size is important for this test, which
1675 # tests behavior when the receive buffer overflows.
1676 if test -e /proc/sys/net/core/rmem_max; then
1678 rmem_max=`cat /proc/sys/net/core/rmem_max`
1679 elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
1682 # Don't know how to get maximum socket receive buffer on this OS
1685 # Calculate the total amount of queuing: rmem_max in the kernel, 128 kB
1686 # in ofproto sending userspace (see ofmonitor_flush() in connmgr.c).
1687 queue_size=`expr $rmem_max + 128 \* 1024`
1688 echo rmem_max=$rmem_max queue_size=$queue_size
1690 # Each flow update message takes up at least 48 bytes of space in queues
1691 # and in practice more than that.
1692 n_msgs=`expr $queue_size / 48`
1697 # Start a monitor watching the flow table, then make it block.
1698 ON_EXIT([kill `cat ovs-ofctl.pid`])
1699 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
1700 AT_CAPTURE_FILE([monitor.log])
1701 ovs-appctl -t ovs-ofctl ofctl/block
1703 # Add $n_msgs flows.
1704 (echo "in_port=2,actions=output:2"
1706 for ($i = 0; $i < '$n_msgs'; $i++) {
1707 print "cookie=1,reg1=$i,actions=drop\n";
1710 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
1711 # Check that multipart flow dumps work properly:
1712 AT_CHECK([ovs-ofctl diff-flows br0 flows.txt])
1713 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,cookie=3,actions=drop])
1714 AT_CHECK([ovs-ofctl mod-flows br0 in_port=2,cookie=2,actions=output:2])
1715 AT_CHECK([ovs-ofctl del-flows br0 cookie=1/-1])
1717 ovs-appctl -t ovs-ofctl ofctl/unblock
1718 ovs-appctl -t ovs-ofctl ofctl/barrier
1720 ovs-appctl -t ovs-ofctl exit
1722 # Check that the flow monitor reported the same number of flows
1723 # added and deleted, but fewer than we actually added and deleted.
1724 adds=`grep -c 'ADDED.*reg1=' monitor.log`
1725 deletes=`grep -c 'DELETED.*reg1=' monitor.log`
1726 echo adds=$adds deletes=$deletes
1727 AT_CHECK([test $adds -gt 100 && test $adds -lt $n_msgs])
1728 AT_CHECK([test $adds = $deletes])
1730 # Check that the flow monitor reported everything in the expected order:
1732 # event=ADDED table=0 cookie=0x1 reg1=0x22
1734 # NXT_FLOW_MONITOR_PAUSED:
1736 # event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1738 # event=ADDED table=0 cookie=0x3 in_port=1
1739 # event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
1740 # NXT_FLOW_MONITOR_RESUMED:
1742 # except that, between the PAUSED and RESUMED, the order of the ADDED
1743 # and MODIFIED lines lines depends on hash order, that is, it varies
1744 # as we change the hash function or change architecture. Therefore,
1745 # we use a couple of tests below to accept both orders.
1746 AT_CHECK([ofctl_strip < monitor.log | sed -n -e '
1749 /NXT_FLOW_MONITOR_PAUSED:/p
1750 /NXT_FLOW_MONITOR_RESUMED:/p
1751 ' > monitor.log.subset])
1752 AT_CHECK([grep -v MODIFIED monitor.log.subset], [0], [dnl
1753 event=ADDED table=0 cookie=0x1 reg1=0x22
1754 NXT_FLOW_MONITOR_PAUSED:
1755 event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1756 event=ADDED table=0 cookie=0x3 in_port=1
1757 NXT_FLOW_MONITOR_RESUMED:
1759 AT_CHECK([grep -v ADDED monitor.log.subset], [0], [dnl
1760 NXT_FLOW_MONITOR_PAUSED:
1761 event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1762 event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
1763 NXT_FLOW_MONITOR_RESUMED: