tests: Add tests for mod flows with cookie miss on OF1.2.
[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:254, 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:     0
19      state:      0
20      speed: 0 Mbps now, 0 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([[sed '
32 s/ (xid=0x[0-9a-fA-F]*)//
33 s/00:0.$/00:0x/' < stdout]],
34       [0], [dnl
35 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
36 n_tables:254, n_buffers:256
37 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
38 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
39  1(p1): addr:aa:55:aa:55:00:0x
40      config:     PORT_DOWN
41      state:      LINK_DOWN
42      speed: 0 Mbps now, 0 Mbps max
43  99(p2): addr:aa:55:aa:55:00:0x
44      config:     PORT_DOWN
45      state:      LINK_DOWN
46      speed: 0 Mbps now, 0 Mbps max
47  LOCAL(br0): addr:aa:55:aa:55:00:0x
48      config:     0
49      state:      0
50      speed: 0 Mbps now, 0 Mbps max
51 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
52 ])
53
54 OVS_VSWITCHD_STOP
55 AT_CLEANUP
56
57 dnl This is really bare-bones.
58 dnl It at least checks request and reply serialization and deserialization.
59 AT_SETUP([ofproto - port stats - (OpenFlow 1.0)])
60 OVS_VSWITCHD_START
61 AT_CHECK([ovs-ofctl -vwarn dump-ports br0], [0], [stdout])
62 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
63 OFPST_PORT reply: 1 ports
64   port LOCAL: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
65            tx pkts=0, bytes=0, drop=0, errs=0, coll=0
66 ])
67 OVS_VSWITCHD_STOP
68 AT_CLEANUP
69
70 AT_SETUP([ofproto - port stats - (OpenFlow 1.2)])
71 OVS_VSWITCHD_START
72 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn dump-ports br0], [0], [stdout])
73 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
74 OFPST_PORT reply (OF1.2): 1 ports
75   port LOCAL: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
76            tx pkts=0, bytes=0, drop=0, errs=0, coll=0
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 - port-desc stats (OpenFlow 1.0)])
84 OVS_VSWITCHD_START
85 AT_CHECK([ovs-ofctl -vwarn dump-ports-desc br0], [0], [stdout])
86 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
87 OFPST_PORT_DESC reply:
88  LOCAL(br0): addr:aa:55:aa:55:00:00
89      config:     0
90      state:      0
91      speed: 0 Mbps now, 0 Mbps max
92 ])
93 OVS_VSWITCHD_STOP
94 AT_CLEANUP
95
96 dnl This is really bare-bones.
97 dnl It at least checks request and reply serialization and deserialization.
98 AT_SETUP([ofproto - port-desc stats (OpenFlow 1.2)])
99 OVS_VSWITCHD_START
100 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn dump-ports-desc br0], [0], [stdout])
101 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
102 OFPST_PORT_DESC reply (OF1.2):
103  LOCAL(br0): addr:aa:55:aa:55:00:00
104      config:     0
105      state:      0
106      speed: 0 Mbps now, 0 Mbps max
107 ])
108 OVS_VSWITCHD_STOP
109 AT_CLEANUP
110
111 dnl This is really bare-bones.
112 dnl It at least checks request and reply serialization and deserialization.
113 AT_SETUP([ofproto - queue stats - (OpenFlow 1.0)])
114 OVS_VSWITCHD_START
115 AT_CHECK([ovs-ofctl -vwarn queue-stats br0], [0], [stdout])
116 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
117 OFPST_QUEUE reply: 0 queues
118 ])
119 AT_CHECK([ovs-ofctl -vwarn queue-stats br0 ANY 5], [0],
120   [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_QUEUE
121 OFPST_QUEUE request (xid=0x2):port=ANY queue=5
122 ])
123 AT_CHECK([ovs-ofctl -vwarn queue-stats br0 10], [0],
124   [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_PORT
125 OFPST_QUEUE request (xid=0x2):port=10 queue=ALL
126 ])
127 OVS_VSWITCHD_STOP
128 AT_CLEANUP
129
130 AT_SETUP([ofproto - queue stats - (OpenFlow 1.2)])
131 OVS_VSWITCHD_START
132 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn queue-stats br0], [0], [stdout])
133 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
134 OFPST_QUEUE reply (OF1.2): 0 queues
135 ])
136 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn queue-stats br0 ALL 5], [0],
137   [OFPT_ERROR (OF1.2) (xid=0x2): OFPQOFC_BAD_QUEUE
138 OFPST_QUEUE request (OF1.2) (xid=0x2):port=ANY queue=5
139 ])
140 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn queue-stats br0 10], [0],
141   [OFPT_ERROR (OF1.2) (xid=0x2): OFPQOFC_BAD_PORT
142 OFPST_QUEUE request (OF1.2) (xid=0x2):port=10 queue=ALL
143 ])
144 OVS_VSWITCHD_STOP
145 AT_CLEANUP
146
147 AT_SETUP([ofproto - mod-port (OpenFlow 1.0)])
148 OVS_VSWITCHD_START
149 for command_config_state in \
150     'up 0 0' \
151     'noflood NO_FLOOD 0' \
152     'down PORT_DOWN,NO_FLOOD LINK_DOWN' \
153     'flood PORT_DOWN LINK_DOWN' \
154     'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
155     'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
156     'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
157     'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
158     'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
159     'up NO_RECV 0' \
160     'receive 0 0'
161 do
162     set $command_config_state
163     command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
164     AT_CHECK([ovs-ofctl -vwarn mod-port br0 br0 $command])
165     AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
166     AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
167 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
168 n_tables:254, n_buffers:256
169 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
170 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
171  LOCAL(br0): addr:aa:55:aa:55:00:00
172      config:     $config
173      state:      $state
174      speed: 0 Mbps now, 0 Mbps max
175 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
176 ])
177 done
178 OVS_VSWITCHD_STOP
179 AT_CLEANUP
180
181 AT_SETUP([ofproto - mod-port (OpenFlow 1.2)])
182 OVS_VSWITCHD_START
183 for command_config_state in \
184     'up 0 0' \
185     'down PORT_DOWN LINK_DOWN' \
186     'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
187     'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
188     'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
189     'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
190     'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
191     'up NO_RECV 0' \
192     'receive 0 0'
193 do
194     set $command_config_state
195     command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
196     AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn mod-port br0 br0 $command])
197     AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn show br0], [0], [stdout])
198     AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
199 OFPT_FEATURES_REPLY (OF1.2): dpid:fedcba9876543210
200 n_tables:254, n_buffers:256
201 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS
202  LOCAL(br0): addr:aa:55:aa:55:00:00
203      config:     $config
204      state:      $state
205      speed: 0 Mbps now, 0 Mbps max
206 OFPT_GET_CONFIG_REPLY (OF1.2): frags=normal miss_send_len=0
207 ])
208 done
209 OVS_VSWITCHD_STOP
210 AT_CLEANUP
211
212 AT_SETUP([ofproto - basic flow_mod commands (NXM)])
213 OVS_VSWITCHD_START
214 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
215 ])
216 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl add-flows br0 -])
217 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=2])
218 AT_CHECK([ovs-ofctl -F nxm add-flow br0 table=1,in_port=4,actions=3])
219 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
220  in_port=1 actions=output:2
221  in_port=2 actions=output:1
222  table=1, in_port=4 actions=output:3
223 NXST_FLOW reply:
224 ])
225 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
226 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
227 ])
228 AT_CHECK([ovs-ofctl del-flows br0])
229 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
230 ])
231 OVS_VSWITCHD_STOP
232 AT_CLEANUP
233
234 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.0)])
235 OVS_VSWITCHD_START
236 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
237 ])
238 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -F openflow10 add-flows br0 -])
239 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 in_port=1,actions=2])
240 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 table=1,in_port=4,actions=3])
241 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
242  in_port=1 actions=output:2
243  in_port=2 actions=output:1
244  table=1, in_port=4 actions=output:3
245 OFPST_FLOW reply:
246 ])
247 AT_CHECK([ovs-ofctl -F openflow10 dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
248 OFPST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
249 ])
250 AT_CHECK([ovs-ofctl -F openflow10 del-flows br0])
251 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
252 ])
253 OVS_VSWITCHD_STOP
254 AT_CLEANUP
255
256 AT_SETUP([ofproto - set-field flow_mod commands (NXM)])
257 OVS_VSWITCHD_START
258 AT_CHECK([ovs-ofctl add-flow br0 ipv6,table=1,in_port=3,actions=drop])
259 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])
260 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
261  table=1, ipv6,in_port=3 actions=load:0xa6badbfffefe59fa->NXM_NX_IPV6_SRC[[0..63]],load:0xfe8001234567890a->NXM_NX_IPV6_SRC[[64..127]]
262 NXST_FLOW reply:
263 ])
264 OVS_VSWITCHD_STOP
265 AT_CLEANUP
266
267 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.2)])
268 OVS_VSWITCHD_START
269 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.2):
270 ])
271 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -O OpenFlow12 add-flows br0 -])
272 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=1,actions=2])
273 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 table=1,in_port=4,actions=3])
274 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
275  in_port=1 actions=output:2
276  in_port=2 actions=output:1
277  table=1, in_port=4 actions=output:3
278 OFPST_FLOW reply (OF1.2):
279 ])
280 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0])
281 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.2):
282 ])
283 OVS_VSWITCHD_STOP
284 AT_CLEANUP
285
286 AT_SETUP([ofproto - dump flows with cookie])
287 OVS_VSWITCHD_START
288 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
289 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
290 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
291 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
292  cookie=0x1, in_port=1 actions=output:1
293  cookie=0x2, in_port=2 actions=output:1
294  cookie=0x3, in_port=3 actions=output:1
295 NXST_FLOW reply:
296 ])
297 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
298 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
299 ])
300 AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/-1 | ofctl_strip | sort], [0], [dnl
301  cookie=0x3, in_port=3 actions=output:1
302 NXST_FLOW reply:
303 ])
304 AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/-1 | STRIP_XIDS], [0], [dnl
305 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=1
306 ])
307 OVS_VSWITCHD_STOP
308 AT_CLEANUP
309
310 AT_SETUP([ofproto - mod flow with cookie change (OpenFlow 1.0)])
311 OVS_VSWITCHD_START
312 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 cookie=0x1,in_port=1,actions=1])
313 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
314  cookie=0x1, in_port=1 actions=output:1
315 OFPST_FLOW reply:
316 ])
317
318 AT_CHECK([ovs-ofctl -F openflow10 mod-flows br0 cookie=0x2,in_port=1,actions=1])
319 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
320  cookie=0x2, in_port=1 actions=output:1
321 OFPST_FLOW reply:
322 ])
323 OVS_VSWITCHD_STOP
324 AT_CLEANUP
325
326 AT_SETUP([ofproto - mod flow with cookie change (NXM)])
327 OVS_VSWITCHD_START
328 AT_CHECK([ovs-ofctl -F nxm add-flow br0 cookie=0x1,in_port=1,actions=1])
329 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
330  cookie=0x1, in_port=1 actions=output:1
331 NXST_FLOW reply:
332 ])
333
334 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x2,in_port=1,actions=1])
335 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
336  cookie=0x2, in_port=1 actions=output:1
337 NXST_FLOW reply:
338 ])
339 OVS_VSWITCHD_STOP
340 AT_CLEANUP
341
342 dnl The OpenFlow 1.2 spec states that the cookie may not be modified
343 AT_SETUP([ofproto - no mod flow with cookie change (OpenFlow 1.2)])
344 OVS_VSWITCHD_START
345 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
346 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
347  cookie=0x1, in_port=1 actions=output:1
348 OFPST_FLOW reply (OF1.2):
349 ])
350
351 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 cookie=0x2,in_port=1,actions=1])
352 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
353  cookie=0x1, in_port=1 actions=output:1
354 OFPST_FLOW reply (OF1.2):
355 ])
356 OVS_VSWITCHD_STOP
357 AT_CLEANUP
358
359 AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.0)])
360 OVS_VSWITCHD_START
361 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
362 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
363 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
364 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
365  cookie=0x1, in_port=1 actions=output:1
366  cookie=0x1, in_port=2 actions=output:1
367  cookie=0x2, in_port=3 actions=output:1
368 NXST_FLOW reply:
369 ])
370
371 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x1/0xff,actions=4])
372 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
373  cookie=0x1, in_port=1 actions=output:4
374  cookie=0x1, in_port=2 actions=output:4
375  cookie=0x2, in_port=3 actions=output:1
376 NXST_FLOW reply:
377 ])
378 OVS_VSWITCHD_STOP
379 AT_CLEANUP
380
381 AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.2)])
382 OVS_VSWITCHD_START
383 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
384 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=2,actions=1])
385 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=3,actions=1])
386 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
387  cookie=0x1, in_port=1 actions=output:1
388  cookie=0x1, in_port=2 actions=output:1
389  cookie=0x2, in_port=3 actions=output:1
390 OFPST_FLOW reply (OF1.2):
391 ])
392
393 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 cookie=0x1/0xff,actions=4])
394 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
395  cookie=0x1, in_port=1 actions=output:4
396  cookie=0x1, in_port=2 actions=output:4
397  cookie=0x2, in_port=3 actions=output:1
398 OFPST_FLOW reply (OF1.2):
399 ])
400 OVS_VSWITCHD_STOP
401 AT_CLEANUP
402
403 dnl The OpenFlow 1.2 spec states that the cookie may not be modified
404 AT_SETUP([ofproto - mod flows based on cookie mask with cookie change])
405 OVS_VSWITCHD_START
406 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
407 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
408 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
409 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
410  cookie=0x1, in_port=1 actions=output:1
411  cookie=0x1, in_port=2 actions=output:1
412  cookie=0x2, in_port=3 actions=output:1
413 NXST_FLOW reply:
414 ])
415
416 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/-1,cookie=4,actions=4])
417 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
418  cookie=0x2, in_port=3 actions=output:1
419  cookie=0x4, in_port=1 actions=output:4
420  cookie=0x4, in_port=2 actions=output:4
421 NXST_FLOW reply:
422 ])
423 OVS_VSWITCHD_STOP
424 AT_CLEANUP
425
426 AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - NXM])
427 OVS_VSWITCHD_START
428 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 in_port=1,actions=1])
429 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
430  in_port=1 actions=output:1
431 NXST_FLOW reply:
432 ])
433 OVS_VSWITCHD_STOP
434 AT_CLEANUP
435
436 AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - OF1.2])
437 OVS_VSWITCHD_START
438 AT_CHECK([ovs-ofctl -O openflow12 mod-flows br0 in_port=1,actions=1])
439 AT_CHECK([ovs-ofctl -O openflow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
440 OFPST_FLOW reply (OF1.2):
441 ])
442 OVS_VSWITCHD_STOP
443 AT_CLEANUP
444
445 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - NXM])
446 OVS_VSWITCHD_START
447 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/1,in_port=1,actions=1])
448 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
449 NXST_FLOW reply:
450 ])
451 OVS_VSWITCHD_STOP
452 AT_CLEANUP
453
454 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - OF1.2])
455 OVS_VSWITCHD_START
456 AT_CHECK([ovs-ofctl -O openflow12 mod-flows br0 cookie=1/1,in_port=1,actions=1])
457 AT_CHECK([ovs-ofctl -O openflow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
458 OFPST_FLOW reply (OF1.2):
459 ])
460 OVS_VSWITCHD_STOP
461 AT_CLEANUP
462
463 AT_SETUP([ofproto - del flows with cookies])
464 OVS_VSWITCHD_START
465 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
466 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
467 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
468 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
469  cookie=0x1, in_port=1 actions=output:1
470  cookie=0x2, in_port=2 actions=output:1
471  cookie=0x3, in_port=3 actions=output:1
472 NXST_FLOW reply:
473 ])
474
475 AT_CHECK([ovs-ofctl del-flows br0])
476 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
477 NXST_FLOW reply:
478 ])
479 OVS_VSWITCHD_STOP
480 AT_CLEANUP
481
482 AT_SETUP([ofproto - del flows based on cookie])
483 OVS_VSWITCHD_START
484 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
485 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
486 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
487 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
488  cookie=0x1, in_port=1 actions=output:1
489  cookie=0x2, in_port=2 actions=output:1
490  cookie=0x3, in_port=3 actions=output:1
491 NXST_FLOW reply:
492 ])
493
494 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/-1])
495 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
496  cookie=0x1, in_port=1 actions=output:1
497  cookie=0x2, in_port=2 actions=output:1
498 NXST_FLOW reply:
499 ])
500 OVS_VSWITCHD_STOP
501 AT_CLEANUP
502
503 AT_SETUP([ofproto - del flows based on cookie mask])
504 OVS_VSWITCHD_START
505 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
506 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
507 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
508 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
509  cookie=0x1, in_port=1 actions=output:1
510  cookie=0x2, in_port=2 actions=output:1
511  cookie=0x3, in_port=3 actions=output:1
512 NXST_FLOW reply:
513 ])
514 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/0x1])
515 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
516  cookie=0x2, in_port=2 actions=output:1
517 NXST_FLOW reply:
518 ])
519 OVS_VSWITCHD_STOP
520 AT_CLEANUP
521
522 AT_SETUP([ofproto - del flows based on table id (NXM)])
523 OVS_VSWITCHD_START
524 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
525 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
526 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
527  cookie=0x1, in_port=1 actions=output:1
528  cookie=0x2, table=1, in_port=2 actions=output:1
529 NXST_FLOW reply:
530 ])
531 AT_CHECK([ovs-ofctl del-flows br0 table=0])
532 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
533  cookie=0x2, table=1, in_port=2 actions=output:1
534 NXST_FLOW reply:
535 ])
536 AT_CHECK([ovs-ofctl del-flows br0 table=1])
537 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
538 NXST_FLOW reply:
539 ])
540 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
541 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
542 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
543  cookie=0x1, in_port=1 actions=output:1
544  cookie=0x2, table=1, in_port=2 actions=output:1
545 NXST_FLOW reply:
546 ])
547 AT_CHECK([ovs-ofctl del-flows br0])
548 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
549 NXST_FLOW reply:
550 ])
551 OVS_VSWITCHD_STOP
552 AT_CLEANUP
553
554 AT_SETUP([ofproto - del flows based on table id (OpenFlow 1.2)])
555 OVS_VSWITCHD_START
556 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
557 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
558 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
559  cookie=0x1, in_port=1 actions=output:1
560  cookie=0x2, table=1, in_port=2 actions=output:1
561 OFPST_FLOW reply (OF1.2):
562 ])
563 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0 table=0])
564 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
565  cookie=0x2, table=1, in_port=2 actions=output:1
566 OFPST_FLOW reply (OF1.2):
567 ])
568 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0 table=1])
569 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
570 OFPST_FLOW reply (OF1.2):
571 ])
572 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
573 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
574 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
575  cookie=0x1, in_port=1 actions=output:1
576  cookie=0x2, table=1, in_port=2 actions=output:1
577 OFPST_FLOW reply (OF1.2):
578 ])
579 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0])
580 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
581 OFPST_FLOW reply (OF1.2):
582 ])
583 OVS_VSWITCHD_STOP
584 AT_CLEANUP
585
586 AT_SETUP([ofproto - flow table configuration (OpenFlow 1.0)])
587 OVS_VSWITCHD_START
588 # Check the default configuration.
589 (echo "OFPST_TABLE reply (xid=0x2): 254 tables
590   0: classifier: wild=0x3fffff, max=1000000, active=0
591                lookup=0, matched=0"
592  x=1
593  while test $x -lt 254; do
594    printf "  %d: %-8s: wild=0x3fffff, max=1000000, active=0
595                lookup=0, matched=0
596 " $x table$x
597    x=`expr $x + 1`
598  done) > expout
599 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
600 # Change the configuration.
601 AT_CHECK(
602   [ovs-vsctl \
603      -- --id=@t0 create Flow_Table name=main \
604      -- --id=@t1 create Flow_Table flow-limit=1024 \
605      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
606    | ${PERL} $srcdir/uuidfilt.pl],
607   [0], [<0>
608 <1>
609 ])
610 # Check that the configuration was updated.
611 mv expout orig-expout
612 (echo "OFPST_TABLE reply (xid=0x2): 254 tables
613   0: main    : wild=0x3fffff, max=1000000, active=0
614                lookup=0, matched=0
615   1: table1  : wild=0x3fffff, max=  1024, active=0
616                lookup=0, matched=0"
617  tail -n +6 orig-expout) > expout
618 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
619 OVS_VSWITCHD_STOP
620 AT_CLEANUP
621
622 AT_SETUP([ofproto - flow table configuration (OpenFlow 1.2)])
623 OVS_VSWITCHD_START
624 # Check the default configuration.
625 (mid="wild=0xffffffffff, max=1000000,"
626  tail="
627                lookup=0, matched=0
628                match=0xffffffffff, instructions=0x00000007, config=0x00000003
629                write_actions=0x00000000, apply_actions=0x00000000
630                write_setfields=0x000000ffffffffff
631                apply_setfields=0x000000ffffffffff
632                metadata_match=0xffffffffffffffff
633                metadata_write=0xffffffffffffffff"
634  echo "OFPST_TABLE reply (OF1.2) (xid=0x2): 254 tables
635   0: classifier: $mid active=0$tail"
636  x=1
637  while test $x -lt 254; do
638    printf "  %d: %-8s: $mid active=0$tail
639 " $x table$x
640    x=`expr $x + 1`
641  done) > expout
642 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
643 # Change the configuration.
644 AT_CHECK(
645   [ovs-vsctl \
646      -- --id=@t0 create Flow_Table name=main \
647      -- --id=@t1 create Flow_Table flow-limit=1024 \
648      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
649    | ${PERL} $srcdir/uuidfilt.pl],
650   [0], [<0>
651 <1>
652 ])
653 # Check that the configuration was updated.
654 mv expout orig-expout
655 (echo "OFPST_TABLE reply (OF1.2) (xid=0x2): 254 tables
656   0: main    : wild=0xffffffffff, max=1000000, active=0"
657  tail -n +3 orig-expout | head -7
658  echo "  1: table1  : wild=0xffffffffff, max=  1024, active=0"
659  tail -n +11 orig-expout) > expout
660 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
661 OVS_VSWITCHD_STOP
662 AT_CLEANUP
663
664 AT_SETUP([ofproto - hard limits on flow table size (OpenFLow 1.0)])
665 OVS_VSWITCHD_START
666 # Configure a maximum of 4 flows.
667 AT_CHECK(
668   [ovs-vsctl \
669      -- --id=@t0 create Flow_Table flow-limit=4 \
670      -- set bridge br0 flow_tables:0=@t0 \
671    | ${PERL} $srcdir/uuidfilt.pl],
672   [0], [<0>
673 ])
674 # Add 4 flows.
675 for in_port in 1 2 3 4; do
676     ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
677 done
678 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
679  in_port=1 actions=drop
680  in_port=2 actions=drop
681  in_port=3 actions=drop
682  in_port=4 actions=drop
683 NXST_FLOW reply:
684 ])
685 # Adding another flow will be refused.
686 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
687 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
688   [OFPT_ERROR: OFPFMFC_TABLE_FULL
689 ])
690 # Also a mod-flow that would add a flow will be refused.
691 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
692 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
693   [OFPT_ERROR: OFPFMFC_TABLE_FULL
694 ])
695 # Replacing or modifying an existing flow is allowed.
696 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
697 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
698 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
699  in_port=1 actions=drop
700  in_port=2 actions=drop
701  in_port=3 actions=output:1
702  in_port=4 actions=NORMAL
703 NXST_FLOW reply:
704 ])
705 OVS_VSWITCHD_STOP
706 AT_CLEANUP
707
708 AT_SETUP([ofproto - hard limits on flow table size (OpenFLow 1.2)])
709 OVS_VSWITCHD_START
710 # Configure a maximum of 4 flows.
711 AT_CHECK(
712   [ovs-vsctl \
713      -- --id=@t0 create Flow_Table flow-limit=4 \
714      -- set bridge br0 flow_tables:0=@t0 \
715    | ${PERL} $srcdir/uuidfilt.pl],
716   [0], [<0>
717 ])
718 # Add 4 flows.
719 for in_port in 1 2 3 4; do
720     ovs-ofctl -O OpenFlow12 add-flow br0 in_port=$in_port,actions=drop
721 done
722 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
723  in_port=1 actions=drop
724  in_port=2 actions=drop
725  in_port=3 actions=drop
726  in_port=4 actions=drop
727 OFPST_FLOW reply (OF1.2):
728 ])
729 # Adding another flow will be refused.
730 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
731 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
732   [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
733 ])
734 # Replacing or modifying an existing flow is allowed.
735 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
736 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
737 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
738  in_port=1 actions=drop
739  in_port=2 actions=drop
740  in_port=3 actions=output:1
741  in_port=4 actions=NORMAL
742 OFPST_FLOW reply (OF1.2):
743 ])
744 OVS_VSWITCHD_STOP
745 AT_CLEANUP
746
747 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.0)])
748 OVS_VSWITCHD_START
749 # Configure a maximum of 4 flows.
750 AT_CHECK(
751   [ovs-vsctl \
752      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
753      -- set bridge br0 flow_tables:0=@t0 \
754    | ${PERL} $srcdir/uuidfilt.pl],
755   [0], [<0>
756 ])
757 # Add 4 flows.
758 for in_port in 4 3 2 1; do
759     ovs-ofctl add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
760 done
761 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
762  idle_timeout=10, in_port=1 actions=drop
763  idle_timeout=20, in_port=2 actions=drop
764  idle_timeout=30, in_port=3 actions=drop
765  idle_timeout=40, in_port=4 actions=drop
766 NXST_FLOW reply:
767 ])
768 # Adding another flow will cause the one that expires soonest to be evicted.
769 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
770 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
771  idle_timeout=20, in_port=2 actions=drop
772  idle_timeout=30, in_port=3 actions=drop
773  idle_timeout=40, in_port=4 actions=drop
774  in_port=5 actions=drop
775 NXST_FLOW reply:
776 ])
777 # A mod-flow that adds a flow also causes eviction, but replacing or
778 # modifying an existing flow doesn't.
779 AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
780 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
781 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
782 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
783  idle_timeout=30, in_port=3 actions=output:1
784  in_port=4 actions=NORMAL
785  in_port=5 actions=drop
786  in_port=6 actions=drop
787 NXST_FLOW reply:
788 ])
789 # Flows with no timeouts at all cannot be evicted.
790 AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
791 AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
792 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
793   [OFPT_ERROR: OFPFMFC_TABLE_FULL
794 ])
795 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
796  in_port=4 actions=NORMAL
797  in_port=5 actions=drop
798  in_port=6 actions=drop
799  in_port=7 actions=NORMAL
800 NXST_FLOW reply:
801 ])
802 OVS_VSWITCHD_STOP
803 AT_CLEANUP
804
805 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.2)])
806 OVS_VSWITCHD_START
807 # Configure a maximum of 4 flows.
808 AT_CHECK(
809   [ovs-vsctl \
810      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
811      -- set bridge br0 flow_tables:0=@t0 \
812    | ${PERL} $srcdir/uuidfilt.pl],
813   [0], [<0>
814 ])
815 # Add 4 flows.
816 for in_port in 4 3 2 1; do
817     ovs-ofctl -O OpenFlow12 add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
818 done
819 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
820  idle_timeout=10, in_port=1 actions=drop
821  idle_timeout=20, in_port=2 actions=drop
822  idle_timeout=30, in_port=3 actions=drop
823  idle_timeout=40, in_port=4 actions=drop
824 OFPST_FLOW reply (OF1.2):
825 ])
826 # Adding another flow will cause the one that expires soonest to be evicted.
827 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop])
828 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
829  idle_timeout=20, in_port=2 actions=drop
830  idle_timeout=30, in_port=3 actions=drop
831  idle_timeout=40, in_port=4 actions=drop
832  in_port=5 actions=drop
833 OFPST_FLOW reply (OF1.2):
834 ])
835 # In Open Flow 1.2 a mod-flow does not ever add a flow and thus
836 # has no effect on eviction
837 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=6,actions=drop])
838 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
839 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
840 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
841  idle_timeout=20, in_port=2 actions=drop
842  idle_timeout=30, in_port=3 actions=output:1
843  in_port=4 actions=NORMAL
844  in_port=5 actions=drop
845 OFPST_FLOW reply (OF1.2):
846 ])
847 # Flows with no timeouts at all cannot be evicted.
848 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=6,actions=drop])
849 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=7,actions=normal])
850 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
851 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
852   [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
853 ])
854 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
855  in_port=4 actions=NORMAL
856  in_port=5 actions=drop
857  in_port=6 actions=drop
858  in_port=7 actions=NORMAL
859 OFPST_FLOW reply (OF1.2):
860 ])
861 OVS_VSWITCHD_STOP
862 AT_CLEANUP
863
864 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.0)])
865 OVS_VSWITCHD_START
866 # Configure a maximum of 4 flows.
867 AT_CHECK(
868   [ovs-vsctl \
869      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
870                                    overflow-policy=evict \
871                                    groups='"NXM_OF_IN_PORT[[]]"' \
872      -- set bridge br0 flow_tables:0=@t0 \
873    | ${PERL} $srcdir/uuidfilt.pl],
874   [0], [<0>
875 ])
876 # Add 4 flows.
877 ovs-ofctl add-flows br0 - <<EOF
878 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
879 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
880 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
881 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
882 EOF
883 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
884  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
885  idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
886  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
887  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
888 NXST_FLOW reply:
889 ])
890 # Adding another flow will cause the one that expires soonest within
891 # the largest group (those with in_port=1) to be evicted.  In this
892 # case this is not the same as the one that expires soonest overall
893 # (which is what makes the test interesting):
894 AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
895 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
896  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
897  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
898  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
899  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
900 NXST_FLOW reply:
901 ])
902 # Enlarge the flow limit, change the eviction policy back to strictly
903 # based on expiration, and and add some flows.
904 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
905 ovs-ofctl add-flows br0 - <<EOF
906 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
907 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
908 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
909 EOF
910 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
911  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
912  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
913  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
914  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
915  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
916  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
917  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
918 NXST_FLOW reply:
919 ])
920 # Adding another flow will cause the one that expires soonest overall
921 # to be evicted.
922 AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
923 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
924  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
925  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
926  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
927  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
928  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
929  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
930  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
931 NXST_FLOW reply:
932 ])
933 # Reducing the flow limit also causes the flows that expire soonest
934 # overall to be evicted.
935 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
936 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
937  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
938  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
939  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
940  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
941 NXST_FLOW reply:
942 ])
943 OVS_VSWITCHD_STOP
944 AT_CLEANUP
945
946 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.2)])
947 OVS_VSWITCHD_START
948 # Configure a maximum of 4 flows.
949 AT_CHECK(
950   [ovs-vsctl \
951      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
952                                    overflow-policy=evict \
953                                    groups='"NXM_OF_IN_PORT[[]]"' \
954      -- set bridge br0 flow_tables:0=@t0 \
955    | ${PERL} $srcdir/uuidfilt.pl],
956   [0], [<0>
957 ])
958 # Add 4 flows.
959 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
960 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
961 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
962 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
963 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
964 EOF
965 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
966  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
967  idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
968  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
969  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
970 OFPST_FLOW reply (OF1.2):
971 ])
972 # Adding another flow will cause the one that expires soonest within
973 # the largest group (those with in_port=1) to be evicted.  In this
974 # case this is not the same as the one that expires soonest overall
975 # (which is what makes the test interesting):
976 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
977 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
978  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
979  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
980  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
981  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
982 OFPST_FLOW reply (OF1.2):
983 ])
984 # Enlarge the flow limit, change the eviction policy back to strictly
985 # based on expiration, and and add some flows.
986 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
987 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
988 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
989 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
990 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
991 EOF
992 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
993  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
994  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
995  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
996  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
997  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
998  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
999  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1000 OFPST_FLOW reply (OF1.2):
1001 ])
1002 # Adding another flow will cause the one that expires soonest overall
1003 # to be evicted.
1004 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
1005 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1006  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1007  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1008  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
1009  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1010  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1011  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1012  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1013 OFPST_FLOW reply (OF1.2):
1014 ])
1015 # Reducing the flow limit also causes the flows that expire soonest
1016 # overall to be evicted.
1017 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
1018 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1019  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1020  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1021  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1022  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1023 OFPST_FLOW reply (OF1.2):
1024 ])
1025 OVS_VSWITCHD_STOP
1026 AT_CLEANUP
1027
1028 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.0)])
1029 OVS_VSWITCHD_START
1030 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
1031 check_async () {
1032     printf '\n\n--- check_async %d ---\n\n\n' $1
1033     shift
1034
1035     ovs-appctl -t ovs-ofctl ofctl/barrier
1036     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1037     : > expout
1038
1039     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1040     ovs-ofctl -v packet-out br0 controller controller '0001020304050010203040501234'
1041     if test X"$1" = X"OFPR_ACTION"; then shift;
1042         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
1043 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"
1044     fi
1045
1046     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1047     ovs-ofctl -v packet-out br0 controller 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1048     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1049         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via no_match) data_len=14 (unbuffered)
1050 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"
1051     fi
1052
1053     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1054     ovs-ofctl packet-out br0 controller dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1055     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1056         echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=CONTROLLER (via invalid_ttl) data_len=76 (unbuffered)
1057 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"
1058     fi
1059
1060     # OFPT_PORT_STATUS, OFPPR_ADD
1061     ovs-vsctl add-port br0 test -- set Interface test type=dummy ofport_request=1
1062     if test X"$1" = X"OFPPR_ADD"; then shift;
1063         echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
1064      config:     PORT_DOWN
1065      state:      LINK_DOWN
1066      speed: 0 Mbps now, 0 Mbps max"
1067     fi
1068
1069     # OFPT_PORT_STATUS, OFPPR_DELETE
1070     ovs-vsctl del-port br0 test
1071     if test X"$1" = X"OFPPR_DELETE"; then shift;
1072         echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
1073      config:     PORT_DOWN
1074      state:      LINK_DOWN
1075      speed: 0 Mbps now, 0 Mbps max"
1076     fi
1077
1078     # OFPT_FLOW_REMOVED, OFPRR_DELETE
1079     ovs-ofctl add-flow br0 send_flow_rem,actions=drop
1080     ovs-ofctl --strict del-flows br0 ''
1081     if test X"$1" = X"OFPRR_DELETE"; then shift;
1082         echo >>expout "OFPT_FLOW_REMOVED:  reason=delete"
1083     fi
1084     AT_FAIL_IF([test X"$1" != X])
1085
1086     ovs-appctl -t ovs-ofctl ofctl/barrier
1087     echo >>expout "OFPT_BARRIER_REPLY:"
1088
1089     AT_CHECK(
1090       [[sed '
1091 s/ (xid=0x[0-9a-fA-F]*)//
1092 s/ *duration.*//
1093 s/00:0.$/00:0x/' < monitor.log]],
1094       [0], [expout])
1095 }
1096
1097 # It's a service connection so initially there should be no async messages.
1098 check_async 1
1099
1100 # Set miss_send_len to 128, turning on packet-ins for our service connection.
1101 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
1102 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1103
1104 # Set miss_send_len to 128 and enable invalid_ttl.
1105 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
1106 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1107
1108 # Become slave, which should disable everything except port status.
1109 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
1110 check_async 4 OFPPR_ADD OFPPR_DELETE
1111
1112 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
1113 ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
1114 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1115
1116 # Set controller ID 123.
1117 ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
1118 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1119
1120 # Restore controller ID 0.
1121 ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
1122
1123 # Become master.
1124 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
1125 check_async 7 OFPR_ACTION OFPPR_ADD
1126
1127 ovs-appctl -t ovs-ofctl exit
1128 OVS_VSWITCHD_STOP
1129 AT_CLEANUP
1130
1131 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.2)])
1132 OVS_VSWITCHD_START
1133 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1134 check_async () {
1135     printf '\n\n--- check_async %d ---\n\n\n' $1
1136     INDEX=$1
1137     shift
1138
1139     ovs-appctl -t ovs-ofctl ofctl/barrier
1140     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1141     : > expout
1142
1143     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1144     ovs-ofctl -O OpenFlow12 -v packet-out br0 none controller '0001020304050010203040501234'
1145     if test X"$1" = X"OFPR_ACTION"; then shift;
1146         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1147 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"
1148     fi
1149
1150     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1151     ovs-ofctl -O OpenFlow12 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1152     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1153         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
1154 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"
1155     fi
1156
1157     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1158     ovs-ofctl -O OpenFlow12 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1159     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1160         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
1161 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"
1162     fi
1163
1164     # OFPT_PORT_STATUS, OFPPR_ADD
1165     ovs-vsctl add-port br0 test -- set Interface test type=dummy
1166     if test X"$1" = X"OFPPR_ADD"; then shift;
1167         echo >>expout "OFPT_PORT_STATUS (OF1.2): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1168      config:     PORT_DOWN
1169      state:      LINK_DOWN
1170      speed: 0 Mbps now, 0 Mbps max"
1171     fi
1172
1173     # OFPT_PORT_STATUS, OFPPR_DELETE
1174     ovs-vsctl del-port br0 test
1175     if test X"$1" = X"OFPPR_DELETE"; then shift;
1176         echo >>expout "OFPT_PORT_STATUS (OF1.2): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1177      config:     PORT_DOWN
1178      state:      LINK_DOWN
1179      speed: 0 Mbps now, 0 Mbps max"
1180     fi
1181
1182     # OFPT_FLOW_REMOVED, OFPRR_DELETE
1183     ovs-ofctl -O OpenFlow12 add-flow br0 send_flow_rem,actions=drop
1184     ovs-ofctl -O OpenFlow12 --strict del-flows br0 ''
1185     if test X"$1" = X"OFPRR_DELETE"; then shift;
1186         echo >>expout "OFPT_FLOW_REMOVED (OF1.2):  reason=delete table_id=0"
1187     fi
1188     AT_FAIL_IF([test X"$1" != X])
1189
1190     ovs-appctl -t ovs-ofctl ofctl/barrier
1191     echo >>expout "OFPT_BARRIER_REPLY (OF1.2):"
1192
1193     AT_CHECK(
1194       [[sed '
1195 s/ (xid=0x[0-9a-fA-F]*)//
1196 s/ *duration.*//
1197 s/00:0.$/00:0x/' < monitor.log]],
1198       [0], [expout])
1199 }
1200
1201 # It's a service connection so initially there should be no async messages.
1202 check_async 1
1203
1204 # Set miss_send_len to 128, turning on packet-ins for our service connection.
1205 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
1206 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1207
1208 # Set miss_send_len to 128 and enable invalid_ttl.
1209 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700040080
1210 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1211
1212 # Become slave (OF 1.2), which should disable everything except port status.
1213 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000200000003000000000000000000000001
1214 check_async 4 OFPPR_ADD OFPPR_DELETE
1215
1216 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
1217 ovs-appctl -t ovs-ofctl ofctl/send 03040028000000020000232000000013000000020000000500000005000000020000000200000005
1218 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1219
1220 # Set controller ID 123.
1221 ovs-appctl -t ovs-ofctl ofctl/send 03040018000000030000232000000014000000000000007b
1222 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1223
1224 # Restore controller ID 0.
1225 ovs-appctl -t ovs-ofctl ofctl/send 030400180000000300002320000000140000000000000000
1226
1227 # Become master (OF 1.2).
1228 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000400000002000000000000000000000002
1229 check_async 7 OFPR_ACTION OFPPR_ADD
1230
1231 ovs-appctl -t ovs-ofctl exit
1232 OVS_VSWITCHD_STOP
1233 AT_CLEANUP
1234
1235 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.3)])
1236 OVS_VSWITCHD_START
1237 AT_CHECK([ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile])
1238 check_async () {
1239     printf '\n\n--- check_async %d ---\n\n\n' $1
1240     INDEX=$1
1241     shift
1242
1243     ovs-appctl -t ovs-ofctl ofctl/barrier
1244     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1245     : > expout
1246
1247     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1248     ovs-ofctl -O OpenFlow13 -v packet-out br0 none controller '0001020304050010203040501234'
1249     if test X"$1" = X"OFPR_ACTION"; then shift;
1250         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1251 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"
1252     fi
1253
1254     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1255     ovs-ofctl -O OpenFlow13 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1256     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1257         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
1258 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"
1259     fi
1260
1261     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1262     ovs-ofctl -O OpenFlow13 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1263     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1264         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
1265 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"
1266     fi
1267
1268     # OFPT_PORT_STATUS, OFPPR_ADD
1269     ovs-vsctl add-port br0 test -- set Interface test type=dummy
1270     if test X"$1" = X"OFPPR_ADD"; then shift;
1271         echo >>expout "OFPT_PORT_STATUS (OF1.3): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1272      config:     PORT_DOWN
1273      state:      LINK_DOWN
1274      speed: 0 Mbps now, 0 Mbps max"
1275     fi
1276
1277     # OFPT_PORT_STATUS, OFPPR_DELETE
1278     ovs-vsctl del-port br0 test
1279     if test X"$1" = X"OFPPR_DELETE"; then shift;
1280         echo >>expout "OFPT_PORT_STATUS (OF1.3): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1281      config:     PORT_DOWN
1282      state:      LINK_DOWN
1283      speed: 0 Mbps now, 0 Mbps max"
1284     fi
1285
1286     # OFPT_FLOW_REMOVED, OFPRR_DELETE
1287     ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=drop
1288     ovs-ofctl -O OpenFlow13 --strict del-flows br0 ''
1289     if test X"$1" = X"OFPRR_DELETE"; then shift;
1290         echo >>expout "OFPT_FLOW_REMOVED (OF1.3):  reason=delete table_id=0"
1291     fi
1292     AT_FAIL_IF([test X"$1" != X])
1293
1294     ovs-appctl -t ovs-ofctl ofctl/barrier
1295     echo >>expout "OFPT_BARRIER_REPLY (OF1.3):"
1296
1297     AT_CHECK(
1298       [[sed '
1299 s/ (xid=0x[0-9a-fA-F]*)//
1300 s/ *duration.*//
1301 s/00:0.$/00:0x/' < monitor.log]],
1302       [0], [expout])
1303 }
1304
1305 # It's a service connection so initially there should be no async messages.
1306 check_async 1
1307
1308 # Set miss_send_len to 128, turning on packet-ins for our service connection.
1309 ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
1310 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1311
1312 # Become slave (OF 1.3), which should disable everything except port status.
1313 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000200000003000000000000000000000001
1314 check_async 3 OFPPR_ADD OFPPR_DELETE
1315
1316 # Use OF 1.3 OFPT_SET_ASYNC to enable a patchwork of asynchronous messages.
1317 ovs-appctl -t ovs-ofctl ofctl/send 041c002000000002000000020000000500000005000000020000000200000005
1318 check_async 4 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1319
1320 # Set controller ID 123.
1321 ovs-appctl -t ovs-ofctl ofctl/send 04040018000000030000232000000014000000000000007b
1322 check_async 5 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1323
1324 # Restore controller ID 0.
1325 ovs-appctl -t ovs-ofctl ofctl/send 040400180000000300002320000000140000000000000000
1326
1327 # Become master (OF 1.3).
1328 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000400000002000000000000000000000002
1329 check_async 6 OFPR_ACTION OFPPR_ADD
1330
1331 ovs-appctl -t ovs-ofctl exit
1332 OVS_VSWITCHD_STOP
1333 AT_CLEANUP
1334
1335 dnl This test checks that the role request/response messaging works
1336 dnl and that generation_id is handled properly.
1337 AT_SETUP([ofproto - controller role (OpenFlow 1.2)])
1338 OVS_VSWITCHD_START
1339 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1340
1341 ovs-appctl -t ovs-ofctl ofctl/barrier
1342 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1343 : > expout
1344
1345 # find out current role
1346 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000200000000000000000000000000000000
1347 echo >>expout "send: OFPT_ROLE_REQUEST (OF1.2) (xid=0x2): role=nochange"
1348 echo >>expout "OFPT_ROLE_REPLY (OF1.2) (xid=0x2): role=equal"
1349
1350 # Become slave (generation_id is initially undefined, so 2^63+2 should not be stale)
1351 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000300000003000000008000000000000002
1352 echo >>expout "send: OFPT_ROLE_REQUEST (OF1.2) (xid=0x3): role=slave generation_id=9223372036854775810"
1353 echo >>expout "OFPT_ROLE_REPLY (OF1.2) (xid=0x3): role=slave generation_id=9223372036854775810"
1354
1355 # Try to become the master using a stale generation ID
1356 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000400000002000000000000000000000002
1357 echo >>expout "send: OFPT_ROLE_REQUEST (OF1.2) (xid=0x4): role=master generation_id=2"
1358 echo >>expout "OFPT_ERROR (OF1.2) (xid=0x4): OFPRRFC_STALE"
1359 echo >>expout "OFPT_ROLE_REQUEST (OF1.2) (xid=0x4): role=master generation_id=2"
1360
1361 # Become master using a valid generation ID
1362 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000500000002000000000000000000000001
1363 echo >>expout "send: OFPT_ROLE_REQUEST (OF1.2) (xid=0x5): role=master generation_id=1"
1364 echo >>expout "OFPT_ROLE_REPLY (OF1.2) (xid=0x5): role=master generation_id=1"
1365 ovs-appctl -t ovs-ofctl ofctl/barrier
1366 echo >>expout "OFPT_BARRIER_REPLY (OF1.2) (xid=0x3):"
1367
1368 AT_CHECK([cat monitor.log], [0], [expout])
1369
1370 ovs-appctl -t ovs-ofctl exit
1371 OVS_VSWITCHD_STOP
1372 AT_CLEANUP
1373
1374 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
1375 dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
1376 dnl controllers despite the spec) as meaning a packet that was generated
1377 dnl by the controller.
1378 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.0)])
1379 OVS_VSWITCHD_START
1380
1381 # Start a monitor listening for packet-ins.
1382 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
1383 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
1384 ovs-appctl -t ovs-ofctl ofctl/barrier
1385 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1386 AT_CAPTURE_FILE([monitor.log])
1387
1388 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
1389 AT_CHECK([ovs-ofctl packet-out br0 none controller '0001020304050010203040501234'])
1390 AT_CHECK([ovs-ofctl packet-out br0 controller controller '0001020304050010203040505678'])
1391
1392 # Stop the monitor and check its output.
1393 ovs-appctl -t ovs-ofctl ofctl/barrier
1394 ovs-appctl -t ovs-ofctl exit
1395
1396 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
1397 OFPT_PACKET_IN: total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1398 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
1399 OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
1400 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
1401 OFPT_BARRIER_REPLY:
1402 ])
1403
1404 OVS_VSWITCHD_STOP
1405 AT_CLEANUP
1406
1407 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
1408 dnl specified by OpenFlow 1.2) and OFPP_CONTROLLER (used by some
1409 dnl controllers despite the spec) as meaning a packet that was generated
1410 dnl by the controller.
1411 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.2)])
1412 OVS_VSWITCHD_START
1413
1414 # Start a monitor listening for packet-ins.
1415 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1416 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
1417 ovs-appctl -t ovs-ofctl ofctl/barrier
1418 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1419 AT_CAPTURE_FILE([monitor.log])
1420
1421 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
1422 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none controller '0001020304050010203040501234'])
1423 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 4294967293 controller '0001020304050010203040505678'])
1424
1425 # Stop the monitor and check its output.
1426 ovs-appctl -t ovs-ofctl ofctl/barrier
1427 ovs-appctl -t ovs-ofctl exit
1428
1429 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
1430 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1431 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
1432 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
1433 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
1434 OFPT_BARRIER_REPLY (OF1.2):
1435 ])
1436
1437 OVS_VSWITCHD_STOP
1438 AT_CLEANUP
1439
1440 dnl This test checks that metadata is encoded in packet_in structures,
1441 dnl supported by NXAST.
1442 AT_SETUP([ofproto - packet-out with metadata (NXM)])
1443 OVS_VSWITCHD_START
1444
1445 # Start a monitor listening for packet-ins.
1446 AT_CHECK([ovs-ofctl -P nxm monitor br0 --detach --no-chdir --pidfile])
1447 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
1448 ovs-appctl -t ovs-ofctl ofctl/barrier
1449 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1450 AT_CAPTURE_FILE([monitor.log])
1451
1452 # Send a packet-out with a load action to set some metadata, and forward to controller
1453 AT_CHECK([ovs-ofctl packet-out br0 controller 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), controller' '0001020304050010203040501234'])
1454
1455 # Stop the monitor and check its output.
1456 ovs-appctl -t ovs-ofctl ofctl/barrier
1457 ovs-appctl -t ovs-ofctl exit
1458
1459 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
1460 NXT_PACKET_IN: total_len=14 in_port=CONTROLLER metadata=0xfafafafa5a5a5a5a (via action) data_len=14 (unbuffered)
1461 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
1462 OFPT_BARRIER_REPLY:
1463 ])
1464
1465 OVS_VSWITCHD_STOP
1466 AT_CLEANUP
1467
1468 dnl This test checks that metadata is encoded in packet_in structures,
1469 dnl supported by NXAST.
1470 AT_SETUP([ofproto - packet-out with metadata (OpenFlow 1.2)])
1471 OVS_VSWITCHD_START
1472
1473 # Start a monitor listening for packet-ins.
1474 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1475 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
1476 ovs-appctl -t ovs-ofctl ofctl/barrier
1477 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1478 AT_CAPTURE_FILE([monitor.log])
1479
1480 # Send a packet-out with a load action to set some metadata, and forward to controller
1481 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), controller' '0001020304050010203040501234'])
1482
1483 # Stop the monitor and check its output.
1484 ovs-appctl -t ovs-ofctl ofctl/barrier
1485 ovs-appctl -t ovs-ofctl exit
1486
1487 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
1488 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY metadata=0xfafafafa5a5a5a5a (via action) data_len=14 (unbuffered)
1489 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
1490 OFPT_BARRIER_REPLY (OF1.2):
1491 ])
1492
1493 OVS_VSWITCHD_STOP
1494 AT_CLEANUP
1495
1496 dnl This test checks that tunnel metadata is encoded in packet_in structures.
1497 AT_SETUP([ofproto - packet-out with tunnel metadata (OpenFlow 1.2)])
1498 OVS_VSWITCHD_START
1499
1500 # Start a monitor listening for packet-ins.
1501 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1502 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
1503 ovs-appctl -t ovs-ofctl ofctl/barrier
1504 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1505 AT_CAPTURE_FILE([monitor.log])
1506
1507 # Send a packet-out with set field actions to set some tunnel metadata, and forward to controller
1508 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none 'set_field:127.0.0.1->tun_src,set_field:0x01020304->tun_id,set_field:192.168.0.1->tun_dst, controller' '0001020304050010203040501234'])
1509
1510 # Stop the monitor and check its output.
1511 ovs-appctl -t ovs-ofctl ofctl/barrier
1512 ovs-appctl -t ovs-ofctl exit
1513
1514 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
1515 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY tun_id=0x1020304 tun_src=127.0.0.1 tun_dst=192.168.0.1 (via action) data_len=14 (unbuffered)
1516 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
1517 OFPT_BARRIER_REPLY (OF1.2):
1518 ])
1519
1520 OVS_VSWITCHD_STOP
1521 AT_CLEANUP
1522
1523 AT_SETUP([ofproto - flow monitoring])
1524 AT_KEYWORDS([monitor])
1525 OVS_VSWITCHD_START
1526
1527 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
1528
1529 # Start a monitor watching the flow table and check the initial reply.
1530 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
1531 AT_CAPTURE_FILE([monitor.log])
1532 ovs-appctl -t ovs-ofctl ofctl/barrier
1533 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
1534   [NXST_FLOW_MONITOR reply:
1535  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
1536 OFPT_BARRIER_REPLY:
1537 ])
1538
1539 # Add, delete, and modify some flows and check the updates.
1540 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1541 ovs-ofctl add-flow br0 in_port=0,dl_vlan=124,actions=output:2
1542 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:5
1543 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=0,actions=output:6
1544 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=1,actions=output:7
1545 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:8
1546 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=0,actions=output:9
1547 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=1,actions=output:10
1548 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,actions=output:11
1549 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=0,actions=output:12
1550 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=1,actions=output:13
1551 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,actions=output:14
1552 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:15
1553 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:16
1554 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:17
1555 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:18
1556 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:19
1557 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:20
1558 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=0,actions=output:21
1559 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=1,actions=output:22
1560 ovs-ofctl add-flow br0 in_port=0,actions=output:23
1561 ovs-ofctl mod-flows br0 cookie=5,dl_vlan=123,actions=output:3
1562 ovs-ofctl del-flows br0 dl_vlan=123
1563 ovs-ofctl del-flows br0
1564 ovs-appctl -t ovs-ofctl ofctl/barrier
1565 sort='
1566     # Sorts groups of lines that start with a space, without moving them
1567     # past the nearest line that does not start with a space.
1568     use warnings;
1569     use strict;
1570     my @buffer = ();
1571     while (<STDIN>) {
1572         if (/^ /) {
1573             push(@buffer, $_);
1574         } else {
1575             print $_ foreach sort(@buffer);
1576             print $_;
1577             @buffer = ();
1578         }
1579     }
1580     print $_ foreach sort(@buffer);
1581 '
1582 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | ${PERL} -e "$sort"], [0],
1583 [NXST_FLOW_MONITOR reply (xid=0x0):
1584  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
1585 NXST_FLOW_MONITOR reply (xid=0x0):
1586  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:5
1587 NXST_FLOW_MONITOR reply (xid=0x0):
1588  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:6
1589 NXST_FLOW_MONITOR reply (xid=0x0):
1590  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:7
1591 NXST_FLOW_MONITOR reply (xid=0x0):
1592  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:8
1593 NXST_FLOW_MONITOR reply (xid=0x0):
1594  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:9
1595 NXST_FLOW_MONITOR reply (xid=0x0):
1596  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:10
1597 NXST_FLOW_MONITOR reply (xid=0x0):
1598  event=ADDED table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
1599 NXST_FLOW_MONITOR reply (xid=0x0):
1600  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
1601 NXST_FLOW_MONITOR reply (xid=0x0):
1602  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
1603 NXST_FLOW_MONITOR reply (xid=0x0):
1604  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
1605 NXST_FLOW_MONITOR reply (xid=0x0):
1606  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:15
1607 NXST_FLOW_MONITOR reply (xid=0x0):
1608  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:16
1609 NXST_FLOW_MONITOR reply (xid=0x0):
1610  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:17
1611 NXST_FLOW_MONITOR reply (xid=0x0):
1612  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
1613 NXST_FLOW_MONITOR reply (xid=0x0):
1614  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
1615 NXST_FLOW_MONITOR reply (xid=0x0):
1616  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
1617 NXST_FLOW_MONITOR reply (xid=0x0):
1618  event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
1619 NXST_FLOW_MONITOR reply (xid=0x0):
1620  event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
1621 NXST_FLOW_MONITOR reply (xid=0x0):
1622  event=ADDED table=0 cookie=0 in_port=0 actions=output:23
1623 NXST_FLOW_MONITOR reply (xid=0x0):
1624  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
1625  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
1626  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
1627 NXST_FLOW_MONITOR reply (xid=0x0):
1628  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
1629  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
1630  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
1631 NXST_FLOW_MONITOR reply (xid=0x0):
1632  event=DELETED reason=delete table=0 cookie=0 in_port=0 actions=output:23
1633  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
1634  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
1635  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
1636  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
1637  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
1638  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
1639  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
1640  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
1641  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
1642  event=DELETED reason=delete table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
1643 OFPT_BARRIER_REPLY:
1644 ])
1645
1646 # Check that our own changes are reported as abbreviations.
1647 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1648 ovs-ofctl add-flow br0 in_port=1,actions=output:2
1649 ovs-ofctl add-flow br0 in_port=2,actions=output:1
1650 ovs-appctl -t ovs-ofctl ofctl/barrier
1651 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
1652 ovs-appctl -t ovs-ofctl ofctl/barrier
1653 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
1654 ])
1655 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
1656 [NXST_FLOW_MONITOR reply (xid=0x0):
1657  event=ADDED table=0 cookie=0 in_port=1 actions=output:2
1658 NXST_FLOW_MONITOR reply (xid=0x0):
1659  event=ADDED table=0 cookie=0 in_port=2 actions=output:1
1660 OFPT_BARRIER_REPLY:
1661 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
1662 NXST_FLOW_MONITOR reply (xid=0x0):
1663  event=ABBREV xid=0x12345678
1664 OFPT_BARRIER_REPLY:
1665 ])
1666
1667 ovs-appctl -t ovs-ofctl exit
1668 OVS_VSWITCHD_STOP
1669 AT_CLEANUP
1670
1671 AT_SETUP([ofproto - flow monitoring pause and resume])
1672 AT_KEYWORDS([monitor])
1673
1674 # The maximum socket receive buffer size is important for this test, which
1675 # tests behavior when the receive buffer overflows.
1676 if test -e /proc/sys/net/core/rmem_max; then
1677     # Linux
1678     rmem_max=`cat /proc/sys/net/core/rmem_max`
1679 elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
1680     : # FreeBSD, NetBSD
1681 else
1682     # Don't know how to get maximum socket receive buffer on this OS
1683     AT_SKIP_IF([:])
1684 fi
1685 # Calculate the total amount of queuing: rmem_max in the kernel, 128 kB
1686 # in ofproto sending userspace (see ofmonitor_flush() in connmgr.c).
1687 queue_size=`expr $rmem_max + 128 \* 1024`
1688 echo rmem_max=$rmem_max queue_size=$queue_size
1689
1690 # Each flow update message takes up at least 48 bytes of space in queues
1691 # and in practice more than that.
1692 n_msgs=`expr $queue_size / 48`
1693 echo n_msgs=$n_msgs
1694
1695 OVS_VSWITCHD_START
1696
1697 # Start a monitor watching the flow table, then make it block.
1698 ON_EXIT([kill `cat ovs-ofctl.pid`])
1699 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
1700 AT_CAPTURE_FILE([monitor.log])
1701 ovs-appctl -t ovs-ofctl ofctl/block
1702
1703 # Add $n_msgs flows.
1704 (echo "in_port=2,actions=output:2"
1705 ${PERL} -e '
1706     for ($i = 0; $i < '$n_msgs'; $i++) {
1707         print "cookie=1,reg1=$i,actions=drop\n";
1708     }
1709 ') > flows.txt
1710 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
1711 # Check that multipart flow dumps work properly:
1712 AT_CHECK([ovs-ofctl diff-flows br0 flows.txt])
1713 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,cookie=3,actions=drop])
1714 AT_CHECK([ovs-ofctl mod-flows br0 in_port=2,cookie=2,actions=output:2])
1715 AT_CHECK([ovs-ofctl del-flows br0 cookie=1/-1])
1716
1717 ovs-appctl -t ovs-ofctl ofctl/unblock
1718 ovs-appctl -t ovs-ofctl ofctl/barrier
1719
1720 ovs-appctl -t ovs-ofctl exit
1721
1722 # Check that the flow monitor reported the same number of flows
1723 # added and deleted, but fewer than we actually added and deleted.
1724 adds=`grep -c 'ADDED.*reg1=' monitor.log`
1725 deletes=`grep -c 'DELETED.*reg1=' monitor.log`
1726 echo adds=$adds deletes=$deletes
1727 AT_CHECK([test $adds -gt 100 && test $adds -lt $n_msgs])
1728 AT_CHECK([test $adds = $deletes])
1729
1730 # Check that the flow monitor reported everything in the expected order:
1731 #
1732 #     event=ADDED table=0 cookie=0x1 reg1=0x22
1733 # ...
1734 #    NXT_FLOW_MONITOR_PAUSED:
1735 # ...
1736 #     event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1737 # ...
1738 #     event=ADDED table=0 cookie=0x3 in_port=1
1739 #     event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
1740 #    NXT_FLOW_MONITOR_RESUMED:
1741 #
1742 # except that, between the PAUSED and RESUMED, the order of the ADDED
1743 # and MODIFIED lines lines depends on hash order, that is, it varies
1744 # as we change the hash function or change architecture.  Therefore,
1745 # we use a couple of tests below to accept both orders.
1746 AT_CHECK([ofctl_strip < monitor.log | sed -n -e '
1747 /reg1=0x22$/p
1748 /cookie=0x[[23]]/p
1749 /NXT_FLOW_MONITOR_PAUSED:/p
1750 /NXT_FLOW_MONITOR_RESUMED:/p
1751 ' > monitor.log.subset])
1752 AT_CHECK([grep -v MODIFIED monitor.log.subset], [0], [dnl
1753  event=ADDED table=0 cookie=0x1 reg1=0x22
1754 NXT_FLOW_MONITOR_PAUSED:
1755  event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1756  event=ADDED table=0 cookie=0x3 in_port=1
1757 NXT_FLOW_MONITOR_RESUMED:
1758 ])
1759 AT_CHECK([grep -v ADDED monitor.log.subset], [0], [dnl
1760 NXT_FLOW_MONITOR_PAUSED:
1761  event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1762  event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
1763 NXT_FLOW_MONITOR_RESUMED:
1764 ])
1765
1766 OVS_VSWITCHD_STOP
1767 AT_CLEANUP