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