]> git.proxmox.com Git - ovs.git/blame - tests/ofproto.at
Process RARP packets with ethertype 0x8035 similar to ARP packets.
[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
BP
17 LOCAL(br0): addr:aa:55:aa:55:00:00
18 config: PORT_DOWN
19 state: LINK_DOWN
9e1fd49b 20 speed: 100 Mbps now, 100 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
42 speed: 100 Mbps now, 100 Mbps max
e44768b7 43 99(p2): addr:aa:55:aa:55:00:0x
81816a5f
JP
44 config: PORT_DOWN
45 state: LINK_DOWN
46 speed: 100 Mbps now, 100 Mbps max
e44768b7 47 LOCAL(br0): addr:aa:55:aa:55:00:0x
81816a5f
JP
48 config: PORT_DOWN
49 state: LINK_DOWN
50 speed: 100 Mbps now, 100 Mbps max
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.
59AT_SETUP([ofproto - port stats])
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
64 port 65534: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
65 tx pkts=0, bytes=0, drop=0, errs=0, coll=0
66])
023e1e0a 67OVS_VSWITCHD_STOP
eaa6eb2a
BP
68AT_CLEANUP
69
2be393ed
JP
70dnl This is really bare-bones.
71dnl It at least checks request and reply serialization and deserialization.
72AT_SETUP([ofproto - port-desc stats])
73OVS_VSWITCHD_START
74AT_CHECK([ovs-ofctl -vwarn dump-ports-desc br0], [0], [stdout])
75AT_CHECK([STRIP_XIDS stdout], [0], [dnl
76OFPST_PORT_DESC reply:
77 LOCAL(br0): addr:aa:55:aa:55:00:00
78 config: PORT_DOWN
79 state: LINK_DOWN
80 speed: 100 Mbps now, 100 Mbps max
81])
82OVS_VSWITCHD_STOP
83AT_CLEANUP
84
eaa6eb2a
BP
85dnl This is really bare-bones.
86dnl It at least checks request and reply serialization and deserialization.
87AT_SETUP([ofproto - queue stats])
023e1e0a 88OVS_VSWITCHD_START
ea523221 89AT_CHECK([ovs-ofctl -vwarn queue-stats br0], [0], [stdout])
eaa6eb2a
BP
90AT_CHECK([STRIP_XIDS stdout], [0], [dnl
91OFPST_QUEUE reply: 0 queues
92])
0414d158 93AT_CHECK([ovs-ofctl -vwarn queue-stats br0 ALL 5], [0],
53514387
SH
94 [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_QUEUE
95OFPST_QUEUE request (xid=0x2):port=ALL queue=5
0414d158
BP
96])
97AT_CHECK([ovs-ofctl -vwarn queue-stats br0 10], [0],
53514387
SH
98 [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_PORT
99OFPST_QUEUE request (xid=0x2):port=10 queue=ALL
0414d158 100])
023e1e0a 101OVS_VSWITCHD_STOP
eaa6eb2a
BP
102AT_CLEANUP
103
a2cb9dfd 104AT_SETUP([ofproto - mod-port])
023e1e0a 105OVS_VSWITCHD_START
a2cb9dfd
BP
106for command_config_state in \
107 'up 0 0' \
0ab14c8e
BP
108 'noflood NO_FLOOD 0' \
109 'down PORT_DOWN,NO_FLOOD LINK_DOWN' \
28124950
BP
110 'flood PORT_DOWN LINK_DOWN' \
111 'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
112 'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
113 'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
114 'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
115 'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
116 'up NO_RECV 0' \
117 'receive 0 0'
a2cb9dfd
BP
118do
119 set $command_config_state
0ab14c8e 120 command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
ea523221
BP
121 AT_CHECK([ovs-ofctl -vwarn mod-port br0 br0 $command])
122 AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
640c7c94 123 AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
9e1fd49b 124OFPT_FEATURES_REPLY: dpid:fedcba9876543210
c2f0373a 125n_tables:254, n_buffers:256
9e1fd49b
BP
126capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
127actions: 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
128 LOCAL(br0): addr:aa:55:aa:55:00:00
129 config: $config
130 state: $state
9e1fd49b 131 speed: 100 Mbps now, 100 Mbps max
3b62feba 132OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
a2cb9dfd
BP
133])
134done
023e1e0a 135OVS_VSWITCHD_STOP
a2cb9dfd 136AT_CLEANUP
640c7c94 137
c168dcc8 138AT_SETUP([ofproto - basic flow_mod commands (NXM)])
023e1e0a 139OVS_VSWITCHD_START
ef0ce8ae 140AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
640c7c94 141])
c6100d92
BP
142AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl add-flows br0 -])
143AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=2])
144AT_CHECK([ovs-ofctl -F nxm add-flow br0 table=1,in_port=4,actions=3])
ef0ce8ae 145AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
146 in_port=1 actions=output:2
147 in_port=2 actions=output:1
148 table=1, in_port=4 actions=output:3
0721c073 149NXST_FLOW reply:
640c7c94 150])
0697b5c3 151AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
c168dcc8
BP
152NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
153])
640c7c94 154AT_CHECK([ovs-ofctl del-flows br0])
ef0ce8ae 155AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
640c7c94 156])
023e1e0a 157OVS_VSWITCHD_STOP
640c7c94 158AT_CLEANUP
c168dcc8
BP
159
160AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.0)])
023e1e0a 161OVS_VSWITCHD_START
ef0ce8ae 162AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
c168dcc8 163])
c6100d92
BP
164AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -F openflow10 add-flows br0 -])
165AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 in_port=1,actions=2])
166AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 table=1,in_port=4,actions=3])
ef0ce8ae 167AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
168 in_port=1 actions=output:2
169 in_port=2 actions=output:1
170 table=1, in_port=4 actions=output:3
c168dcc8
BP
171OFPST_FLOW reply:
172])
0697b5c3 173AT_CHECK([ovs-ofctl -F openflow10 dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
c168dcc8
BP
174OFPST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
175])
176AT_CHECK([ovs-ofctl -F openflow10 del-flows br0])
ef0ce8ae 177AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
c168dcc8 178])
023e1e0a 179OVS_VSWITCHD_STOP
c168dcc8 180AT_CLEANUP
e729e793 181
f5c45121
SH
182AT_SETUP([ofproto - set-field flow_mod commands (NXM)])
183OVS_VSWITCHD_START
184AT_CHECK([ovs-ofctl add-flow br0 ipv6,table=1,in_port=3,actions=drop])
185AT_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])
186AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
187 table=1, ipv6,in_port=3 actions=load:0xa6badbfffefe59fa->NXM_NX_IPV6_SRC[[0..63]],load:0xfe8001234567890a->NXM_NX_IPV6_SRC[[64..127]]
188NXST_FLOW reply:
189])
190OVS_VSWITCHD_STOP
191AT_CLEANUP
192
e729e793
JP
193AT_SETUP([ofproto - dump flows with cookie])
194OVS_VSWITCHD_START
c6100d92
BP
195AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
196AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
197AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
ef0ce8ae 198AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
199 cookie=0x1, in_port=1 actions=output:1
200 cookie=0x2, in_port=2 actions=output:1
201 cookie=0x3, in_port=3 actions=output:1
e729e793
JP
202NXST_FLOW reply:
203])
204AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
205NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
206])
623e1caf 207AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/-1 | ofctl_strip | sort], [0], [dnl
c6100d92 208 cookie=0x3, in_port=3 actions=output:1
e729e793
JP
209NXST_FLOW reply:
210])
623e1caf 211AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/-1 | STRIP_XIDS], [0], [dnl
e729e793
JP
212NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=1
213])
214OVS_VSWITCHD_STOP
215AT_CLEANUP
216
217AT_SETUP([ofproto - dump flows with cookie mask])
218OVS_VSWITCHD_START
c6100d92
BP
219AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
220AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
221AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
ef0ce8ae 222AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
223 cookie=0x1, in_port=1 actions=output:1
224 cookie=0x2, in_port=2 actions=output:1
225 cookie=0x3, in_port=3 actions=output:1
e729e793
JP
226NXST_FLOW reply:
227])
228AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
229NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
230])
ef0ce8ae 231AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/0x1 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
232 cookie=0x1, in_port=1 actions=output:1
233 cookie=0x3, in_port=3 actions=output:1
e729e793
JP
234NXST_FLOW reply:
235])
236AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/0x1 | STRIP_XIDS], [0], [dnl
237NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
238])
239OVS_VSWITCHD_STOP
240AT_CLEANUP
241
623e1caf
JP
242AT_SETUP([ofproto - mod flow with cookie change (OpenFlow 1.0)])
243OVS_VSWITCHD_START
c6100d92 244AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 cookie=0x1,in_port=1,actions=1])
623e1caf 245AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 246 cookie=0x1, in_port=1 actions=output:1
623e1caf
JP
247OFPST_FLOW reply:
248])
249
c6100d92 250AT_CHECK([ovs-ofctl -F openflow10 mod-flows br0 cookie=0x2,in_port=1,actions=1])
623e1caf 251AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 252 cookie=0x2, in_port=1 actions=output:1
623e1caf
JP
253OFPST_FLOW reply:
254])
255OVS_VSWITCHD_STOP
256AT_CLEANUP
257
258AT_SETUP([ofproto - mod flow with cookie change (NXM)])
259OVS_VSWITCHD_START
c6100d92 260AT_CHECK([ovs-ofctl -F nxm add-flow br0 cookie=0x1,in_port=1,actions=1])
623e1caf 261AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 262 cookie=0x1, in_port=1 actions=output:1
623e1caf
JP
263NXST_FLOW reply:
264])
265
c6100d92 266AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x2,in_port=1,actions=1])
623e1caf 267AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 268 cookie=0x2, in_port=1 actions=output:1
623e1caf
JP
269NXST_FLOW reply:
270])
271OVS_VSWITCHD_STOP
272AT_CLEANUP
273
274AT_SETUP([ofproto - mod flows based on cookie mask])
275OVS_VSWITCHD_START
c6100d92
BP
276AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
277AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
278AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
623e1caf 279AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
280 cookie=0x1, in_port=1 actions=output:1
281 cookie=0x1, in_port=2 actions=output:1
282 cookie=0x2, in_port=3 actions=output:1
623e1caf
JP
283NXST_FLOW reply:
284])
285
286AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x1/0xff,actions=4])
287AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
288 cookie=0x1, in_port=1 actions=output:4
289 cookie=0x1, in_port=2 actions=output:4
c6100d92 290 cookie=0x2, in_port=3 actions=output:1
623e1caf
JP
291NXST_FLOW reply:
292])
293OVS_VSWITCHD_STOP
294AT_CLEANUP
295
296AT_SETUP([ofproto - mod flows based on cookie mask with cookie change])
297OVS_VSWITCHD_START
c6100d92
BP
298AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
299AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
300AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
623e1caf 301AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
302 cookie=0x1, in_port=1 actions=output:1
303 cookie=0x1, in_port=2 actions=output:1
304 cookie=0x2, in_port=3 actions=output:1
623e1caf
JP
305NXST_FLOW reply:
306])
307
308AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/-1,cookie=4,actions=4])
309AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 310 cookie=0x2, in_port=3 actions=output:1
623e1caf
JP
311 cookie=0x4, in_port=1 actions=output:4
312 cookie=0x4, in_port=2 actions=output:4
313NXST_FLOW reply:
314])
315OVS_VSWITCHD_STOP
316AT_CLEANUP
317
318AT_SETUP([ofproto - mod flow with cookie miss (mask==0)])
319OVS_VSWITCHD_START
c6100d92 320AT_CHECK([ovs-ofctl -F nxm mod-flows br0 in_port=1,actions=1])
623e1caf 321AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 322 in_port=1 actions=output:1
623e1caf
JP
323NXST_FLOW reply:
324])
325OVS_VSWITCHD_STOP
326AT_CLEANUP
327
328AT_SETUP([ofproto - mod flow with cookie miss (mask!=0)])
329OVS_VSWITCHD_START
c6100d92 330AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/1,in_port=1,actions=1])
623e1caf
JP
331AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
332NXST_FLOW reply:
333])
334OVS_VSWITCHD_STOP
335AT_CLEANUP
336
337AT_SETUP([ofproto - del flows with cookies])
338OVS_VSWITCHD_START
c6100d92
BP
339AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
340AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
341AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
623e1caf 342AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
343 cookie=0x1, in_port=1 actions=output:1
344 cookie=0x2, in_port=2 actions=output:1
345 cookie=0x3, in_port=3 actions=output:1
623e1caf
JP
346NXST_FLOW reply:
347])
348
349AT_CHECK([ovs-ofctl del-flows br0])
350AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
351NXST_FLOW reply:
352])
353OVS_VSWITCHD_STOP
354AT_CLEANUP
355
356AT_SETUP([ofproto - del flows based on cookie])
e729e793 357OVS_VSWITCHD_START
c6100d92
BP
358AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
359AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
360AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
ef0ce8ae 361AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
362 cookie=0x1, in_port=1 actions=output:1
363 cookie=0x2, in_port=2 actions=output:1
364 cookie=0x3, in_port=3 actions=output:1
e729e793
JP
365NXST_FLOW reply:
366])
80d5aefd 367
623e1caf 368AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/-1])
ef0ce8ae 369AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
370 cookie=0x1, in_port=1 actions=output:1
371 cookie=0x2, in_port=2 actions=output:1
e729e793
JP
372NXST_FLOW reply:
373])
374OVS_VSWITCHD_STOP
375AT_CLEANUP
376
623e1caf 377AT_SETUP([ofproto - del flows based on cookie mask])
e729e793 378OVS_VSWITCHD_START
c6100d92
BP
379AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
380AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
381AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
ef0ce8ae 382AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
383 cookie=0x1, in_port=1 actions=output:1
384 cookie=0x2, in_port=2 actions=output:1
385 cookie=0x3, in_port=3 actions=output:1
e729e793
JP
386NXST_FLOW reply:
387])
388AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/0x1])
ef0ce8ae 389AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 390 cookie=0x2, in_port=2 actions=output:1
e729e793
JP
391NXST_FLOW reply:
392])
393OVS_VSWITCHD_STOP
394AT_CLEANUP
254750ce 395
c90cfeaf
SH
396AT_SETUP([ofproto - del flows based on table id])
397OVS_VSWITCHD_START
398AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
399AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
400AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
401 cookie=0x1, in_port=1 actions=output:1
402 cookie=0x2, table=1, in_port=2 actions=output:1
403NXST_FLOW reply:
404])
405AT_CHECK([ovs-ofctl del-flows br0 table=0])
406AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
407 cookie=0x2, table=1, in_port=2 actions=output:1
408NXST_FLOW reply:
409])
410AT_CHECK([ovs-ofctl del-flows br0 table=1])
411AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
412NXST_FLOW reply:
413])
414AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
415AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
416AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
417 cookie=0x1, in_port=1 actions=output:1
418 cookie=0x2, table=1, in_port=2 actions=output:1
419NXST_FLOW reply:
420])
421AT_CHECK([ovs-ofctl del-flows br0])
422AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
423NXST_FLOW reply:
424])
425OVS_VSWITCHD_STOP
426AT_CLEANUP
427
254750ce
BP
428AT_SETUP([ofproto - flow table configuration])
429OVS_VSWITCHD_START
430# Check the default configuration.
c2f0373a 431(echo "OFPST_TABLE reply (xid=0x2): 254 tables
254750ce
BP
432 0: classifier: wild=0x3fffff, max=1000000, active=0
433 lookup=0, matched=0"
434 x=1
c57b2226 435 while test $x -lt 254; do
254750ce
BP
436 printf " %d: %-8s: wild=0x3fffff, max=1000000, active=0
437 lookup=0, matched=0
438" $x table$x
439 x=`expr $x + 1`
c2f0373a 440 done) > expout
254750ce
BP
441AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
442# Change the configuration.
443AT_CHECK(
444 [ovs-vsctl \
445 -- --id=@t0 create Flow_Table name=main \
446 -- --id=@t1 create Flow_Table flow-limit=1024 \
447 -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
448 | perl $srcdir/uuidfilt.pl],
449 [0], [<0>
450<1>
451])
452# Check that the configuration was updated.
453mv expout orig-expout
c2f0373a 454(echo "OFPST_TABLE reply (xid=0x2): 254 tables
254750ce
BP
455 0: main : wild=0x3fffff, max=1000000, active=0
456 lookup=0, matched=0
457 1: table1 : wild=0x3fffff, max= 1024, active=0
458 lookup=0, matched=0"
459 tail -n +6 orig-expout) > expout
460AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
461OVS_VSWITCHD_STOP
462AT_CLEANUP
463
464AT_SETUP([ofproto - hard limits on flow table size])
465OVS_VSWITCHD_START
466# Configure a maximum of 4 flows.
467AT_CHECK(
468 [ovs-vsctl \
469 -- --id=@t0 create Flow_Table flow-limit=4 \
470 -- set bridge br0 flow_tables:0=@t0 \
471 | perl $srcdir/uuidfilt.pl],
472 [0], [<0>
473])
474# Add 4 flows.
475for in_port in 1 2 3 4; do
476 ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
477done
478AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
479 in_port=1 actions=drop
480 in_port=2 actions=drop
481 in_port=3 actions=drop
482 in_port=4 actions=drop
483NXST_FLOW reply:
484])
485# Adding another flow will be refused.
486AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
27527aa0 487AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
be2b69d1 488 [OFPT_ERROR: OFPFMFC_TABLE_FULL
254750ce
BP
489])
490# Also a mod-flow that would add a flow will be refused.
491AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
27527aa0 492AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
be2b69d1 493 [OFPT_ERROR: OFPFMFC_TABLE_FULL
254750ce
BP
494])
495# Replacing or modifying an existing flow is allowed.
496AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
497AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
498AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
499 in_port=1 actions=drop
500 in_port=2 actions=drop
501 in_port=3 actions=output:1
502 in_port=4 actions=NORMAL
503NXST_FLOW reply:
504])
505OVS_VSWITCHD_STOP
506AT_CLEANUP
507
508AT_SETUP([ofproto - eviction upon table overflow])
509OVS_VSWITCHD_START
510# Configure a maximum of 4 flows.
511AT_CHECK(
512 [ovs-vsctl \
513 -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
514 -- set bridge br0 flow_tables:0=@t0 \
515 | perl $srcdir/uuidfilt.pl],
516 [0], [<0>
517])
518# Add 4 flows.
519for in_port in 4 3 2 1; do
520 ovs-ofctl add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
521done
522AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
523 idle_timeout=10, in_port=1 actions=drop
524 idle_timeout=20, in_port=2 actions=drop
525 idle_timeout=30, in_port=3 actions=drop
526 idle_timeout=40, in_port=4 actions=drop
254750ce
BP
527NXST_FLOW reply:
528])
529# Adding another flow will cause the one that expires soonest to be evicted.
530AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
531AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
532 idle_timeout=20, in_port=2 actions=drop
533 idle_timeout=30, in_port=3 actions=drop
534 idle_timeout=40, in_port=4 actions=drop
254750ce
BP
535 in_port=5 actions=drop
536NXST_FLOW reply:
537])
538# A mod-flow that adds a flow also causes eviction, but replacing or
539# modifying an existing flow doesn't.
540AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
541AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
542AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
543AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b 544 idle_timeout=30, in_port=3 actions=output:1
254750ce
BP
545 in_port=4 actions=NORMAL
546 in_port=5 actions=drop
547 in_port=6 actions=drop
548NXST_FLOW reply:
549])
550# Flows with no timeouts at all cannot be evicted.
551AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
552AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
27527aa0 553AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
be2b69d1 554 [OFPT_ERROR: OFPFMFC_TABLE_FULL
254750ce
BP
555])
556AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
557 in_port=4 actions=NORMAL
558 in_port=5 actions=drop
559 in_port=6 actions=drop
560 in_port=7 actions=NORMAL
561NXST_FLOW reply:
562])
563OVS_VSWITCHD_STOP
564AT_CLEANUP
565
566AT_SETUP([ofproto - eviction upon table overflow, with fairness])
567OVS_VSWITCHD_START
568# Configure a maximum of 4 flows.
569AT_CHECK(
570 [ovs-vsctl \
571 -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
572 overflow-policy=evict \
573 groups='"NXM_OF_IN_PORT[[]]"' \
574 -- set bridge br0 flow_tables:0=@t0 \
575 | perl $srcdir/uuidfilt.pl],
576 [0], [<0>
577])
578# Add 4 flows.
579ovs-ofctl add-flows br0 - <<EOF
580idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
581idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
582idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
583idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
584EOF
585AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
586 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
587 idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
588 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
589 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
254750ce
BP
590NXST_FLOW reply:
591])
592# Adding another flow will cause the one that expires soonest within
593# the largest group (those with in_port=1) to be evicted. In this
594# case this is not the same as the one that expires soonest overall
595# (which is what makes the test interesting):
596AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
597AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
598 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
599 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
600 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
254750ce
BP
601 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
602NXST_FLOW reply:
603])
604# Enlarge the flow limit, change the eviction policy back to strictly
605# based on expiration, and and add some flows.
606AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
607ovs-ofctl add-flows br0 - <<EOF
608idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
609idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
610idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
611EOF
612AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
613 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
614 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
615 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
616 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
617 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
618 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
254750ce
BP
619 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
620NXST_FLOW reply:
621])
622# Adding another flow will cause the one that expires soonest overall
623# to be evicted.
624AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
625AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
626 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
627 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
628 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
629 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
630 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
631 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
254750ce
BP
632 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
633NXST_FLOW reply:
634])
635# Reducing the flow limit also causes the flows that expire soonest
636# overall to be evicted.
637AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
638AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
639 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
640 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
641 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
254750ce
BP
642 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
643NXST_FLOW reply:
644])
645OVS_VSWITCHD_STOP
646AT_CLEANUP
80d5aefd
BP
647
648AT_SETUP([ofproto - asynchronous message control])
649OVS_VSWITCHD_START
650AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
651check_async () {
652 printf '\n\n--- check_async %d ---\n\n\n' $1
653 shift
654
6fc67c4f 655 ovs-appctl -t ovs-ofctl ofctl/barrier
80d5aefd
BP
656 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
657 : > expout
658
a7349929 659 # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
80d5aefd
BP
660 ovs-ofctl -v packet-out br0 none controller '0001020304050010203040501234'
661 if test X"$1" = X"OFPR_ACTION"; then shift;
662 echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=NONE (via action) data_len=14 (unbuffered)
aa6c9932 663priority=0,metadata=0,in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
80d5aefd
BP
664 fi
665
a7349929
BP
666 # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
667 ovs-ofctl -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
668 if test X"$1" = X"OFPR_NO_MATCH"; then shift;
669 echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=NONE (via no_match) data_len=14 (unbuffered)
aa6c9932 670priority=0,metadata=0,in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
a7349929
BP
671 fi
672
673 # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
80d5aefd
BP
674 ovs-ofctl packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
675 if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
676 echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=NONE (via invalid_ttl) data_len=76 (unbuffered)
aa6c9932 677priority=0,udp,metadata=0,in_port=0,vlan_tci=0x0000,dl_src=00:26:b9:8c:b0:f9,dl_dst=00:25:83:df:b4:00,nw_src=172.17.55.13,nw_dst=172.16.0.2,nw_tos=0,nw_ecn=0,nw_ttl=0,tp_src=55155,tp_dst=53 udp_csum:8f6d"
80d5aefd
BP
678 fi
679
680 # OFPT_PORT_STATUS, OFPPR_ADD
e1b1d06a 681 ovs-vsctl add-port br0 test -- set Interface test type=dummy ofport_request=1
80d5aefd
BP
682 if test X"$1" = X"OFPPR_ADD"; then shift;
683 echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
684 config: PORT_DOWN
9e1fd49b
BP
685 state: LINK_DOWN
686 speed: 100 Mbps now, 100 Mbps max"
80d5aefd
BP
687 fi
688
689 # OFPT_PORT_STATUS, OFPPR_DELETE
690 ovs-vsctl del-port br0 test
691 if test X"$1" = X"OFPPR_DELETE"; then shift;
692 echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
693 config: PORT_DOWN
9e1fd49b
BP
694 state: LINK_DOWN
695 speed: 100 Mbps now, 100 Mbps max"
80d5aefd
BP
696 fi
697
698 # OFPT_FLOW_REMOVED, OFPRR_DELETE
699 ovs-ofctl add-flow br0 send_flow_rem,actions=drop
700 ovs-ofctl --strict del-flows br0 ''
701 if test X"$1" = X"OFPRR_DELETE"; then shift;
702 echo >>expout "OFPT_FLOW_REMOVED: reason=delete"
703 fi
704 AT_FAIL_IF([test X"$1" != X])
705
706 ovs-appctl -t ovs-ofctl ofctl/barrier
fd0aa9ea 707 echo >>expout "OFPT_BARRIER_REPLY:"
80d5aefd
BP
708
709 AT_CHECK(
710 [[sed '
711s/ (xid=0x[0-9a-fA-F]*)//
712s/ *duration.*//
713s/00:0.$/00:0x/' < monitor.log]],
714 [0], [expout])
715}
716
717# It's a service connection so initially there should be no async messages.
718check_async 1
719
99811d07 720# Set miss_send_len to 128, turning on packet-ins for our service connection.
80d5aefd
BP
721ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
722check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
723
724# Set miss_send_len to 128 and enable invalid_ttl.
725ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
726check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
727
728# Become slave, which should disable everything except port status.
729ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
730check_async 4 OFPPR_ADD OFPPR_DELETE
731
732# Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
733ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
734check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
735
a7349929
BP
736# Set controller ID 123.
737ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
738check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
739
740# Restore controller ID 0.
741ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
742
80d5aefd
BP
743# Become master.
744ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
a7349929 745check_async 7 OFPR_ACTION OFPPR_ADD
80d5aefd
BP
746
747ovs-appctl -t ovs-ofctl exit
94c33672 748OVS_VSWITCHD_STOP
80d5aefd 749AT_CLEANUP
751c7785
BP
750
751dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
752dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
753dnl controllers despite the spec) as meaning a packet that was generated
754dnl by the controller.
755AT_SETUP([ofproto - packet-out from controller])
756OVS_VSWITCHD_START
757
758# Start a monitor listening for packet-ins.
759AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
760ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
761ovs-appctl -t ovs-ofctl ofctl/barrier
762ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
763AT_CAPTURE_FILE([monitor.log])
764
765# Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
766AT_CHECK([ovs-ofctl packet-out br0 none controller '0001020304050010203040501234'])
c6100d92 767AT_CHECK([ovs-ofctl packet-out br0 controller controller '0001020304050010203040505678'])
751c7785
BP
768
769# Stop the monitor and check its output.
770ovs-appctl -t ovs-ofctl ofctl/barrier
771ovs-appctl -t ovs-ofctl exit
772
773AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
774OFPT_PACKET_IN: total_len=14 in_port=NONE (via action) data_len=14 (unbuffered)
aa6c9932 775priority=0,metadata=0,in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
751c7785 776OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
aa6c9932 777priority=0,metadata=0,in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
969fc56c
JS
778OFPT_BARRIER_REPLY:
779])
780
781OVS_VSWITCHD_STOP
782AT_CLEANUP
783
784dnl This test checks that metadata is encoded in packet_in structures,
785dnl supported by NXAST.
786AT_SETUP([ofproto - packet-out with metadata (NXM)])
787OVS_VSWITCHD_START
788
789# Start a monitor listening for packet-ins.
790AT_CHECK([ovs-ofctl -P nxm monitor br0 --detach --no-chdir --pidfile])
791ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
792ovs-appctl -t ovs-ofctl ofctl/barrier
793ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
794AT_CAPTURE_FILE([monitor.log])
795
796# Send a packet-out with a load action to set some metadata, and forward to controller
797AT_CHECK([ovs-ofctl packet-out br0 none 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), controller' '0001020304050010203040501234'])
798
799# Stop the monitor and check its output.
800ovs-appctl -t ovs-ofctl ofctl/barrier
801ovs-appctl -t ovs-ofctl exit
802
803AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
42edbe39 804NXT_PACKET_IN: total_len=14 in_port=NONE metadata=0xfafafafa5a5a5a5a (via action) data_len=14 (unbuffered)
aa6c9932 805priority=0,metadata=0,in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
751c7785
BP
806OFPT_BARRIER_REPLY:
807])
808
809OVS_VSWITCHD_STOP
810AT_CLEANUP
2b07c8b1
BP
811
812AT_SETUP([ofproto - flow monitoring])
813AT_KEYWORDS([monitor])
814OVS_VSWITCHD_START
815
816ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
817
818# Start a monitor watching the flow table and check the initial reply.
819ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
820AT_CAPTURE_FILE([monitor.log])
821ovs-appctl -t ovs-ofctl ofctl/barrier
822AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
823 [NXST_FLOW_MONITOR reply:
824 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
825OFPT_BARRIER_REPLY:
826])
827
828# Add, delete, and modify some flows and check the updates.
829ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
830ovs-ofctl add-flow br0 in_port=0,dl_vlan=124,actions=output:2
831ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:5
95a1c4ca
SH
832ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=0,actions=output:6
833ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=1,actions=output:7
834ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:8
835ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=0,actions=output:9
836ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=1,actions=output:10
837ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,actions=output:11
838ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=0,actions=output:12
839ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=1,actions=output:13
840ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,actions=output:14
841ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:15
842ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:16
843ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:17
844ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:18
845ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:19
846ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:20
847ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=0,actions=output:21
848ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=1,actions=output:22
849ovs-ofctl add-flow br0 in_port=0,actions=output:23
2b07c8b1
BP
850ovs-ofctl mod-flows br0 cookie=5,dl_vlan=123,actions=output:3
851ovs-ofctl del-flows br0 dl_vlan=123
852ovs-ofctl del-flows br0
853ovs-appctl -t ovs-ofctl ofctl/barrier
32cd83a2
BP
854sort='
855 # Sorts groups of lines that start with a space, without moving them
856 # past the nearest line that does not start with a space.
857 use warnings;
858 use strict;
859 my @buffer = ();
860 while (<STDIN>) {
861 if (/^ /) {
862 push(@buffer, $_);
863 } else {
864 print $_ foreach sort(@buffer);
865 print $_;
866 @buffer = ();
867 }
868 }
869 print $_ foreach sort(@buffer);
870'
871AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | perl -e "$sort"], [0],
2b07c8b1
BP
872[NXST_FLOW_MONITOR reply (xid=0x0):
873 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
874NXST_FLOW_MONITOR reply (xid=0x0):
875 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:5
95a1c4ca
SH
876NXST_FLOW_MONITOR reply (xid=0x0):
877 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:6
878NXST_FLOW_MONITOR reply (xid=0x0):
879 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:7
880NXST_FLOW_MONITOR reply (xid=0x0):
881 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:8
882NXST_FLOW_MONITOR reply (xid=0x0):
883 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:9
884NXST_FLOW_MONITOR reply (xid=0x0):
885 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:10
886NXST_FLOW_MONITOR reply (xid=0x0):
887 event=ADDED table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
888NXST_FLOW_MONITOR reply (xid=0x0):
889 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
890NXST_FLOW_MONITOR reply (xid=0x0):
891 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
892NXST_FLOW_MONITOR reply (xid=0x0):
893 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
894NXST_FLOW_MONITOR reply (xid=0x0):
895 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:15
896NXST_FLOW_MONITOR reply (xid=0x0):
897 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:16
898NXST_FLOW_MONITOR reply (xid=0x0):
899 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:17
900NXST_FLOW_MONITOR reply (xid=0x0):
901 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
902NXST_FLOW_MONITOR reply (xid=0x0):
903 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
904NXST_FLOW_MONITOR reply (xid=0x0):
905 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
906NXST_FLOW_MONITOR reply (xid=0x0):
907 event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
908NXST_FLOW_MONITOR reply (xid=0x0):
909 event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
910NXST_FLOW_MONITOR reply (xid=0x0):
911 event=ADDED table=0 cookie=0 in_port=0 actions=output:23
2b07c8b1
BP
912NXST_FLOW_MONITOR reply (xid=0x0):
913 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
95a1c4ca
SH
914 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
915 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
2b07c8b1
BP
916NXST_FLOW_MONITOR reply (xid=0x0):
917 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
95a1c4ca
SH
918 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
919 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
2b07c8b1 920NXST_FLOW_MONITOR reply (xid=0x0):
32cd83a2 921 event=DELETED reason=delete table=0 cookie=0 in_port=0 actions=output:23
95a1c4ca 922 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
32cd83a2
BP
923 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
924 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
2b07c8b1 925 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
95a1c4ca 926 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
32cd83a2 927 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
95a1c4ca 928 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
32cd83a2
BP
929 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
930 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
95a1c4ca 931 event=DELETED reason=delete table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
2b07c8b1
BP
932OFPT_BARRIER_REPLY:
933])
934
935# Check that our own changes are reported as abbreviations.
936ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
937ovs-ofctl add-flow br0 in_port=1,actions=output:2
938ovs-ofctl add-flow br0 in_port=2,actions=output:1
939ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
940ovs-appctl -t ovs-ofctl ofctl/barrier
941AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
942])
943AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
944[NXST_FLOW_MONITOR reply (xid=0x0):
945 event=ADDED table=0 cookie=0 in_port=1 actions=output:2
946NXST_FLOW_MONITOR reply (xid=0x0):
947 event=ADDED table=0 cookie=0 in_port=2 actions=output:1
948send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
949NXST_FLOW_MONITOR reply (xid=0x0):
950 event=ABBREV xid=0x12345678
951OFPT_BARRIER_REPLY:
952])
953
954ovs-appctl -t ovs-ofctl exit
955OVS_VSWITCHD_STOP
956AT_CLEANUP
957
958AT_SETUP([ofproto - flow monitoring pause and resume])
959AT_KEYWORDS([monitor])
960
46a80050
EM
961# The maximum socket receive buffer size is important for this test, which
962# tests behavior when the receive buffer overflows.
963if test -e /proc/sys/net/core/rmem_max; then
964 # Linux
965 rmem_max=`cat /proc/sys/net/core/rmem_max`
966elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
967 : # FreeBSD
968else
969 # Don't know how to get maximum socket receive buffer on this OS
970 AT_SKIP_IF([:])
971fi
2b07c8b1
BP
972# Calculate the total amount of queuing: rmem_max in the kernel, 128 kB
973# in ofproto sending userspace (see ofmonitor_flush() in connmgr.c).
2b07c8b1
BP
974queue_size=`expr $rmem_max + 128 \* 1024`
975echo rmem_max=$rmem_max queue_size=$queue_size
976
977# Each flow update message takes up at least 48 bytes of space in queues
978# and in practice more than that.
979n_msgs=`expr $queue_size / 48`
980echo n_msgs=$n_msgs
981
982OVS_VSWITCHD_START
983
984# Start a monitor watching the flow table, then make it block.
0b7140bb 985ON_EXIT([kill `cat ovs-ofctl.pid`])
2b07c8b1
BP
986ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
987AT_CAPTURE_FILE([monitor.log])
988ovs-appctl -t ovs-ofctl ofctl/block
989
990# Add $n_msgs flows.
991(echo "in_port=2,actions=output:2"
992perl -e '
993 for ($i = 0; $i < '$n_msgs'; $i++) {
994 print "cookie=1,reg1=$i,actions=drop\n";
995 }
996') > flows.txt
997AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
79b8c36c
BP
998# Check that multipart flow dumps work properly:
999AT_CHECK([ovs-ofctl diff-flows br0 flows.txt])
2b07c8b1
BP
1000AT_CHECK([ovs-ofctl add-flow br0 in_port=1,cookie=3,actions=drop])
1001AT_CHECK([ovs-ofctl mod-flows br0 in_port=2,cookie=2,actions=output:2])
1002AT_CHECK([ovs-ofctl del-flows br0 cookie=1/-1])
1003
1004ovs-appctl -t ovs-ofctl ofctl/unblock
1005ovs-appctl -t ovs-ofctl ofctl/barrier
1006
1007ovs-appctl -t ovs-ofctl exit
1008
1009# Check that the flow monitor reported the same number of flows
1010# added and deleted, but fewer than we actually added and deleted.
1011adds=`grep -c 'ADDED.*reg1=' monitor.log`
1012deletes=`grep -c 'DELETED.*reg1=' monitor.log`
1013echo adds=$adds deletes=$deletes
1014AT_CHECK([test $adds -gt 100 && test $adds -lt $n_msgs])
1015AT_CHECK([test $adds = $deletes])
1016
d0ab8a1a
BP
1017# Check that the flow monitor reported everything in the expected order:
1018#
1019# event=ADDED table=0 cookie=0x1 reg1=0x22
1020# ...
1021# NXT_FLOW_MONITOR_PAUSED:
1022# ...
1023# event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1024# ...
1025# event=ADDED table=0 cookie=0x3 in_port=1
1026# event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
1027# NXT_FLOW_MONITOR_RESUMED:
1028#
1029# except that, between the PAUSED and RESUMED, the order of the ADDED
1030# and MODIFIED lines lines depends on hash order, that is, it varies
1031# as we change the hash function or change architecture. Therefore,
1032# we use a couple of tests below to accept both orders.
2b07c8b1 1033AT_CHECK([ofctl_strip < monitor.log | sed -n -e '
46a80050 1034/reg1=0x22$/p
2b07c8b1
BP
1035/cookie=0x[[23]]/p
1036/NXT_FLOW_MONITOR_PAUSED:/p
1037/NXT_FLOW_MONITOR_RESUMED:/p
d0ab8a1a
BP
1038' > monitor.log.subset])
1039AT_CHECK([grep -v MODIFIED monitor.log.subset], [0], [dnl
1040 event=ADDED table=0 cookie=0x1 reg1=0x22
2b07c8b1
BP
1041NXT_FLOW_MONITOR_PAUSED:
1042 event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
1043 event=ADDED table=0 cookie=0x3 in_port=1
d0ab8a1a
BP
1044NXT_FLOW_MONITOR_RESUMED:
1045])
1046AT_CHECK([grep -v ADDED monitor.log.subset], [0], [dnl
1047NXT_FLOW_MONITOR_PAUSED:
1048 event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
2b07c8b1
BP
1049 event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
1050NXT_FLOW_MONITOR_RESUMED:
1051])
1052
1053OVS_VSWITCHD_STOP
1054AT_CLEANUP