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