]> git.proxmox.com Git - ovs.git/blame - tests/ofproto.at
nx-match: Add support for multiple OXM field assignments for one field.
[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
2b4cca6f
BP
9AT_SETUP([ofproto - handling messages with bad version])
10OVS_VSWITCHD_START
11
12# Start a monitor running OpenFlow 1.0, then send the switch an OF1.1 features
13# request
14AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
15ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
16AT_CAPTURE_FILE([monitor.log])
17ovs-appctl -t ovs-ofctl ofctl/send 0205000801234567
18ovs-appctl -t ovs-ofctl ofctl/barrier
19ovs-appctl -t ovs-ofctl exit
20
21AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//
22/ECHO/d' monitor.log], [0], [dnl
23send: OFPT_FEATURES_REQUEST (OF1.1):
24OFPT_ERROR (OF1.1): OFPBRC_BAD_VERSION
25OFPT_FEATURES_REQUEST (OF1.1):
26OFPT_BARRIER_REPLY:
27])
28
29OVS_VSWITCHD_STOP(["/received OpenFlow version 0x02 != expected 01/d"])
30AT_CLEANUP
31
a2cb9dfd 32AT_SETUP([ofproto - feature request, config request])
023e1e0a 33OVS_VSWITCHD_START
ea523221 34AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
640c7c94 35AT_CHECK([STRIP_XIDS stdout], [0], [dnl
9e1fd49b 36OFPT_FEATURES_REPLY: dpid:fedcba9876543210
c2f0373a 37n_tables:254, n_buffers:256
9e1fd49b 38capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
08d1e234 39actions: output enqueue set_vlan_vid set_vlan_pcp strip_vlan mod_dl_src mod_dl_dst mod_nw_src mod_nw_dst mod_nw_tos mod_tp_src mod_tp_dst
0ab14c8e 40 LOCAL(br0): addr:aa:55:aa:55:00:00
1839c356
FL
41 config: PORT_DOWN
42 state: LINK_DOWN
d02a5f8e 43 speed: 0 Mbps now, 0 Mbps max
3b62feba 44OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
a2cb9dfd 45])
023e1e0a 46OVS_VSWITCHD_STOP
81816a5f
JP
47AT_CLEANUP
48
49AT_SETUP([ofproto - set OpenFlow port number])
50OVS_VSWITCHD_START(
51 [add-port br0 p1 -- set Interface p1 type=dummy --\
52 add-port br0 p2 -- set Interface p2 type=dummy ofport_request=99])
53AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
e44768b7
JP
54AT_CHECK([[sed '
55s/ (xid=0x[0-9a-fA-F]*)//
56s/00:0.$/00:0x/' < stdout]],
57 [0], [dnl
81816a5f 58OFPT_FEATURES_REPLY: dpid:fedcba9876543210
c2f0373a 59n_tables:254, n_buffers:256
81816a5f 60capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
08d1e234 61actions: output enqueue set_vlan_vid set_vlan_pcp strip_vlan mod_dl_src mod_dl_dst mod_nw_src mod_nw_dst mod_nw_tos mod_tp_src mod_tp_dst
e44768b7 62 1(p1): addr:aa:55:aa:55:00:0x
81816a5f
JP
63 config: PORT_DOWN
64 state: LINK_DOWN
d02a5f8e 65 speed: 0 Mbps now, 0 Mbps max
e44768b7 66 99(p2): addr:aa:55:aa:55:00:0x
81816a5f
JP
67 config: PORT_DOWN
68 state: LINK_DOWN
d02a5f8e 69 speed: 0 Mbps now, 0 Mbps max
e44768b7 70 LOCAL(br0): addr:aa:55:aa:55:00:0x
1839c356
FL
71 config: PORT_DOWN
72 state: LINK_DOWN
d02a5f8e 73 speed: 0 Mbps now, 0 Mbps max
81816a5f
JP
74OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
75])
e44768b7 76
81816a5f 77OVS_VSWITCHD_STOP
a2cb9dfd
BP
78AT_CLEANUP
79
eaa6eb2a
BP
80dnl This is really bare-bones.
81dnl It at least checks request and reply serialization and deserialization.
9dcd1c00 82AT_SETUP([ofproto - port stats - (OpenFlow 1.0)])
023e1e0a 83OVS_VSWITCHD_START
ea523221 84AT_CHECK([ovs-ofctl -vwarn dump-ports br0], [0], [stdout])
eaa6eb2a
BP
85AT_CHECK([STRIP_XIDS stdout], [0], [dnl
86OFPST_PORT reply: 1 ports
e1db42d6 87 port LOCAL: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
eaa6eb2a
BP
88 tx pkts=0, bytes=0, drop=0, errs=0, coll=0
89])
023e1e0a 90OVS_VSWITCHD_STOP
eaa6eb2a
BP
91AT_CLEANUP
92
9dcd1c00
SH
93AT_SETUP([ofproto - port stats - (OpenFlow 1.2)])
94OVS_VSWITCHD_START
95AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn dump-ports br0], [0], [stdout])
96AT_CHECK([STRIP_XIDS stdout], [0], [dnl
97OFPST_PORT reply (OF1.2): 1 ports
e1db42d6 98 port LOCAL: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
9dcd1c00
SH
99 tx pkts=0, bytes=0, drop=0, errs=0, coll=0
100])
101OVS_VSWITCHD_STOP
102AT_CLEANUP
103
5469537b
BP
104AT_SETUP([ofproto - port stats - (OpenFlow 1.4)])
105OVS_VSWITCHD_START
106AT_CHECK([ovs-ofctl -O OpenFlow14 -vwarn dump-ports br0], [0], [stdout])
107AT_CHECK([STRIP_XIDS stdout | sed 's/duration=[[0-9.]]*s/duration=?s/'],
108 [0], [dnl
109OFPST_PORT reply (OF1.4): 1 ports
110 port LOCAL: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0
111 tx pkts=0, bytes=0, drop=0, errs=0, coll=0
112 duration=?s
113])
114OVS_VSWITCHD_STOP
115AT_CLEANUP
116
2be393ed
JP
117dnl This is really bare-bones.
118dnl It at least checks request and reply serialization and deserialization.
9dcd1c00 119AT_SETUP([ofproto - port-desc stats (OpenFlow 1.0)])
2be393ed
JP
120OVS_VSWITCHD_START
121AT_CHECK([ovs-ofctl -vwarn dump-ports-desc br0], [0], [stdout])
122AT_CHECK([STRIP_XIDS stdout], [0], [dnl
123OFPST_PORT_DESC reply:
124 LOCAL(br0): addr:aa:55:aa:55:00:00
1839c356
FL
125 config: PORT_DOWN
126 state: LINK_DOWN
d02a5f8e 127 speed: 0 Mbps now, 0 Mbps max
2be393ed
JP
128])
129OVS_VSWITCHD_STOP
130AT_CLEANUP
131
eaa6eb2a
BP
132dnl This is really bare-bones.
133dnl It at least checks request and reply serialization and deserialization.
9dcd1c00
SH
134AT_SETUP([ofproto - port-desc stats (OpenFlow 1.2)])
135OVS_VSWITCHD_START
136AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn dump-ports-desc br0], [0], [stdout])
137AT_CHECK([STRIP_XIDS stdout], [0], [dnl
138OFPST_PORT_DESC reply (OF1.2):
139 LOCAL(br0): addr:aa:55:aa:55:00:00
1839c356
FL
140 config: PORT_DOWN
141 state: LINK_DOWN
9dcd1c00
SH
142 speed: 0 Mbps now, 0 Mbps max
143])
144OVS_VSWITCHD_STOP
145AT_CLEANUP
146
70ae4f93
BP
147AT_SETUP([ofproto - port-desc stats (OpenFlow 1.5)])
148OVS_VSWITCHD_START
149ADD_OF_PORTS([br0], 1, 2, 3)
150AT_CHECK([ovs-ofctl -F OXM-OpenFlow15 -O OpenFlow15 -vwarn dump-ports-desc br0], [0], [stdout])
151AT_CHECK([STRIP_XIDS stdout | sed 's/00:0./00:0x/'], [0], [dnl
152OFPST_PORT_DESC reply (OF1.5):
153 1(p1): addr:aa:55:aa:55:00:0x
154 config: PORT_DOWN
155 state: LINK_DOWN
156 speed: 0 Mbps now, 0 Mbps max
157 2(p2): addr:aa:55:aa:55:00:0x
158 config: PORT_DOWN
159 state: LINK_DOWN
160 speed: 0 Mbps now, 0 Mbps max
161 3(p3): addr:aa:55:aa:55:00:0x
162 config: PORT_DOWN
163 state: LINK_DOWN
164 speed: 0 Mbps now, 0 Mbps max
165 LOCAL(br0): addr:aa:55:aa:55:00:0x
166 config: PORT_DOWN
167 state: LINK_DOWN
168 speed: 0 Mbps now, 0 Mbps max
169])
170AT_CHECK([ovs-ofctl -F OXM-OpenFlow15 -O OpenFlow15 -vwarn dump-ports-desc br0 2], [0], [stdout])
171AT_CHECK([STRIP_XIDS stdout | sed 's/00:0./00:0x/'], [0], [dnl
172OFPST_PORT_DESC reply (OF1.5):
173 2(p2): addr:aa:55:aa:55:00:0x
174 config: PORT_DOWN
175 state: LINK_DOWN
176 speed: 0 Mbps now, 0 Mbps max
177])
178OVS_VSWITCHD_STOP
179AT_CLEANUP
180
9dcd1c00
SH
181dnl This is really bare-bones.
182dnl It at least checks request and reply serialization and deserialization.
183AT_SETUP([ofproto - queue stats - (OpenFlow 1.0)])
023e1e0a 184OVS_VSWITCHD_START
ea523221 185AT_CHECK([ovs-ofctl -vwarn queue-stats br0], [0], [stdout])
eaa6eb2a
BP
186AT_CHECK([STRIP_XIDS stdout], [0], [dnl
187OFPST_QUEUE reply: 0 queues
188])
7f05e7ab 189AT_CHECK([ovs-ofctl -vwarn queue-stats br0 ANY 5], [0],
53514387 190 [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_QUEUE
7f05e7ab 191OFPST_QUEUE request (xid=0x2):port=ANY queue=5
0414d158
BP
192])
193AT_CHECK([ovs-ofctl -vwarn queue-stats br0 10], [0],
53514387
SH
194 [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_PORT
195OFPST_QUEUE request (xid=0x2):port=10 queue=ALL
0414d158 196])
023e1e0a 197OVS_VSWITCHD_STOP
eaa6eb2a
BP
198AT_CLEANUP
199
9dcd1c00
SH
200AT_SETUP([ofproto - queue stats - (OpenFlow 1.2)])
201OVS_VSWITCHD_START
202AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn queue-stats br0], [0], [stdout])
203AT_CHECK([STRIP_XIDS stdout], [0], [dnl
204OFPST_QUEUE reply (OF1.2): 0 queues
205])
206AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn queue-stats br0 ALL 5], [0],
207 [OFPT_ERROR (OF1.2) (xid=0x2): OFPQOFC_BAD_QUEUE
208OFPST_QUEUE request (OF1.2) (xid=0x2):port=ANY queue=5
209])
210AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn queue-stats br0 10], [0],
211 [OFPT_ERROR (OF1.2) (xid=0x2): OFPQOFC_BAD_PORT
212OFPST_QUEUE request (OF1.2) (xid=0x2):port=10 queue=ALL
213])
214OVS_VSWITCHD_STOP
215AT_CLEANUP
216
1bb2cdbe
BP
217AT_SETUP([ofproto - queue stats - (OpenFlow 1.4)])
218OVS_VSWITCHD_START
219AT_CHECK([ovs-ofctl -O OpenFlow14 -vwarn queue-stats br0], [0], [stdout])
220AT_CHECK([STRIP_XIDS stdout], [0], [dnl
221OFPST_QUEUE reply (OF1.4): 0 queues
222])
223AT_CHECK([ovs-ofctl -O OpenFlow14 -vwarn queue-stats br0 ALL 5], [0],
224 [OFPT_ERROR (OF1.4) (xid=0x2): OFPQOFC_BAD_QUEUE
225OFPST_QUEUE request (OF1.4) (xid=0x2):port=ANY queue=5
226])
227AT_CHECK([ovs-ofctl -O OpenFlow14 -vwarn queue-stats br0 10], [0],
228 [OFPT_ERROR (OF1.4) (xid=0x2): OFPQOFC_BAD_PORT
229OFPST_QUEUE request (OF1.4) (xid=0x2):port=10 queue=ALL
230])
231OVS_VSWITCHD_STOP
232AT_CLEANUP
233
e8f9a7bb
VG
234dnl This is really bare-bones.
235dnl It at least checks request and reply serialization and deserialization.
236AT_SETUP([ofproto - queue configuration - (OpenFlow 1.0)])
237OVS_VSWITCHD_START
238ADD_OF_PORTS([br0], [1], [2])
239AT_CHECK([ovs-ofctl queue-get-config br0 1], [0], [stdout])
240AT_CHECK([STRIP_XIDS stdout], [0], [dnl
241OFPT_QUEUE_GET_CONFIG_REPLY: port=1
242])
243AT_CHECK([ovs-ofctl queue-get-config br0 10], [0],
244 [OFPT_ERROR (xid=0x2): OFPQOFC_BAD_PORT
245OFPT_QUEUE_GET_CONFIG_REQUEST (xid=0x2): port=10
246])
247OVS_VSWITCHD_STOP
248AT_CLEANUP
249
250AT_SETUP([ofproto - queue configuration - (OpenFlow 1.2)])
251OVS_VSWITCHD_START
252ADD_OF_PORTS([br0], [1], [2])
253AT_CHECK([ovs-ofctl -O OpenFlow12 queue-get-config br0 1], [0], [stdout])
254AT_CHECK([STRIP_XIDS stdout], [0], [dnl
255OFPT_QUEUE_GET_CONFIG_REPLY (OF1.2): port=1
256])
257AT_CHECK([ovs-ofctl -O OpenFlow12 queue-get-config br0 10], [0],
258 [OFPT_ERROR (OF1.2) (xid=0x2): OFPQOFC_BAD_PORT
259OFPT_QUEUE_GET_CONFIG_REQUEST (OF1.2) (xid=0x2): port=10
260])
261OVS_VSWITCHD_STOP
262AT_CLEANUP
263
433702fc
SH
264dnl This is really bare-bones.
265dnl It at least checks request and reply serialization and deserialization.
f1457c26 266dnl Actions definition listed in both supported formats (w/ actions=)
433702fc
SH
267AT_SETUP([ofproto - del group])
268OVS_VSWITCHD_START
269AT_DATA([groups.txt], [dnl
270group_id=1234,type=all,bucket=output:10
f1457c26 271group_id=1235,type=all,bucket=actions=output:10
433702fc
SH
272])
273AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-groups br0 groups.txt])
19187a71
BP
274AT_CHECK([ovs-ofctl -F OXM-OpenFlow15 -O OpenFlow15 -vwarn dump-groups br0 1234], [0], [stdout])
275AT_CHECK([STRIP_XIDS stdout], [0], [dnl
276OFPST_GROUP_DESC reply (OF1.5):
277 group_id=1234,type=all,bucket=actions=output:10
278])
433702fc
SH
279AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
280AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
281AT_CHECK([STRIP_XIDS stdout], [0], [dnl
282OFPST_GROUP_DESC reply (OF1.1):
283 group_id=1235,type=all,bucket=actions=output:10
284])
285AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
286AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
287AT_CHECK([STRIP_XIDS stdout], [0], [dnl
288OFPST_GROUP_DESC reply (OF1.1):
289 group_id=1235,type=all,bucket=actions=output:10
290])
291AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0], [0])
292AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
293AT_CHECK([STRIP_XIDS stdout], [0], [dnl
294OFPST_GROUP_DESC reply (OF1.1):
295])
296OVS_VSWITCHD_STOP
297AT_CLEANUP
298
e1799eb7
SH
299dnl This is really bare-bones.
300dnl It at least checks request and reply serialization and deserialization.
301dnl Actions definition listed in both supported formats (w/ actions=)
302AT_SETUP([ofproto - add indirect group])
303OVS_VSWITCHD_START
304dnl indirect group must have exactly one bucket
305AT_DATA([stderr], [dnl
306OFPT_ERROR (OF1.1) (xid=0x2): OFPGMFC_INVALID_GROUP
307OFPT_GROUP_MOD (OF1.1) (xid=0x2): ***decode error: OFPGMFC_INVALID_GROUP***
308])
309AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 'group_id=1234,type=indirect'], [1], , [stderr])
310AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 'group_id=1235,type=indirect,bucket=output:10'])
311AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 'group_id=1236,type=indirect,bucket=output:10,bucket=output:11'], [1], , [stderr])
312OVS_VSWITCHD_STOP
313AT_CLEANUP
314
433702fc
SH
315dnl This is really bare-bones.
316dnl It at least checks request and reply serialization and deserialization.
317AT_SETUP([ofproto - del group deletes flows])
318OVS_VSWITCHD_START
319AT_DATA([groups.txt], [dnl
320group_id=1234,type=all,bucket=output:10
321group_id=1235,type=all,bucket=output:10
322])
323AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-groups br0 groups.txt])
324AT_DATA([flows.txt], [dnl
325tcp actions=group:1234
326udp actions=group:1235
327])
328AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flows br0 flows.txt])
329AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
330[0], [dnl
331 tcp actions=group:1234
332 udp actions=group:1235
333OFPST_FLOW reply (OF1.1):
334])
335AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
336AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
337[0], [dnl
338 udp actions=group:1235
339OFPST_FLOW reply (OF1.1):
340])
341AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0 group_id=1234])
342AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
343[0], [dnl
344 udp actions=group:1235
345OFPST_FLOW reply (OF1.1):
346])
347AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn del-groups br0])
348AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-flows br0 | ofctl_strip | sort],
349[0], [dnl
350OFPST_FLOW reply (OF1.1):
351])
352OVS_VSWITCHD_STOP
353AT_CLEANUP
354
0860fea7
SH
355dnl This is really bare-bones.
356dnl It at least checks request and reply serialization and deserialization.
357AT_SETUP([ofproto - flow mod checks group availability])
358OVS_VSWITCHD_START
359AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 group_id=1234,type=all,bucket=output:10])
360AT_DATA([flows.txt], [dnl
361tcp actions=group:1234
362udp actions=group:1235
363])
364AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=group:1234'])
365AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=group:1235'], [1], [], [stderr])
366
367# The output should look like this:
368#
369# 00000000 02 0e 00 98 00 00 00 02-00 00 00 00 00 00 00 00 |................|
370# 00000010 00 00 00 00 00 00 00 00-ff 00 00 00 00 00 80 00 |................|
371# 00000020 ff ff ff ff ff ff ff ff-ff ff ff ff 00 00 00 00 |................|
372# 00000030 00 00 00 58 00 00 00 00-00 00 03 d7 00 00 00 00 |...X............|
373#
374# This 'sed' command captures the error message but drops details.
375AT_CHECK([sed '/truncated/d
376/^000000.0/d' stderr | STRIP_XIDS], [0],
377 [OFPT_ERROR (OF1.1): OFPBAC_BAD_OUT_GROUP
378OFPT_FLOW_MOD (OF1.1):
379])
380OVS_VSWITCHD_STOP
381AT_CLEANUP
382
433702fc
SH
383dnl This is really bare-bones.
384dnl It at least checks request and reply serialization and deserialization.
385AT_SETUP([ofproto - group description])
386OVS_VSWITCHD_START
387AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 group_id=1234,type=all,bucket=output:10], [0], [stdout])
388AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
389AT_CHECK([STRIP_XIDS stdout], [0], [dnl
390OFPST_GROUP_DESC reply (OF1.1):
391 group_id=1234,type=all,bucket=actions=output:10
392])
393OVS_VSWITCHD_STOP
394AT_CLEANUP
395
2134b5ec
SH
396dnl This is really bare-bones.
397dnl It at least checks request and reply serialization and deserialization.
398AT_SETUP([ofproto - group description])
399OVS_VSWITCHD_START
400AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-group br0 group_id=1234,type=all,bucket=output:10])
401AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-groups br0], [0], [stdout])
402AT_CHECK([STRIP_XIDS stdout], [0], [dnl
403OFPST_GROUP_DESC reply (OF1.1):
404 group_id=1234,type=all,bucket=actions=output:10
405])
406OVS_VSWITCHD_STOP
407AT_CLEANUP
408
d45418dd
SH
409dnl This is really bare-bones.
410dnl It at least checks request and reply serialization and deserialization.
411AT_SETUP([ofproto - group features])
412OVS_VSWITCHD_START
413AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn dump-group-features br0], [0], [stdout])
414AT_CHECK([STRIP_XIDS stdout], [0], [dnl
415OFPST_GROUP_FEATURES reply (OF1.2):
416 Group table:
417 Types: 0x0
7cb279c2 418 Capabilities: 0x7
d45418dd
SH
419])
420OVS_VSWITCHD_STOP
421AT_CLEANUP
422
2134b5ec
SH
423dnl This is really bare-bones.
424dnl It at least checks request and reply serialization and deserialization.
425AT_SETUP([ofproto - group stats])
426OVS_VSWITCHD_START
427AT_DATA([groups.txt], [dnl
428group_id=1234,type=all,bucket=output:10
429group_id=1235,type=all,bucket=output:10
430])
431AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-groups br0 groups.txt])
432AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn add-flow br0 'tcp actions=group:1234'])
433AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-group-stats br0 group_id=1234], [0], [stdout])
434AT_CHECK([STRIP_XIDS stdout | sort], [0], [dnl
435 group_id=1234,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
436OFPST_GROUP reply (OF1.1):
437])
438AT_CHECK([ovs-ofctl -O OpenFlow11 -vwarn dump-group-stats br0], [0], [stdout])
439AT_CHECK([STRIP_XIDS stdout | sort], [0], [dnl
440 group_id=1234,ref_count=1,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
441 group_id=1235,ref_count=0,packet_count=0,byte_count=0,bucket0:packet_count=0,byte_count=0
442OFPST_GROUP reply (OF1.1):
443])
444OVS_VSWITCHD_STOP
445AT_CLEANUP
446
9dcd1c00 447AT_SETUP([ofproto - mod-port (OpenFlow 1.0)])
023e1e0a 448OVS_VSWITCHD_START
a2cb9dfd
BP
449for command_config_state in \
450 'up 0 0' \
0ab14c8e
BP
451 'noflood NO_FLOOD 0' \
452 'down PORT_DOWN,NO_FLOOD LINK_DOWN' \
28124950
BP
453 'flood PORT_DOWN LINK_DOWN' \
454 'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
455 'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
456 'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
457 'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
458 'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
459 'up NO_RECV 0' \
460 'receive 0 0'
a2cb9dfd
BP
461do
462 set $command_config_state
0ab14c8e 463 command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
ea523221
BP
464 AT_CHECK([ovs-ofctl -vwarn mod-port br0 br0 $command])
465 AT_CHECK([ovs-ofctl -vwarn show br0], [0], [stdout])
640c7c94 466 AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
9e1fd49b 467OFPT_FEATURES_REPLY: dpid:fedcba9876543210
c2f0373a 468n_tables:254, n_buffers:256
9e1fd49b 469capabilities: FLOW_STATS TABLE_STATS PORT_STATS QUEUE_STATS ARP_MATCH_IP
08d1e234 470actions: output enqueue set_vlan_vid set_vlan_pcp strip_vlan mod_dl_src mod_dl_dst mod_nw_src mod_nw_dst mod_nw_tos mod_tp_src mod_tp_dst
0ab14c8e
BP
471 LOCAL(br0): addr:aa:55:aa:55:00:00
472 config: $config
473 state: $state
d02a5f8e 474 speed: 0 Mbps now, 0 Mbps max
3b62feba 475OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0
a2cb9dfd
BP
476])
477done
023e1e0a 478OVS_VSWITCHD_STOP
a2cb9dfd 479AT_CLEANUP
640c7c94 480
9dcd1c00
SH
481AT_SETUP([ofproto - mod-port (OpenFlow 1.2)])
482OVS_VSWITCHD_START
483for command_config_state in \
484 'up 0 0' \
485 'down PORT_DOWN LINK_DOWN' \
486 'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
487 'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
488 'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
489 'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
490 'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
491 'up NO_RECV 0' \
492 'receive 0 0'
493do
494 set $command_config_state
495 command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
496 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn mod-port br0 br0 $command])
497 AT_CHECK([ovs-ofctl -O OpenFlow12 -vwarn show br0], [0], [stdout])
498 AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
499OFPT_FEATURES_REPLY (OF1.2): dpid:fedcba9876543210
500n_tables:254, n_buffers:256
4efe455d 501capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS QUEUE_STATS
9dcd1c00
SH
502 LOCAL(br0): addr:aa:55:aa:55:00:00
503 config: $config
504 state: $state
505 speed: 0 Mbps now, 0 Mbps max
506OFPT_GET_CONFIG_REPLY (OF1.2): frags=normal miss_send_len=0
507])
508done
509OVS_VSWITCHD_STOP
510AT_CLEANUP
511
18cc69d9
BP
512AT_SETUP([ofproto - mod-port (OpenFlow 1.4)])
513OVS_VSWITCHD_START
514for command_config_state in \
515 'up 0 0' \
516 'down PORT_DOWN LINK_DOWN' \
517 'no-receive PORT_DOWN,NO_RECV LINK_DOWN' \
518 'no-forward PORT_DOWN,NO_RECV,NO_FWD LINK_DOWN' \
519 'no-packet-in PORT_DOWN,NO_RECV,NO_FWD,NO_PACKET_IN LINK_DOWN' \
520 'forward PORT_DOWN,NO_RECV,NO_PACKET_IN LINK_DOWN' \
521 'packet-in PORT_DOWN,NO_RECV LINK_DOWN' \
522 'up NO_RECV 0' \
523 'receive 0 0'
524do
525 set $command_config_state
526 command=$[1] config=`echo $[2] | sed 's/,/ /g'` state=$[3]
527 AT_CHECK([ovs-ofctl -O OpenFlow14 -vwarn mod-port br0 br0 $command])
528 AT_CHECK([ovs-ofctl -O OpenFlow14 -vwarn show br0], [0], [stdout])
529 AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
530OFPT_FEATURES_REPLY (OF1.4): dpid:fedcba9876543210
531n_tables:254, n_buffers:256
4efe455d 532capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS QUEUE_STATS
18cc69d9
BP
533OFPST_PORT_DESC reply (OF1.4):
534 LOCAL(br0): addr:aa:55:aa:55:00:00
535 config: $config
536 state: $state
537 speed: 0 Mbps now, 0 Mbps max
538OFPT_GET_CONFIG_REPLY (OF1.4): frags=normal miss_send_len=0
539])
540done
541OVS_VSWITCHD_STOP
542AT_CLEANUP
543
c168dcc8 544AT_SETUP([ofproto - basic flow_mod commands (NXM)])
023e1e0a 545OVS_VSWITCHD_START
ef0ce8ae 546AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
640c7c94 547])
c6100d92
BP
548AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl add-flows br0 -])
549AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=2])
550AT_CHECK([ovs-ofctl -F nxm add-flow br0 table=1,in_port=4,actions=3])
ef0ce8ae 551AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
552 in_port=1 actions=output:2
553 in_port=2 actions=output:1
554 table=1, in_port=4 actions=output:3
0721c073 555NXST_FLOW reply:
640c7c94 556])
0697b5c3 557AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
c168dcc8
BP
558NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
559])
640c7c94 560AT_CHECK([ovs-ofctl del-flows br0])
ef0ce8ae 561AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
640c7c94 562])
023e1e0a 563OVS_VSWITCHD_STOP
640c7c94 564AT_CLEANUP
c168dcc8
BP
565
566AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.0)])
023e1e0a 567OVS_VSWITCHD_START
ef0ce8ae 568AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
c168dcc8 569])
c6100d92
BP
570AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -F openflow10 add-flows br0 -])
571AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 in_port=1,actions=2])
572AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 table=1,in_port=4,actions=3])
ef0ce8ae 573AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
574 in_port=1 actions=output:2
575 in_port=2 actions=output:1
576 table=1, in_port=4 actions=output:3
c168dcc8
BP
577OFPST_FLOW reply:
578])
0697b5c3 579AT_CHECK([ovs-ofctl -F openflow10 dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
c168dcc8
BP
580OFPST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
581])
582AT_CHECK([ovs-ofctl -F openflow10 del-flows br0])
ef0ce8ae 583AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply:
c168dcc8 584])
023e1e0a 585OVS_VSWITCHD_STOP
c168dcc8 586AT_CLEANUP
e729e793 587
75fa58f8
BP
588AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.1)])
589OVS_VSWITCHD_START
590AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.1):
591])
592AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -O OpenFlow11 add-flows br0 -])
593AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 in_port=1,actions=2])
594AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 table=1,in_port=4,actions=3])
595AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
596 in_port=1 actions=output:2
597 in_port=2 actions=output:1
598 table=1, in_port=4 actions=output:3
599OFPST_FLOW reply (OF1.1):
600])
601AT_CHECK([ovs-ofctl -O OpenFlow11 dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
602OFPST_AGGREGATE reply (OF1.1): packet_count=0 byte_count=0 flow_count=2
603])
604AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0])
605AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.1):
0e197060 606 table=1, in_port=4 actions=output:3
75fa58f8
BP
607])
608OVS_VSWITCHD_STOP
609AT_CLEANUP
610
862d8eed
BP
611AT_SETUP([ofproto - flow_mod negative test (OpenFlow 1.1)])
612OVS_VSWITCHD_START(
613 [set bridge br0 protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13])
614AT_CHECK([ovs-ofctl add-flow -O OpenFlow11 br0 table=1,action=goto_table:2])
862d8eed 615
0e197060
BP
616# The error message here actually comes from ovs-ofctl, not from ovs-vswitchd,
617# but at least it's the same code in ofpacts_check() that issues the error.
618AT_CHECK([ovs-ofctl add-flow -O OpenFlow11 br0 table=1,action=goto_table:1],
619 [1], [],
8c87971e 620 [ovs-ofctl: actions are invalid with specified match (OFPBIC_BAD_TABLE_ID)
862d8eed
BP
621])
622OVS_VSWITCHD_STOP
623AT_CLEANUP
624
f5c45121
SH
625AT_SETUP([ofproto - set-field flow_mod commands (NXM)])
626OVS_VSWITCHD_START
627AT_CHECK([ovs-ofctl add-flow br0 ipv6,table=1,in_port=3,actions=drop])
628AT_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])
629AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
630 table=1, ipv6,in_port=3 actions=load:0xa6badbfffefe59fa->NXM_NX_IPV6_SRC[[0..63]],load:0xfe8001234567890a->NXM_NX_IPV6_SRC[[64..127]]
631NXST_FLOW reply:
632])
633OVS_VSWITCHD_STOP
634AT_CLEANUP
635
9dcd1c00 636AT_SETUP([ofproto - basic flow_mod commands (OpenFlow 1.2)])
e729e793 637OVS_VSWITCHD_START
9dcd1c00 638AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.2):
e729e793 639])
9dcd1c00
SH
640AT_CHECK([echo 'in_port=2,actions=1' | ovs-ofctl -O OpenFlow12 add-flows br0 -])
641AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=1,actions=2])
642AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 table=1,in_port=4,actions=3])
643AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
644 in_port=1 actions=output:2
645 in_port=2 actions=output:1
646 table=1, in_port=4 actions=output:3
647OFPST_FLOW reply (OF1.2):
e729e793 648])
9dcd1c00
SH
649AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0])
650AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [OFPST_FLOW reply (OF1.2):
e729e793
JP
651])
652OVS_VSWITCHD_STOP
653AT_CLEANUP
654
9dcd1c00 655AT_SETUP([ofproto - dump flows with cookie])
e729e793 656OVS_VSWITCHD_START
c6100d92
BP
657AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
658AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
659AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
ef0ce8ae 660AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
661 cookie=0x1, in_port=1 actions=output:1
662 cookie=0x2, in_port=2 actions=output:1
663 cookie=0x3, in_port=3 actions=output:1
e729e793
JP
664NXST_FLOW reply:
665])
666AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
667NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=3
668])
9dcd1c00 669AT_CHECK([ovs-ofctl dump-flows br0 cookie=0x3/-1 | ofctl_strip | sort], [0], [dnl
c6100d92 670 cookie=0x3, in_port=3 actions=output:1
e729e793
JP
671NXST_FLOW reply:
672])
9dcd1c00
SH
673AT_CHECK([ovs-ofctl dump-aggregate br0 cookie=0x3/-1 | STRIP_XIDS], [0], [dnl
674NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=1
e729e793
JP
675])
676OVS_VSWITCHD_STOP
677AT_CLEANUP
678
623e1caf
JP
679AT_SETUP([ofproto - mod flow with cookie change (OpenFlow 1.0)])
680OVS_VSWITCHD_START
c6100d92 681AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 cookie=0x1,in_port=1,actions=1])
623e1caf 682AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 683 cookie=0x1, in_port=1 actions=output:1
623e1caf
JP
684OFPST_FLOW reply:
685])
686
c6100d92 687AT_CHECK([ovs-ofctl -F openflow10 mod-flows br0 cookie=0x2,in_port=1,actions=1])
623e1caf 688AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 689 cookie=0x2, in_port=1 actions=output:1
623e1caf
JP
690OFPST_FLOW reply:
691])
692OVS_VSWITCHD_STOP
693AT_CLEANUP
694
695AT_SETUP([ofproto - mod flow with cookie change (NXM)])
696OVS_VSWITCHD_START
c6100d92 697AT_CHECK([ovs-ofctl -F nxm add-flow br0 cookie=0x1,in_port=1,actions=1])
623e1caf 698AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 699 cookie=0x1, in_port=1 actions=output:1
623e1caf
JP
700NXST_FLOW reply:
701])
702
c6100d92 703AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x2,in_port=1,actions=1])
623e1caf 704AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 705 cookie=0x2, in_port=1 actions=output:1
623e1caf
JP
706NXST_FLOW reply:
707])
708OVS_VSWITCHD_STOP
709AT_CLEANUP
710
75fa58f8
BP
711AT_SETUP([ofproto - no mod flow with cookie change (OpenFlow 1.1)])
712OVS_VSWITCHD_START
713AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
714AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
715 cookie=0x1, in_port=1 actions=output:1
716OFPST_FLOW reply (OF1.1):
717])
718AT_CHECK([ovs-ofctl -O OpenFlow11 mod-flows br0 cookie=0x2,in_port=1,actions=1])
719AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
720 cookie=0x1, in_port=1 actions=output:1
721OFPST_FLOW reply (OF1.1):
722])
723OVS_VSWITCHD_STOP
724AT_CLEANUP
725
9dcd1c00 726dnl The OpenFlow 1.2 spec states that the cookie may not be modified
2df3b874 727AT_SETUP([ofproto - no mod flow with cookie change (OpenFlow 1.2)])
9dcd1c00
SH
728OVS_VSWITCHD_START
729AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
730AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
731 cookie=0x1, in_port=1 actions=output:1
732OFPST_FLOW reply (OF1.2):
733])
734
735AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 cookie=0x2,in_port=1,actions=1])
736AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
737 cookie=0x1, in_port=1 actions=output:1
738OFPST_FLOW reply (OF1.2):
739])
740OVS_VSWITCHD_STOP
741AT_CLEANUP
742
743AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.0)])
623e1caf 744OVS_VSWITCHD_START
c6100d92
BP
745AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
746AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
747AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
623e1caf 748AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
749 cookie=0x1, in_port=1 actions=output:1
750 cookie=0x1, in_port=2 actions=output:1
751 cookie=0x2, in_port=3 actions=output:1
623e1caf
JP
752NXST_FLOW reply:
753])
754
755AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=0x1/0xff,actions=4])
756AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
757 cookie=0x1, in_port=1 actions=output:4
758 cookie=0x1, in_port=2 actions=output:4
c6100d92 759 cookie=0x2, in_port=3 actions=output:1
623e1caf
JP
760NXST_FLOW reply:
761])
762OVS_VSWITCHD_STOP
763AT_CLEANUP
764
75fa58f8
BP
765AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.1)])
766OVS_VSWITCHD_START
767AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
768AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=2,actions=1])
769AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x2,in_port=3,actions=1])
770AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
771 cookie=0x1, in_port=1 actions=output:1
772 cookie=0x1, in_port=2 actions=output:1
773 cookie=0x2, in_port=3 actions=output:1
774OFPST_FLOW reply (OF1.1):
775])
776
777AT_CHECK([ovs-ofctl -O OpenFlow11 mod-flows br0 cookie=0x1/0xff,actions=4])
778AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
779 cookie=0x1, in_port=1 actions=output:4
780 cookie=0x1, in_port=2 actions=output:4
781 cookie=0x2, in_port=3 actions=output:1
782OFPST_FLOW reply (OF1.1):
783])
784OVS_VSWITCHD_STOP
785AT_CLEANUP
786
9dcd1c00
SH
787AT_SETUP([ofproto - mod flows based on cookie mask (OpenFlow 1.2)])
788OVS_VSWITCHD_START
789AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
790AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=2,actions=1])
791AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=3,actions=1])
792AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
793 cookie=0x1, in_port=1 actions=output:1
794 cookie=0x1, in_port=2 actions=output:1
795 cookie=0x2, in_port=3 actions=output:1
796OFPST_FLOW reply (OF1.2):
797])
798
799AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 cookie=0x1/0xff,actions=4])
800AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
801 cookie=0x1, in_port=1 actions=output:4
802 cookie=0x1, in_port=2 actions=output:4
803 cookie=0x2, in_port=3 actions=output:1
804OFPST_FLOW reply (OF1.2):
805])
806OVS_VSWITCHD_STOP
807AT_CLEANUP
808
809dnl The OpenFlow 1.2 spec states that the cookie may not be modified
623e1caf
JP
810AT_SETUP([ofproto - mod flows based on cookie mask with cookie change])
811OVS_VSWITCHD_START
c6100d92
BP
812AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
813AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=2,actions=1])
814AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=3,actions=1])
623e1caf 815AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
816 cookie=0x1, in_port=1 actions=output:1
817 cookie=0x1, in_port=2 actions=output:1
818 cookie=0x2, in_port=3 actions=output:1
623e1caf
JP
819NXST_FLOW reply:
820])
821
822AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/-1,cookie=4,actions=4])
823AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 824 cookie=0x2, in_port=3 actions=output:1
623e1caf
JP
825 cookie=0x4, in_port=1 actions=output:4
826 cookie=0x4, in_port=2 actions=output:4
827NXST_FLOW reply:
828])
829OVS_VSWITCHD_STOP
830AT_CLEANUP
831
490020fe 832AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - NXM])
623e1caf 833OVS_VSWITCHD_START
c6100d92 834AT_CHECK([ovs-ofctl -F nxm mod-flows br0 in_port=1,actions=1])
623e1caf 835AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 836 in_port=1 actions=output:1
623e1caf
JP
837NXST_FLOW reply:
838])
839OVS_VSWITCHD_STOP
840AT_CLEANUP
841
75fa58f8
BP
842AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - OF1.1])
843OVS_VSWITCHD_START
844AT_CHECK([ovs-ofctl -O openflow11 mod-flows br0 in_port=1,actions=1])
845AT_CHECK([ovs-ofctl -O openflow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
846 in_port=1 actions=output:1
847OFPST_FLOW reply (OF1.1):
848])
849OVS_VSWITCHD_STOP
850AT_CLEANUP
851
490020fe
BP
852AT_SETUP([ofproto - mod flow with cookie miss (mask==0) - OF1.2])
853OVS_VSWITCHD_START
854AT_CHECK([ovs-ofctl -O openflow12 mod-flows br0 in_port=1,actions=1])
855AT_CHECK([ovs-ofctl -O openflow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
856OFPST_FLOW reply (OF1.2):
857])
858OVS_VSWITCHD_STOP
859AT_CLEANUP
860
861AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - NXM])
623e1caf 862OVS_VSWITCHD_START
c6100d92 863AT_CHECK([ovs-ofctl -F nxm mod-flows br0 cookie=1/1,in_port=1,actions=1])
623e1caf
JP
864AT_CHECK([ovs-ofctl -F nxm dump-flows br0 | ofctl_strip | sort], [0], [dnl
865NXST_FLOW reply:
866])
867OVS_VSWITCHD_STOP
868AT_CLEANUP
869
75fa58f8
BP
870AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - OF1.1])
871OVS_VSWITCHD_START
872AT_CHECK([ovs-ofctl -O openflow11 mod-flows br0 cookie=1/1,in_port=1,actions=1])
873AT_CHECK([ovs-ofctl -O openflow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
874OFPST_FLOW reply (OF1.1):
875])
876OVS_VSWITCHD_STOP
877AT_CLEANUP
878
490020fe
BP
879AT_SETUP([ofproto - mod flow with cookie miss (mask!=0) - OF1.2])
880OVS_VSWITCHD_START
881AT_CHECK([ovs-ofctl -O openflow12 mod-flows br0 cookie=1/1,in_port=1,actions=1])
882AT_CHECK([ovs-ofctl -O openflow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
883OFPST_FLOW reply (OF1.2):
884])
885OVS_VSWITCHD_STOP
886AT_CLEANUP
887
623e1caf
JP
888AT_SETUP([ofproto - del flows with cookies])
889OVS_VSWITCHD_START
c6100d92
BP
890AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
891AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
892AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
623e1caf 893AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
894 cookie=0x1, in_port=1 actions=output:1
895 cookie=0x2, in_port=2 actions=output:1
896 cookie=0x3, in_port=3 actions=output:1
623e1caf
JP
897NXST_FLOW reply:
898])
899
900AT_CHECK([ovs-ofctl del-flows br0])
901AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
902NXST_FLOW reply:
903])
904OVS_VSWITCHD_STOP
905AT_CLEANUP
906
907AT_SETUP([ofproto - del flows based on cookie])
e729e793 908OVS_VSWITCHD_START
c6100d92
BP
909AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
910AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
911AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
ef0ce8ae 912AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
913 cookie=0x1, in_port=1 actions=output:1
914 cookie=0x2, in_port=2 actions=output:1
915 cookie=0x3, in_port=3 actions=output:1
e729e793
JP
916NXST_FLOW reply:
917])
80d5aefd 918
623e1caf 919AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/-1])
ef0ce8ae 920AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
921 cookie=0x1, in_port=1 actions=output:1
922 cookie=0x2, in_port=2 actions=output:1
e729e793
JP
923NXST_FLOW reply:
924])
925OVS_VSWITCHD_STOP
926AT_CLEANUP
927
623e1caf 928AT_SETUP([ofproto - del flows based on cookie mask])
e729e793 929OVS_VSWITCHD_START
c6100d92
BP
930AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
931AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,actions=1])
932AT_CHECK([ovs-ofctl add-flow br0 cookie=0x3,in_port=3,actions=1])
ef0ce8ae 933AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92
BP
934 cookie=0x1, in_port=1 actions=output:1
935 cookie=0x2, in_port=2 actions=output:1
936 cookie=0x3, in_port=3 actions=output:1
e729e793
JP
937NXST_FLOW reply:
938])
939AT_CHECK([ovs-ofctl del-flows br0 cookie=0x3/0x1])
ef0ce8ae 940AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
c6100d92 941 cookie=0x2, in_port=2 actions=output:1
e729e793
JP
942NXST_FLOW reply:
943])
944OVS_VSWITCHD_STOP
945AT_CLEANUP
254750ce 946
9dcd1c00 947AT_SETUP([ofproto - del flows based on table id (NXM)])
c90cfeaf
SH
948OVS_VSWITCHD_START
949AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
950AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
951AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
952 cookie=0x1, in_port=1 actions=output:1
953 cookie=0x2, table=1, in_port=2 actions=output:1
954NXST_FLOW reply:
955])
956AT_CHECK([ovs-ofctl del-flows br0 table=0])
957AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
958 cookie=0x2, table=1, in_port=2 actions=output:1
959NXST_FLOW reply:
960])
961AT_CHECK([ovs-ofctl del-flows br0 table=1])
962AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
963NXST_FLOW reply:
964])
965AT_CHECK([ovs-ofctl add-flow br0 cookie=0x1,in_port=1,actions=1])
966AT_CHECK([ovs-ofctl add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
967AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
968 cookie=0x1, in_port=1 actions=output:1
969 cookie=0x2, table=1, in_port=2 actions=output:1
970NXST_FLOW reply:
971])
972AT_CHECK([ovs-ofctl del-flows br0])
973AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
974NXST_FLOW reply:
975])
976OVS_VSWITCHD_STOP
977AT_CLEANUP
978
75fa58f8
BP
979AT_SETUP([ofproto - del flows based on table id (OpenFlow 1.1)])
980OVS_VSWITCHD_START
981AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
982AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
983AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
984 cookie=0x1, in_port=1 actions=output:1
985 cookie=0x2, table=1, in_port=2 actions=output:1
986OFPST_FLOW reply (OF1.1):
987])
988AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 table=0])
989AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
990 cookie=0x2, table=1, in_port=2 actions=output:1
991OFPST_FLOW reply (OF1.1):
992])
993AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0 table=1])
994AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
995OFPST_FLOW reply (OF1.1):
996])
997AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x1,in_port=1,actions=1])
998AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
999AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1000 cookie=0x1, in_port=1 actions=output:1
1001 cookie=0x2, table=1, in_port=2 actions=output:1
1002OFPST_FLOW reply (OF1.1):
1003])
1004AT_CHECK([ovs-ofctl -O OpenFlow11 del-flows br0])
0e197060 1005AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
75fa58f8 1006OFPST_FLOW reply (OF1.1):
0e197060 1007 cookie=0x2, table=1, in_port=2 actions=output:1
75fa58f8
BP
1008])
1009OVS_VSWITCHD_STOP
1010AT_CLEANUP
1011
9dcd1c00
SH
1012AT_SETUP([ofproto - del flows based on table id (OpenFlow 1.2)])
1013OVS_VSWITCHD_START
1014AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
1015AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
1016AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1017 cookie=0x1, in_port=1 actions=output:1
1018 cookie=0x2, table=1, in_port=2 actions=output:1
1019OFPST_FLOW reply (OF1.2):
1020])
1021AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0 table=0])
1022AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1023 cookie=0x2, table=1, in_port=2 actions=output:1
1024OFPST_FLOW reply (OF1.2):
1025])
1026AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0 table=1])
1027AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1028OFPST_FLOW reply (OF1.2):
1029])
1030AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x1,in_port=1,actions=1])
1031AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 cookie=0x2,in_port=2,table=1,actions=1])
1032AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1033 cookie=0x1, in_port=1 actions=output:1
1034 cookie=0x2, table=1, in_port=2 actions=output:1
1035OFPST_FLOW reply (OF1.2):
1036])
1037AT_CHECK([ovs-ofctl -O OpenFlow12 del-flows br0])
1038AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1039OFPST_FLOW reply (OF1.2):
1040])
1041OVS_VSWITCHD_STOP
1042AT_CLEANUP
1043
1044AT_SETUP([ofproto - flow table configuration (OpenFlow 1.0)])
254750ce
BP
1045OVS_VSWITCHD_START
1046# Check the default configuration.
3c1bb396
BP
1047(printf "OFPST_TABLE reply (xid=0x2):"
1048 x=0
1049 name=classifier
c57b2226 1050 while test $x -lt 254; do
3c1bb396
BP
1051 printf "
1052 table %d (\"%s\"):
1053 active=0, lookup=0, matched=0
1054 max_entries=1000000
1055 matching:
1056 in_port: exact match or wildcard
1057 eth_src: exact match or wildcard
1058 eth_dst: exact match or wildcard
1059 eth_type: exact match or wildcard
1060 vlan_vid: exact match or wildcard
1061 vlan_pcp: exact match or wildcard
1062 ip_src: exact match or wildcard
1063 ip_dst: exact match or wildcard
1064 nw_proto: exact match or wildcard
1065 nw_tos: exact match or wildcard
1066 tcp_src: exact match or wildcard
1067 tcp_dst: exact match or wildcard
1068" $x $name
254750ce 1069 x=`expr $x + 1`
3c1bb396 1070 name=table$x
c2f0373a 1071 done) > expout
254750ce
BP
1072AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
1073# Change the configuration.
1074AT_CHECK(
1075 [ovs-vsctl \
1076 -- --id=@t0 create Flow_Table name=main \
1077 -- --id=@t1 create Flow_Table flow-limit=1024 \
1078 -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
5c6d0628 1079 | ${PERL} $srcdir/uuidfilt.pl],
254750ce
BP
1080 [0], [<0>
1081<1>
1082])
1083# Check that the configuration was updated.
1084mv expout orig-expout
3c1bb396
BP
1085sed -e 's/classifier/main/
108621s/1000000/1024/' orig-expout > expout
254750ce
BP
1087AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
1088OVS_VSWITCHD_STOP
1089AT_CLEANUP
1090
9dcd1c00
SH
1091AT_SETUP([ofproto - flow table configuration (OpenFlow 1.2)])
1092OVS_VSWITCHD_START
1093# Check the default configuration.
3c1bb396
BP
1094(printf "OFPST_TABLE reply (OF1.2) (xid=0x2):"
1095 x=0
1096 name=classifier
9dcd1c00 1097 while test $x -lt 254; do
3c1bb396
BP
1098 echo "
1099 table $x (\"$name\"):
1100 active=0, lookup=0, matched=0
1101 metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1102 config=controller
1103 max_entries=1000000
1104 instructions (table miss and others):
1105 instructions: apply_actions,clear_actions,write_actions,write_metadata,goto_table
1106 Write-Actions and Apply-Actions features:
1107 actions: output group set_field strip_vlan push_vlan mod_nw_ttl dec_ttl set_mpls_ttl dec_mpls_ttl push_mpls pop_mpls set_queue
1108 supported on Set-Field: metadata in_port_oxm eth_src eth_dst vlan_vid vlan_pcp mpls_label mpls_tc ip_src ip_dst ipv6_src ipv6_dst ip_dscp nw_ecn arp_op arp_spa arp_tpa arp_sha arp_tha tcp_src tcp_dst udp_src udp_dst sctp_src sctp_dst
1109 matching:
1110 metadata: exact match or wildcard
1111 in_port_oxm: exact match or wildcard
1112 eth_src: exact match or wildcard
1113 eth_dst: exact match or wildcard
1114 eth_type: exact match or wildcard
1115 vlan_vid: exact match or wildcard
1116 vlan_pcp: exact match or wildcard
1117 mpls_label: exact match or wildcard
1118 mpls_tc: exact match or wildcard
1119 ip_src: exact match or wildcard
1120 ip_dst: exact match or wildcard
1121 ipv6_src: exact match or wildcard
1122 ipv6_dst: exact match or wildcard
1123 ipv6_label: exact match or wildcard
1124 nw_proto: exact match or wildcard
1125 ip_dscp: exact match or wildcard
1126 nw_ecn: exact match or wildcard
1127 arp_op: exact match or wildcard
1128 arp_spa: exact match or wildcard
1129 arp_tpa: exact match or wildcard
1130 arp_sha: exact match or wildcard
1131 arp_tha: exact match or wildcard
1132 tcp_src: exact match or wildcard
1133 tcp_dst: exact match or wildcard
1134 udp_src: exact match or wildcard
1135 udp_dst: exact match or wildcard
1136 sctp_src: exact match or wildcard
1137 sctp_dst: exact match or wildcard
1138 icmp_type: exact match or wildcard
1139 icmp_code: exact match or wildcard
1140 icmpv6_type: exact match or wildcard
1141 icmpv6_code: exact match or wildcard
1142 nd_target: exact match or wildcard
1143 nd_sll: exact match or wildcard
1144 nd_tll: exact match or wildcard"
9dcd1c00 1145 x=`expr $x + 1`
3c1bb396 1146 name=table$x
9dcd1c00
SH
1147 done) > expout
1148AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
1149# Change the configuration.
1150AT_CHECK(
1151 [ovs-vsctl \
1152 -- --id=@t0 create Flow_Table name=main \
1153 -- --id=@t1 create Flow_Table flow-limit=1024 \
1154 -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
5c6d0628 1155 | ${PERL} $srcdir/uuidfilt.pl],
9dcd1c00
SH
1156 [0], [<0>
1157<1>
1158])
1159# Check that the configuration was updated.
1160mv expout orig-expout
3c1bb396
BP
1161sed 's/classifier/main/
116253s/1000000/1024/' < orig-expout > expout
9dcd1c00
SH
1163AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], [expout])
1164OVS_VSWITCHD_STOP
1165AT_CLEANUP
1166
3c4e10fb
BP
1167AT_SETUP([ofproto - table features (OpenFlow 1.3)])
1168OVS_VSWITCHD_START
1169(x=0
1170 name=classifier
1171 while test $x -lt 254; do
1172 y=`expr $x + 1`
1173 if test $x = 253; then
1174 next=254
1175 else
1176 next=$y-254
1177 fi
1178 echo " table $x (\"$name\"):
1179 metadata: match=0xffffffffffffffff write=0xffffffffffffffff
1180 max_entries=1000000
1181 instructions (table miss and others):
1182 next tables: $next
1183 instructions: meter,apply_actions,clear_actions,write_actions,write_metadata,goto_table
1184 Write-Actions and Apply-Actions features:
1185 actions: output group set_field strip_vlan push_vlan mod_nw_ttl dec_ttl set_mpls_ttl dec_mpls_ttl push_mpls pop_mpls set_queue
1186 supported on Set-Field: tun_id tun_src tun_dst metadata in_port in_port_oxm pkt_mark reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 xreg0 xreg1 xreg2 xreg3 eth_src eth_dst vlan_tci vlan_vid vlan_pcp mpls_label mpls_tc ip_src ip_dst ipv6_src ipv6_dst nw_tos ip_dscp nw_ecn nw_ttl arp_op arp_spa arp_tpa arp_sha arp_tha tcp_src tcp_dst udp_src udp_dst sctp_src sctp_dst
1187 matching:
1188 dp_hash: arbitrary mask
1189 recirc_id: exact match or wildcard
1190 tun_id: arbitrary mask
1191 tun_src: arbitrary mask
1192 tun_dst: arbitrary mask
1193 metadata: arbitrary mask
1194 in_port: exact match or wildcard
1195 in_port_oxm: exact match or wildcard
1196 pkt_mark: arbitrary mask
1197 reg0: arbitrary mask
1198 reg1: arbitrary mask
1199 reg2: arbitrary mask
1200 reg3: arbitrary mask
1201 reg4: arbitrary mask
1202 reg5: arbitrary mask
1203 reg6: arbitrary mask
1204 reg7: arbitrary mask
1205 xreg0: arbitrary mask
1206 xreg1: arbitrary mask
1207 xreg2: arbitrary mask
1208 xreg3: arbitrary mask
1209 eth_src: arbitrary mask
1210 eth_dst: arbitrary mask
1211 eth_type: exact match or wildcard
1212 vlan_tci: arbitrary mask
1213 vlan_vid: arbitrary mask
1214 vlan_pcp: exact match or wildcard
1215 mpls_label: exact match or wildcard
1216 mpls_tc: exact match or wildcard
1217 mpls_bos: exact match or wildcard
1218 ip_src: arbitrary mask
1219 ip_dst: arbitrary mask
1220 ipv6_src: arbitrary mask
1221 ipv6_dst: arbitrary mask
1222 ipv6_label: arbitrary mask
1223 nw_proto: exact match or wildcard
1224 nw_tos: exact match or wildcard
1225 ip_dscp: exact match or wildcard
1226 nw_ecn: exact match or wildcard
1227 nw_ttl: exact match or wildcard
1228 ip_frag: arbitrary mask
1229 arp_op: exact match or wildcard
1230 arp_spa: arbitrary mask
1231 arp_tpa: arbitrary mask
1232 arp_sha: arbitrary mask
1233 arp_tha: arbitrary mask
1234 tcp_src: arbitrary mask
1235 tcp_dst: arbitrary mask
1236 tcp_flags: arbitrary mask
1237 udp_src: arbitrary mask
1238 udp_dst: arbitrary mask
1239 sctp_src: arbitrary mask
1240 sctp_dst: arbitrary mask
1241 icmp_type: exact match or wildcard
1242 icmp_code: exact match or wildcard
1243 icmpv6_type: exact match or wildcard
1244 icmpv6_code: exact match or wildcard
1245 nd_target: arbitrary mask
1246 nd_sll: arbitrary mask
1247 nd_tll: arbitrary mask"
1248 x=$y
1249 name=table$x
1250 done) > expout
1251AT_CHECK([ovs-ofctl -O OpenFlow13 dump-table-features br0 | sed '/^$/d
1252/^OFPST_TABLE_FEATURES/d'], [0], [expout])
1253# Change the configuration.
1254AT_CHECK(
1255 [ovs-vsctl \
1256 -- --id=@t0 create Flow_Table name=main \
1257 -- --id=@t1 create Flow_Table flow-limit=1024 \
1258 -- set bridge br0 'flow_tables={1=@t1,0=@t0}' \
1259 | ${PERL} $srcdir/uuidfilt.pl],
1260 [0], [<0>
1261<1>
1262])
1263# Check that the configuration was updated.
1264mv expout orig-expout
1265sed 's/classifier/main/
126673s/1000000/1024/' < orig-expout > expout
1267AT_CHECK([ovs-ofctl -O OpenFlow13 dump-table-features br0 | sed '/^$/d
1268/^OFPST_TABLE_FEATURES/d'], [0], [expout])
1269OVS_VSWITCHD_STOP
1270AT_CLEANUP
1271
06f64d03 1272AT_SETUP([ofproto - hard limits on flow table size (OpenFlow 1.0)])
254750ce
BP
1273OVS_VSWITCHD_START
1274# Configure a maximum of 4 flows.
1275AT_CHECK(
1276 [ovs-vsctl \
1277 -- --id=@t0 create Flow_Table flow-limit=4 \
1278 -- set bridge br0 flow_tables:0=@t0 \
5c6d0628 1279 | ${PERL} $srcdir/uuidfilt.pl],
254750ce
BP
1280 [0], [<0>
1281])
1282# Add 4 flows.
1283for in_port in 1 2 3 4; do
1284 ovs-ofctl add-flow br0 in_port=$in_port,actions=drop
1285done
1286AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1287 in_port=1 actions=drop
1288 in_port=2 actions=drop
1289 in_port=3 actions=drop
1290 in_port=4 actions=drop
1291NXST_FLOW reply:
1292])
1293# Adding another flow will be refused.
1294AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
27527aa0 1295AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
be2b69d1 1296 [OFPT_ERROR: OFPFMFC_TABLE_FULL
254750ce
BP
1297])
1298# Also a mod-flow that would add a flow will be refused.
1299AT_CHECK([ovs-ofctl mod-flows br0 in_port=5,actions=drop], [1], [], [stderr])
27527aa0 1300AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
be2b69d1 1301 [OFPT_ERROR: OFPFMFC_TABLE_FULL
254750ce
BP
1302])
1303# Replacing or modifying an existing flow is allowed.
1304AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
1305AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
1306AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1307 in_port=1 actions=drop
1308 in_port=2 actions=drop
1309 in_port=3 actions=output:1
1310 in_port=4 actions=NORMAL
1311NXST_FLOW reply:
1312])
1313OVS_VSWITCHD_STOP
1314AT_CLEANUP
1315
06f64d03 1316AT_SETUP([ofproto - hard limits on flow table size (OpenFlow 1.2)])
9dcd1c00
SH
1317OVS_VSWITCHD_START
1318# Configure a maximum of 4 flows.
1319AT_CHECK(
1320 [ovs-vsctl \
1321 -- --id=@t0 create Flow_Table flow-limit=4 \
1322 -- set bridge br0 flow_tables:0=@t0 \
5c6d0628 1323 | ${PERL} $srcdir/uuidfilt.pl],
9dcd1c00
SH
1324 [0], [<0>
1325])
1326# Add 4 flows.
1327for in_port in 1 2 3 4; do
1328 ovs-ofctl -O OpenFlow12 add-flow br0 in_port=$in_port,actions=drop
1329done
1330AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1331 in_port=1 actions=drop
1332 in_port=2 actions=drop
1333 in_port=3 actions=drop
1334 in_port=4 actions=drop
1335OFPST_FLOW reply (OF1.2):
1336])
1337# Adding another flow will be refused.
1338AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop], [1], [], [stderr])
1339AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1340 [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
1341])
1342# Replacing or modifying an existing flow is allowed.
1343AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
1344AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
1345AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1346 in_port=1 actions=drop
1347 in_port=2 actions=drop
1348 in_port=3 actions=output:1
1349 in_port=4 actions=NORMAL
1350OFPST_FLOW reply (OF1.2):
1351])
1352OVS_VSWITCHD_STOP
1353AT_CLEANUP
1354
1355AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.0)])
254750ce
BP
1356OVS_VSWITCHD_START
1357# Configure a maximum of 4 flows.
1358AT_CHECK(
1359 [ovs-vsctl \
1360 -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
1361 -- set bridge br0 flow_tables:0=@t0 \
5c6d0628 1362 | ${PERL} $srcdir/uuidfilt.pl],
254750ce
BP
1363 [0], [<0>
1364])
1365# Add 4 flows.
1366for in_port in 4 3 2 1; do
1367 ovs-ofctl add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
1368done
1369AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
1370 idle_timeout=10, in_port=1 actions=drop
1371 idle_timeout=20, in_port=2 actions=drop
1372 idle_timeout=30, in_port=3 actions=drop
1373 idle_timeout=40, in_port=4 actions=drop
254750ce
BP
1374NXST_FLOW reply:
1375])
1376# Adding another flow will cause the one that expires soonest to be evicted.
1377AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
1378AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
1379 idle_timeout=20, in_port=2 actions=drop
1380 idle_timeout=30, in_port=3 actions=drop
1381 idle_timeout=40, in_port=4 actions=drop
254750ce
BP
1382 in_port=5 actions=drop
1383NXST_FLOW reply:
1384])
1385# A mod-flow that adds a flow also causes eviction, but replacing or
1386# modifying an existing flow doesn't.
1387AT_CHECK([ovs-ofctl mod-flows br0 in_port=6,actions=drop])
1388AT_CHECK([ovs-ofctl add-flow br0 in_port=4,actions=normal])
1389AT_CHECK([ovs-ofctl mod-flows br0 in_port=3,actions=output:1])
1390AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b 1391 idle_timeout=30, in_port=3 actions=output:1
254750ce
BP
1392 in_port=4 actions=NORMAL
1393 in_port=5 actions=drop
1394 in_port=6 actions=drop
1395NXST_FLOW reply:
1396])
1397# Flows with no timeouts at all cannot be evicted.
1398AT_CHECK([ovs-ofctl add-flow br0 in_port=7,actions=normal])
1399AT_CHECK([ovs-ofctl add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
27527aa0 1400AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
be2b69d1 1401 [OFPT_ERROR: OFPFMFC_TABLE_FULL
254750ce
BP
1402])
1403AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
1404 in_port=4 actions=NORMAL
1405 in_port=5 actions=drop
1406 in_port=6 actions=drop
1407 in_port=7 actions=NORMAL
1408NXST_FLOW reply:
1409])
1410OVS_VSWITCHD_STOP
1411AT_CLEANUP
1412
9dcd1c00
SH
1413AT_SETUP([ofproto - eviction upon table overflow (OpenFlow 1.2)])
1414OVS_VSWITCHD_START
1415# Configure a maximum of 4 flows.
1416AT_CHECK(
1417 [ovs-vsctl \
1418 -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
1419 -- set bridge br0 flow_tables:0=@t0 \
5c6d0628 1420 | ${PERL} $srcdir/uuidfilt.pl],
9dcd1c00
SH
1421 [0], [<0>
1422])
1423# Add 4 flows.
1424for in_port in 4 3 2 1; do
1425 ovs-ofctl -O OpenFlow12 add-flow br0 idle_timeout=${in_port}0,in_port=$in_port,actions=drop
1426done
1427AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1428 idle_timeout=10, in_port=1 actions=drop
1429 idle_timeout=20, in_port=2 actions=drop
1430 idle_timeout=30, in_port=3 actions=drop
1431 idle_timeout=40, in_port=4 actions=drop
1432OFPST_FLOW reply (OF1.2):
1433])
1434# Adding another flow will cause the one that expires soonest to be evicted.
1435AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=5,actions=drop])
1436AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1437 idle_timeout=20, in_port=2 actions=drop
1438 idle_timeout=30, in_port=3 actions=drop
1439 idle_timeout=40, in_port=4 actions=drop
1440 in_port=5 actions=drop
1441OFPST_FLOW reply (OF1.2):
1442])
1443# In Open Flow 1.2 a mod-flow does not ever add a flow and thus
1444# has no effect on eviction
1445AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=6,actions=drop])
1446AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=4,actions=normal])
1447AT_CHECK([ovs-ofctl -O OpenFlow12 mod-flows br0 in_port=3,actions=output:1])
1448AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1449 idle_timeout=20, in_port=2 actions=drop
1450 idle_timeout=30, in_port=3 actions=output:1
1451 in_port=4 actions=NORMAL
1452 in_port=5 actions=drop
1453OFPST_FLOW reply (OF1.2):
1454])
1455# Flows with no timeouts at all cannot be evicted.
1456AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=6,actions=drop])
1457AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=7,actions=normal])
1458AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=8,actions=drop], [1], [], [stderr])
1459AT_CHECK([head -n 1 stderr | ofctl_strip], [0],
1460 [OFPT_ERROR (OF1.2): OFPFMFC_TABLE_FULL
1461])
1462AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1463 in_port=4 actions=NORMAL
1464 in_port=5 actions=drop
1465 in_port=6 actions=drop
1466 in_port=7 actions=NORMAL
1467OFPST_FLOW reply (OF1.2):
1468])
1469OVS_VSWITCHD_STOP
1470AT_CLEANUP
1471
1472AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.0)])
254750ce
BP
1473OVS_VSWITCHD_START
1474# Configure a maximum of 4 flows.
1475AT_CHECK(
1476 [ovs-vsctl \
1477 -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
1478 overflow-policy=evict \
1479 groups='"NXM_OF_IN_PORT[[]]"' \
1480 -- set bridge br0 flow_tables:0=@t0 \
5c6d0628 1481 | ${PERL} $srcdir/uuidfilt.pl],
254750ce
BP
1482 [0], [<0>
1483])
1484# Add 4 flows.
1485ovs-ofctl add-flows br0 - <<EOF
1486idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
1487idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
1488idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
1489idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
1490EOF
1491AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
1492 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1493 idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
1494 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1495 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
254750ce
BP
1496NXST_FLOW reply:
1497])
1498# Adding another flow will cause the one that expires soonest within
1499# the largest group (those with in_port=1) to be evicted. In this
1500# case this is not the same as the one that expires soonest overall
1501# (which is what makes the test interesting):
1502AT_CHECK([ovs-ofctl add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
1503AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
1504 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1505 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1506 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
254750ce
BP
1507 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1508NXST_FLOW reply:
1509])
1510# Enlarge the flow limit, change the eviction policy back to strictly
1511# based on expiration, and and add some flows.
1512AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
1513ovs-ofctl add-flows br0 - <<EOF
1514idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
1515idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
1516idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
1517EOF
1518AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
1519 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1520 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1521 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1522 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
1523 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1524 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
254750ce
BP
1525 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1526NXST_FLOW reply:
1527])
1528# Adding another flow will cause the one that expires soonest overall
1529# to be evicted.
1530AT_CHECK([ovs-ofctl add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
1531AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
1532 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1533 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1534 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
1535 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1536 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1537 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
254750ce
BP
1538 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1539NXST_FLOW reply:
1540])
1541# Reducing the flow limit also causes the flows that expire soonest
1542# overall to be evicted.
1543AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
1544AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
b9718b7b
BP
1545 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1546 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1547 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
254750ce
BP
1548 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1549NXST_FLOW reply:
1550])
1551OVS_VSWITCHD_STOP
1552AT_CLEANUP
80d5aefd 1553
9dcd1c00
SH
1554AT_SETUP([ofproto - eviction upon table overflow, with fairness (OpenFlow 1.2)])
1555OVS_VSWITCHD_START
1556# Configure a maximum of 4 flows.
1557AT_CHECK(
1558 [ovs-vsctl \
1559 -- --id=@t0 create Flow_Table name=evict flow-limit=4 \
1560 overflow-policy=evict \
1561 groups='"NXM_OF_IN_PORT[[]]"' \
1562 -- set bridge br0 flow_tables:0=@t0 \
5c6d0628 1563 | ${PERL} $srcdir/uuidfilt.pl],
9dcd1c00
SH
1564 [0], [<0>
1565])
1566# Add 4 flows.
1567ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
1568idle_timeout=10 in_port=2 dl_src=00:44:55:66:77:88 actions=drop
1569idle_timeout=20 in_port=1 dl_src=00:11:22:33:44:55 actions=drop
1570idle_timeout=30 in_port=1 dl_src=00:22:33:44:55:66 actions=drop
1571idle_timeout=40 in_port=1 dl_src=00:33:44:55:66:77 actions=drop
1572EOF
1573AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1574 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1575 idle_timeout=20, in_port=1,dl_src=00:11:22:33:44:55 actions=drop
1576 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1577 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1578OFPST_FLOW reply (OF1.2):
1579])
1580# Adding another flow will cause the one that expires soonest within
1581# the largest group (those with in_port=1) to be evicted. In this
1582# case this is not the same as the one that expires soonest overall
1583# (which is what makes the test interesting):
1584AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 in_port=2,dl_src=00:55:66:77:88:99,actions=drop])
1585AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1586 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1587 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1588 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1589 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1590OFPST_FLOW reply (OF1.2):
1591])
1592# Enlarge the flow limit, change the eviction policy back to strictly
1593# based on expiration, and and add some flows.
1594AT_CHECK([ovs-vsctl set Flow_Table evict groups='[[]]' flow-limit=7])
1595ovs-ofctl -O OpenFlow12 add-flows br0 - <<EOF
1596idle_timeout=50 in_port=2 dl_src=00:66:77:88:99:aa actions=drop
1597idle_timeout=60 in_port=2 dl_src=00:77:88:99:aa:bb actions=drop
1598idle_timeout=70 in_port=2 dl_src=00:88:99:aa:bb:cc actions=drop
1599EOF
1600AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1601 idle_timeout=10, in_port=2,dl_src=00:44:55:66:77:88 actions=drop
1602 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1603 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1604 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
1605 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1606 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1607 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1608OFPST_FLOW reply (OF1.2):
1609])
1610# Adding another flow will cause the one that expires soonest overall
1611# to be evicted.
1612AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 'idle_timeout=80 in_port=2 dl_src=00:99:aa:bb:cc:dd actions=drop'])
1613AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1614 idle_timeout=30, in_port=1,dl_src=00:22:33:44:55:66 actions=drop
1615 idle_timeout=40, in_port=1,dl_src=00:33:44:55:66:77 actions=drop
1616 idle_timeout=50, in_port=2,dl_src=00:66:77:88:99:aa actions=drop
1617 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1618 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1619 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1620 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1621OFPST_FLOW reply (OF1.2):
1622])
1623# Reducing the flow limit also causes the flows that expire soonest
1624# overall to be evicted.
1625AT_CHECK([ovs-vsctl set Flow_Table evict flow-limit=4])
1626AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip | sort], [0], [dnl
1627 idle_timeout=60, in_port=2,dl_src=00:77:88:99:aa:bb actions=drop
1628 idle_timeout=70, in_port=2,dl_src=00:88:99:aa:bb:cc actions=drop
1629 idle_timeout=80, in_port=2,dl_src=00:99:aa:bb:cc:dd actions=drop
1630 in_port=2,dl_src=00:55:66:77:88:99 actions=drop
1631OFPST_FLOW reply (OF1.2):
1632])
1633OVS_VSWITCHD_STOP
1634AT_CLEANUP
1635
6d56c1f1
K
1636AT_SETUP([ofproto - eviction upon table overflow, with modified hard timeout])
1637OVS_VSWITCHD_START
1638# Configure a maximum of 4 flows.
1639AT_CHECK(
1640 [ovs-vsctl \
1641 -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
1642 -- set bridge br0 flow_tables:0=@t0 \
1643 | ${PERL} $srcdir/uuidfilt.pl],
1644 [0], [<0>
1645])
337a3866 1646ovs-appctl time/stop
6d56c1f1
K
1647# Add 4 flows.
1648for in_port in 4 3 2 1; do
337a3866 1649 ovs-ofctl add-flow br0 hard_timeout=$((10 + in_port * 3)),in_port=$in_port,actions=drop
6d56c1f1
K
1650done
1651AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
337a3866
YT
1652 hard_timeout=13, in_port=1 actions=drop
1653 hard_timeout=16, in_port=2 actions=drop
1654 hard_timeout=19, in_port=3 actions=drop
1655 hard_timeout=22, in_port=4 actions=drop
6d56c1f1
K
1656NXST_FLOW reply:
1657])
1658# Sleep and modify the one that expires soonest
337a3866 1659ovs-appctl time/warp 5000
6d56c1f1 1660AT_CHECK([ovs-ofctl mod-flows br0 in_port=1,actions=drop])
337a3866
YT
1661# At this point the table would looks like:
1662# in_port seconds to expire
1663# 1 13
1664# 2 11
1665# 3 14
1666# 4 17
1667ovs-appctl time/warp 2000
6d56c1f1
K
1668# Adding another flow will cause the one that expires soonest to be evicted.
1669AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
1670AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
337a3866
YT
1671 hard_timeout=13, in_port=1 actions=drop
1672 hard_timeout=19, in_port=3 actions=drop
1673 hard_timeout=22, in_port=4 actions=drop
6d56c1f1
K
1674 in_port=5 actions=drop
1675NXST_FLOW reply:
1676])
1677OVS_VSWITCHD_STOP
1678AT_CLEANUP
1679
1680AT_SETUP([ofproto - eviction upon table overflow, with modified idle timeout])
1681OVS_VSWITCHD_START([add-port br0 p1 -- set interface p1 type=dummy ofport_request=1])
1682# Configure a maximum of 4 flows.
1683AT_CHECK(
1684 [ovs-vsctl \
1685 -- --id=@t0 create Flow_Table flow-limit=4 overflow-policy=evict \
1686 -- set bridge br0 flow_tables:0=@t0 \
1687 | ${PERL} $srcdir/uuidfilt.pl],
1688 [0], [<0>
1689])
1690# Add 4 flows.
1691for in_port in 4 3 2 1; do
337a3866 1692 ovs-ofctl add-flow br0 idle_timeout=$((10 + in_port * 3)),in_port=$in_port,actions=drop
6d56c1f1 1693done
337a3866 1694ovs-appctl time/stop
6d56c1f1 1695AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
337a3866
YT
1696 idle_timeout=13, in_port=1 actions=drop
1697 idle_timeout=16, in_port=2 actions=drop
1698 idle_timeout=19, in_port=3 actions=drop
1699 idle_timeout=22, in_port=4 actions=drop
6d56c1f1
K
1700NXST_FLOW reply:
1701])
1702# Sleep and receive on the flow that expires soonest
337a3866 1703ovs-appctl time/warp 5000
6d56c1f1 1704AT_CHECK([ovs-appctl netdev-dummy/receive p1 'in_port(1)'])
337a3866
YT
1705# At this point the table would looks like:
1706# in_port seconds to expire
1707# 1 13
1708# 2 11
1709# 3 14
1710# 4 17
1711ovs-appctl time/warp 2000
6d56c1f1
K
1712# Adding another flow will cause the one that expires soonest to be evicted.
1713AT_CHECK([ovs-ofctl add-flow br0 in_port=5,actions=drop])
1714AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl
337a3866
YT
1715 idle_timeout=19, in_port=3 actions=drop
1716 idle_timeout=22, in_port=4 actions=drop
6d56c1f1 1717 in_port=5 actions=drop
337a3866 1718 n_packets=1, n_bytes=60, idle_timeout=13, in_port=1 actions=drop
6d56c1f1
K
1719NXST_FLOW reply:
1720])
1721OVS_VSWITCHD_STOP
1722AT_CLEANUP
1723
9dcd1c00 1724AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.0)])
80d5aefd
BP
1725OVS_VSWITCHD_START
1726AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
1727check_async () {
1728 printf '\n\n--- check_async %d ---\n\n\n' $1
1729 shift
1730
6fc67c4f 1731 ovs-appctl -t ovs-ofctl ofctl/barrier
80d5aefd
BP
1732 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1733 : > expout
1734
a7349929 1735 # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
7f05e7ab 1736 ovs-ofctl -v packet-out br0 controller controller '0001020304050010203040501234'
80d5aefd 1737 if test X"$1" = X"OFPR_ACTION"; then shift;
7f05e7ab 1738 echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
78c9486d 1739in_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
1740 fi
1741
a7349929 1742 # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
7f05e7ab 1743 ovs-ofctl -v packet-out br0 controller 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
a7349929 1744 if test X"$1" = X"OFPR_NO_MATCH"; then shift;
7f05e7ab 1745 echo >>expout "OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via no_match) data_len=14 (unbuffered)
78c9486d 1746in_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
1747 fi
1748
1749 # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
7f05e7ab 1750 ovs-ofctl packet-out br0 controller dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
80d5aefd 1751 if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
7f05e7ab 1752 echo >>expout "OFPT_PACKET_IN: total_len=76 in_port=CONTROLLER (via invalid_ttl) data_len=76 (unbuffered)
78c9486d 1753udp,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
1754 fi
1755
1756 # OFPT_PORT_STATUS, OFPPR_ADD
e1b1d06a 1757 ovs-vsctl add-port br0 test -- set Interface test type=dummy ofport_request=1
80d5aefd
BP
1758 if test X"$1" = X"OFPPR_ADD"; then shift;
1759 echo >>expout "OFPT_PORT_STATUS: ADD: 1(test): addr:aa:55:aa:55:00:0x
1760 config: PORT_DOWN
9e1fd49b 1761 state: LINK_DOWN
d02a5f8e 1762 speed: 0 Mbps now, 0 Mbps max"
80d5aefd
BP
1763 fi
1764
1765 # OFPT_PORT_STATUS, OFPPR_DELETE
1766 ovs-vsctl del-port br0 test
1767 if test X"$1" = X"OFPPR_DELETE"; then shift;
1768 echo >>expout "OFPT_PORT_STATUS: DEL: 1(test): addr:aa:55:aa:55:00:0x
1769 config: PORT_DOWN
9e1fd49b 1770 state: LINK_DOWN
d02a5f8e 1771 speed: 0 Mbps now, 0 Mbps max"
80d5aefd
BP
1772 fi
1773
1774 # OFPT_FLOW_REMOVED, OFPRR_DELETE
1775 ovs-ofctl add-flow br0 send_flow_rem,actions=drop
1776 ovs-ofctl --strict del-flows br0 ''
1777 if test X"$1" = X"OFPRR_DELETE"; then shift;
1778 echo >>expout "OFPT_FLOW_REMOVED: reason=delete"
1779 fi
1780 AT_FAIL_IF([test X"$1" != X])
1781
1782 ovs-appctl -t ovs-ofctl ofctl/barrier
fd0aa9ea 1783 echo >>expout "OFPT_BARRIER_REPLY:"
80d5aefd
BP
1784
1785 AT_CHECK(
1786 [[sed '
1787s/ (xid=0x[0-9a-fA-F]*)//
1788s/ *duration.*//
1789s/00:0.$/00:0x/' < monitor.log]],
1790 [0], [expout])
1791}
1792
1793# It's a service connection so initially there should be no async messages.
1794check_async 1
1795
99811d07 1796# Set miss_send_len to 128, turning on packet-ins for our service connection.
80d5aefd
BP
1797ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
1798check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1799
1800# Set miss_send_len to 128 and enable invalid_ttl.
1801ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700040080
1802check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1803
1804# Become slave, which should disable everything except port status.
1805ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000002
1806check_async 4 OFPPR_ADD OFPPR_DELETE
1807
1808# Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
1809ovs-appctl -t ovs-ofctl ofctl/send 01040028000000020000232000000013000000020000000500000005000000020000000200000005
1810check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1811
a7349929
BP
1812# Set controller ID 123.
1813ovs-appctl -t ovs-ofctl ofctl/send 01040018000000030000232000000014000000000000007b
1814check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1815
1816# Restore controller ID 0.
1817ovs-appctl -t ovs-ofctl ofctl/send 010400180000000300002320000000140000000000000000
1818
80d5aefd
BP
1819# Become master.
1820ovs-appctl -t ovs-ofctl ofctl/send 0104001400000002000023200000000a00000001
a7349929 1821check_async 7 OFPR_ACTION OFPPR_ADD
80d5aefd
BP
1822
1823ovs-appctl -t ovs-ofctl exit
94c33672 1824OVS_VSWITCHD_STOP
80d5aefd 1825AT_CLEANUP
751c7785 1826
9dcd1c00
SH
1827AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.2)])
1828OVS_VSWITCHD_START
1829AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
1830check_async () {
1831 printf '\n\n--- check_async %d ---\n\n\n' $1
1832 INDEX=$1
1833 shift
1834
1835 ovs-appctl -t ovs-ofctl ofctl/barrier
1836 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1837 : > expout
1838
1839 # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1840 ovs-ofctl -O OpenFlow12 -v packet-out br0 none controller '0001020304050010203040501234'
1841 if test X"$1" = X"OFPR_ACTION"; then shift;
1842 echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
78c9486d 1843in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
9dcd1c00
SH
1844 fi
1845
1846 # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1847 ovs-ofctl -O OpenFlow12 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1848 if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1849 echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
78c9486d 1850in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
9dcd1c00
SH
1851 fi
1852
1853 # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1854 ovs-ofctl -O OpenFlow12 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1855 if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1856 echo >>expout "OFPT_PACKET_IN (OF1.2): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
78c9486d 1857udp,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"
9dcd1c00
SH
1858 fi
1859
1860 # OFPT_PORT_STATUS, OFPPR_ADD
1861 ovs-vsctl add-port br0 test -- set Interface test type=dummy
1862 if test X"$1" = X"OFPPR_ADD"; then shift;
1863 echo >>expout "OFPT_PORT_STATUS (OF1.2): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1864 config: PORT_DOWN
1865 state: LINK_DOWN
1866 speed: 0 Mbps now, 0 Mbps max"
1867 fi
1868
1869 # OFPT_PORT_STATUS, OFPPR_DELETE
1870 ovs-vsctl del-port br0 test
1871 if test X"$1" = X"OFPPR_DELETE"; then shift;
1872 echo >>expout "OFPT_PORT_STATUS (OF1.2): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1873 config: PORT_DOWN
1874 state: LINK_DOWN
1875 speed: 0 Mbps now, 0 Mbps max"
1876 fi
1877
1878 # OFPT_FLOW_REMOVED, OFPRR_DELETE
1879 ovs-ofctl -O OpenFlow12 add-flow br0 send_flow_rem,actions=drop
1880 ovs-ofctl -O OpenFlow12 --strict del-flows br0 ''
1881 if test X"$1" = X"OFPRR_DELETE"; then shift;
1882 echo >>expout "OFPT_FLOW_REMOVED (OF1.2): reason=delete table_id=0"
1883 fi
1884 AT_FAIL_IF([test X"$1" != X])
1885
1886 ovs-appctl -t ovs-ofctl ofctl/barrier
1887 echo >>expout "OFPT_BARRIER_REPLY (OF1.2):"
1888
1889 AT_CHECK(
1890 [[sed '
1891s/ (xid=0x[0-9a-fA-F]*)//
1892s/ *duration.*//
1893s/00:0.$/00:0x/' < monitor.log]],
1894 [0], [expout])
1895}
1896
1897# It's a service connection so initially there should be no async messages.
1898check_async 1
1899
1900# Set miss_send_len to 128, turning on packet-ins for our service connection.
1901ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
1902check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1903
1904# Set miss_send_len to 128 and enable invalid_ttl.
1905ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700040080
1906check_async 3 OFPR_ACTION OFPR_INVALID_TTL OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
1907
6ea4776b
JR
1908# Become slave (OF 1.2), which should disable everything except port status.
1909ovs-appctl -t ovs-ofctl ofctl/send 031800180000000200000003000000000000000000000001
9dcd1c00
SH
1910check_async 4 OFPPR_ADD OFPPR_DELETE
1911
1912# Use NXT_SET_ASYNC_CONFIG to enable a patchwork of asynchronous messages.
1913ovs-appctl -t ovs-ofctl ofctl/send 03040028000000020000232000000013000000020000000500000005000000020000000200000005
1914check_async 5 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
1915
1916# Set controller ID 123.
1917ovs-appctl -t ovs-ofctl ofctl/send 03040018000000030000232000000014000000000000007b
1918check_async 6 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
1919
1920# Restore controller ID 0.
1921ovs-appctl -t ovs-ofctl ofctl/send 030400180000000300002320000000140000000000000000
1922
6ea4776b
JR
1923# Become master (OF 1.2).
1924ovs-appctl -t ovs-ofctl ofctl/send 031800180000000400000002000000000000000000000002
9dcd1c00
SH
1925check_async 7 OFPR_ACTION OFPPR_ADD
1926
1927ovs-appctl -t ovs-ofctl exit
1928OVS_VSWITCHD_STOP
1929AT_CLEANUP
1930
b21eb1da
JR
1931AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.3)])
1932OVS_VSWITCHD_START
1933AT_CHECK([ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile])
1934check_async () {
1935 printf '\n\n--- check_async %d ---\n\n\n' $1
1936 INDEX=$1
1937 shift
1938
1939 ovs-appctl -t ovs-ofctl ofctl/barrier
1940 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
1941 : > expout
1942
1943 # OFPT_PACKET_IN, OFPR_ACTION (controller_id=0)
1944 ovs-ofctl -O OpenFlow13 -v packet-out br0 none controller '0001020304050010203040501234'
1945 if test X"$1" = X"OFPR_ACTION"; then shift;
1946 echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
78c9486d 1947in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
b21eb1da
JR
1948 fi
1949
1950 # OFPT_PACKET_IN, OFPR_NO_MATCH (controller_id=123)
1951 ovs-ofctl -O OpenFlow13 -v packet-out br0 none 'controller(reason=no_match,id=123)' '0001020304050010203040501234'
1952 if test X"$1" = X"OFPR_NO_MATCH"; then shift;
1953 echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY (via no_match) data_len=14 (unbuffered)
78c9486d 1954in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234"
b21eb1da
JR
1955 fi
1956
1957 # OFPT_PACKET_IN, OFPR_INVALID_TTL (controller_id=0)
1958 ovs-ofctl -O OpenFlow13 packet-out br0 none dec_ttl '002583dfb4000026b98cb0f908004500003fb7e200000011339bac11370dac100002d7730035002b8f6d86fb0100000100000000000006626c702d7873066e696369726103636f6d00000f00'
1959 if test X"$1" = X"OFPR_INVALID_TTL"; then shift;
1960 echo >>expout "OFPT_PACKET_IN (OF1.3): total_len=76 in_port=ANY (via invalid_ttl) data_len=76 (unbuffered)
78c9486d 1961udp,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"
b21eb1da
JR
1962 fi
1963
1964 # OFPT_PORT_STATUS, OFPPR_ADD
1965 ovs-vsctl add-port br0 test -- set Interface test type=dummy
1966 if test X"$1" = X"OFPPR_ADD"; then shift;
1967 echo >>expout "OFPT_PORT_STATUS (OF1.3): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1968 config: PORT_DOWN
1969 state: LINK_DOWN
1970 speed: 0 Mbps now, 0 Mbps max"
1971 fi
1972
1973 # OFPT_PORT_STATUS, OFPPR_DELETE
1974 ovs-vsctl del-port br0 test
1975 if test X"$1" = X"OFPPR_DELETE"; then shift;
1976 echo >>expout "OFPT_PORT_STATUS (OF1.3): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
1977 config: PORT_DOWN
1978 state: LINK_DOWN
1979 speed: 0 Mbps now, 0 Mbps max"
1980 fi
1981
1982 # OFPT_FLOW_REMOVED, OFPRR_DELETE
1983 ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=drop
1984 ovs-ofctl -O OpenFlow13 --strict del-flows br0 ''
1985 if test X"$1" = X"OFPRR_DELETE"; then shift;
1986 echo >>expout "OFPT_FLOW_REMOVED (OF1.3): reason=delete table_id=0"
1987 fi
cc40d06b
SH
1988
1989 # OFPT_FLOW_REMOVED, OFPRR_GROUP_DELETE
1990 ovs-ofctl -O OpenFlow13 add-group br0 group_id=1234,type=all,bucket=output:10
1991 ovs-ofctl -O OpenFlow13 add-flow br0 send_flow_rem,actions=group:1234
1992 ovs-ofctl -O OpenFlow13 --strict del-groups br0 group_id=1234
1993 if test X"$1" = X"OFPRR_DELETE"; then shift;
1994 echo >>expout "OFPT_FLOW_REMOVED (OF1.3): reason=gropu_delete table_id=0"
1995 fi
1996
b21eb1da
JR
1997 AT_FAIL_IF([test X"$1" != X])
1998
1999 ovs-appctl -t ovs-ofctl ofctl/barrier
2000 echo >>expout "OFPT_BARRIER_REPLY (OF1.3):"
2001
2002 AT_CHECK(
2003 [[sed '
2004s/ (xid=0x[0-9a-fA-F]*)//
2005s/ *duration.*//
2006s/00:0.$/00:0x/' < monitor.log]],
2007 [0], [expout])
2008}
2009
2010# It's a service connection so initially there should be no async messages.
2011check_async 1
2012
2013# Set miss_send_len to 128, turning on packet-ins for our service connection.
2014ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
2015check_async 2 OFPR_ACTION OFPPR_ADD OFPPR_DELETE OFPRR_DELETE
2016
2017# Become slave (OF 1.3), which should disable everything except port status.
2018ovs-appctl -t ovs-ofctl ofctl/send 041800180000000200000003000000000000000000000001
2019check_async 3 OFPPR_ADD OFPPR_DELETE
2020
2021# Use OF 1.3 OFPT_SET_ASYNC to enable a patchwork of asynchronous messages.
2022ovs-appctl -t ovs-ofctl ofctl/send 041c002000000002000000020000000500000005000000020000000200000005
2023check_async 4 OFPR_INVALID_TTL OFPPR_DELETE OFPRR_DELETE
2024
2025# Set controller ID 123.
2026ovs-appctl -t ovs-ofctl ofctl/send 04040018000000030000232000000014000000000000007b
2027check_async 5 OFPR_NO_MATCH OFPPR_DELETE OFPRR_DELETE
2028
2029# Restore controller ID 0.
2030ovs-appctl -t ovs-ofctl ofctl/send 040400180000000300002320000000140000000000000000
2031
2032# Become master (OF 1.3).
2033ovs-appctl -t ovs-ofctl ofctl/send 041800180000000400000002000000000000000000000002
2034check_async 6 OFPR_ACTION OFPPR_ADD
2035
2036ovs-appctl -t ovs-ofctl exit
2037OVS_VSWITCHD_STOP
2038AT_CLEANUP
2039
ebeae5db
JT
2040AT_SETUP([ofproto - asynchronous message control (OpenFlow 1.5)])
2041OVS_VSWITCHD_START
2042AT_CHECK([ovs-ofctl -O OpenFlow15 monitor br0 --detach --no-chdir --pidfile])
2043check_async () {
2044 printf '\n\n--- check_async %d ---\n\n\n' $1
2045 INDEX=$1
2046 shift
2047
2048 ovs-appctl -t ovs-ofctl ofctl/barrier
2049 ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2050 : > expout
2051
2052 # Other tests are not working with OF 1.5, and message
2053 # format may change, so leave them out.
2054
2055 # OFPT_PORT_STATUS, OFPPR_ADD
2056 ovs-vsctl add-port br0 test -- set Interface test type=dummy
2057 if test X"$1" = X"OFPPR_ADD"; then shift;
2058 echo >>expout "OFPT_PORT_STATUS (OF1.5): ADD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2059 config: PORT_DOWN
2060 state: LINK_DOWN
2061 speed: 0 Mbps now, 0 Mbps max"
2062 fi
2063
2064 # OFPT_PORT_STATUS, OFPPR_MODIFY
2065 ovs-ofctl -O OpenFlow15 -vwarn mod-port br0 test up
2066 if test X"$1" = X"OFPPR_MODIFY"; then shift;
2067 echo >>expout "OFPT_PORT_STATUS (OF1.5): MOD: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2068 config: 0
2069 state: LINK_DOWN
2070 speed: 0 Mbps now, 0 Mbps max
2071OFPT_PORT_STATUS (OF1.5): MOD: 2(test): addr:aa:55:aa:55:00:0x
2072 config: 0
2073 state: 0
2074 speed: 0 Mbps now, 0 Mbps max"
2075 fi
2076
2077 # OFPT_PORT_STATUS, OFPPR_DELETE
2078 ovs-vsctl del-port br0 test
2079 if test X"$1" = X"OFPPR_DELETE"; then shift;
2080 echo >>expout "OFPT_PORT_STATUS (OF1.5): DEL: ${INDEX}(test): addr:aa:55:aa:55:00:0x
2081 config: 0
2082 state: 0
2083 speed: 0 Mbps now, 0 Mbps max"
2084 fi
2085
2086 AT_FAIL_IF([test X"$1" != X])
2087
2088 ovs-appctl -t ovs-ofctl ofctl/barrier
2089 echo >>expout "OFPT_BARRIER_REPLY (OF1.5):"
2090
2091 AT_CHECK(
2092 [[sed '
2093s/ (xid=0x[0-9a-fA-F]*)//
2094s/ *duration.*//
2095s/00:0.$/00:0x/' < monitor.log]],
2096 [0], [expout])
2097}
2098
2099# It's a service connection so initially there should be no async messages.
2100check_async 1
2101
2102# If we don't set this, async messages are not received.
2103# Set miss_send_len to 128, turning on packet-ins for our service connection.
2104ovs-appctl -t ovs-ofctl ofctl/send 0609000c0123456700000080
2105check_async 2 OFPPR_ADD OFPPR_MODIFY OFPPR_DELETE
2106
2107# Set-async has changed in OF 1.4 and is not yet implemented.
2108
2109ovs-appctl -t ovs-ofctl exit
2110OVS_VSWITCHD_STOP
2111AT_CLEANUP
2112
6ea4776b
JR
2113dnl This test checks that the role request/response messaging works
2114dnl and that generation_id is handled properly.
2115AT_SETUP([ofproto - controller role (OpenFlow 1.2)])
2116OVS_VSWITCHD_START
6751a4b4
BP
2117ON_EXIT([kill `cat c1.pid c2.pid`])
2118
2119# Start two ovs-ofctl controller processes.
2120AT_CAPTURE_FILE([monitor1.log])
2121AT_CAPTURE_FILE([expout1])
2122AT_CAPTURE_FILE([experr1])
2123AT_CAPTURE_FILE([monitor2.log])
2124AT_CAPTURE_FILE([expout2])
2125AT_CAPTURE_FILE([experr2])
2126for i in 1 2; do
2127 AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile=`pwd`/c$i.pid --unixctl=`pwd`/c$i])
2128 ovs-appctl -t `pwd`/c$i ofctl/barrier
2129 ovs-appctl -t `pwd`/c$i ofctl/set-output-file monitor$i.log
2130 : > expout$i
2131 : > experr$i
2132
2133 # find out current role
2134 ovs-appctl -t `pwd`/c$i ofctl/send 031800180000000200000000000000000000000000000000
2135 echo >>experr$i "send: OFPT_ROLE_REQUEST (OF1.2): role=nochange"
2136 echo >>expout$i "OFPT_ROLE_REPLY (OF1.2): role=equal"
2137done
6ea4776b 2138
6751a4b4
BP
2139# controller 1: Become slave (generation_id is initially undefined, so
2140# 2^63+2 should not be stale)
2141ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000300000003000000008000000000000002
2142echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=slave generation_id=9223372036854775810"
2143echo >>expout1 "OFPT_ROLE_REPLY (OF1.2): role=slave generation_id=9223372036854775810"
2144
2145# controller 2: Become master.
2146ovs-appctl -t `pwd`/c2 ofctl/send 031800180000000300000002000000008000000000000003
2147echo >>experr2 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=9223372036854775811"
2148echo >>expout2 "OFPT_ROLE_REPLY (OF1.2): role=master generation_id=9223372036854775811"
2149
2150# controller 1: Try to become the master using a stale generation ID
2151ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000400000002000000000000000000000003
2152echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=3"
2153echo >>expout1 "OFPT_ERROR (OF1.2): OFPRRFC_STALE"
2154echo >>expout1 "OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=3"
2155
2156# controller 1: Become master using a valid generation ID
2157ovs-appctl -t `pwd`/c1 ofctl/send 031800180000000500000002000000000000000000000001
2158echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.2): role=master generation_id=1"
2159echo >>expout1 "OFPT_ROLE_REPLY (OF1.2): role=master generation_id=1"
2160
2161for i in 1 2; do
2162 ovs-appctl -t `pwd`/c$i ofctl/barrier
2163 echo >>expout$i "OFPT_BARRIER_REPLY (OF1.2):"
2164done
6ea4776b 2165
6751a4b4
BP
2166# Check output.
2167for i in 1 2; do
2168 cp expout$i expout
2169 AT_CHECK([grep -v '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
2170 cp experr$i expout
2171 AT_CHECK([grep '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
2172done
2173OVS_VSWITCHD_STOP
2174AT_CLEANUP
6ea4776b 2175
6751a4b4
BP
2176dnl This test checks that the role request/response messaging works,
2177dnl that generation_id is handled properly, and that role status update
2178dnl messages are sent when a controller's role gets changed from master
2179dnl to slave.
2180AT_SETUP([ofproto - controller role (OpenFlow 1.4)])
2181OVS_VSWITCHD_START
2182ON_EXIT([kill `cat c1.pid c2.pid`])
2183
2184# Start two ovs-ofctl controller processes.
2185AT_CAPTURE_FILE([monitor1.log])
2186AT_CAPTURE_FILE([expout1])
2187AT_CAPTURE_FILE([experr1])
2188AT_CAPTURE_FILE([monitor2.log])
2189AT_CAPTURE_FILE([expout2])
2190AT_CAPTURE_FILE([experr2])
2191for i in 1 2; do
2192 AT_CHECK([ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile=`pwd`/c$i.pid --unixctl=`pwd`/c$i])
2193 ovs-appctl -t `pwd`/c$i ofctl/barrier
2194 ovs-appctl -t `pwd`/c$i ofctl/set-output-file monitor$i.log
2195 : > expout$i
2196 : > experr$i
2197
2198 # find out current role
2199 ovs-appctl -t `pwd`/c$i ofctl/send 051800180000000200000000000000000000000000000000
2200 echo >>experr$i "send: OFPT_ROLE_REQUEST (OF1.4): role=nochange"
2201 echo >>expout$i "OFPT_ROLE_REPLY (OF1.4): role=equal"
2202done
6ea4776b 2203
6751a4b4
BP
2204# controller 1: Become slave (generation_id is initially undefined, so
2205# 2^63+2 should not be stale)
2206ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000300000003000000008000000000000002
2207echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=slave generation_id=9223372036854775810"
2208echo >>expout1 "OFPT_ROLE_REPLY (OF1.4): role=slave generation_id=9223372036854775810"
2209
2210# controller 2: Become master.
2211ovs-appctl -t `pwd`/c2 ofctl/send 051800180000000300000002000000008000000000000003
2212echo >>experr2 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=9223372036854775811"
2213echo >>expout2 "OFPT_ROLE_REPLY (OF1.4): role=master generation_id=9223372036854775811"
2214
2215# controller 1: Try to become the master using a stale generation ID
2216ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000400000002000000000000000000000003
2217echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=3"
2218echo >>expout1 "OFPT_ERROR (OF1.4): OFPRRFC_STALE"
2219echo >>expout1 "OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=3"
2220
2221# controller 1: Become master using a valid generation ID
2222ovs-appctl -t `pwd`/c1 ofctl/send 051800180000000500000002000000000000000000000001
2223echo >>experr1 "send: OFPT_ROLE_REQUEST (OF1.4): role=master generation_id=1"
2224echo >>expout1 "OFPT_ROLE_REPLY (OF1.4): role=master generation_id=1"
2225echo >>expout2 "OFPT_ROLE_STATUS (OF1.4): role=slave generation_id=1 reason=master_request"
2226
2227for i in 1 2; do
2228 ovs-appctl -t `pwd`/c$i ofctl/barrier
2229 echo >>expout$i "OFPT_BARRIER_REPLY (OF1.4):"
2230done
6ea4776b 2231
6751a4b4
BP
2232# Check output.
2233for i in 1 2; do
2234 cp expout$i expout
2235 AT_CHECK([grep -v '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
2236 cp experr$i expout
2237 AT_CHECK([grep '^send:' monitor$i.log | STRIP_XIDS], [0], [expout])
2238done
6ea4776b
JR
2239OVS_VSWITCHD_STOP
2240AT_CLEANUP
2241
751c7785
BP
2242dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
2243dnl specified by OpenFlow 1.0) and OFPP_CONTROLLER (used by some
2244dnl controllers despite the spec) as meaning a packet that was generated
2245dnl by the controller.
9dcd1c00 2246AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.0)])
751c7785 2247OVS_VSWITCHD_START
586ddea5 2248ADD_OF_PORTS([br0], [1])
751c7785
BP
2249
2250# Start a monitor listening for packet-ins.
2251AT_CHECK([ovs-ofctl -P openflow10 monitor br0 --detach --no-chdir --pidfile])
2252ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
2253ovs-appctl -t ovs-ofctl ofctl/barrier
2254ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2255AT_CAPTURE_FILE([monitor.log])
2256
2257# Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
586ddea5
BP
2258AT_CHECK([ovs-ofctl packet-out br0 none controller,1 '0001020304050010203040501234'])
2259AT_CHECK([ovs-ofctl packet-out br0 controller controller,1 '0001020304050010203040505678'])
751c7785
BP
2260
2261# Stop the monitor and check its output.
2262ovs-appctl -t ovs-ofctl ofctl/barrier
2263ovs-appctl -t ovs-ofctl exit
2264
586ddea5
BP
2265ovs-ofctl dump-ports br0
2266
751c7785 2267AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
7f05e7ab 2268OFPT_PACKET_IN: total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
78c9486d 2269in_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 2270OFPT_PACKET_IN: total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
78c9486d 2271in_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
2272OFPT_BARRIER_REPLY:
2273])
2274
2275OVS_VSWITCHD_STOP
2276AT_CLEANUP
2277
9dcd1c00
SH
2278dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
2279dnl specified by OpenFlow 1.2) and OFPP_CONTROLLER (used by some
2280dnl controllers despite the spec) as meaning a packet that was generated
2281dnl by the controller.
2282AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.2)])
2283OVS_VSWITCHD_START
2284
2285# Start a monitor listening for packet-ins.
2286AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
2287ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
2288ovs-appctl -t ovs-ofctl ofctl/barrier
2289ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2290AT_CAPTURE_FILE([monitor.log])
2291
2292# Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
2293AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none controller '0001020304050010203040501234'])
2294AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 4294967293 controller '0001020304050010203040505678'])
2295
2296# Stop the monitor and check its output.
2297ovs-appctl -t ovs-ofctl ofctl/barrier
2298ovs-appctl -t ovs-ofctl exit
2299
2300AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2301OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
78c9486d 2302in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
9dcd1c00 2303OFPT_PACKET_IN (OF1.2): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
78c9486d 2304in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
9dcd1c00
SH
2305OFPT_BARRIER_REPLY (OF1.2):
2306])
2307
2308OVS_VSWITCHD_STOP
2309AT_CLEANUP
2310
4d197ebb
BP
2311dnl This test checks that OFPT_PACKET_OUT accepts both OFPP_NONE (as
2312dnl specified by OpenFlow 1.1) and OFPP_CONTROLLER (used by some
2313dnl controllers despite the spec) as meaning a packet that was generated
2314dnl by the controller.
2315AT_SETUP([ofproto - packet-out from controller (OpenFlow 1.1)])
2316OVS_VSWITCHD_START
2317
2318# Start a monitor listening for packet-ins.
2319AT_CHECK([ovs-ofctl -O OpenFlow11 monitor br0 --detach --no-chdir --pidfile])
2320ovs-appctl -t ovs-ofctl ofctl/send 0209000c0123456700000080
2321ovs-appctl -t ovs-ofctl ofctl/barrier
2322ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2323AT_CAPTURE_FILE([monitor.log])
2324
2325# Send some packet-outs with OFPP_NONE and OFPP_CONTROLLER (65533) as in_port.
2326AT_CHECK([ovs-ofctl -O OpenFlow11 packet-out br0 none controller '0001020304050010203040501234'])
2327AT_CHECK([ovs-ofctl -O OpenFlow11 packet-out br0 4294967293 controller '0001020304050010203040505678'])
2328
2329# Stop the monitor and check its output.
2330ovs-appctl -t ovs-ofctl ofctl/barrier
2331ovs-appctl -t ovs-ofctl exit
2332
2333AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2334OFPT_PACKET_IN (OF1.1): total_len=14 in_port=ANY (via action) data_len=14 (unbuffered)
78c9486d 2335in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
4d197ebb 2336OFPT_PACKET_IN (OF1.1): total_len=14 in_port=CONTROLLER (via action) data_len=14 (unbuffered)
78c9486d 2337in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x5678
4d197ebb
BP
2338OFPT_BARRIER_REPLY (OF1.1):
2339])
2340
2341OVS_VSWITCHD_STOP
2342AT_CLEANUP
2343
969fc56c
JS
2344dnl This test checks that metadata is encoded in packet_in structures,
2345dnl supported by NXAST.
2346AT_SETUP([ofproto - packet-out with metadata (NXM)])
2347OVS_VSWITCHD_START
2348
2349# Start a monitor listening for packet-ins.
2350AT_CHECK([ovs-ofctl -P nxm monitor br0 --detach --no-chdir --pidfile])
2351ovs-appctl -t ovs-ofctl ofctl/send 0109000c0123456700000080
2352ovs-appctl -t ovs-ofctl ofctl/barrier
2353ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2354AT_CAPTURE_FILE([monitor.log])
2355
2356# Send a packet-out with a load action to set some metadata, and forward to controller
ac923e91 2357AT_CHECK([ovs-ofctl packet-out br0 controller 'load(0xfafafafa5a5a5a5a->OXM_OF_METADATA[[0..63]]), load(0xaa->NXM_NX_PKT_MARK[[]]), controller' '0001020304050010203040501234'])
969fc56c
JS
2358
2359# Stop the monitor and check its output.
2360ovs-appctl -t ovs-ofctl ofctl/barrier
2361ovs-appctl -t ovs-ofctl exit
2362
2363AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
ac923e91 2364NXT_PACKET_IN: total_len=14 in_port=CONTROLLER metadata=0xfafafafa5a5a5a5a pkt_mark=0xaa (via action) data_len=14 (unbuffered)
78c9486d 2365in_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
2366OFPT_BARRIER_REPLY:
2367])
2368
2369OVS_VSWITCHD_STOP
2370AT_CLEANUP
2b07c8b1 2371
9dcd1c00
SH
2372dnl This test checks that metadata is encoded in packet_in structures,
2373dnl supported by NXAST.
2374AT_SETUP([ofproto - packet-out with metadata (OpenFlow 1.2)])
2375OVS_VSWITCHD_START
2376
2377# Start a monitor listening for packet-ins.
2378AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
2379ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
2380ovs-appctl -t ovs-ofctl ofctl/barrier
2381ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2382AT_CAPTURE_FILE([monitor.log])
2383
277876e9
JT
2384# Send a packet-out with a set-field action to set some metadata, and forward to controller
2385AT_CHECK([ovs-ofctl -O OpenFlow12 packet-out br0 none 'set_field:0xfafafafa5a5a5a5a->metadata, controller' '0001020304050010203040501234'])
9dcd1c00
SH
2386
2387# Stop the monitor and check its output.
2388ovs-appctl -t ovs-ofctl ofctl/barrier
2389ovs-appctl -t ovs-ofctl exit
2390
2391AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2392OFPT_PACKET_IN (OF1.2): total_len=14 in_port=ANY metadata=0xfafafafa5a5a5a5a (via action) data_len=14 (unbuffered)
78c9486d 2393in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
0ad90c84
JR
2394OFPT_BARRIER_REPLY (OF1.2):
2395])
2396
2397OVS_VSWITCHD_STOP
2398AT_CLEANUP
2399
743c159b
JT
2400dnl This test checks that metadata is encoded in packet_in structures,
2401dnl supported by NXAST.
2402AT_SETUP([ofproto - packet-out with metadata and dual set_field (OpenFlow 1.3)])
2403OVS_VSWITCHD_START
2404
2405# Start a monitor listening for packet-ins.
2406AT_CHECK([ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile])
2407ovs-appctl -t ovs-ofctl ofctl/send 0409000c0123456700000080
2408ovs-appctl -t ovs-ofctl ofctl/barrier
2409ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2410AT_CAPTURE_FILE([monitor.log])
2411
2412# Send a packet-out with a couple of set-field action to set some metadata, and forward to controller
2413AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 none 'set_field:0xfafafafa5a5a5a5a->metadata, set_field:0x6b->metadata, controller' '0001020304050010203040501234'])
2414
2415# Stop the monitor and check its output.
2416ovs-appctl -t ovs-ofctl ofctl/barrier
2417ovs-appctl -t ovs-ofctl exit
2418
2419AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2420OFPT_PACKET_IN (OF1.3): total_len=14 in_port=ANY metadata=0x6b (via action) data_len=14 (unbuffered)
2421in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
2422OFPT_BARRIER_REPLY (OF1.3):
2423])
2424
2425OVS_VSWITCHD_STOP
2426AT_CLEANUP
2427
0ad90c84
JR
2428dnl This test checks that tunnel metadata is encoded in packet_in structures.
2429AT_SETUP([ofproto - packet-out with tunnel metadata (OpenFlow 1.2)])
2430OVS_VSWITCHD_START
2431
2432# Start a monitor listening for packet-ins.
2433AT_CHECK([ovs-ofctl -O OpenFlow12 monitor br0 --detach --no-chdir --pidfile])
2434ovs-appctl -t ovs-ofctl ofctl/send 0309000c0123456700000080
2435ovs-appctl -t ovs-ofctl ofctl/barrier
2436ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2437AT_CAPTURE_FILE([monitor.log])
2438
2439# Send a packet-out with set field actions to set some tunnel metadata, and forward to controller
2440AT_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'])
2441
2442# Stop the monitor and check its output.
2443ovs-appctl -t ovs-ofctl ofctl/barrier
2444ovs-appctl -t ovs-ofctl exit
2445
2446AT_CHECK([sed 's/ (xid=0x[[0-9a-fA-F]]*)//' monitor.log], [0], [dnl
2447OFPT_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)
78c9486d 2448in_port=0,vlan_tci=0x0000,dl_src=00:10:20:30:40:50,dl_dst=00:01:02:03:04:05,dl_type=0x1234
9dcd1c00
SH
2449OFPT_BARRIER_REPLY (OF1.2):
2450])
2451
2452OVS_VSWITCHD_STOP
2453AT_CLEANUP
2454
1637ebb2
SH
2455m4_divert_push([PREPARE_TESTS])
2456# Sorts groups of lines that start with a space, without moving them
2457# past the nearest line that does not start with a space.
2458multiline_sort () {
2459 ${PERL} -e '
2460 use warnings;
2461 use strict;
2462 my @buffer = ();
2463 while (<STDIN>) {
2464 if (/^ /) {
2465 push(@buffer, $_);
2466 } else {
2467 print $_ foreach sort(@buffer);
2468 print $_;
2469 @buffer = ();
2470 }
2471 }
2472 print $_ foreach sort(@buffer);
2473'
2474}
2475m4_divert_pop([PREPARE_TESTS])
2476
2b07c8b1
BP
2477AT_SETUP([ofproto - flow monitoring])
2478AT_KEYWORDS([monitor])
2479OVS_VSWITCHD_START
2480
2481ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
2482
2483# Start a monitor watching the flow table and check the initial reply.
2484ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
2485AT_CAPTURE_FILE([monitor.log])
2486ovs-appctl -t ovs-ofctl ofctl/barrier
2487AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
2488 [NXST_FLOW_MONITOR reply:
2489 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
2490OFPT_BARRIER_REPLY:
2491])
2492
2493# Add, delete, and modify some flows and check the updates.
2494ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2495ovs-ofctl add-flow br0 in_port=0,dl_vlan=124,actions=output:2
2496ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:5
95a1c4ca
SH
2497ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=0,actions=output:6
2498ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,dl_vlan_pcp=1,actions=output:7
2499ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:8
2500ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=0,actions=output:9
2501ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,dl_vlan_pcp=1,actions=output:10
2502ovs-ofctl add-flow br0 in_port=0,dl_vlan=65535,actions=output:11
2503ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=0,actions=output:12
2504ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,dl_vlan_pcp=1,actions=output:13
2505ovs-ofctl add-flow br0 in_port=0,dl_vlan=8191,actions=output:14
2506ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:15
2507ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:16
2508ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:17
2509ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=0,actions=output:18
2510ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,dl_vlan_pcp=1,actions=output:19
2511ovs-ofctl add-flow br0 in_port=0,dl_vlan=0,actions=output:20
2512ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=0,actions=output:21
2513ovs-ofctl add-flow br0 in_port=0,dl_vlan_pcp=1,actions=output:22
2514ovs-ofctl add-flow br0 in_port=0,actions=output:23
ee088a75 2515ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:3
2b07c8b1
BP
2516ovs-ofctl mod-flows br0 cookie=5,dl_vlan=123,actions=output:3
2517ovs-ofctl del-flows br0 dl_vlan=123
2518ovs-ofctl del-flows br0
2519ovs-appctl -t ovs-ofctl ofctl/barrier
1637ebb2 2520AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | multiline_sort], [0],
2b07c8b1
BP
2521[NXST_FLOW_MONITOR reply (xid=0x0):
2522 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
2523NXST_FLOW_MONITOR reply (xid=0x0):
2524 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:5
95a1c4ca
SH
2525NXST_FLOW_MONITOR reply (xid=0x0):
2526 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:6
2527NXST_FLOW_MONITOR reply (xid=0x0):
2528 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:7
2529NXST_FLOW_MONITOR reply (xid=0x0):
2530 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:8
2531NXST_FLOW_MONITOR reply (xid=0x0):
2532 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:9
2533NXST_FLOW_MONITOR reply (xid=0x0):
2534 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:10
2535NXST_FLOW_MONITOR reply (xid=0x0):
2536 event=ADDED table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
2537NXST_FLOW_MONITOR reply (xid=0x0):
2538 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
2539NXST_FLOW_MONITOR reply (xid=0x0):
2540 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
2541NXST_FLOW_MONITOR reply (xid=0x0):
2542 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
2543NXST_FLOW_MONITOR reply (xid=0x0):
2544 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:15
2545NXST_FLOW_MONITOR reply (xid=0x0):
2546 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:16
2547NXST_FLOW_MONITOR reply (xid=0x0):
2548 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:17
2549NXST_FLOW_MONITOR reply (xid=0x0):
2550 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
2551NXST_FLOW_MONITOR reply (xid=0x0):
2552 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
2553NXST_FLOW_MONITOR reply (xid=0x0):
2554 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
2555NXST_FLOW_MONITOR reply (xid=0x0):
2556 event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
2557NXST_FLOW_MONITOR reply (xid=0x0):
2558 event=ADDED table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
2559NXST_FLOW_MONITOR reply (xid=0x0):
2560 event=ADDED table=0 cookie=0 in_port=0 actions=output:23
ee088a75
SH
2561NXST_FLOW_MONITOR reply (xid=0x0):
2562 event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:3
2563 event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
2564 event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
2b07c8b1
BP
2565NXST_FLOW_MONITOR reply (xid=0x0):
2566 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
95a1c4ca
SH
2567 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
2568 event=MODIFIED table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
2b07c8b1
BP
2569NXST_FLOW_MONITOR reply (xid=0x0):
2570 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123 actions=output:3
95a1c4ca
SH
2571 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=0 actions=output:3
2572 event=DELETED reason=delete table=0 cookie=0x5 in_port=0,dl_vlan=123,dl_vlan_pcp=1 actions=output:3
2b07c8b1 2573NXST_FLOW_MONITOR reply (xid=0x0):
32cd83a2 2574 event=DELETED reason=delete table=0 cookie=0 in_port=0 actions=output:23
95a1c4ca 2575 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0 actions=output:20
32cd83a2
BP
2576 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=0 actions=output:18
2577 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=0,dl_vlan_pcp=1 actions=output:19
2b07c8b1 2578 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=124 actions=output:2
95a1c4ca 2579 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095 actions=output:14
32cd83a2 2580 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=0 actions=output:12
95a1c4ca 2581 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan=4095,dl_vlan_pcp=1 actions=output:13
32cd83a2
BP
2582 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=0 actions=output:21
2583 event=DELETED reason=delete table=0 cookie=0 in_port=0,dl_vlan_pcp=1 actions=output:22
95a1c4ca 2584 event=DELETED reason=delete table=0 cookie=0 in_port=0,vlan_tci=0x0000 actions=output:11
2b07c8b1
BP
2585OFPT_BARRIER_REPLY:
2586])
2587
200d6ac4
SH
2588# Check that our own changes are reported as full updates.
2589ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2590ovs-ofctl add-flow br0 in_port=1,actions=output:2
2591ovs-ofctl add-flow br0 in_port=2,actions=output:1
2592ovs-appctl -t ovs-ofctl ofctl/barrier
2593ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
2594ovs-appctl -t ovs-ofctl ofctl/barrier
2595AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
2596])
2597AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log | multiline_sort], [0],
2598[NXST_FLOW_MONITOR reply (xid=0x0):
2599 event=ADDED table=0 cookie=0 in_port=1 actions=output:2
2600NXST_FLOW_MONITOR reply (xid=0x0):
2601 event=ADDED table=0 cookie=0 in_port=2 actions=output:1
2602OFPT_BARRIER_REPLY:
2603send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
2604NXST_FLOW_MONITOR reply (xid=0x0):
2605 event=DELETED reason=delete table=0 cookie=0 in_port=1 actions=output:2
2606 event=DELETED reason=delete table=0 cookie=0 in_port=2 actions=output:1
2607OFPT_BARRIER_REPLY:
2608])
2609
2610ovs-appctl -t ovs-ofctl exit
2611OVS_VSWITCHD_STOP
2612AT_CLEANUP
2613
2614AT_SETUP([ofproto - flow monitoring with !own])
2615AT_KEYWORDS([monitor])
2616OVS_VSWITCHD_START
2617
2618ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:1
2619
2620# Start a monitor watching the flow table and check the initial reply.
2621ovs-ofctl monitor br0 watch:\!own --detach --no-chdir --pidfile >monitor.log 2>&1
2622AT_CAPTURE_FILE([monitor.log])
2623ovs-appctl -t ovs-ofctl ofctl/barrier
2624AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
2625 [NXST_FLOW_MONITOR reply:
2626 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1
2627OFPT_BARRIER_REPLY:
2628])
2629
2b07c8b1
BP
2630# Check that our own changes are reported as abbreviations.
2631ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2632ovs-ofctl add-flow br0 in_port=1,actions=output:2
2633ovs-ofctl add-flow br0 in_port=2,actions=output:1
90d721f0 2634ovs-appctl -t ovs-ofctl ofctl/barrier
2b07c8b1
BP
2635ovs-appctl -t ovs-ofctl ofctl/send 010e004812345678003fffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000ffffffffffff0000
2636ovs-appctl -t ovs-ofctl ofctl/barrier
2637AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip], [0], [NXST_FLOW reply:
2638])
2639AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
2640[NXST_FLOW_MONITOR reply (xid=0x0):
2641 event=ADDED table=0 cookie=0 in_port=1 actions=output:2
2642NXST_FLOW_MONITOR reply (xid=0x0):
2643 event=ADDED table=0 cookie=0 in_port=2 actions=output:1
90d721f0 2644OFPT_BARRIER_REPLY:
2b07c8b1
BP
2645send: OFPT_FLOW_MOD: DEL priority=0 actions=drop
2646NXST_FLOW_MONITOR reply (xid=0x0):
2647 event=ABBREV xid=0x12345678
cdbdeeda
SH
2648OFPT_BARRIER_REPLY:
2649])
2650
2651ovs-appctl -t ovs-ofctl exit
2652OVS_VSWITCHD_STOP
2653AT_CLEANUP
2654
2655AT_SETUP([ofproto - flow monitoring with out_port])
2656AT_KEYWORDS([monitor])
2657OVS_VSWITCHD_START
2658
2659ovs-ofctl add-flow br0 in_port=0,dl_vlan=121,actions=output:1
2660ovs-ofctl add-flow br0 in_port=0,dl_vlan=122,actions=output:1
2661ovs-ofctl add-flow br0 in_port=0,dl_vlan=123,actions=output:2
2662
2663# Start a monitor watching the flow table and check the initial reply.
2664ovs-ofctl monitor br0 watch:out_port=2 --detach --no-chdir --pidfile >monitor.log 2>&1
2665AT_CAPTURE_FILE([monitor.log])
2666ovs-appctl -t ovs-ofctl ofctl/barrier
2667AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
2668 [NXST_FLOW_MONITOR reply:
2669 event=ADDED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:2
2670OFPT_BARRIER_REPLY:
2671])
2672
2673ovs-appctl -t ovs-ofctl ofctl/set-output-file monitor.log
2674
2675# Add, modify flows and check the updates.
2676ovs-ofctl mod-flows br0 dl_vlan=121,actions=drop
2677ovs-ofctl mod-flows br0 dl_vlan=122,actions=output:1,output:2
2678ovs-appctl -t ovs-ofctl ofctl/barrier
2679
2680ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:1,output:2
2681ovs-appctl -t ovs-ofctl ofctl/barrier
2682
2683ovs-ofctl mod-flows br0 dl_vlan=122,actions=output:1
2684ovs-appctl -t ovs-ofctl ofctl/barrier
2685ovs-ofctl mod-flows br0 dl_vlan=123,actions=output:2
2686ovs-appctl -t ovs-ofctl ofctl/barrier
2687
2688AT_CHECK([sed 's/ (xid=0x[[1-9a-fA-F]][[0-9a-fA-F]]*)//' monitor.log], [0],
2689[NXST_FLOW_MONITOR reply (xid=0x0):
2690 event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=122 actions=output:1,output:2
2691OFPT_BARRIER_REPLY:
2692NXST_FLOW_MONITOR reply (xid=0x0):
2693 event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:1,output:2
2694OFPT_BARRIER_REPLY:
2695NXST_FLOW_MONITOR reply (xid=0x0):
2696 event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=122 actions=output:1
2697OFPT_BARRIER_REPLY:
2698NXST_FLOW_MONITOR reply (xid=0x0):
2699 event=MODIFIED table=0 cookie=0 in_port=0,dl_vlan=123 actions=output:2
2b07c8b1
BP
2700OFPT_BARRIER_REPLY:
2701])
2702
2703ovs-appctl -t ovs-ofctl exit
2704OVS_VSWITCHD_STOP
2705AT_CLEANUP
2706
2707AT_SETUP([ofproto - flow monitoring pause and resume])
2708AT_KEYWORDS([monitor])
2709
46a80050
EM
2710# The maximum socket receive buffer size is important for this test, which
2711# tests behavior when the receive buffer overflows.
2712if test -e /proc/sys/net/core/rmem_max; then
2713 # Linux
2714 rmem_max=`cat /proc/sys/net/core/rmem_max`
2715elif rmem_max=`sysctl -n net.inet.tcp.recvbuf_max 2>/dev/null`; then
f3326eeb 2716 : # FreeBSD, NetBSD
46a80050
EM
2717else
2718 # Don't know how to get maximum socket receive buffer on this OS
2719 AT_SKIP_IF([:])
2720fi
2b07c8b1
BP
2721# Calculate the total amount of queuing: rmem_max in the kernel, 128 kB
2722# in ofproto sending userspace (see ofmonitor_flush() in connmgr.c).
2b07c8b1
BP
2723queue_size=`expr $rmem_max + 128 \* 1024`
2724echo rmem_max=$rmem_max queue_size=$queue_size
2725
21aa35c3
BP
2726# If there's too much queuing skip the test to avoid timing out.
2727AT_SKIP_IF([test $rmem_max -gt 1048576])
2728
2b07c8b1
BP
2729# Each flow update message takes up at least 48 bytes of space in queues
2730# and in practice more than that.
2731n_msgs=`expr $queue_size / 48`
2732echo n_msgs=$n_msgs
2733
2734OVS_VSWITCHD_START
2735
2736# Start a monitor watching the flow table, then make it block.
0b7140bb 2737ON_EXIT([kill `cat ovs-ofctl.pid`])
2b07c8b1
BP
2738ovs-ofctl monitor br0 watch: --detach --no-chdir --pidfile >monitor.log 2>&1
2739AT_CAPTURE_FILE([monitor.log])
2740ovs-appctl -t ovs-ofctl ofctl/block
2741
2742# Add $n_msgs flows.
2743(echo "in_port=2,actions=output:2"
5c6d0628 2744${PERL} -e '
2b07c8b1
BP
2745 for ($i = 0; $i < '$n_msgs'; $i++) {
2746 print "cookie=1,reg1=$i,actions=drop\n";
2747 }
2748') > flows.txt
2749AT_CHECK([ovs-ofctl add-flows br0 flows.txt])
79b8c36c
BP
2750# Check that multipart flow dumps work properly:
2751AT_CHECK([ovs-ofctl diff-flows br0 flows.txt])
2b07c8b1
BP
2752AT_CHECK([ovs-ofctl add-flow br0 in_port=1,cookie=3,actions=drop])
2753AT_CHECK([ovs-ofctl mod-flows br0 in_port=2,cookie=2,actions=output:2])
2754AT_CHECK([ovs-ofctl del-flows br0 cookie=1/-1])
2755
2756ovs-appctl -t ovs-ofctl ofctl/unblock
c4821629
YT
2757
2758# Wait for the connection resumed.
2759# A barrier doesn't work for this purpose.
2760# https://www.mail-archive.com/dev@openvswitch.org/msg27013.html
2761# https://www.mail-archive.com/dev@openvswitch.org/msg27675.html
2762OVS_WAIT_UNTIL([grep NXT_FLOW_MONITOR_RESUMED monitor.log])
2b07c8b1
BP
2763
2764ovs-appctl -t ovs-ofctl exit
2765
2766# Check that the flow monitor reported the same number of flows
2767# added and deleted, but fewer than we actually added and deleted.
2768adds=`grep -c 'ADDED.*reg1=' monitor.log`
2769deletes=`grep -c 'DELETED.*reg1=' monitor.log`
2770echo adds=$adds deletes=$deletes
2771AT_CHECK([test $adds -gt 100 && test $adds -lt $n_msgs])
2772AT_CHECK([test $adds = $deletes])
2773
d0ab8a1a
BP
2774# Check that the flow monitor reported everything in the expected order:
2775#
2776# event=ADDED table=0 cookie=0x1 reg1=0x22
2777# ...
2778# NXT_FLOW_MONITOR_PAUSED:
2779# ...
2780# event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
2781# ...
2782# event=ADDED table=0 cookie=0x3 in_port=1
2783# event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
2784# NXT_FLOW_MONITOR_RESUMED:
2785#
2786# except that, between the PAUSED and RESUMED, the order of the ADDED
2787# and MODIFIED lines lines depends on hash order, that is, it varies
2788# as we change the hash function or change architecture. Therefore,
2789# we use a couple of tests below to accept both orders.
2b07c8b1 2790AT_CHECK([ofctl_strip < monitor.log | sed -n -e '
46a80050 2791/reg1=0x22$/p
2b07c8b1
BP
2792/cookie=0x[[23]]/p
2793/NXT_FLOW_MONITOR_PAUSED:/p
2794/NXT_FLOW_MONITOR_RESUMED:/p
d0ab8a1a
BP
2795' > monitor.log.subset])
2796AT_CHECK([grep -v MODIFIED monitor.log.subset], [0], [dnl
2797 event=ADDED table=0 cookie=0x1 reg1=0x22
2b07c8b1
BP
2798NXT_FLOW_MONITOR_PAUSED:
2799 event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
2800 event=ADDED table=0 cookie=0x3 in_port=1
d0ab8a1a
BP
2801NXT_FLOW_MONITOR_RESUMED:
2802])
2803AT_CHECK([grep -v ADDED monitor.log.subset], [0], [dnl
2804NXT_FLOW_MONITOR_PAUSED:
2805 event=DELETED reason=delete table=0 cookie=0x1 reg1=0x22
2b07c8b1
BP
2806 event=MODIFIED table=0 cookie=0x2 in_port=2 actions=output:2
2807NXT_FLOW_MONITOR_RESUMED:
2808])
2809
2810OVS_VSWITCHD_STOP
2811AT_CLEANUP
45156451
AC
2812
2813AT_SETUP([ofproto - event filtering (OpenFlow 1.3)])
2814AT_KEYWORDS([monitor])
2815OVS_VSWITCHD_START
2816
2817# Start a monitor, use the required protocol version
2818ovs-ofctl -O OpenFlow13 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2819AT_CAPTURE_FILE([monitor.log])
2820
2821# Send an OpenFlow13 message (04), OFPT_GET_ASYNC_REQUEST (1a), length (8), xid (0a)
2822ovs-appctl -t ovs-ofctl ofctl/send 041a00080000000a
2823ovs-appctl -t ovs-ofctl ofctl/barrier
2824
2825# Check default setting
2826read -r -d '' expected <<'EOF'
2827EOF
2828
2829AT_CHECK([ofctl_strip < monitor.log], [], [dnl
2830send: OFPT_GET_ASYNC_REQUEST (OF1.3):
2831OFPT_GET_ASYNC_REPLY (OF1.3):
2832 master:
2833 PACKET_IN: no_match action
2834 PORT_STATUS: add delete modify
2835 FLOW_REMOVED: idle hard delete
2836
2837 slave:
2838 PACKET_IN: (off)
2839 PORT_STATUS: add delete modify
2840 FLOW_REMOVED: (off)
2841OFPT_BARRIER_REPLY (OF1.3):
2842])
2843
2844OVS_VSWITCHD_STOP
2845AT_CLEANUP
4abb8608
BP
2846
2847AT_SETUP([ofproto - ofport_request])
2848OVS_VSWITCHD_START
2849ADD_OF_PORTS([br0], [1], [2], [3])
2850
2851set_and_check_specific_ofports () {
2852 ovs-vsctl set Interface p1 ofport_request="$1" -- \
2853 set Interface p2 ofport_request="$2" -- \
2854 set Interface p3 ofport_request="$3"
2855 ofports=`ovs-vsctl get Interface p1 ofport -- \
2856 get Interface p2 ofport -- \
2857 get Interface p3 ofport`
2858 AT_CHECK_UNQUOTED([echo $ofports], [0], [$1 $2 $3
2859])
2860}
2861for pre in '1 2 3' '1 3 2' '2 1 3' '2 3 1' '3 1 2' '3 2 1'; do
2862 for post in '1 2 3' '1 3 2' '2 1 3' '2 3 1' '3 1 2' '3 2 1'; do
2863 echo -----------------------------------------------------------
2864 echo "Check changing port numbers from $pre to $post"
d08d51b9
JS
2865 set_and_check_specific_ofports $pre
2866 set_and_check_specific_ofports $post
4abb8608
BP
2867 done
2868done
2869
2870ovs-vsctl del-port p3
2871
2872set_and_check_poorly_specified_ofports () {
2873 ovs-vsctl set Interface p1 ofport_request="$1" -- \
2874 set Interface p2 ofport_request="$2"
2875 p1=`ovs-vsctl get Interface p1 ofport`
2876 p2=`ovs-vsctl get Interface p2 ofport`
2877 echo $p1 $p2
2878
2879 AT_CHECK([test "$p1" != "$p2"])
2880 if test "$1" = "$2" && test "$1" != '[[]]'; then
2881 # One port number must be the requested one.
2882 AT_CHECK([test "$p1" = "$1" || test "$p2" = "$1"])
2883 # The other port number must be different (already tested above).
2884 else
2885 AT_CHECK([test "$1" = '[[]]' || test "$p1" == "$1"])
2886 AT_CHECK([test "$2" = '[[]]' || test "$p2" == "$2"])
2887 fi
2888}
2889for pre in '1 2' '[[]] 2' '1 [[]]' '[[]] [[]]' '2 1' '[[]] 1' '2 [[]]' \
2890 '1 1' '2 2'; do
2891 for post in '1 2' '[[]] 2' '1 [[]]' '[[]] [[]]' '2 1' '[[]] 1' '2 [[]]' \
2892 '1 1' '2 2'; do
2893 echo -----------------------------------------------------------
2894 echo "Check changing port numbers from $pre to $post"
2895 set_and_check_poorly_specified_ofports $pre
2896 set_and_check_poorly_specified_ofports $post
2897 done
2898done
2899OVS_VSWITCHD_STOP
2900AT_CLEANUP
777af88d
AC
2901
2902
2903AT_SETUP([ofproto - bundles, open (OpenFlow 1.4)])
2904AT_KEYWORDS([monitor])
2905OVS_VSWITCHD_START
2906
2907# Start a monitor, use the required protocol version
2908ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2909AT_CAPTURE_FILE([monitor.log])
2910
2911# Send an OpenFlow14 message (05), OFPT_BUNDLE_CONTROL (21), length (10), xid (0a)
2912ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2913ovs-appctl -t ovs-ofctl ofctl/barrier
2914ovs-appctl -t ovs-ofctl exit
2915
2916AT_CHECK([ofctl_strip < monitor.log], [], [dnl
2917send: OFPT_BUNDLE_CONTROL (OF1.4):
2918 bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2919OFPT_BUNDLE_CONTROL (OF1.4):
2920 bundle_id=0x1 type=OPEN_REPLY flags=0
2921OFPT_BARRIER_REPLY (OF1.4):
2922])
2923
2924OVS_VSWITCHD_STOP
2925AT_CLEANUP
2926
2927AT_SETUP([ofproto - bundles, double open (OpenFlow 1.4)])
2928AT_KEYWORDS([monitor])
2929OVS_VSWITCHD_START
2930
2931# Start a monitor, use the required protocol version
2932ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2933AT_CAPTURE_FILE([monitor.log])
2934
2935# Send twice an OpenFlow14 message (05), OFPT_BUNDLE_CONTROL (21), length (10), xid (0a)
2936ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2937ovs-appctl -t ovs-ofctl ofctl/barrier
2938ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2939ovs-appctl -t ovs-ofctl ofctl/barrier
2940ovs-appctl -t ovs-ofctl exit
2941
2942AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2943send: OFPT_BUNDLE_CONTROL (OF1.4):
2944 bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2945OFPT_BUNDLE_CONTROL (OF1.4):
2946 bundle_id=0x1 type=OPEN_REPLY flags=0
2947OFPT_BARRIER_REPLY (OF1.4):
2948send: OFPT_BUNDLE_CONTROL (OF1.4):
2949 bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2950OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
2951OFPT_BUNDLE_CONTROL (OF1.4):
2952 bundle_id=0x1 type=OPEN_REQUEST flags=atomic
2953OFPT_BARRIER_REPLY (OF1.4):
2954])
2955
2956OVS_VSWITCHD_STOP
2957AT_CLEANUP
2958
2959AT_SETUP([ofproto - bundle close without open (OpenFlow 1.4)])
2960AT_KEYWORDS([monitor])
2961OVS_VSWITCHD_START
2962
2963# Start a monitor, use the required protocol version
2964ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2965AT_CAPTURE_FILE([monitor.log])
2966
2967ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 01"
2968ovs-appctl -t ovs-ofctl ofctl/barrier
2969ovs-appctl -t ovs-ofctl exit
2970
2971AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
2972send: OFPT_BUNDLE_CONTROL (OF1.4):
2973 bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
2974OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
2975OFPT_BUNDLE_CONTROL (OF1.4):
2976 bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
2977OFPT_BARRIER_REPLY (OF1.4):
2978])
2979
2980OVS_VSWITCHD_STOP
2981AT_CLEANUP
2982
2983AT_SETUP([ofproto - bundle double close (OpenFlow 1.4)])
2984AT_KEYWORDS([monitor])
2985OVS_VSWITCHD_START
2986
2987# Start a monitor, use the required protocol version
2988ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
2989AT_CAPTURE_FILE([monitor.log])
2990
2991# Open, Close, Close
2992ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
2993ovs-appctl -t ovs-ofctl ofctl/barrier
2994ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 01"
2995ovs-appctl -t ovs-ofctl ofctl/barrier
2996ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 01"
2997ovs-appctl -t ovs-ofctl ofctl/barrier
2998ovs-appctl -t ovs-ofctl exit
2999
3000AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3001send: OFPT_BUNDLE_CONTROL (OF1.4):
3002 bundle_id=0x1 type=OPEN_REQUEST flags=atomic
3003OFPT_BUNDLE_CONTROL (OF1.4):
3004 bundle_id=0x1 type=OPEN_REPLY flags=0
3005OFPT_BARRIER_REPLY (OF1.4):
3006send: OFPT_BUNDLE_CONTROL (OF1.4):
3007 bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
3008OFPT_BUNDLE_CONTROL (OF1.4):
3009 bundle_id=0x1 type=CLOSE_REPLY flags=0
3010OFPT_BARRIER_REPLY (OF1.4):
3011send: OFPT_BUNDLE_CONTROL (OF1.4):
3012 bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
3013OFPT_ERROR (OF1.4): OFPBFC_BUNDLE_CLOSED
3014OFPT_BUNDLE_CONTROL (OF1.4):
3015 bundle_id=0x1 type=CLOSE_REQUEST flags=atomic
3016OFPT_BARRIER_REPLY (OF1.4):
3017])
3018
3019OVS_VSWITCHD_STOP
3020AT_CLEANUP
3021
3022AT_SETUP([ofproto - bundle close, different flags (OpenFlow 1.4)])
3023AT_KEYWORDS([monitor])
3024OVS_VSWITCHD_START
3025
3026# Start a monitor, use the required protocol version
3027ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3028AT_CAPTURE_FILE([monitor.log])
3029
3030# Open, Close, Close
3031ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
3032ovs-appctl -t ovs-ofctl ofctl/barrier
3033ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 02 00 02"
3034ovs-appctl -t ovs-ofctl ofctl/barrier
3035ovs-appctl -t ovs-ofctl exit
3036
3037AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3038send: OFPT_BUNDLE_CONTROL (OF1.4):
3039 bundle_id=0x1 type=OPEN_REQUEST flags=atomic
3040OFPT_BUNDLE_CONTROL (OF1.4):
3041 bundle_id=0x1 type=OPEN_REPLY flags=0
3042OFPT_BARRIER_REPLY (OF1.4):
3043send: OFPT_BUNDLE_CONTROL (OF1.4):
3044 bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
3045OFPT_ERROR (OF1.4): OFPBFC_BAD_FLAGS
3046OFPT_BUNDLE_CONTROL (OF1.4):
3047 bundle_id=0x1 type=CLOSE_REQUEST flags=ordered
3048OFPT_BARRIER_REPLY (OF1.4):
3049])
3050
3051OVS_VSWITCHD_STOP
3052AT_CLEANUP
3053
3054AT_SETUP([ofproto - bundle commit without open (OpenFlow 1.4)])
3055AT_KEYWORDS([monitor])
3056OVS_VSWITCHD_START
3057
3058# Start a monitor, use the required protocol version
3059ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3060AT_CAPTURE_FILE([monitor.log])
3061
3062# Open, Close, Close
3063ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 04 00 01"
3064ovs-appctl -t ovs-ofctl ofctl/barrier
3065ovs-appctl -t ovs-ofctl exit
3066
3067AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3068send: OFPT_BUNDLE_CONTROL (OF1.4):
3069 bundle_id=0x1 type=COMMIT_REQUEST flags=atomic
3070OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
3071OFPT_BUNDLE_CONTROL (OF1.4):
3072 bundle_id=0x1 type=COMMIT_REQUEST flags=atomic
3073OFPT_BARRIER_REPLY (OF1.4):
3074])
3075
3076OVS_VSWITCHD_STOP
3077AT_CLEANUP
3078
3079AT_SETUP([ofproto - bundle commit, different flags (OpenFlow 1.4)])
3080AT_KEYWORDS([monitor])
3081OVS_VSWITCHD_START
3082
3083# Start a monitor, use the required protocol version
3084ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3085AT_CAPTURE_FILE([monitor.log])
3086
3087# Open, Close, Close
3088ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 00 00 01"
3089ovs-appctl -t ovs-ofctl ofctl/barrier
3090ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 04 00 02"
3091ovs-appctl -t ovs-ofctl ofctl/barrier
3092ovs-appctl -t ovs-ofctl exit
3093
3094AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3095send: OFPT_BUNDLE_CONTROL (OF1.4):
3096 bundle_id=0x1 type=OPEN_REQUEST flags=atomic
3097OFPT_BUNDLE_CONTROL (OF1.4):
3098 bundle_id=0x1 type=OPEN_REPLY flags=0
3099OFPT_BARRIER_REPLY (OF1.4):
3100send: OFPT_BUNDLE_CONTROL (OF1.4):
3101 bundle_id=0x1 type=COMMIT_REQUEST flags=ordered
3102OFPT_ERROR (OF1.4): OFPBFC_BAD_FLAGS
3103OFPT_BUNDLE_CONTROL (OF1.4):
3104 bundle_id=0x1 type=COMMIT_REQUEST flags=ordered
3105OFPT_BARRIER_REPLY (OF1.4):
3106])
3107
3108OVS_VSWITCHD_STOP
3109AT_CLEANUP
3110
3111AT_SETUP([ofproto - bundle discard without open (OpenFlow 1.4)])
3112AT_KEYWORDS([monitor])
3113OVS_VSWITCHD_START
3114
3115# Start a monitor, use the required protocol version
3116ovs-ofctl -O OpenFlow14 monitor br0 --detach --no-chdir --pidfile >monitor.log 2>&1
3117AT_CAPTURE_FILE([monitor.log])
3118
3119# Open, Close, Close
3120ovs-appctl -t ovs-ofctl ofctl/send "05 21 00 10 00 00 00 0a 00 00 00 01 00 06 00 01"
3121ovs-appctl -t ovs-ofctl ofctl/barrier
3122ovs-appctl -t ovs-ofctl exit
3123
3124AT_CHECK([ofctl_strip < monitor.log], [0], [dnl
3125send: OFPT_BUNDLE_CONTROL (OF1.4):
3126 bundle_id=0x1 type=DISCARD_REQUEST flags=atomic
3127OFPT_ERROR (OF1.4): OFPBFC_BAD_ID
3128OFPT_BUNDLE_CONTROL (OF1.4):
3129 bundle_id=0x1 type=DISCARD_REQUEST flags=atomic
3130OFPT_BARRIER_REPLY (OF1.4):
3131])
3132
3133OVS_VSWITCHD_STOP
3134AT_CLEANUP