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