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