ofproto: Add support for OF1.3 port description multipart message.
[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 -vANY:ANY:WARN 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 -vANY:ANY:WARN 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 -vANY:ANY:WARN 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 -vANY:ANY:WARN 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 -vANY:ANY:WARN mod-port br0 br0 $command])
76     AT_CHECK([ovs-ofctl -vANY:ANY:WARN 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 255; 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) > expout
238 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
239 # Change the configuration.
240 AT_CHECK(
241   [ovs-vsctl \
242      -- --id=@t0 create Flow_Table name=main \
243      -- --id=@t1 create Flow_Table flow-limit=1024 \
244      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
245    | perl $srcdir/uuidfilt.pl],
246   [0], [<0>
247 <1>
248 ])
249 # Check that the configuration was updated.
250 mv expout orig-expout
251 (echo "OFPST_TABLE reply (xid=0x1): 255 tables
252   0: main    : wild=0x3fffff, max=1000000, active=0
253                lookup=0, matched=0
254   1: table1  : wild=0x3fffff, max=  1024, active=0
255                lookup=0, matched=0"
256  tail -n +6 orig-expout) > expout
257 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
258 OVS_VSWITCHD_STOP
259 AT_CLEANUP
260
261 AT_SETUP([ofproto - hard limits on flow table size])
262 OVS_VSWITCHD_START
263 # Configure a maximum of 4 flows.
264 AT_CHECK(
265   [ovs-vsctl \
266      -- --id=@t0 create Flow_Table flow-limit=4 \
267      -- set bridge br0 flow_tables:0=@t0 \
268    | perl $srcdir/uuidfilt.pl],
269   [0], [<0>
270 ])
271 # Add 4 flows.
272 for in_port in 1 2 3 4; do
273     ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
274 done
275 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
276  in_port=1 actions=drop
277  in_port=2 actions=drop
278  in_port=3 actions=drop
279  in_port=4 actions=drop
280 NXST_FLOW reply:
281 ])
282 # Adding another flow will be refused.
283 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
284 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
285   [OFPT_ERROR: OFPFMFC_ALL_TABLES_FULL
286 ])
287 # Also a mod-flow that would add a flow will be refused.
288 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
289 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
290   [OFPT_ERROR: OFPFMFC_ALL_TABLES_FULL
291 ])
292 # Replacing or modifying an existing flow is allowed.
293 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
294 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
295 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
296  in_port=1 actions=drop
297  in_port=2 actions=drop
298  in_port=3 actions=output:1
299  in_port=4 actions=NORMAL
300 NXST_FLOW reply:
301 ])
302 OVS_VSWITCHD_STOP
303 AT_CLEANUP
304
305 AT_SETUP([ofproto - eviction upon table overflow])
306 OVS_VSWITCHD_START
307 # Configure a maximum of 4 flows.
308 AT_CHECK(
309   [ovs-vsctl \
310      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
311      -- set bridge br0 flow_tables:0=@t0 \
312    | perl $srcdir/uuidfilt.pl],
313   [0], [<0>
314 ])
315 # Add 4 flows.
316 for in_port in 4 3 2 1; do
317     ovs-ofctl add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
318 done
319 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
320  idle_timeout=10, in_port=1 actions=drop
321  idle_timeout=20, in_port=2 actions=drop
322  idle_timeout=30, in_port=3 actions=drop
323  idle_timeout=40, in_port=4 actions=drop
324 NXST_FLOW reply:
325 ])
326 # Adding another flow will cause the one that expires soonest to be evicted.
327 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
328 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
329  idle_timeout=20, in_port=2 actions=drop
330  idle_timeout=30, in_port=3 actions=drop
331  idle_timeout=40, in_port=4 actions=drop
332  in_port=5 actions=drop
333 NXST_FLOW reply:
334 ])
335 # A mod-flow that adds a flow also causes eviction, but replacing or
336 # modifying an existing flow doesn't.
337 AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
338 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
339 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
340 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
341  idle_timeout=30, in_port=3 actions=output:1
342  in_port=4 actions=NORMAL
343  in_port=5 actions=drop
344  in_port=6 actions=drop
345 NXST_FLOW reply:
346 ])
347 # Flows with no timeouts at all cannot be evicted.
348 AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
349 AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
350 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
351   [OFPT_ERROR: OFPFMFC_ALL_TABLES_FULL
352 ])
353 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
354  in_port=4 actions=NORMAL
355  in_port=5 actions=drop
356  in_port=6 actions=drop
357  in_port=7 actions=NORMAL
358 NXST_FLOW reply:
359 ])
360 OVS_VSWITCHD_STOP
361 AT_CLEANUP
362
363 AT_SETUP([ofproto - eviction upon table overflow, with fairness])
364 OVS_VSWITCHD_START
365 # Configure a maximum of 4 flows.
366 AT_CHECK(
367   [ovs-vsctl \
368      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
369                                    overflow-policy=evict \
370                                    groups='"NXM_OF_IN_PORT[[]]"' \
371      -- set bridge br0 flow_tables:0=@t0 \
372    | perl $srcdir/uuidfilt.pl],
373   [0], [<0>
374 ])
375 # Add 4 flows.
376 ovs-ofctl add-flows br0 - <<EOF
377 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
378 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
379 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
380 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
381 EOF
382 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
383  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
384  idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
385  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
386  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
387 NXST_FLOW reply:
388 ])
389 # Adding another flow will cause the one that expires soonest within
390 # the largest group (those with in_port=1) to be evicted.  In this
391 # case this is not the same as the one that expires soonest overall
392 # (which is what makes the test interesting):
393 AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
394 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
395  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
396  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
397  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
398  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
399 NXST_FLOW reply:
400 ])
401 # Enlarge the flow limit, change the eviction policy back to strictly
402 # based on expiration, and and add some flows.
403 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
404 ovs-ofctl add-flows br0 - <<EOF
405 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
406 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
407 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
408 EOF
409 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
410  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
411  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
412  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
413  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
414  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
415  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
416  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
417 NXST_FLOW reply:
418 ])
419 # Adding another flow will cause the one that expires soonest overall
420 # to be evicted.
421 AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
422 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
423  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
424  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
425  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
426  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
427  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
428  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
429  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
430 NXST_FLOW reply:
431 ])
432 # Reducing the flow limit also causes the flows that expire soonest
433 # overall to be evicted.
434 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
435 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
436  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
437  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
438  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
439  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
440 NXST_FLOW reply:
441 ])
442 OVS_VSWITCHD_STOP
443 AT_CLEANUP
444
445 AT_SETUP([ofproto - asynchronous message control])
446 OVS_VSWITCHD_START
447 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
448 check_async () {
449     printf '\n\n--- check_async %d ---\n\n\n' $1
450     shift
451
452     ovs-appctl -t ovs-ofctl ofctl/barrier
453     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
454     : > expout
455
456     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
457     ovs-ofctl -v packet-out br0 none controller '0001020304050010203040501234'
458     if test X"$1" = X"OFPR_ACTION"; then shift;
459         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=NONE (via action) data_len=14 (unbuffered)
460 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)"
461     fi
462
463     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
464     ovs-ofctl -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
465     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
466         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=NONE (via no_match) data_len=14 (unbuffered)
467 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)"
468     fi
469
470     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
471     ovs-ofctl packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
472     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
473         echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=NONE (via invalid_ttl) data_len=76 (unbuffered)
474 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"
475     fi
476
477     # OFPT_PORT_STATUS, OFPPR_ADD
478     ovs-vsctl add-port br0 test -- set Interface test type=dummy
479     if test X"$1" = X"OFPPR_ADD"; then shift;
480         echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
481      config:     PORT_DOWN
482      state:      LINK_DOWN
483      speed: 100 Mbps now, 100 Mbps max"
484     fi
485
486     # OFPT_PORT_STATUS, OFPPR_DELETE
487     ovs-vsctl del-port br0 test
488     if test X"$1" = X"OFPPR_DELETE"; then shift;
489         echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
490      config:     PORT_DOWN
491      state:      LINK_DOWN
492      speed: 100 Mbps now, 100 Mbps max"
493     fi
494
495     # OFPT_FLOW_REMOVED, OFPRR_DELETE
496     ovs-ofctl add-flow br0 send_flow_rem,actions=drop
497     ovs-ofctl --strict del-flows br0 ''
498     if test X"$1" = X"OFPRR_DELETE"; then shift;
499         echo >>expout "OFPT_FLOW_REMOVED:  reason=delete"
500     fi
501     AT_FAIL_IF([test X"$1" != X])
502
503     ovs-appctl -t ovs-ofctl ofctl/barrier
504     echo >>expout "OFPT_BARRIER_REPLY:"
505
506     AT_CHECK(
507       [[sed '
508 s/ (xid=0x[0-9a-fA-F]*)//
509 s/ *duration.*//
510 s/00:0.$/00:0x/' < monitor.log]],
511       [0], [expout])
512 }
513
514 # It's a service connection so initially there should be no async messages.
515 check_async 1
516
517 # Set miss_send_len to 128, turning on packet-ins for our service connection.
518 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
519 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
520
521 # Set miss_send_len to 128 and enable invalid_ttl.
522 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
523 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
524
525 # Become slave, which should disable everything except port status.
526 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
527 check_async 4 OFPPR_ADD OFPPR_DELETE
528
529 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
530 ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
531 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
532
533 # Set controller ID 123.
534 ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
535 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
536
537 # Restore controller ID 0.
538 ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
539
540 # Become master.
541 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
542 check_async 7 OFPR_ACTION OFPPR_ADD
543
544 ovs-appctl -t ovs-ofctl exit
545 OVS_VSWITCHD_STOP
546 AT_CLEANUP
547
548 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
549 dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
550 dnl controllers despite the spec) as meaning a packet that was generated
551 dnl by the controller.
552 AT_SETUP([ofproto - packet-out from controller])
553 OVS_VSWITCHD_START
554
555 # Start a monitor listening for packet-ins.
556 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
557 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
558 ovs-appctl -t ovs-ofctl ofctl/barrier
559 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
560 AT_CAPTURE_FILE([monitor.log])
561
562 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
563 AT_CHECK([ovs-ofctl packet-out br0 none controller '0001020304050010203040501234'])
564 AT_CHECK([ovs-ofctl packet-out br0 65533 controller '0001020304050010203040505678'])
565
566 # Stop the monitor and check its output.
567 ovs-appctl -t ovs-ofctl ofctl/barrier
568 ovs-appctl -t ovs-ofctl exit
569
570 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
571 OFPT_PACKET_IN: total_len=14 in_port=NONE (via action) data_len=14 (unbuffered)
572 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)
573 OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (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:5678 proto:0 tos:0 ttl:0 ip(0.0.0.0->0.0.0.0)
575 OFPT_BARRIER_REPLY:
576 ])
577
578 OVS_VSWITCHD_STOP
579 AT_CLEANUP