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