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