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