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