ovs-ofctl: Fix del-flows command parsing bugs.
[sliver-openvswitch.git] / tests / ovs-ofctl.at
1 AT_BANNER([ovs-ofctl])
2
3 AT_SETUP([ovs-ofctl parse-flows])
4 AT_DATA([flows.txt], [
5 # comment
6 tcp,tp_src=123,actions=flood
7 in_port=LOCAL dl_vlan=9 dl_src=00:0A:E4:25:6B:B0 actions=drop
8 arp,nw_src=192.168.0.1 actions=drop_spoofed_arp,NORMAL
9 udp dl_vlan_pcp=7 idle_timeout=5 actions=strip_vlan output:0
10 tcp,nw_src=192.168.0.3,tp_dst=80 actions=set_queue:37,output:1
11 udp,nw_src=192.168.0.3,tp_dst=53 actions=pop_queue,output:1
12 cookie=0x123456789abcdef hard_timeout=10 priority=60000 actions=controller
13 actions=note:41.42.43,note:00.01.02.03.04.05.06.07,note
14 tun_id=0x1234,cookie=0x5678,actions=flood
15 actions=drop
16 ])
17 AT_CHECK([ovs-ofctl parse-flows flows.txt], [0], [stdout], [stderr])
18 AT_CHECK([[sed 's/ (xid=0x[0-9a-fA-F]*)//' stdout]], [0], [dnl
19 OFPT_FLOW_MOD: ADD tcp,tp_src=123 actions=FLOOD
20 OFPT_FLOW_MOD: ADD in_port=65534,dl_vlan=9,dl_src=00:0a:e4:25:6b:b0 actions=drop
21 OFPT_FLOW_MOD: ADD arp,nw_src=192.168.0.1 actions=drop_spoofed_arp,NORMAL
22 OFPT_FLOW_MOD: ADD udp,dl_vlan_pcp=7 idle:5 actions=strip_vlan,output:0
23 OFPT_FLOW_MOD: ADD tcp,nw_src=192.168.0.3,tp_dst=80 actions=set_queue:37,output:1
24 OFPT_FLOW_MOD: ADD udp,nw_src=192.168.0.3,tp_dst=53 actions=pop_queue,output:1
25 OFPT_FLOW_MOD: ADD priority=60000 cookie:0x123456789abcdef hard:10 actions=CONTROLLER:65535
26 OFPT_FLOW_MOD: ADD actions=note:41.42.43.00.00.00,note:00.01.02.03.04.05.06.07.00.00.00.00.00.00,note:00.00.00.00.00.00
27 NXT_TUN_ID_FROM_COOKIE: set=1
28 OFPT_FLOW_MOD: ADD cookie:0x123400005678 actions=FLOOD
29 OFPT_FLOW_MOD: ADD actions=drop
30 ])
31 AT_CHECK([sed 's/.*|//' stderr], [0], [dnl
32 normalization changed ofp_match, details:
33  pre: wildcards=  0x3820f8  in_port=65534  dl_src=00:0a:e4:25:6b:b0  dl_dst=00:00:00:00:00:00  dl_vlan=    9  dl_vlan_pcp=  0  dl_type=     0  nw_tos=   0  nw_proto=   0  nw_src=         0  nw_dst=         0  tp_src=    0  tp_dst=    0
34 post: wildcards=  0x3ffff8  in_port=65534  dl_src=00:0a:e4:25:6b:b0  dl_dst=00:00:00:00:00:00  dl_vlan=    9  dl_vlan_pcp=  0  dl_type=     0  nw_tos=   0  nw_proto=   0  nw_src=         0  nw_dst=         0  tp_src=    0  tp_dst=    0
35 normalization changed ofp_match, details:
36  pre: wildcards=  0x3820ff  in_port=65534  dl_src=00:00:00:00:00:00  dl_dst=00:00:00:00:00:00  dl_vlan=    0  dl_vlan_pcp=  0  dl_type=     0  nw_tos=   0  nw_proto=   0  nw_src=         0  nw_dst=         0  tp_src=    0  tp_dst=    0
37 post: wildcards=  0x3fffff  in_port=65534  dl_src=00:00:00:00:00:00  dl_dst=00:00:00:00:00:00  dl_vlan=    0  dl_vlan_pcp=  0  dl_type=     0  nw_tos=   0  nw_proto=   0  nw_src=         0  nw_dst=         0  tp_src=    0  tp_dst=    0
38 normalization changed ofp_match, details:
39  pre: wildcards=  0x3820ff  in_port=65534  dl_src=00:00:00:00:00:00  dl_dst=00:00:00:00:00:00  dl_vlan=    0  dl_vlan_pcp=  0  dl_type=     0  nw_tos=   0  nw_proto=   0  nw_src=         0  nw_dst=         0  tp_src=    0  tp_dst=    0
40 post: wildcards=  0x3fffff  in_port=65534  dl_src=00:00:00:00:00:00  dl_dst=00:00:00:00:00:00  dl_vlan=    0  dl_vlan_pcp=  0  dl_type=     0  nw_tos=   0  nw_proto=   0  nw_src=         0  nw_dst=         0  tp_src=    0  tp_dst=    0
41 normalization changed ofp_match, details:
42  pre: wildcards=  0x3820ff  in_port=65534  dl_src=00:00:00:00:00:00  dl_dst=00:00:00:00:00:00  dl_vlan=    0  dl_vlan_pcp=  0  dl_type=     0  nw_tos=   0  nw_proto=   0  nw_src=         0  nw_dst=         0  tp_src=    0  tp_dst=    0
43 post: wildcards=  0x3fffff  in_port=65534  dl_src=00:00:00:00:00:00  dl_dst=00:00:00:00:00:00  dl_vlan=    0  dl_vlan_pcp=  0  dl_type=     0  nw_tos=   0  nw_proto=   0  nw_src=         0  nw_dst=         0  tp_src=    0  tp_dst=    0
44 normalization changed ofp_match, details:
45  pre: wildcards= 0x23820ff  in_port=65534  dl_src=00:00:00:00:00:00  dl_dst=00:00:00:00:00:00  dl_vlan=    0  dl_vlan_pcp=  0  dl_type=     0  nw_tos=   0  nw_proto=   0  nw_src=         0  nw_dst=         0  tp_src=    0  tp_dst=    0
46 post: wildcards= 0x23fffff  in_port=65534  dl_src=00:00:00:00:00:00  dl_dst=00:00:00:00:00:00  dl_vlan=    0  dl_vlan_pcp=  0  dl_type=     0  nw_tos=   0  nw_proto=   0  nw_src=         0  nw_dst=         0  tp_src=    0  tp_dst=    0
47 ])
48 AT_CLEANUP
49
50 AT_SETUP([ovs-ofctl -F nxm parse-flows])
51 AT_DATA([flows.txt], [
52 # comment
53 tcp,tp_src=123,actions=flood
54 in_port=LOCAL dl_vlan=9 dl_src=00:0A:E4:25:6B:B0 actions=drop
55 arp,nw_src=192.168.0.1 actions=drop_spoofed_arp,NORMAL
56 udp dl_vlan_pcp=7 idle_timeout=5 actions=strip_vlan output:0
57 tcp,nw_src=192.168.0.3,tp_dst=80 actions=set_queue:37,output:1
58 udp,nw_src=192.168.0.3,tp_dst=53 actions=pop_queue,output:1
59 cookie=0x123456789abcdef hard_timeout=10 priority=60000 actions=controller
60 actions=note:41.42.43,note:00.01.02.03.04.05.06.07,note
61 tun_id=0x1234,cookie=0x5678,actions=flood
62 actions=drop
63 ])
64 AT_CHECK([ovs-ofctl -F nxm parse-flows flows.txt], [0], [stdout])
65 AT_CHECK([[sed 's/ (xid=0x[0-9a-fA-F]*)//' stdout]], [0], [dnl
66 NXT_FLOW_MOD: ADD tcp,tp_src=123 actions=FLOOD
67 NXT_FLOW_MOD: ADD in_port=65534,dl_vlan=9,dl_src=00:0a:e4:25:6b:b0 actions=drop
68 NXT_FLOW_MOD: ADD arp,nw_src=192.168.0.1 actions=drop_spoofed_arp,NORMAL
69 NXT_FLOW_MOD: ADD udp,dl_vlan_pcp=7 idle:5 actions=strip_vlan,output:0
70 NXT_FLOW_MOD: ADD tcp,nw_src=192.168.0.3,tp_dst=80 actions=set_queue:37,output:1
71 NXT_FLOW_MOD: ADD udp,nw_src=192.168.0.3,tp_dst=53 actions=pop_queue,output:1
72 NXT_FLOW_MOD: ADD priority=60000 cookie:0x123456789abcdef hard:10 actions=CONTROLLER:65535
73 NXT_FLOW_MOD: ADD actions=note:41.42.43.00.00.00,note:00.01.02.03.04.05.06.07.00.00.00.00.00.00,note:00.00.00.00.00.00
74 NXT_FLOW_MOD: ADD tun_id=0x1234 cookie:0x5678 actions=FLOOD
75 NXT_FLOW_MOD: ADD actions=drop
76 ])
77 AT_CLEANUP
78
79 AT_SETUP([ovs-ofctl -F nxm -mmm parse-flows])
80 AT_DATA([flows.txt], [
81 # comment
82 tcp,tp_src=123,actions=flood
83 in_port=LOCAL dl_vlan=9 dl_src=00:0A:E4:25:6B:B0 actions=drop
84 arp,nw_src=192.168.0.1 actions=drop_spoofed_arp,NORMAL
85 udp dl_vlan_pcp=7 idle_timeout=5 actions=strip_vlan output:0
86 tcp,nw_src=192.168.0.3,tp_dst=80 actions=set_queue:37,output:1
87 udp,nw_src=192.168.0.3,tp_dst=53 actions=pop_queue,output:1
88 cookie=0x123456789abcdef hard_timeout=10 priority=60000 actions=controller
89 actions=note:41.42.43,note:00.01.02.03.04.05.06.07,note
90 tun_id=0x1234,cookie=0x5678,actions=flood
91 actions=drop
92 ])
93 AT_CHECK([ovs-ofctl -F nxm -mmm parse-flows flows.txt], [0], [stdout])
94 AT_CHECK([[sed 's/ (xid=0x[0-9a-fA-F]*)//' stdout]], [0], [dnl
95 NXT_FLOW_MOD: ADD NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(06), NXM_OF_TCP_SRC(007b) actions=FLOOD
96 NXT_FLOW_MOD: ADD NXM_OF_IN_PORT(fffe), NXM_OF_ETH_SRC(000ae4256bb0), NXM_OF_VLAN_TCI_W(1009/1fff) actions=drop
97 NXT_FLOW_MOD: ADD NXM_OF_ETH_TYPE(0806), NXM_OF_ARP_SPA(c0a80001) actions=drop_spoofed_arp,NORMAL
98 NXT_FLOW_MOD: ADD NXM_OF_ETH_TYPE(0800), NXM_OF_VLAN_TCI_W(f000/f000), NXM_OF_IP_PROTO(11) idle:5 actions=strip_vlan,output:0
99 NXT_FLOW_MOD: ADD NXM_OF_ETH_TYPE(0800), NXM_OF_IP_SRC(c0a80003), NXM_OF_IP_PROTO(06), NXM_OF_TCP_DST(0050) actions=set_queue:37,output:1
100 NXT_FLOW_MOD: ADD NXM_OF_ETH_TYPE(0800), NXM_OF_IP_SRC(c0a80003), NXM_OF_IP_PROTO(11), NXM_OF_UDP_DST(0035) actions=pop_queue,output:1
101 NXT_FLOW_MOD: ADD <any> cookie:0x123456789abcdef hard:10 pri:60000 actions=CONTROLLER:65535
102 NXT_FLOW_MOD: ADD <any> actions=note:41.42.43.00.00.00,note:00.01.02.03.04.05.06.07.00.00.00.00.00.00,note:00.00.00.00.00.00
103 NXT_FLOW_MOD: ADD NXM_NX_TUN_ID(0000000000001234) cookie:0x5678 actions=FLOOD
104 NXT_FLOW_MOD: ADD <any> actions=drop
105 ])
106 AT_CLEANUP
107
108 AT_SETUP([ovs-ofctl parse-nx-match])
109 AT_KEYWORDS([nx-match])
110 AT_DATA([nx-match.txt], [dnl
111 <any>
112
113 # in port
114 NXM_OF_IN_PORT(0000)
115 NXM_OF_IN_PORT(fffe)
116
117 # eth dst
118 NXM_OF_ETH_DST(0002e30f80a4)
119 NXM_OF_ETH_DST_W(010000000000/010000000000)
120 NXM_OF_ETH_DST_W(000000000000/010000000000)
121 NXM_OF_ETH_DST_W(ffffffffffff/010000000000)
122 NXM_OF_ETH_DST_W(0002e30f80a4/ffffffffffff)
123 NXM_OF_ETH_DST_W(0002e30f80a4/feffffffffff)
124
125 # eth src
126 NXM_OF_ETH_SRC(020898456ddb)
127
128 # eth type
129 NXM_OF_ETH_TYPE(0800)
130 NXM_OF_ETH_TYPE(0800) NXM_OF_IN_PORT(0012)
131
132 # vlan tci
133 NXM_OF_VLAN_TCI(f009)
134 NXM_OF_VLAN_TCI(f009) NXM_OF_VLAN_TCI(f009)
135 NXM_OF_VLAN_TCI(0000)           # Packets without 802.1Q header.
136 NXM_OF_VLAN_TCI(3123)           # Packets with VID=123, PCP=1.
137 NXM_OF_VLAN_TCI(0123)           # Does not make sense (but supported anyway)
138 NXM_OF_VLAN_TCI_W(1123/1fff)    # Packets with VID=123, any PCP.
139 NXM_OF_VLAN_TCI_W(f000/f000)    # Packets with any VID, PCP=7.
140 NXM_OF_VLAN_TCI_W(0000/e000)    # No 802.1Q or with VID=0
141
142 # IP TOS
143 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_TOS(f0)
144 NXM_OF_IP_TOS(f0)
145
146 # IP protocol
147 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(01)
148 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(05)
149 NXM_OF_IP_PROTO(05)
150
151 # IP source
152 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_SRC(ac100014)
153 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_SRC_W(C0a80000/FFFF0000)
154 NXM_OF_ETH_TYPE(0806) NXM_OF_IP_SRC(ac100014)
155 NXM_OF_IP_SRC_W(C0D80000/FFFF0000)
156
157 # IP destination
158 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_DST(ac100014)
159 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_DST_W(C0a88012/FFFF0000)
160 NXM_OF_IP_DST(ac100014)
161 NXM_OF_ETH_TYPE(0806) NXM_OF_IP_DST_W(C0D80000/FFFF0000)
162
163 # TCP source port
164 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(06) NXM_OF_TCP_SRC(4231)
165 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(07) NXM_OF_TCP_SRC(4231)
166
167 # TCP destination port
168 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(06) NXM_OF_TCP_DST(4231)
169 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(07) NXM_OF_TCP_DST(4231)
170
171 # UDP source port
172 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(11) NXM_OF_UDP_SRC(8732)
173 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(06) NXM_OF_UDP_SRC(7823)
174
175 # UDP destination port
176 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(11) NXM_OF_UDP_DST(1782)
177 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(02) NXM_OF_UDP_DST(1293)
178
179 # ICMP type
180 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(01) NXM_OF_ICMP_TYPE(12)
181 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(00) NXM_OF_ICMP_TYPE(10)
182
183 # ICMP code
184 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(01) NXM_OF_ICMP_CODE(12)
185 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(00) NXM_OF_ICMP_CODE(10)
186 NXM_OF_ETH_TYPE(0800) NXM_OF_ICMP_CODE(10)
187 NXM_OF_ICMP_CODE(00)
188
189 # ARP opcode
190 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_OP(0001)
191 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_OP(1111)
192 NXM_OF_ETH_TYPE(0000) NXM_OF_ARP_OP(0001)
193 NXM_OF_ARP_OP(0001)
194 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_OP(0001) NXM_OF_ARP_OP(0001)
195
196 # ARP source
197 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_SPA(ac100014)
198 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_SPA_W(C0a81234/FFFFFF00)
199 NXM_OF_ETH_TYPE(0800) NXM_OF_ARP_SPA(ac100014)
200 NXM_OF_ARP_SPA_W(C0D8fedc/FFFF0000)
201
202 # ARP destination
203 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_TPA(ac100014)
204 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_TPA_W(C0a812fe/FFFFFF00)
205 NXM_OF_ETH_TYPE(0800) NXM_OF_ARP_TPA(ac100014)
206 NXM_OF_ARP_TPA_W(C0D80000/FFFF0000)
207
208 # Tunnel ID.
209 NXM_NX_TUN_ID(00000000abcdef01)
210
211 # Register 0.
212 NXM_NX_REG0(acebdf56)
213 NXM_NX_REG0_W(a0e0d050/f0f0f0f0)
214
215 # Invalid field number.
216 01020304(1111/2222)
217
218 # Unimplemented registers.
219 #
220 # This test assumes that at least two registers, but fewer than 16,
221 # registers are implemented.
222 00010004(12345678)
223 00010108(12345678/12345678)
224 00011e04(12345678)
225 00011f08(12345678/12345678)
226 ])
227 AT_CHECK([ovs-ofctl parse-nx-match < nx-match.txt], [0], [dnl
228 <any>
229
230 # in port
231 NXM_OF_IN_PORT(fffe)
232 NXM_OF_IN_PORT(fffe)
233
234 # eth dst
235 NXM_OF_ETH_DST(0002e30f80a4)
236 NXM_OF_ETH_DST_W(010000000000/010000000000)
237 NXM_OF_ETH_DST_W(000000000000/010000000000)
238 NXM_OF_ETH_DST_W(010000000000/010000000000)
239 NXM_OF_ETH_DST(0002e30f80a4)
240 NXM_OF_ETH_DST_W(0002e30f80a4/feffffffffff)
241
242 # eth src
243 NXM_OF_ETH_SRC(020898456ddb)
244
245 # eth type
246 NXM_OF_ETH_TYPE(0800)
247 NXM_OF_IN_PORT(0012), NXM_OF_ETH_TYPE(0800) 
248
249 # vlan tci
250 NXM_OF_VLAN_TCI(f009)
251 nx_pull_match() returned error 44010105
252 NXM_OF_VLAN_TCI(0000)
253 NXM_OF_VLAN_TCI(3123)
254 NXM_OF_VLAN_TCI(0123)
255 NXM_OF_VLAN_TCI_W(1123/1fff)
256 NXM_OF_VLAN_TCI_W(f000/f000)
257 NXM_OF_VLAN_TCI_W(0000/e000)
258
259 # IP TOS
260 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_TOS(f0)
261 nx_pull_match() returned error 44010104
262
263 # IP protocol
264 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(01)
265 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(05)
266 nx_pull_match() returned error 44010104
267
268 # IP source
269 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_SRC(ac100014)
270 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_SRC_W(c0a80000/ffff0000)
271 nx_pull_match() returned error 44010104
272 nx_pull_match() returned error 44010104
273
274 # IP destination
275 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_DST(ac100014)
276 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_DST_W(c0a80000/ffff0000)
277 nx_pull_match() returned error 44010104
278 nx_pull_match() returned error 44010104
279
280 # TCP source port
281 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(06), NXM_OF_TCP_SRC(4231)
282 nx_pull_match() returned error 44010104
283
284 # TCP destination port
285 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(06), NXM_OF_TCP_DST(4231)
286 nx_pull_match() returned error 44010104
287
288 # UDP source port
289 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(11), NXM_OF_UDP_SRC(8732)
290 nx_pull_match() returned error 44010104
291
292 # UDP destination port
293 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(11), NXM_OF_UDP_DST(1782)
294 nx_pull_match() returned error 44010104
295
296 # ICMP type
297 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(01), NXM_OF_ICMP_TYPE(12)
298 nx_pull_match() returned error 44010104
299
300 # ICMP code
301 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(01), NXM_OF_ICMP_CODE(12)
302 nx_pull_match() returned error 44010104
303 nx_pull_match() returned error 44010104
304 nx_pull_match() returned error 44010104
305
306 # ARP opcode
307 NXM_OF_ETH_TYPE(0806), NXM_OF_ARP_OP(0001)
308 nx_pull_match() returned error 44010102
309 nx_pull_match() returned error 44010104
310 nx_pull_match() returned error 44010104
311 nx_pull_match() returned error 44010105
312
313 # ARP source
314 NXM_OF_ETH_TYPE(0806), NXM_OF_ARP_SPA(ac100014)
315 NXM_OF_ETH_TYPE(0806), NXM_OF_ARP_SPA_W(c0a81200/ffffff00)
316 nx_pull_match() returned error 44010104
317 nx_pull_match() returned error 44010104
318
319 # ARP destination
320 NXM_OF_ETH_TYPE(0806), NXM_OF_ARP_TPA(ac100014)
321 NXM_OF_ETH_TYPE(0806), NXM_OF_ARP_TPA_W(c0a81200/ffffff00)
322 nx_pull_match() returned error 44010104
323 nx_pull_match() returned error 44010104
324
325 # Tunnel ID.
326 NXM_NX_TUN_ID(00000000abcdef01)
327
328 # Register 0.
329 NXM_NX_REG0(acebdf56)
330 NXM_NX_REG0_W(a0e0d050/f0f0f0f0)
331
332 # Invalid field number.
333 nx_pull_match() returned error 44010101
334
335 # Unimplemented registers.
336 #
337 # This test assumes that at least two registers, but fewer than 16,
338 # registers are implemented.
339 NXM_NX_REG0(12345678)
340 NXM_NX_REG0_W(12345678/12345678)
341 nx_pull_match() returned error 44010101
342 nx_pull_match() returned error 44010101
343 ])
344 AT_CLEANUP