3f39538a73e635ad08b3bc0d470bd2ce0d0f22b8
[openvswitch] / 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 parse-nx-match])
80 AT_KEYWORDS([nx-match])
81 AT_DATA([nx-match.txt], [dnl
82 <any>
83
84 # in port
85 NXM_OF_IN_PORT(0000)
86 NXM_OF_IN_PORT(fffe)
87
88 # eth dst
89 NXM_OF_ETH_DST(0002e30f80a4)
90 NXM_OF_ETH_DST_W(010000000000/010000000000)
91 NXM_OF_ETH_DST_W(000000000000/010000000000)
92 NXM_OF_ETH_DST_W(ffffffffffff/010000000000)
93 NXM_OF_ETH_DST_W(0002e30f80a4/ffffffffffff)
94 NXM_OF_ETH_DST_W(0002e30f80a4/feffffffffff)
95
96 # eth src
97 NXM_OF_ETH_SRC(020898456ddb)
98
99 # eth type
100 NXM_OF_ETH_TYPE(0800)
101 NXM_OF_ETH_TYPE(0800) NXM_OF_IN_PORT(0012)
102
103 # vlan tci
104 NXM_OF_VLAN_TCI(f009)
105 NXM_OF_VLAN_TCI(f009) NXM_OF_VLAN_TCI(f009)
106 NXM_OF_VLAN_TCI(0000)           # Packets without 802.1Q header.
107 NXM_OF_VLAN_TCI(3123)           # Packets with VID=123, PCP=1.
108 NXM_OF_VLAN_TCI(0123)           # Does not make sense (but supported anyway)
109 NXM_OF_VLAN_TCI_W(1123/1fff)    # Packets with VID=123, any PCP.
110 NXM_OF_VLAN_TCI_W(f000/f000)    # Packets with any VID, PCP=7.
111 NXM_OF_VLAN_TCI_W(0000/e000)    # No 802.1Q or with VID=0
112
113 # IP TOS
114 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_TOS(f0)
115 NXM_OF_IP_TOS(f0)
116
117 # IP protocol
118 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(01)
119 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(05)
120 NXM_OF_IP_PROTO(05)
121
122 # IP source
123 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_SRC(ac100014)
124 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_SRC_W(C0a80000/FFFF0000)
125 NXM_OF_ETH_TYPE(0806) NXM_OF_IP_SRC(ac100014)
126 NXM_OF_IP_SRC_W(C0D80000/FFFF0000)
127
128 # IP destination
129 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_DST(ac100014)
130 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_DST_W(C0a88012/FFFF0000)
131 NXM_OF_IP_DST(ac100014)
132 NXM_OF_ETH_TYPE(0806) NXM_OF_IP_DST_W(C0D80000/FFFF0000)
133
134 # TCP source port
135 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(06) NXM_OF_TCP_SRC(4231)
136 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(07) NXM_OF_TCP_SRC(4231)
137
138 # TCP destination port
139 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(06) NXM_OF_TCP_DST(4231)
140 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(07) NXM_OF_TCP_DST(4231)
141
142 # UDP source port
143 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(11) NXM_OF_UDP_SRC(8732)
144 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(06) NXM_OF_UDP_SRC(7823)
145
146 # UDP destination port
147 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(11) NXM_OF_UDP_DST(1782)
148 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(02) NXM_OF_UDP_DST(1293)
149
150 # ICMP type
151 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(01) NXM_OF_ICMP_TYPE(12)
152 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(00) NXM_OF_ICMP_TYPE(10)
153
154 # ICMP code
155 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(01) NXM_OF_ICMP_CODE(12)
156 NXM_OF_ETH_TYPE(0800) NXM_OF_IP_PROTO(00) NXM_OF_ICMP_CODE(10)
157 NXM_OF_ETH_TYPE(0800) NXM_OF_ICMP_CODE(10)
158 NXM_OF_ICMP_CODE(00)
159
160 # ARP opcode
161 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_OP(0001)
162 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_OP(1111)
163 NXM_OF_ETH_TYPE(0000) NXM_OF_ARP_OP(0001)
164 NXM_OF_ARP_OP(0001)
165 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_OP(0001) NXM_OF_ARP_OP(0001)
166
167 # ARP source
168 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_SPA(ac100014)
169 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_SPA_W(C0a81234/FFFFFF00)
170 NXM_OF_ETH_TYPE(0800) NXM_OF_ARP_SPA(ac100014)
171 NXM_OF_ARP_SPA_W(C0D8fedc/FFFF0000)
172
173 # ARP destination
174 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_TPA(ac100014)
175 NXM_OF_ETH_TYPE(0806) NXM_OF_ARP_TPA_W(C0a812fe/FFFFFF00)
176 NXM_OF_ETH_TYPE(0800) NXM_OF_ARP_TPA(ac100014)
177 NXM_OF_ARP_TPA_W(C0D80000/FFFF0000)
178
179 # Tunnel ID.
180 NXM_NX_TUN_ID(00000000abcdef01)
181
182 # Register 0.
183 NXM_NX_REG0(acebdf56)
184 NXM_NX_REG0_W(a0e0d050/f0f0f0f0)
185
186 # Invalid field number.
187 01020304(1111/2222)
188
189 # Unimplemented registers.
190 #
191 # This test assumes that at least two registers, but fewer than 16,
192 # registers are implemented.
193 00010004(12345678)
194 00010108(12345678/12345678)
195 00011e04(12345678)
196 00011f08(12345678/12345678)
197 ])
198 AT_CHECK([ovs-ofctl parse-nx-match < nx-match.txt], [0], [dnl
199 <any>
200
201 # in port
202 NXM_OF_IN_PORT(fffe)
203 NXM_OF_IN_PORT(fffe)
204
205 # eth dst
206 NXM_OF_ETH_DST(0002e30f80a4)
207 NXM_OF_ETH_DST_W(010000000000/010000000000)
208 NXM_OF_ETH_DST_W(000000000000/010000000000)
209 NXM_OF_ETH_DST_W(010000000000/010000000000)
210 NXM_OF_ETH_DST(0002e30f80a4)
211 NXM_OF_ETH_DST_W(0002e30f80a4/feffffffffff)
212
213 # eth src
214 NXM_OF_ETH_SRC(020898456ddb)
215
216 # eth type
217 NXM_OF_ETH_TYPE(0800)
218 NXM_OF_IN_PORT(0012), NXM_OF_ETH_TYPE(0800) 
219
220 # vlan tci
221 NXM_OF_VLAN_TCI(f009)
222 nx_pull_match() returned error 44010105
223 NXM_OF_VLAN_TCI(0000)
224 NXM_OF_VLAN_TCI(3123)
225 NXM_OF_VLAN_TCI(0123)
226 NXM_OF_VLAN_TCI_W(1123/1fff)
227 NXM_OF_VLAN_TCI_W(f000/f000)
228 NXM_OF_VLAN_TCI_W(0000/e000)
229
230 # IP TOS
231 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_TOS(f0)
232 nx_pull_match() returned error 44010104
233
234 # IP protocol
235 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(01)
236 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(05)
237 nx_pull_match() returned error 44010104
238
239 # IP source
240 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_SRC(ac100014)
241 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_SRC_W(c0a80000/ffff0000)
242 nx_pull_match() returned error 44010104
243 nx_pull_match() returned error 44010104
244
245 # IP destination
246 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_DST(ac100014)
247 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_DST_W(c0a80000/ffff0000)
248 nx_pull_match() returned error 44010104
249 nx_pull_match() returned error 44010104
250
251 # TCP source port
252 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(06), NXM_OF_TCP_SRC(4231)
253 nx_pull_match() returned error 44010104
254
255 # TCP destination port
256 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(06), NXM_OF_TCP_DST(4231)
257 nx_pull_match() returned error 44010104
258
259 # UDP source port
260 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(11), NXM_OF_UDP_SRC(8732)
261 nx_pull_match() returned error 44010104
262
263 # UDP destination port
264 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(11), NXM_OF_UDP_DST(1782)
265 nx_pull_match() returned error 44010104
266
267 # ICMP type
268 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(01), NXM_OF_ICMP_TYPE(12)
269 nx_pull_match() returned error 44010104
270
271 # ICMP code
272 NXM_OF_ETH_TYPE(0800), NXM_OF_IP_PROTO(01), NXM_OF_ICMP_CODE(12)
273 nx_pull_match() returned error 44010104
274 nx_pull_match() returned error 44010104
275 nx_pull_match() returned error 44010104
276
277 # ARP opcode
278 NXM_OF_ETH_TYPE(0806), NXM_OF_ARP_OP(0001)
279 nx_pull_match() returned error 44010102
280 nx_pull_match() returned error 44010104
281 nx_pull_match() returned error 44010104
282 nx_pull_match() returned error 44010105
283
284 # ARP source
285 NXM_OF_ETH_TYPE(0806), NXM_OF_ARP_SPA(ac100014)
286 NXM_OF_ETH_TYPE(0806), NXM_OF_ARP_SPA_W(c0a81200/ffffff00)
287 nx_pull_match() returned error 44010104
288 nx_pull_match() returned error 44010104
289
290 # ARP destination
291 NXM_OF_ETH_TYPE(0806), NXM_OF_ARP_TPA(ac100014)
292 NXM_OF_ETH_TYPE(0806), NXM_OF_ARP_TPA_W(c0a81200/ffffff00)
293 nx_pull_match() returned error 44010104
294 nx_pull_match() returned error 44010104
295
296 # Tunnel ID.
297 NXM_NX_TUN_ID(00000000abcdef01)
298
299 # Register 0.
300 NXM_NX_REG0(acebdf56)
301 NXM_NX_REG0_W(a0e0d050/f0f0f0f0)
302
303 # Invalid field number.
304 nx_pull_match() returned error 44010101
305
306 # Unimplemented registers.
307 #
308 # This test assumes that at least two registers, but fewer than 16,
309 # registers are implemented.
310 NXM_NX_REG0(12345678)
311 NXM_NX_REG0_W(12345678/12345678)
312 nx_pull_match() returned error 44010101
313 nx_pull_match() returned error 44010101
314 ])
315 AT_CLEANUP