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