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