vlog: Take advantage of relaxed "-v" syntax through the tree.
[sliver-openvswitch.git] / tests / ofproto.at
1 AT_BANNER([ofproto])
2
3 AT_SETUP([ofproto - echo request])
4 OVS_VSWITCHD_START
5 AT_CHECK([ovs-ofctl -vwarn probe br0])
6 OVS_VSWITCHD_STOP
7 AT_CLEANUP
8
9 AT_SETUP([ofproto - feature request, config request])
10 OVS_VSWITCHD_START
11 AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
12 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
13 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
14 n_tables:255, n_buffers:256
15 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
16 actions: OUTPUT SET_VLAN_VID SET_VLAN_PCP STRIP_VLAN SET_DL_SRC SET_DL_DST SET_NW_SRC SET_NW_DST SET_NW_TOS SET_TP_SRC SET_TP_DST ENQUEUE
17  LOCAL(br0): addr:aa:55:aa:55:00:00
18      config:     PORT_DOWN
19      state:      LINK_DOWN
20      speed: 100 Mbps now, 100 Mbps max
21 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
22 ])
23 OVS_VSWITCHD_STOP
24 AT_CLEANUP
25
26 dnl This is really bare-bones.
27 dnl It at least checks request and reply serialization and deserialization.
28 AT_SETUP([ofproto - port stats])
29 OVS_VSWITCHD_START
30 AT_CHECK([ovs-ofctl -vwarn dump-ports br0], [0], [stdout])
31 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
32 OFPST_PORT reply: 1 ports
33   port 65534: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
34            tx pkts=0, bytes=0, drop=0, errs=0, coll=0
35 ])
36 OVS_VSWITCHD_STOP
37 AT_CLEANUP
38
39 dnl This is really bare-bones.
40 dnl It at least checks request and reply serialization and deserialization.
41 AT_SETUP([ofproto - port-desc stats])
42 OVS_VSWITCHD_START
43 AT_CHECK([ovs-ofctl -vwarn dump-ports-desc br0], [0], [stdout])
44 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
45 OFPST_PORT_DESC reply:
46  LOCAL(br0): addr:aa:55:aa:55:00:00
47      config:     PORT_DOWN
48      state:      LINK_DOWN
49      speed: 100 Mbps now, 100 Mbps max
50 ])
51 OVS_VSWITCHD_STOP
52 AT_CLEANUP
53
54 dnl This is really bare-bones.
55 dnl It at least checks request and reply serialization and deserialization.
56 AT_SETUP([ofproto - queue stats])
57 OVS_VSWITCHD_START
58 AT_CHECK([ovs-ofctl -vwarn queue-stats br0], [0], [stdout])
59 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
60 OFPST_QUEUE reply: 0 queues
61 ])
62 OVS_VSWITCHD_STOP
63 AT_CLEANUP
64
65 AT_SETUP([ofproto - mod-port])
66 OVS_VSWITCHD_START
67 for command_config_state in \
68     'up 0 0' \
69     'noflood NO_FLOOD 0' \
70     'down PORT_DOWN,NO_FLOOD LINK_DOWN' \
71     'flood PORT_DOWN LINK_DOWN'
72 do
73     set $command_config_state
74     command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
75     AT_CHECK([ovs-ofctl -vwarn mod-port br0 br0 $command])
76     AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
77     AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
78 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
79 n_tables:255, n_buffers:256
80 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
81 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
82  LOCAL(br0): addr:aa:55:aa:55:00:00
83      config:     $config
84      state:      $state
85      speed: 100 Mbps now, 100 Mbps max
86 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
87 ])
88 done
89 OVS_VSWITCHD_STOP
90 AT_CLEANUP
91
92 AT_SETUP([ofproto - basic flow_mod commands (NXM)])
93 OVS_VSWITCHD_START
94 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
95 ])
96 AT_CHECK([echo 'in_port=1,actions=0' | ovs-ofctl add-flows br0 -])
97 AT_CHECK([ovs-ofctl add-flow br0 in_port=0,actions=1])
98 AT_CHECK([ovs-ofctl -F nxm add-flow br0 table=1,in_port=3,actions=2])
99 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
100  in_port=0 actions=output:1
101  in_port=1 actions=output:0
102  table=1, in_port=3 actions=output:2
103 NXST_FLOW reply:
104 ])
105 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
106 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
107 ])
108 AT_CHECK([ovs-ofctl del-flows br0])
109 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
110 ])
111 OVS_VSWITCHD_STOP
112 AT_CLEANUP
113
114 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.0)])
115 OVS_VSWITCHD_START
116 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
117 ])
118 AT_CHECK([echo 'in_port=1,actions=0' | ovs-ofctl -F openflow10 add-flows br0 -])
119 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 in_port=0,actions=1])
120 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 table=1,in_port=3,actions=2])
121 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
122  in_port=0 actions=output:1
123  in_port=1 actions=output:0
124  table=1, in_port=3 actions=output:2
125 OFPST_FLOW reply:
126 ])
127 AT_CHECK([ovs-ofctl -F openflow10 dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
128 OFPST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
129 ])
130 AT_CHECK([ovs-ofctl -F openflow10 del-flows br0])
131 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
132 ])
133 OVS_VSWITCHD_STOP
134 AT_CLEANUP
135
136 AT_SETUP([ofproto - dump flows with cookie])
137 OVS_VSWITCHD_START
138 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=0])
139 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=0])
140 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=0])
141 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
142  cookie=0x1, in_port=1 actions=output:0
143  cookie=0x2, in_port=2 actions=output:0
144  cookie=0x3, in_port=3 actions=output:0
145 NXST_FLOW reply:
146 ])
147 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
148 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
149 ])
150 AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3 | ofctl_strip | sort], [0], [dnl
151  cookie=0x3, in_port=3 actions=output:0
152 NXST_FLOW reply:
153 ])
154 AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3 | STRIP_XIDS], [0], [dnl
155 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=1
156 ])
157 OVS_VSWITCHD_STOP
158 AT_CLEANUP
159
160 AT_SETUP([ofproto - dump flows with cookie mask])
161 OVS_VSWITCHD_START
162 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=0])
163 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=0])
164 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=0])
165 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
166  cookie=0x1, in_port=1 actions=output:0
167  cookie=0x2, in_port=2 actions=output:0
168  cookie=0x3, in_port=3 actions=output:0
169 NXST_FLOW reply:
170 ])
171 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
172 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
173 ])
174 AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/0x1 | ofctl_strip | sort], [0], [dnl
175  cookie=0x1, in_port=1 actions=output:0
176  cookie=0x3, in_port=3 actions=output:0
177 NXST_FLOW reply:
178 ])
179 AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/0x1 | STRIP_XIDS], [0], [dnl
180 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
181 ])
182 OVS_VSWITCHD_STOP
183 AT_CLEANUP
184
185 AT_SETUP([ofproto - del flows with cookie])
186 OVS_VSWITCHD_START
187 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=0])
188 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=0])
189 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=0])
190 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
191  cookie=0x1, in_port=1 actions=output:0
192  cookie=0x2, in_port=2 actions=output:0
193  cookie=0x3, in_port=3 actions=output:0
194 NXST_FLOW reply:
195 ])
196
197 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3])
198 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
199  cookie=0x1, in_port=1 actions=output:0
200  cookie=0x2, in_port=2 actions=output:0
201 NXST_FLOW reply:
202 ])
203 OVS_VSWITCHD_STOP
204 AT_CLEANUP
205
206 AT_SETUP([ofproto - del flows with cookie mask])
207 OVS_VSWITCHD_START
208 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=0])
209 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=0])
210 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=0])
211 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
212  cookie=0x1, in_port=1 actions=output:0
213  cookie=0x2, in_port=2 actions=output:0
214  cookie=0x3, in_port=3 actions=output:0
215 NXST_FLOW reply:
216 ])
217 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/0x1])
218 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
219  cookie=0x2, in_port=2 actions=output:0
220 NXST_FLOW reply:
221 ])
222 OVS_VSWITCHD_STOP
223 AT_CLEANUP
224
225 AT_SETUP([ofproto - flow table configuration])
226 OVS_VSWITCHD_START
227 # Check the default configuration.
228 (echo "OFPST_TABLE reply (xid=0x1): 255 tables
229   0: classifier: wild=0x3fffff, max=1000000, active=0
230                lookup=0, matched=0"
231  x=1
232  while test $x -lt 254; do
233    printf "  %d: %-8s: wild=0x3fffff, max=1000000, active=0
234                lookup=0, matched=0
235 " $x table$x
236    x=`expr $x + 1`
237  done
238  echo "  254: table254: wild=0x3fffff, max=1000000, active=2
239                lookup=0, matched=0") > expout
240 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
241 # Change the configuration.
242 AT_CHECK(
243   [ovs-vsctl \
244      -- --id=@t0 create Flow_Table name=main \
245      -- --id=@t1 create Flow_Table flow-limit=1024 \
246      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
247    | perl $srcdir/uuidfilt.pl],
248   [0], [<0>
249 <1>
250 ])
251 # Check that the configuration was updated.
252 mv expout orig-expout
253 (echo "OFPST_TABLE reply (xid=0x1): 255 tables
254   0: main    : wild=0x3fffff, max=1000000, active=0
255                lookup=0, matched=0
256   1: table1  : wild=0x3fffff, max=  1024, active=0
257                lookup=0, matched=0"
258  tail -n +6 orig-expout) > expout
259 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
260 OVS_VSWITCHD_STOP
261 AT_CLEANUP
262
263 AT_SETUP([ofproto - hard limits on flow table size])
264 OVS_VSWITCHD_START
265 # Configure a maximum of 4 flows.
266 AT_CHECK(
267   [ovs-vsctl \
268      -- --id=@t0 create Flow_Table flow-limit=4 \
269      -- set bridge br0 flow_tables:0=@t0 \
270    | perl $srcdir/uuidfilt.pl],
271   [0], [<0>
272 ])
273 # Add 4 flows.
274 for in_port in 1 2 3 4; do
275     ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
276 done
277 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
278  in_port=1 actions=drop
279  in_port=2 actions=drop
280  in_port=3 actions=drop
281  in_port=4 actions=drop
282 NXST_FLOW reply:
283 ])
284 # Adding another flow will be refused.
285 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
286 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
287   [OFPT_ERROR: OFPFMFC_ALL_TABLES_FULL
288 ])
289 # Also a mod-flow that would add a flow will be refused.
290 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
291 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
292   [OFPT_ERROR: OFPFMFC_ALL_TABLES_FULL
293 ])
294 # Replacing or modifying an existing flow is allowed.
295 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
296 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
297 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
298  in_port=1 actions=drop
299  in_port=2 actions=drop
300  in_port=3 actions=output:1
301  in_port=4 actions=NORMAL
302 NXST_FLOW reply:
303 ])
304 OVS_VSWITCHD_STOP
305 AT_CLEANUP
306
307 AT_SETUP([ofproto - eviction upon table overflow])
308 OVS_VSWITCHD_START
309 # Configure a maximum of 4 flows.
310 AT_CHECK(
311   [ovs-vsctl \
312      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
313      -- set bridge br0 flow_tables:0=@t0 \
314    | perl $srcdir/uuidfilt.pl],
315   [0], [<0>
316 ])
317 # Add 4 flows.
318 for in_port in 4 3 2 1; do
319     ovs-ofctl add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
320 done
321 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
322  idle_timeout=10, in_port=1 actions=drop
323  idle_timeout=20, in_port=2 actions=drop
324  idle_timeout=30, in_port=3 actions=drop
325  idle_timeout=40, in_port=4 actions=drop
326 NXST_FLOW reply:
327 ])
328 # Adding another flow will cause the one that expires soonest to be evicted.
329 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
330 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
331  idle_timeout=20, in_port=2 actions=drop
332  idle_timeout=30, in_port=3 actions=drop
333  idle_timeout=40, in_port=4 actions=drop
334  in_port=5 actions=drop
335 NXST_FLOW reply:
336 ])
337 # A mod-flow that adds a flow also causes eviction, but replacing or
338 # modifying an existing flow doesn't.
339 AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
340 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
341 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
342 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
343  idle_timeout=30, in_port=3 actions=output:1
344  in_port=4 actions=NORMAL
345  in_port=5 actions=drop
346  in_port=6 actions=drop
347 NXST_FLOW reply:
348 ])
349 # Flows with no timeouts at all cannot be evicted.
350 AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
351 AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
352 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
353   [OFPT_ERROR: OFPFMFC_ALL_TABLES_FULL
354 ])
355 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
356  in_port=4 actions=NORMAL
357  in_port=5 actions=drop
358  in_port=6 actions=drop
359  in_port=7 actions=NORMAL
360 NXST_FLOW reply:
361 ])
362 OVS_VSWITCHD_STOP
363 AT_CLEANUP
364
365 AT_SETUP([ofproto - eviction upon table overflow, with fairness])
366 OVS_VSWITCHD_START
367 # Configure a maximum of 4 flows.
368 AT_CHECK(
369   [ovs-vsctl \
370      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
371                                    overflow-policy=evict \
372                                    groups='"NXM_OF_IN_PORT[[]]"' \
373      -- set bridge br0 flow_tables:0=@t0 \
374    | perl $srcdir/uuidfilt.pl],
375   [0], [<0>
376 ])
377 # Add 4 flows.
378 ovs-ofctl add-flows br0 - <<EOF
379 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
380 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
381 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
382 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
383 EOF
384 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
385  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
386  idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
387  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
388  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
389 NXST_FLOW reply:
390 ])
391 # Adding another flow will cause the one that expires soonest within
392 # the largest group (those with in_port=1) to be evicted.  In this
393 # case this is not the same as the one that expires soonest overall
394 # (which is what makes the test interesting):
395 AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
396 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
397  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
398  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
399  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
400  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
401 NXST_FLOW reply:
402 ])
403 # Enlarge the flow limit, change the eviction policy back to strictly
404 # based on expiration, and and add some flows.
405 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
406 ovs-ofctl add-flows br0 - <<EOF
407 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
408 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
409 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
410 EOF
411 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
412  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
413  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
414  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
415  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
416  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
417  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
418  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
419 NXST_FLOW reply:
420 ])
421 # Adding another flow will cause the one that expires soonest overall
422 # to be evicted.
423 AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
424 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
425  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
426  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
427  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
428  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
429  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
430  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
431  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
432 NXST_FLOW reply:
433 ])
434 # Reducing the flow limit also causes the flows that expire soonest
435 # overall to be evicted.
436 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
437 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
438  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
439  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
440  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
441  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
442 NXST_FLOW reply:
443 ])
444 OVS_VSWITCHD_STOP
445 AT_CLEANUP
446
447 AT_SETUP([ofproto - asynchronous message control])
448 OVS_VSWITCHD_START
449 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
450 check_async () {
451     printf '\n\n--- check_async %d ---\n\n\n' $1
452     shift
453
454     ovs-appctl -t ovs-ofctl ofctl/barrier
455     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
456     : > expout
457
458     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
459     ovs-ofctl -v packet-out br0 none controller '0001020304050010203040501234'
460     if test X"$1" = X"OFPR_ACTION"; then shift;
461         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=NONE (via action) data_len=14 (unbuffered)
462 priority:0,tunnel:0,in_port:0000,tci(0) mac(00:10:20:30:40:50->00:01:02:03:04:05) type:1234 proto:0 tos:0 ttl:0 ip(0.0.0.0->0.0.0.0)"
463     fi
464
465     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
466     ovs-ofctl -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
467     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
468         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=NONE (via no_match) data_len=14 (unbuffered)
469 priority:0,tunnel:0,in_port:0000,tci(0) mac(00:10:20:30:40:50->00:01:02:03:04:05) type:1234 proto:0 tos:0 ttl:0 ip(0.0.0.0->0.0.0.0)"
470     fi
471
472     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
473     ovs-ofctl packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
474     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
475         echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=NONE (via invalid_ttl) data_len=76 (unbuffered)
476 priority:0,tunnel:0,in_port:0000,tci(0) mac(00:26:b9:8c:b0:f9->00:25:83:df:b4:00) type:0800 proto:17 tos:0 ttl:0 ip(172.17.55.13->172.16.0.2) port(55155->53) udp_csum:8f6d"
477     fi
478
479     # OFPT_PORT_STATUS, OFPPR_ADD
480     ovs-vsctl add-port br0 test -- set Interface test type=dummy
481     if test X"$1" = X"OFPPR_ADD"; then shift;
482         echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
483      config:     PORT_DOWN
484      state:      LINK_DOWN
485      speed: 100 Mbps now, 100 Mbps max"
486     fi
487
488     # OFPT_PORT_STATUS, OFPPR_DELETE
489     ovs-vsctl del-port br0 test
490     if test X"$1" = X"OFPPR_DELETE"; then shift;
491         echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
492      config:     PORT_DOWN
493      state:      LINK_DOWN
494      speed: 100 Mbps now, 100 Mbps max"
495     fi
496
497     # OFPT_FLOW_REMOVED, OFPRR_DELETE
498     ovs-ofctl add-flow br0 send_flow_rem,actions=drop
499     ovs-ofctl --strict del-flows br0 ''
500     if test X"$1" = X"OFPRR_DELETE"; then shift;
501         echo >>expout "OFPT_FLOW_REMOVED:  reason=delete"
502     fi
503     AT_FAIL_IF([test X"$1" != X])
504
505     ovs-appctl -t ovs-ofctl ofctl/barrier
506     echo >>expout "OFPT_BARRIER_REPLY:"
507
508     AT_CHECK(
509       [[sed '
510 s/ (xid=0x[0-9a-fA-F]*)//
511 s/ *duration.*//
512 s/00:0.$/00:0x/' < monitor.log]],
513       [0], [expout])
514 }
515
516 # It's a service connection so initially there should be no async messages.
517 check_async 1
518
519 # Set miss_send_len to 128, turning on packet-ins for our service connection.
520 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
521 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
522
523 # Set miss_send_len to 128 and enable invalid_ttl.
524 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
525 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
526
527 # Become slave, which should disable everything except port status.
528 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
529 check_async 4 OFPPR_ADD OFPPR_DELETE
530
531 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
532 ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
533 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
534
535 # Set controller ID 123.
536 ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
537 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
538
539 # Restore controller ID 0.
540 ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
541
542 # Become master.
543 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
544 check_async 7 OFPR_ACTION OFPPR_ADD
545
546 ovs-appctl -t ovs-ofctl exit
547 OVS_VSWITCHD_STOP
548 AT_CLEANUP
549
550 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
551 dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
552 dnl controllers despite the spec) as meaning a packet that was generated
553 dnl by the controller.
554 AT_SETUP([ofproto - packet-out from controller])
555 OVS_VSWITCHD_START
556
557 # Start a monitor listening for packet-ins.
558 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
559 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
560 ovs-appctl -t ovs-ofctl ofctl/barrier
561 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
562 AT_CAPTURE_FILE([monitor.log])
563
564 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
565 AT_CHECK([ovs-ofctl packet-out br0 none controller '0001020304050010203040501234'])
566 AT_CHECK([ovs-ofctl packet-out br0 65533 controller '0001020304050010203040505678'])
567
568 # Stop the monitor and check its output.
569 ovs-appctl -t ovs-ofctl ofctl/barrier
570 ovs-appctl -t ovs-ofctl exit
571
572 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
573 OFPT_PACKET_IN: total_len=14 in_port=NONE (via action) data_len=14 (unbuffered)
574 priority:0,tunnel:0,in_port:0000,tci(0) mac(00:10:20:30:40:50->00:01:02:03:04:05) type:1234 proto:0 tos:0 ttl:0 ip(0.0.0.0->0.0.0.0)
575 OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
576 priority:0,tunnel:0,in_port:0000,tci(0) mac(00:10:20:30:40:50->00:01:02:03:04:05) type:5678 proto:0 tos:0 ttl:0 ip(0.0.0.0->0.0.0.0)
577 OFPT_BARRIER_REPLY:
578 ])
579
580 OVS_VSWITCHD_STOP
581 AT_CLEANUP