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