]>
Commit | Line | Data |
---|---|---|
3223e977 BP |
1 | AT_BANNER([flow classifier unit tests]) |
2 | m4_foreach( | |
3 | [testname], | |
4 | [[empty], | |
5 | [destroy-null], | |
6 | [single-rule], | |
7 | [rule-replacement], | |
b5d97350 | 8 | [many-rules-in-one-list], |
3bbe9a1f | 9 | [versioned many-rules-in-one-list], |
3223e977 | 10 | [many-rules-in-one-table], |
3bbe9a1f | 11 | [versioned many-rules-in-one-table], |
b5d97350 | 12 | [many-rules-in-two-tables], |
3bbe9a1f JR |
13 | [versioned many-rules-in-two-tables], |
14 | [many-rules-in-five-tables], | |
15 | [versioned many-rules-in-five-tables]], | |
3223e977 | 16 | [AT_SETUP([flow classifier - m4_bpatsubst(testname, [-], [ ])]) |
3bbe9a1f | 17 | AT_CHECK([ovstest test-classifier m4_bpatsubst(testname, [versioned], [--versioned])], [0], [], []) |
3223e977 | 18 | AT_CLEANUP])]) |
5cb7a798 BP |
19 | |
20 | AT_BANNER([miniflow unit tests]) | |
21 | m4_foreach( | |
22 | [testname], | |
23 | [[miniflow], | |
24 | [minimask_has_extra], | |
25 | [minimask_combine]], | |
26 | [AT_SETUP([miniflow - m4_bpatsubst(testname, [-], [ ])]) | |
eadd1644 | 27 | AT_CHECK([ovstest test-classifier testname], [0], [], []) |
5cb7a798 | 28 | AT_CLEANUP])]) |
476f36e8 JR |
29 | |
30 | AT_BANNER([flow classifier lookup segmentation]) | |
31 | AT_SETUP([flow classifier - lookup segmentation]) | |
32 | OVS_VSWITCHD_START | |
ca5792f0 | 33 | add_of_ports br0 1 2 3 |
476f36e8 JR |
34 | AT_DATA([flows.txt], [dnl |
35 | table=0 in_port=1 priority=16,tcp,nw_dst=10.1.0.0/255.255.0.0,action=output(3) | |
36 | table=0 in_port=1 priority=32,tcp,nw_dst=10.1.2.15,action=output(2) | |
37 | table=0 in_port=1 priority=33,tcp,nw_dst=10.1.2.15,tp_dst=80,action=drop | |
38 | table=0 in_port=1 priority=0,ip,action=drop | |
39 | table=0 in_port=2 priority=16,tcp,nw_dst=192.168.0.0/255.255.0.0,action=output(1) | |
40 | table=0 in_port=2 priority=0,ip,action=drop | |
41 | table=0 in_port=3 priority=16,tcp,nw_src=10.1.0.0/255.255.0.0,action=output(1) | |
42 | table=0 in_port=3 priority=0,ip,action=drop | |
43 | ]) | |
44 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
45 | AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=2,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=80'], [0], [stdout]) | |
46 | AT_CHECK([tail -2 stdout], [0], | |
16194afd | 47 | [Megaflow: recirc_id=0,tcp,in_port=2,nw_dst=192.168.0.0/16,nw_frag=no |
476f36e8 JR |
48 | Datapath actions: 1 |
49 | ]) | |
66e1d955 | 50 | AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=11.1.2.15,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=80'], [0], [stdout]) |
476f36e8 | 51 | AT_CHECK([tail -2 stdout], [0], |
31ecf25f | 52 | [Megaflow: recirc_id=0,ip,in_port=1,nw_dst=11.0.0.0/8,nw_frag=no |
476f36e8 JR |
53 | Datapath actions: drop |
54 | ]) | |
55 | AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=10.1.2.15,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=80'], [0], [stdout]) | |
56 | AT_CHECK([tail -2 stdout], [0], | |
16194afd | 57 | [Megaflow: recirc_id=0,tcp,in_port=1,nw_dst=10.1.2.15,nw_frag=no,tp_dst=80 |
476f36e8 JR |
58 | Datapath actions: drop |
59 | ]) | |
60 | AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=10.1.2.15,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=79'], [0], [stdout]) | |
61 | AT_CHECK([tail -2 stdout], [0], | |
31ecf25f | 62 | [Megaflow: recirc_id=0,tcp,in_port=1,nw_dst=10.1.2.15,nw_frag=no,tp_dst=0x40/0xfff0 |
476f36e8 JR |
63 | Datapath actions: 2 |
64 | ]) | |
65 | OVS_VSWITCHD_STOP | |
66 | AT_CLEANUP | |
13751fd8 JR |
67 | |
68 | AT_BANNER([flow classifier prefix lookup]) | |
69 | AT_SETUP([flow classifier - prefix lookup]) | |
70 | OVS_VSWITCHD_START | |
ca5792f0 | 71 | add_of_ports br0 1 2 3 |
13751fd8 | 72 | AT_CHECK([ovs-vsctl set Bridge br0 flow_tables:0=@N1 -- --id=@N1 create Flow_Table name=t0], [0], [ignore], []) |
13751fd8 JR |
73 | AT_DATA([flows.txt], [dnl |
74 | table=0 in_port=1 priority=16,tcp,nw_dst=10.1.0.0/255.255.0.0,action=output(3) | |
75 | table=0 in_port=1 priority=32,tcp,nw_dst=10.1.2.0/255.255.255.0,tp_src=79,action=output(2) | |
76 | table=0 in_port=1 priority=33,tcp,nw_dst=10.1.2.15,tp_dst=80,action=drop | |
69d6040e JR |
77 | table=0 in_port=1 priority=33,tcp,nw_dst=10.1.2.15,tp_dst=8080,action=output(2) |
78 | table=0 in_port=1 priority=33,tcp,nw_dst=10.1.2.15,tp_dst=192,action=output(2) | |
13751fd8 JR |
79 | table=0 in_port=1 priority=0,ip,action=drop |
80 | table=0 in_port=2 priority=16,tcp,nw_dst=192.168.0.0/255.255.0.0,action=output(1) | |
81 | table=0 in_port=2 priority=0,ip,action=drop | |
82 | table=0 in_port=3 priority=16,tcp,nw_src=10.1.0.0/255.255.0.0,action=output(1) | |
83 | table=0 in_port=3 priority=0,ip,action=drop | |
84 | ]) | |
85 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
f017d986 JR |
86 | |
87 | # nw_dst and nw_src should be on by default | |
88 | AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=80'], [0], [stdout]) | |
89 | AT_CHECK([tail -2 stdout], [0], | |
31ecf25f | 90 | [Megaflow: recirc_id=0,tcp,in_port=1,nw_dst=192.168.0.0/16,nw_frag=no |
f017d986 JR |
91 | Datapath actions: drop |
92 | ]) | |
93 | ||
94 | AT_CHECK([ovs-vsctl set Flow_Table t0 prefixes=ipv6_label], [0]) | |
95 | AT_CHECK([ovs-vsctl set Flow_Table t0 prefixes=nw_dst,nw_src,tun_dst,tun_src], [1], [], | |
96 | [ovs-vsctl: nw_dst,nw_src,tun_dst,tun_src: 4 value(s) specified but the maximum number is 3 | |
97 | ]) | |
98 | AT_CHECK([ovs-vsctl set Flow_Table t0 prefixes=nw_dst,nw_dst], [1], [], | |
99 | [ovs-vsctl: nw_dst,nw_dst: set contains duplicate value | |
100 | ]) | |
101 | ||
102 | AT_CHECK([ovs-vsctl set Flow_Table t0 prefixes=nw_dst], [0]) | |
13751fd8 JR |
103 | AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=80'], [0], [stdout]) |
104 | AT_CHECK([tail -2 stdout], [0], | |
31ecf25f | 105 | [Megaflow: recirc_id=0,tcp,in_port=1,nw_dst=192.168.0.0/16,nw_frag=no |
13751fd8 JR |
106 | Datapath actions: drop |
107 | ]) | |
108 | AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=2,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=80'], [0], [stdout]) | |
109 | AT_CHECK([tail -2 stdout], [0], | |
16194afd | 110 | [Megaflow: recirc_id=0,tcp,in_port=2,nw_dst=192.168.0.0/16,nw_frag=no |
13751fd8 JR |
111 | Datapath actions: 1 |
112 | ]) | |
113 | AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=10.1.2.15,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=80'], [0], [stdout]) | |
114 | AT_CHECK([tail -2 stdout], [0], | |
16194afd | 115 | [Megaflow: recirc_id=0,tcp,in_port=1,nw_dst=10.1.2.15,nw_frag=no,tp_dst=80 |
13751fd8 JR |
116 | Datapath actions: drop |
117 | ]) | |
118 | AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=10.1.2.15,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=79'], [0], [stdout]) | |
119 | AT_CHECK([tail -2 stdout], [0], | |
31ecf25f | 120 | [Megaflow: recirc_id=0,tcp,in_port=1,nw_dst=10.1.2.15,nw_frag=no,tp_src=0x0/0xffc0,tp_dst=0x40/0xfff0 |
13751fd8 JR |
121 | Datapath actions: 3 |
122 | ]) | |
f017d986 JR |
123 | AT_CHECK([ovs-vsctl set Flow_Table t0 prefixes=none], [0]) |
124 | AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:07,dl_type=0x0800,nw_src=192.168.0.1,nw_dst=10.1.3.16,nw_proto=6,nw_tos=0,nw_ttl=128,tp_src=8,tp_dst=79'], [0], [stdout]) | |
125 | AT_CHECK([tail -2 stdout], [0], | |
16194afd | 126 | [Megaflow: recirc_id=0,tcp,in_port=1,nw_dst=10.1.3.16,nw_frag=no |
f017d986 JR |
127 | Datapath actions: 3 |
128 | ]) | |
13751fd8 JR |
129 | OVS_VSWITCHD_STOP(["/'prefixes' with incompatible field: ipv6_label/d"]) |
130 | AT_CLEANUP | |
18080541 BP |
131 | |
132 | AT_BANNER([conjunctive match]) | |
133 | ||
134 | AT_SETUP([single conjunctive match]) | |
135 | OVS_VSWITCHD_START | |
ca5792f0 | 136 | add_of_ports br0 1 2 3 4 5 |
18080541 BP |
137 | AT_DATA([flows.txt], [dnl |
138 | conj_id=1,actions=3 | |
139 | priority=100,ip,ip_src=10.0.0.1,actions=conjunction(1,1/2) | |
140 | priority=100,ip,ip_src=10.0.0.4,actions=conjunction(1,1/2) | |
141 | priority=100,ip,ip_src=10.0.0.6,actions=conjunction(1,1/2) | |
142 | priority=100,ip,ip_src=10.0.0.7,actions=conjunction(1,1/2) | |
143 | priority=100,ip,ip_dst=10.0.0.2,actions=conjunction(1,2/2) | |
144 | priority=100,ip,ip_dst=10.0.0.5,actions=conjunction(1,2/2) | |
145 | priority=100,ip,ip_dst=10.0.0.7,actions=conjunction(1,2/2) | |
146 | priority=100,ip,ip_dst=10.0.0.8,actions=conjunction(1,2/2) | |
147 | priority=100,ip,ip_src=10.0.0.1,ip_dst=10.0.0.4,actions=4 | |
148 | priority=100,ip,ip_src=10.0.0.3,ip_dst=10.0.0.5,actions=5 | |
149 | ||
150 | priority=0 actions=2 | |
151 | ]) | |
152 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
153 | for src in 0 1 2 3 4 5 6 7; do | |
154 | for dst in 0 1 2 3 4 5 6 7; do | |
155 | if test $src$dst = 14; then | |
156 | out=4 | |
157 | elif test $src$dst = 35; then | |
158 | out=5 | |
159 | else | |
160 | out=2 | |
161 | case $src in [[1467]]) case $dst in [[2578]]) out=3 ;; esac ;; esac | |
162 | fi | |
163 | AT_CHECK([ovs-appctl ofproto/trace br0 "in_port=1,dl_type=0x0800,nw_src=10.0.0.$src,nw_dst=10.0.0.$dst"], [0], [stdout]) | |
164 | AT_CHECK_UNQUOTED([tail -1 stdout], [0], [Datapath actions: $out | |
165 | ]) | |
166 | done | |
167 | done | |
168 | OVS_VSWITCHD_STOP | |
169 | AT_CLEANUP | |
170 | ||
171 | AT_SETUP([multiple conjunctive match]) | |
172 | OVS_VSWITCHD_START | |
ca5792f0 | 173 | add_of_ports br0 1 2 3 4 5 |
18080541 BP |
174 | AT_DATA([flows.txt], [dnl |
175 | conj_id=1,actions=1 | |
176 | conj_id=2,actions=2 | |
177 | conj_id=3,actions=3 | |
178 | ||
179 | priority=5,ip,ip_src=20.0.0.0/8,actions=conjunction(1,1/2),conjunction(2,1/2) | |
180 | priority=5,ip,ip_src=10.1.0.0/16,actions=conjunction(1,1/2),conjunction(3,2/3) | |
181 | priority=5,ip,ip_src=10.2.0.0/16,actions=conjunction(1,1/2),conjunction(2,1/2) | |
182 | priority=5,ip,ip_src=10.1.3.0/24,actions=conjunction(1,1/2),conjunction(3,2/3) | |
183 | priority=5,ip,ip_src=10.1.4.5/32,actions=conjunction(1,1/2),conjunction(2,1/2) | |
184 | ||
185 | priority=5,ip,ip_dst=20.0.0.0/8,actions=conjunction(1,2/2) | |
186 | priority=5,ip,ip_dst=10.1.0.0/16,actions=conjunction(1,2/2) | |
187 | priority=5,ip,ip_dst=10.2.0.0/16,actions=conjunction(1,2/2) | |
188 | priority=5,ip,ip_dst=10.1.3.0/24,actions=conjunction(1,2/2) | |
189 | priority=5,ip,ip_dst=10.1.4.5/32,actions=conjunction(1,2/2) | |
190 | priority=5,ip,ip_dst=30.0.0.0/8,actions=conjunction(2,2/2),conjunction(3,1/3) | |
191 | priority=5,ip,ip_dst=40.5.0.0/16,actions=conjunction(2,2/2),conjunction(3,1/3) | |
192 | ||
193 | priority=5,tcp,tcp_dst=80,actions=conjunction(3,3/3) | |
194 | priority=5,tcp,tcp_dst=443,actions=conjunction(3,3/3) | |
195 | ||
196 | priority=5,tcp,tcp_src=80,actions=conjunction(3,3/3) | |
197 | priority=5,tcp,tcp_src=443,actions=conjunction(3,3/3) | |
198 | ||
199 | priority=0,actions=4 | |
200 | ]) | |
201 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
202 | for a0 in \ | |
203 | '1 20.0.0.1' \ | |
204 | '2 10.1.0.1' \ | |
205 | '3 10.2.0.1' \ | |
206 | '4 10.1.3.1' \ | |
207 | '5 10.1.4.5' \ | |
208 | '6 1.2.3.4' | |
209 | do | |
210 | for b0 in \ | |
211 | '1 20.0.0.1' \ | |
212 | '2 10.1.0.1' \ | |
213 | '3 10.2.0.1' \ | |
214 | '4 10.1.3.1' \ | |
215 | '5 10.1.4.5' \ | |
216 | '6 30.0.0.1' \ | |
217 | '7 40.5.0.1' \ | |
218 | '8 1.2.3.4' | |
219 | do | |
220 | for c0 in '1 80' '2 443' '3 8080'; do | |
221 | for d0 in '1 80' '2 443' '3 8080'; do | |
222 | set $a0; a=$1 ip_src=$2 | |
223 | set $b0; b=$1 ip_dst=$2 | |
224 | set $c0; c=$1 tcp_src=$2 | |
225 | set $d0; d=$1 tcp_dst=$2 | |
226 | case $a$b$c$d in | |
227 | [[12345]][[12345]]??) out=1 ;; | |
228 | [[135]][[67]]??) out=2 ;; | |
229 | [[24]][[67]][[12]]? | [[24]][[67]]?[[12]]) out=3 ;; | |
230 | *) out=4 | |
231 | esac | |
232 | AT_CHECK([ovs-appctl ofproto/trace br0 "in_port=5,dl_type=0x0800,nw_proto=6,nw_src=$ip_src,nw_dst=$ip_dst,tcp_src=$tcp_src,tcp_dst=$tcp_dst"], [0], [stdout]) | |
233 | AT_CHECK_UNQUOTED([tail -1 stdout], [0], [Datapath actions: $out | |
234 | ]) | |
235 | done | |
236 | done | |
237 | done | |
238 | done | |
239 | OVS_VSWITCHD_STOP | |
240 | AT_CLEANUP | |
241 | ||
242 | # In conjunctive match, we can find some soft matches that turn out not to be a | |
243 | # real match. Usually, that's the end of the road--there is no real match. | |
244 | # But if there is a flow identical to one of the flows that was a soft match, | |
245 | # except with a lower priority, then we have to try again with that lower | |
246 | # priority flow. This test checks this special case. | |
247 | AT_SETUP([conjunctive match priority fallback]) | |
248 | OVS_VSWITCHD_START | |
ca5792f0 | 249 | add_of_ports br0 1 2 3 4 5 6 7 |
18080541 BP |
250 | AT_DATA([flows.txt], [dnl |
251 | conj_id=1,actions=1 | |
252 | conj_id=3,actions=3 | |
253 | ||
254 | priority=5,ip,ip_src=10.0.0.1,actions=conjunction(1,1/2) | |
255 | priority=5,ip,ip_src=10.0.0.2,actions=conjunction(1,1/2) | |
256 | priority=5,ip,ip_dst=10.0.0.1,actions=conjunction(1,2/2) | |
257 | priority=5,ip,ip_dst=10.0.0.2,actions=conjunction(1,2/2) | |
258 | priority=5,ip,ip_dst=10.0.0.3,actions=conjunction(1,2/2) | |
259 | ||
260 | priority=4,ip,ip_src=10.0.0.3,ip_dst=10.0.0.2,actions=2 | |
261 | ||
262 | priority=3,ip,ip_src=10.0.0.1,actions=conjunction(3,1/2) | |
263 | priority=3,ip,ip_src=10.0.0.3,actions=conjunction(3,1/2) | |
264 | priority=3,ip,ip_dst=10.0.0.2,actions=conjunction(3,2/2) | |
265 | priority=3,ip,ip_dst=10.0.0.3,actions=conjunction(3,2/2) | |
266 | priority=3,ip,ip_dst=10.0.0.4,actions=conjunction(3,2/2) | |
267 | ||
268 | priority=2,ip,ip_dst=10.0.0.1,actions=4 | |
269 | ||
270 | priority=1,ip,ip_src=10.0.0.1,ip_dst=10.0.0.5,actions=5 | |
271 | ||
272 | priority=0,actions=6 | |
273 | ]) | |
274 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
275 | for src in 0 1 2 3; do | |
276 | for dst in 0 1 2 3 4 5; do | |
277 | case $src$dst in | |
278 | [[12]][[123]]) out=1 ;; | |
279 | 32) out=2 ;; | |
280 | [[13]][[234]]) out=3 ;; | |
281 | ?1) out=4 ;; | |
282 | 15) out=5 ;; | |
283 | *) out=6 | |
284 | esac | |
285 | AT_CHECK([ovs-appctl ofproto/trace br0 "in_port=7,dl_type=0x0800,nw_src=10.0.0.$src,nw_dst=10.0.0.$dst"], [0], [stdout]) | |
286 | AT_CHECK_UNQUOTED([tail -1 stdout], [0], [Datapath actions: $out | |
287 | ]) | |
288 | done | |
289 | done | |
290 | OVS_VSWITCHD_STOP | |
291 | AT_CLEANUP | |
f08e39dd BP |
292 | |
293 | AT_SETUP([conjunctive match and other actions]) | |
294 | OVS_VSWITCHD_START | |
295 | # It's OK to use "conjunction" actions with "note" actions. | |
296 | AT_CHECK([ovs-ofctl add-flow br0 'actions=conjunction(3,1/2),note:41.42.43.44.45.46']) | |
297 | AT_CHECK([ovs-ofctl add-flow br0 'actions=note:41.42.43.44.45.46,conjunction(3,1/2)']) | |
298 | # It's not OK to use "conjunction" actions with other types of actions. | |
299 | AT_CHECK([ovs-ofctl '-vPATTERN:console:%c|%p|%m' add-flow br0 'actions=output:1,conjunction(3,1/2)'], [1], [], [dnl | |
300 | ofp_actions|WARN|"conjunction" actions may be used along with "note" but not any other kind of action (such as the "output" action used here) | |
301 | ovs-ofctl: Incorrect instruction ordering | |
302 | ]) | |
303 | AT_CHECK([ovs-ofctl '-vPATTERN:console:%c|%p|%m' add-flow br0 'actions=conjunction(3,1/2),output:1'], [1], [], [dnl | |
304 | ofp_actions|WARN|"conjunction" actions may be used along with "note" but not any other kind of action (such as the "output" action used here) | |
305 | ovs-ofctl: Incorrect instruction ordering | |
306 | ]) | |
307 | OVS_VSWITCHD_STOP | |
308 | AT_CLEANUP |