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 (OpenFlow1.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)])
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)])
438 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/1,in_port=1,actions=1])
439 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
445 AT_SETUP([ofproto - del flows with cookies])
447 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
448 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
449 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
450 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
451 cookie=0x1, in_port=1 actions=output:1
452 cookie=0x2, in_port=2 actions=output:1
453 cookie=0x3, in_port=3 actions=output:1
457 AT_CHECK([ovs-ofctl del-flows br0])
458 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
464 AT_SETUP([ofproto - del flows based on cookie])
466 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
467 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
468 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
469 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
470 cookie=0x1, in_port=1 actions=output:1
471 cookie=0x2, in_port=2 actions=output:1
472 cookie=0x3, in_port=3 actions=output:1
476 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/-1])
477 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
478 cookie=0x1, in_port=1 actions=output:1
479 cookie=0x2, in_port=2 actions=output:1
485 AT_SETUP([ofproto - del flows based on cookie mask])
487 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
488 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
489 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
490 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
491 cookie=0x1, in_port=1 actions=output:1
492 cookie=0x2, in_port=2 actions=output:1
493 cookie=0x3, in_port=3 actions=output:1
496 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/0x1])
497 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
498 cookie=0x2, in_port=2 actions=output:1
504 AT_SETUP([ofproto - del flows based on table id (NXM)])
506 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
507 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,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, table=1, in_port=2 actions=output:1
513 AT_CHECK([ovs-ofctl del-flows br0 table=0])
514 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
515 cookie=0x2, table=1, in_port=2 actions=output:1
518 AT_CHECK([ovs-ofctl del-flows br0 table=1])
519 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
522 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
523 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
524 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
525 cookie=0x1, in_port=1 actions=output:1
526 cookie=0x2, table=1, in_port=2 actions=output:1
529 AT_CHECK([ovs-ofctl del-flows br0])
530 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
536 AT_SETUP([ofproto - del flows based on table id (OpenFlow 1.2)])
538 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
539 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
540 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
541 cookie=0x1, in_port=1 actions=output:1
542 cookie=0x2, table=1, in_port=2 actions=output:1
543 OFPST_FLOW reply (OF1.2):
545 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0 table=0])
546 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
547 cookie=0x2, table=1, in_port=2 actions=output:1
548 OFPST_FLOW reply (OF1.2):
550 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0 table=1])
551 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
552 OFPST_FLOW reply (OF1.2):
554 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
555 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
556 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
557 cookie=0x1, in_port=1 actions=output:1
558 cookie=0x2, table=1, in_port=2 actions=output:1
559 OFPST_FLOW reply (OF1.2):
561 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0])
562 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
563 OFPST_FLOW reply (OF1.2):
568 AT_SETUP([ofproto - flow table configuration (OpenFlow 1.0)])
570 # Check the default configuration.
571 (echo "OFPST_TABLE reply (xid=0x2): 254 tables
572 0: classifier: wild=0x3fffff, max=1000000, active=0
575 while test $x -lt 254; do
576 printf " %d: %-8s: wild=0x3fffff, max=1000000, active=0
581 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
582 # Change the configuration.
585 -- --id=@t0 create Flow_Table name=main \
586 -- --id=@t1 create Flow_Table flow-limit=1024 \
587 -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
588 | perl $srcdir/uuidfilt.pl],
592 # Check that the configuration was updated.
593 mv expout orig-expout
594 (echo "OFPST_TABLE reply (xid=0x2): 254 tables
595 0: main : wild=0x3fffff, max=1000000, active=0
597 1: table1 : wild=0x3fffff, max= 1024, active=0
599 tail -n +6 orig-expout) > expout
600 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
604 AT_SETUP([ofproto - flow table configuration (OpenFlow 1.2)])
606 # Check the default configuration.
607 (mid="wild=0xffffffffff, max=1000000,"
610 match=0xffffffffff, instructions=0x00000007, config=0x00000003
611 write_actions=0x00000000, apply_actions=0x00000000
612 write_setfields=0x000000ffffffffff
613 apply_setfields=0x000000ffffffffff
614 metadata_match=0xffffffffffffffff
615 metadata_write=0xffffffffffffffff"
616 echo "OFPST_TABLE reply (OF1.2) (xid=0x2): 254 tables
617 0: classifier: $mid active=0$tail"
619 while test $x -lt 254; do
620 printf " %d: %-8s: $mid active=0$tail
624 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
625 # Change the configuration.
628 -- --id=@t0 create Flow_Table name=main \
629 -- --id=@t1 create Flow_Table flow-limit=1024 \
630 -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
631 | perl $srcdir/uuidfilt.pl],
635 # Check that the configuration was updated.
636 mv expout orig-expout
637 (echo "OFPST_TABLE reply (OF1.2) (xid=0x2): 254 tables
638 0: main : wild=0xffffffffff, max=1000000, active=0"
639 tail -n +3 orig-expout | head -7
640 echo " 1: table1 : wild=0xffffffffff, max= 1024, active=0"
641 tail -n +11 orig-expout) > expout
642 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
646 AT_SETUP([ofproto - hard limits on flow table size (OpenFLow 1.0)])
648 # Configure a maximum of 4 flows.
651 -- --id=@t0 create Flow_Table flow-limit=4 \
652 -- set bridge br0 flow_tables:0=@t0 \
653 | perl $srcdir/uuidfilt.pl],
657 for in_port in 1 2 3 4; do
658 ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
660 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
661 in_port=1 actions=drop
662 in_port=2 actions=drop
663 in_port=3 actions=drop
664 in_port=4 actions=drop
667 # Adding another flow will be refused.
668 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
669 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
670 [OFPT_ERROR: OFPFMFC_TABLE_FULL
672 # Also a mod-flow that would add a flow will be refused.
673 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
674 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
675 [OFPT_ERROR: OFPFMFC_TABLE_FULL
677 # Replacing or modifying an existing flow is allowed.
678 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
679 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
680 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
681 in_port=1 actions=drop
682 in_port=2 actions=drop
683 in_port=3 actions=output:1
684 in_port=4 actions=NORMAL
690 AT_SETUP([ofproto - hard limits on flow table size (OpenFLow 1.2)])
692 # Configure a maximum of 4 flows.
695 -- --id=@t0 create Flow_Table flow-limit=4 \
696 -- set bridge br0 flow_tables:0=@t0 \
697 | perl $srcdir/uuidfilt.pl],
701 for in_port in 1 2 3 4; do
702 ovs-ofctl -O OpenFlow12 add-flow br0 in_port=$in_port,actions=drop
704 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
705 in_port=1 actions=drop
706 in_port=2 actions=drop
707 in_port=3 actions=drop
708 in_port=4 actions=drop
709 OFPST_FLOW reply (OF1.2):
711 # Adding another flow will be refused.
712 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
713 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
714 [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
716 # Replacing or modifying an existing flow is allowed.
717 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
718 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
719 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
720 in_port=1 actions=drop
721 in_port=2 actions=drop
722 in_port=3 actions=output:1
723 in_port=4 actions=NORMAL
724 OFPST_FLOW reply (OF1.2):
729 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.0)])
731 # Configure a maximum of 4 flows.
734 -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
735 -- set bridge br0 flow_tables:0=@t0 \
736 | perl $srcdir/uuidfilt.pl],
740 for in_port in 4 3 2 1; do
741 ovs-ofctl add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
743 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
744 idle_timeout=10, in_port=1 actions=drop
745 idle_timeout=20, in_port=2 actions=drop
746 idle_timeout=30, in_port=3 actions=drop
747 idle_timeout=40, in_port=4 actions=drop
750 # Adding another flow will cause the one that expires soonest to be evicted.
751 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
752 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
753 idle_timeout=20, in_port=2 actions=drop
754 idle_timeout=30, in_port=3 actions=drop
755 idle_timeout=40, in_port=4 actions=drop
756 in_port=5 actions=drop
759 # A mod-flow that adds a flow also causes eviction, but replacing or
760 # modifying an existing flow doesn't.
761 AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
762 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
763 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
764 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
765 idle_timeout=30, in_port=3 actions=output:1
766 in_port=4 actions=NORMAL
767 in_port=5 actions=drop
768 in_port=6 actions=drop
771 # Flows with no timeouts at all cannot be evicted.
772 AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
773 AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
774 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
775 [OFPT_ERROR: OFPFMFC_TABLE_FULL
777 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
778 in_port=4 actions=NORMAL
779 in_port=5 actions=drop
780 in_port=6 actions=drop
781 in_port=7 actions=NORMAL
787 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.2)])
789 # Configure a maximum of 4 flows.
792 -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
793 -- set bridge br0 flow_tables:0=@t0 \
794 | perl $srcdir/uuidfilt.pl],
798 for in_port in 4 3 2 1; do
799 ovs-ofctl -O OpenFlow12 add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
801 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
802 idle_timeout=10, in_port=1 actions=drop
803 idle_timeout=20, in_port=2 actions=drop
804 idle_timeout=30, in_port=3 actions=drop
805 idle_timeout=40, in_port=4 actions=drop
806 OFPST_FLOW reply (OF1.2):
808 # Adding another flow will cause the one that expires soonest to be evicted.
809 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop])
810 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
811 idle_timeout=20, in_port=2 actions=drop
812 idle_timeout=30, in_port=3 actions=drop
813 idle_timeout=40, in_port=4 actions=drop
814 in_port=5 actions=drop
815 OFPST_FLOW reply (OF1.2):
817 # In Open Flow 1.2 a mod-flow does not ever add a flow and thus
818 # has no effect on eviction
819 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=6,actions=drop])
820 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
821 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
822 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
823 idle_timeout=20, in_port=2 actions=drop
824 idle_timeout=30, in_port=3 actions=output:1
825 in_port=4 actions=NORMAL
826 in_port=5 actions=drop
827 OFPST_FLOW reply (OF1.2):
829 # Flows with no timeouts at all cannot be evicted.
830 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=6,actions=drop])
831 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=7,actions=normal])
832 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
833 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
834 [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
836 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
837 in_port=4 actions=NORMAL
838 in_port=5 actions=drop
839 in_port=6 actions=drop
840 in_port=7 actions=NORMAL
841 OFPST_FLOW reply (OF1.2):
846 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.0)])
848 # Configure a maximum of 4 flows.
851 -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
852 overflow-policy=evict \
853 groups='"NXM_OF_IN_PORT[[]]"' \
854 -- set bridge br0 flow_tables:0=@t0 \
855 | perl $srcdir/uuidfilt.pl],
859 ovs-ofctl add-flows br0 - <<EOF
860 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
861 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
862 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
863 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
865 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
866 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
867 idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
868 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
869 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
872 # Adding another flow will cause the one that expires soonest within
873 # the largest group (those with in_port=1) to be evicted. In this
874 # case this is not the same as the one that expires soonest overall
875 # (which is what makes the test interesting):
876 AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
877 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
878 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
879 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
880 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
881 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
884 # Enlarge the flow limit, change the eviction policy back to strictly
885 # based on expiration, and and add some flows.
886 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
887 ovs-ofctl add-flows br0 - <<EOF
888 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
889 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
890 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
892 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
893 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
894 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
895 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
896 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
897 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
898 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
899 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
902 # Adding another flow will cause the one that expires soonest overall
904 AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
905 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
906 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
907 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
908 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
909 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
910 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
911 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
912 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
915 # Reducing the flow limit also causes the flows that expire soonest
916 # overall to be evicted.
917 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
918 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
919 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
920 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
921 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
922 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
928 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.2)])
930 # Configure a maximum of 4 flows.
933 -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
934 overflow-policy=evict \
935 groups='"NXM_OF_IN_PORT[[]]"' \
936 -- set bridge br0 flow_tables:0=@t0 \
937 | perl $srcdir/uuidfilt.pl],
941 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
942 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
943 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
944 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
945 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
947 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
948 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
949 idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
950 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
951 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
952 OFPST_FLOW reply (OF1.2):
954 # Adding another flow will cause the one that expires soonest within
955 # the largest group (those with in_port=1) to be evicted. In this
956 # case this is not the same as the one that expires soonest overall
957 # (which is what makes the test interesting):
958 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
959 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
960 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
961 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
962 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
963 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
964 OFPST_FLOW reply (OF1.2):
966 # Enlarge the flow limit, change the eviction policy back to strictly
967 # based on expiration, and and add some flows.
968 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
969 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
970 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
971 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
972 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
974 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
975 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
976 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
977 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
978 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
979 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
980 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
981 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
982 OFPST_FLOW reply (OF1.2):
984 # Adding another flow will cause the one that expires soonest overall
986 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'])
987 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
988 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
989 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
990 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
991 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
992 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
993 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
994 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
995 OFPST_FLOW reply (OF1.2):
997 # Reducing the flow limit also causes the flows that expire soonest
998 # overall to be evicted.
999 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
1000 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1001 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1002 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1003 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1004 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1005 OFPST_FLOW reply (OF1.2):
1010 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.0)])
1012 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
1014 printf '\n\n--- check_async %d ---\n\n\n' $1
1017 ovs-appctl -t ovs-ofctl ofctl/barrier
1018 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1021 # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1022 ovs-ofctl -v packet-out br0 controller controller '0001020304050010203040501234'
1023 if test X"$1" = X"OFPR_ACTION"; then shift;
1024 echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
1025 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"
1028 # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1029 ovs-ofctl -v packet-out br0 controller 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1030 if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1031 echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via no_match) data_len=14 (unbuffered)
1032 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"
1035 # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1036 ovs-ofctl packet-out br0 controller dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1037 if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1038 echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=CONTROLLER (via invalid_ttl) data_len=76 (unbuffered)
1039 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"
1042 # OFPT_PORT_STATUS, OFPPR_ADD
1043 ovs-vsctl add-port br0 test -- set Interface test type=dummy ofport_request=1
1044 if test X"$1" = X"OFPPR_ADD"; then shift;
1045 echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
1048 speed: 0 Mbps now, 0 Mbps max"
1051 # OFPT_PORT_STATUS, OFPPR_DELETE
1052 ovs-vsctl del-port br0 test
1053 if test X"$1" = X"OFPPR_DELETE"; then shift;
1054 echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
1057 speed: 0 Mbps now, 0 Mbps max"
1060 # OFPT_FLOW_REMOVED, OFPRR_DELETE
1061 ovs-ofctl add-flow br0 send_flow_rem,actions=drop
1062 ovs-ofctl --strict del-flows br0 ''
1063 if test X"$1" = X"OFPRR_DELETE"; then shift;
1064 echo >>expout "OFPT_FLOW_REMOVED: reason=delete"
1066 AT_FAIL_IF([test X"$1" != X])
1068 ovs-appctl -t ovs-ofctl ofctl/barrier
1069 echo >>expout "OFPT_BARRIER_REPLY:"
1073 s/ (xid=0x[0-9a-fA-F]*)//
1075 s/00:0.$/00:0x/' < monitor.log]],
1079 # It's a service connection so initially there should be no async messages.
1082 # Set miss_send_len to 128, turning on packet-ins for our service connection.
1083 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
1084 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1086 # Set miss_send_len to 128 and enable invalid_ttl.
1087 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
1088 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1090 # Become slave, which should disable everything except port status.
1091 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
1092 check_async 4 OFPPR_ADD OFPPR_DELETE
1094 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
1095 ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
1096 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1098 # Set controller ID 123.
1099 ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
1100 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1102 # Restore controller ID 0.
1103 ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
1106 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
1107 check_async 7 OFPR_ACTION OFPPR_ADD
1109 ovs-appctl -t ovs-ofctl exit
1113 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.2)])
1115 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1117 printf '\n\n--- check_async %d ---\n\n\n' $1
1121 ovs-appctl -t ovs-ofctl ofctl/barrier
1122 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1125 # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1126 ovs-ofctl -O OpenFlow12 -v packet-out br0 none controller '0001020304050010203040501234'
1127 if test X"$1" = X"OFPR_ACTION"; then shift;
1128 echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1129 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"
1132 # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1133 ovs-ofctl -O OpenFlow12 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1134 if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1135 echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
1136 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"
1139 # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1140 ovs-ofctl -O OpenFlow12 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1141 if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1142 echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
1143 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"
1146 # OFPT_PORT_STATUS, OFPPR_ADD
1147 ovs-vsctl add-port br0 test -- set Interface test type=dummy
1148 if test X"$1" = X"OFPPR_ADD"; then shift;
1149 echo >>expout "OFPT_PORT_STATUS (OF1.2): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1152 speed: 0 Mbps now, 0 Mbps max"
1155 # OFPT_PORT_STATUS, OFPPR_DELETE
1156 ovs-vsctl del-port br0 test
1157 if test X"$1" = X"OFPPR_DELETE"; then shift;
1158 echo >>expout "OFPT_PORT_STATUS (OF1.2): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1161 speed: 0 Mbps now, 0 Mbps max"
1164 # OFPT_FLOW_REMOVED, OFPRR_DELETE
1165 ovs-ofctl -O OpenFlow12 add-flow br0 send_flow_rem,actions=drop
1166 ovs-ofctl -O OpenFlow12 --strict del-flows br0 ''
1167 if test X"$1" = X"OFPRR_DELETE"; then shift;
1168 echo >>expout "OFPT_FLOW_REMOVED (OF1.2): reason=delete table_id=0"
1170 AT_FAIL_IF([test X"$1" != X])
1172 ovs-appctl -t ovs-ofctl ofctl/barrier
1173 echo >>expout "OFPT_BARRIER_REPLY (OF1.2):"
1177 s/ (xid=0x[0-9a-fA-F]*)//
1179 s/00:0.$/00:0x/' < monitor.log]],
1183 # It's a service connection so initially there should be no async messages.
1186 # Set miss_send_len to 128, turning on packet-ins for our service connection.
1187 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
1188 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1190 # Set miss_send_len to 128 and enable invalid_ttl.
1191 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700040080
1192 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1194 # Become slave (OF 1.2), which should disable everything except port status.
1195 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000200000003000000000000000000000001
1196 check_async 4 OFPPR_ADD OFPPR_DELETE
1198 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
1199 ovs-appctl -t ovs-ofctl ofctl/send 03040028000000020000232000000013000000020000000500000005000000020000000200000005
1200 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1202 # Set controller ID 123.
1203 ovs-appctl -t ovs-ofctl ofctl/send 03040018000000030000232000000014000000000000007b
1204 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1206 # Restore controller ID 0.
1207 ovs-appctl -t ovs-ofctl ofctl/send 030400180000000300002320000000140000000000000000
1209 # Become master (OF 1.2).
1210 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000400000002000000000000000000000002
1211 check_async 7 OFPR_ACTION OFPPR_ADD
1213 ovs-appctl -t ovs-ofctl exit
1217 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.3)])
1219 AT_CHECK([ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile])
1221 printf '\n\n--- check_async %d ---\n\n\n' $1
1225 ovs-appctl -t ovs-ofctl ofctl/barrier
1226 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1229 # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1230 ovs-ofctl -O OpenFlow13 -v packet-out br0 none controller '0001020304050010203040501234'
1231 if test X"$1" = X"OFPR_ACTION"; then shift;
1232 echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1233 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"
1236 # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1237 ovs-ofctl -O OpenFlow13 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1238 if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1239 echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
1240 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"
1243 # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1244 ovs-ofctl -O OpenFlow13 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1245 if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1246 echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
1247 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"
1250 # OFPT_PORT_STATUS, OFPPR_ADD
1251 ovs-vsctl add-port br0 test -- set Interface test type=dummy
1252 if test X"$1" = X"OFPPR_ADD"; then shift;
1253 echo >>expout "OFPT_PORT_STATUS (OF1.3): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1256 speed: 0 Mbps now, 0 Mbps max"
1259 # OFPT_PORT_STATUS, OFPPR_DELETE
1260 ovs-vsctl del-port br0 test
1261 if test X"$1" = X"OFPPR_DELETE"; then shift;
1262 echo >>expout "OFPT_PORT_STATUS (OF1.3): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1265 speed: 0 Mbps now, 0 Mbps max"
1268 # OFPT_FLOW_REMOVED, OFPRR_DELETE
1269 ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=drop
1270 ovs-ofctl -O OpenFlow13 --strict del-flows br0 ''
1271 if test X"$1" = X"OFPRR_DELETE"; then shift;
1272 echo >>expout "OFPT_FLOW_REMOVED (OF1.3): reason=delete table_id=0"
1274 AT_FAIL_IF([test X"$1" != X])
1276 ovs-appctl -t ovs-ofctl ofctl/barrier
1277 echo >>expout "OFPT_BARRIER_REPLY (OF1.3):"
1281 s/ (xid=0x[0-9a-fA-F]*)//
1283 s/00:0.$/00:0x/' < monitor.log]],
1287 # It's a service connection so initially there should be no async messages.
1290 # Set miss_send_len to 128, turning on packet-ins for our service connection.
1291 ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
1292 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1294 # Become slave (OF 1.3), which should disable everything except port status.
1295 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000200000003000000000000000000000001
1296 check_async 3 OFPPR_ADD OFPPR_DELETE
1298 # Use OF 1.3 OFPT_SET_ASYNC to enable a patchwork of asynchronous messages.
1299 ovs-appctl -t ovs-ofctl ofctl/send 041c002000000002000000020000000500000005000000020000000200000005
1300 check_async 4 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1302 # Set controller ID 123.
1303 ovs-appctl -t ovs-ofctl ofctl/send 04040018000000030000232000000014000000000000007b
1304 check_async 5 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1306 # Restore controller ID 0.
1307 ovs-appctl -t ovs-ofctl ofctl/send 040400180000000300002320000000140000000000000000
1309 # Become master (OF 1.3).
1310 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000400000002000000000000000000000002
1311 check_async 6 OFPR_ACTION OFPPR_ADD
1313 ovs-appctl -t ovs-ofctl exit
1317 dnl This test checks that the role request/response messaging works
1318 dnl and that generation_id is handled properly.
1319 AT_SETUP([ofproto - controller role (OpenFlow 1.2)])
1321 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1323 ovs-appctl -t ovs-ofctl ofctl/barrier
1324 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1327 # find out current role
1328 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000200000000000000000000000000000000
1329 echo >>expout "send: OFPT_ROLE_REQUEST (OF1.2) (xid=0x2): role=nochange"
1330 echo >>expout "OFPT_ROLE_REPLY (OF1.2) (xid=0x2): role=equal"
1332 # Become slave (generation_id is initially undefined, so 2^63+2 should not be stale)
1333 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000300000003000000008000000000000002
1334 echo >>expout "send: OFPT_ROLE_REQUEST (OF1.2) (xid=0x3): role=slave generation_id=9223372036854775810"
1335 echo >>expout "OFPT_ROLE_REPLY (OF1.2) (xid=0x3): role=slave"
1337 # Try to become the master using a stale generation ID
1338 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000400000002000000000000000000000002
1339 echo >>expout "send: OFPT_ROLE_REQUEST (OF1.2) (xid=0x4): role=master generation_id=2"
1340 echo >>expout "OFPT_ERROR (OF1.2) (xid=0x4): OFPRRFC_STALE"
1341 echo >>expout "OFPT_ROLE_REQUEST (OF1.2) (xid=0x4): role=master generation_id=2"
1343 # Become master using a valid generation ID
1344 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000500000002000000000000000000000001
1345 echo >>expout "send: OFPT_ROLE_REQUEST (OF1.2) (xid=0x5): role=master generation_id=1"
1346 echo >>expout "OFPT_ROLE_REPLY (OF1.2) (xid=0x5): role=master"
1347 ovs-appctl -t ovs-ofctl ofctl/barrier
1348 echo >>expout "OFPT_BARRIER_REPLY (OF1.2) (xid=0x3):"
1350 AT_CHECK([cat monitor.log], [0], [expout])
1352 ovs-appctl -t ovs-ofctl exit
1356 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
1357 dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
1358 dnl controllers despite the spec) as meaning a packet that was generated
1359 dnl by the controller.
1360 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.0)])
1363 # Start a monitor listening for packet-ins.
1364 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
1365 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
1366 ovs-appctl -t ovs-ofctl ofctl/barrier
1367 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1368 AT_CAPTURE_FILE([monitor.log])
1370 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
1371 AT_CHECK([ovs-ofctl packet-out br0 none controller '0001020304050010203040501234'])
1372 AT_CHECK([ovs-ofctl packet-out br0 controller controller '0001020304050010203040505678'])
1374 # Stop the monitor and check its output.
1375 ovs-appctl -t ovs-ofctl ofctl/barrier
1376 ovs-appctl -t ovs-ofctl exit
1378 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
1379 OFPT_PACKET_IN: total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1380 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
1381 OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
1382 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
1389 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
1390 dnl specified by OpenFlow 1.2) and OFPP_CONTROLLER (used by some
1391 dnl controllers despite the spec) as meaning a packet that was generated
1392 dnl by the controller.
1393 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.2)])
1396 # Start a monitor listening for packet-ins.
1397 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1398 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
1399 ovs-appctl -t ovs-ofctl ofctl/barrier
1400 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1401 AT_CAPTURE_FILE([monitor.log])
1403 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
1404 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none controller '0001020304050010203040501234'])
1405 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 4294967293 controller '0001020304050010203040505678'])
1407 # Stop the monitor and check its output.
1408 ovs-appctl -t ovs-ofctl ofctl/barrier
1409 ovs-appctl -t ovs-ofctl exit
1411 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
1412 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1413 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
1414 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
1415 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
1416 OFPT_BARRIER_REPLY (OF1.2):
1422 dnl This test checks that metadata is encoded in packet_in structures,
1423 dnl supported by NXAST.
1424 AT_SETUP([ofproto - packet-out with metadata (NXM)])
1427 # Start a monitor listening for packet-ins.
1428 AT_CHECK([ovs-ofctl -P nxm monitor br0 --detach --no-chdir --pidfile])
1429 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
1430 ovs-appctl -t ovs-ofctl ofctl/barrier
1431 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1432 AT_CAPTURE_FILE([monitor.log])
1434 # Send a packet-out with a load action to set some metadata, and forward to controller
1435 AT_CHECK([ovs-ofctl packet-out br0 controller 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), controller' '0001020304050010203040501234'])
1437 # Stop the monitor and check its output.
1438 ovs-appctl -t ovs-ofctl ofctl/barrier
1439 ovs-appctl -t ovs-ofctl exit
1441 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
1442 NXT_PACKET_IN: total_len=14 in_port=CONTROLLER metadata=0xfafafafa5a5a5a5a (via action) data_len=14 (unbuffered)
1443 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
1450 dnl This test checks that metadata is encoded in packet_in structures,
1451 dnl supported by NXAST.
1452 AT_SETUP([ofproto - packet-out with metadata (OpenFlow 1.2)])
1455 # Start a monitor listening for packet-ins.
1456 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1457 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
1458 ovs-appctl -t ovs-ofctl ofctl/barrier
1459 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1460 AT_CAPTURE_FILE([monitor.log])
1462 # Send a packet-out with a load action to set some metadata, and forward to controller
1463 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), controller' '0001020304050010203040501234'])
1465 # Stop the monitor and check its output.
1466 ovs-appctl -t ovs-ofctl ofctl/barrier
1467 ovs-appctl -t ovs-ofctl exit
1469 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
1470 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY metadata=0xfafafafa5a5a5a5a (via action) data_len=14 (unbuffered)
1471 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
1472 OFPT_BARRIER_REPLY (OF1.2):
1478 AT_SETUP([ofproto - flow monitoring])
1479 AT_KEYWORDS([monitor])
1482 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
1484 # Start a monitor watching the flow table and check the initial reply.
1485 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
1486 AT_CAPTURE_FILE([monitor.log])
1487 ovs-appctl -t ovs-ofctl ofctl/barrier
1488 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
1489 [NXST_FLOW_MONITOR reply:
1490 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
1494 # Add, delete, and modify some flows and check the updates.
1495 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1496 ovs-ofctl add-flow br0 in_port=0,dl_vlan=124,actions=output:2
1497 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:5
1498 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=0,actions=output:6
1499 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=1,actions=output:7
1500 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:8
1501 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=0,actions=output:9
1502 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=1,actions=output:10
1503 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,actions=output:11
1504 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=0,actions=output:12
1505 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=1,actions=output:13
1506 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,actions=output:14
1507 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:15
1508 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:16
1509 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:17
1510 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:18
1511 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:19
1512 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:20
1513 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=0,actions=output:21
1514 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=1,actions=output:22
1515 ovs-ofctl add-flow br0 in_port=0,actions=output:23
1516 ovs-ofctl mod-flows br0 cookie=5,dl_vlan=123,actions=output:3
1517 ovs-ofctl del-flows br0 dl_vlan=123
1518 ovs-ofctl del-flows br0
1519 ovs-appctl -t ovs-ofctl ofctl/barrier
1521 # Sorts groups of lines that start with a space, without moving them
1522 # past the nearest line that does not start with a space.
1530 print $_ foreach sort(@buffer);
1535 print $_ foreach sort(@buffer);
1537 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | perl -e "$sort"], [0],
1538 [NXST_FLOW_MONITOR reply (xid=0x0):
1539 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
1540 NXST_FLOW_MONITOR reply (xid=0x0):
1541 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:5
1542 NXST_FLOW_MONITOR reply (xid=0x0):
1543 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:6
1544 NXST_FLOW_MONITOR reply (xid=0x0):
1545 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:7
1546 NXST_FLOW_MONITOR reply (xid=0x0):
1547 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:8
1548 NXST_FLOW_MONITOR reply (xid=0x0):
1549 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:9
1550 NXST_FLOW_MONITOR reply (xid=0x0):
1551 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:10
1552 NXST_FLOW_MONITOR reply (xid=0x0):
1553 event=ADDED table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
1554 NXST_FLOW_MONITOR reply (xid=0x0):
1555 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
1556 NXST_FLOW_MONITOR reply (xid=0x0):
1557 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
1558 NXST_FLOW_MONITOR reply (xid=0x0):
1559 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
1560 NXST_FLOW_MONITOR reply (xid=0x0):
1561 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:15
1562 NXST_FLOW_MONITOR reply (xid=0x0):
1563 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:16
1564 NXST_FLOW_MONITOR reply (xid=0x0):
1565 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:17
1566 NXST_FLOW_MONITOR reply (xid=0x0):
1567 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
1568 NXST_FLOW_MONITOR reply (xid=0x0):
1569 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
1570 NXST_FLOW_MONITOR reply (xid=0x0):
1571 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
1572 NXST_FLOW_MONITOR reply (xid=0x0):
1573 event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
1574 NXST_FLOW_MONITOR reply (xid=0x0):
1575 event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
1576 NXST_FLOW_MONITOR reply (xid=0x0):
1577 event=ADDED table=0 cookie=0 in_port=0 actions=output:23
1578 NXST_FLOW_MONITOR reply (xid=0x0):
1579 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
1580 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
1581 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
1582 NXST_FLOW_MONITOR reply (xid=0x0):
1583 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
1584 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
1585 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
1586 NXST_FLOW_MONITOR reply (xid=0x0):
1587 event=DELETED reason=delete table=0 cookie=0 in_port=0 actions=output:23
1588 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
1589 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
1590 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
1591 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
1592 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
1593 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
1594 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
1595 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
1596 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
1597 event=DELETED reason=delete table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
1601 # Check that our own changes are reported as abbreviations.
1602 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1603 ovs-ofctl add-flow br0 in_port=1,actions=output:2
1604 ovs-ofctl add-flow br0 in_port=2,actions=output:1
1605 ovs-appctl -t ovs-ofctl ofctl/barrier
1606 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
1607 ovs-appctl -t ovs-ofctl ofctl/barrier
1608 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
1610 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
1611 [NXST_FLOW_MONITOR reply (xid=0x0):
1612 event=ADDED table=0 cookie=0 in_port=1 actions=output:2
1613 NXST_FLOW_MONITOR reply (xid=0x0):
1614 event=ADDED table=0 cookie=0 in_port=2 actions=output:1
1616 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
1617 NXST_FLOW_MONITOR reply (xid=0x0):
1618 event=ABBREV xid=0x12345678
1622 ovs-appctl -t ovs-ofctl exit
1626 AT_SETUP([ofproto - flow monitoring pause and resume])
1627 AT_KEYWORDS([monitor])
1629 # The maximum socket receive buffer size is important for this test, which
1630 # tests behavior when the receive buffer overflows.
1631 if test -e /proc/sys/net/core/rmem_max; then
1633 rmem_max=`cat /proc/sys/net/core/rmem_max`
1634 elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
1637 # Don't know how to get maximum socket receive buffer on this OS
1640 # Calculate the total amount of queuing: rmem_max in the kernel, 128 kB
1641 # in ofproto sending userspace (see ofmonitor_flush() in connmgr.c).
1642 queue_size=`expr $rmem_max + 128 \* 1024`
1643 echo rmem_max=$rmem_max queue_size=$queue_size
1645 # Each flow update message takes up at least 48 bytes of space in queues
1646 # and in practice more than that.
1647 n_msgs=`expr $queue_size / 48`
1652 # Start a monitor watching the flow table, then make it block.
1653 ON_EXIT([kill `cat ovs-ofctl.pid`])
1654 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
1655 AT_CAPTURE_FILE([monitor.log])
1656 ovs-appctl -t ovs-ofctl ofctl/block
1658 # Add $n_msgs flows.
1659 (echo "in_port=2,actions=output:2"
1661 for ($i = 0; $i < '$n_msgs'; $i++) {
1662 print "cookie=1,reg1=$i,actions=drop\n";
1665 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
1666 # Check that multipart flow dumps work properly:
1667 AT_CHECK([ovs-ofctl diff-flows br0 flows.txt])
1668 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,cookie=3,actions=drop])
1669 AT_CHECK([ovs-ofctl mod-flows br0 in_port=2,cookie=2,actions=output:2])
1670 AT_CHECK([ovs-ofctl del-flows br0 cookie=1/-1])
1672 ovs-appctl -t ovs-ofctl ofctl/unblock
1673 ovs-appctl -t ovs-ofctl ofctl/barrier
1675 ovs-appctl -t ovs-ofctl exit
1677 # Check that the flow monitor reported the same number of flows
1678 # added and deleted, but fewer than we actually added and deleted.
1679 adds=`grep -c 'ADDED.*reg1=' monitor.log`
1680 deletes=`grep -c 'DELETED.*reg1=' monitor.log`
1681 echo adds=$adds deletes=$deletes
1682 AT_CHECK([test $adds -gt 100 && test $adds -lt $n_msgs])
1683 AT_CHECK([test $adds = $deletes])
1685 # Check that the flow monitor reported everything in the expected order:
1687 # event=ADDED table=0 cookie=0x1 reg1=0x22
1689 # NXT_FLOW_MONITOR_PAUSED:
1691 # event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1693 # event=ADDED table=0 cookie=0x3 in_port=1
1694 # event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
1695 # NXT_FLOW_MONITOR_RESUMED:
1697 # except that, between the PAUSED and RESUMED, the order of the ADDED
1698 # and MODIFIED lines lines depends on hash order, that is, it varies
1699 # as we change the hash function or change architecture. Therefore,
1700 # we use a couple of tests below to accept both orders.
1701 AT_CHECK([ofctl_strip < monitor.log | sed -n -e '
1704 /NXT_FLOW_MONITOR_PAUSED:/p
1705 /NXT_FLOW_MONITOR_RESUMED:/p
1706 ' > monitor.log.subset])
1707 AT_CHECK([grep -v MODIFIED monitor.log.subset], [0], [dnl
1708 event=ADDED table=0 cookie=0x1 reg1=0x22
1709 NXT_FLOW_MONITOR_PAUSED:
1710 event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1711 event=ADDED table=0 cookie=0x3 in_port=1
1712 NXT_FLOW_MONITOR_RESUMED:
1714 AT_CHECK([grep -v ADDED monitor.log.subset], [0], [dnl
1715 NXT_FLOW_MONITOR_PAUSED:
1716 event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1717 event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
1718 NXT_FLOW_MONITOR_RESUMED: