Implement OpenFlow 1.4 port statistics.
[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 - handling messages with bad version])
10 OVS_VSWITCHD_START
11
12 # Start a monitor running OpenFlow 1.0, then send the switch an OF1.1 features
13 # request
14 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
15 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
16 AT_CAPTURE_FILE([monitor.log])
17 ovs-appctl -t ovs-ofctl ofctl/send 0205000801234567
18 ovs-appctl -t ovs-ofctl ofctl/barrier
19 ovs-appctl -t ovs-ofctl exit
20
21 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//
22 /ECHO/d' monitor.log], [0], [dnl
23 send: OFPT_FEATURES_REQUEST (OF1.1):
24 OFPT_ERROR (OF1.1): OFPBRC_BAD_VERSION
25 OFPT_FEATURES_REQUEST (OF1.1):
26 OFPT_BARRIER_REPLY:
27 ])
28
29 OVS_VSWITCHD_STOP(["/received OpenFlow version 0x02 != expected 01/d"])
30 AT_CLEANUP
31
32 AT_SETUP([ofproto - feature request, config request])
33 OVS_VSWITCHD_START
34 AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
35 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
36 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
37 n_tables:254, n_buffers:256
38 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
39 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
40  LOCAL(br0): addr:aa:55:aa:55:00:00
41      config:     PORT_DOWN
42      state:      LINK_DOWN
43      speed: 0 Mbps now, 0 Mbps max
44 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
45 ])
46 OVS_VSWITCHD_STOP
47 AT_CLEANUP
48
49 AT_SETUP([ofproto - set OpenFlow port number])
50 OVS_VSWITCHD_START(
51        [add-port br0 p1 -- set Interface p1 type=dummy --\
52         add-port br0 p2 -- set Interface p2 type=dummy ofport_request=99])
53 AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
54 AT_CHECK([[sed '
55 s/ (xid=0x[0-9a-fA-F]*)//
56 s/00:0.$/00:0x/' < stdout]],
57       [0], [dnl
58 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
59 n_tables:254, n_buffers:256
60 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
61 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
62  1(p1): addr:aa:55:aa:55:00:0x
63      config:     PORT_DOWN
64      state:      LINK_DOWN
65      speed: 0 Mbps now, 0 Mbps max
66  99(p2): addr:aa:55:aa:55:00:0x
67      config:     PORT_DOWN
68      state:      LINK_DOWN
69      speed: 0 Mbps now, 0 Mbps max
70  LOCAL(br0): addr:aa:55:aa:55:00:0x
71      config:     PORT_DOWN
72      state:      LINK_DOWN
73      speed: 0 Mbps now, 0 Mbps max
74 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
75 ])
76
77 OVS_VSWITCHD_STOP
78 AT_CLEANUP
79
80 dnl This is really bare-bones.
81 dnl It at least checks request and reply serialization and deserialization.
82 AT_SETUP([ofproto - port stats - (OpenFlow 1.0)])
83 OVS_VSWITCHD_START
84 AT_CHECK([ovs-ofctl -vwarn dump-ports br0], [0], [stdout])
85 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
86 OFPST_PORT reply: 1 ports
87   port LOCAL: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
88            tx pkts=0, bytes=0, drop=0, errs=0, coll=0
89 ])
90 OVS_VSWITCHD_STOP
91 AT_CLEANUP
92
93 AT_SETUP([ofproto - port stats - (OpenFlow 1.2)])
94 OVS_VSWITCHD_START
95 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn dump-ports br0], [0], [stdout])
96 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
97 OFPST_PORT reply (OF1.2): 1 ports
98   port LOCAL: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
99            tx pkts=0, bytes=0, drop=0, errs=0, coll=0
100 ])
101 OVS_VSWITCHD_STOP
102 AT_CLEANUP
103
104 AT_SETUP([ofproto - port stats - (OpenFlow 1.4)])
105 OVS_VSWITCHD_START
106 AT_CHECK([ovs-ofctl -O OpenFlow14 -vwarn dump-ports br0], [0], [stdout])
107 AT_CHECK([STRIP_XIDS stdout | sed 's/duration=[[0-9.]]*s/duration=?s/'],
108   [0], [dnl
109 OFPST_PORT reply (OF1.4): 1 ports
110   port LOCAL: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
111            tx pkts=0, bytes=0, drop=0, errs=0, coll=0
112            duration=?s
113 ])
114 OVS_VSWITCHD_STOP
115 AT_CLEANUP
116
117 dnl This is really bare-bones.
118 dnl It at least checks request and reply serialization and deserialization.
119 AT_SETUP([ofproto - port-desc stats (OpenFlow 1.0)])
120 OVS_VSWITCHD_START
121 AT_CHECK([ovs-ofctl -vwarn dump-ports-desc br0], [0], [stdout])
122 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
123 OFPST_PORT_DESC reply:
124  LOCAL(br0): addr:aa:55:aa:55:00:00
125      config:     PORT_DOWN
126      state:      LINK_DOWN
127      speed: 0 Mbps now, 0 Mbps max
128 ])
129 OVS_VSWITCHD_STOP
130 AT_CLEANUP
131
132 dnl This is really bare-bones.
133 dnl It at least checks request and reply serialization and deserialization.
134 AT_SETUP([ofproto - port-desc stats (OpenFlow 1.2)])
135 OVS_VSWITCHD_START
136 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn dump-ports-desc br0], [0], [stdout])
137 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
138 OFPST_PORT_DESC reply (OF1.2):
139  LOCAL(br0): addr:aa:55:aa:55:00:00
140      config:     PORT_DOWN
141      state:      LINK_DOWN
142      speed: 0 Mbps now, 0 Mbps max
143 ])
144 OVS_VSWITCHD_STOP
145 AT_CLEANUP
146
147 dnl This is really bare-bones.
148 dnl It at least checks request and reply serialization and deserialization.
149 AT_SETUP([ofproto - queue stats - (OpenFlow 1.0)])
150 OVS_VSWITCHD_START
151 AT_CHECK([ovs-ofctl -vwarn queue-stats br0], [0], [stdout])
152 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
153 OFPST_QUEUE reply: 0 queues
154 ])
155 AT_CHECK([ovs-ofctl -vwarn queue-stats br0 ANY 5], [0],
156   [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_QUEUE
157 OFPST_QUEUE request (xid=0x2):port=ANY queue=5
158 ])
159 AT_CHECK([ovs-ofctl -vwarn queue-stats br0 10], [0],
160   [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_PORT
161 OFPST_QUEUE request (xid=0x2):port=10 queue=ALL
162 ])
163 OVS_VSWITCHD_STOP
164 AT_CLEANUP
165
166 AT_SETUP([ofproto - queue stats - (OpenFlow 1.2)])
167 OVS_VSWITCHD_START
168 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn queue-stats br0], [0], [stdout])
169 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
170 OFPST_QUEUE reply (OF1.2): 0 queues
171 ])
172 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn queue-stats br0 ALL 5], [0],
173   [OFPT_ERROR (OF1.2) (xid=0x2): OFPQOFC_BAD_QUEUE
174 OFPST_QUEUE request (OF1.2) (xid=0x2):port=ANY queue=5
175 ])
176 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn queue-stats br0 10], [0],
177   [OFPT_ERROR (OF1.2) (xid=0x2): OFPQOFC_BAD_PORT
178 OFPST_QUEUE request (OF1.2) (xid=0x2):port=10 queue=ALL
179 ])
180 OVS_VSWITCHD_STOP
181 AT_CLEANUP
182
183 dnl This is really bare-bones.
184 dnl It at least checks request and reply serialization and deserialization.
185 AT_SETUP([ofproto - queue configuration - (OpenFlow 1.0)])
186 OVS_VSWITCHD_START
187 ADD_OF_PORTS([br0], [1], [2])
188 AT_CHECK([ovs-ofctl queue-get-config br0 1], [0], [stdout])
189 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
190 OFPT_QUEUE_GET_CONFIG_REPLY: port=1
191 ])
192 AT_CHECK([ovs-ofctl queue-get-config br0 10], [0],
193   [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_PORT
194 OFPT_QUEUE_GET_CONFIG_REQUEST (xid=0x2): port=10
195 ])
196 OVS_VSWITCHD_STOP
197 AT_CLEANUP
198
199 AT_SETUP([ofproto - queue configuration - (OpenFlow 1.2)])
200 OVS_VSWITCHD_START
201 ADD_OF_PORTS([br0], [1], [2])
202 AT_CHECK([ovs-ofctl -O OpenFlow12 queue-get-config br0 1], [0], [stdout])
203 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
204 OFPT_QUEUE_GET_CONFIG_REPLY (OF1.2): port=1
205 ])
206 AT_CHECK([ovs-ofctl -O OpenFlow12 queue-get-config br0 10], [0],
207   [OFPT_ERROR (OF1.2) (xid=0x2): OFPQOFC_BAD_PORT
208 OFPT_QUEUE_GET_CONFIG_REQUEST (OF1.2) (xid=0x2): port=10
209 ])
210 OVS_VSWITCHD_STOP
211 AT_CLEANUP
212
213 dnl This is really bare-bones.
214 dnl It at least checks request and reply serialization and deserialization.
215 AT_SETUP([ofproto - del group])
216 OVS_VSWITCHD_START
217 AT_DATA([groups.txt], [dnl
218 group_id=1234,type=all,bucket=output:10
219 group_id=1235,type=all,bucket=output:10
220 ])
221 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-groups br0 groups.txt])
222 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
223 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
224 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
225 OFPST_GROUP_DESC reply (OF1.1):
226  group_id=1235,type=all,bucket=actions=output:10
227 ])
228 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
229 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
230 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
231 OFPST_GROUP_DESC reply (OF1.1):
232  group_id=1235,type=all,bucket=actions=output:10
233 ])
234 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0], [0])
235 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
236 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
237 OFPST_GROUP_DESC reply (OF1.1):
238 ])
239 OVS_VSWITCHD_STOP
240 AT_CLEANUP
241
242 dnl This is really bare-bones.
243 dnl It at least checks request and reply serialization and deserialization.
244 AT_SETUP([ofproto - del group deletes flows])
245 OVS_VSWITCHD_START
246 AT_DATA([groups.txt], [dnl
247 group_id=1234,type=all,bucket=output:10
248 group_id=1235,type=all,bucket=output:10
249 ])
250 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-groups br0 groups.txt])
251 AT_DATA([flows.txt], [dnl
252 tcp actions=group:1234
253 udp actions=group:1235
254 ])
255 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flows br0 flows.txt])
256 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
257 [0], [dnl
258  tcp actions=group:1234
259  udp actions=group:1235
260 OFPST_FLOW reply (OF1.1):
261 ])
262 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
263 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
264 [0], [dnl
265  udp actions=group:1235
266 OFPST_FLOW reply (OF1.1):
267 ])
268 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
269 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
270 [0], [dnl
271  udp actions=group:1235
272 OFPST_FLOW reply (OF1.1):
273 ])
274 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0])
275 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
276 [0], [dnl
277 OFPST_FLOW reply (OF1.1):
278 ])
279 OVS_VSWITCHD_STOP
280 AT_CLEANUP
281
282 dnl This is really bare-bones.
283 dnl It at least checks request and reply serialization and deserialization.
284 AT_SETUP([ofproto - flow mod checks group availability])
285 OVS_VSWITCHD_START
286 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 group_id=1234,type=all,bucket=output:10])
287 AT_DATA([flows.txt], [dnl
288 tcp actions=group:1234
289 udp actions=group:1235
290 ])
291 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=group:1234'])
292 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=group:1235'], [1], [], [stderr])
293
294 # The output should look like this:
295 #
296 # 00000000  02 0e 00 98 00 00 00 02-00 00 00 00 00 00 00 00 |................|
297 # 00000010  00 00 00 00 00 00 00 00-ff 00 00 00 00 00 80 00 |................|
298 # 00000020  ff ff ff ff ff ff ff ff-ff ff ff ff 00 00 00 00 |................|
299 # 00000030  00 00 00 58 00 00 00 00-00 00 03 d7 00 00 00 00 |...X............|
300 #
301 # This 'sed' command captures the error message but drops details.
302 AT_CHECK([sed '/truncated/d
303 /^000000.0/d' stderr | STRIP_XIDS], [0],
304   [OFPT_ERROR (OF1.1): OFPBAC_BAD_OUT_GROUP
305 OFPT_FLOW_MOD (OF1.1):
306 ])
307 OVS_VSWITCHD_STOP
308 AT_CLEANUP
309
310 dnl This is really bare-bones.
311 dnl It at least checks request and reply serialization and deserialization.
312 AT_SETUP([ofproto - group description])
313 OVS_VSWITCHD_START
314 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 group_id=1234,type=all,bucket=output:10], [0], [stdout])
315 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
316 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
317 OFPST_GROUP_DESC reply (OF1.1):
318  group_id=1234,type=all,bucket=actions=output:10
319 ])
320 OVS_VSWITCHD_STOP
321 AT_CLEANUP
322
323 dnl This is really bare-bones.
324 dnl It at least checks request and reply serialization and deserialization.
325 AT_SETUP([ofproto - group description])
326 OVS_VSWITCHD_START
327 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 group_id=1234,type=all,bucket=output:10])
328 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
329 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
330 OFPST_GROUP_DESC reply (OF1.1):
331  group_id=1234,type=all,bucket=actions=output:10
332 ])
333 OVS_VSWITCHD_STOP
334 AT_CLEANUP
335
336 dnl This is really bare-bones.
337 dnl It at least checks request and reply serialization and deserialization.
338 AT_SETUP([ofproto - group features])
339 OVS_VSWITCHD_START
340 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn dump-group-features br0], [0], [stdout])
341 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
342 OFPST_GROUP_FEATURES reply (OF1.2):
343  Group table:
344     Types:  0x0
345     Capabilities:  0x7
346 ])
347 OVS_VSWITCHD_STOP
348 AT_CLEANUP
349
350 dnl This is really bare-bones.
351 dnl It at least checks request and reply serialization and deserialization.
352 AT_SETUP([ofproto - group stats])
353 OVS_VSWITCHD_START
354 AT_DATA([groups.txt], [dnl
355 group_id=1234,type=all,bucket=output:10
356 group_id=1235,type=all,bucket=output:10
357 ])
358 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-groups br0 groups.txt])
359 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=group:1234'])
360 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-group-stats br0 group_id=1234], [0], [stdout])
361 AT_CHECK([STRIP_XIDS stdout | sort], [0], [dnl
362  group_id=1234,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
363 OFPST_GROUP reply (OF1.1):
364 ])
365 AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-group-stats br0], [0], [stdout])
366 AT_CHECK([STRIP_XIDS stdout | sort], [0], [dnl
367  group_id=1234,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
368  group_id=1235,ref_count=0,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
369 OFPST_GROUP reply (OF1.1):
370 ])
371 OVS_VSWITCHD_STOP
372 AT_CLEANUP
373
374 AT_SETUP([ofproto - mod-port (OpenFlow 1.0)])
375 OVS_VSWITCHD_START
376 for command_config_state in \
377     'up 0 0' \
378     'noflood NO_FLOOD 0' \
379     'down PORT_DOWN,NO_FLOOD LINK_DOWN' \
380     'flood PORT_DOWN LINK_DOWN' \
381     'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
382     'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
383     'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
384     'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
385     'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
386     'up NO_RECV 0' \
387     'receive 0 0'
388 do
389     set $command_config_state
390     command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
391     AT_CHECK([ovs-ofctl -vwarn mod-port br0 br0 $command])
392     AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
393     AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
394 OFPT_FEATURES_REPLY: dpid:fedcba9876543210
395 n_tables:254, n_buffers:256
396 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
397 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
398  LOCAL(br0): addr:aa:55:aa:55:00:00
399      config:     $config
400      state:      $state
401      speed: 0 Mbps now, 0 Mbps max
402 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
403 ])
404 done
405 OVS_VSWITCHD_STOP
406 AT_CLEANUP
407
408 AT_SETUP([ofproto - mod-port (OpenFlow 1.2)])
409 OVS_VSWITCHD_START
410 for command_config_state in \
411     'up 0 0' \
412     'down PORT_DOWN LINK_DOWN' \
413     'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
414     'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
415     'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
416     'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
417     'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
418     'up NO_RECV 0' \
419     'receive 0 0'
420 do
421     set $command_config_state
422     command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
423     AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn mod-port br0 br0 $command])
424     AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn show br0], [0], [stdout])
425     AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
426 OFPT_FEATURES_REPLY (OF1.2): dpid:fedcba9876543210
427 n_tables:254, n_buffers:256
428 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS
429  LOCAL(br0): addr:aa:55:aa:55:00:00
430      config:     $config
431      state:      $state
432      speed: 0 Mbps now, 0 Mbps max
433 OFPT_GET_CONFIG_REPLY (OF1.2): frags=normal miss_send_len=0
434 ])
435 done
436 OVS_VSWITCHD_STOP
437 AT_CLEANUP
438
439 AT_SETUP([ofproto - mod-port (OpenFlow 1.4)])
440 OVS_VSWITCHD_START
441 for command_config_state in \
442     'up 0 0' \
443     'down PORT_DOWN LINK_DOWN' \
444     'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
445     'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
446     'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
447     'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
448     'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
449     'up NO_RECV 0' \
450     'receive 0 0'
451 do
452     set $command_config_state
453     command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
454     AT_CHECK([ovs-ofctl -O OpenFlow14 -vwarn mod-port br0 br0 $command])
455     AT_CHECK([ovs-ofctl -O OpenFlow14 -vwarn show br0], [0], [stdout])
456     AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
457 OFPT_FEATURES_REPLY (OF1.4): dpid:fedcba9876543210
458 n_tables:254, n_buffers:256
459 capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS
460 OFPST_PORT_DESC reply (OF1.4):
461  LOCAL(br0): addr:aa:55:aa:55:00:00
462      config:     $config
463      state:      $state
464      speed: 0 Mbps now, 0 Mbps max
465 OFPT_GET_CONFIG_REPLY (OF1.4): frags=normal miss_send_len=0
466 ])
467 done
468 OVS_VSWITCHD_STOP
469 AT_CLEANUP
470
471 AT_SETUP([ofproto - basic flow_mod commands (NXM)])
472 OVS_VSWITCHD_START
473 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
474 ])
475 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl add-flows br0 -])
476 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=2])
477 AT_CHECK([ovs-ofctl -F nxm add-flow br0 table=1,in_port=4,actions=3])
478 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
479  in_port=1 actions=output:2
480  in_port=2 actions=output:1
481  table=1, in_port=4 actions=output:3
482 NXST_FLOW reply:
483 ])
484 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
485 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
486 ])
487 AT_CHECK([ovs-ofctl del-flows br0])
488 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
489 ])
490 OVS_VSWITCHD_STOP
491 AT_CLEANUP
492
493 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.0)])
494 OVS_VSWITCHD_START
495 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
496 ])
497 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -F openflow10 add-flows br0 -])
498 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 in_port=1,actions=2])
499 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 table=1,in_port=4,actions=3])
500 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
501  in_port=1 actions=output:2
502  in_port=2 actions=output:1
503  table=1, in_port=4 actions=output:3
504 OFPST_FLOW reply:
505 ])
506 AT_CHECK([ovs-ofctl -F openflow10 dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
507 OFPST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
508 ])
509 AT_CHECK([ovs-ofctl -F openflow10 del-flows br0])
510 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
511 ])
512 OVS_VSWITCHD_STOP
513 AT_CLEANUP
514
515 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.1)])
516 OVS_VSWITCHD_START
517 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.1):
518 ])
519 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -O OpenFlow11 add-flows br0 -])
520 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 in_port=1,actions=2])
521 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 table=1,in_port=4,actions=3])
522 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
523  in_port=1 actions=output:2
524  in_port=2 actions=output:1
525  table=1, in_port=4 actions=output:3
526 OFPST_FLOW reply (OF1.1):
527 ])
528 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
529 OFPST_AGGREGATE reply (OF1.1): packet_count=0 byte_count=0 flow_count=2
530 ])
531 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0])
532 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.1):
533  table=1, in_port=4 actions=output:3
534 ])
535 OVS_VSWITCHD_STOP
536 AT_CLEANUP
537
538 AT_SETUP([ofproto - flow_mod negative test (OpenFlow 1.1)])
539 OVS_VSWITCHD_START(
540   [set bridge br0 protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13])
541 AT_CHECK([ovs-ofctl add-flow -O OpenFlow11 br0 table=1,action=goto_table:2])
542
543 # The error message here actually comes from ovs-ofctl, not from ovs-vswitchd,
544 # but at least it's the same code in ofpacts_check() that issues the error.
545 AT_CHECK([ovs-ofctl add-flow -O OpenFlow11 br0 table=1,action=goto_table:1],
546   [1], [],
547   [ovs-ofctl: actions are invalid with specified match (OFPBRC_BAD_TABLE_ID)
548 ])
549 OVS_VSWITCHD_STOP
550 AT_CLEANUP
551
552 AT_SETUP([ofproto - set-field flow_mod commands (NXM)])
553 OVS_VSWITCHD_START
554 AT_CHECK([ovs-ofctl add-flow br0 ipv6,table=1,in_port=3,actions=drop])
555 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])
556 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
557  table=1, ipv6,in_port=3 actions=load:0xa6badbfffefe59fa->NXM_NX_IPV6_SRC[[0..63]],load:0xfe8001234567890a->NXM_NX_IPV6_SRC[[64..127]]
558 NXST_FLOW reply:
559 ])
560 OVS_VSWITCHD_STOP
561 AT_CLEANUP
562
563 AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.2)])
564 OVS_VSWITCHD_START
565 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.2):
566 ])
567 AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -O OpenFlow12 add-flows br0 -])
568 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=1,actions=2])
569 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 table=1,in_port=4,actions=3])
570 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
571  in_port=1 actions=output:2
572  in_port=2 actions=output:1
573  table=1, in_port=4 actions=output:3
574 OFPST_FLOW reply (OF1.2):
575 ])
576 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0])
577 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.2):
578 ])
579 OVS_VSWITCHD_STOP
580 AT_CLEANUP
581
582 AT_SETUP([ofproto - dump flows with cookie])
583 OVS_VSWITCHD_START
584 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
585 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
586 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
587 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
588  cookie=0x1, in_port=1 actions=output:1
589  cookie=0x2, in_port=2 actions=output:1
590  cookie=0x3, in_port=3 actions=output:1
591 NXST_FLOW reply:
592 ])
593 AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
594 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
595 ])
596 AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/-1 | ofctl_strip | sort], [0], [dnl
597  cookie=0x3, in_port=3 actions=output:1
598 NXST_FLOW reply:
599 ])
600 AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/-1 | STRIP_XIDS], [0], [dnl
601 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=1
602 ])
603 OVS_VSWITCHD_STOP
604 AT_CLEANUP
605
606 AT_SETUP([ofproto - mod flow with cookie change (OpenFlow 1.0)])
607 OVS_VSWITCHD_START
608 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 cookie=0x1,in_port=1,actions=1])
609 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
610  cookie=0x1, in_port=1 actions=output:1
611 OFPST_FLOW reply:
612 ])
613
614 AT_CHECK([ovs-ofctl -F openflow10 mod-flows br0 cookie=0x2,in_port=1,actions=1])
615 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
616  cookie=0x2, in_port=1 actions=output:1
617 OFPST_FLOW reply:
618 ])
619 OVS_VSWITCHD_STOP
620 AT_CLEANUP
621
622 AT_SETUP([ofproto - mod flow with cookie change (NXM)])
623 OVS_VSWITCHD_START
624 AT_CHECK([ovs-ofctl -F nxm add-flow br0 cookie=0x1,in_port=1,actions=1])
625 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
626  cookie=0x1, in_port=1 actions=output:1
627 NXST_FLOW reply:
628 ])
629
630 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x2,in_port=1,actions=1])
631 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
632  cookie=0x2, in_port=1 actions=output:1
633 NXST_FLOW reply:
634 ])
635 OVS_VSWITCHD_STOP
636 AT_CLEANUP
637
638 AT_SETUP([ofproto - no mod flow with cookie change (OpenFlow 1.1)])
639 OVS_VSWITCHD_START
640 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
641 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
642  cookie=0x1, in_port=1 actions=output:1
643 OFPST_FLOW reply (OF1.1):
644 ])
645 AT_CHECK([ovs-ofctl -O OpenFlow11 mod-flows br0 cookie=0x2,in_port=1,actions=1])
646 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
647  cookie=0x1, in_port=1 actions=output:1
648 OFPST_FLOW reply (OF1.1):
649 ])
650 OVS_VSWITCHD_STOP
651 AT_CLEANUP
652
653 dnl The OpenFlow 1.2 spec states that the cookie may not be modified
654 AT_SETUP([ofproto - no mod flow with cookie change (OpenFlow 1.2)])
655 OVS_VSWITCHD_START
656 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
657 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
658  cookie=0x1, in_port=1 actions=output:1
659 OFPST_FLOW reply (OF1.2):
660 ])
661
662 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 cookie=0x2,in_port=1,actions=1])
663 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
664  cookie=0x1, in_port=1 actions=output:1
665 OFPST_FLOW reply (OF1.2):
666 ])
667 OVS_VSWITCHD_STOP
668 AT_CLEANUP
669
670 AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.0)])
671 OVS_VSWITCHD_START
672 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
673 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
674 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
675 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
676  cookie=0x1, in_port=1 actions=output:1
677  cookie=0x1, in_port=2 actions=output:1
678  cookie=0x2, in_port=3 actions=output:1
679 NXST_FLOW reply:
680 ])
681
682 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x1/0xff,actions=4])
683 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
684  cookie=0x1, in_port=1 actions=output:4
685  cookie=0x1, in_port=2 actions=output:4
686  cookie=0x2, in_port=3 actions=output:1
687 NXST_FLOW reply:
688 ])
689 OVS_VSWITCHD_STOP
690 AT_CLEANUP
691
692 AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.1)])
693 OVS_VSWITCHD_START
694 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
695 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=2,actions=1])
696 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x2,in_port=3,actions=1])
697 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
698  cookie=0x1, in_port=1 actions=output:1
699  cookie=0x1, in_port=2 actions=output:1
700  cookie=0x2, in_port=3 actions=output:1
701 OFPST_FLOW reply (OF1.1):
702 ])
703
704 AT_CHECK([ovs-ofctl -O OpenFlow11 mod-flows br0 cookie=0x1/0xff,actions=4])
705 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
706  cookie=0x1, in_port=1 actions=output:4
707  cookie=0x1, in_port=2 actions=output:4
708  cookie=0x2, in_port=3 actions=output:1
709 OFPST_FLOW reply (OF1.1):
710 ])
711 OVS_VSWITCHD_STOP
712 AT_CLEANUP
713
714 AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.2)])
715 OVS_VSWITCHD_START
716 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
717 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=2,actions=1])
718 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=3,actions=1])
719 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
720  cookie=0x1, in_port=1 actions=output:1
721  cookie=0x1, in_port=2 actions=output:1
722  cookie=0x2, in_port=3 actions=output:1
723 OFPST_FLOW reply (OF1.2):
724 ])
725
726 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 cookie=0x1/0xff,actions=4])
727 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
728  cookie=0x1, in_port=1 actions=output:4
729  cookie=0x1, in_port=2 actions=output:4
730  cookie=0x2, in_port=3 actions=output:1
731 OFPST_FLOW reply (OF1.2):
732 ])
733 OVS_VSWITCHD_STOP
734 AT_CLEANUP
735
736 dnl The OpenFlow 1.2 spec states that the cookie may not be modified
737 AT_SETUP([ofproto - mod flows based on cookie mask with cookie change])
738 OVS_VSWITCHD_START
739 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
740 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
741 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
742 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
743  cookie=0x1, in_port=1 actions=output:1
744  cookie=0x1, in_port=2 actions=output:1
745  cookie=0x2, in_port=3 actions=output:1
746 NXST_FLOW reply:
747 ])
748
749 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/-1,cookie=4,actions=4])
750 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
751  cookie=0x2, in_port=3 actions=output:1
752  cookie=0x4, in_port=1 actions=output:4
753  cookie=0x4, in_port=2 actions=output:4
754 NXST_FLOW reply:
755 ])
756 OVS_VSWITCHD_STOP
757 AT_CLEANUP
758
759 AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - NXM])
760 OVS_VSWITCHD_START
761 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 in_port=1,actions=1])
762 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
763  in_port=1 actions=output:1
764 NXST_FLOW reply:
765 ])
766 OVS_VSWITCHD_STOP
767 AT_CLEANUP
768
769 AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - OF1.1])
770 OVS_VSWITCHD_START
771 AT_CHECK([ovs-ofctl -O openflow11 mod-flows br0 in_port=1,actions=1])
772 AT_CHECK([ovs-ofctl -O openflow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
773  in_port=1 actions=output:1
774 OFPST_FLOW reply (OF1.1):
775 ])
776 OVS_VSWITCHD_STOP
777 AT_CLEANUP
778
779 AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - OF1.2])
780 OVS_VSWITCHD_START
781 AT_CHECK([ovs-ofctl -O openflow12 mod-flows br0 in_port=1,actions=1])
782 AT_CHECK([ovs-ofctl -O openflow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
783 OFPST_FLOW reply (OF1.2):
784 ])
785 OVS_VSWITCHD_STOP
786 AT_CLEANUP
787
788 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - NXM])
789 OVS_VSWITCHD_START
790 AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/1,in_port=1,actions=1])
791 AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
792 NXST_FLOW reply:
793 ])
794 OVS_VSWITCHD_STOP
795 AT_CLEANUP
796
797 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - OF1.1])
798 OVS_VSWITCHD_START
799 AT_CHECK([ovs-ofctl -O openflow11 mod-flows br0 cookie=1/1,in_port=1,actions=1])
800 AT_CHECK([ovs-ofctl -O openflow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
801 OFPST_FLOW reply (OF1.1):
802 ])
803 OVS_VSWITCHD_STOP
804 AT_CLEANUP
805
806 AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - OF1.2])
807 OVS_VSWITCHD_START
808 AT_CHECK([ovs-ofctl -O openflow12 mod-flows br0 cookie=1/1,in_port=1,actions=1])
809 AT_CHECK([ovs-ofctl -O openflow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
810 OFPST_FLOW reply (OF1.2):
811 ])
812 OVS_VSWITCHD_STOP
813 AT_CLEANUP
814
815 AT_SETUP([ofproto - del flows with cookies])
816 OVS_VSWITCHD_START
817 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
818 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
819 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
820 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
821  cookie=0x1, in_port=1 actions=output:1
822  cookie=0x2, in_port=2 actions=output:1
823  cookie=0x3, in_port=3 actions=output:1
824 NXST_FLOW reply:
825 ])
826
827 AT_CHECK([ovs-ofctl del-flows br0])
828 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
829 NXST_FLOW reply:
830 ])
831 OVS_VSWITCHD_STOP
832 AT_CLEANUP
833
834 AT_SETUP([ofproto - del flows based on cookie])
835 OVS_VSWITCHD_START
836 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
837 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
838 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
839 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
840  cookie=0x1, in_port=1 actions=output:1
841  cookie=0x2, in_port=2 actions=output:1
842  cookie=0x3, in_port=3 actions=output:1
843 NXST_FLOW reply:
844 ])
845
846 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/-1])
847 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
848  cookie=0x1, in_port=1 actions=output:1
849  cookie=0x2, in_port=2 actions=output:1
850 NXST_FLOW reply:
851 ])
852 OVS_VSWITCHD_STOP
853 AT_CLEANUP
854
855 AT_SETUP([ofproto - del flows based on cookie mask])
856 OVS_VSWITCHD_START
857 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
858 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
859 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
860 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
861  cookie=0x1, in_port=1 actions=output:1
862  cookie=0x2, in_port=2 actions=output:1
863  cookie=0x3, in_port=3 actions=output:1
864 NXST_FLOW reply:
865 ])
866 AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/0x1])
867 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
868  cookie=0x2, in_port=2 actions=output:1
869 NXST_FLOW reply:
870 ])
871 OVS_VSWITCHD_STOP
872 AT_CLEANUP
873
874 AT_SETUP([ofproto - del flows based on table id (NXM)])
875 OVS_VSWITCHD_START
876 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
877 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
878 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
879  cookie=0x1, in_port=1 actions=output:1
880  cookie=0x2, table=1, in_port=2 actions=output:1
881 NXST_FLOW reply:
882 ])
883 AT_CHECK([ovs-ofctl del-flows br0 table=0])
884 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
885  cookie=0x2, table=1, in_port=2 actions=output:1
886 NXST_FLOW reply:
887 ])
888 AT_CHECK([ovs-ofctl del-flows br0 table=1])
889 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
890 NXST_FLOW reply:
891 ])
892 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
893 AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
894 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
895  cookie=0x1, in_port=1 actions=output:1
896  cookie=0x2, table=1, in_port=2 actions=output:1
897 NXST_FLOW reply:
898 ])
899 AT_CHECK([ovs-ofctl del-flows br0])
900 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
901 NXST_FLOW reply:
902 ])
903 OVS_VSWITCHD_STOP
904 AT_CLEANUP
905
906 AT_SETUP([ofproto - del flows based on table id (OpenFlow 1.1)])
907 OVS_VSWITCHD_START
908 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
909 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
910 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
911  cookie=0x1, in_port=1 actions=output:1
912  cookie=0x2, table=1, in_port=2 actions=output:1
913 OFPST_FLOW reply (OF1.1):
914 ])
915 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 table=0])
916 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
917  cookie=0x2, table=1, in_port=2 actions=output:1
918 OFPST_FLOW reply (OF1.1):
919 ])
920 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 table=1])
921 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
922 OFPST_FLOW reply (OF1.1):
923 ])
924 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
925 AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
926 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
927  cookie=0x1, in_port=1 actions=output:1
928  cookie=0x2, table=1, in_port=2 actions=output:1
929 OFPST_FLOW reply (OF1.1):
930 ])
931 AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0])
932 AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
933 OFPST_FLOW reply (OF1.1):
934  cookie=0x2, table=1, in_port=2 actions=output:1
935 ])
936 OVS_VSWITCHD_STOP
937 AT_CLEANUP
938
939 AT_SETUP([ofproto - del flows based on table id (OpenFlow 1.2)])
940 OVS_VSWITCHD_START
941 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
942 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
943 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
944  cookie=0x1, in_port=1 actions=output:1
945  cookie=0x2, table=1, in_port=2 actions=output:1
946 OFPST_FLOW reply (OF1.2):
947 ])
948 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0 table=0])
949 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
950  cookie=0x2, table=1, in_port=2 actions=output:1
951 OFPST_FLOW reply (OF1.2):
952 ])
953 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0 table=1])
954 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
955 OFPST_FLOW reply (OF1.2):
956 ])
957 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
958 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
959 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
960  cookie=0x1, in_port=1 actions=output:1
961  cookie=0x2, table=1, in_port=2 actions=output:1
962 OFPST_FLOW reply (OF1.2):
963 ])
964 AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0])
965 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
966 OFPST_FLOW reply (OF1.2):
967 ])
968 OVS_VSWITCHD_STOP
969 AT_CLEANUP
970
971 AT_SETUP([ofproto - flow table configuration (OpenFlow 1.0)])
972 OVS_VSWITCHD_START
973 # Check the default configuration.
974 (echo "OFPST_TABLE reply (xid=0x2): 254 tables
975   0: classifier: wild=0x3fffff, max=1000000, active=0
976                lookup=0, matched=0"
977  x=1
978  while test $x -lt 254; do
979    printf "  %d: %-8s: wild=0x3fffff, max=1000000, active=0
980                lookup=0, matched=0
981 " $x table$x
982    x=`expr $x + 1`
983  done) > expout
984 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
985 # Change the configuration.
986 AT_CHECK(
987   [ovs-vsctl \
988      -- --id=@t0 create Flow_Table name=main \
989      -- --id=@t1 create Flow_Table flow-limit=1024 \
990      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
991    | ${PERL} $srcdir/uuidfilt.pl],
992   [0], [<0>
993 <1>
994 ])
995 # Check that the configuration was updated.
996 mv expout orig-expout
997 (echo "OFPST_TABLE reply (xid=0x2): 254 tables
998   0: main    : wild=0x3fffff, max=1000000, active=0
999                lookup=0, matched=0
1000   1: table1  : wild=0x3fffff, max=  1024, active=0
1001                lookup=0, matched=0"
1002  tail -n +6 orig-expout) > expout
1003 AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
1004 OVS_VSWITCHD_STOP
1005 AT_CLEANUP
1006
1007 AT_SETUP([ofproto - flow table configuration (OpenFlow 1.2)])
1008 OVS_VSWITCHD_START
1009 # Check the default configuration.
1010 (mid="wild=0xfffffffff, max=1000000,"
1011  tail="
1012                lookup=0, matched=0
1013                match=0xfffffffff, instructions=0x00000007, config=0x00000003
1014                write_actions=0x00000000, apply_actions=0x00000000
1015                write_setfields=0x0000000fffffffff
1016                apply_setfields=0x0000000fffffffff
1017                metadata_match=0xffffffffffffffff
1018                metadata_write=0xffffffffffffffff"
1019  echo "OFPST_TABLE reply (OF1.2) (xid=0x2): 254 tables
1020   0: classifier: $mid active=0$tail"
1021  x=1
1022  while test $x -lt 254; do
1023    printf "  %d: %-8s: $mid active=0$tail
1024 " $x table$x
1025    x=`expr $x + 1`
1026  done) > expout
1027 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
1028 # Change the configuration.
1029 AT_CHECK(
1030   [ovs-vsctl \
1031      -- --id=@t0 create Flow_Table name=main \
1032      -- --id=@t1 create Flow_Table flow-limit=1024 \
1033      -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
1034    | ${PERL} $srcdir/uuidfilt.pl],
1035   [0], [<0>
1036 <1>
1037 ])
1038 # Check that the configuration was updated.
1039 mv expout orig-expout
1040 (echo "OFPST_TABLE reply (OF1.2) (xid=0x2): 254 tables
1041   0: main    : wild=0xfffffffff, max=1000000, active=0"
1042  tail -n +3 orig-expout | head -7
1043  echo "  1: table1  : wild=0xfffffffff, max=  1024, active=0"
1044  tail -n +11 orig-expout) > expout
1045 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
1046 OVS_VSWITCHD_STOP
1047 AT_CLEANUP
1048
1049 AT_SETUP([ofproto - hard limits on flow table size (OpenFlow 1.0)])
1050 OVS_VSWITCHD_START
1051 # Configure a maximum of 4 flows.
1052 AT_CHECK(
1053   [ovs-vsctl \
1054      -- --id=@t0 create Flow_Table flow-limit=4 \
1055      -- set bridge br0 flow_tables:0=@t0 \
1056    | ${PERL} $srcdir/uuidfilt.pl],
1057   [0], [<0>
1058 ])
1059 # Add 4 flows.
1060 for in_port in 1 2 3 4; do
1061     ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
1062 done
1063 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1064  in_port=1 actions=drop
1065  in_port=2 actions=drop
1066  in_port=3 actions=drop
1067  in_port=4 actions=drop
1068 NXST_FLOW reply:
1069 ])
1070 # Adding another flow will be refused.
1071 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
1072 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1073   [OFPT_ERROR: OFPFMFC_TABLE_FULL
1074 ])
1075 # Also a mod-flow that would add a flow will be refused.
1076 AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
1077 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1078   [OFPT_ERROR: OFPFMFC_TABLE_FULL
1079 ])
1080 # Replacing or modifying an existing flow is allowed.
1081 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
1082 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
1083 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1084  in_port=1 actions=drop
1085  in_port=2 actions=drop
1086  in_port=3 actions=output:1
1087  in_port=4 actions=NORMAL
1088 NXST_FLOW reply:
1089 ])
1090 OVS_VSWITCHD_STOP
1091 AT_CLEANUP
1092
1093 AT_SETUP([ofproto - hard limits on flow table size (OpenFlow 1.2)])
1094 OVS_VSWITCHD_START
1095 # Configure a maximum of 4 flows.
1096 AT_CHECK(
1097   [ovs-vsctl \
1098      -- --id=@t0 create Flow_Table flow-limit=4 \
1099      -- set bridge br0 flow_tables:0=@t0 \
1100    | ${PERL} $srcdir/uuidfilt.pl],
1101   [0], [<0>
1102 ])
1103 # Add 4 flows.
1104 for in_port in 1 2 3 4; do
1105     ovs-ofctl -O OpenFlow12 add-flow br0 in_port=$in_port,actions=drop
1106 done
1107 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1108  in_port=1 actions=drop
1109  in_port=2 actions=drop
1110  in_port=3 actions=drop
1111  in_port=4 actions=drop
1112 OFPST_FLOW reply (OF1.2):
1113 ])
1114 # Adding another flow will be refused.
1115 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
1116 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1117   [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
1118 ])
1119 # Replacing or modifying an existing flow is allowed.
1120 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
1121 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
1122 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1123  in_port=1 actions=drop
1124  in_port=2 actions=drop
1125  in_port=3 actions=output:1
1126  in_port=4 actions=NORMAL
1127 OFPST_FLOW reply (OF1.2):
1128 ])
1129 OVS_VSWITCHD_STOP
1130 AT_CLEANUP
1131
1132 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.0)])
1133 OVS_VSWITCHD_START
1134 # Configure a maximum of 4 flows.
1135 AT_CHECK(
1136   [ovs-vsctl \
1137      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
1138      -- set bridge br0 flow_tables:0=@t0 \
1139    | ${PERL} $srcdir/uuidfilt.pl],
1140   [0], [<0>
1141 ])
1142 # Add 4 flows.
1143 for in_port in 4 3 2 1; do
1144     ovs-ofctl add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
1145 done
1146 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1147  idle_timeout=10, in_port=1 actions=drop
1148  idle_timeout=20, in_port=2 actions=drop
1149  idle_timeout=30, in_port=3 actions=drop
1150  idle_timeout=40, in_port=4 actions=drop
1151 NXST_FLOW reply:
1152 ])
1153 # Adding another flow will cause the one that expires soonest to be evicted.
1154 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
1155 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1156  idle_timeout=20, in_port=2 actions=drop
1157  idle_timeout=30, in_port=3 actions=drop
1158  idle_timeout=40, in_port=4 actions=drop
1159  in_port=5 actions=drop
1160 NXST_FLOW reply:
1161 ])
1162 # A mod-flow that adds a flow also causes eviction, but replacing or
1163 # modifying an existing flow doesn't.
1164 AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
1165 AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
1166 AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
1167 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1168  idle_timeout=30, in_port=3 actions=output:1
1169  in_port=4 actions=NORMAL
1170  in_port=5 actions=drop
1171  in_port=6 actions=drop
1172 NXST_FLOW reply:
1173 ])
1174 # Flows with no timeouts at all cannot be evicted.
1175 AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
1176 AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
1177 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1178   [OFPT_ERROR: OFPFMFC_TABLE_FULL
1179 ])
1180 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1181  in_port=4 actions=NORMAL
1182  in_port=5 actions=drop
1183  in_port=6 actions=drop
1184  in_port=7 actions=NORMAL
1185 NXST_FLOW reply:
1186 ])
1187 OVS_VSWITCHD_STOP
1188 AT_CLEANUP
1189
1190 AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.2)])
1191 OVS_VSWITCHD_START
1192 # Configure a maximum of 4 flows.
1193 AT_CHECK(
1194   [ovs-vsctl \
1195      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
1196      -- set bridge br0 flow_tables:0=@t0 \
1197    | ${PERL} $srcdir/uuidfilt.pl],
1198   [0], [<0>
1199 ])
1200 # Add 4 flows.
1201 for in_port in 4 3 2 1; do
1202     ovs-ofctl -O OpenFlow12 add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
1203 done
1204 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1205  idle_timeout=10, in_port=1 actions=drop
1206  idle_timeout=20, in_port=2 actions=drop
1207  idle_timeout=30, in_port=3 actions=drop
1208  idle_timeout=40, in_port=4 actions=drop
1209 OFPST_FLOW reply (OF1.2):
1210 ])
1211 # Adding another flow will cause the one that expires soonest to be evicted.
1212 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop])
1213 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1214  idle_timeout=20, in_port=2 actions=drop
1215  idle_timeout=30, in_port=3 actions=drop
1216  idle_timeout=40, in_port=4 actions=drop
1217  in_port=5 actions=drop
1218 OFPST_FLOW reply (OF1.2):
1219 ])
1220 # In Open Flow 1.2 a mod-flow does not ever add a flow and thus
1221 # has no effect on eviction
1222 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=6,actions=drop])
1223 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
1224 AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
1225 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1226  idle_timeout=20, in_port=2 actions=drop
1227  idle_timeout=30, in_port=3 actions=output:1
1228  in_port=4 actions=NORMAL
1229  in_port=5 actions=drop
1230 OFPST_FLOW reply (OF1.2):
1231 ])
1232 # Flows with no timeouts at all cannot be evicted.
1233 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=6,actions=drop])
1234 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=7,actions=normal])
1235 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
1236 AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1237   [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
1238 ])
1239 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1240  in_port=4 actions=NORMAL
1241  in_port=5 actions=drop
1242  in_port=6 actions=drop
1243  in_port=7 actions=NORMAL
1244 OFPST_FLOW reply (OF1.2):
1245 ])
1246 OVS_VSWITCHD_STOP
1247 AT_CLEANUP
1248
1249 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.0)])
1250 OVS_VSWITCHD_START
1251 # Configure a maximum of 4 flows.
1252 AT_CHECK(
1253   [ovs-vsctl \
1254      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
1255                                    overflow-policy=evict \
1256                                    groups='"NXM_OF_IN_PORT[[]]"' \
1257      -- set bridge br0 flow_tables:0=@t0 \
1258    | ${PERL} $srcdir/uuidfilt.pl],
1259   [0], [<0>
1260 ])
1261 # Add 4 flows.
1262 ovs-ofctl add-flows br0 - <<EOF
1263 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
1264 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
1265 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
1266 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
1267 EOF
1268 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1269  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1270  idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
1271  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1272  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1273 NXST_FLOW reply:
1274 ])
1275 # Adding another flow will cause the one that expires soonest within
1276 # the largest group (those with in_port=1) to be evicted.  In this
1277 # case this is not the same as the one that expires soonest overall
1278 # (which is what makes the test interesting):
1279 AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
1280 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1281  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1282  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1283  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1284  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1285 NXST_FLOW reply:
1286 ])
1287 # Enlarge the flow limit, change the eviction policy back to strictly
1288 # based on expiration, and and add some flows.
1289 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
1290 ovs-ofctl add-flows br0 - <<EOF
1291 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
1292 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
1293 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
1294 EOF
1295 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1296  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1297  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1298  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1299  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
1300  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1301  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1302  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1303 NXST_FLOW reply:
1304 ])
1305 # Adding another flow will cause the one that expires soonest overall
1306 # to be evicted.
1307 AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
1308 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1309  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1310  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1311  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
1312  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1313  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1314  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1315  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1316 NXST_FLOW reply:
1317 ])
1318 # Reducing the flow limit also causes the flows that expire soonest
1319 # overall to be evicted.
1320 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
1321 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1322  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1323  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1324  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1325  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1326 NXST_FLOW reply:
1327 ])
1328 OVS_VSWITCHD_STOP
1329 AT_CLEANUP
1330
1331 AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.2)])
1332 OVS_VSWITCHD_START
1333 # Configure a maximum of 4 flows.
1334 AT_CHECK(
1335   [ovs-vsctl \
1336      -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
1337                                    overflow-policy=evict \
1338                                    groups='"NXM_OF_IN_PORT[[]]"' \
1339      -- set bridge br0 flow_tables:0=@t0 \
1340    | ${PERL} $srcdir/uuidfilt.pl],
1341   [0], [<0>
1342 ])
1343 # Add 4 flows.
1344 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
1345 idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
1346 idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
1347 idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
1348 idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
1349 EOF
1350 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1351  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1352  idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
1353  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1354  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1355 OFPST_FLOW reply (OF1.2):
1356 ])
1357 # Adding another flow will cause the one that expires soonest within
1358 # the largest group (those with in_port=1) to be evicted.  In this
1359 # case this is not the same as the one that expires soonest overall
1360 # (which is what makes the test interesting):
1361 AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
1362 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1363  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1364  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1365  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1366  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1367 OFPST_FLOW reply (OF1.2):
1368 ])
1369 # Enlarge the flow limit, change the eviction policy back to strictly
1370 # based on expiration, and and add some flows.
1371 AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
1372 ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
1373 idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
1374 idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
1375 idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
1376 EOF
1377 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1378  idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1379  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1380  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1381  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
1382  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1383  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1384  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1385 OFPST_FLOW reply (OF1.2):
1386 ])
1387 # Adding another flow will cause the one that expires soonest overall
1388 # to be evicted.
1389 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'])
1390 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1391  idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1392  idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1393  idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
1394  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1395  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1396  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1397  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1398 OFPST_FLOW reply (OF1.2):
1399 ])
1400 # Reducing the flow limit also causes the flows that expire soonest
1401 # overall to be evicted.
1402 AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
1403 AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1404  idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1405  idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1406  idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1407  in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1408 OFPST_FLOW reply (OF1.2):
1409 ])
1410 OVS_VSWITCHD_STOP
1411 AT_CLEANUP
1412
1413 AT_SETUP([ofproto - eviction upon table overflow, with modified hard timeout])
1414 OVS_VSWITCHD_START
1415 # Configure a maximum of 4 flows.
1416 AT_CHECK(
1417   [ovs-vsctl \
1418      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
1419      -- set bridge br0 flow_tables:0=@t0 \
1420    | ${PERL} $srcdir/uuidfilt.pl],
1421   [0], [<0>
1422 ])
1423 ovs-appctl time/stop
1424 # Add 4 flows.
1425 for in_port in 4 3 2 1; do
1426     ovs-ofctl add-flow br0 hard_timeout=$((10 + in_port * 3)),in_port=$in_port,actions=drop
1427 done
1428 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1429  hard_timeout=13, in_port=1 actions=drop
1430  hard_timeout=16, in_port=2 actions=drop
1431  hard_timeout=19, in_port=3 actions=drop
1432  hard_timeout=22, in_port=4 actions=drop
1433 NXST_FLOW reply:
1434 ])
1435 # Sleep and modify the one that expires soonest
1436 ovs-appctl time/warp 5000
1437 AT_CHECK([ovs-ofctl mod-flows br0 in_port=1,actions=drop])
1438 # At this point the table would looks like:
1439 #  in_port   seconds to expire
1440 #     1            13
1441 #     2            11
1442 #     3            14
1443 #     4            17
1444 ovs-appctl time/warp 2000
1445 # Adding another flow will cause the one that expires soonest to be evicted.
1446 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
1447 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1448  hard_timeout=13, in_port=1 actions=drop
1449  hard_timeout=19, in_port=3 actions=drop
1450  hard_timeout=22, in_port=4 actions=drop
1451  in_port=5 actions=drop
1452 NXST_FLOW reply:
1453 ])
1454 OVS_VSWITCHD_STOP
1455 AT_CLEANUP
1456
1457 AT_SETUP([ofproto - eviction upon table overflow, with modified idle timeout])
1458 OVS_VSWITCHD_START([add-port br0 p1 -- set interface p1 type=dummy ofport_request=1])
1459 # Configure a maximum of 4 flows.
1460 AT_CHECK(
1461   [ovs-vsctl \
1462      -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
1463      -- set bridge br0 flow_tables:0=@t0 \
1464    | ${PERL} $srcdir/uuidfilt.pl],
1465   [0], [<0>
1466 ])
1467 # Add 4 flows.
1468 for in_port in 4 3 2 1; do
1469     ovs-ofctl add-flow br0 idle_timeout=$((10 + in_port * 3)),in_port=$in_port,actions=drop
1470 done
1471 ovs-appctl time/stop
1472 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1473  idle_timeout=13, in_port=1 actions=drop
1474  idle_timeout=16, in_port=2 actions=drop
1475  idle_timeout=19, in_port=3 actions=drop
1476  idle_timeout=22, in_port=4 actions=drop
1477 NXST_FLOW reply:
1478 ])
1479 # Sleep and receive on the flow that expires soonest
1480 ovs-appctl time/warp 5000
1481 AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1)'])
1482 # At this point the table would looks like:
1483 #  in_port   seconds to expire
1484 #     1            13
1485 #     2            11
1486 #     3            14
1487 #     4            17
1488 ovs-appctl time/warp 2000
1489 # Adding another flow will cause the one that expires soonest to be evicted.
1490 AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
1491 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1492  idle_timeout=19, in_port=3 actions=drop
1493  idle_timeout=22, in_port=4 actions=drop
1494  in_port=5 actions=drop
1495  n_packets=1, n_bytes=60, idle_timeout=13, in_port=1 actions=drop
1496 NXST_FLOW reply:
1497 ])
1498 OVS_VSWITCHD_STOP
1499 AT_CLEANUP
1500
1501 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.0)])
1502 OVS_VSWITCHD_START
1503 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
1504 check_async () {
1505     printf '\n\n--- check_async %d ---\n\n\n' $1
1506     shift
1507
1508     ovs-appctl -t ovs-ofctl ofctl/barrier
1509     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1510     : > expout
1511
1512     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1513     ovs-ofctl -v packet-out br0 controller controller '0001020304050010203040501234'
1514     if test X"$1" = X"OFPR_ACTION"; then shift;
1515         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (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     fi
1518
1519     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1520     ovs-ofctl -v packet-out br0 controller 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1521     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1522         echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via no_match) data_len=14 (unbuffered)
1523 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"
1524     fi
1525
1526     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1527     ovs-ofctl packet-out br0 controller dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1528     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1529         echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=CONTROLLER (via invalid_ttl) data_len=76 (unbuffered)
1530 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"
1531     fi
1532
1533     # OFPT_PORT_STATUS, OFPPR_ADD
1534     ovs-vsctl add-port br0 test -- set Interface test type=dummy ofport_request=1
1535     if test X"$1" = X"OFPPR_ADD"; then shift;
1536         echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
1537      config:     PORT_DOWN
1538      state:      LINK_DOWN
1539      speed: 0 Mbps now, 0 Mbps max"
1540     fi
1541
1542     # OFPT_PORT_STATUS, OFPPR_DELETE
1543     ovs-vsctl del-port br0 test
1544     if test X"$1" = X"OFPPR_DELETE"; then shift;
1545         echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
1546      config:     PORT_DOWN
1547      state:      LINK_DOWN
1548      speed: 0 Mbps now, 0 Mbps max"
1549     fi
1550
1551     # OFPT_FLOW_REMOVED, OFPRR_DELETE
1552     ovs-ofctl add-flow br0 send_flow_rem,actions=drop
1553     ovs-ofctl --strict del-flows br0 ''
1554     if test X"$1" = X"OFPRR_DELETE"; then shift;
1555         echo >>expout "OFPT_FLOW_REMOVED:  reason=delete"
1556     fi
1557     AT_FAIL_IF([test X"$1" != X])
1558
1559     ovs-appctl -t ovs-ofctl ofctl/barrier
1560     echo >>expout "OFPT_BARRIER_REPLY:"
1561
1562     AT_CHECK(
1563       [[sed '
1564 s/ (xid=0x[0-9a-fA-F]*)//
1565 s/ *duration.*//
1566 s/00:0.$/00:0x/' < monitor.log]],
1567       [0], [expout])
1568 }
1569
1570 # It's a service connection so initially there should be no async messages.
1571 check_async 1
1572
1573 # Set miss_send_len to 128, turning on packet-ins for our service connection.
1574 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
1575 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1576
1577 # Set miss_send_len to 128 and enable invalid_ttl.
1578 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
1579 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1580
1581 # Become slave, which should disable everything except port status.
1582 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
1583 check_async 4 OFPPR_ADD OFPPR_DELETE
1584
1585 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
1586 ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
1587 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1588
1589 # Set controller ID 123.
1590 ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
1591 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1592
1593 # Restore controller ID 0.
1594 ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
1595
1596 # Become master.
1597 ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
1598 check_async 7 OFPR_ACTION OFPPR_ADD
1599
1600 ovs-appctl -t ovs-ofctl exit
1601 OVS_VSWITCHD_STOP
1602 AT_CLEANUP
1603
1604 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.2)])
1605 OVS_VSWITCHD_START
1606 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1607 check_async () {
1608     printf '\n\n--- check_async %d ---\n\n\n' $1
1609     INDEX=$1
1610     shift
1611
1612     ovs-appctl -t ovs-ofctl ofctl/barrier
1613     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1614     : > expout
1615
1616     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1617     ovs-ofctl -O OpenFlow12 -v packet-out br0 none controller '0001020304050010203040501234'
1618     if test X"$1" = X"OFPR_ACTION"; then shift;
1619         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1620 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"
1621     fi
1622
1623     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1624     ovs-ofctl -O OpenFlow12 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1625     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1626         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
1627 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"
1628     fi
1629
1630     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1631     ovs-ofctl -O OpenFlow12 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1632     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1633         echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
1634 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"
1635     fi
1636
1637     # OFPT_PORT_STATUS, OFPPR_ADD
1638     ovs-vsctl add-port br0 test -- set Interface test type=dummy
1639     if test X"$1" = X"OFPPR_ADD"; then shift;
1640         echo >>expout "OFPT_PORT_STATUS (OF1.2): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1641      config:     PORT_DOWN
1642      state:      LINK_DOWN
1643      speed: 0 Mbps now, 0 Mbps max"
1644     fi
1645
1646     # OFPT_PORT_STATUS, OFPPR_DELETE
1647     ovs-vsctl del-port br0 test
1648     if test X"$1" = X"OFPPR_DELETE"; then shift;
1649         echo >>expout "OFPT_PORT_STATUS (OF1.2): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1650      config:     PORT_DOWN
1651      state:      LINK_DOWN
1652      speed: 0 Mbps now, 0 Mbps max"
1653     fi
1654
1655     # OFPT_FLOW_REMOVED, OFPRR_DELETE
1656     ovs-ofctl -O OpenFlow12 add-flow br0 send_flow_rem,actions=drop
1657     ovs-ofctl -O OpenFlow12 --strict del-flows br0 ''
1658     if test X"$1" = X"OFPRR_DELETE"; then shift;
1659         echo >>expout "OFPT_FLOW_REMOVED (OF1.2):  reason=delete table_id=0"
1660     fi
1661     AT_FAIL_IF([test X"$1" != X])
1662
1663     ovs-appctl -t ovs-ofctl ofctl/barrier
1664     echo >>expout "OFPT_BARRIER_REPLY (OF1.2):"
1665
1666     AT_CHECK(
1667       [[sed '
1668 s/ (xid=0x[0-9a-fA-F]*)//
1669 s/ *duration.*//
1670 s/00:0.$/00:0x/' < monitor.log]],
1671       [0], [expout])
1672 }
1673
1674 # It's a service connection so initially there should be no async messages.
1675 check_async 1
1676
1677 # Set miss_send_len to 128, turning on packet-ins for our service connection.
1678 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
1679 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1680
1681 # Set miss_send_len to 128 and enable invalid_ttl.
1682 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700040080
1683 check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1684
1685 # Become slave (OF 1.2), which should disable everything except port status.
1686 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000200000003000000000000000000000001
1687 check_async 4 OFPPR_ADD OFPPR_DELETE
1688
1689 # Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
1690 ovs-appctl -t ovs-ofctl ofctl/send 03040028000000020000232000000013000000020000000500000005000000020000000200000005
1691 check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1692
1693 # Set controller ID 123.
1694 ovs-appctl -t ovs-ofctl ofctl/send 03040018000000030000232000000014000000000000007b
1695 check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1696
1697 # Restore controller ID 0.
1698 ovs-appctl -t ovs-ofctl ofctl/send 030400180000000300002320000000140000000000000000
1699
1700 # Become master (OF 1.2).
1701 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000400000002000000000000000000000002
1702 check_async 7 OFPR_ACTION OFPPR_ADD
1703
1704 ovs-appctl -t ovs-ofctl exit
1705 OVS_VSWITCHD_STOP
1706 AT_CLEANUP
1707
1708 AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.3)])
1709 OVS_VSWITCHD_START
1710 AT_CHECK([ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile])
1711 check_async () {
1712     printf '\n\n--- check_async %d ---\n\n\n' $1
1713     INDEX=$1
1714     shift
1715
1716     ovs-appctl -t ovs-ofctl ofctl/barrier
1717     ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1718     : > expout
1719
1720     # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1721     ovs-ofctl -O OpenFlow13 -v packet-out br0 none controller '0001020304050010203040501234'
1722     if test X"$1" = X"OFPR_ACTION"; then shift;
1723         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1724 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"
1725     fi
1726
1727     # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1728     ovs-ofctl -O OpenFlow13 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1729     if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1730         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
1731 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"
1732     fi
1733
1734     # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1735     ovs-ofctl -O OpenFlow13 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1736     if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1737         echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
1738 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"
1739     fi
1740
1741     # OFPT_PORT_STATUS, OFPPR_ADD
1742     ovs-vsctl add-port br0 test -- set Interface test type=dummy
1743     if test X"$1" = X"OFPPR_ADD"; then shift;
1744         echo >>expout "OFPT_PORT_STATUS (OF1.3): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1745      config:     PORT_DOWN
1746      state:      LINK_DOWN
1747      speed: 0 Mbps now, 0 Mbps max"
1748     fi
1749
1750     # OFPT_PORT_STATUS, OFPPR_DELETE
1751     ovs-vsctl del-port br0 test
1752     if test X"$1" = X"OFPPR_DELETE"; then shift;
1753         echo >>expout "OFPT_PORT_STATUS (OF1.3): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1754      config:     PORT_DOWN
1755      state:      LINK_DOWN
1756      speed: 0 Mbps now, 0 Mbps max"
1757     fi
1758
1759     # OFPT_FLOW_REMOVED, OFPRR_DELETE
1760     ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=drop
1761     ovs-ofctl -O OpenFlow13 --strict del-flows br0 ''
1762     if test X"$1" = X"OFPRR_DELETE"; then shift;
1763         echo >>expout "OFPT_FLOW_REMOVED (OF1.3):  reason=delete table_id=0"
1764     fi
1765     AT_FAIL_IF([test X"$1" != X])
1766
1767     ovs-appctl -t ovs-ofctl ofctl/barrier
1768     echo >>expout "OFPT_BARRIER_REPLY (OF1.3):"
1769
1770     AT_CHECK(
1771       [[sed '
1772 s/ (xid=0x[0-9a-fA-F]*)//
1773 s/ *duration.*//
1774 s/00:0.$/00:0x/' < monitor.log]],
1775       [0], [expout])
1776 }
1777
1778 # It's a service connection so initially there should be no async messages.
1779 check_async 1
1780
1781 # Set miss_send_len to 128, turning on packet-ins for our service connection.
1782 ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
1783 check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1784
1785 # Become slave (OF 1.3), which should disable everything except port status.
1786 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000200000003000000000000000000000001
1787 check_async 3 OFPPR_ADD OFPPR_DELETE
1788
1789 # Use OF 1.3 OFPT_SET_ASYNC to enable a patchwork of asynchronous messages.
1790 ovs-appctl -t ovs-ofctl ofctl/send 041c002000000002000000020000000500000005000000020000000200000005
1791 check_async 4 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1792
1793 # Set controller ID 123.
1794 ovs-appctl -t ovs-ofctl ofctl/send 04040018000000030000232000000014000000000000007b
1795 check_async 5 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1796
1797 # Restore controller ID 0.
1798 ovs-appctl -t ovs-ofctl ofctl/send 040400180000000300002320000000140000000000000000
1799
1800 # Become master (OF 1.3).
1801 ovs-appctl -t ovs-ofctl ofctl/send 041800180000000400000002000000000000000000000002
1802 check_async 6 OFPR_ACTION OFPPR_ADD
1803
1804 ovs-appctl -t ovs-ofctl exit
1805 OVS_VSWITCHD_STOP
1806 AT_CLEANUP
1807
1808 dnl This test checks that the role request/response messaging works
1809 dnl and that generation_id is handled properly.
1810 AT_SETUP([ofproto - controller role (OpenFlow 1.2)])
1811 OVS_VSWITCHD_START
1812 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1813
1814 ovs-appctl -t ovs-ofctl ofctl/barrier
1815 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1816 : > expout
1817 : > experr
1818
1819 # find out current role
1820 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000200000000000000000000000000000000
1821 echo >>experr "send: OFPT_ROLE_REQUEST (OF1.2) (xid=0x2): role=nochange"
1822 echo >>expout "OFPT_ROLE_REPLY (OF1.2) (xid=0x2): role=equal"
1823
1824 # Become slave (generation_id is initially undefined, so 2^63+2 should not be stale)
1825 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000300000003000000008000000000000002
1826 echo >>experr "send: OFPT_ROLE_REQUEST (OF1.2) (xid=0x3): role=slave generation_id=9223372036854775810"
1827 echo >>expout "OFPT_ROLE_REPLY (OF1.2) (xid=0x3): role=slave generation_id=9223372036854775810"
1828
1829 # Try to become the master using a stale generation ID
1830 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000400000002000000000000000000000002
1831 echo >>experr "send: OFPT_ROLE_REQUEST (OF1.2) (xid=0x4): role=master generation_id=2"
1832 echo >>expout "OFPT_ERROR (OF1.2) (xid=0x4): OFPRRFC_STALE"
1833 echo >>expout "OFPT_ROLE_REQUEST (OF1.2) (xid=0x4): role=master generation_id=2"
1834
1835 # Become master using a valid generation ID
1836 ovs-appctl -t ovs-ofctl ofctl/send 031800180000000500000002000000000000000000000001
1837 echo >>experr "send: OFPT_ROLE_REQUEST (OF1.2) (xid=0x5): role=master generation_id=1"
1838 echo >>expout "OFPT_ROLE_REPLY (OF1.2) (xid=0x5): role=master generation_id=1"
1839 ovs-appctl -t ovs-ofctl ofctl/barrier
1840 echo >>expout "OFPT_BARRIER_REPLY (OF1.2) (xid=0x3):"
1841
1842 AT_CHECK([grep -v '^send:' monitor.log], [0], [expout])
1843 mv experr expout
1844 AT_CHECK([grep '^send:' monitor.log], [0], [expout])
1845
1846 ovs-appctl -t ovs-ofctl exit
1847 OVS_VSWITCHD_STOP
1848 AT_CLEANUP
1849
1850 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
1851 dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
1852 dnl controllers despite the spec) as meaning a packet that was generated
1853 dnl by the controller.
1854 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.0)])
1855 OVS_VSWITCHD_START
1856 ADD_OF_PORTS([br0], [1])
1857
1858 # Start a monitor listening for packet-ins.
1859 AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
1860 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
1861 ovs-appctl -t ovs-ofctl ofctl/barrier
1862 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1863 AT_CAPTURE_FILE([monitor.log])
1864
1865 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
1866 AT_CHECK([ovs-ofctl packet-out br0 none controller,1 '0001020304050010203040501234'])
1867 AT_CHECK([ovs-ofctl packet-out br0 controller controller,1 '0001020304050010203040505678'])
1868
1869 # Stop the monitor and check its output.
1870 ovs-appctl -t ovs-ofctl ofctl/barrier
1871 ovs-appctl -t ovs-ofctl exit
1872
1873 ovs-ofctl dump-ports br0
1874
1875 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
1876 OFPT_PACKET_IN: total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1877 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
1878 OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
1879 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
1880 OFPT_BARRIER_REPLY:
1881 ])
1882
1883 OVS_VSWITCHD_STOP
1884 AT_CLEANUP
1885
1886 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
1887 dnl specified by OpenFlow 1.2) and OFPP_CONTROLLER (used by some
1888 dnl controllers despite the spec) as meaning a packet that was generated
1889 dnl by the controller.
1890 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.2)])
1891 OVS_VSWITCHD_START
1892
1893 # Start a monitor listening for packet-ins.
1894 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1895 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
1896 ovs-appctl -t ovs-ofctl ofctl/barrier
1897 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1898 AT_CAPTURE_FILE([monitor.log])
1899
1900 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
1901 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none controller '0001020304050010203040501234'])
1902 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 4294967293 controller '0001020304050010203040505678'])
1903
1904 # Stop the monitor and check its output.
1905 ovs-appctl -t ovs-ofctl ofctl/barrier
1906 ovs-appctl -t ovs-ofctl exit
1907
1908 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
1909 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1910 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
1911 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
1912 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
1913 OFPT_BARRIER_REPLY (OF1.2):
1914 ])
1915
1916 OVS_VSWITCHD_STOP
1917 AT_CLEANUP
1918
1919 dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
1920 dnl specified by OpenFlow 1.1) and OFPP_CONTROLLER (used by some
1921 dnl controllers despite the spec) as meaning a packet that was generated
1922 dnl by the controller.
1923 AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.1)])
1924 OVS_VSWITCHD_START
1925
1926 # Start a monitor listening for packet-ins.
1927 AT_CHECK([ovs-ofctl -O OpenFlow11 monitor br0 --detach --no-chdir --pidfile])
1928 ovs-appctl -t ovs-ofctl ofctl/send 0209000c0123456700000080
1929 ovs-appctl -t ovs-ofctl ofctl/barrier
1930 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1931 AT_CAPTURE_FILE([monitor.log])
1932
1933 # Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
1934 AT_CHECK([ovs-ofctl -O OpenFlow11 packet-out br0 none controller '0001020304050010203040501234'])
1935 AT_CHECK([ovs-ofctl -O OpenFlow11 packet-out br0 4294967293 controller '0001020304050010203040505678'])
1936
1937 # Stop the monitor and check its output.
1938 ovs-appctl -t ovs-ofctl ofctl/barrier
1939 ovs-appctl -t ovs-ofctl exit
1940
1941 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
1942 OFPT_PACKET_IN (OF1.1): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
1943 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
1944 OFPT_PACKET_IN (OF1.1): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
1945 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
1946 OFPT_BARRIER_REPLY (OF1.1):
1947 ])
1948
1949 OVS_VSWITCHD_STOP
1950 AT_CLEANUP
1951
1952 dnl This test checks that metadata is encoded in packet_in structures,
1953 dnl supported by NXAST.
1954 AT_SETUP([ofproto - packet-out with metadata (NXM)])
1955 OVS_VSWITCHD_START
1956
1957 # Start a monitor listening for packet-ins.
1958 AT_CHECK([ovs-ofctl -P nxm monitor br0 --detach --no-chdir --pidfile])
1959 ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
1960 ovs-appctl -t ovs-ofctl ofctl/barrier
1961 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1962 AT_CAPTURE_FILE([monitor.log])
1963
1964 # Send a packet-out with a load action to set some metadata, and forward to controller
1965 AT_CHECK([ovs-ofctl packet-out br0 controller 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), load(0xaa->NXM_NX_PKT_MARK[[]]), controller' '0001020304050010203040501234'])
1966
1967 # Stop the monitor and check its output.
1968 ovs-appctl -t ovs-ofctl ofctl/barrier
1969 ovs-appctl -t ovs-ofctl exit
1970
1971 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
1972 NXT_PACKET_IN: total_len=14 in_port=CONTROLLER metadata=0xfafafafa5a5a5a5a pkt_mark=0xaa (via action) data_len=14 (unbuffered)
1973 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
1974 OFPT_BARRIER_REPLY:
1975 ])
1976
1977 OVS_VSWITCHD_STOP
1978 AT_CLEANUP
1979
1980 dnl This test checks that metadata is encoded in packet_in structures,
1981 dnl supported by NXAST.
1982 AT_SETUP([ofproto - packet-out with metadata (OpenFlow 1.2)])
1983 OVS_VSWITCHD_START
1984
1985 # Start a monitor listening for packet-ins.
1986 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1987 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
1988 ovs-appctl -t ovs-ofctl ofctl/barrier
1989 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1990 AT_CAPTURE_FILE([monitor.log])
1991
1992 # Send a packet-out with a load action to set some metadata, and forward to controller
1993 AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), controller' '0001020304050010203040501234'])
1994
1995 # Stop the monitor and check its output.
1996 ovs-appctl -t ovs-ofctl ofctl/barrier
1997 ovs-appctl -t ovs-ofctl exit
1998
1999 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2000 OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY metadata=0xfafafafa5a5a5a5a (via action) data_len=14 (unbuffered)
2001 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
2002 OFPT_BARRIER_REPLY (OF1.2):
2003 ])
2004
2005 OVS_VSWITCHD_STOP
2006 AT_CLEANUP
2007
2008 dnl This test checks that tunnel metadata is encoded in packet_in structures.
2009 AT_SETUP([ofproto - packet-out with tunnel metadata (OpenFlow 1.2)])
2010 OVS_VSWITCHD_START
2011
2012 # Start a monitor listening for packet-ins.
2013 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
2014 ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
2015 ovs-appctl -t ovs-ofctl ofctl/barrier
2016 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2017 AT_CAPTURE_FILE([monitor.log])
2018
2019 # Send a packet-out with set field actions to set some tunnel metadata, and forward to controller
2020 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'])
2021
2022 # Stop the monitor and check its output.
2023 ovs-appctl -t ovs-ofctl ofctl/barrier
2024 ovs-appctl -t ovs-ofctl exit
2025
2026 AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2027 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)
2028 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
2029 OFPT_BARRIER_REPLY (OF1.2):
2030 ])
2031
2032 OVS_VSWITCHD_STOP
2033 AT_CLEANUP
2034
2035 AT_SETUP([ofproto - flow monitoring])
2036 AT_KEYWORDS([monitor])
2037 OVS_VSWITCHD_START
2038
2039 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
2040
2041 # Start a monitor watching the flow table and check the initial reply.
2042 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
2043 AT_CAPTURE_FILE([monitor.log])
2044 ovs-appctl -t ovs-ofctl ofctl/barrier
2045 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
2046   [NXST_FLOW_MONITOR reply:
2047  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
2048 OFPT_BARRIER_REPLY:
2049 ])
2050
2051 # Add, delete, and modify some flows and check the updates.
2052 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2053 ovs-ofctl add-flow br0 in_port=0,dl_vlan=124,actions=output:2
2054 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:5
2055 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=0,actions=output:6
2056 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=1,actions=output:7
2057 ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:8
2058 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=0,actions=output:9
2059 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=1,actions=output:10
2060 ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,actions=output:11
2061 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=0,actions=output:12
2062 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=1,actions=output:13
2063 ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,actions=output:14
2064 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:15
2065 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:16
2066 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:17
2067 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:18
2068 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:19
2069 ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:20
2070 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=0,actions=output:21
2071 ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=1,actions=output:22
2072 ovs-ofctl add-flow br0 in_port=0,actions=output:23
2073 ovs-ofctl mod-flows br0 cookie=5,dl_vlan=123,actions=output:3
2074 ovs-ofctl del-flows br0 dl_vlan=123
2075 ovs-ofctl del-flows br0
2076 ovs-appctl -t ovs-ofctl ofctl/barrier
2077 sort='
2078     # Sorts groups of lines that start with a space, without moving them
2079     # past the nearest line that does not start with a space.
2080     use warnings;
2081     use strict;
2082     my @buffer = ();
2083     while (<STDIN>) {
2084         if (/^ /) {
2085             push(@buffer, $_);
2086         } else {
2087             print $_ foreach sort(@buffer);
2088             print $_;
2089             @buffer = ();
2090         }
2091     }
2092     print $_ foreach sort(@buffer);
2093 '
2094 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | ${PERL} -e "$sort"], [0],
2095 [NXST_FLOW_MONITOR reply (xid=0x0):
2096  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
2097 NXST_FLOW_MONITOR reply (xid=0x0):
2098  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:5
2099 NXST_FLOW_MONITOR reply (xid=0x0):
2100  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:6
2101 NXST_FLOW_MONITOR reply (xid=0x0):
2102  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:7
2103 NXST_FLOW_MONITOR reply (xid=0x0):
2104  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:8
2105 NXST_FLOW_MONITOR reply (xid=0x0):
2106  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:9
2107 NXST_FLOW_MONITOR reply (xid=0x0):
2108  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:10
2109 NXST_FLOW_MONITOR reply (xid=0x0):
2110  event=ADDED table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
2111 NXST_FLOW_MONITOR reply (xid=0x0):
2112  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
2113 NXST_FLOW_MONITOR reply (xid=0x0):
2114  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
2115 NXST_FLOW_MONITOR reply (xid=0x0):
2116  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
2117 NXST_FLOW_MONITOR reply (xid=0x0):
2118  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:15
2119 NXST_FLOW_MONITOR reply (xid=0x0):
2120  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:16
2121 NXST_FLOW_MONITOR reply (xid=0x0):
2122  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:17
2123 NXST_FLOW_MONITOR reply (xid=0x0):
2124  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
2125 NXST_FLOW_MONITOR reply (xid=0x0):
2126  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
2127 NXST_FLOW_MONITOR reply (xid=0x0):
2128  event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
2129 NXST_FLOW_MONITOR reply (xid=0x0):
2130  event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
2131 NXST_FLOW_MONITOR reply (xid=0x0):
2132  event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
2133 NXST_FLOW_MONITOR reply (xid=0x0):
2134  event=ADDED table=0 cookie=0 in_port=0 actions=output:23
2135 NXST_FLOW_MONITOR reply (xid=0x0):
2136  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
2137  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
2138  event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
2139 NXST_FLOW_MONITOR reply (xid=0x0):
2140  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
2141  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
2142  event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
2143 NXST_FLOW_MONITOR reply (xid=0x0):
2144  event=DELETED reason=delete table=0 cookie=0 in_port=0 actions=output:23
2145  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
2146  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
2147  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
2148  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
2149  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
2150  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
2151  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
2152  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
2153  event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
2154  event=DELETED reason=delete table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
2155 OFPT_BARRIER_REPLY:
2156 ])
2157
2158 # Check that our own changes are reported as abbreviations.
2159 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2160 ovs-ofctl add-flow br0 in_port=1,actions=output:2
2161 ovs-ofctl add-flow br0 in_port=2,actions=output:1
2162 ovs-appctl -t ovs-ofctl ofctl/barrier
2163 ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
2164 ovs-appctl -t ovs-ofctl ofctl/barrier
2165 AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
2166 ])
2167 AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
2168 [NXST_FLOW_MONITOR reply (xid=0x0):
2169  event=ADDED table=0 cookie=0 in_port=1 actions=output:2
2170 NXST_FLOW_MONITOR reply (xid=0x0):
2171  event=ADDED table=0 cookie=0 in_port=2 actions=output:1
2172 OFPT_BARRIER_REPLY:
2173 send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
2174 NXST_FLOW_MONITOR reply (xid=0x0):
2175  event=ABBREV xid=0x12345678
2176 OFPT_BARRIER_REPLY:
2177 ])
2178
2179 ovs-appctl -t ovs-ofctl exit
2180 OVS_VSWITCHD_STOP
2181 AT_CLEANUP
2182
2183 AT_SETUP([ofproto - flow monitoring pause and resume])
2184 AT_KEYWORDS([monitor])
2185
2186 # The maximum socket receive buffer size is important for this test, which
2187 # tests behavior when the receive buffer overflows.
2188 if test -e /proc/sys/net/core/rmem_max; then
2189     # Linux
2190     rmem_max=`cat /proc/sys/net/core/rmem_max`
2191 elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
2192     : # FreeBSD, NetBSD
2193 else
2194     # Don't know how to get maximum socket receive buffer on this OS
2195     AT_SKIP_IF([:])
2196 fi
2197 # Calculate the total amount of queuing: rmem_max in the kernel, 128 kB
2198 # in ofproto sending userspace (see ofmonitor_flush() in connmgr.c).
2199 queue_size=`expr $rmem_max + 128 \* 1024`
2200 echo rmem_max=$rmem_max queue_size=$queue_size
2201
2202 # If there's too much queuing skip the test to avoid timing out.
2203 AT_SKIP_IF([test $rmem_max -gt 1048576])
2204
2205 # Each flow update message takes up at least 48 bytes of space in queues
2206 # and in practice more than that.
2207 n_msgs=`expr $queue_size / 48`
2208 echo n_msgs=$n_msgs
2209
2210 OVS_VSWITCHD_START
2211
2212 # Start a monitor watching the flow table, then make it block.
2213 ON_EXIT([kill `cat ovs-ofctl.pid`])
2214 ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
2215 AT_CAPTURE_FILE([monitor.log])
2216 ovs-appctl -t ovs-ofctl ofctl/block
2217
2218 # Add $n_msgs flows.
2219 (echo "in_port=2,actions=output:2"
2220 ${PERL} -e '
2221     for ($i = 0; $i < '$n_msgs'; $i++) {
2222         print "cookie=1,reg1=$i,actions=drop\n";
2223     }
2224 ') > flows.txt
2225 AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
2226 # Check that multipart flow dumps work properly:
2227 AT_CHECK([ovs-ofctl diff-flows br0 flows.txt])
2228 AT_CHECK([ovs-ofctl add-flow br0 in_port=1,cookie=3,actions=drop])
2229 AT_CHECK([ovs-ofctl mod-flows br0 in_port=2,cookie=2,actions=output:2])
2230 AT_CHECK([ovs-ofctl del-flows br0 cookie=1/-1])
2231
2232 ovs-appctl -t ovs-ofctl ofctl/unblock
2233
2234 # Wait for the connection resumed.
2235 # A barrier doesn't work for this purpose.
2236 #    https://www.mail-archive.com/dev@openvswitch.org/msg27013.html
2237 #    https://www.mail-archive.com/dev@openvswitch.org/msg27675.html
2238 OVS_WAIT_UNTIL([grep NXT_FLOW_MONITOR_RESUMED monitor.log])
2239
2240 ovs-appctl -t ovs-ofctl exit
2241
2242 # Check that the flow monitor reported the same number of flows
2243 # added and deleted, but fewer than we actually added and deleted.
2244 adds=`grep -c 'ADDED.*reg1=' monitor.log`
2245 deletes=`grep -c 'DELETED.*reg1=' monitor.log`
2246 echo adds=$adds deletes=$deletes
2247 AT_CHECK([test $adds -gt 100 && test $adds -lt $n_msgs])
2248 AT_CHECK([test $adds = $deletes])
2249
2250 # Check that the flow monitor reported everything in the expected order:
2251 #
2252 #     event=ADDED table=0 cookie=0x1 reg1=0x22
2253 # ...
2254 #    NXT_FLOW_MONITOR_PAUSED:
2255 # ...
2256 #     event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
2257 # ...
2258 #     event=ADDED table=0 cookie=0x3 in_port=1
2259 #     event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
2260 #    NXT_FLOW_MONITOR_RESUMED:
2261 #
2262 # except that, between the PAUSED and RESUMED, the order of the ADDED
2263 # and MODIFIED lines lines depends on hash order, that is, it varies
2264 # as we change the hash function or change architecture.  Therefore,
2265 # we use a couple of tests below to accept both orders.
2266 AT_CHECK([ofctl_strip < monitor.log | sed -n -e '
2267 /reg1=0x22$/p
2268 /cookie=0x[[23]]/p
2269 /NXT_FLOW_MONITOR_PAUSED:/p
2270 /NXT_FLOW_MONITOR_RESUMED:/p
2271 ' > monitor.log.subset])
2272 AT_CHECK([grep -v MODIFIED monitor.log.subset], [0], [dnl
2273  event=ADDED table=0 cookie=0x1 reg1=0x22
2274 NXT_FLOW_MONITOR_PAUSED:
2275  event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
2276  event=ADDED table=0 cookie=0x3 in_port=1
2277 NXT_FLOW_MONITOR_RESUMED:
2278 ])
2279 AT_CHECK([grep -v ADDED monitor.log.subset], [0], [dnl
2280 NXT_FLOW_MONITOR_PAUSED:
2281  event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
2282  event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
2283 NXT_FLOW_MONITOR_RESUMED:
2284 ])
2285
2286 OVS_VSWITCHD_STOP
2287 AT_CLEANUP
2288
2289 AT_SETUP([ofproto - event filtering (OpenFlow 1.3)])
2290 AT_KEYWORDS([monitor])
2291 OVS_VSWITCHD_START
2292
2293 # Start a monitor, use the required protocol version
2294 ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2295 AT_CAPTURE_FILE([monitor.log])
2296
2297 # Send an OpenFlow13 message (04), OFPT_GET_ASYNC_REQUEST (1a), length (8), xid (0a)
2298 ovs-appctl -t ovs-ofctl ofctl/send 041a00080000000a
2299 ovs-appctl -t ovs-ofctl ofctl/barrier
2300
2301 # Check default setting
2302 read -r -d '' expected <<'EOF'
2303 EOF
2304
2305 AT_CHECK([ofctl_strip < monitor.log], [], [dnl
2306 send: OFPT_GET_ASYNC_REQUEST (OF1.3):
2307 OFPT_GET_ASYNC_REPLY (OF1.3):
2308  master:
2309        PACKET_IN: no_match action
2310      PORT_STATUS: add delete modify
2311     FLOW_REMOVED: idle hard delete
2312
2313  slave:
2314        PACKET_IN: (off)
2315      PORT_STATUS: add delete modify
2316     FLOW_REMOVED: (off)
2317 OFPT_BARRIER_REPLY (OF1.3):
2318 ])
2319
2320 OVS_VSWITCHD_STOP
2321 AT_CLEANUP
2322
2323 AT_SETUP([ofproto - ofport_request])
2324 OVS_VSWITCHD_START
2325 ADD_OF_PORTS([br0], [1], [2], [3])
2326
2327 set_and_check_specific_ofports () {
2328     ovs-vsctl set Interface p1 ofport_request="$1" -- \
2329               set Interface p2 ofport_request="$2" -- \
2330               set Interface p3 ofport_request="$3"
2331     ofports=`ovs-vsctl get Interface p1 ofport -- \
2332                        get Interface p2 ofport -- \
2333                        get Interface p3 ofport`
2334     AT_CHECK_UNQUOTED([echo $ofports], [0], [$1 $2 $3
2335 ])
2336 }
2337 for pre in      '1 2 3' '1 3 2' '2 1 3' '2 3 1' '3 1 2' '3 2 1'; do
2338     for post in '1 2 3' '1 3 2' '2 1 3' '2 3 1' '3 1 2' '3 2 1'; do
2339         echo -----------------------------------------------------------
2340         echo "Check changing port numbers from $pre to $post"
2341         set_and_check_ofports $pre
2342         set_and_check_ofports $post
2343     done
2344 done
2345
2346 ovs-vsctl del-port p3
2347
2348 set_and_check_poorly_specified_ofports () {
2349     ovs-vsctl set Interface p1 ofport_request="$1" -- \
2350               set Interface p2 ofport_request="$2"
2351     p1=`ovs-vsctl get Interface p1 ofport`
2352     p2=`ovs-vsctl get Interface p2 ofport`
2353     echo $p1 $p2
2354
2355     AT_CHECK([test "$p1" != "$p2"])
2356     if test "$1" = "$2" && test "$1" != '[[]]'; then
2357         # One port number must be the requested one.
2358         AT_CHECK([test "$p1" = "$1" || test "$p2" = "$1"])
2359         # The other port number must be different (already tested above).
2360     else
2361         AT_CHECK([test "$1" = '[[]]' || test "$p1" == "$1"])
2362         AT_CHECK([test "$2" = '[[]]' || test "$p2" == "$2"])
2363     fi
2364 }
2365 for pre in      '1 2' '[[]] 2' '1 [[]]' '[[]] [[]]' '2 1' '[[]] 1' '2 [[]]' \
2366                 '1 1' '2 2'; do
2367     for post in '1 2' '[[]] 2' '1 [[]]' '[[]] [[]]' '2 1' '[[]] 1' '2 [[]]' \
2368                 '1 1' '2 2'; do
2369         echo -----------------------------------------------------------
2370         echo "Check changing port numbers from $pre to $post"
2371         set_and_check_poorly_specified_ofports $pre
2372         set_and_check_poorly_specified_ofports $post
2373     done
2374 done
2375 OVS_VSWITCHD_STOP
2376 AT_CLEANUP
2377
2378
2379 AT_SETUP([ofproto - bundles, open (OpenFlow 1.4)])
2380 AT_KEYWORDS([monitor])
2381 OVS_VSWITCHD_START
2382
2383 # Start a monitor, use the required protocol version
2384 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2385 AT_CAPTURE_FILE([monitor.log])
2386
2387 # Send an OpenFlow14 message (05), OFPT_BUNDLE_CONTROL (21), length (10), xid (0a)
2388 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2389 ovs-appctl -t ovs-ofctl ofctl/barrier
2390 ovs-appctl -t ovs-ofctl exit
2391
2392 AT_CHECK([ofctl_strip < monitor.log], [], [dnl
2393 send: OFPT_BUNDLE_CONTROL (OF1.4):
2394  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2395 OFPT_BUNDLE_CONTROL (OF1.4):
2396  bundle_id=0x1 type=OPEN_REPLY flags=0
2397 OFPT_BARRIER_REPLY (OF1.4):
2398 ])
2399
2400 OVS_VSWITCHD_STOP
2401 AT_CLEANUP
2402
2403 AT_SETUP([ofproto - bundles, double open (OpenFlow 1.4)])
2404 AT_KEYWORDS([monitor])
2405 OVS_VSWITCHD_START
2406
2407 # Start a monitor, use the required protocol version
2408 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2409 AT_CAPTURE_FILE([monitor.log])
2410
2411 # Send twice an OpenFlow14 message (05), OFPT_BUNDLE_CONTROL (21), length (10), xid (0a)
2412 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2413 ovs-appctl -t ovs-ofctl ofctl/barrier
2414 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2415 ovs-appctl -t ovs-ofctl ofctl/barrier
2416 ovs-appctl -t ovs-ofctl exit
2417
2418 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2419 send: OFPT_BUNDLE_CONTROL (OF1.4):
2420  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2421 OFPT_BUNDLE_CONTROL (OF1.4):
2422  bundle_id=0x1 type=OPEN_REPLY flags=0
2423 OFPT_BARRIER_REPLY (OF1.4):
2424 send: OFPT_BUNDLE_CONTROL (OF1.4):
2425  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2426 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
2427 OFPT_BUNDLE_CONTROL (OF1.4):
2428  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2429 OFPT_BARRIER_REPLY (OF1.4):
2430 ])
2431
2432 OVS_VSWITCHD_STOP
2433 AT_CLEANUP
2434
2435 AT_SETUP([ofproto - bundle close without open (OpenFlow 1.4)])
2436 AT_KEYWORDS([monitor])
2437 OVS_VSWITCHD_START
2438
2439 # Start a monitor, use the required protocol version
2440 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2441 AT_CAPTURE_FILE([monitor.log])
2442
2443 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 01"
2444 ovs-appctl -t ovs-ofctl ofctl/barrier
2445 ovs-appctl -t ovs-ofctl exit
2446
2447 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2448 send: OFPT_BUNDLE_CONTROL (OF1.4):
2449  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
2450 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
2451 OFPT_BUNDLE_CONTROL (OF1.4):
2452  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
2453 OFPT_BARRIER_REPLY (OF1.4):
2454 ])
2455
2456 OVS_VSWITCHD_STOP
2457 AT_CLEANUP
2458
2459 AT_SETUP([ofproto - bundle double close (OpenFlow 1.4)])
2460 AT_KEYWORDS([monitor])
2461 OVS_VSWITCHD_START
2462
2463 # Start a monitor, use the required protocol version
2464 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2465 AT_CAPTURE_FILE([monitor.log])
2466
2467 # Open, Close, Close
2468 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2469 ovs-appctl -t ovs-ofctl ofctl/barrier
2470 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 01"
2471 ovs-appctl -t ovs-ofctl ofctl/barrier
2472 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 01"
2473 ovs-appctl -t ovs-ofctl ofctl/barrier
2474 ovs-appctl -t ovs-ofctl exit
2475
2476 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2477 send: OFPT_BUNDLE_CONTROL (OF1.4):
2478  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2479 OFPT_BUNDLE_CONTROL (OF1.4):
2480  bundle_id=0x1 type=OPEN_REPLY flags=0
2481 OFPT_BARRIER_REPLY (OF1.4):
2482 send: OFPT_BUNDLE_CONTROL (OF1.4):
2483  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
2484 OFPT_BUNDLE_CONTROL (OF1.4):
2485  bundle_id=0x1 type=CLOSE_REPLY flags=0
2486 OFPT_BARRIER_REPLY (OF1.4):
2487 send: OFPT_BUNDLE_CONTROL (OF1.4):
2488  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
2489 OFPT_ERROR (OF1.4): OFPBFC_BUNDLE_CLOSED
2490 OFPT_BUNDLE_CONTROL (OF1.4):
2491  bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
2492 OFPT_BARRIER_REPLY (OF1.4):
2493 ])
2494
2495 OVS_VSWITCHD_STOP
2496 AT_CLEANUP
2497
2498 AT_SETUP([ofproto - bundle close, different flags (OpenFlow 1.4)])
2499 AT_KEYWORDS([monitor])
2500 OVS_VSWITCHD_START
2501
2502 # Start a monitor, use the required protocol version
2503 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2504 AT_CAPTURE_FILE([monitor.log])
2505
2506 # Open, Close, Close
2507 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2508 ovs-appctl -t ovs-ofctl ofctl/barrier
2509 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 02"
2510 ovs-appctl -t ovs-ofctl ofctl/barrier
2511 ovs-appctl -t ovs-ofctl exit
2512
2513 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2514 send: OFPT_BUNDLE_CONTROL (OF1.4):
2515  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2516 OFPT_BUNDLE_CONTROL (OF1.4):
2517  bundle_id=0x1 type=OPEN_REPLY flags=0
2518 OFPT_BARRIER_REPLY (OF1.4):
2519 send: OFPT_BUNDLE_CONTROL (OF1.4):
2520  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
2521 OFPT_ERROR (OF1.4): OFPBFC_BAD_FLAGS
2522 OFPT_BUNDLE_CONTROL (OF1.4):
2523  bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
2524 OFPT_BARRIER_REPLY (OF1.4):
2525 ])
2526
2527 OVS_VSWITCHD_STOP
2528 AT_CLEANUP
2529
2530 AT_SETUP([ofproto - bundle commit without open (OpenFlow 1.4)])
2531 AT_KEYWORDS([monitor])
2532 OVS_VSWITCHD_START
2533
2534 # Start a monitor, use the required protocol version
2535 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2536 AT_CAPTURE_FILE([monitor.log])
2537
2538 # Open, Close, Close
2539 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 04 00 01"
2540 ovs-appctl -t ovs-ofctl ofctl/barrier
2541 ovs-appctl -t ovs-ofctl exit
2542
2543 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2544 send: OFPT_BUNDLE_CONTROL (OF1.4):
2545  bundle_id=0x1 type=COMMIT_REQUEST flags=atomic
2546 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
2547 OFPT_BUNDLE_CONTROL (OF1.4):
2548  bundle_id=0x1 type=COMMIT_REQUEST flags=atomic
2549 OFPT_BARRIER_REPLY (OF1.4):
2550 ])
2551
2552 OVS_VSWITCHD_STOP
2553 AT_CLEANUP
2554
2555 AT_SETUP([ofproto - bundle commit, different flags (OpenFlow 1.4)])
2556 AT_KEYWORDS([monitor])
2557 OVS_VSWITCHD_START
2558
2559 # Start a monitor, use the required protocol version
2560 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2561 AT_CAPTURE_FILE([monitor.log])
2562
2563 # Open, Close, Close
2564 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2565 ovs-appctl -t ovs-ofctl ofctl/barrier
2566 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 04 00 02"
2567 ovs-appctl -t ovs-ofctl ofctl/barrier
2568 ovs-appctl -t ovs-ofctl exit
2569
2570 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2571 send: OFPT_BUNDLE_CONTROL (OF1.4):
2572  bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2573 OFPT_BUNDLE_CONTROL (OF1.4):
2574  bundle_id=0x1 type=OPEN_REPLY flags=0
2575 OFPT_BARRIER_REPLY (OF1.4):
2576 send: OFPT_BUNDLE_CONTROL (OF1.4):
2577  bundle_id=0x1 type=COMMIT_REQUEST flags=ordered
2578 OFPT_ERROR (OF1.4): OFPBFC_BAD_FLAGS
2579 OFPT_BUNDLE_CONTROL (OF1.4):
2580  bundle_id=0x1 type=COMMIT_REQUEST flags=ordered
2581 OFPT_BARRIER_REPLY (OF1.4):
2582 ])
2583
2584 OVS_VSWITCHD_STOP
2585 AT_CLEANUP
2586
2587 AT_SETUP([ofproto - bundle discard without open (OpenFlow 1.4)])
2588 AT_KEYWORDS([monitor])
2589 OVS_VSWITCHD_START
2590
2591 # Start a monitor, use the required protocol version
2592 ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2593 AT_CAPTURE_FILE([monitor.log])
2594
2595 # Open, Close, Close
2596 ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 06 00 01"
2597 ovs-appctl -t ovs-ofctl ofctl/barrier
2598 ovs-appctl -t ovs-ofctl exit
2599
2600 AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2601 send: OFPT_BUNDLE_CONTROL (OF1.4):
2602  bundle_id=0x1 type=DISCARD_REQUEST flags=atomic
2603 OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
2604 OFPT_BUNDLE_CONTROL (OF1.4):
2605  bundle_id=0x1 type=DISCARD_REQUEST flags=atomic
2606 OFPT_BARRIER_REPLY (OF1.4):
2607 ])
2608
2609 OVS_VSWITCHD_STOP
2610 AT_CLEANUP