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