]> git.proxmox.com Git - mirror_ovs.git/blame - tests/ofproto.at
datapath: Fix checksum update for actions on UDP packets.
[mirror_ovs.git] / tests / ofproto.at
CommitLineData
a2cb9dfd
BP
1AT_BANNER([ofproto])
2
a2cb9dfd 3AT_SETUP([ofproto - echo request])
023e1e0a 4OVS_VSWITCHD_START
a2cb9dfd 5AT_CHECK([ovs-ofctl -vANY:ANY:WARN probe br0])
023e1e0a 6OVS_VSWITCHD_STOP
a2cb9dfd
BP
7AT_CLEANUP
8
9AT_SETUP([ofproto - feature request, config request])
023e1e0a 10OVS_VSWITCHD_START
a2cb9dfd 11AT_CHECK([ovs-ofctl -vANY:ANY:WARN show br0], [0], [stdout])
640c7c94 12AT_CHECK([STRIP_XIDS stdout], [0], [dnl
9e1fd49b 13OFPT_FEATURES_REPLY: dpid:fedcba9876543210
0697b5c3 14n_tables:255, n_buffers:256
9e1fd49b
BP
15capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
16actions: 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
0ab14c8e
BP
17 LOCAL(br0): addr:aa:55:aa:55:00:00
18 config: PORT_DOWN
19 state: LINK_DOWN
9e1fd49b 20 speed: 100 Mbps now, 100 Mbps max
3b62feba 21OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
a2cb9dfd 22])
023e1e0a 23OVS_VSWITCHD_STOP
a2cb9dfd
BP
24AT_CLEANUP
25
eaa6eb2a
BP
26dnl This is really bare-bones.
27dnl It at least checks request and reply serialization and deserialization.
28AT_SETUP([ofproto - port stats])
023e1e0a 29OVS_VSWITCHD_START
eaa6eb2a
BP
30AT_CHECK([ovs-ofctl -vANY:ANY:WARN dump-ports br0], [0], [stdout])
31AT_CHECK([STRIP_XIDS stdout], [0], [dnl
32OFPST_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])
023e1e0a 36OVS_VSWITCHD_STOP
eaa6eb2a
BP
37AT_CLEANUP
38
39dnl This is really bare-bones.
40dnl It at least checks request and reply serialization and deserialization.
41AT_SETUP([ofproto - queue stats])
023e1e0a 42OVS_VSWITCHD_START
eaa6eb2a
BP
43AT_CHECK([ovs-ofctl -vANY:ANY:WARN queue-stats br0], [0], [stdout])
44AT_CHECK([STRIP_XIDS stdout], [0], [dnl
45OFPST_QUEUE reply: 0 queues
46])
023e1e0a 47OVS_VSWITCHD_STOP
eaa6eb2a
BP
48AT_CLEANUP
49
a2cb9dfd 50AT_SETUP([ofproto - mod-port])
023e1e0a 51OVS_VSWITCHD_START
a2cb9dfd
BP
52for command_config_state in \
53 'up 0 0' \
0ab14c8e
BP
54 'noflood NO_FLOOD 0' \
55 'down PORT_DOWN,NO_FLOOD LINK_DOWN' \
56 'flood PORT_DOWN LINK_DOWN'
a2cb9dfd
BP
57do
58 set $command_config_state
0ab14c8e 59 command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
a2cb9dfd
BP
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])
640c7c94 62 AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
9e1fd49b 63OFPT_FEATURES_REPLY: dpid:fedcba9876543210
0697b5c3 64n_tables:255, n_buffers:256
9e1fd49b
BP
65capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
66actions: 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
0ab14c8e
BP
67 LOCAL(br0): addr:aa:55:aa:55:00:00
68 config: $config
69 state: $state
9e1fd49b 70 speed: 100 Mbps now, 100 Mbps max
3b62feba 71OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
a2cb9dfd
BP
72])
73done
023e1e0a 74OVS_VSWITCHD_STOP
a2cb9dfd 75AT_CLEANUP
640c7c94 76
c168dcc8 77AT_SETUP([ofproto - basic flow_mod commands (NXM)])
023e1e0a 78OVS_VSWITCHD_START
ef0ce8ae 79AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
640c7c94 80])
70315176 81AT_CHECK([echo 'in_port=1,actions=0' | ovs-ofctl add-flows br0 -])
640c7c94 82AT_CHECK([ovs-ofctl add-flow br0 in_port=0,actions=1])
0697b5c3 83AT_CHECK([ovs-ofctl -F nxm add-flow br0 table=1,in_port=3,actions=2])
ef0ce8ae
BP
84AT_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
0721c073 88NXST_FLOW reply:
640c7c94 89])
0697b5c3 90AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
c168dcc8
BP
91NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
92])
640c7c94 93AT_CHECK([ovs-ofctl del-flows br0])
ef0ce8ae 94AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
640c7c94 95])
023e1e0a 96OVS_VSWITCHD_STOP
640c7c94 97AT_CLEANUP
c168dcc8
BP
98
99AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.0)])
023e1e0a 100OVS_VSWITCHD_START
ef0ce8ae 101AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
c168dcc8
BP
102])
103AT_CHECK([echo 'in_port=1,actions=0' | ovs-ofctl -F openflow10 add-flows br0 -])
104AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 in_port=0,actions=1])
0697b5c3 105AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 table=1,in_port=3,actions=2])
ef0ce8ae
BP
106AT_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
c168dcc8
BP
110OFPST_FLOW reply:
111])
0697b5c3 112AT_CHECK([ovs-ofctl -F openflow10 dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
c168dcc8
BP
113OFPST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
114])
115AT_CHECK([ovs-ofctl -F openflow10 del-flows br0])
ef0ce8ae 116AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
c168dcc8 117])
023e1e0a 118OVS_VSWITCHD_STOP
c168dcc8 119AT_CLEANUP
e729e793
JP
120
121AT_SETUP([ofproto - dump flows with cookie])
122OVS_VSWITCHD_START
123AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=0])
124AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=0])
125AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=0])
ef0ce8ae
BP
126AT_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
e729e793
JP
130NXST_FLOW reply:
131])
132AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
133NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
134])
ef0ce8ae
BP
135AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3 | ofctl_strip | sort], [0], [dnl
136 cookie=0x3, in_port=3 actions=output:0
e729e793
JP
137NXST_FLOW reply:
138])
139AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3 | STRIP_XIDS], [0], [dnl
140NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=1
141])
142OVS_VSWITCHD_STOP
143AT_CLEANUP
144
145AT_SETUP([ofproto - dump flows with cookie mask])
146OVS_VSWITCHD_START
147AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=0])
148AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=0])
149AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=0])
ef0ce8ae
BP
150AT_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
e729e793
JP
154NXST_FLOW reply:
155])
156AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
157NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
158])
ef0ce8ae
BP
159AT_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
e729e793
JP
162NXST_FLOW reply:
163])
164AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/0x1 | STRIP_XIDS], [0], [dnl
165NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
166])
167OVS_VSWITCHD_STOP
168AT_CLEANUP
169
170AT_SETUP([ofproto - del flows with cookie])
171OVS_VSWITCHD_START
172AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=0])
173AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=0])
174AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=0])
ef0ce8ae
BP
175AT_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
e729e793
JP
179NXST_FLOW reply:
180])
80d5aefd 181
e729e793 182AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3])
ef0ce8ae
BP
183AT_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
e729e793
JP
186NXST_FLOW reply:
187])
188OVS_VSWITCHD_STOP
189AT_CLEANUP
190
191AT_SETUP([ofproto - del flows with cookie mask])
192OVS_VSWITCHD_START
193AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=0])
194AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=0])
195AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=0])
ef0ce8ae
BP
196AT_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
e729e793
JP
200NXST_FLOW reply:
201])
202AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/0x1])
ef0ce8ae
BP
203AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
204 cookie=0x2, in_port=2 actions=output:0
e729e793
JP
205NXST_FLOW reply:
206])
207OVS_VSWITCHD_STOP
208AT_CLEANUP
254750ce
BP
209
210AT_SETUP([ofproto - flow table configuration])
211OVS_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
223AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
224# Change the configuration.
225AT_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.
235mv 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
242AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
243OVS_VSWITCHD_STOP
244AT_CLEANUP
245
246AT_SETUP([ofproto - hard limits on flow table size])
247OVS_VSWITCHD_START
248# Configure a maximum of 4 flows.
249AT_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.
257for in_port in 1 2 3 4; do
258 ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
259done
260AT_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
265NXST_FLOW reply:
266])
267# Adding another flow will be refused.
268AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
27527aa0
BP
269AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
270 [OFPT_ERROR: OFPFMFC_ALL_TABLES_FULL
254750ce
BP
271])
272# Also a mod-flow that would add a flow will be refused.
273AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
27527aa0
BP
274AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
275 [OFPT_ERROR: OFPFMFC_ALL_TABLES_FULL
254750ce
BP
276])
277# Replacing or modifying an existing flow is allowed.
278AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
279AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
280AT_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
285NXST_FLOW reply:
286])
287OVS_VSWITCHD_STOP
288AT_CLEANUP
289
290AT_SETUP([ofproto - eviction upon table overflow])
291OVS_VSWITCHD_START
292# Configure a maximum of 4 flows.
293AT_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.
301for 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
303done
304AT_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
309NXST_FLOW reply:
310])
311# Adding another flow will cause the one that expires soonest to be evicted.
312AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
313AT_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
318NXST_FLOW reply:
319])
320# A mod-flow that adds a flow also causes eviction, but replacing or
321# modifying an existing flow doesn't.
322AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
323AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
324AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
325AT_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
330NXST_FLOW reply:
331])
332# Flows with no timeouts at all cannot be evicted.
333AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
334AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
27527aa0
BP
335AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
336 [OFPT_ERROR: OFPFMFC_ALL_TABLES_FULL
254750ce
BP
337])
338AT_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
343NXST_FLOW reply:
344])
345OVS_VSWITCHD_STOP
346AT_CLEANUP
347
348AT_SETUP([ofproto - eviction upon table overflow, with fairness])
349OVS_VSWITCHD_START
350# Configure a maximum of 4 flows.
351AT_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.
361ovs-ofctl add-flows br0 - <<EOF
362idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
363idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
364idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
365idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
366EOF
367AT_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
372NXST_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):
378AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
379AT_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
384NXST_FLOW reply:
385])
386# Enlarge the flow limit, change the eviction policy back to strictly
387# based on expiration, and and add some flows.
388AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
389ovs-ofctl add-flows br0 - <<EOF
390idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
391idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
392idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
393EOF
394AT_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
402NXST_FLOW reply:
403])
404# Adding another flow will cause the one that expires soonest overall
405# to be evicted.
406AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
407AT_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
415NXST_FLOW reply:
416])
417# Reducing the flow limit also causes the flows that expire soonest
418# overall to be evicted.
419AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
420AT_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
425NXST_FLOW reply:
426])
427OVS_VSWITCHD_STOP
428AT_CLEANUP
80d5aefd
BP
429
430AT_SETUP([ofproto - asynchronous message control])
431OVS_VSWITCHD_START
432AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
433check_async () {
434 printf '\n\n--- check_async %d ---\n\n\n' $1
435 shift
436
437 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
438 : > expout
439
a7349929 440 # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
80d5aefd
BP
441 ovs-ofctl -v packet-out br0 none controller '0001020304050010203040501234'
442 if test X"$1" = X"OFPR_ACTION"; then shift;
443 echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=NONE (via action) data_len=14 (unbuffered)
444priority: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)"
445 fi
446
a7349929
BP
447 # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
448 ovs-ofctl -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
449 if test X"$1" = X"OFPR_NO_MATCH"; then shift;
450 echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=NONE (via no_match) data_len=14 (unbuffered)
451priority: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)"
452 fi
453
454 # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
80d5aefd
BP
455 ovs-ofctl packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
456 if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
457 echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=NONE (via invalid_ttl) data_len=76 (unbuffered)
458priority: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"
459 fi
460
461 # OFPT_PORT_STATUS, OFPPR_ADD
462 ovs-vsctl add-port br0 test -- set Interface test type=dummy
463 if test X"$1" = X"OFPPR_ADD"; then shift;
464 echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
465 config: PORT_DOWN
9e1fd49b
BP
466 state: LINK_DOWN
467 speed: 100 Mbps now, 100 Mbps max"
80d5aefd
BP
468 fi
469
470 # OFPT_PORT_STATUS, OFPPR_DELETE
471 ovs-vsctl del-port br0 test
472 if test X"$1" = X"OFPPR_DELETE"; then shift;
473 echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
474 config: PORT_DOWN
9e1fd49b
BP
475 state: LINK_DOWN
476 speed: 100 Mbps now, 100 Mbps max"
80d5aefd
BP
477 fi
478
479 # OFPT_FLOW_REMOVED, OFPRR_DELETE
480 ovs-ofctl add-flow br0 send_flow_rem,actions=drop
481 ovs-ofctl --strict del-flows br0 ''
482 if test X"$1" = X"OFPRR_DELETE"; then shift;
483 echo >>expout "OFPT_FLOW_REMOVED: reason=delete"
484 fi
485 AT_FAIL_IF([test X"$1" != X])
486
487 ovs-appctl -t ovs-ofctl ofctl/barrier
488 echo >>expout "send: OFPT_BARRIER_REQUEST:
489OFPT_BARRIER_REPLY:"
490
491 AT_CHECK(
492 [[sed '
493s/ (xid=0x[0-9a-fA-F]*)//
494s/ *duration.*//
495s/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.
500check_async 1
501
502# Set miss_send_len to 128, turning on packet-outs for our service connection.
503ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
504check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
505
506# Set miss_send_len to 128 and enable invalid_ttl.
507ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
508check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
509
510# Become slave, which should disable everything except port status.
511ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
512check_async 4 OFPPR_ADD OFPPR_DELETE
513
514# Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
515ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
516check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
517
a7349929
BP
518# Set controller ID 123.
519ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
520check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
521
522# Restore controller ID 0.
523ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
524
80d5aefd
BP
525# Become master.
526ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
a7349929 527check_async 7 OFPR_ACTION OFPPR_ADD
80d5aefd
BP
528
529ovs-appctl -t ovs-ofctl exit
530AT_CLEANUP