ofproto-dpif: Do not give stats to rules bypassed by "drop" frag policy.
[cascardo/ovs.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 AT_CHECK([ovs-ofctl -vwarn queue-stats br0 ALL 5], [0],
63   [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_QUEUE
64 OFPST_QUEUE request (xid=0x2):port=ALL queue=5
65 ])
66 AT_CHECK([ovs-ofctl -vwarn queue-stats br0 10], [0],
67   [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_PORT
68 OFPST_QUEUE request (xid=0x2):port=10 queue=ALL
69 ])
70 OVS_VSWITCHD_STOP
71 AT_CLEANUP
72
73 AT_SETUP([ofproto - mod-port])
74 OVS_VSWITCHD_START
75 for command_config_state in \
76     'up 0 0' \
77     'noflood NO_FLOOD 0' \
78     'down PORT_DOWN,NO_FLOOD LINK_DOWN' \
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'
87 do
88     set $command_config_state
89     command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
90     AT_CHECK([ovs-ofctl -vwarn mod-port br0 br0 $command])
91     AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
92     AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
93 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
94 n_tables:255, n_buffers:256
95 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
96 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
97  LOCAL(br0): addr:aa:55:aa:55:00:00
98      config:     $config
99      state:      $state
100      speed: 100 Mbps now, 100 Mbps max
101 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
102 ])
103 done
104 OVS_VSWITCHD_STOP
105 AT_CLEANUP
106
107 AT_SETUP([ofproto - basic flow_mod commands (NXM)])
108 OVS_VSWITCHD_START
109 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
110 ])
111 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl add-flows br0 -])
112 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=2])
113 AT_CHECK([ovs-ofctl -F nxm add-flow br0 table=1,in_port=4,actions=3])
114 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
115  in_port=1 actions=output:2
116  in_port=2 actions=output:1
117  table=1, in_port=4 actions=output:3
118 NXST_FLOW reply:
119 ])
120 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
121 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
122 ])
123 AT_CHECK([ovs-ofctl del-flows br0])
124 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
125 ])
126 OVS_VSWITCHD_STOP
127 AT_CLEANUP
128
129 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.0)])
130 OVS_VSWITCHD_START
131 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
132 ])
133 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -F openflow10 add-flows br0 -])
134 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 in_port=1,actions=2])
135 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 table=1,in_port=4,actions=3])
136 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
137  in_port=1 actions=output:2
138  in_port=2 actions=output:1
139  table=1, in_port=4 actions=output:3
140 OFPST_FLOW reply:
141 ])
142 AT_CHECK([ovs-ofctl -F openflow10 dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
143 OFPST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
144 ])
145 AT_CHECK([ovs-ofctl -F openflow10 del-flows br0])
146 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
147 ])
148 OVS_VSWITCHD_STOP
149 AT_CLEANUP
150
151 AT_SETUP([ofproto - set-field flow_mod commands (NXM)])
152 OVS_VSWITCHD_START
153 AT_CHECK([ovs-ofctl add-flow br0 ipv6,table=1,in_port=3,actions=drop])
154 AT_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])
155 AT_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]]
157 NXST_FLOW reply:
158 ])
159 OVS_VSWITCHD_STOP
160 AT_CLEANUP
161
162 AT_SETUP([ofproto - dump flows with cookie])
163 OVS_VSWITCHD_START
164 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
165 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
166 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
167 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
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
171 NXST_FLOW reply:
172 ])
173 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
174 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
175 ])
176 AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/-1 | ofctl_strip | sort], [0], [dnl
177  cookie=0x3, in_port=3 actions=output:1
178 NXST_FLOW reply:
179 ])
180 AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/-1 | STRIP_XIDS], [0], [dnl
181 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=1
182 ])
183 OVS_VSWITCHD_STOP
184 AT_CLEANUP
185
186 AT_SETUP([ofproto - dump flows with cookie mask])
187 OVS_VSWITCHD_START
188 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
189 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
190 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
191 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
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
195 NXST_FLOW reply:
196 ])
197 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
198 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
199 ])
200 AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/0x1 | ofctl_strip | sort], [0], [dnl
201  cookie=0x1, in_port=1 actions=output:1
202  cookie=0x3, in_port=3 actions=output:1
203 NXST_FLOW reply:
204 ])
205 AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/0x1 | STRIP_XIDS], [0], [dnl
206 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
207 ])
208 OVS_VSWITCHD_STOP
209 AT_CLEANUP
210
211 AT_SETUP([ofproto - mod flow with cookie change (OpenFlow 1.0)])
212 OVS_VSWITCHD_START
213 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 cookie=0x1,in_port=1,actions=1])
214 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
215  cookie=0x1, in_port=1 actions=output:1
216 OFPST_FLOW reply:
217 ])
218
219 AT_CHECK([ovs-ofctl -F openflow10 mod-flows br0 cookie=0x2,in_port=1,actions=1])
220 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
221  cookie=0x2, in_port=1 actions=output:1
222 OFPST_FLOW reply:
223 ])
224 OVS_VSWITCHD_STOP
225 AT_CLEANUP
226
227 AT_SETUP([ofproto - mod flow with cookie change (NXM)])
228 OVS_VSWITCHD_START
229 AT_CHECK([ovs-ofctl -F nxm add-flow br0 cookie=0x1,in_port=1,actions=1])
230 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
231  cookie=0x1, in_port=1 actions=output:1
232 NXST_FLOW reply:
233 ])
234
235 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x2,in_port=1,actions=1])
236 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
237  cookie=0x2, in_port=1 actions=output:1
238 NXST_FLOW reply:
239 ])
240 OVS_VSWITCHD_STOP
241 AT_CLEANUP
242
243 AT_SETUP([ofproto - mod flows based on cookie mask])
244 OVS_VSWITCHD_START
245 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
246 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
247 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
248 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
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
252 NXST_FLOW reply:
253 ])
254
255 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x1/0xff,actions=4])
256 AT_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
259  cookie=0x2, in_port=3 actions=output:1
260 NXST_FLOW reply:
261 ])
262 OVS_VSWITCHD_STOP
263 AT_CLEANUP
264
265 AT_SETUP([ofproto - mod flows based on cookie mask with cookie change])
266 OVS_VSWITCHD_START
267 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
268 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
269 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
270 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
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
274 NXST_FLOW reply:
275 ])
276
277 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/-1,cookie=4,actions=4])
278 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
279  cookie=0x2, in_port=3 actions=output:1
280  cookie=0x4, in_port=1 actions=output:4
281  cookie=0x4, in_port=2 actions=output:4
282 NXST_FLOW reply:
283 ])
284 OVS_VSWITCHD_STOP
285 AT_CLEANUP
286
287 AT_SETUP([ofproto - mod flow with cookie miss (mask==0)])
288 OVS_VSWITCHD_START
289 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 in_port=1,actions=1])
290 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
291  in_port=1 actions=output:1
292 NXST_FLOW reply:
293 ])
294 OVS_VSWITCHD_STOP
295 AT_CLEANUP
296
297 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0)])
298 OVS_VSWITCHD_START
299 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/1,in_port=1,actions=1])
300 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
301 NXST_FLOW reply:
302 ])
303 OVS_VSWITCHD_STOP
304 AT_CLEANUP
305
306 AT_SETUP([ofproto - del flows with cookies])
307 OVS_VSWITCHD_START
308 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
309 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
310 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
311 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
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
315 NXST_FLOW reply:
316 ])
317
318 AT_CHECK([ovs-ofctl del-flows br0])
319 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
320 NXST_FLOW reply:
321 ])
322 OVS_VSWITCHD_STOP
323 AT_CLEANUP
324
325 AT_SETUP([ofproto - del flows based on cookie])
326 OVS_VSWITCHD_START
327 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
328 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
329 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
330 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
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
334 NXST_FLOW reply:
335 ])
336
337 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/-1])
338 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
339  cookie=0x1, in_port=1 actions=output:1
340  cookie=0x2, in_port=2 actions=output:1
341 NXST_FLOW reply:
342 ])
343 OVS_VSWITCHD_STOP
344 AT_CLEANUP
345
346 AT_SETUP([ofproto - del flows based on cookie mask])
347 OVS_VSWITCHD_START
348 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
349 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
350 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
351 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
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
355 NXST_FLOW reply:
356 ])
357 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/0x1])
358 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
359  cookie=0x2, in_port=2 actions=output:1
360 NXST_FLOW reply:
361 ])
362 OVS_VSWITCHD_STOP
363 AT_CLEANUP
364
365 AT_SETUP([ofproto - del flows based on table id])
366 OVS_VSWITCHD_START
367 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
368 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
369 AT_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
372 NXST_FLOW reply:
373 ])
374 AT_CHECK([ovs-ofctl del-flows br0 table=0])
375 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
376  cookie=0x2, table=1, in_port=2 actions=output:1
377 NXST_FLOW reply:
378 ])
379 AT_CHECK([ovs-ofctl del-flows br0 table=1])
380 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
381 NXST_FLOW reply:
382 ])
383 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
384 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
385 AT_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
388 NXST_FLOW reply:
389 ])
390 AT_CHECK([ovs-ofctl del-flows br0])
391 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
392 NXST_FLOW reply:
393 ])
394 OVS_VSWITCHD_STOP
395 AT_CLEANUP
396
397 AT_SETUP([ofproto - flow table configuration])
398 OVS_VSWITCHD_START
399 # Check the default configuration.
400 (echo "OFPST_TABLE reply (xid=0x2): 255 tables
401   0: classifier: wild=0x3fffff, max=1000000, active=0
402                lookup=0, matched=0"
403  x=1
404  while test $x -lt 254; do
405    printf "  %d: %-8s: wild=0x3fffff, max=1000000, active=0
406                lookup=0, matched=0
407 " $x table$x
408    x=`expr $x + 1`
409  done
410  echo "  254: table254: wild=0x3fffff, max=1000000, active=3
411                lookup=0, matched=0") > expout
412 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
413 # Change the configuration.
414 AT_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.
424 mv expout orig-expout
425 (echo "OFPST_TABLE reply (xid=0x2): 255 tables
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
431 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
432 OVS_VSWITCHD_STOP
433 AT_CLEANUP
434
435 AT_SETUP([ofproto - hard limits on flow table size])
436 OVS_VSWITCHD_START
437 # Configure a maximum of 4 flows.
438 AT_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.
446 for in_port in 1 2 3 4; do
447     ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
448 done
449 AT_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
454 NXST_FLOW reply:
455 ])
456 # Adding another flow will be refused.
457 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
458 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
459   [OFPT_ERROR: OFPFMFC_TABLE_FULL
460 ])
461 # Also a mod-flow that would add a flow will be refused.
462 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
463 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
464   [OFPT_ERROR: OFPFMFC_TABLE_FULL
465 ])
466 # Replacing or modifying an existing flow is allowed.
467 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
468 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
469 AT_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
474 NXST_FLOW reply:
475 ])
476 OVS_VSWITCHD_STOP
477 AT_CLEANUP
478
479 AT_SETUP([ofproto - eviction upon table overflow])
480 OVS_VSWITCHD_START
481 # Configure a maximum of 4 flows.
482 AT_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.
490 for 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
492 done
493 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
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
498 NXST_FLOW reply:
499 ])
500 # Adding another flow will cause the one that expires soonest to be evicted.
501 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
502 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
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
506  in_port=5 actions=drop
507 NXST_FLOW reply:
508 ])
509 # A mod-flow that adds a flow also causes eviction, but replacing or
510 # modifying an existing flow doesn't.
511 AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
512 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
513 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
514 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
515  idle_timeout=30, in_port=3 actions=output:1
516  in_port=4 actions=NORMAL
517  in_port=5 actions=drop
518  in_port=6 actions=drop
519 NXST_FLOW reply:
520 ])
521 # Flows with no timeouts at all cannot be evicted.
522 AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
523 AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
524 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
525   [OFPT_ERROR: OFPFMFC_TABLE_FULL
526 ])
527 AT_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
532 NXST_FLOW reply:
533 ])
534 OVS_VSWITCHD_STOP
535 AT_CLEANUP
536
537 AT_SETUP([ofproto - eviction upon table overflow, with fairness])
538 OVS_VSWITCHD_START
539 # Configure a maximum of 4 flows.
540 AT_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.
550 ovs-ofctl add-flows br0 - <<EOF
551 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
552 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
553 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
554 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
555 EOF
556 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
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
561 NXST_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):
567 AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
568 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
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
572  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
573 NXST_FLOW reply:
574 ])
575 # Enlarge the flow limit, change the eviction policy back to strictly
576 # based on expiration, and and add some flows.
577 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
578 ovs-ofctl add-flows br0 - <<EOF
579 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
580 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
581 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
582 EOF
583 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
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
590  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
591 NXST_FLOW reply:
592 ])
593 # Adding another flow will cause the one that expires soonest overall
594 # to be evicted.
595 AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
596 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
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
603  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
604 NXST_FLOW reply:
605 ])
606 # Reducing the flow limit also causes the flows that expire soonest
607 # overall to be evicted.
608 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
609 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
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
613  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
614 NXST_FLOW reply:
615 ])
616 OVS_VSWITCHD_STOP
617 AT_CLEANUP
618
619 AT_SETUP([ofproto - asynchronous message control])
620 OVS_VSWITCHD_START
621 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
622 check_async () {
623     printf '\n\n--- check_async %d ---\n\n\n' $1
624     shift
625
626     ovs-appctl -t ovs-ofctl ofctl/barrier
627     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
628     : > expout
629
630     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
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)
634 metadata=0,in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
635     fi
636
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)
641 metadata=0,in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
642     fi
643
644     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
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)
648 udp,metadata=0,in_port=0,vlan_tci=0x0000,dl_src=00:26:b9:8c:b0:f9,dl_dst=00:25:83:df:b4:00,nw_src=172.17.55.13,nw_dst=172.16.0.2,nw_tos=0,nw_ecn=0,nw_ttl=0,tp_src=55155,tp_dst=53 udp_csum:8f6d"
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
656      state:      LINK_DOWN
657      speed: 100 Mbps now, 100 Mbps max"
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
665      state:      LINK_DOWN
666      speed: 100 Mbps now, 100 Mbps max"
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
678     echo >>expout "OFPT_BARRIER_REPLY:"
679
680     AT_CHECK(
681       [[sed '
682 s/ (xid=0x[0-9a-fA-F]*)//
683 s/ *duration.*//
684 s/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.
689 check_async 1
690
691 # Set miss_send_len to 128, turning on packet-ins for our service connection.
692 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
693 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
694
695 # Set miss_send_len to 128 and enable invalid_ttl.
696 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
697 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
698
699 # Become slave, which should disable everything except port status.
700 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
701 check_async 4 OFPPR_ADD OFPPR_DELETE
702
703 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
704 ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
705 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
706
707 # Set controller ID 123.
708 ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
709 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
710
711 # Restore controller ID 0.
712 ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
713
714 # Become master.
715 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
716 check_async 7 OFPR_ACTION OFPPR_ADD
717
718 ovs-appctl -t ovs-ofctl exit
719 OVS_VSWITCHD_STOP
720 AT_CLEANUP
721
722 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
723 dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
724 dnl controllers despite the spec) as meaning a packet that was generated
725 dnl by the controller.
726 AT_SETUP([ofproto - packet-out from controller])
727 OVS_VSWITCHD_START
728
729 # Start a monitor listening for packet-ins.
730 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
731 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
732 ovs-appctl -t ovs-ofctl ofctl/barrier
733 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
734 AT_CAPTURE_FILE([monitor.log])
735
736 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
737 AT_CHECK([ovs-ofctl packet-out br0 none controller '0001020304050010203040501234'])
738 AT_CHECK([ovs-ofctl packet-out br0 controller controller '0001020304050010203040505678'])
739
740 # Stop the monitor and check its output.
741 ovs-appctl -t ovs-ofctl ofctl/barrier
742 ovs-appctl -t ovs-ofctl exit
743
744 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
745 OFPT_PACKET_IN: total_len=14 in_port=NONE (via action) data_len=14 (unbuffered)
746 metadata=0,in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
747 OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
748 metadata=0,in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
749 OFPT_BARRIER_REPLY:
750 ])
751
752 OVS_VSWITCHD_STOP
753 AT_CLEANUP
754
755 dnl This test checks that metadata is encoded in packet_in structures,
756 dnl supported by NXAST.
757 AT_SETUP([ofproto - packet-out with metadata (NXM)])
758 OVS_VSWITCHD_START
759
760 # Start a monitor listening for packet-ins.
761 AT_CHECK([ovs-ofctl -P nxm monitor br0 --detach --no-chdir --pidfile])
762 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
763 ovs-appctl -t ovs-ofctl ofctl/barrier
764 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
765 AT_CAPTURE_FILE([monitor.log])
766
767 # Send a packet-out with a load action to set some metadata, and forward to controller
768 AT_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.
771 ovs-appctl -t ovs-ofctl ofctl/barrier
772 ovs-appctl -t ovs-ofctl exit
773
774 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
775 NXT_PACKET_IN: total_len=14 in_port=NONE metadata=0xfafafafa5a5a5a5a (via action) data_len=14 (unbuffered)
776 metadata=0,in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
777 OFPT_BARRIER_REPLY:
778 ])
779
780 OVS_VSWITCHD_STOP
781 AT_CLEANUP
782
783 AT_SETUP([ofproto - flow monitoring])
784 AT_KEYWORDS([monitor])
785 OVS_VSWITCHD_START
786
787 ovs-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.
790 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
791 AT_CAPTURE_FILE([monitor.log])
792 ovs-appctl -t ovs-ofctl ofctl/barrier
793 AT_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
796 OFPT_BARRIER_REPLY:
797 ])
798
799 # Add, delete, and modify some flows and check the updates.
800 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
801 ovs-ofctl add-flow br0 in_port=0,dl_vlan=124,actions=output:2
802 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:5
803 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=0,actions=output:6
804 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=1,actions=output:7
805 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:8
806 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=0,actions=output:9
807 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=1,actions=output:10
808 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,actions=output:11
809 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=0,actions=output:12
810 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=1,actions=output:13
811 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,actions=output:14
812 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:15
813 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:16
814 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:17
815 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:18
816 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:19
817 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:20
818 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=0,actions=output:21
819 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=1,actions=output:22
820 ovs-ofctl add-flow br0 in_port=0,actions=output:23
821 ovs-ofctl mod-flows br0 cookie=5,dl_vlan=123,actions=output:3
822 ovs-ofctl del-flows br0 dl_vlan=123
823 ovs-ofctl del-flows br0
824 ovs-appctl -t ovs-ofctl ofctl/barrier
825 sort='
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 '
842 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | perl -e "$sort"], [0],
843 [NXST_FLOW_MONITOR reply (xid=0x0):
844  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
845 NXST_FLOW_MONITOR reply (xid=0x0):
846  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:5
847 NXST_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
849 NXST_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
851 NXST_FLOW_MONITOR reply (xid=0x0):
852  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:8
853 NXST_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
855 NXST_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
857 NXST_FLOW_MONITOR reply (xid=0x0):
858  event=ADDED table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
859 NXST_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
861 NXST_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
863 NXST_FLOW_MONITOR reply (xid=0x0):
864  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
865 NXST_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
867 NXST_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
869 NXST_FLOW_MONITOR reply (xid=0x0):
870  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:17
871 NXST_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
873 NXST_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
875 NXST_FLOW_MONITOR reply (xid=0x0):
876  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
877 NXST_FLOW_MONITOR reply (xid=0x0):
878  event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
879 NXST_FLOW_MONITOR reply (xid=0x0):
880  event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
881 NXST_FLOW_MONITOR reply (xid=0x0):
882  event=ADDED table=0 cookie=0 in_port=0 actions=output:23
883 NXST_FLOW_MONITOR reply (xid=0x0):
884  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
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
887 NXST_FLOW_MONITOR reply (xid=0x0):
888  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
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
891 NXST_FLOW_MONITOR reply (xid=0x0):
892  event=DELETED reason=delete table=0 cookie=0 in_port=0 actions=output:23
893  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
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
896  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
897  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
898  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
899  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
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
902  event=DELETED reason=delete table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
903 OFPT_BARRIER_REPLY:
904 ])
905
906 # Check that our own changes are reported as abbreviations.
907 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
908 ovs-ofctl add-flow br0 in_port=1,actions=output:2
909 ovs-ofctl add-flow br0 in_port=2,actions=output:1
910 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
911 ovs-appctl -t ovs-ofctl ofctl/barrier
912 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
913 ])
914 AT_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
917 NXST_FLOW_MONITOR reply (xid=0x0):
918  event=ADDED table=0 cookie=0 in_port=2 actions=output:1
919 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
920 NXST_FLOW_MONITOR reply (xid=0x0):
921  event=ABBREV xid=0x12345678
922 OFPT_BARRIER_REPLY:
923 ])
924
925 ovs-appctl -t ovs-ofctl exit
926 OVS_VSWITCHD_STOP
927 AT_CLEANUP
928
929 AT_SETUP([ofproto - flow monitoring pause and resume])
930 AT_KEYWORDS([monitor])
931
932 # The maximum socket receive buffer size is important for this test, which
933 # tests behavior when the receive buffer overflows.
934 if test -e /proc/sys/net/core/rmem_max; then
935     # Linux
936     rmem_max=`cat /proc/sys/net/core/rmem_max`
937 elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
938     : # FreeBSD
939 else
940     # Don't know how to get maximum socket receive buffer on this OS
941     AT_SKIP_IF([:])
942 fi
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).
945 queue_size=`expr $rmem_max + 128 \* 1024`
946 echo 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.
950 n_msgs=`expr $queue_size / 48`
951 echo n_msgs=$n_msgs
952
953 OVS_VSWITCHD_START
954
955 # Start a monitor watching the flow table, then make it block.
956 ON_EXIT([kill `cat ovs-ofctl.pid`])
957 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
958 AT_CAPTURE_FILE([monitor.log])
959 ovs-appctl -t ovs-ofctl ofctl/block
960
961 # Add $n_msgs flows.
962 (echo "in_port=2,actions=output:2"
963 perl -e '
964     for ($i = 0; $i < '$n_msgs'; $i++) {
965         print "cookie=1,reg1=$i,actions=drop\n";
966     }
967 ') > flows.txt
968 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
969 # Check that multipart flow dumps work properly:
970 AT_CHECK([ovs-ofctl diff-flows br0 flows.txt])
971 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,cookie=3,actions=drop])
972 AT_CHECK([ovs-ofctl mod-flows br0 in_port=2,cookie=2,actions=output:2])
973 AT_CHECK([ovs-ofctl del-flows br0 cookie=1/-1])
974
975 ovs-appctl -t ovs-ofctl ofctl/unblock
976 ovs-appctl -t ovs-ofctl ofctl/barrier
977
978 ovs-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.
982 adds=`grep -c 'ADDED.*reg1=' monitor.log`
983 deletes=`grep -c 'DELETED.*reg1=' monitor.log`
984 echo adds=$adds deletes=$deletes
985 AT_CHECK([test $adds -gt 100 && test $adds -lt $n_msgs])
986 AT_CHECK([test $adds = $deletes])
987
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.
1004 AT_CHECK([ofctl_strip < monitor.log | sed -n -e '
1005 /reg1=0x22$/p
1006 /cookie=0x[[23]]/p
1007 /NXT_FLOW_MONITOR_PAUSED:/p
1008 /NXT_FLOW_MONITOR_RESUMED:/p
1009 ' > monitor.log.subset])
1010 AT_CHECK([grep -v MODIFIED monitor.log.subset], [0], [dnl
1011  event=ADDED table=0 cookie=0x1 reg1=0x22
1012 NXT_FLOW_MONITOR_PAUSED:
1013  event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1014  event=ADDED table=0 cookie=0x3 in_port=1
1015 NXT_FLOW_MONITOR_RESUMED:
1016 ])
1017 AT_CHECK([grep -v ADDED monitor.log.subset], [0], [dnl
1018 NXT_FLOW_MONITOR_PAUSED:
1019  event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1020  event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
1021 NXT_FLOW_MONITOR_RESUMED:
1022 ])
1023
1024 OVS_VSWITCHD_STOP
1025 AT_CLEANUP