]> git.proxmox.com Git - ovs.git/blame - tests/ofproto.at
ofproto: Fix typo in macro name.
[ovs.git] / tests / ofproto.at
CommitLineData
a2cb9dfd
BP
1AT_BANNER([ofproto])
2
a2cb9dfd 3AT_SETUP([ofproto - echo request])
023e1e0a 4OVS_VSWITCHD_START
ea523221 5AT_CHECK([ovs-ofctl -vwarn probe br0])
023e1e0a 6OVS_VSWITCHD_STOP
a2cb9dfd
BP
7AT_CLEANUP
8
9AT_SETUP([ofproto - feature request, config request])
023e1e0a 10OVS_VSWITCHD_START
ea523221 11AT_CHECK([ovs-ofctl -vwarn 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
ea523221 30AT_CHECK([ovs-ofctl -vwarn dump-ports br0], [0], [stdout])
eaa6eb2a
BP
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
2be393ed
JP
39dnl This is really bare-bones.
40dnl It at least checks request and reply serialization and deserialization.
41AT_SETUP([ofproto - port-desc stats])
42OVS_VSWITCHD_START
43AT_CHECK([ovs-ofctl -vwarn dump-ports-desc br0], [0], [stdout])
44AT_CHECK([STRIP_XIDS stdout], [0], [dnl
45OFPST_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])
51OVS_VSWITCHD_STOP
52AT_CLEANUP
53
eaa6eb2a
BP
54dnl This is really bare-bones.
55dnl It at least checks request and reply serialization and deserialization.
56AT_SETUP([ofproto - queue stats])
023e1e0a 57OVS_VSWITCHD_START
ea523221 58AT_CHECK([ovs-ofctl -vwarn queue-stats br0], [0], [stdout])
eaa6eb2a
BP
59AT_CHECK([STRIP_XIDS stdout], [0], [dnl
60OFPST_QUEUE reply: 0 queues
61])
0414d158 62AT_CHECK([ovs-ofctl -vwarn queue-stats br0 ALL 5], [0],
53514387
SH
63 [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_QUEUE
64OFPST_QUEUE request (xid=0x2):port=ALL queue=5
0414d158
BP
65])
66AT_CHECK([ovs-ofctl -vwarn queue-stats br0 10], [0],
53514387
SH
67 [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_PORT
68OFPST_QUEUE request (xid=0x2):port=10 queue=ALL
0414d158 69])
023e1e0a 70OVS_VSWITCHD_STOP
eaa6eb2a
BP
71AT_CLEANUP
72
a2cb9dfd 73AT_SETUP([ofproto - mod-port])
023e1e0a 74OVS_VSWITCHD_START
a2cb9dfd
BP
75for command_config_state in \
76 'up 0 0' \
0ab14c8e
BP
77 'noflood NO_FLOOD 0' \
78 'down PORT_DOWN,NO_FLOOD LINK_DOWN' \
28124950
BP
79 'flood PORT_DOWN LINK_DOWN' \
80 'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
81 'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
82 'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
83 'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
84 'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
85 'up NO_RECV 0' \
86 'receive 0 0'
a2cb9dfd
BP
87do
88 set $command_config_state
0ab14c8e 89 command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
ea523221
BP
90 AT_CHECK([ovs-ofctl -vwarn mod-port br0 br0 $command])
91 AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
640c7c94 92 AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
9e1fd49b 93OFPT_FEATURES_REPLY: dpid:fedcba9876543210
0697b5c3 94n_tables:255, n_buffers:256
9e1fd49b
BP
95capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
96actions: 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
97 LOCAL(br0): addr:aa:55:aa:55:00:00
98 config: $config
99 state: $state
9e1fd49b 100 speed: 100 Mbps now, 100 Mbps max
3b62feba 101OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
a2cb9dfd
BP
102])
103done
023e1e0a 104OVS_VSWITCHD_STOP
a2cb9dfd 105AT_CLEANUP
640c7c94 106
c168dcc8 107AT_SETUP([ofproto - basic flow_mod commands (NXM)])
023e1e0a 108OVS_VSWITCHD_START
ef0ce8ae 109AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
640c7c94 110])
c6100d92
BP
111AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl add-flows br0 -])
112AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=2])
113AT_CHECK([ovs-ofctl -F nxm add-flow br0 table=1,in_port=4,actions=3])
ef0ce8ae 114AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
115 in_port=1 actions=output:2
116 in_port=2 actions=output:1
117 table=1, in_port=4 actions=output:3
0721c073 118NXST_FLOW reply:
640c7c94 119])
0697b5c3 120AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
c168dcc8
BP
121NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
122])
640c7c94 123AT_CHECK([ovs-ofctl del-flows br0])
ef0ce8ae 124AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
640c7c94 125])
023e1e0a 126OVS_VSWITCHD_STOP
640c7c94 127AT_CLEANUP
c168dcc8
BP
128
129AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.0)])
023e1e0a 130OVS_VSWITCHD_START
ef0ce8ae 131AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
c168dcc8 132])
c6100d92
BP
133AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -F openflow10 add-flows br0 -])
134AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 in_port=1,actions=2])
135AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 table=1,in_port=4,actions=3])
ef0ce8ae 136AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
137 in_port=1 actions=output:2
138 in_port=2 actions=output:1
139 table=1, in_port=4 actions=output:3
c168dcc8
BP
140OFPST_FLOW reply:
141])
0697b5c3 142AT_CHECK([ovs-ofctl -F openflow10 dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
c168dcc8
BP
143OFPST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
144])
145AT_CHECK([ovs-ofctl -F openflow10 del-flows br0])
ef0ce8ae 146AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
c168dcc8 147])
023e1e0a 148OVS_VSWITCHD_STOP
c168dcc8 149AT_CLEANUP
e729e793 150
f5c45121
SH
151AT_SETUP([ofproto - set-field flow_mod commands (NXM)])
152OVS_VSWITCHD_START
153AT_CHECK([ovs-ofctl add-flow br0 ipv6,table=1,in_port=3,actions=drop])
154AT_CHECK([ovs-ofctl add-flow br0 ipv6,table=1,in_port=3,actions=set_field:fe80:0123:4567:890a:a6ba:dbff:fefe:59fa-\>ipv6_src])
155AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
156 table=1, ipv6,in_port=3 actions=load:0xa6badbfffefe59fa->NXM_NX_IPV6_SRC[[0..63]],load:0xfe8001234567890a->NXM_NX_IPV6_SRC[[64..127]]
157NXST_FLOW reply:
158])
159OVS_VSWITCHD_STOP
160AT_CLEANUP
161
e729e793
JP
162AT_SETUP([ofproto - dump flows with cookie])
163OVS_VSWITCHD_START
c6100d92
BP
164AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
165AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
166AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
ef0ce8ae 167AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
168 cookie=0x1, in_port=1 actions=output:1
169 cookie=0x2, in_port=2 actions=output:1
170 cookie=0x3, in_port=3 actions=output:1
e729e793
JP
171NXST_FLOW reply:
172])
173AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
174NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
175])
623e1caf 176AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/-1 | ofctl_strip | sort], [0], [dnl
c6100d92 177 cookie=0x3, in_port=3 actions=output:1
e729e793
JP
178NXST_FLOW reply:
179])
623e1caf 180AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/-1 | STRIP_XIDS], [0], [dnl
e729e793
JP
181NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=1
182])
183OVS_VSWITCHD_STOP
184AT_CLEANUP
185
186AT_SETUP([ofproto - dump flows with cookie mask])
187OVS_VSWITCHD_START
c6100d92
BP
188AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
189AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
190AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
ef0ce8ae 191AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
192 cookie=0x1, in_port=1 actions=output:1
193 cookie=0x2, in_port=2 actions=output:1
194 cookie=0x3, in_port=3 actions=output:1
e729e793
JP
195NXST_FLOW reply:
196])
197AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
198NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
199])
ef0ce8ae 200AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/0x1 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
201 cookie=0x1, in_port=1 actions=output:1
202 cookie=0x3, in_port=3 actions=output:1
e729e793
JP
203NXST_FLOW reply:
204])
205AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/0x1 | STRIP_XIDS], [0], [dnl
206NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
207])
208OVS_VSWITCHD_STOP
209AT_CLEANUP
210
623e1caf
JP
211AT_SETUP([ofproto - mod flow with cookie change (OpenFlow 1.0)])
212OVS_VSWITCHD_START
c6100d92 213AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 cookie=0x1,in_port=1,actions=1])
623e1caf 214AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 215 cookie=0x1, in_port=1 actions=output:1
623e1caf
JP
216OFPST_FLOW reply:
217])
218
c6100d92 219AT_CHECK([ovs-ofctl -F openflow10 mod-flows br0 cookie=0x2,in_port=1,actions=1])
623e1caf 220AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 221 cookie=0x2, in_port=1 actions=output:1
623e1caf
JP
222OFPST_FLOW reply:
223])
224OVS_VSWITCHD_STOP
225AT_CLEANUP
226
227AT_SETUP([ofproto - mod flow with cookie change (NXM)])
228OVS_VSWITCHD_START
c6100d92 229AT_CHECK([ovs-ofctl -F nxm add-flow br0 cookie=0x1,in_port=1,actions=1])
623e1caf 230AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 231 cookie=0x1, in_port=1 actions=output:1
623e1caf
JP
232NXST_FLOW reply:
233])
234
c6100d92 235AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x2,in_port=1,actions=1])
623e1caf 236AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 237 cookie=0x2, in_port=1 actions=output:1
623e1caf
JP
238NXST_FLOW reply:
239])
240OVS_VSWITCHD_STOP
241AT_CLEANUP
242
243AT_SETUP([ofproto - mod flows based on cookie mask])
244OVS_VSWITCHD_START
c6100d92
BP
245AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
246AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
247AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
623e1caf 248AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
249 cookie=0x1, in_port=1 actions=output:1
250 cookie=0x1, in_port=2 actions=output:1
251 cookie=0x2, in_port=3 actions=output:1
623e1caf
JP
252NXST_FLOW reply:
253])
254
255AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x1/0xff,actions=4])
256AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
257 cookie=0x1, in_port=1 actions=output:4
258 cookie=0x1, in_port=2 actions=output:4
c6100d92 259 cookie=0x2, in_port=3 actions=output:1
623e1caf
JP
260NXST_FLOW reply:
261])
262OVS_VSWITCHD_STOP
263AT_CLEANUP
264
265AT_SETUP([ofproto - mod flows based on cookie mask with cookie change])
266OVS_VSWITCHD_START
c6100d92
BP
267AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
268AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
269AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
623e1caf 270AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
271 cookie=0x1, in_port=1 actions=output:1
272 cookie=0x1, in_port=2 actions=output:1
273 cookie=0x2, in_port=3 actions=output:1
623e1caf
JP
274NXST_FLOW reply:
275])
276
277AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/-1,cookie=4,actions=4])
278AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 279 cookie=0x2, in_port=3 actions=output:1
623e1caf
JP
280 cookie=0x4, in_port=1 actions=output:4
281 cookie=0x4, in_port=2 actions=output:4
282NXST_FLOW reply:
283])
284OVS_VSWITCHD_STOP
285AT_CLEANUP
286
287AT_SETUP([ofproto - mod flow with cookie miss (mask==0)])
288OVS_VSWITCHD_START
c6100d92 289AT_CHECK([ovs-ofctl -F nxm mod-flows br0 in_port=1,actions=1])
623e1caf 290AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 291 in_port=1 actions=output:1
623e1caf
JP
292NXST_FLOW reply:
293])
294OVS_VSWITCHD_STOP
295AT_CLEANUP
296
297AT_SETUP([ofproto - mod flow with cookie miss (mask!=0)])
298OVS_VSWITCHD_START
c6100d92 299AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/1,in_port=1,actions=1])
623e1caf
JP
300AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
301NXST_FLOW reply:
302])
303OVS_VSWITCHD_STOP
304AT_CLEANUP
305
306AT_SETUP([ofproto - del flows with cookies])
307OVS_VSWITCHD_START
c6100d92
BP
308AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
309AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
310AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
623e1caf 311AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
312 cookie=0x1, in_port=1 actions=output:1
313 cookie=0x2, in_port=2 actions=output:1
314 cookie=0x3, in_port=3 actions=output:1
623e1caf
JP
315NXST_FLOW reply:
316])
317
318AT_CHECK([ovs-ofctl del-flows br0])
319AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
320NXST_FLOW reply:
321])
322OVS_VSWITCHD_STOP
323AT_CLEANUP
324
325AT_SETUP([ofproto - del flows based on cookie])
e729e793 326OVS_VSWITCHD_START
c6100d92
BP
327AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
328AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
329AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
ef0ce8ae 330AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
331 cookie=0x1, in_port=1 actions=output:1
332 cookie=0x2, in_port=2 actions=output:1
333 cookie=0x3, in_port=3 actions=output:1
e729e793
JP
334NXST_FLOW reply:
335])
80d5aefd 336
623e1caf 337AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/-1])
ef0ce8ae 338AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
339 cookie=0x1, in_port=1 actions=output:1
340 cookie=0x2, in_port=2 actions=output:1
e729e793
JP
341NXST_FLOW reply:
342])
343OVS_VSWITCHD_STOP
344AT_CLEANUP
345
623e1caf 346AT_SETUP([ofproto - del flows based on cookie mask])
e729e793 347OVS_VSWITCHD_START
c6100d92
BP
348AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
349AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
350AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
ef0ce8ae 351AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
352 cookie=0x1, in_port=1 actions=output:1
353 cookie=0x2, in_port=2 actions=output:1
354 cookie=0x3, in_port=3 actions=output:1
e729e793
JP
355NXST_FLOW reply:
356])
357AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/0x1])
ef0ce8ae 358AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 359 cookie=0x2, in_port=2 actions=output:1
e729e793
JP
360NXST_FLOW reply:
361])
362OVS_VSWITCHD_STOP
363AT_CLEANUP
254750ce 364
c90cfeaf
SH
365AT_SETUP([ofproto - del flows based on table id])
366OVS_VSWITCHD_START
367AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
368AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
369AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
370 cookie=0x1, in_port=1 actions=output:1
371 cookie=0x2, table=1, in_port=2 actions=output:1
372NXST_FLOW reply:
373])
374AT_CHECK([ovs-ofctl del-flows br0 table=0])
375AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
376 cookie=0x2, table=1, in_port=2 actions=output:1
377NXST_FLOW reply:
378])
379AT_CHECK([ovs-ofctl del-flows br0 table=1])
380AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
381NXST_FLOW reply:
382])
383AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
384AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
385AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
386 cookie=0x1, in_port=1 actions=output:1
387 cookie=0x2, table=1, in_port=2 actions=output:1
388NXST_FLOW reply:
389])
390AT_CHECK([ovs-ofctl del-flows br0])
391AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
392NXST_FLOW reply:
393])
394OVS_VSWITCHD_STOP
395AT_CLEANUP
396
254750ce
BP
397AT_SETUP([ofproto - flow table configuration])
398OVS_VSWITCHD_START
399# Check the default configuration.
53514387 400(echo "OFPST_TABLE reply (xid=0x2): 255 tables
254750ce
BP
401 0: classifier: wild=0x3fffff, max=1000000, active=0
402 lookup=0, matched=0"
403 x=1
c57b2226 404 while test $x -lt 254; do
254750ce
BP
405 printf " %d: %-8s: wild=0x3fffff, max=1000000, active=0
406 lookup=0, matched=0
407" $x table$x
408 x=`expr $x + 1`
c57b2226
BP
409 done
410 echo " 254: table254: wild=0x3fffff, max=1000000, active=2
411 lookup=0, matched=0") > expout
254750ce
BP
412AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
413# Change the configuration.
414AT_CHECK(
415 [ovs-vsctl \
416 -- --id=@t0 create Flow_Table name=main \
417 -- --id=@t1 create Flow_Table flow-limit=1024 \
418 -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
419 | perl $srcdir/uuidfilt.pl],
420 [0], [<0>
421<1>
422])
423# Check that the configuration was updated.
424mv expout orig-expout
53514387 425(echo "OFPST_TABLE reply (xid=0x2): 255 tables
254750ce
BP
426 0: main : wild=0x3fffff, max=1000000, active=0
427 lookup=0, matched=0
428 1: table1 : wild=0x3fffff, max= 1024, active=0
429 lookup=0, matched=0"
430 tail -n +6 orig-expout) > expout
431AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
432OVS_VSWITCHD_STOP
433AT_CLEANUP
434
435AT_SETUP([ofproto - hard limits on flow table size])
436OVS_VSWITCHD_START
437# Configure a maximum of 4 flows.
438AT_CHECK(
439 [ovs-vsctl \
440 -- --id=@t0 create Flow_Table flow-limit=4 \
441 -- set bridge br0 flow_tables:0=@t0 \
442 | perl $srcdir/uuidfilt.pl],
443 [0], [<0>
444])
445# Add 4 flows.
446for in_port in 1 2 3 4; do
447 ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
448done
449AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
450 in_port=1 actions=drop
451 in_port=2 actions=drop
452 in_port=3 actions=drop
453 in_port=4 actions=drop
454NXST_FLOW reply:
455])
456# Adding another flow will be refused.
457AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
27527aa0
BP
458AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
459 [OFPT_ERROR: OFPFMFC_ALL_TABLES_FULL
254750ce
BP
460])
461# Also a mod-flow that would add a flow will be refused.
462AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
27527aa0
BP
463AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
464 [OFPT_ERROR: OFPFMFC_ALL_TABLES_FULL
254750ce
BP
465])
466# Replacing or modifying an existing flow is allowed.
467AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
468AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
469AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
470 in_port=1 actions=drop
471 in_port=2 actions=drop
472 in_port=3 actions=output:1
473 in_port=4 actions=NORMAL
474NXST_FLOW reply:
475])
476OVS_VSWITCHD_STOP
477AT_CLEANUP
478
479AT_SETUP([ofproto - eviction upon table overflow])
480OVS_VSWITCHD_START
481# Configure a maximum of 4 flows.
482AT_CHECK(
483 [ovs-vsctl \
484 -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
485 -- set bridge br0 flow_tables:0=@t0 \
486 | perl $srcdir/uuidfilt.pl],
487 [0], [<0>
488])
489# Add 4 flows.
490for in_port in 4 3 2 1; do
491 ovs-ofctl add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
492done
493AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
494 idle_timeout=10, in_port=1 actions=drop
495 idle_timeout=20, in_port=2 actions=drop
496 idle_timeout=30, in_port=3 actions=drop
497 idle_timeout=40, in_port=4 actions=drop
254750ce
BP
498NXST_FLOW reply:
499])
500# Adding another flow will cause the one that expires soonest to be evicted.
501AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
502AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
503 idle_timeout=20, in_port=2 actions=drop
504 idle_timeout=30, in_port=3 actions=drop
505 idle_timeout=40, in_port=4 actions=drop
254750ce
BP
506 in_port=5 actions=drop
507NXST_FLOW reply:
508])
509# A mod-flow that adds a flow also causes eviction, but replacing or
510# modifying an existing flow doesn't.
511AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
512AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
513AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
514AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b 515 idle_timeout=30, in_port=3 actions=output:1
254750ce
BP
516 in_port=4 actions=NORMAL
517 in_port=5 actions=drop
518 in_port=6 actions=drop
519NXST_FLOW reply:
520])
521# Flows with no timeouts at all cannot be evicted.
522AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
523AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
27527aa0
BP
524AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
525 [OFPT_ERROR: OFPFMFC_ALL_TABLES_FULL
254750ce
BP
526])
527AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
528 in_port=4 actions=NORMAL
529 in_port=5 actions=drop
530 in_port=6 actions=drop
531 in_port=7 actions=NORMAL
532NXST_FLOW reply:
533])
534OVS_VSWITCHD_STOP
535AT_CLEANUP
536
537AT_SETUP([ofproto - eviction upon table overflow, with fairness])
538OVS_VSWITCHD_START
539# Configure a maximum of 4 flows.
540AT_CHECK(
541 [ovs-vsctl \
542 -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
543 overflow-policy=evict \
544 groups='"NXM_OF_IN_PORT[[]]"' \
545 -- set bridge br0 flow_tables:0=@t0 \
546 | perl $srcdir/uuidfilt.pl],
547 [0], [<0>
548])
549# Add 4 flows.
550ovs-ofctl add-flows br0 - <<EOF
551idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
552idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
553idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
554idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
555EOF
556AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
557 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
558 idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
559 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
560 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
254750ce
BP
561NXST_FLOW reply:
562])
563# Adding another flow will cause the one that expires soonest within
564# the largest group (those with in_port=1) to be evicted. In this
565# case this is not the same as the one that expires soonest overall
566# (which is what makes the test interesting):
567AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
568AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
569 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
570 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
571 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
254750ce
BP
572 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
573NXST_FLOW reply:
574])
575# Enlarge the flow limit, change the eviction policy back to strictly
576# based on expiration, and and add some flows.
577AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
578ovs-ofctl add-flows br0 - <<EOF
579idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
580idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
581idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
582EOF
583AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
584 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
585 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
586 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
587 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
588 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
589 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
254750ce
BP
590 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
591NXST_FLOW reply:
592])
593# Adding another flow will cause the one that expires soonest overall
594# to be evicted.
595AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
596AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
597 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
598 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
599 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
600 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
601 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
602 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
254750ce
BP
603 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
604NXST_FLOW reply:
605])
606# Reducing the flow limit also causes the flows that expire soonest
607# overall to be evicted.
608AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
609AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
610 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
611 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
612 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
254750ce
BP
613 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
614NXST_FLOW reply:
615])
616OVS_VSWITCHD_STOP
617AT_CLEANUP
80d5aefd
BP
618
619AT_SETUP([ofproto - asynchronous message control])
620OVS_VSWITCHD_START
621AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
622check_async () {
623 printf '\n\n--- check_async %d ---\n\n\n' $1
624 shift
625
6fc67c4f 626 ovs-appctl -t ovs-ofctl ofctl/barrier
80d5aefd
BP
627 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
628 : > expout
629
a7349929 630 # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
80d5aefd
BP
631 ovs-ofctl -v packet-out br0 none controller '0001020304050010203040501234'
632 if test X"$1" = X"OFPR_ACTION"; then shift;
633 echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=NONE (via action) data_len=14 (unbuffered)
296e07ac 634priority:0,metadata:0,in_port:0000,tci(0) mac(00:10:20:30:40:50->00:01:02:03:04:05) type:1234"
80d5aefd
BP
635 fi
636
a7349929
BP
637 # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
638 ovs-ofctl -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
639 if test X"$1" = X"OFPR_NO_MATCH"; then shift;
640 echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=NONE (via no_match) data_len=14 (unbuffered)
296e07ac 641priority:0,metadata:0,in_port:0000,tci(0) mac(00:10:20:30:40:50->00:01:02:03:04:05) type:1234"
a7349929
BP
642 fi
643
644 # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
80d5aefd
BP
645 ovs-ofctl packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
646 if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
647 echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=NONE (via invalid_ttl) data_len=76 (unbuffered)
296e07ac 648priority:0,metadata: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"
80d5aefd
BP
649 fi
650
651 # OFPT_PORT_STATUS, OFPPR_ADD
652 ovs-vsctl add-port br0 test -- set Interface test type=dummy
653 if test X"$1" = X"OFPPR_ADD"; then shift;
654 echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
655 config: PORT_DOWN
9e1fd49b
BP
656 state: LINK_DOWN
657 speed: 100 Mbps now, 100 Mbps max"
80d5aefd
BP
658 fi
659
660 # OFPT_PORT_STATUS, OFPPR_DELETE
661 ovs-vsctl del-port br0 test
662 if test X"$1" = X"OFPPR_DELETE"; then shift;
663 echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
664 config: PORT_DOWN
9e1fd49b
BP
665 state: LINK_DOWN
666 speed: 100 Mbps now, 100 Mbps max"
80d5aefd
BP
667 fi
668
669 # OFPT_FLOW_REMOVED, OFPRR_DELETE
670 ovs-ofctl add-flow br0 send_flow_rem,actions=drop
671 ovs-ofctl --strict del-flows br0 ''
672 if test X"$1" = X"OFPRR_DELETE"; then shift;
673 echo >>expout "OFPT_FLOW_REMOVED: reason=delete"
674 fi
675 AT_FAIL_IF([test X"$1" != X])
676
677 ovs-appctl -t ovs-ofctl ofctl/barrier
fd0aa9ea 678 echo >>expout "OFPT_BARRIER_REPLY:"
80d5aefd
BP
679
680 AT_CHECK(
681 [[sed '
682s/ (xid=0x[0-9a-fA-F]*)//
683s/ *duration.*//
684s/00:0.$/00:0x/' < monitor.log]],
685 [0], [expout])
686}
687
688# It's a service connection so initially there should be no async messages.
689check_async 1
690
99811d07 691# Set miss_send_len to 128, turning on packet-ins for our service connection.
80d5aefd
BP
692ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
693check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
694
695# Set miss_send_len to 128 and enable invalid_ttl.
696ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
697check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
698
699# Become slave, which should disable everything except port status.
700ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
701check_async 4 OFPPR_ADD OFPPR_DELETE
702
703# Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
704ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
705check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
706
a7349929
BP
707# Set controller ID 123.
708ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
709check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
710
711# Restore controller ID 0.
712ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
713
80d5aefd
BP
714# Become master.
715ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
a7349929 716check_async 7 OFPR_ACTION OFPPR_ADD
80d5aefd
BP
717
718ovs-appctl -t ovs-ofctl exit
94c33672 719OVS_VSWITCHD_STOP
80d5aefd 720AT_CLEANUP
751c7785
BP
721
722dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
723dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
724dnl controllers despite the spec) as meaning a packet that was generated
725dnl by the controller.
726AT_SETUP([ofproto - packet-out from controller])
727OVS_VSWITCHD_START
728
729# Start a monitor listening for packet-ins.
730AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
731ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
732ovs-appctl -t ovs-ofctl ofctl/barrier
733ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
734AT_CAPTURE_FILE([monitor.log])
735
736# Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
737AT_CHECK([ovs-ofctl packet-out br0 none controller '0001020304050010203040501234'])
c6100d92 738AT_CHECK([ovs-ofctl packet-out br0 controller controller '0001020304050010203040505678'])
751c7785
BP
739
740# Stop the monitor and check its output.
741ovs-appctl -t ovs-ofctl ofctl/barrier
742ovs-appctl -t ovs-ofctl exit
743
744AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
745OFPT_PACKET_IN: total_len=14 in_port=NONE (via action) data_len=14 (unbuffered)
296e07ac 746priority:0,metadata:0,in_port:0000,tci(0) mac(00:10:20:30:40:50->00:01:02:03:04:05) type:1234
751c7785 747OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
296e07ac 748priority:0,metadata:0,in_port:0000,tci(0) mac(00:10:20:30:40:50->00:01:02:03:04:05) type:5678
969fc56c
JS
749OFPT_BARRIER_REPLY:
750])
751
752OVS_VSWITCHD_STOP
753AT_CLEANUP
754
755dnl This test checks that metadata is encoded in packet_in structures,
756dnl supported by NXAST.
757AT_SETUP([ofproto - packet-out with metadata (NXM)])
758OVS_VSWITCHD_START
759
760# Start a monitor listening for packet-ins.
761AT_CHECK([ovs-ofctl -P nxm monitor br0 --detach --no-chdir --pidfile])
762ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
763ovs-appctl -t ovs-ofctl ofctl/barrier
764ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
765AT_CAPTURE_FILE([monitor.log])
766
767# Send a packet-out with a load action to set some metadata, and forward to controller
768AT_CHECK([ovs-ofctl packet-out br0 none 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), controller' '0001020304050010203040501234'])
769
770# Stop the monitor and check its output.
771ovs-appctl -t ovs-ofctl ofctl/barrier
772ovs-appctl -t ovs-ofctl exit
773
774AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
42edbe39 775NXT_PACKET_IN: total_len=14 in_port=NONE metadata=0xfafafafa5a5a5a5a (via action) data_len=14 (unbuffered)
296e07ac 776priority:0,metadata:0,in_port:0000,tci(0) mac(00:10:20:30:40:50->00:01:02:03:04:05) type:1234
751c7785
BP
777OFPT_BARRIER_REPLY:
778])
779
780OVS_VSWITCHD_STOP
781AT_CLEANUP
2b07c8b1
BP
782
783AT_SETUP([ofproto - flow monitoring])
784AT_KEYWORDS([monitor])
785OVS_VSWITCHD_START
786
787ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
788
789# Start a monitor watching the flow table and check the initial reply.
790ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
791AT_CAPTURE_FILE([monitor.log])
792ovs-appctl -t ovs-ofctl ofctl/barrier
793AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
794 [NXST_FLOW_MONITOR reply:
795 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
796OFPT_BARRIER_REPLY:
797])
798
799# Add, delete, and modify some flows and check the updates.
800ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
801ovs-ofctl add-flow br0 in_port=0,dl_vlan=124,actions=output:2
802ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:5
95a1c4ca
SH
803ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=0,actions=output:6
804ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=1,actions=output:7
805ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:8
806ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=0,actions=output:9
807ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=1,actions=output:10
808ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,actions=output:11
809ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=0,actions=output:12
810ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=1,actions=output:13
811ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,actions=output:14
812ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:15
813ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:16
814ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:17
815ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:18
816ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:19
817ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:20
818ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=0,actions=output:21
819ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=1,actions=output:22
820ovs-ofctl add-flow br0 in_port=0,actions=output:23
2b07c8b1
BP
821ovs-ofctl mod-flows br0 cookie=5,dl_vlan=123,actions=output:3
822ovs-ofctl del-flows br0 dl_vlan=123
823ovs-ofctl del-flows br0
824ovs-appctl -t ovs-ofctl ofctl/barrier
32cd83a2
BP
825sort='
826 # Sorts groups of lines that start with a space, without moving them
827 # past the nearest line that does not start with a space.
828 use warnings;
829 use strict;
830 my @buffer = ();
831 while (<STDIN>) {
832 if (/^ /) {
833 push(@buffer, $_);
834 } else {
835 print $_ foreach sort(@buffer);
836 print $_;
837 @buffer = ();
838 }
839 }
840 print $_ foreach sort(@buffer);
841'
842AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | perl -e "$sort"], [0],
2b07c8b1
BP
843[NXST_FLOW_MONITOR reply (xid=0x0):
844 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
845NXST_FLOW_MONITOR reply (xid=0x0):
846 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:5
95a1c4ca
SH
847NXST_FLOW_MONITOR reply (xid=0x0):
848 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:6
849NXST_FLOW_MONITOR reply (xid=0x0):
850 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:7
851NXST_FLOW_MONITOR reply (xid=0x0):
852 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:8
853NXST_FLOW_MONITOR reply (xid=0x0):
854 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:9
855NXST_FLOW_MONITOR reply (xid=0x0):
856 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:10
857NXST_FLOW_MONITOR reply (xid=0x0):
858 event=ADDED table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
859NXST_FLOW_MONITOR reply (xid=0x0):
860 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
861NXST_FLOW_MONITOR reply (xid=0x0):
862 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
863NXST_FLOW_MONITOR reply (xid=0x0):
864 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
865NXST_FLOW_MONITOR reply (xid=0x0):
866 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:15
867NXST_FLOW_MONITOR reply (xid=0x0):
868 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:16
869NXST_FLOW_MONITOR reply (xid=0x0):
870 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:17
871NXST_FLOW_MONITOR reply (xid=0x0):
872 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
873NXST_FLOW_MONITOR reply (xid=0x0):
874 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
875NXST_FLOW_MONITOR reply (xid=0x0):
876 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
877NXST_FLOW_MONITOR reply (xid=0x0):
878 event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
879NXST_FLOW_MONITOR reply (xid=0x0):
880 event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
881NXST_FLOW_MONITOR reply (xid=0x0):
882 event=ADDED table=0 cookie=0 in_port=0 actions=output:23
2b07c8b1
BP
883NXST_FLOW_MONITOR reply (xid=0x0):
884 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
95a1c4ca
SH
885 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
886 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
2b07c8b1
BP
887NXST_FLOW_MONITOR reply (xid=0x0):
888 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
95a1c4ca
SH
889 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
890 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
2b07c8b1 891NXST_FLOW_MONITOR reply (xid=0x0):
32cd83a2 892 event=DELETED reason=delete table=0 cookie=0 in_port=0 actions=output:23
95a1c4ca 893 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
32cd83a2
BP
894 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
895 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
2b07c8b1 896 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
95a1c4ca 897 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
32cd83a2 898 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
95a1c4ca 899 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
32cd83a2
BP
900 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
901 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
95a1c4ca 902 event=DELETED reason=delete table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
2b07c8b1
BP
903OFPT_BARRIER_REPLY:
904])
905
906# Check that our own changes are reported as abbreviations.
907ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
908ovs-ofctl add-flow br0 in_port=1,actions=output:2
909ovs-ofctl add-flow br0 in_port=2,actions=output:1
910ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
911ovs-appctl -t ovs-ofctl ofctl/barrier
912AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
913])
914AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
915[NXST_FLOW_MONITOR reply (xid=0x0):
916 event=ADDED table=0 cookie=0 in_port=1 actions=output:2
917NXST_FLOW_MONITOR reply (xid=0x0):
918 event=ADDED table=0 cookie=0 in_port=2 actions=output:1
919send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
920NXST_FLOW_MONITOR reply (xid=0x0):
921 event=ABBREV xid=0x12345678
922OFPT_BARRIER_REPLY:
923])
924
925ovs-appctl -t ovs-ofctl exit
926OVS_VSWITCHD_STOP
927AT_CLEANUP
928
929AT_SETUP([ofproto - flow monitoring pause and resume])
930AT_KEYWORDS([monitor])
931
46a80050
EM
932# The maximum socket receive buffer size is important for this test, which
933# tests behavior when the receive buffer overflows.
934if test -e /proc/sys/net/core/rmem_max; then
935 # Linux
936 rmem_max=`cat /proc/sys/net/core/rmem_max`
937elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
938 : # FreeBSD
939else
940 # Don't know how to get maximum socket receive buffer on this OS
941 AT_SKIP_IF([:])
942fi
2b07c8b1
BP
943# Calculate the total amount of queuing: rmem_max in the kernel, 128 kB
944# in ofproto sending userspace (see ofmonitor_flush() in connmgr.c).
2b07c8b1
BP
945queue_size=`expr $rmem_max + 128 \* 1024`
946echo rmem_max=$rmem_max queue_size=$queue_size
947
948# Each flow update message takes up at least 48 bytes of space in queues
949# and in practice more than that.
950n_msgs=`expr $queue_size / 48`
951echo n_msgs=$n_msgs
952
953OVS_VSWITCHD_START
954
955# Start a monitor watching the flow table, then make it block.
0b7140bb 956ON_EXIT([kill `cat ovs-ofctl.pid`])
2b07c8b1
BP
957ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
958AT_CAPTURE_FILE([monitor.log])
959ovs-appctl -t ovs-ofctl ofctl/block
960
961# Add $n_msgs flows.
962(echo "in_port=2,actions=output:2"
963perl -e '
964 for ($i = 0; $i < '$n_msgs'; $i++) {
965 print "cookie=1,reg1=$i,actions=drop\n";
966 }
967') > flows.txt
968AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
79b8c36c
BP
969# Check that multipart flow dumps work properly:
970AT_CHECK([ovs-ofctl diff-flows br0 flows.txt])
2b07c8b1
BP
971AT_CHECK([ovs-ofctl add-flow br0 in_port=1,cookie=3,actions=drop])
972AT_CHECK([ovs-ofctl mod-flows br0 in_port=2,cookie=2,actions=output:2])
973AT_CHECK([ovs-ofctl del-flows br0 cookie=1/-1])
974
975ovs-appctl -t ovs-ofctl ofctl/unblock
976ovs-appctl -t ovs-ofctl ofctl/barrier
977
978ovs-appctl -t ovs-ofctl exit
979
980# Check that the flow monitor reported the same number of flows
981# added and deleted, but fewer than we actually added and deleted.
982adds=`grep -c 'ADDED.*reg1=' monitor.log`
983deletes=`grep -c 'DELETED.*reg1=' monitor.log`
984echo adds=$adds deletes=$deletes
985AT_CHECK([test $adds -gt 100 && test $adds -lt $n_msgs])
986AT_CHECK([test $adds = $deletes])
987
d0ab8a1a
BP
988# Check that the flow monitor reported everything in the expected order:
989#
990# event=ADDED table=0 cookie=0x1 reg1=0x22
991# ...
992# NXT_FLOW_MONITOR_PAUSED:
993# ...
994# event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
995# ...
996# event=ADDED table=0 cookie=0x3 in_port=1
997# event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
998# NXT_FLOW_MONITOR_RESUMED:
999#
1000# except that, between the PAUSED and RESUMED, the order of the ADDED
1001# and MODIFIED lines lines depends on hash order, that is, it varies
1002# as we change the hash function or change architecture. Therefore,
1003# we use a couple of tests below to accept both orders.
2b07c8b1 1004AT_CHECK([ofctl_strip < monitor.log | sed -n -e '
46a80050 1005/reg1=0x22$/p
2b07c8b1
BP
1006/cookie=0x[[23]]/p
1007/NXT_FLOW_MONITOR_PAUSED:/p
1008/NXT_FLOW_MONITOR_RESUMED:/p
d0ab8a1a
BP
1009' > monitor.log.subset])
1010AT_CHECK([grep -v MODIFIED monitor.log.subset], [0], [dnl
1011 event=ADDED table=0 cookie=0x1 reg1=0x22
2b07c8b1
BP
1012NXT_FLOW_MONITOR_PAUSED:
1013 event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1014 event=ADDED table=0 cookie=0x3 in_port=1
d0ab8a1a
BP
1015NXT_FLOW_MONITOR_RESUMED:
1016])
1017AT_CHECK([grep -v ADDED monitor.log.subset], [0], [dnl
1018NXT_FLOW_MONITOR_PAUSED:
1019 event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
2b07c8b1
BP
1020 event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
1021NXT_FLOW_MONITOR_RESUMED:
1022])
1023
1024OVS_VSWITCHD_STOP
1025AT_CLEANUP