]>
Commit | Line | Data |
---|---|---|
d7c5426b | 1 | AT_BANNER([datapath-sanity]) |
69c2bdfe | 2 | |
d7c5426b | 3 | AT_SETUP([datapath - ping between two ports]) |
cf7659b6 JR |
4 | OVS_TRAFFIC_VSWITCHD_START() |
5 | ||
6 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
69c2bdfe AZ |
7 | |
8 | ADD_NAMESPACES(at_ns0, at_ns1) | |
9 | ||
10 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
11 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
12 | ||
de22d08f | 13 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl |
cfe17b43 | 14 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
de22d08f JS |
15 | ]) |
16 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
cfe17b43 | 17 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
de22d08f JS |
18 | ]) |
19 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
cfe17b43 JS |
20 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
21 | ]) | |
22 | ||
d7c5426b | 23 | OVS_TRAFFIC_VSWITCHD_STOP |
cfe17b43 JS |
24 | AT_CLEANUP |
25 | ||
e0b92701 DDP |
26 | AT_SETUP([datapath - http between two ports]) |
27 | OVS_TRAFFIC_VSWITCHD_START() | |
28 | ||
29 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
30 | ||
31 | ADD_NAMESPACES(at_ns0, at_ns1) | |
32 | ||
33 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
34 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
35 | ||
36 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
37 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
38 | ]) | |
39 | ||
7ed40afe | 40 | OVS_START_L7([at_ns1], [http]) |
e0b92701 DDP |
41 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
42 | ||
43 | OVS_TRAFFIC_VSWITCHD_STOP | |
44 | AT_CLEANUP | |
45 | ||
d7c5426b | 46 | AT_SETUP([datapath - ping between two ports on vlan]) |
cf7659b6 JR |
47 | OVS_TRAFFIC_VSWITCHD_START() |
48 | ||
49 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
cfe17b43 JS |
50 | |
51 | ADD_NAMESPACES(at_ns0, at_ns1) | |
52 | ||
53 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
54 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
55 | ||
56 | ADD_VLAN(p0, at_ns0, 100, "10.2.2.1/24") | |
57 | ADD_VLAN(p1, at_ns1, 100, "10.2.2.2/24") | |
58 | ||
de22d08f | 59 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl |
cfe17b43 | 60 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
de22d08f JS |
61 | ]) |
62 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
cfe17b43 | 63 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
de22d08f JS |
64 | ]) |
65 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
cfe17b43 JS |
66 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
67 | ]) | |
68 | ||
d7c5426b | 69 | OVS_TRAFFIC_VSWITCHD_STOP |
cfe17b43 JS |
70 | AT_CLEANUP |
71 | ||
c5abeef4 EG |
72 | AT_SETUP([datapath - ping between two ports on cvlan]) |
73 | OVS_TRAFFIC_VSWITCHD_START() | |
74 | ||
75 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
76 | ||
77 | ADD_NAMESPACES(at_ns0, at_ns1) | |
78 | ||
79 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
80 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
81 | ||
82 | ADD_SVLAN(p0, at_ns0, 4094, "10.255.2.1/24") | |
83 | ADD_SVLAN(p1, at_ns1, 4094, "10.255.2.2/24") | |
84 | ||
85 | ADD_CVLAN(p0.4094, at_ns0, 100, "10.2.2.1/24") | |
86 | ADD_CVLAN(p1.4094, at_ns1, 100, "10.2.2.2/24") | |
87 | ||
88 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping -c 1 10.2.2.2]) | |
89 | ||
90 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
91 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
92 | ]) | |
93 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
94 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
95 | ]) | |
96 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
97 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
98 | ]) | |
99 | ||
100 | OVS_TRAFFIC_VSWITCHD_STOP | |
101 | AT_CLEANUP | |
102 | ||
d7c5426b | 103 | AT_SETUP([datapath - ping6 between two ports]) |
cf7659b6 JR |
104 | OVS_TRAFFIC_VSWITCHD_START() |
105 | ||
106 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
cfe17b43 JS |
107 | |
108 | ADD_NAMESPACES(at_ns0, at_ns1) | |
109 | ||
110 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
111 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
112 | ||
c10840ff JS |
113 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
114 | dnl waiting, we get occasional failures due to the following error: | |
cfe17b43 | 115 | dnl "connect: Cannot assign requested address" |
c10840ff | 116 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) |
cfe17b43 | 117 | |
de22d08f | 118 | NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl |
cfe17b43 | 119 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
de22d08f JS |
120 | ]) |
121 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
cfe17b43 | 122 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
de22d08f JS |
123 | ]) |
124 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
cfe17b43 JS |
125 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
126 | ]) | |
127 | ||
d7c5426b | 128 | OVS_TRAFFIC_VSWITCHD_STOP |
cfe17b43 JS |
129 | AT_CLEANUP |
130 | ||
d7c5426b | 131 | AT_SETUP([datapath - ping6 between two ports on vlan]) |
cf7659b6 JR |
132 | OVS_TRAFFIC_VSWITCHD_START() |
133 | ||
134 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
cfe17b43 JS |
135 | |
136 | ADD_NAMESPACES(at_ns0, at_ns1) | |
137 | ||
138 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
139 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
140 | ||
141 | ADD_VLAN(p0, at_ns0, 100, "fc00:1::1/96") | |
142 | ADD_VLAN(p1, at_ns1, 100, "fc00:1::2/96") | |
143 | ||
c10840ff JS |
144 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
145 | dnl waiting, we get occasional failures due to the following error: | |
cfe17b43 | 146 | dnl "connect: Cannot assign requested address" |
68ffb694 | 147 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00:1::2]) |
cfe17b43 | 148 | |
de22d08f | 149 | NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00:1::2 | FORMAT_PING], [0], [dnl |
cfe17b43 | 150 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
de22d08f JS |
151 | ]) |
152 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00:1::2 | FORMAT_PING], [0], [dnl | |
cfe17b43 | 153 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
de22d08f JS |
154 | ]) |
155 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00:1::2 | FORMAT_PING], [0], [dnl | |
cfe17b43 JS |
156 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
157 | ]) | |
158 | ||
d7c5426b | 159 | OVS_TRAFFIC_VSWITCHD_STOP |
69c2bdfe | 160 | AT_CLEANUP |
810e1785 | 161 | |
c5abeef4 EG |
162 | AT_SETUP([datapath - ping6 between two ports on cvlan]) |
163 | OVS_TRAFFIC_VSWITCHD_START() | |
164 | ||
165 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
166 | ||
167 | ADD_NAMESPACES(at_ns0, at_ns1) | |
168 | ||
169 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
170 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
171 | ||
172 | ADD_SVLAN(p0, at_ns0, 4094, "fc00:ffff::1/96") | |
173 | ADD_SVLAN(p1, at_ns1, 4094, "fc00:ffff::2/96") | |
174 | ||
175 | ADD_CVLAN(p0.4094, at_ns0, 100, "fc00:1::1/96") | |
176 | ADD_CVLAN(p1.4094, at_ns1, 100, "fc00:1::2/96") | |
177 | ||
178 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00:1::2]) | |
179 | ||
180 | NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00:1::2 | FORMAT_PING], [0], [dnl | |
181 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
182 | ]) | |
183 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00:1::2 | FORMAT_PING], [0], [dnl | |
184 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
185 | ]) | |
186 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00:1::2 | FORMAT_PING], [0], [dnl | |
187 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
188 | ]) | |
189 | ||
190 | OVS_TRAFFIC_VSWITCHD_STOP | |
191 | AT_CLEANUP | |
192 | ||
ddb5f937 LR |
193 | AT_SETUP([datapath - ping over bond]) |
194 | OVS_TRAFFIC_VSWITCHD_START() | |
195 | ||
196 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
197 | ||
198 | ADD_NAMESPACES(at_ns0, at_ns1) | |
199 | ||
200 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
201 | ADD_VETH_BOND(p1 p2, at_ns1, br0, bond0, lacp=active bond_mode=balance-tcp, "10.1.1.2/24") | |
202 | ||
203 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping -c 1 10.1.1.2]) | |
204 | ||
205 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
206 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
207 | ]) | |
208 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
209 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
210 | ]) | |
211 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
212 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
213 | ]) | |
214 | ||
215 | OVS_TRAFFIC_VSWITCHD_STOP | |
216 | AT_CLEANUP | |
217 | ||
810e1785 | 218 | AT_SETUP([datapath - ping over vxlan tunnel]) |
dfb21e96 | 219 | OVS_CHECK_VXLAN() |
810e1785 | 220 | |
cf7659b6 JR |
221 | OVS_TRAFFIC_VSWITCHD_START() |
222 | ADD_BR([br-underlay]) | |
223 | ||
224 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
225 | AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"]) | |
226 | ||
810e1785 JS |
227 | ADD_NAMESPACES(at_ns0) |
228 | ||
229 | dnl Set up underlay link from host into the namespace using veth pair. | |
230 | ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24") | |
231 | AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"]) | |
232 | AT_CHECK([ip link set dev br-underlay up]) | |
233 | ||
234 | dnl Set up tunnel endpoints on OVS outside the namespace and with a native | |
235 | dnl linux device inside the namespace. | |
236 | ADD_OVS_TUNNEL([vxlan], [br0], [at_vxlan0], [172.31.1.1], [10.1.1.100/24]) | |
237 | ADD_NATIVE_TUNNEL([vxlan], [at_vxlan1], [at_ns0], [172.31.1.100], [10.1.1.1/24], | |
238 | [id 0 dstport 4789]) | |
239 | ||
240 | dnl First, check the underlay | |
241 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl | |
242 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
243 | ]) | |
244 | ||
245 | dnl Okay, now check the overlay with different packet sizes | |
246 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
247 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
248 | ]) | |
249 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
250 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
251 | ]) | |
252 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
523256cc JS |
253 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
254 | ]) | |
255 | ||
256 | OVS_TRAFFIC_VSWITCHD_STOP | |
257 | AT_CLEANUP | |
258 | ||
259 | AT_SETUP([datapath - ping over gre tunnel]) | |
260 | OVS_CHECK_GRE() | |
261 | ||
262 | OVS_TRAFFIC_VSWITCHD_START() | |
263 | ADD_BR([br-underlay]) | |
264 | ||
265 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
266 | AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"]) | |
267 | ||
268 | ADD_NAMESPACES(at_ns0) | |
269 | ||
270 | dnl Set up underlay link from host into the namespace using veth pair. | |
271 | ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24") | |
272 | AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"]) | |
273 | AT_CHECK([ip link set dev br-underlay up]) | |
274 | ||
275 | dnl Set up tunnel endpoints on OVS outside the namespace and with a native | |
276 | dnl linux device inside the namespace. | |
277 | ADD_OVS_TUNNEL([gre], [br0], [at_gre0], [172.31.1.1], [10.1.1.100/24]) | |
278 | ADD_NATIVE_TUNNEL([gretap], [ns_gre0], [at_ns0], [172.31.1.100], [10.1.1.1/24]) | |
279 | ||
280 | dnl First, check the underlay | |
281 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl | |
282 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
283 | ]) | |
284 | ||
285 | dnl Okay, now check the overlay with different packet sizes | |
286 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
287 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
288 | ]) | |
289 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
290 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
291 | ]) | |
292 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
92b8af2c JS |
293 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
294 | ]) | |
295 | ||
296 | OVS_TRAFFIC_VSWITCHD_STOP | |
297 | AT_CLEANUP | |
298 | ||
299 | AT_SETUP([datapath - ping over geneve tunnel]) | |
300 | OVS_CHECK_GENEVE() | |
301 | ||
302 | OVS_TRAFFIC_VSWITCHD_START() | |
303 | ADD_BR([br-underlay]) | |
304 | ||
305 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
306 | AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"]) | |
307 | ||
308 | ADD_NAMESPACES(at_ns0) | |
309 | ||
310 | dnl Set up underlay link from host into the namespace using veth pair. | |
311 | ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24") | |
312 | AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"]) | |
313 | AT_CHECK([ip link set dev br-underlay up]) | |
314 | ||
315 | dnl Set up tunnel endpoints on OVS outside the namespace and with a native | |
316 | dnl linux device inside the namespace. | |
317 | ADD_OVS_TUNNEL([geneve], [br0], [at_gnv0], [172.31.1.1], [10.1.1.100/24]) | |
318 | ADD_NATIVE_TUNNEL([geneve], [ns_gnv0], [at_ns0], [172.31.1.100], [10.1.1.1/24], | |
319 | [vni 0]) | |
320 | ||
321 | dnl First, check the underlay | |
322 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl | |
323 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
324 | ]) | |
325 | ||
326 | dnl Okay, now check the overlay with different packet sizes | |
327 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
328 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
329 | ]) | |
330 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
331 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
332 | ]) | |
333 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
810e1785 JS |
334 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms |
335 | ]) | |
336 | ||
337 | OVS_TRAFFIC_VSWITCHD_STOP | |
338 | AT_CLEANUP | |
07659514 | 339 | |
7ae62a67 WT |
340 | AT_SETUP([datapath - clone action]) |
341 | OVS_TRAFFIC_VSWITCHD_START() | |
342 | ||
343 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2) | |
344 | ||
345 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
346 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
7ae62a67 | 347 | |
88b5874e WT |
348 | AT_CHECK([ovs-vsctl -- set interface ovs-p0 ofport_request=1 \ |
349 | -- set interface ovs-p1 ofport_request=2]) | |
7ae62a67 | 350 | |
88b5874e WT |
351 | AT_DATA([flows.txt], [dnl |
352 | priority=1 actions=NORMAL | |
353 | priority=10 in_port=1,ip,actions=clone(mod_dl_dst(50:54:00:00:00:0a),set_field:192.168.3.3->ip_dst), output:2 | |
354 | priority=10 in_port=2,ip,actions=clone(mod_dl_src(ae:c6:7e:54:8d:4d),mod_dl_dst(50:54:00:00:00:0b),set_field:192.168.4.4->ip_dst, controller), output:1 | |
355 | ]) | |
356 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
7ae62a67 | 357 | |
88b5874e | 358 | AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log]) |
7ae62a67 WT |
359 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl |
360 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
361 | ]) | |
362 | ||
88b5874e WT |
363 | AT_CHECK([cat ofctl_monitor.log | STRIP_MONITOR_CSUM], [0], [dnl |
364 | icmp,vlan_tci=0x0000,dl_src=ae:c6:7e:54:8d:4d,dl_dst=50:54:00:00:00:0b,nw_src=10.1.1.2,nw_dst=192.168.4.4,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=0,icmp_code=0 icmp_csum: <skip> | |
365 | icmp,vlan_tci=0x0000,dl_src=ae:c6:7e:54:8d:4d,dl_dst=50:54:00:00:00:0b,nw_src=10.1.1.2,nw_dst=192.168.4.4,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=0,icmp_code=0 icmp_csum: <skip> | |
366 | icmp,vlan_tci=0x0000,dl_src=ae:c6:7e:54:8d:4d,dl_dst=50:54:00:00:00:0b,nw_src=10.1.1.2,nw_dst=192.168.4.4,nw_tos=0,nw_ecn=0,nw_ttl=64,icmp_type=0,icmp_code=0 icmp_csum: <skip> | |
367 | ]) | |
7ae62a67 WT |
368 | |
369 | OVS_TRAFFIC_VSWITCHD_STOP | |
370 | AT_CLEANUP | |
371 | ||
aaca4fe0 | 372 | AT_SETUP([datapath - basic truncate action]) |
9c1ab985 | 373 | AT_SKIP_IF([test $HAVE_NC = no]) |
aaca4fe0 WT |
374 | OVS_TRAFFIC_VSWITCHD_START() |
375 | AT_CHECK([ovs-ofctl del-flows br0]) | |
376 | ||
377 | dnl Create p0 and ovs-p0(1) | |
378 | ADD_NAMESPACES(at_ns0) | |
379 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
380 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address e6:66:c1:11:11:11]) | |
381 | NS_CHECK_EXEC([at_ns0], [arp -s 10.1.1.2 e6:66:c1:22:22:22]) | |
382 | ||
383 | dnl Create p1(3) and ovs-p1(2), packets received from ovs-p1 will appear in p1 | |
384 | AT_CHECK([ip link add p1 type veth peer name ovs-p1]) | |
385 | on_exit 'ip link del ovs-p1' | |
386 | AT_CHECK([ip link set dev ovs-p1 up]) | |
387 | AT_CHECK([ip link set dev p1 up]) | |
388 | AT_CHECK([ovs-vsctl add-port br0 ovs-p1 -- set interface ovs-p1 ofport_request=2]) | |
389 | dnl Use p1 to check the truncated packet | |
390 | AT_CHECK([ovs-vsctl add-port br0 p1 -- set interface p1 ofport_request=3]) | |
391 | ||
392 | dnl Create p2(5) and ovs-p2(4) | |
393 | AT_CHECK([ip link add p2 type veth peer name ovs-p2]) | |
394 | on_exit 'ip link del ovs-p2' | |
395 | AT_CHECK([ip link set dev ovs-p2 up]) | |
396 | AT_CHECK([ip link set dev p2 up]) | |
397 | AT_CHECK([ovs-vsctl add-port br0 ovs-p2 -- set interface ovs-p2 ofport_request=4]) | |
398 | dnl Use p2 to check the truncated packet | |
399 | AT_CHECK([ovs-vsctl add-port br0 p2 -- set interface p2 ofport_request=5]) | |
400 | ||
401 | dnl basic test | |
402 | AT_CHECK([ovs-ofctl del-flows br0]) | |
403 | AT_DATA([flows.txt], [dnl | |
404 | in_port=3 dl_dst=e6:66:c1:22:22:22 actions=drop | |
405 | in_port=5 dl_dst=e6:66:c1:22:22:22 actions=drop | |
406 | in_port=1 dl_dst=e6:66:c1:22:22:22 actions=output(port=2,max_len=100),output:4 | |
407 | ]) | |
408 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
409 | ||
410 | dnl use this file as payload file for ncat | |
411 | AT_CHECK([dd if=/dev/urandom of=payload200.bin bs=200 count=1 2> /dev/null]) | |
412 | on_exit 'rm -f payload200.bin' | |
a037f175 | 413 | NS_CHECK_EXEC([at_ns0], [nc $NC_EOF_OPT -u 10.1.1.2 1234 < payload200.bin]) |
aaca4fe0 WT |
414 | |
415 | dnl packet with truncated size | |
416 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
417 | AT_CHECK([ovs-ofctl dump-flows br0 table=0 | grep "in_port=3" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
418 | n_bytes=100 | |
419 | ]) | |
420 | dnl packet with original size | |
421 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
422 | AT_CHECK([ovs-ofctl dump-flows br0 table=0 | grep "in_port=5" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
423 | n_bytes=242 | |
424 | ]) | |
425 | ||
426 | dnl more complicated output actions | |
427 | AT_CHECK([ovs-ofctl del-flows br0]) | |
428 | AT_DATA([flows.txt], [dnl | |
429 | in_port=3 dl_dst=e6:66:c1:22:22:22 actions=drop | |
430 | in_port=5 dl_dst=e6:66:c1:22:22:22 actions=drop | |
431 | in_port=1 dl_dst=e6:66:c1:22:22:22 actions=output(port=2,max_len=100),output:4,output(port=2,max_len=100),output(port=4,max_len=100),output:2,output(port=4,max_len=200),output(port=2,max_len=65535) | |
432 | ]) | |
433 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
434 | ||
a037f175 | 435 | NS_CHECK_EXEC([at_ns0], [nc $NC_EOF_OPT -u 10.1.1.2 1234 < payload200.bin]) |
aaca4fe0 WT |
436 | |
437 | dnl 100 + 100 + 242 + min(65535,242) = 684 | |
438 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
439 | AT_CHECK([ovs-ofctl dump-flows br0 table=0 | grep "in_port=3" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
440 | n_bytes=684 | |
441 | ]) | |
442 | dnl 242 + 100 + min(242,200) = 542 | |
443 | AT_CHECK([ovs-ofctl dump-flows br0 table=0 | grep "in_port=5" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
444 | n_bytes=542 | |
445 | ]) | |
446 | ||
447 | dnl SLOW_ACTION: disable kernel datapath truncate support | |
448 | dnl Repeat the test above, but exercise the SLOW_ACTION code path | |
449 | AT_CHECK([ovs-appctl dpif/disable-truncate], [0], | |
450 | [Datapath truncate action diabled | |
451 | ]) | |
452 | ||
453 | dnl SLOW_ACTION test1: check datapatch actions | |
454 | AT_CHECK([ovs-ofctl del-flows br0]) | |
455 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
456 | ||
3041e1fc | 457 | AT_CHECK([ovs-appctl ofproto/trace br0 "in_port=1,dl_type=0x800,dl_src=e6:66:c1:11:11:11,dl_dst=e6:66:c1:22:22:22,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_proto=6,tp_src=8,tp_dst=9"], [0], [stdout]) |
aaca4fe0 WT |
458 | AT_CHECK([tail -3 stdout], [0], |
459 | [Datapath actions: trunc(100),3,5,trunc(100),3,trunc(100),5,3,trunc(200),5,trunc(65535),3 | |
460 | This flow is handled by the userspace slow path because it: | |
461 | - Uses action(s) not supported by datapath. | |
462 | ]) | |
aaca4fe0 WT |
463 | |
464 | dnl SLOW_ACTION test2: check actual packet truncate | |
465 | AT_CHECK([ovs-ofctl del-flows br0]) | |
466 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
a037f175 | 467 | NS_CHECK_EXEC([at_ns0], [nc $NC_EOF_OPT -u 10.1.1.2 1234 < payload200.bin]) |
aaca4fe0 WT |
468 | |
469 | dnl 100 + 100 + 242 + min(65535,242) = 684 | |
470 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
471 | AT_CHECK([ovs-ofctl dump-flows br0 table=0 | grep "in_port=3" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
472 | n_bytes=684 | |
473 | ]) | |
474 | ||
475 | dnl 242 + 100 + min(242,200) = 542 | |
476 | AT_CHECK([ovs-ofctl dump-flows br0 table=0 | grep "in_port=5" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
477 | n_bytes=542 | |
478 | ]) | |
479 | ||
480 | OVS_TRAFFIC_VSWITCHD_STOP | |
481 | AT_CLEANUP | |
482 | ||
483 | dnl Create 2 bridges and 2 namespaces to test truncate over | |
484 | dnl GRE tunnel: | |
485 | dnl br0: overlay bridge | |
486 | dnl ns1: connect to br0, with IP:10.1.1.2 | |
487 | dnl br-underlay: with IP: 172.31.1.100 | |
488 | dnl ns0: connect to br-underlay, with IP: 10.1.1.1 | |
489 | AT_SETUP([datapath - truncate and output to gre tunnel]) | |
9c1ab985 | 490 | AT_SKIP_IF([test $HAVE_NC = no]) |
aaca4fe0 WT |
491 | OVS_CHECK_GRE() |
492 | OVS_TRAFFIC_VSWITCHD_START() | |
493 | ||
494 | ADD_BR([br-underlay]) | |
495 | ADD_NAMESPACES(at_ns0) | |
496 | ADD_NAMESPACES(at_ns1) | |
497 | AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) | |
498 | AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"]) | |
499 | ||
500 | dnl Set up underlay link from host into the namespace using veth pair. | |
501 | ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24") | |
502 | AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"]) | |
503 | AT_CHECK([ip link set dev br-underlay up]) | |
504 | ||
505 | dnl Set up tunnel endpoints on OVS outside the namespace and with a native | |
506 | dnl linux device inside the namespace. | |
507 | ADD_OVS_TUNNEL([gre], [br0], [at_gre0], [172.31.1.1], [10.1.1.100/24]) | |
2b9f3924 WT |
508 | ADD_NATIVE_TUNNEL([gretap], [ns_gre0], [at_ns0], [172.31.1.100], [10.1.1.1/24], |
509 | [], [address e6:66:c1:11:11:11]) | |
aaca4fe0 | 510 | AT_CHECK([ovs-vsctl -- set interface at_gre0 ofport_request=1]) |
aaca4fe0 WT |
511 | NS_CHECK_EXEC([at_ns0], [arp -s 10.1.1.2 e6:66:c1:22:22:22]) |
512 | ||
513 | dnl Set up (p1 and ovs-p1) at br0 | |
514 | ADD_VETH(p1, at_ns1, br0, '10.1.1.2/24') | |
515 | AT_CHECK([ovs-vsctl -- set interface ovs-p1 ofport_request=2]) | |
516 | NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address e6:66:c1:22:22:22]) | |
517 | NS_CHECK_EXEC([at_ns1], [arp -s 10.1.1.1 e6:66:c1:11:11:11]) | |
518 | ||
519 | dnl Set up (p2 and ovs-p2) as loopback for verifying packet size | |
520 | AT_CHECK([ip link add p2 type veth peer name ovs-p2]) | |
521 | on_exit 'ip link del ovs-p2' | |
522 | AT_CHECK([ip link set dev ovs-p2 up]) | |
523 | AT_CHECK([ip link set dev p2 up]) | |
524 | AT_CHECK([ovs-vsctl add-port br0 ovs-p2 -- set interface ovs-p2 ofport_request=3]) | |
525 | AT_CHECK([ovs-vsctl add-port br0 p2 -- set interface p2 ofport_request=4]) | |
526 | ||
527 | dnl use this file as payload file for ncat | |
528 | AT_CHECK([dd if=/dev/urandom of=payload200.bin bs=200 count=1 2> /dev/null]) | |
529 | on_exit 'rm -f payload200.bin' | |
530 | ||
531 | AT_CHECK([ovs-ofctl del-flows br0]) | |
532 | AT_DATA([flows.txt], [dnl | |
533 | priority=99,in_port=1,actions=output(port=2,max_len=100),output(port=3,max_len=100) | |
534 | priority=99,in_port=2,udp,actions=output(port=1,max_len=100) | |
535 | priority=1,in_port=4,ip,actions=drop | |
536 | priority=1,actions=drop | |
537 | ]) | |
538 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
539 | ||
540 | AT_CHECK([ovs-ofctl del-flows br-underlay]) | |
541 | AT_DATA([flows-underlay.txt], [dnl | |
542 | priority=99,dl_type=0x0800,nw_proto=47,in_port=1,actions=LOCAL | |
543 | priority=99,dl_type=0x0800,nw_proto=47,in_port=LOCAL,ip_dst=172.31.1.1/24,actions=1 | |
544 | priority=1,actions=drop | |
545 | ]) | |
546 | ||
547 | AT_CHECK([ovs-ofctl add-flows br-underlay flows-underlay.txt]) | |
548 | ||
549 | dnl check tunnel push path, from at_ns1 to at_ns0 | |
a037f175 | 550 | NS_CHECK_EXEC([at_ns1], [nc $NC_EOF_OPT -u 10.1.1.1 1234 < payload200.bin]) |
aaca4fe0 WT |
551 | AT_CHECK([ovs-appctl revalidator/purge], [0]) |
552 | ||
553 | dnl Before truncation = ETH(14) + IP(20) + UDP(8) + 200 = 242B | |
554 | AT_CHECK([ovs-ofctl dump-flows br0 | grep "in_port=2" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
555 | n_bytes=242 | |
556 | ]) | |
557 | dnl After truncation = outer ETH(14) + outer IP(20) + GRE(4) + 100 = 138B | |
558 | AT_CHECK([ovs-ofctl dump-flows br-underlay | grep "in_port=LOCAL" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
559 | n_bytes=138 | |
560 | ]) | |
561 | ||
562 | dnl check tunnel pop path, from at_ns0 to at_ns1 | |
a037f175 | 563 | NS_CHECK_EXEC([at_ns0], [nc $NC_EOF_OPT -u 10.1.1.2 5678 < payload200.bin]) |
aaca4fe0 WT |
564 | dnl After truncation = 100 byte at loopback device p2(4) |
565 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
32b0cc65 JS |
566 | AT_CHECK([ovs-ofctl dump-flows br0 | grep "in_port=4" | ofctl_strip], [0], [dnl |
567 | n_packets=1, n_bytes=100, priority=1,ip,in_port=4 actions=drop | |
aaca4fe0 WT |
568 | ]) |
569 | ||
570 | dnl SLOW_ACTION: disable datapath truncate support | |
571 | dnl Repeat the test above, but exercise the SLOW_ACTION code path | |
572 | AT_CHECK([ovs-appctl dpif/disable-truncate], [0], | |
573 | [Datapath truncate action diabled | |
574 | ]) | |
575 | ||
576 | dnl SLOW_ACTION test1: check datapatch actions | |
577 | AT_CHECK([ovs-ofctl del-flows br0]) | |
578 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
579 | ||
aaca4fe0 WT |
580 | dnl SLOW_ACTION test2: check actual packet truncate |
581 | AT_CHECK([ovs-ofctl del-flows br0]) | |
582 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
583 | AT_CHECK([ovs-ofctl del-flows br-underlay]) | |
584 | AT_CHECK([ovs-ofctl add-flows br-underlay flows-underlay.txt]) | |
585 | ||
586 | dnl check tunnel push path, from at_ns1 to at_ns0 | |
a037f175 | 587 | NS_CHECK_EXEC([at_ns1], [nc $NC_EOF_OPT -u 10.1.1.1 1234 < payload200.bin]) |
aaca4fe0 WT |
588 | AT_CHECK([ovs-appctl revalidator/purge], [0]) |
589 | ||
590 | dnl Before truncation = ETH(14) + IP(20) + UDP(8) + 200 = 242B | |
591 | AT_CHECK([ovs-ofctl dump-flows br0 | grep "in_port=2" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
592 | n_bytes=242 | |
593 | ]) | |
594 | dnl After truncation = outer ETH(14) + outer IP(20) + GRE(4) + 100 = 138B | |
595 | AT_CHECK([ovs-ofctl dump-flows br-underlay | grep "in_port=LOCAL" | sed -n 's/.*\(n\_bytes=[[0-9]]*\).*/\1/p'], [0], [dnl | |
596 | n_bytes=138 | |
597 | ]) | |
598 | ||
599 | dnl check tunnel pop path, from at_ns0 to at_ns1 | |
a037f175 | 600 | NS_CHECK_EXEC([at_ns0], [nc $NC_EOF_OPT -u 10.1.1.2 5678 < payload200.bin]) |
aaca4fe0 WT |
601 | dnl After truncation = 100 byte at loopback device p2(4) |
602 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
32b0cc65 JS |
603 | AT_CHECK([ovs-ofctl dump-flows br0 | grep "in_port=4" | ofctl_strip], [0], [dnl |
604 | n_packets=1, n_bytes=100, priority=1,ip,in_port=4 actions=drop | |
aaca4fe0 WT |
605 | ]) |
606 | ||
607 | OVS_TRAFFIC_VSWITCHD_STOP | |
608 | AT_CLEANUP | |
609 | ||
ee8941ab JS |
610 | AT_BANNER([conntrack]) |
611 | ||
07659514 JS |
612 | AT_SETUP([conntrack - controller]) |
613 | CHECK_CONNTRACK() | |
cf7659b6 | 614 | OVS_TRAFFIC_VSWITCHD_START() |
daf4d3c1 | 615 | AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg ofproto_dpif_upcall:dbg]) |
07659514 JS |
616 | |
617 | ADD_NAMESPACES(at_ns0, at_ns1) | |
618 | ||
619 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
620 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
621 | ||
622 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
623 | AT_DATA([flows.txt], [dnl | |
624 | priority=1,action=drop | |
625 | priority=10,arp,action=normal | |
626 | priority=100,in_port=1,udp,action=ct(commit),controller | |
627 | priority=100,in_port=2,ct_state=-trk,udp,action=ct(table=0) | |
628 | priority=100,in_port=2,ct_state=+trk+est,udp,action=controller | |
629 | ]) | |
630 | ||
6cfa8ec3 | 631 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 JS |
632 | |
633 | AT_CAPTURE_FILE([ofctl_monitor.log]) | |
634 | AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log]) | |
635 | ||
636 | dnl Send an unsolicited reply from port 2. This should be dropped. | |
4573c42e | 637 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 ct\(table=0\) '50540000000a50540000000908004500001c000000000011a4cd0a0101020a0101010002000100080000']) |
07659514 JS |
638 | |
639 | dnl OK, now start a new connection from port 1. | |
4573c42e | 640 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 1 ct\(commit\),controller '50540000000a50540000000908004500001c000000000011a4cd0a0101010a0101020001000200080000']) |
07659514 JS |
641 | |
642 | dnl Now try a reply from port 2. | |
4573c42e | 643 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 ct\(table=0\) '50540000000a50540000000908004500001c000000000011a4cd0a0101020a0101010002000100080000']) |
07659514 JS |
644 | |
645 | dnl Check this output. We only see the latter two packets, not the first. | |
646 | AT_CHECK([cat ofctl_monitor.log], [0], [dnl | |
f274a047 | 647 | NXT_PACKET_IN2 (xid=0x0): total_len=42 in_port=1 (via action) data_len=42 (unbuffered) |
07659514 | 648 | udp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.1.1.1,nw_dst=10.1.1.2,nw_tos=0,nw_ecn=0,nw_ttl=0,tp_src=1,tp_dst=2 udp_csum:0 |
daf4d3c1 | 649 | NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=42 ct_state=est|rpl|trk,ct_nw_src=10.1.1.1,ct_nw_dst=10.1.1.2,ct_nw_proto=17,ct_tp_src=1,ct_tp_dst=2,in_port=2 (via action) data_len=42 (unbuffered) |
07659514 JS |
650 | udp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.1.1.2,nw_dst=10.1.1.1,nw_tos=0,nw_ecn=0,nw_ttl=0,tp_src=2,tp_dst=1 udp_csum:0 |
651 | ]) | |
652 | ||
653 | OVS_TRAFFIC_VSWITCHD_STOP | |
654 | AT_CLEANUP | |
655 | ||
a76a37ef JR |
656 | AT_SETUP([conntrack - force commit]) |
657 | CHECK_CONNTRACK() | |
658 | OVS_TRAFFIC_VSWITCHD_START() | |
659 | AT_CHECK([ovs-appctl vlog/set dpif:dbg dpif_netdev:dbg ofproto_dpif_upcall:dbg]) | |
660 | ||
661 | ADD_NAMESPACES(at_ns0, at_ns1) | |
662 | ||
663 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
664 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
665 | ||
666 | AT_DATA([flows.txt], [dnl | |
667 | priority=1,action=drop | |
668 | priority=10,arp,action=normal | |
669 | priority=100,in_port=1,udp,action=ct(commit),controller | |
670 | priority=100,in_port=2,ct_state=-trk,udp,action=ct(table=0) | |
671 | priority=100,in_port=2,ct_state=+trk+est,udp,action=ct(force,commit,table=1) | |
672 | table=1,in_port=2,ct_state=+trk,udp,action=controller | |
673 | ]) | |
674 | ||
675 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
676 | ||
677 | AT_CAPTURE_FILE([ofctl_monitor.log]) | |
678 | AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log]) | |
679 | ||
680 | dnl Send an unsolicited reply from port 2. This should be dropped. | |
681 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 "in_port=2 packet=50540000000a50540000000908004500001c000000000011a4cd0a0101020a0101010002000100080000 actions=resubmit(,0)"]) | |
682 | ||
683 | dnl OK, now start a new connection from port 1. | |
684 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 "in_port=1 packet=50540000000a50540000000908004500001c000000000011a4cd0a0101010a0101020001000200080000 actions=resubmit(,0)"]) | |
685 | ||
686 | dnl Now try a reply from port 2. | |
687 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 "in_port=2 packet=50540000000a50540000000908004500001c000000000011a4cd0a0101020a0101010002000100080000 actions=resubmit(,0)"]) | |
688 | ||
689 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
690 | ||
691 | dnl Check this output. We only see the latter two packets, not the first. | |
692 | AT_CHECK([cat ofctl_monitor.log], [0], [dnl | |
693 | NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=42 in_port=1 (via action) data_len=42 (unbuffered) | |
694 | udp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.1.1.1,nw_dst=10.1.1.2,nw_tos=0,nw_ecn=0,nw_ttl=0,tp_src=1,tp_dst=2 udp_csum:0 | |
695 | NXT_PACKET_IN2 (xid=0x0): table_id=1 cookie=0x0 total_len=42 ct_state=new|trk,ct_nw_src=10.1.1.2,ct_nw_dst=10.1.1.1,ct_nw_proto=17,ct_tp_src=2,ct_tp_dst=1,in_port=2 (via action) data_len=42 (unbuffered) | |
696 | udp,vlan_tci=0x0000,dl_src=50:54:00:00:00:09,dl_dst=50:54:00:00:00:0a,nw_src=10.1.1.2,nw_dst=10.1.1.1,nw_tos=0,nw_ecn=0,nw_ttl=0,tp_src=2,tp_dst=1 udp_csum:0 | |
697 | ]) | |
698 | ||
699 | dnl | |
700 | dnl Check that the directionality has been changed by force commit. | |
701 | dnl | |
702 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | grep "orig=.src=10\.1\.1\.2,"], [], [dnl | |
703 | udp,orig=(src=10.1.1.2,dst=10.1.1.1,sport=2,dport=1),reply=(src=10.1.1.1,dst=10.1.1.2,sport=1,dport=2) | |
704 | ]) | |
705 | ||
706 | OVS_TRAFFIC_VSWITCHD_STOP | |
707 | AT_CLEANUP | |
708 | ||
e5cf8cce DDP |
709 | AT_SETUP([conntrack - IPv4 ping]) |
710 | CHECK_CONNTRACK() | |
711 | OVS_TRAFFIC_VSWITCHD_START() | |
712 | ||
713 | ADD_NAMESPACES(at_ns0, at_ns1) | |
714 | ||
715 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
716 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
717 | ||
718 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
719 | AT_DATA([flows.txt], [dnl | |
720 | priority=1,action=drop | |
721 | priority=10,arp,action=normal | |
722 | priority=100,in_port=1,icmp,action=ct(commit),2 | |
723 | priority=100,in_port=2,icmp,ct_state=-trk,action=ct(table=0) | |
724 | priority=100,in_port=2,icmp,ct_state=+trk+est,action=1 | |
725 | ]) | |
726 | ||
727 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
728 | ||
729 | dnl Pings from ns0->ns1 should work fine. | |
730 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
731 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
732 | ]) | |
733 | ||
734 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
735 | icmp,orig=(src=10.1.1.1,dst=10.1.1.2,id=<cleared>,type=8,code=0),reply=(src=10.1.1.2,dst=10.1.1.1,id=<cleared>,type=0,code=0) | |
736 | ]) | |
737 | ||
738 | AT_CHECK([ovs-appctl dpctl/flush-conntrack]) | |
739 | ||
740 | dnl Pings from ns1->ns0 should fail. | |
741 | NS_CHECK_EXEC([at_ns1], [ping -q -c 3 -i 0.3 -w 2 10.1.1.1 | FORMAT_PING], [0], [dnl | |
742 | 7 packets transmitted, 0 received, 100% packet loss, time 0ms | |
743 | ]) | |
744 | ||
745 | OVS_TRAFFIC_VSWITCHD_STOP | |
746 | AT_CLEANUP | |
747 | ||
748 | AT_SETUP([conntrack - IPv6 ping]) | |
749 | CHECK_CONNTRACK() | |
750 | OVS_TRAFFIC_VSWITCHD_START() | |
751 | ||
752 | ADD_NAMESPACES(at_ns0, at_ns1) | |
753 | ||
754 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
755 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
756 | ||
757 | AT_DATA([flows.txt], [dnl | |
758 | ||
759 | dnl ICMPv6 echo request and reply go to table 1. The rest of the traffic goes | |
760 | dnl through normal action. | |
761 | table=0,priority=10,icmp6,icmp_type=128,action=goto_table:1 | |
762 | table=0,priority=10,icmp6,icmp_type=129,action=goto_table:1 | |
763 | table=0,priority=1,action=normal | |
764 | ||
765 | dnl Allow everything from ns0->ns1. Only allow return traffic from ns1->ns0. | |
766 | table=1,priority=100,in_port=1,icmp6,action=ct(commit),2 | |
767 | table=1,priority=100,in_port=2,icmp6,ct_state=-trk,action=ct(table=0) | |
768 | table=1,priority=100,in_port=2,icmp6,ct_state=+trk+est,action=1 | |
769 | table=1,priority=1,action=drop | |
770 | ]) | |
771 | ||
772 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
773 | ||
774 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) | |
775 | ||
027f7e84 DDP |
776 | dnl The above ping creates state in the connection tracker. We're not |
777 | dnl interested in that state. | |
778 | AT_CHECK([ovs-appctl dpctl/flush-conntrack]) | |
779 | ||
e5cf8cce DDP |
780 | dnl Pings from ns1->ns0 should fail. |
781 | NS_CHECK_EXEC([at_ns1], [ping6 -q -c 3 -i 0.3 -w 2 fc00::1 | FORMAT_PING], [0], [dnl | |
782 | 7 packets transmitted, 0 received, 100% packet loss, time 0ms | |
783 | ]) | |
784 | ||
785 | dnl Pings from ns0->ns1 should work fine. | |
786 | NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
787 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
788 | ]) | |
789 | ||
790 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl | |
791 | icmpv6,orig=(src=fc00::1,dst=fc00::2,id=<cleared>,type=128,code=0),reply=(src=fc00::2,dst=fc00::1,id=<cleared>,type=129,code=0) | |
792 | ]) | |
793 | ||
794 | OVS_TRAFFIC_VSWITCHD_STOP | |
795 | AT_CLEANUP | |
796 | ||
07659514 JS |
797 | AT_SETUP([conntrack - preserve registers]) |
798 | CHECK_CONNTRACK() | |
cf7659b6 | 799 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
800 | |
801 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
802 | ||
803 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
804 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
805 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
806 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
807 | ||
808 | dnl Allow any traffic from ns0->ns1, ns2->ns3. | |
809 | AT_DATA([flows.txt], [dnl | |
810 | priority=1,action=drop | |
811 | priority=10,arp,action=normal | |
812 | priority=10,icmp,action=normal | |
813 | priority=100,in_port=1,tcp,ct_state=-trk,action=ct(commit,table=0) | |
814 | priority=100,in_port=1,tcp,ct_state=+trk,action=2 | |
815 | priority=100,in_port=2,tcp,ct_state=-trk,action=ct(table=0) | |
816 | priority=100,in_port=2,tcp,ct_state=+trk,action=1 | |
817 | priority=100,in_port=3,tcp,ct_state=-trk,action=load:0->NXM_NX_REG0[[]],ct(table=0) | |
818 | priority=100,in_port=3,tcp,ct_state=+trk,reg0=0,action=load:1->NXM_NX_REG0[[]],ct(commit,table=0) | |
819 | priority=100,in_port=3,tcp,ct_state=+trk,reg0=1,action=4 | |
820 | priority=100,in_port=4,tcp,ct_state=-trk,action=ct(commit,table=0) | |
821 | priority=100,in_port=4,tcp,ct_state=+trk,action=3 | |
822 | ]) | |
823 | ||
6cfa8ec3 | 824 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 | 825 | |
7ed40afe JS |
826 | OVS_START_L7([at_ns1], [http]) |
827 | OVS_START_L7([at_ns3], [http]) | |
828 | ||
07659514 | 829 | dnl HTTP requests from p0->p1 should work fine. |
07659514 JS |
830 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
831 | ||
832 | dnl HTTP requests from p2->p3 should work fine. | |
07659514 JS |
833 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 --retry-connrefused -v -o wget1.log]) |
834 | ||
835 | OVS_TRAFFIC_VSWITCHD_STOP | |
836 | AT_CLEANUP | |
837 | ||
838 | AT_SETUP([conntrack - invalid]) | |
839 | CHECK_CONNTRACK() | |
cf7659b6 | 840 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
841 | |
842 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
843 | ||
844 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
845 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
846 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
847 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
848 | ||
849 | dnl Pass traffic from ns0->ns1 without committing, but attempt to track in | |
850 | dnl the opposite direction. This should fail. | |
851 | dnl Pass traffic from ns3->ns4 without committing, and this time match | |
852 | dnl invalid traffic and allow it through. | |
853 | AT_DATA([flows.txt], [dnl | |
854 | priority=1,action=drop | |
855 | priority=10,arp,action=normal | |
856 | priority=10,icmp,action=normal | |
857 | priority=100,in_port=1,tcp,action=ct(),2 | |
858 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0) | |
859 | priority=100,in_port=2,ct_state=+trk+new,tcp,action=1 | |
860 | priority=100,in_port=3,tcp,action=ct(),4 | |
861 | priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0) | |
862 | priority=100,in_port=4,ct_state=+trk+inv,tcp,action=3 | |
863 | priority=100,in_port=4,ct_state=+trk+new,tcp,action=3 | |
864 | ]) | |
865 | ||
6cfa8ec3 | 866 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 JS |
867 | |
868 | dnl We set up our rules to allow the request without committing. The return | |
869 | dnl traffic can't be identified, because the initial request wasn't committed. | |
870 | dnl For the first pair of ports, this means that the connection fails. | |
7ed40afe JS |
871 | OVS_START_L7([at_ns1], [http]) |
872 | OVS_START_L7([at_ns3], [http]) | |
07659514 JS |
873 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log], [4]) |
874 | ||
875 | dnl For the second pair, we allow packets from invalid connections, so it works. | |
07659514 JS |
876 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 --retry-connrefused -v -o wget1.log]) |
877 | ||
878 | OVS_TRAFFIC_VSWITCHD_STOP | |
879 | AT_CLEANUP | |
880 | ||
881 | AT_SETUP([conntrack - zones]) | |
882 | CHECK_CONNTRACK() | |
cf7659b6 | 883 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
884 | |
885 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
886 | ||
887 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
888 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
889 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
890 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
891 | ||
892 | dnl Allow any traffic from ns0->ns1. Allow return traffic, matching on zone. | |
893 | dnl For ns2->ns3, use a different zone and see that the match fails. | |
894 | AT_DATA([flows.txt], [dnl | |
895 | priority=1,action=drop | |
896 | priority=10,arp,action=normal | |
897 | priority=10,icmp,action=normal | |
898 | priority=100,in_port=1,tcp,action=ct(commit,zone=1),2 | |
899 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0,zone=1) | |
900 | priority=100,in_port=2,ct_state=+trk,ct_zone=1,tcp,action=1 | |
901 | priority=100,in_port=3,tcp,action=ct(commit,zone=2),4 | |
902 | priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0,zone=2) | |
903 | priority=100,in_port=4,ct_state=+trk,ct_zone=1,tcp,action=3 | |
904 | ]) | |
905 | ||
6cfa8ec3 | 906 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 | 907 | |
7ed40afe JS |
908 | OVS_START_L7([at_ns1], [http]) |
909 | OVS_START_L7([at_ns3], [http]) | |
910 | ||
07659514 | 911 | dnl HTTP requests from p0->p1 should work fine. |
07659514 JS |
912 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
913 | ||
ec3aa16c | 914 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
420c73b2 | 915 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) |
07659514 JS |
916 | ]) |
917 | ||
918 | dnl HTTP requests from p2->p3 should fail due to network failure. | |
919 | dnl Try 3 times, in 1 second intervals. | |
07659514 JS |
920 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4]) |
921 | ||
ec3aa16c | 922 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl |
420c73b2 | 923 | tcp,orig=(src=10.1.1.3,dst=10.1.1.4,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.4,dst=10.1.1.3,sport=<cleared>,dport=<cleared>),zone=2,protoinfo=(state=<cleared>) |
07659514 JS |
924 | ]) |
925 | ||
926 | OVS_TRAFFIC_VSWITCHD_STOP | |
927 | AT_CLEANUP | |
928 | ||
929 | AT_SETUP([conntrack - zones from field]) | |
930 | CHECK_CONNTRACK() | |
cf7659b6 | 931 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
932 | |
933 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
934 | ||
935 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
936 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
937 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
938 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
939 | ||
940 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
941 | AT_DATA([flows.txt], [dnl | |
942 | priority=1,action=drop | |
943 | priority=10,arp,action=normal | |
944 | priority=10,icmp,action=normal | |
945 | priority=100,in_port=1,tcp,action=load:0x1001->NXM_NX_REG0[[0..15]],ct(commit,zone=NXM_NX_REG0[[0..15]]),2 | |
946 | priority=100,in_port=2,ct_state=-trk,tcp,action=load:0x1001->NXM_NX_REG0[[0..15]],ct(table=0,zone=NXM_NX_REG0[[0..15]]) | |
947 | priority=100,in_port=2,ct_state=+trk,ct_zone=0x1001,tcp,action=1 | |
948 | priority=100,in_port=3,tcp,action=load:0x1002->NXM_NX_REG0[[0..15]],ct(commit,zone=NXM_NX_REG0[[0..15]]),4 | |
949 | priority=100,in_port=4,ct_state=-trk,tcp,action=load:0x1002->NXM_NX_REG0[[0..15]],ct(table=0,zone=NXM_NX_REG0[[0..15]]) | |
950 | priority=100,in_port=4,ct_state=+trk,ct_zone=0x1001,tcp,action=3 | |
951 | ]) | |
952 | ||
6cfa8ec3 | 953 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 | 954 | |
7ed40afe JS |
955 | OVS_START_L7([at_ns1], [http]) |
956 | OVS_START_L7([at_ns3], [http]) | |
957 | ||
07659514 | 958 | dnl HTTP requests from p0->p1 should work fine. |
07659514 JS |
959 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
960 | ||
ec3aa16c | 961 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
420c73b2 | 962 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=4097,protoinfo=(state=<cleared>) |
07659514 JS |
963 | ]) |
964 | ||
965 | dnl HTTP requests from p2->p3 should fail due to network failure. | |
966 | dnl Try 3 times, in 1 second intervals. | |
07659514 JS |
967 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4]) |
968 | ||
ec3aa16c | 969 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl |
420c73b2 | 970 | tcp,orig=(src=10.1.1.3,dst=10.1.1.4,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.4,dst=10.1.1.3,sport=<cleared>,dport=<cleared>),zone=4098,protoinfo=(state=<cleared>) |
07659514 JS |
971 | ]) |
972 | ||
973 | OVS_TRAFFIC_VSWITCHD_STOP | |
974 | AT_CLEANUP | |
975 | ||
976 | AT_SETUP([conntrack - multiple bridges]) | |
977 | CHECK_CONNTRACK() | |
978 | OVS_TRAFFIC_VSWITCHD_START( | |
cf7659b6 | 979 | [_ADD_BR([br1]) --\ |
07659514 JS |
980 | add-port br0 patch+ -- set int patch+ type=patch options:peer=patch- --\ |
981 | add-port br1 patch- -- set int patch- type=patch options:peer=patch+ --]) | |
982 | ||
983 | ADD_NAMESPACES(at_ns0, at_ns1) | |
984 | ||
985 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
986 | ADD_VETH(p1, at_ns1, br1, "10.1.1.2/24") | |
987 | ||
988 | dnl Allow any traffic from ns0->br1, allow established in reverse. | |
989 | AT_DATA([flows-br0.txt], [dnl | |
990 | priority=1,action=drop | |
991 | priority=10,arp,action=normal | |
992 | priority=10,icmp,action=normal | |
993 | priority=100,in_port=2,tcp,ct_state=-trk,action=ct(commit,zone=1),1 | |
994 | priority=100,in_port=1,tcp,ct_state=-trk,action=ct(table=0,zone=1) | |
995 | priority=100,in_port=1,tcp,ct_state=+trk+est,ct_zone=1,action=2 | |
996 | ]) | |
997 | ||
998 | dnl Allow any traffic from br0->ns1, allow established in reverse. | |
999 | AT_DATA([flows-br1.txt], [dnl | |
1000 | priority=1,action=drop | |
1001 | priority=10,arp,action=normal | |
1002 | priority=10,icmp,action=normal | |
1003 | priority=100,in_port=1,tcp,ct_state=-trk,action=ct(table=0,zone=2) | |
1004 | priority=100,in_port=1,tcp,ct_state=+trk+new,ct_zone=2,action=ct(commit,zone=2),2 | |
1005 | priority=100,in_port=1,tcp,ct_state=+trk+est,ct_zone=2,action=2 | |
1006 | priority=100,in_port=2,tcp,ct_state=-trk,action=ct(table=0,zone=2) | |
1007 | priority=100,in_port=2,tcp,ct_state=+trk+est,ct_zone=2,action=ct(commit,zone=2),1 | |
1008 | ]) | |
1009 | ||
6cfa8ec3 JR |
1010 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows-br0.txt]) |
1011 | AT_CHECK([ovs-ofctl --bundle add-flows br1 flows-br1.txt]) | |
07659514 JS |
1012 | |
1013 | dnl HTTP requests from p0->p1 should work fine. | |
7ed40afe | 1014 | OVS_START_L7([at_ns1], [http]) |
07659514 JS |
1015 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1016 | ||
1017 | OVS_TRAFFIC_VSWITCHD_STOP | |
1018 | AT_CLEANUP | |
1019 | ||
1020 | AT_SETUP([conntrack - multiple zones]) | |
1021 | CHECK_CONNTRACK() | |
cf7659b6 | 1022 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
1023 | |
1024 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1025 | ||
1026 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1027 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1028 | ||
1029 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
1030 | AT_DATA([flows.txt], [dnl | |
1031 | priority=1,action=drop | |
1032 | priority=10,arp,action=normal | |
1033 | priority=10,icmp,action=normal | |
1034 | priority=100,in_port=1,tcp,action=ct(commit,zone=1),ct(commit,zone=2),2 | |
1035 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0,zone=2) | |
1036 | priority=100,in_port=2,ct_state=+trk,ct_zone=2,tcp,action=1 | |
1037 | ]) | |
1038 | ||
6cfa8ec3 | 1039 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 | 1040 | |
7ed40afe JS |
1041 | OVS_START_L7([at_ns1], [http]) |
1042 | ||
07659514 | 1043 | dnl HTTP requests from p0->p1 should work fine. |
07659514 JS |
1044 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1045 | ||
1046 | dnl (again) HTTP requests from p0->p1 should work fine. | |
1047 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
1048 | ||
ec3aa16c | 1049 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
420c73b2 JR |
1050 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) |
1051 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=2,protoinfo=(state=<cleared>) | |
07659514 JS |
1052 | ]) |
1053 | ||
1054 | OVS_TRAFFIC_VSWITCHD_STOP | |
1055 | AT_CLEANUP | |
1056 | ||
0e27c629 JS |
1057 | AT_SETUP([conntrack - multiple namespaces, internal ports]) |
1058 | CHECK_CONNTRACK() | |
4573c42e | 1059 | CHECK_CONNTRACK_LOCAL_STACK() |
0e27c629 JS |
1060 | OVS_TRAFFIC_VSWITCHD_START( |
1061 | [set-fail-mode br0 secure -- ]) | |
1062 | ||
1063 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1064 | ||
1065 | ADD_INT(p0, at_ns0, br0, "10.1.1.1/24") | |
1066 | ADD_INT(p1, at_ns1, br0, "10.1.1.2/24") | |
1067 | ||
1068 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
1069 | dnl | |
1070 | dnl If skb->nfct is leaking from inside the namespace, this test will fail. | |
1071 | AT_DATA([flows.txt], [dnl | |
1072 | priority=1,action=drop | |
1073 | priority=10,arp,action=normal | |
1074 | priority=10,icmp,action=normal | |
1075 | priority=100,in_port=1,tcp,ct_state=-trk,action=ct(commit,zone=1),2 | |
1076 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0,zone=1) | |
1077 | priority=100,in_port=2,ct_state=+trk,ct_zone=1,tcp,action=1 | |
1078 | ]) | |
1079 | ||
1080 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
1081 | ||
7ed40afe JS |
1082 | OVS_START_L7([at_ns1], [http]) |
1083 | ||
0e27c629 | 1084 | dnl HTTP requests from p0->p1 should work fine. |
0e27c629 JS |
1085 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1086 | ||
1087 | dnl (again) HTTP requests from p0->p1 should work fine. | |
1088 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
1089 | ||
ec3aa16c | 1090 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
420c73b2 | 1091 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) |
0e27c629 JS |
1092 | ]) |
1093 | ||
1094 | OVS_TRAFFIC_VSWITCHD_STOP(["dnl | |
1095 | /ioctl(SIOCGIFINDEX) on .* device failed: No such device/d | |
1096 | /removing policing failed: No such device/d"]) | |
1097 | AT_CLEANUP | |
1098 | ||
8e53fe8c JS |
1099 | AT_SETUP([conntrack - ct_mark]) |
1100 | CHECK_CONNTRACK() | |
cf7659b6 | 1101 | OVS_TRAFFIC_VSWITCHD_START() |
8e53fe8c JS |
1102 | |
1103 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1104 | ||
1105 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1106 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1107 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
1108 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
1109 | ||
1110 | dnl Allow traffic between ns0<->ns1 using the ct_mark. | |
1111 | dnl Check that different marks do not match for traffic between ns2<->ns3. | |
1112 | AT_DATA([flows.txt], [dnl | |
1113 | priority=1,action=drop | |
1114 | priority=10,arp,action=normal | |
1115 | priority=10,icmp,action=normal | |
1116 | priority=100,in_port=1,tcp,action=ct(commit,exec(set_field:1->ct_mark)),2 | |
1117 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0) | |
1118 | priority=100,in_port=2,ct_state=+trk,ct_mark=1,tcp,action=1 | |
1119 | priority=100,in_port=3,tcp,action=ct(commit,exec(set_field:2->ct_mark)),4 | |
1120 | priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0) | |
1121 | priority=100,in_port=4,ct_state=+trk,ct_mark=1,tcp,action=3 | |
1122 | ]) | |
1123 | ||
6cfa8ec3 | 1124 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
8e53fe8c | 1125 | |
7ed40afe JS |
1126 | OVS_START_L7([at_ns1], [http]) |
1127 | OVS_START_L7([at_ns3], [http]) | |
1128 | ||
8e53fe8c | 1129 | dnl HTTP requests from p0->p1 should work fine. |
8e53fe8c | 1130 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
420c73b2 JR |
1131 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1132 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),mark=1,protoinfo=(state=<cleared>) | |
8e53fe8c JS |
1133 | ]) |
1134 | ||
1135 | dnl HTTP requests from p2->p3 should fail due to network failure. | |
1136 | dnl Try 3 times, in 1 second intervals. | |
8e53fe8c | 1137 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4]) |
ec3aa16c | 1138 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl |
420c73b2 | 1139 | tcp,orig=(src=10.1.1.3,dst=10.1.1.4,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.4,dst=10.1.1.3,sport=<cleared>,dport=<cleared>),mark=2,protoinfo=(state=<cleared>) |
8e53fe8c JS |
1140 | ]) |
1141 | ||
1142 | OVS_TRAFFIC_VSWITCHD_STOP | |
1143 | AT_CLEANUP | |
1144 | ||
4d182934 JS |
1145 | AT_SETUP([conntrack - ct_mark bit-fiddling]) |
1146 | CHECK_CONNTRACK() | |
1147 | OVS_TRAFFIC_VSWITCHD_START() | |
1148 | ||
1149 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1150 | ||
1151 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1152 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1153 | ||
1154 | dnl Allow traffic between ns0<->ns1 using the ct_mark. Return traffic should | |
1155 | dnl cause an additional bit to be set in the connection (and be allowed). | |
1156 | AT_DATA([flows.txt], [dnl | |
1157 | table=0,priority=1,action=drop | |
1158 | table=0,priority=10,arp,action=normal | |
1159 | table=0,priority=10,icmp,action=normal | |
1160 | table=0,priority=100,in_port=1,tcp,action=ct(table=1) | |
1161 | table=0,priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=1,commit,exec(set_field:0x2/0x6->ct_mark)) | |
723af132 JS |
1162 | table=1,in_port=1,ct_state=+new,tcp,action=ct(commit,exec(set_field:0x5/0x5->ct_mark)),2 |
1163 | table=1,in_port=1,ct_state=-new,tcp,action=2 | |
1164 | table=1,in_port=2,ct_state=+trk,ct_mark=3,tcp,action=1 | |
4d182934 JS |
1165 | ]) |
1166 | ||
1167 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1168 | ||
7ed40afe JS |
1169 | OVS_START_L7([at_ns1], [http]) |
1170 | ||
4d182934 | 1171 | dnl HTTP requests from p0->p1 should work fine. |
4d182934 JS |
1172 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1173 | ||
420c73b2 JR |
1174 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1175 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),mark=3,protoinfo=(state=<cleared>) | |
4d182934 JS |
1176 | ]) |
1177 | ||
1178 | OVS_TRAFFIC_VSWITCHD_STOP | |
1179 | AT_CLEANUP | |
1180 | ||
8e53fe8c JS |
1181 | AT_SETUP([conntrack - ct_mark from register]) |
1182 | CHECK_CONNTRACK() | |
cf7659b6 | 1183 | OVS_TRAFFIC_VSWITCHD_START() |
8e53fe8c JS |
1184 | |
1185 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1186 | ||
1187 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1188 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1189 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
1190 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
1191 | ||
1192 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
1193 | AT_DATA([flows.txt], [dnl | |
1194 | priority=1,action=drop | |
1195 | priority=10,arp,action=normal | |
1196 | priority=10,icmp,action=normal | |
1197 | priority=100,in_port=1,tcp,action=load:1->NXM_NX_REG0[[0..31]],ct(commit,exec(move:NXM_NX_REG0[[0..31]]->NXM_NX_CT_MARK[[]])),2 | |
1198 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0) | |
1199 | priority=100,in_port=2,ct_state=+trk,ct_mark=1,tcp,action=1 | |
1200 | priority=100,in_port=3,tcp,action=load:2->NXM_NX_REG0[[0..31]],ct(commit,exec(move:NXM_NX_REG0[[0..31]]->NXM_NX_CT_MARK[[]])),4 | |
1201 | priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0) | |
1202 | priority=100,in_port=4,ct_state=+trk,ct_mark=1,tcp,action=3 | |
1203 | ]) | |
1204 | ||
6cfa8ec3 | 1205 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
8e53fe8c | 1206 | |
7ed40afe JS |
1207 | OVS_START_L7([at_ns1], [http]) |
1208 | OVS_START_L7([at_ns3], [http]) | |
1209 | ||
8e53fe8c | 1210 | dnl HTTP requests from p0->p1 should work fine. |
8e53fe8c | 1211 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
420c73b2 JR |
1212 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1213 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),mark=1,protoinfo=(state=<cleared>) | |
8e53fe8c JS |
1214 | ]) |
1215 | ||
1216 | dnl HTTP requests from p2->p3 should fail due to network failure. | |
1217 | dnl Try 3 times, in 1 second intervals. | |
8e53fe8c | 1218 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4]) |
ec3aa16c | 1219 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl |
420c73b2 | 1220 | tcp,orig=(src=10.1.1.3,dst=10.1.1.4,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.4,dst=10.1.1.3,sport=<cleared>,dport=<cleared>),mark=2,protoinfo=(state=<cleared>) |
8e53fe8c JS |
1221 | ]) |
1222 | ||
1223 | OVS_TRAFFIC_VSWITCHD_STOP | |
1224 | AT_CLEANUP | |
1225 | ||
9daf2348 JS |
1226 | AT_SETUP([conntrack - ct_label]) |
1227 | CHECK_CONNTRACK() | |
cf7659b6 | 1228 | OVS_TRAFFIC_VSWITCHD_START() |
9daf2348 JS |
1229 | |
1230 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1231 | ||
1232 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1233 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1234 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
1235 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
1236 | ||
1237 | dnl Allow traffic between ns0<->ns1 using the ct_label. | |
1238 | dnl Check that different labels do not match for traffic between ns2<->ns3. | |
1239 | AT_DATA([flows.txt], [dnl | |
1240 | priority=1,action=drop | |
1241 | priority=10,arp,action=normal | |
1242 | priority=10,icmp,action=normal | |
1243 | priority=100,in_port=1,tcp,action=ct(commit,exec(set_field:0x0a000d000005000001->ct_label)),2 | |
1244 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0) | |
1245 | priority=100,in_port=2,ct_state=+trk,ct_label=0x0a000d000005000001,tcp,action=1 | |
1246 | priority=100,in_port=3,tcp,action=ct(commit,exec(set_field:0x2->ct_label)),4 | |
1247 | priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0) | |
1248 | priority=100,in_port=4,ct_state=+trk,ct_label=0x0a000d000005000001,tcp,action=3 | |
1249 | ]) | |
1250 | ||
6cfa8ec3 | 1251 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
9daf2348 | 1252 | |
7ed40afe JS |
1253 | OVS_START_L7([at_ns1], [http]) |
1254 | OVS_START_L7([at_ns3], [http]) | |
1255 | ||
9daf2348 | 1256 | dnl HTTP requests from p0->p1 should work fine. |
9daf2348 JS |
1257 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1258 | ||
1259 | dnl HTTP requests from p2->p3 should fail due to network failure. | |
1260 | dnl Try 3 times, in 1 second intervals. | |
9daf2348 JS |
1261 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4]) |
1262 | ||
1263 | OVS_TRAFFIC_VSWITCHD_STOP | |
1264 | AT_CLEANUP | |
1265 | ||
4d182934 JS |
1266 | AT_SETUP([conntrack - ct_label bit-fiddling]) |
1267 | CHECK_CONNTRACK() | |
1268 | OVS_TRAFFIC_VSWITCHD_START() | |
1269 | ||
1270 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1271 | ||
1272 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1273 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1274 | ||
1275 | dnl Allow traffic between ns0<->ns1 using the ct_labels. Return traffic should | |
1276 | dnl cause an additional bit to be set in the connection labels (and be allowed) | |
1277 | AT_DATA([flows.txt], [dnl | |
1278 | table=0,priority=1,action=drop | |
1279 | table=0,priority=10,arp,action=normal | |
1280 | table=0,priority=10,icmp,action=normal | |
1281 | table=0,priority=100,in_port=1,tcp,action=ct(table=1) | |
1282 | table=0,priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=1,commit,exec(set_field:0x200000000/0x200000004->ct_label)) | |
723af132 JS |
1283 | table=1,in_port=1,tcp,ct_state=+new,action=ct(commit,exec(set_field:0x5/0x5->ct_label)),2 |
1284 | table=1,in_port=1,tcp,ct_state=-new,action=2 | |
1285 | table=1,in_port=2,ct_state=+trk,ct_label=0x200000001,tcp,action=1 | |
4d182934 JS |
1286 | ]) |
1287 | ||
1288 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1289 | ||
7ed40afe JS |
1290 | OVS_START_L7([at_ns1], [http]) |
1291 | ||
4d182934 | 1292 | dnl HTTP requests from p0->p1 should work fine. |
4d182934 JS |
1293 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1294 | ||
420c73b2 JR |
1295 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1296 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),labels=0x200000001,protoinfo=(state=<cleared>) | |
4d182934 JS |
1297 | ]) |
1298 | ||
1299 | OVS_TRAFFIC_VSWITCHD_STOP | |
1300 | AT_CLEANUP | |
1301 | ||
f2d105b5 JS |
1302 | AT_SETUP([conntrack - ct metadata, multiple zones]) |
1303 | CHECK_CONNTRACK() | |
1304 | OVS_TRAFFIC_VSWITCHD_START() | |
1305 | ||
1306 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1307 | ||
1308 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1309 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1310 | ||
1311 | dnl Allow traffic between ns0<->ns1 using the ct_mark and ct_labels in zone=1, | |
1312 | dnl but do *not* set any of these for the ct() in zone=2. Traffic should pass, | |
1313 | dnl and we should see that the conntrack entries only apply the ct_mark and | |
1314 | dnl ct_labels to the connection in zone=1. | |
1315 | AT_DATA([flows.txt], [dnl | |
1316 | table=0,priority=1,action=drop | |
1317 | table=0,priority=10,arp,action=normal | |
1318 | table=0,priority=10,icmp,action=normal | |
1319 | table=0,priority=100,in_port=1,tcp,action=ct(zone=1,table=1) | |
1320 | table=0,priority=100,in_port=2,ct_state=-trk,tcp,action=ct(zone=1,table=1,commit,exec(set_field:0x200000000/0x200000004->ct_label,set_field:0x2/0x6->ct_mark)) | |
723af132 JS |
1321 | table=1,in_port=1,tcp,ct_state=+new,action=ct(zone=1,commit,exec(set_field:0x5/0x5->ct_label,set_field:0x5/0x5->ct_mark)),ct(commit,zone=2),2 |
1322 | table=1,in_port=1,tcp,ct_state=-new,action=ct(zone=2),2 | |
1323 | table=1,in_port=2,tcp,action=ct(zone=2),1 | |
f2d105b5 JS |
1324 | ]) |
1325 | ||
1326 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1327 | ||
7ed40afe JS |
1328 | OVS_START_L7([at_ns1], [http]) |
1329 | ||
f2d105b5 | 1330 | dnl HTTP requests from p0->p1 should work fine. |
f2d105b5 JS |
1331 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1332 | ||
420c73b2 JR |
1333 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1334 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,mark=3,labels=0x200000001,protoinfo=(state=<cleared>) | |
1335 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=2,protoinfo=(state=<cleared>) | |
f2d105b5 JS |
1336 | ]) |
1337 | ||
1338 | OVS_TRAFFIC_VSWITCHD_STOP | |
1339 | AT_CLEANUP | |
1340 | ||
8e53fe8c | 1341 | AT_SETUP([conntrack - ICMP related]) |
9c1ab985 | 1342 | AT_SKIP_IF([test $HAVE_NC = no]) |
8e53fe8c | 1343 | CHECK_CONNTRACK() |
cf7659b6 | 1344 | OVS_TRAFFIC_VSWITCHD_START() |
8e53fe8c JS |
1345 | |
1346 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1347 | ||
1348 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1349 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1350 | ||
1351 | dnl Allow UDP traffic from ns0->ns1. Only allow related ICMP responses back. | |
1352 | AT_DATA([flows.txt], [dnl | |
1353 | priority=1,action=drop | |
1354 | priority=10,arp,action=normal | |
1355 | priority=100,in_port=1,udp,action=ct(commit,exec(set_field:1->ct_mark)),2 | |
1356 | priority=100,in_port=2,icmp,ct_state=-trk,action=ct(table=0) | |
1357 | priority=100,in_port=2,icmp,ct_state=+trk+rel,ct_mark=1,action=1 | |
1358 | ]) | |
1359 | ||
6cfa8ec3 | 1360 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
8e53fe8c | 1361 | |
bde2e7b5 | 1362 | dnl UDP packets from ns0->ns1 should solicit "destination unreachable" response. |
b54971f7 | 1363 | NS_CHECK_EXEC([at_ns0], [bash -c "echo a | nc $NC_EOF_OPT -u 10.1.1.2 10000"]) |
8e53fe8c JS |
1364 | |
1365 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
1366 | AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort | grep -v drop], [0], [dnl | |
1367 | n_packets=1, n_bytes=44, priority=100,udp,in_port=1 actions=ct(commit,exec(load:0x1->NXM_NX_CT_MARK[[]])),output:2 | |
1368 | n_packets=1, n_bytes=72, priority=100,ct_state=+rel+trk,ct_mark=0x1,icmp,in_port=2 actions=output:1 | |
1369 | n_packets=1, n_bytes=72, priority=100,ct_state=-trk,icmp,in_port=2 actions=ct(table=0) | |
bde2e7b5 | 1370 | n_packets=2, n_bytes=84, priority=10,arp actions=NORMAL |
8e53fe8c JS |
1371 | NXST_FLOW reply: |
1372 | ]) | |
1373 | ||
1374 | OVS_TRAFFIC_VSWITCHD_STOP | |
1375 | AT_CLEANUP | |
1376 | ||
07659514 JS |
1377 | AT_SETUP([conntrack - ICMP related 2]) |
1378 | CHECK_CONNTRACK() | |
cf7659b6 | 1379 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
1380 | |
1381 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1382 | ||
1383 | ADD_VETH(p0, at_ns0, br0, "172.16.0.1/24") | |
1384 | ADD_VETH(p1, at_ns1, br0, "172.16.0.2/24") | |
1385 | ||
1386 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
1387 | AT_DATA([flows.txt], [dnl | |
5c2e106b DDP |
1388 | table=0,ip,action=ct(commit,table=1) |
1389 | table=1,ip,action=controller | |
07659514 JS |
1390 | ]) |
1391 | ||
6cfa8ec3 | 1392 | AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows.txt]) |
07659514 JS |
1393 | |
1394 | AT_CAPTURE_FILE([ofctl_monitor.log]) | |
1395 | AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log]) | |
1396 | ||
1397 | dnl 1. Send an ICMP port unreach reply for port 8738, without any previous request | |
5c2e106b | 1398 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 resubmit\(,0\) 'f64c473528c9c6f54ecb72db080045c0003d2e8700004001f351ac100004ac1000030303da490000000045000021317040004011b138ac100003ac10000411112222000d20966369616f0a']) |
07659514 JS |
1399 | |
1400 | dnl 2. Send and UDP packet to port 5555 | |
5c2e106b | 1401 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 1 resubmit\(,0\) 'c6f94ecb72dbe64c473528c9080045000021317040004011b138ac100001ac100002a28e15b3000d20966369616f0a']) |
07659514 JS |
1402 | |
1403 | dnl 3. Send an ICMP port unreach reply for port 5555, related to the first packet | |
5c2e106b | 1404 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 resubmit\(,0\) 'e64c473528c9c6f94ecb72db080045c0003d2e8700004001f355ac100002ac1000010303553f0000000045000021317040004011b138ac100001ac100002a28e15b3000d20966369616f0a']) |
07659514 JS |
1405 | |
1406 | dnl Check this output. We only see the latter two packets, not the first. | |
1407 | AT_CHECK([cat ofctl_monitor.log], [0], [dnl | |
5c2e106b DDP |
1408 | NXT_PACKET_IN2 (xid=0x0): table_id=1 cookie=0x0 total_len=75 ct_state=inv|trk,in_port=2 (via action) data_len=75 (unbuffered) |
1409 | icmp,vlan_tci=0x0000,dl_src=c6:f5:4e:cb:72:db,dl_dst=f6:4c:47:35:28:c9,nw_src=172.16.0.4,nw_dst=172.16.0.3,nw_tos=192,nw_ecn=0,nw_ttl=64,icmp_type=3,icmp_code=3 icmp_csum:da49 | |
daf4d3c1 | 1410 | NXT_PACKET_IN2 (xid=0x0): table_id=1 cookie=0x0 total_len=47 ct_state=new|trk,ct_nw_src=172.16.0.1,ct_nw_dst=172.16.0.2,ct_nw_proto=17,ct_tp_src=41614,ct_tp_dst=5555,in_port=1 (via action) data_len=47 (unbuffered) |
07659514 | 1411 | udp,vlan_tci=0x0000,dl_src=e6:4c:47:35:28:c9,dl_dst=c6:f9:4e:cb:72:db,nw_src=172.16.0.1,nw_dst=172.16.0.2,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=41614,tp_dst=5555 udp_csum:2096 |
daf4d3c1 | 1412 | NXT_PACKET_IN2 (xid=0x0): table_id=1 cookie=0x0 total_len=75 ct_state=rel|rpl|trk,ct_nw_src=172.16.0.1,ct_nw_dst=172.16.0.2,ct_nw_proto=17,ct_tp_src=41614,ct_tp_dst=5555,in_port=2 (via action) data_len=75 (unbuffered) |
07659514 JS |
1413 | icmp,vlan_tci=0x0000,dl_src=c6:f9:4e:cb:72:db,dl_dst=e6:4c:47:35:28:c9,nw_src=172.16.0.2,nw_dst=172.16.0.1,nw_tos=192,nw_ecn=0,nw_ttl=64,icmp_type=3,icmp_code=3 icmp_csum:553f |
1414 | ]) | |
1415 | ||
5c2e106b DDP |
1416 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(172.16.0.1)], [0], [dnl |
1417 | udp,orig=(src=172.16.0.1,dst=172.16.0.2,sport=<cleared>,dport=<cleared>),reply=(src=172.16.0.2,dst=172.16.0.1,sport=<cleared>,dport=<cleared>) | |
1418 | ]) | |
1419 | ||
1420 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(172.16.0.3)], [0], [dnl | |
1421 | ]) | |
1422 | ||
07659514 JS |
1423 | OVS_TRAFFIC_VSWITCHD_STOP |
1424 | AT_CLEANUP | |
d787ad39 | 1425 | |
daf4d3c1 | 1426 | AT_SETUP([conntrack - IPv4 fragmentation]) |
d787ad39 | 1427 | CHECK_CONNTRACK() |
1d768544 | 1428 | CHECK_CONNTRACK_FRAG() |
cf7659b6 | 1429 | OVS_TRAFFIC_VSWITCHD_START() |
27130224 AZ |
1430 | |
1431 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1432 | ||
1433 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1434 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1435 | ||
1436 | dnl Sending ping through conntrack | |
1437 | AT_DATA([flows.txt], [dnl | |
1438 | priority=1,action=drop | |
1439 | priority=10,arp,action=normal | |
1440 | priority=100,in_port=1,icmp,action=ct(commit,zone=9),2 | |
1441 | priority=100,in_port=2,ct_state=-trk,icmp,action=ct(table=0,zone=9) | |
1442 | priority=100,in_port=2,ct_state=+trk+est-new,icmp,action=1 | |
1443 | ]) | |
1444 | ||
6cfa8ec3 | 1445 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
27130224 | 1446 | |
27130224 AZ |
1447 | dnl Ipv4 fragmentation connectivity check. |
1448 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
1449 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1450 | ]) | |
1451 | ||
1452 | dnl Ipv4 larger fragmentation connectivity check. | |
1453 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
1454 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1455 | ]) | |
1456 | ||
1457 | OVS_TRAFFIC_VSWITCHD_STOP | |
1458 | AT_CLEANUP | |
1459 | ||
0cf28088 JS |
1460 | AT_SETUP([conntrack - IPv4 fragmentation expiry]) |
1461 | CHECK_CONNTRACK() | |
4573c42e | 1462 | CHECK_CONNTRACK_FRAG() |
0cf28088 JS |
1463 | OVS_TRAFFIC_VSWITCHD_START() |
1464 | ||
1465 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1466 | ||
1467 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1468 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1469 | ||
1470 | AT_DATA([flows.txt], [dnl | |
1471 | priority=1,action=drop | |
1472 | priority=10,arp,action=normal | |
1473 | ||
1474 | dnl Only allow non-fragmented messages and 1st fragments of each message | |
1475 | priority=100,in_port=1,icmp,ip_frag=no,action=ct(commit,zone=9),2 | |
1476 | priority=100,in_port=1,icmp,ip_frag=firstaction=ct(commit,zone=9),2 | |
1477 | priority=100,in_port=2,ct_state=-trk,icmp,action=ct(table=0,zone=9) | |
1478 | priority=100,in_port=2,ct_state=+trk+est-new,icmp,action=1 | |
1479 | ]) | |
1480 | ||
1481 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1482 | ||
0cf28088 JS |
1483 | dnl Ipv4 fragmentation connectivity check. |
1484 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 1 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
1485 | 7 packets transmitted, 0 received, 100% packet loss, time 0ms | |
1486 | ]) | |
1487 | ||
1488 | OVS_TRAFFIC_VSWITCHD_STOP | |
1489 | AT_CLEANUP | |
1490 | ||
27130224 AZ |
1491 | AT_SETUP([conntrack - IPv4 fragmentation + vlan]) |
1492 | CHECK_CONNTRACK() | |
4573c42e | 1493 | CHECK_CONNTRACK_FRAG() |
cf7659b6 | 1494 | OVS_TRAFFIC_VSWITCHD_START() |
27130224 AZ |
1495 | |
1496 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1497 | ||
1498 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1499 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1500 | ADD_VLAN(p0, at_ns0, 100, "10.2.2.1/24") | |
1501 | ADD_VLAN(p1, at_ns1, 100, "10.2.2.2/24") | |
1502 | ||
1503 | dnl Sending ping through conntrack | |
1504 | AT_DATA([flows.txt], [dnl | |
1505 | priority=1,action=drop | |
1506 | priority=10,arp,action=normal | |
1507 | priority=100,in_port=1,icmp,action=ct(commit,zone=9),2 | |
1508 | priority=100,in_port=2,ct_state=-trk,icmp,action=ct(table=0,zone=9) | |
1509 | priority=100,in_port=2,ct_state=+trk+est-new,icmp,action=1 | |
1510 | ]) | |
1511 | ||
6cfa8ec3 | 1512 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
27130224 | 1513 | |
27130224 AZ |
1514 | dnl Ipv4 fragmentation connectivity check. |
1515 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
1516 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1517 | ]) | |
1518 | ||
1519 | dnl Ipv4 larger fragmentation connectivity check. | |
1520 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
1521 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1522 | ]) | |
1523 | ||
1524 | OVS_TRAFFIC_VSWITCHD_STOP | |
1525 | AT_CLEANUP | |
1526 | ||
2526a3dc EG |
1527 | AT_SETUP([conntrack - IPv4 fragmentation + cvlan]) |
1528 | CHECK_CONNTRACK() | |
1529 | CHECK_CONNTRACK_FRAG() | |
1530 | OVS_TRAFFIC_VSWITCHD_START([set Open_vSwitch . other_config:vlan-limit=0]) | |
1531 | OVS_CHECK_8021AD() | |
1532 | ||
1533 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1534 | ||
1535 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1536 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1537 | ||
1538 | ADD_SVLAN(p0, at_ns0, 4094, "10.255.2.1/24") | |
1539 | ADD_SVLAN(p1, at_ns1, 4094, "10.255.2.2/24") | |
1540 | ||
1541 | ADD_CVLAN(p0.4094, at_ns0, 100, "10.2.2.1/24") | |
1542 | ADD_CVLAN(p1.4094, at_ns1, 100, "10.2.2.2/24") | |
1543 | ||
1544 | dnl Sending ping through conntrack | |
1545 | AT_DATA([flows.txt], [dnl | |
1546 | priority=1,action=drop | |
1547 | priority=10,arp,action=normal | |
1548 | priority=100,in_port=1,icmp,action=ct(commit,zone=9),2 | |
1549 | priority=100,in_port=2,ct_state=-trk,icmp,action=ct(table=0,zone=9) | |
1550 | priority=100,in_port=2,ct_state=+trk+est-new,icmp,action=1 | |
1551 | ]) | |
1552 | ||
1553 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1554 | ||
1555 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping -c 1 10.2.2.2]) | |
1556 | ||
1557 | dnl Ipv4 fragmentation connectivity check. | |
1558 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
1559 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1560 | ]) | |
1561 | ||
1562 | dnl Ipv4 fragmentation connectivity check. (outer svlan) | |
1563 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.255.2.2 | FORMAT_PING], [0], [dnl | |
1564 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1565 | ]) | |
1566 | ||
1567 | dnl Ipv4 larger fragmentation connectivity check. | |
1568 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
1569 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1570 | ]) | |
1571 | ||
1572 | dnl Ipv4 larger fragmentation connectivity check. (outer svlan) | |
1573 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.255.2.2 | FORMAT_PING], [0], [dnl | |
1574 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1575 | ]) | |
1576 | ||
1577 | OVS_TRAFFIC_VSWITCHD_STOP | |
1578 | AT_CLEANUP | |
1579 | ||
27130224 AZ |
1580 | AT_SETUP([conntrack - IPv6 fragmentation]) |
1581 | CHECK_CONNTRACK() | |
4573c42e | 1582 | CHECK_CONNTRACK_FRAG() |
cf7659b6 | 1583 | OVS_TRAFFIC_VSWITCHD_START() |
27130224 AZ |
1584 | |
1585 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1586 | ||
1587 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
1588 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
1589 | ||
1590 | dnl Sending ping through conntrack | |
1591 | AT_DATA([flows.txt], [dnl | |
1592 | priority=1,action=drop | |
1593 | priority=10,in_port=1,ipv6,action=ct(commit,zone=9),2 | |
1594 | priority=10,in_port=2,ct_state=-trk,ipv6,action=ct(table=0,zone=9) | |
1595 | priority=10,in_port=2,ct_state=+trk+est-new,ipv6,action=1 | |
1596 | priority=100,icmp6,icmp_type=135,action=normal | |
1597 | priority=100,icmp6,icmp_type=136,action=normal | |
1598 | ]) | |
1599 | ||
6cfa8ec3 | 1600 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
27130224 | 1601 | |
c10840ff JS |
1602 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
1603 | dnl waiting, we get occasional failures due to the following error: | |
27130224 | 1604 | dnl "connect: Cannot assign requested address" |
c10840ff | 1605 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) |
27130224 | 1606 | |
221a2668 | 1607 | dnl Ipv6 fragmentation connectivity check. |
27130224 AZ |
1608 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl |
1609 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1610 | ]) | |
1611 | ||
221a2668 | 1612 | dnl Ipv6 larger fragmentation connectivity check. |
27130224 AZ |
1613 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl |
1614 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1615 | ]) | |
1616 | ||
1617 | OVS_TRAFFIC_VSWITCHD_STOP | |
1618 | AT_CLEANUP | |
1619 | ||
0cf28088 JS |
1620 | AT_SETUP([conntrack - IPv6 fragmentation expiry]) |
1621 | CHECK_CONNTRACK() | |
4573c42e | 1622 | CHECK_CONNTRACK_FRAG() |
0cf28088 JS |
1623 | OVS_TRAFFIC_VSWITCHD_START() |
1624 | ||
1625 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1626 | ||
1627 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
1628 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
1629 | ||
1630 | AT_DATA([flows.txt], [dnl | |
1631 | priority=1,action=drop | |
1632 | ||
1633 | dnl Only allow non-fragmented messages and 1st fragments of each message | |
1634 | priority=10,in_port=1,ipv6,ip_frag=first,action=ct(commit,zone=9),2 | |
1635 | priority=10,in_port=1,ipv6,ip_frag=no,action=ct(commit,zone=9),2 | |
1636 | priority=10,in_port=2,ct_state=-trk,ipv6,action=ct(table=0,zone=9) | |
1637 | priority=10,in_port=2,ct_state=+trk+est-new,ipv6,action=1 | |
1638 | ||
1639 | dnl Neighbour Discovery | |
1640 | priority=100,icmp6,icmp_type=135,action=normal | |
1641 | priority=100,icmp6,icmp_type=136,action=normal | |
1642 | ]) | |
1643 | ||
1644 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1645 | ||
c10840ff JS |
1646 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
1647 | dnl waiting, we get occasional failures due to the following error: | |
0cf28088 | 1648 | dnl "connect: Cannot assign requested address" |
c10840ff | 1649 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) |
0cf28088 | 1650 | |
0cf28088 JS |
1651 | dnl Send an IPv6 fragment. Some time later, it should expire. |
1652 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 1 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
1653 | 7 packets transmitted, 0 received, 100% packet loss, time 0ms | |
1654 | ]) | |
1655 | ||
1656 | dnl At this point, the kernel will either crash or everything is OK. | |
1657 | ||
1658 | OVS_TRAFFIC_VSWITCHD_STOP | |
1659 | AT_CLEANUP | |
1660 | ||
27130224 AZ |
1661 | AT_SETUP([conntrack - IPv6 fragmentation + vlan]) |
1662 | CHECK_CONNTRACK() | |
4573c42e | 1663 | CHECK_CONNTRACK_FRAG() |
cf7659b6 | 1664 | OVS_TRAFFIC_VSWITCHD_START() |
27130224 AZ |
1665 | |
1666 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1667 | ||
1668 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
1669 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
1670 | ||
1671 | ADD_VLAN(p0, at_ns0, 100, "fc00:1::3/96") | |
1672 | ADD_VLAN(p1, at_ns1, 100, "fc00:1::4/96") | |
1673 | ||
1674 | dnl Sending ping through conntrack | |
1675 | AT_DATA([flows.txt], [dnl | |
1676 | priority=1,action=drop | |
1677 | priority=10,in_port=1,ipv6,action=ct(commit,zone=9),2 | |
1678 | priority=10,in_port=2,ct_state=-trk,ipv6,action=ct(table=0,zone=9) | |
1679 | priority=10,in_port=2,ct_state=+trk+est-new,ipv6,action=1 | |
1680 | priority=100,icmp6,icmp_type=135,action=normal | |
1681 | priority=100,icmp6,icmp_type=136,action=normal | |
1682 | ]) | |
1683 | ||
6cfa8ec3 | 1684 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
27130224 | 1685 | |
c10840ff JS |
1686 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
1687 | dnl waiting, we get occasional failures due to the following error: | |
27130224 | 1688 | dnl "connect: Cannot assign requested address" |
c10840ff | 1689 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) |
27130224 | 1690 | |
27130224 AZ |
1691 | dnl Ipv4 fragmentation connectivity check. |
1692 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00:1::4 | FORMAT_PING], [0], [dnl | |
1693 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1694 | ]) | |
1695 | ||
1696 | dnl Ipv4 larger fragmentation connectivity check. | |
1697 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00:1::4 | FORMAT_PING], [0], [dnl | |
1698 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1699 | ]) | |
1700 | ||
1701 | OVS_TRAFFIC_VSWITCHD_STOP | |
1702 | AT_CLEANUP | |
1703 | ||
2526a3dc EG |
1704 | AT_SETUP([conntrack - IPv6 fragmentation + cvlan]) |
1705 | CHECK_CONNTRACK() | |
1706 | CHECK_CONNTRACK_FRAG() | |
1707 | OVS_TRAFFIC_VSWITCHD_START([set Open_vSwitch . other_config:vlan-limit=0]) | |
1708 | OVS_CHECK_8021AD() | |
1709 | ||
1710 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1711 | ||
1712 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
1713 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
1714 | ||
1715 | ADD_SVLAN(p0, at_ns0, 4094, "fc00:ffff::3/96") | |
1716 | ADD_SVLAN(p1, at_ns1, 4094, "fc00:ffff::4/96") | |
1717 | ||
1718 | ADD_CVLAN(p0.4094, at_ns0, 100, "fc00:1::3/96") | |
1719 | ADD_CVLAN(p1.4094, at_ns1, 100, "fc00:1::4/96") | |
1720 | ||
1721 | dnl Sending ping through conntrack | |
1722 | AT_DATA([flows.txt], [dnl | |
1723 | priority=1,action=drop | |
1724 | priority=10,in_port=1,ipv6,action=ct(commit,zone=9),2 | |
1725 | priority=10,in_port=2,ct_state=-trk,ipv6,action=ct(table=0,zone=9) | |
1726 | priority=10,in_port=2,ct_state=+trk+est-new,ipv6,action=1 | |
1727 | priority=100,icmp6,icmp_type=135,action=normal | |
1728 | priority=100,icmp6,icmp_type=136,action=normal | |
1729 | ]) | |
1730 | ||
1731 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1732 | ||
1733 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00:1::4]) | |
1734 | ||
1735 | dnl Ipv6 fragmentation connectivity check. | |
1736 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00:1::4 | FORMAT_PING], [0], [dnl | |
1737 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1738 | ]) | |
1739 | ||
1740 | dnl Ipv6 fragmentation connectivity check. (outer svlan) | |
1741 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00:ffff::4 | FORMAT_PING], [0], [dnl | |
1742 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1743 | ]) | |
1744 | ||
1745 | dnl Ipv6 larger fragmentation connectivity check. | |
1746 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00:1::4 | FORMAT_PING], [0], [dnl | |
1747 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1748 | ]) | |
1749 | ||
1750 | dnl Ipv6 larger fragmentation connectivity check. (outer svlan) | |
1751 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00:ffff::4 | FORMAT_PING], [0], [dnl | |
1752 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1753 | ]) | |
1754 | ||
1755 | OVS_TRAFFIC_VSWITCHD_STOP | |
1756 | AT_CLEANUP | |
1757 | ||
27130224 | 1758 | AT_SETUP([conntrack - Fragmentation over vxlan]) |
dfb21e96 | 1759 | OVS_CHECK_VXLAN() |
27130224 | 1760 | CHECK_CONNTRACK() |
4573c42e | 1761 | CHECK_CONNTRACK_FRAG() |
27130224 | 1762 | |
cf7659b6 JR |
1763 | OVS_TRAFFIC_VSWITCHD_START() |
1764 | ADD_BR([br-underlay]) | |
1765 | AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"]) | |
1766 | ||
27130224 AZ |
1767 | ADD_NAMESPACES(at_ns0) |
1768 | ||
1769 | dnl Sending ping through conntrack | |
1770 | AT_DATA([flows.txt], [dnl | |
1771 | priority=1,action=drop | |
1772 | priority=10,arp,action=normal | |
1773 | priority=100,in_port=1,icmp,action=ct(commit,zone=9),LOCAL | |
3a9eb803 | 1774 | priority=100,in_port=LOCAL,icmp,action=ct(table=1,zone=9) |
723af132 | 1775 | table=1,in_port=LOCAL,ct_state=+trk+est,icmp,action=1 |
27130224 AZ |
1776 | ]) |
1777 | ||
6cfa8ec3 | 1778 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
27130224 AZ |
1779 | |
1780 | dnl Set up underlay link from host into the namespace using veth pair. | |
1781 | ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24") | |
1782 | AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"]) | |
1783 | AT_CHECK([ip link set dev br-underlay up]) | |
1784 | ||
1785 | dnl Set up tunnel endpoints on OVS outside the namespace and with a native | |
1786 | dnl linux device inside the namespace. | |
6e3a764c | 1787 | ADD_OVS_TUNNEL([vxlan], [br0], [at_vxlan0], [172.31.1.1], [10.1.1.100/24]) |
27130224 AZ |
1788 | ADD_NATIVE_TUNNEL([vxlan], [at_vxlan1], [at_ns0], [172.31.1.100], [10.1.1.1/24], |
1789 | [id 0 dstport 4789]) | |
1790 | ||
1791 | dnl First, check the underlay | |
1792 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl | |
1793 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1794 | ]) | |
1795 | ||
1796 | dnl Okay, now check the overlay with different packet sizes | |
1797 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
1798 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1799 | ]) | |
1800 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
1801 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1802 | ]) | |
1803 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
1804 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1805 | ]) | |
1806 | ||
1807 | OVS_TRAFFIC_VSWITCHD_STOP | |
1808 | AT_CLEANUP | |
c4e34c61 | 1809 | |
84f646df | 1810 | AT_SETUP([conntrack - IPv6 Fragmentation over vxlan]) |
a9f70f3d | 1811 | OVS_CHECK_VXLAN() |
84f646df | 1812 | CHECK_CONNTRACK() |
4573c42e | 1813 | CHECK_CONNTRACK_FRAG() |
84f646df JS |
1814 | |
1815 | OVS_TRAFFIC_VSWITCHD_START() | |
1816 | ADD_BR([br-underlay]) | |
1817 | AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"]) | |
1818 | ||
1819 | ADD_NAMESPACES(at_ns0) | |
1820 | ||
1821 | dnl Sending ping through conntrack | |
1822 | AT_DATA([flows.txt], [dnl | |
1823 | priority=1,action=drop | |
1824 | priority=100,in_port=1,ipv6,action=ct(commit,zone=9),LOCAL | |
1825 | priority=100,in_port=LOCAL,ipv6,action=ct(table=1,zone=9) | |
723af132 | 1826 | table=1,in_port=LOCAL,ct_state=+trk+est,ipv6,action=1 |
84f646df JS |
1827 | |
1828 | dnl Neighbour Discovery | |
1829 | priority=1000,icmp6,icmp_type=135,action=normal | |
1830 | priority=1000,icmp6,icmp_type=136,action=normal | |
1831 | ]) | |
1832 | ||
1833 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1834 | ||
1835 | dnl Set up underlay link from host into the namespace using veth pair. | |
1836 | ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24") | |
1837 | AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"]) | |
1838 | AT_CHECK([ip link set dev br-underlay up]) | |
1839 | ||
1840 | dnl Set up tunnel endpoints on OVS outside the namespace and with a native | |
1841 | dnl linux device inside the namespace. | |
6e3a764c | 1842 | ADD_OVS_TUNNEL([vxlan], [br0], [at_vxlan0], [172.31.1.1], ["fc00::2/96"]) |
84f646df JS |
1843 | ADD_NATIVE_TUNNEL([vxlan], [at_vxlan1], [at_ns0], [172.31.1.100], ["fc00::1/96"], |
1844 | [id 0 dstport 4789]) | |
1845 | ||
c10840ff JS |
1846 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
1847 | dnl waiting, we get occasional failures due to the following error: | |
84f646df | 1848 | dnl "connect: Cannot assign requested address" |
c10840ff | 1849 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) |
84f646df JS |
1850 | |
1851 | dnl First, check the underlay | |
1852 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl | |
1853 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1854 | ]) | |
1855 | ||
1856 | dnl Okay, now check the overlay with different packet sizes | |
1857 | NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
1858 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1859 | ]) | |
1860 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
1861 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1862 | ]) | |
1863 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
1864 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1865 | ]) | |
1866 | ||
1867 | OVS_TRAFFIC_VSWITCHD_STOP | |
1868 | AT_CLEANUP | |
9ac0aada | 1869 | |
c4e34c61 RB |
1870 | AT_SETUP([conntrack - resubmit to ct multiple times]) |
1871 | CHECK_CONNTRACK() | |
1872 | ||
1873 | OVS_TRAFFIC_VSWITCHD_START( | |
1874 | [set-fail-mode br0 secure -- ]) | |
1875 | ||
1876 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1877 | ||
1878 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1879 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1880 | ||
1881 | AT_DATA([flows.txt], [dnl | |
1882 | table=0,priority=150,arp,action=normal | |
1883 | table=0,priority=100,ip,in_port=1,action=resubmit(,1),resubmit(,2) | |
1884 | ||
723af132 JS |
1885 | table=1,ip,action=ct(table=3) |
1886 | table=2,ip,action=ct(table=3) | |
c4e34c61 RB |
1887 | |
1888 | table=3,ip,action=drop | |
1889 | ]) | |
1890 | ||
1891 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
1892 | ||
1893 | NS_CHECK_EXEC([at_ns0], [ping -q -c 1 10.1.1.2 | FORMAT_PING], [0], [dnl | |
1894 | 1 packets transmitted, 0 received, 100% packet loss, time 0ms | |
1895 | ]) | |
1896 | ||
1897 | AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl | |
1898 | n_packets=1, n_bytes=98, priority=100,ip,in_port=1 actions=resubmit(,1),resubmit(,2) | |
1899 | n_packets=2, n_bytes=84, priority=150,arp actions=NORMAL | |
723af132 JS |
1900 | table=1, n_packets=1, n_bytes=98, ip actions=ct(table=3) |
1901 | table=2, n_packets=1, n_bytes=98, ip actions=ct(table=3) | |
c4e34c61 RB |
1902 | table=3, n_packets=2, n_bytes=196, ip actions=drop |
1903 | NXST_FLOW reply: | |
1904 | ]) | |
1905 | ||
1906 | OVS_TRAFFIC_VSWITCHD_STOP | |
1907 | AT_CLEANUP | |
9ac0aada | 1908 | |
1d768544 JS |
1909 | AT_BANNER([conntrack - L7]) |
1910 | ||
1911 | AT_SETUP([conntrack - IPv4 HTTP]) | |
1912 | CHECK_CONNTRACK() | |
1913 | OVS_TRAFFIC_VSWITCHD_START() | |
1914 | ||
1915 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1916 | ||
1917 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1918 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1919 | ||
1920 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
1921 | AT_DATA([flows.txt], [dnl | |
1922 | priority=1,action=drop | |
1923 | priority=10,arp,action=normal | |
1924 | priority=10,icmp,action=normal | |
1925 | priority=100,in_port=1,tcp,action=ct(commit),2 | |
1926 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0) | |
1927 | priority=100,in_port=2,ct_state=+trk+est,tcp,action=1 | |
1928 | ]) | |
1929 | ||
1930 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1931 | ||
1932 | OVS_START_L7([at_ns0], [http]) | |
1933 | OVS_START_L7([at_ns1], [http]) | |
1934 | ||
1935 | dnl HTTP requests from ns0->ns1 should work fine. | |
1936 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
1937 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
1938 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
1939 | ]) | |
1940 | ||
1941 | dnl HTTP requests from ns1->ns0 should fail due to network failure. | |
1942 | dnl Try 3 times, in 1 second intervals. | |
1943 | NS_CHECK_EXEC([at_ns1], [wget 10.1.1.1 -t 3 -T 1 --retry-connrefused -v -o wget1.log], [4]) | |
1944 | ||
1945 | OVS_TRAFFIC_VSWITCHD_STOP | |
1946 | AT_CLEANUP | |
1947 | ||
1948 | AT_SETUP([conntrack - IPv6 HTTP]) | |
1949 | CHECK_CONNTRACK() | |
1950 | OVS_TRAFFIC_VSWITCHD_START() | |
1951 | ||
1952 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1953 | ||
1954 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
1955 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
1956 | ||
1957 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
1958 | AT_DATA([flows.txt], [dnl | |
1959 | priority=1,action=drop | |
1960 | priority=10,icmp6,action=normal | |
1961 | priority=100,in_port=1,tcp6,action=ct(commit),2 | |
1962 | priority=100,in_port=2,ct_state=-trk,tcp6,action=ct(table=0) | |
1963 | priority=100,in_port=2,ct_state=+trk+est,tcp6,action=1 | |
1964 | ]) | |
1965 | ||
1966 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1967 | ||
1968 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without | |
1969 | dnl waiting, we get occasional failures due to the following error: | |
1970 | dnl "connect: Cannot assign requested address" | |
1971 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) | |
1972 | ||
1973 | OVS_START_L7([at_ns0], [http6]) | |
1974 | OVS_START_L7([at_ns1], [http6]) | |
1975 | ||
1976 | dnl HTTP requests from ns0->ns1 should work fine. | |
1977 | NS_CHECK_EXEC([at_ns0], [wget http://[[fc00::2]] -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
1978 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl | |
1979 | tcp,orig=(src=fc00::1,dst=fc00::2,sport=<cleared>,dport=<cleared>),reply=(src=fc00::2,dst=fc00::1,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
1980 | ]) | |
1981 | ||
1982 | dnl HTTP requests from ns1->ns0 should fail due to network failure. | |
1983 | dnl Try 3 times, in 1 second intervals. | |
1984 | NS_CHECK_EXEC([at_ns1], [wget http://[[fc00::1]] -t 3 -T 1 --retry-connrefused -v -o wget1.log], [4]) | |
1985 | ||
1986 | OVS_TRAFFIC_VSWITCHD_STOP | |
1987 | AT_CLEANUP | |
1988 | ||
1989 | AT_SETUP([conntrack - commit, recirc]) | |
1990 | CHECK_CONNTRACK() | |
1991 | OVS_TRAFFIC_VSWITCHD_START() | |
1992 | ||
1993 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1994 | ||
1995 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1996 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1997 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
1998 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
1999 | ||
2000 | dnl Allow any traffic from ns0->ns1, ns2->ns3. | |
2001 | AT_DATA([flows.txt], [dnl | |
2002 | priority=1,action=drop | |
2003 | priority=10,arp,action=normal | |
2004 | priority=10,icmp,action=normal | |
2005 | priority=100,in_port=1,tcp,ct_state=-trk,action=ct(commit,table=0) | |
2006 | priority=100,in_port=1,tcp,ct_state=+trk,action=2 | |
2007 | priority=100,in_port=2,tcp,ct_state=-trk,action=ct(table=0) | |
2008 | priority=100,in_port=2,tcp,ct_state=+trk,action=1 | |
2009 | priority=100,in_port=3,tcp,ct_state=-trk,action=set_field:0->metadata,ct(table=0) | |
2010 | priority=100,in_port=3,tcp,ct_state=+trk,metadata=0,action=set_field:1->metadata,ct(commit,table=0) | |
2011 | priority=100,in_port=3,tcp,ct_state=+trk,metadata=1,action=4 | |
2012 | priority=100,in_port=4,tcp,ct_state=-trk,action=ct(commit,table=0) | |
2013 | priority=100,in_port=4,tcp,ct_state=+trk,action=3 | |
2014 | ]) | |
2015 | ||
2016 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2017 | ||
2018 | OVS_START_L7([at_ns1], [http]) | |
2019 | OVS_START_L7([at_ns3], [http]) | |
2020 | ||
2021 | dnl HTTP requests from p0->p1 should work fine. | |
2022 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2023 | ||
2024 | dnl HTTP requests from p2->p3 should work fine. | |
2025 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 --retry-connrefused -v -o wget1.log]) | |
2026 | ||
2027 | OVS_TRAFFIC_VSWITCHD_STOP | |
2028 | AT_CLEANUP | |
2029 | ||
2030 | AT_SETUP([conntrack - multiple zones, local]) | |
2031 | CHECK_CONNTRACK() | |
2032 | CHECK_CONNTRACK_LOCAL_STACK() | |
2033 | OVS_TRAFFIC_VSWITCHD_START() | |
2034 | ||
2035 | ADD_NAMESPACES(at_ns0) | |
2036 | ||
2037 | AT_CHECK([ip addr add dev br0 "10.1.1.1/24"]) | |
2038 | AT_CHECK([ip link set dev br0 up]) | |
2039 | on_exit 'ip addr del dev br0 "10.1.1.1/24"' | |
2040 | ADD_VETH(p0, at_ns0, br0, "10.1.1.2/24") | |
2041 | ||
2042 | dnl Allow traffic from local stack to ns0. Only allow neighbour discovery, | |
2043 | dnl return traffic from ns0 back to the local stack. | |
2044 | AT_DATA([flows.txt], [dnl | |
2045 | priority=1,action=drop | |
2046 | priority=10,arp,action=normal | |
2047 | priority=100,in_port=LOCAL,ip,ct_state=-trk,action=drop | |
2048 | priority=100,in_port=LOCAL,ip,ct_state=+trk+new,action=ct(commit,zone=1),ct(commit,zone=2),1 | |
2049 | priority=100,in_port=LOCAL,ip,ct_state=+trk+est,action=ct(commit,zone=1),ct(commit,zone=2),1 | |
2050 | priority=100,in_port=1,ip,ct_state=-trk,action=ct(table=1,zone=1) | |
2051 | table=1,in_port=1,ip,ct_state=+trk+est,ct_zone=1,action=ct(table=2,zone=2) | |
2052 | table=2,in_port=1,ip,ct_state=+trk+est,ct_zone=2,action=LOCAL | |
2053 | ]) | |
2054 | ||
2055 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2056 | ||
2057 | AT_CHECK([ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
2058 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
2059 | ]) | |
2060 | ||
2061 | OVS_START_L7([at_ns0], [http]) | |
2062 | ||
2063 | dnl HTTP requests from root namespace to p0 should work fine. | |
2064 | AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2065 | ||
2066 | dnl (again) HTTP requests from root namespace to p0 should work fine. | |
2067 | AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2068 | ||
2069 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep "zone"], [0], [dnl | |
2070 | icmp,orig=(src=10.1.1.1,dst=10.1.1.2,id=<cleared>,type=8,code=0),reply=(src=10.1.1.2,dst=10.1.1.1,id=<cleared>,type=0,code=0),zone=1 | |
2071 | icmp,orig=(src=10.1.1.1,dst=10.1.1.2,id=<cleared>,type=8,code=0),reply=(src=10.1.1.2,dst=10.1.1.1,id=<cleared>,type=0,code=0),zone=2 | |
2072 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) | |
2073 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=2,protoinfo=(state=<cleared>) | |
2074 | ]) | |
2075 | ||
2076 | OVS_TRAFFIC_VSWITCHD_STOP | |
2077 | AT_CLEANUP | |
2078 | ||
2079 | AT_SETUP([conntrack - multi-stage pipeline, local]) | |
2080 | CHECK_CONNTRACK() | |
2081 | CHECK_CONNTRACK_LOCAL_STACK() | |
2082 | OVS_TRAFFIC_VSWITCHD_START() | |
2083 | ||
2084 | ADD_NAMESPACES(at_ns0) | |
2085 | ||
2086 | AT_CHECK([ip addr add dev br0 "10.1.1.1/24"]) | |
2087 | AT_CHECK([ip link set dev br0 up]) | |
2088 | on_exit 'ip addr del dev br0 "10.1.1.1/24"' | |
2089 | ADD_VETH(p0, at_ns0, br0, "10.1.1.2/24") | |
2090 | ||
2091 | dnl Allow traffic from local stack to ns0. Only allow neighbour discovery, | |
2092 | dnl return traffic from ns0 back to the local stack. | |
2093 | AT_DATA([flows.txt], [dnl | |
2094 | dnl default | |
2095 | table=0,priority=1,action=drop | |
2096 | table=0,priority=10,arp,action=normal | |
2097 | ||
2098 | dnl Load the output port to REG0 | |
2099 | table=0,priority=100,ip,in_port=LOCAL,action=load:1->NXM_NX_REG0[[0..15]],goto_table:1 | |
2100 | table=0,priority=100,ip,in_port=1,action=load:65534->NXM_NX_REG0[[0..15]],goto_table:1 | |
2101 | ||
2102 | dnl Ingress pipeline | |
2103 | dnl - Allow all connections from LOCAL port (commit and proceed to egress) | |
2104 | dnl - All other connections go through conntracker using the input port as | |
2105 | dnl a connection tracking zone. | |
2106 | table=1,priority=150,in_port=LOCAL,ip,ct_state=+trk+new,action=ct(commit,zone=OXM_OF_IN_PORT[[0..15]]),goto_table:2 | |
2107 | table=1,priority=100,ip,action=ct(table=2,zone=OXM_OF_IN_PORT[[0..15]]) | |
2108 | table=1,priority=1,action=drop | |
2109 | ||
2110 | dnl Egress pipeline | |
2111 | dnl - Allow all connections from LOCAL port (commit and skip to output) | |
2112 | dnl - Allow other established connections to go through conntracker using | |
2113 | dnl output port as a connection tracking zone. | |
2114 | table=2,priority=150,in_port=LOCAL,ip,ct_state=+trk+new,action=ct(commit,zone=NXM_NX_REG0[[0..15]]),goto_table:4 | |
2115 | table=2,priority=100,ip,ct_state=+trk+est,action=ct(table=3,zone=NXM_NX_REG0[[0..15]]) | |
2116 | table=2,priority=1,action=drop | |
2117 | ||
2118 | dnl Only allow established traffic from egress ct lookup | |
2119 | table=3,priority=100,ip,ct_state=+trk+est,action=goto_table:4 | |
2120 | table=3,priority=1,action=drop | |
2121 | ||
2122 | dnl output table | |
2123 | table=4,priority=100,ip,action=output:NXM_NX_REG0[[]] | |
2124 | ]) | |
2125 | ||
2126 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2127 | ||
2128 | AT_CHECK([ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
2129 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
2130 | ]) | |
2131 | ||
2132 | OVS_START_L7([at_ns0], [http]) | |
2133 | ||
2134 | dnl HTTP requests from root namespace to p0 should work fine. | |
2135 | AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2136 | ||
2137 | dnl (again) HTTP requests from root namespace to p0 should work fine. | |
2138 | AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2139 | ||
2140 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep "zone"], [0], [dnl | |
2141 | icmp,orig=(src=10.1.1.1,dst=10.1.1.2,id=<cleared>,type=8,code=0),reply=(src=10.1.1.2,dst=10.1.1.1,id=<cleared>,type=0,code=0),zone=1 | |
2142 | icmp,orig=(src=10.1.1.1,dst=10.1.1.2,id=<cleared>,type=8,code=0),reply=(src=10.1.1.2,dst=10.1.1.1,id=<cleared>,type=0,code=0),zone=65534 | |
2143 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) | |
2144 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=65534,protoinfo=(state=<cleared>) | |
2145 | ]) | |
2146 | ||
2147 | OVS_TRAFFIC_VSWITCHD_STOP | |
2148 | AT_CLEANUP | |
2149 | ||
9d3e0e5c JR |
2150 | AT_SETUP([FTP - no conntrack]) |
2151 | AT_SKIP_IF([test $HAVE_FTP = no]) | |
2152 | OVS_TRAFFIC_VSWITCHD_START() | |
2153 | ||
2154 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2155 | ||
2156 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2157 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2158 | ||
2159 | AT_DATA([flows.txt], [dnl | |
2160 | table=0,action=normal | |
2161 | ]) | |
2162 | ||
2163 | AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows.txt]) | |
2164 | ||
2165 | NETNS_DAEMONIZE([at_ns0], [[$PYTHON $srcdir/test-l7.py ftp]], [ftp1.pid]) | |
2166 | NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py ftp]], [ftp0.pid]) | |
2167 | OVS_WAIT_UNTIL([ip netns exec at_ns1 netstat -l | grep ftp]) | |
2168 | ||
2169 | dnl FTP requests from p0->p1 should work fine. | |
2170 | NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2171 | ||
2172 | AT_CHECK([find -name index.html], [0], [dnl | |
2173 | ./index.html | |
2174 | ]) | |
2175 | ||
2176 | OVS_TRAFFIC_VSWITCHD_STOP | |
2177 | AT_CLEANUP | |
2178 | ||
1d768544 | 2179 | AT_SETUP([conntrack - FTP]) |
40c7b2fc | 2180 | AT_SKIP_IF([test $HAVE_FTP = no]) |
1d768544 JS |
2181 | CHECK_CONNTRACK() |
2182 | CHECK_CONNTRACK_ALG() | |
2183 | OVS_TRAFFIC_VSWITCHD_START() | |
2184 | ||
2185 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2186 | ||
2187 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2188 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2189 | ||
2190 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2191 | AT_DATA([flows1.txt], [dnl | |
2192 | table=0,priority=1,action=drop | |
2193 | table=0,priority=10,arp,action=normal | |
2194 | table=0,priority=10,icmp,action=normal | |
2195 | table=0,priority=100,in_port=1,tcp,action=ct(alg=ftp,commit),2 | |
2196 | table=0,priority=100,in_port=2,tcp,action=ct(table=1) | |
2197 | table=1,in_port=2,tcp,ct_state=+trk+est,action=1 | |
2198 | table=1,in_port=2,tcp,ct_state=+trk+rel,action=1 | |
2199 | ]) | |
2200 | ||
2201 | dnl Similar policy but without allowing all traffic from ns0->ns1. | |
2202 | AT_DATA([flows2.txt], [dnl | |
2203 | table=0,priority=1,action=drop | |
2204 | table=0,priority=10,arp,action=normal | |
2205 | table=0,priority=10,icmp,action=normal | |
2206 | ||
2207 | dnl Allow outgoing TCP connections, and treat them as FTP | |
2208 | table=0,priority=100,in_port=1,tcp,action=ct(table=1) | |
2209 | table=1,in_port=1,tcp,ct_state=+trk+new,action=ct(commit,alg=ftp),2 | |
2210 | table=1,in_port=1,tcp,ct_state=+trk+est,action=2 | |
2211 | ||
2212 | dnl Allow incoming FTP data connections and responses to existing connections | |
2213 | table=0,priority=100,in_port=2,tcp,action=ct(table=1) | |
2214 | table=1,in_port=2,tcp,ct_state=+trk+new+rel,action=ct(commit),1 | |
2215 | table=1,in_port=2,tcp,ct_state=+trk+est,action=1 | |
2216 | table=1,in_port=2,tcp,ct_state=+trk-new+rel,action=1 | |
2217 | ]) | |
2218 | ||
2219 | AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows1.txt]) | |
2220 | ||
2221 | OVS_START_L7([at_ns0], [ftp]) | |
2222 | OVS_START_L7([at_ns1], [ftp]) | |
2223 | ||
2224 | dnl FTP requests from p1->p0 should fail due to network failure. | |
2225 | dnl Try 3 times, in 1 second intervals. | |
2226 | NS_CHECK_EXEC([at_ns1], [wget ftp://10.1.1.1 --no-passive-ftp -t 3 -T 1 -v -o wget1.log], [4]) | |
2227 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl | |
2228 | ]) | |
2229 | ||
2230 | dnl FTP requests from p0->p1 should work fine. | |
2231 | NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2232 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
2233 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>),helper=ftp | |
2234 | ]) | |
2235 | ||
2236 | dnl Try the second set of flows. | |
2237 | AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows2.txt]) | |
2238 | AT_CHECK([ovs-appctl dpctl/flush-conntrack]) | |
2239 | ||
2240 | dnl FTP requests from p1->p0 should fail due to network failure. | |
2241 | dnl Try 3 times, in 1 second intervals. | |
2242 | NS_CHECK_EXEC([at_ns1], [wget ftp://10.1.1.1 --no-passive-ftp -t 3 -T 1 -v -o wget1.log], [4]) | |
2243 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl | |
2244 | ]) | |
2245 | ||
2246 | dnl Active FTP requests from p0->p1 should work fine. | |
2247 | NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v -o wget0-1.log]) | |
2248 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
2249 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>),helper=ftp | |
2250 | tcp,orig=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
2251 | ]) | |
2252 | ||
2253 | AT_CHECK([ovs-appctl dpctl/flush-conntrack]) | |
2254 | ||
2255 | dnl Passive FTP requests from p0->p1 should work fine. | |
2256 | NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0-2.log]) | |
2257 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
2258 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>),helper=ftp | |
2259 | ]) | |
2260 | ||
2261 | OVS_TRAFFIC_VSWITCHD_STOP | |
2262 | AT_CLEANUP | |
2263 | ||
2264 | AT_SETUP([conntrack - FTP over IPv6]) | |
40c7b2fc | 2265 | AT_SKIP_IF([test $HAVE_FTP = no]) |
1d768544 JS |
2266 | CHECK_CONNTRACK() |
2267 | CHECK_CONNTRACK_ALG() | |
2268 | OVS_TRAFFIC_VSWITCHD_START() | |
2269 | ||
2270 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2271 | ||
2272 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
2273 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
2274 | ||
2275 | dnl Allow any traffic from ns0->ns1. | |
2276 | dnl Only allow nd, return traffic from ns1->ns0. | |
2277 | AT_DATA([flows.txt], [dnl | |
2278 | dnl Track all IPv6 traffic and drop the rest. | |
2279 | dnl Allow ICMPv6 both ways. No commit, so pings will not be tracked. | |
2280 | table=0 priority=100 in_port=1 icmp6, action=2 | |
2281 | table=0 priority=100 in_port=2 icmp6, action=1 | |
2282 | table=0 priority=10 ip6, action=ct(table=1) | |
2283 | table=0 priority=0 action=drop | |
2284 | dnl | |
2285 | dnl Table 1 | |
2286 | dnl | |
2287 | dnl Allow new TCPv6 FTP control connections from port 1. | |
2288 | table=1 in_port=1 ct_state=+new, tcp6, tp_dst=21, action=ct(alg=ftp,commit),2 | |
2289 | dnl Allow related TCPv6 connections from port 2. | |
2290 | table=1 in_port=2 ct_state=+new+rel, tcp6, action=ct(commit),1 | |
2291 | dnl Allow established TCPv6 connections both ways. | |
2292 | table=1 in_port=1 ct_state=+est, tcp6, action=2 | |
2293 | table=1 in_port=2 ct_state=+est, tcp6, action=1 | |
2294 | dnl Drop everything else. | |
2295 | table=1 priority=0, action=drop | |
2296 | ]) | |
2297 | ||
2298 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2299 | ||
2300 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without | |
2301 | dnl waiting, we get occasional failures due to the following error: | |
2302 | dnl "connect: Cannot assign requested address" | |
2303 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2 >/dev/null]) | |
2304 | ||
2305 | OVS_START_L7([at_ns1], [ftp]) | |
2306 | ||
2307 | dnl FTP requests from p0->p1 should work fine. | |
2308 | NS_CHECK_EXEC([at_ns0], [wget ftp://[[fc00::2]] -6 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v --server-response --no-remove-listing -o wget0.log -d]) | |
2309 | ||
2310 | dnl Discards CLOSE_WAIT and CLOSING | |
2311 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl | |
2312 | tcp,orig=(src=fc00::1,dst=fc00::2,sport=<cleared>,dport=<cleared>),reply=(src=fc00::2,dst=fc00::1,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>),helper=ftp | |
2313 | tcp,orig=(src=fc00::2,dst=fc00::1,sport=<cleared>,dport=<cleared>),reply=(src=fc00::1,dst=fc00::2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
2314 | ]) | |
2315 | ||
2316 | OVS_TRAFFIC_VSWITCHD_STOP | |
2317 | AT_CLEANUP | |
2318 | ||
2319 | AT_SETUP([conntrack - FTP with multiple expectations]) | |
40c7b2fc | 2320 | AT_SKIP_IF([test $HAVE_FTP = no]) |
1d768544 JS |
2321 | CHECK_CONNTRACK() |
2322 | CHECK_CONNTRACK_ALG() | |
2323 | OVS_TRAFFIC_VSWITCHD_START() | |
2324 | ||
2325 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2326 | ||
2327 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2328 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2329 | ||
2330 | dnl Dual-firewall, allow all from ns1->ns2, allow established and ftp ns2->ns1. | |
2331 | AT_DATA([flows.txt], [dnl | |
2332 | table=0,priority=1,action=drop | |
2333 | table=0,priority=10,arp,action=normal | |
2334 | table=0,priority=10,icmp,action=normal | |
2335 | ||
2336 | dnl Traffic from ns1 | |
2337 | table=0,priority=100,in_port=1,tcp,action=ct(table=1,zone=1) | |
2338 | table=1,in_port=1,tcp,ct_zone=1,ct_state=+trk+new-rel,action=ct(commit,alg=ftp,zone=1),ct(commit,alg=ftp,zone=2),2 | |
2339 | table=1,in_port=1,tcp,ct_zone=1,ct_state=+trk+new+rel,action=ct(commit,zone=1),ct(commit,zone=2),2 | |
2340 | table=1,in_port=1,tcp,ct_zone=1,ct_state=+trk+est,action=ct(table=2,zone=2) | |
2341 | table=2,in_port=1,tcp,ct_zone=2,ct_state=+trk+est,action=2 | |
2342 | ||
2343 | dnl Traffic from ns2 | |
2344 | table=0,priority=100,in_port=2,tcp,action=ct(table=1,zone=2) | |
2345 | table=1,in_port=2,tcp,ct_zone=2,ct_state=+trk+rel,action=ct(commit,zone=2),ct(commit,zone=1),1 | |
2346 | table=1,in_port=2,tcp,ct_zone=2,ct_state=+trk+est,action=ct(table=2,zone=1) | |
2347 | table=2,in_port=2,tcp,ct_zone=1,ct_state=+trk+rel,action=ct(commit,zone=2),ct(commit,zone=1),1 | |
2348 | table=2,in_port=2,tcp,ct_zone=1,ct_state=+trk+est,action=1 | |
2349 | ]) | |
2350 | ||
2351 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2352 | ||
2353 | OVS_START_L7([at_ns0], [ftp]) | |
2354 | OVS_START_L7([at_ns1], [ftp]) | |
2355 | ||
2356 | dnl FTP requests from p1->p0 should fail due to network failure. | |
2357 | dnl Try 3 times, in 1 second intervals. | |
2358 | NS_CHECK_EXEC([at_ns1], [wget ftp://10.1.1.1 --no-passive-ftp -t 3 -T 1 -v -o wget1.log], [4]) | |
2359 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl | |
2360 | ]) | |
2361 | ||
2362 | dnl Active FTP requests from p0->p1 should work fine. | |
2363 | NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2364 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
2365 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>),helper=ftp | |
2366 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=2,protoinfo=(state=<cleared>),helper=ftp | |
2367 | tcp,orig=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) | |
2368 | tcp,orig=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),zone=2,protoinfo=(state=<cleared>) | |
2369 | ]) | |
2370 | ||
2371 | AT_CHECK([ovs-appctl dpctl/flush-conntrack]) | |
2372 | ||
2373 | dnl Passive FTP requests from p0->p1 should work fine. | |
2374 | NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2375 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
2376 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) | |
2377 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>),helper=ftp | |
2378 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=2,protoinfo=(state=<cleared>) | |
2379 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=2,protoinfo=(state=<cleared>),helper=ftp | |
2380 | ]) | |
2381 | ||
2382 | OVS_TRAFFIC_VSWITCHD_STOP | |
2383 | AT_CLEANUP | |
2384 | ||
40c7b2fc JS |
2385 | AT_SETUP([conntrack - TFTP]) |
2386 | AT_SKIP_IF([test $HAVE_TFTP = no]) | |
2387 | CHECK_CONNTRACK() | |
2388 | CHECK_CONNTRACK_ALG() | |
2389 | OVS_TRAFFIC_VSWITCHD_START() | |
2390 | ||
2391 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2392 | ||
2393 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2394 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2395 | ||
2396 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2397 | AT_DATA([flows1.txt], [dnl | |
2398 | table=0,priority=1,action=drop | |
2399 | table=0,priority=10,arp,action=normal | |
2400 | table=0,priority=10,icmp,action=normal | |
2401 | table=0,priority=100,in_port=1,udp,action=ct(alg=tftp,commit),2 | |
2402 | table=0,priority=100,in_port=2,udp,action=ct(table=1) | |
2403 | table=1,in_port=2,udp,ct_state=+trk+est,action=1 | |
2404 | table=1,in_port=2,udp,ct_state=+trk+rel,action=1 | |
2405 | ]) | |
2406 | ||
2407 | dnl Similar policy but without allowing all traffic from ns0->ns1. | |
2408 | AT_DATA([flows2.txt], [dnl | |
2409 | table=0,priority=1,action=drop | |
2410 | table=0,priority=10,arp,action=normal | |
2411 | table=0,priority=10,icmp,action=normal | |
2412 | ||
2413 | dnl Allow outgoing UDP connections, and treat them as TFTP | |
2414 | table=0,priority=100,in_port=1,udp,action=ct(table=1) | |
2415 | table=1,in_port=1,udp,ct_state=+trk+new-rel,action=ct(commit,alg=tftp),2 | |
2416 | table=1,in_port=1,udp,ct_state=+trk+new+rel,action=ct(commit),2 | |
2417 | table=1,in_port=1,udp,ct_state=+trk+est,action=2 | |
2418 | ||
2419 | dnl Allow incoming TFTP data connections and responses to existing connections | |
2420 | table=0,priority=100,in_port=2,udp,action=ct(table=1) | |
2421 | table=1,in_port=2,udp,ct_state=+trk+est,action=1 | |
2422 | table=1,in_port=2,udp,ct_state=+trk+new+rel,action=1 | |
2423 | ]) | |
2424 | ||
2425 | AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows1.txt]) | |
2426 | ||
2427 | OVS_START_L7([at_ns0], [tftp]) | |
2428 | OVS_START_L7([at_ns1], [tftp]) | |
2429 | ||
2430 | dnl TFTP requests from p1->p0 should fail due to network failure. | |
2431 | NS_CHECK_EXEC([at_ns1], [[curl $CURL_OPT tftp://10.1.1.1/flows1.txt -o foo 2>curl0.log]], [28]) | |
2432 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl | |
2433 | ]) | |
2434 | ||
2435 | dnl TFTP requests from p0->p1 should work fine. | |
2436 | NS_CHECK_EXEC([at_ns0], [[curl $CURL_OPT tftp://10.1.1.2/flows1.txt -o foo 2>curl1.log]]) | |
2437 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
2438 | udp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),helper=tftp | |
2439 | ]) | |
2440 | ||
2441 | dnl Try the second set of flows. | |
2442 | AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows2.txt]) | |
2443 | AT_CHECK([ovs-appctl dpctl/flush-conntrack]) | |
2444 | ||
2445 | dnl TFTP requests from p1->p0 should fail due to network failure. | |
2446 | NS_CHECK_EXEC([at_ns1], [[curl $CURL_OPT tftp://10.1.1.1/flows1.txt -o foo 2>curl2.log]], [28]) | |
2447 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl | |
2448 | ]) | |
2449 | ||
2450 | dnl TFTP requests from p0->p1 should work fine. | |
2451 | NS_CHECK_EXEC([at_ns0], [[curl $CURL_OPT tftp://10.1.1.2/flows1.txt -o foo 2>curl3.log]]) | |
2452 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
2453 | udp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),helper=tftp | |
2454 | ]) | |
2455 | ||
2456 | OVS_TRAFFIC_VSWITCHD_STOP | |
2457 | AT_CLEANUP | |
2458 | ||
ee8941ab | 2459 | AT_BANNER([conntrack - NAT]) |
9ac0aada JR |
2460 | |
2461 | AT_SETUP([conntrack - simple SNAT]) | |
2462 | CHECK_CONNTRACK() | |
4573c42e | 2463 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2464 | OVS_TRAFFIC_VSWITCHD_START() |
2465 | ||
2466 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2467 | ||
2468 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2469 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2470 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2471 | ||
2472 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2473 | AT_DATA([flows.txt], [dnl | |
2474 | in_port=1,ip,action=ct(commit,zone=1,nat(src=10.1.1.240-10.1.1.255)),2 | |
2475 | in_port=2,ct_state=-trk,ip,action=ct(table=0,zone=1,nat) | |
2476 | in_port=2,ct_state=+trk,ct_zone=1,ip,action=1 | |
2477 | dnl | |
2478 | dnl ARP | |
2479 | priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2480 | priority=10 arp action=normal | |
2481 | priority=0,action=drop | |
2482 | dnl | |
2483 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2484 | table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2485 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2486 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2487 | dnl TPA IP in reg2. | |
2488 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2489 | table=10 priority=100 arp xreg0=0 action=normal | |
2490 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
2491 | table=10 priority=0 action=drop | |
2492 | ]) | |
2493 | ||
2494 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2495 | ||
2496 | dnl HTTP requests from p0->p1 should work fine. | |
7ed40afe | 2497 | OVS_START_L7([at_ns1], [http]) |
9ac0aada JR |
2498 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 5 -T 1 --retry-connrefused -v -o wget0.log]) |
2499 | ||
a857bb69 | 2500 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | sed -e 's/dst=10.1.1.2[[45]][[0-9]]/dst=10.1.1.2XX/'], [0], [dnl |
420c73b2 | 2501 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.2XX,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) |
9ac0aada JR |
2502 | ]) |
2503 | ||
2504 | OVS_TRAFFIC_VSWITCHD_STOP | |
2505 | AT_CLEANUP | |
2506 | ||
c0324e37 JR |
2507 | AT_SETUP([conntrack - SNAT with ct_mark change on reply]) |
2508 | CHECK_CONNTRACK() | |
2509 | CHECK_CONNTRACK_NAT() | |
2510 | OVS_TRAFFIC_VSWITCHD_START() | |
2511 | ||
2512 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2513 | ||
2514 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2515 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2516 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2517 | ||
2518 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2519 | AT_DATA([flows.txt], [dnl | |
2520 | in_port=1,ip,action=ct(commit,zone=1,nat(src=10.1.1.240-10.1.1.255)),2 | |
2521 | in_port=2,ct_state=-trk,ip,action=ct(table=0,zone=1,nat) | |
2522 | dnl | |
2523 | dnl Setting the mark fails if the datapath can't find the existing conntrack | |
2524 | dnl entry after NAT has been reversed and the skb was lost due to an upcall. | |
2525 | dnl | |
2526 | in_port=2,ct_state=+trk,ct_zone=1,ip,action=ct(table=1,commit,zone=1,exec(set_field:1->ct_mark)),1 | |
2527 | table=1,in_port=2,ct_mark=1,ct_state=+rpl,ct_zone=1,ip,action=1 | |
2528 | dnl | |
2529 | dnl ARP | |
2530 | priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2531 | priority=10 arp action=normal | |
2532 | priority=0,action=drop | |
2533 | dnl | |
2534 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2535 | table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2536 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2537 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2538 | dnl TPA IP in reg2. | |
2539 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2540 | table=10 priority=100 arp xreg0=0 action=normal | |
2541 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
2542 | table=10 priority=0 action=drop | |
2543 | ]) | |
2544 | ||
2545 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2546 | ||
2547 | dnl HTTP requests from p0->p1 should work fine. | |
2548 | NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py]], [http0.pid]) | |
2549 | NS_CHECK_EXEC([at_ns0], [ping -c 1 10.1.1.2 | FORMAT_PING], [0], [dnl | |
2550 | 1 packets transmitted, 1 received, 0% packet loss, time 0ms | |
2551 | ]) | |
2552 | ||
2553 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | sed -e 's/dst=10.1.1.2[[45]][[0-9]]/dst=10.1.1.2XX/'], [0], [dnl | |
2554 | icmp,orig=(src=10.1.1.1,dst=10.1.1.2,id=<cleared>,type=8,code=0),reply=(src=10.1.1.2,dst=10.1.1.2XX,id=<cleared>,type=0,code=0),zone=1,mark=1 | |
2555 | ]) | |
2556 | ||
2557 | OVS_TRAFFIC_VSWITCHD_STOP | |
2558 | AT_CLEANUP | |
9ac0aada JR |
2559 | |
2560 | AT_SETUP([conntrack - SNAT with port range]) | |
2561 | CHECK_CONNTRACK() | |
4573c42e | 2562 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2563 | OVS_TRAFFIC_VSWITCHD_START() |
2564 | ||
2565 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2566 | ||
2567 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2568 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2569 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2570 | ||
2571 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2572 | AT_DATA([flows.txt], [dnl | |
2573 | in_port=1,tcp,action=ct(commit,zone=1,nat(src=10.1.1.240-10.1.1.255:34567-34568,random)),2 | |
2574 | in_port=2,ct_state=-trk,tcp,tp_dst=34567,action=ct(table=0,zone=1,nat) | |
2575 | in_port=2,ct_state=-trk,tcp,tp_dst=34568,action=ct(table=0,zone=1,nat) | |
2576 | in_port=2,ct_state=+trk,ct_zone=1,tcp,action=1 | |
2577 | dnl | |
2578 | dnl ARP | |
2579 | priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2580 | priority=10 arp action=normal | |
2581 | priority=0,action=drop | |
2582 | dnl | |
2583 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2584 | table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2585 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2586 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2587 | dnl TPA IP in reg2. | |
2588 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2589 | table=10 priority=100 arp xreg0=0 action=normal | |
2590 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
2591 | table=10 priority=0 action=drop | |
2592 | ]) | |
2593 | ||
2594 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2595 | ||
2596 | dnl HTTP requests from p0->p1 should work fine. | |
7ed40afe | 2597 | OVS_START_L7([at_ns1], [http]) |
9ac0aada JR |
2598 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 5 -T 1 --retry-connrefused -v -o wget0.log]) |
2599 | ||
a857bb69 | 2600 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | sed -e 's/dst=10.1.1.2[[45]][[0-9]]/dst=10.1.1.2XX/'], [0], [dnl |
420c73b2 | 2601 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.2XX,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) |
9ac0aada JR |
2602 | ]) |
2603 | ||
2604 | OVS_TRAFFIC_VSWITCHD_STOP | |
2605 | AT_CLEANUP | |
2606 | ||
2607 | ||
2608 | AT_SETUP([conntrack - more complex SNAT]) | |
2609 | CHECK_CONNTRACK() | |
4573c42e | 2610 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2611 | OVS_TRAFFIC_VSWITCHD_START() |
2612 | ||
2613 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2614 | ||
2615 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2616 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2617 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2618 | ||
2619 | AT_DATA([flows.txt], [dnl | |
2620 | dnl Track all IP traffic, NAT existing connections. | |
2621 | priority=100 ip action=ct(table=1,zone=1,nat) | |
2622 | dnl | |
2623 | dnl Allow ARP, but generate responses for NATed addresses | |
2624 | priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2625 | priority=10 arp action=normal | |
2626 | priority=0 action=drop | |
2627 | dnl | |
2628 | dnl Allow any traffic from ns0->ns1. SNAT ns0 to 10.1.1.240-10.1.1.255 | |
2629 | table=1 priority=100 in_port=1 ip ct_state=+trk+new-est action=ct(commit,zone=1,nat(src=10.1.1.240-10.1.1.255)),2 | |
2630 | table=1 priority=100 in_port=1 ip ct_state=+trk-new+est action=2 | |
2631 | dnl Only allow established traffic from ns1->ns0. | |
2632 | table=1 priority=100 in_port=2 ip ct_state=+trk-new+est action=1 | |
2633 | table=1 priority=0 action=drop | |
2634 | dnl | |
2635 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2636 | table=8 priority=100 reg2=0x0a0101f0/0xfffffff0 action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2637 | dnl Zero result means not found. | |
2638 | table=8 priority=0 action=load:0->OXM_OF_PKT_REG0[[]] | |
2639 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2640 | dnl ARP TPA IP in reg2. | |
2641 | table=10 priority=100 arp xreg0=0 action=normal | |
2642 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2643 | table=10 priority=10 arp arp_op=1 action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
2644 | table=10 priority=0 action=drop | |
2645 | ]) | |
2646 | ||
2647 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2648 | ||
2649 | dnl HTTP requests from p0->p1 should work fine. | |
7ed40afe | 2650 | OVS_START_L7([at_ns1], [http]) |
9ac0aada JR |
2651 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 5 -T 1 --retry-connrefused -v -o wget0.log]) |
2652 | ||
a857bb69 | 2653 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | sed -e 's/dst=10.1.1.2[[45]][[0-9]]/dst=10.1.1.2XX/'], [0], [dnl |
420c73b2 | 2654 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.2XX,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) |
9ac0aada JR |
2655 | ]) |
2656 | ||
2657 | OVS_TRAFFIC_VSWITCHD_STOP | |
2658 | AT_CLEANUP | |
2659 | ||
2660 | AT_SETUP([conntrack - simple DNAT]) | |
2661 | CHECK_CONNTRACK() | |
4573c42e | 2662 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2663 | OVS_TRAFFIC_VSWITCHD_START() |
2664 | ||
2665 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2666 | ||
2667 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2668 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2669 | NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address 80:88:88:88:88:88]) | |
2670 | ||
2671 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2672 | AT_DATA([flows.txt], [dnl | |
2673 | priority=100 in_port=1,ip,nw_dst=10.1.1.64,action=ct(zone=1,nat(dst=10.1.1.2),commit),2 | |
2674 | priority=10 in_port=1,ip,action=ct(commit,zone=1),2 | |
2675 | priority=100 in_port=2,ct_state=-trk,ip,action=ct(table=0,nat,zone=1) | |
2676 | priority=100 in_port=2,ct_state=+trk+est,ct_zone=1,ip,action=1 | |
2677 | dnl | |
2678 | dnl ARP | |
2679 | priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2680 | priority=10 arp action=normal | |
2681 | priority=0,action=drop | |
2682 | dnl | |
2683 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2684 | table=8,reg2=0x0a010140,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2685 | dnl Zero result means not found. | |
2686 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2687 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2688 | dnl TPA IP in reg2. | |
2689 | table=10 priority=100 arp xreg0=0 action=normal | |
2690 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2691 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
2692 | table=10 priority=0 action=drop | |
2693 | ]) | |
2694 | ||
2695 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2696 | ||
2697 | dnl Should work with the virtual IP address through NAT | |
7ed40afe | 2698 | OVS_START_L7([at_ns1], [http]) |
9ac0aada JR |
2699 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.64 -t 5 -T 1 --retry-connrefused -v -o wget0.log]) |
2700 | ||
420c73b2 JR |
2701 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.64)], [0], [dnl |
2702 | tcp,orig=(src=10.1.1.1,dst=10.1.1.64,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) | |
9ac0aada JR |
2703 | ]) |
2704 | ||
2705 | dnl Should work with the assigned IP address as well | |
2706 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2707 | ||
420c73b2 JR |
2708 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
2709 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) | |
9ac0aada JR |
2710 | ]) |
2711 | ||
2712 | OVS_TRAFFIC_VSWITCHD_STOP | |
2713 | AT_CLEANUP | |
2714 | ||
2715 | AT_SETUP([conntrack - more complex DNAT]) | |
2716 | CHECK_CONNTRACK() | |
4573c42e | 2717 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2718 | OVS_TRAFFIC_VSWITCHD_START() |
2719 | ||
2720 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2721 | ||
2722 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2723 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2724 | NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address 80:88:88:88:88:88]) | |
2725 | ||
2726 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2727 | AT_DATA([flows.txt], [dnl | |
2728 | dnl Track all IP traffic | |
2729 | table=0 priority=100 ip action=ct(table=1,zone=1,nat) | |
2730 | dnl | |
2731 | dnl Allow ARP, but generate responses for NATed addresses | |
2732 | table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2733 | table=0 priority=10 arp action=normal | |
2734 | table=0 priority=0 action=drop | |
2735 | dnl | |
2736 | dnl Allow any IP traffic from ns0->ns1. DNAT ns0 from 10.1.1.64 to 10.1.1.2 | |
2737 | table=1 priority=100 in_port=1 ct_state=+new ip nw_dst=10.1.1.64 action=ct(zone=1,nat(dst=10.1.1.2),commit),2 | |
2738 | table=1 priority=10 in_port=1 ct_state=+new ip action=ct(commit,zone=1),2 | |
2739 | table=1 priority=100 in_port=1 ct_state=+est ct_zone=1 action=2 | |
2740 | dnl Only allow established traffic from ns1->ns0. | |
2741 | table=1 priority=100 in_port=2 ct_state=+est ct_zone=1 action=1 | |
2742 | table=1 priority=0 action=drop | |
2743 | dnl | |
2744 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2745 | table=8,reg2=0x0a010140,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2746 | dnl Zero result means not found. | |
2747 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2748 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2749 | dnl TPA IP in reg2. | |
2750 | table=10 priority=100 arp xreg0=0 action=normal | |
2751 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2752 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
2753 | table=10 priority=0 action=drop | |
2754 | ]) | |
2755 | ||
2756 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2757 | ||
2758 | dnl Should work with the virtual IP address through NAT | |
7ed40afe | 2759 | OVS_START_L7([at_ns1], [http]) |
9ac0aada JR |
2760 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.64 -t 5 -T 1 --retry-connrefused -v -o wget0.log]) |
2761 | ||
420c73b2 JR |
2762 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.64)], [0], [dnl |
2763 | tcp,orig=(src=10.1.1.1,dst=10.1.1.64,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) | |
9ac0aada JR |
2764 | ]) |
2765 | ||
2766 | dnl Should work with the assigned IP address as well | |
2767 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2768 | ||
420c73b2 JR |
2769 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
2770 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),zone=1,protoinfo=(state=<cleared>) | |
9ac0aada JR |
2771 | ]) |
2772 | ||
2773 | OVS_TRAFFIC_VSWITCHD_STOP | |
2774 | AT_CLEANUP | |
2775 | ||
2776 | AT_SETUP([conntrack - ICMP related with NAT]) | |
9c1ab985 | 2777 | AT_SKIP_IF([test $HAVE_NC = no]) |
9ac0aada | 2778 | CHECK_CONNTRACK() |
4573c42e | 2779 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2780 | OVS_TRAFFIC_VSWITCHD_START() |
2781 | ||
2782 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2783 | ||
2784 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2785 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2786 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2787 | ||
2788 | dnl Allow UDP traffic from ns0->ns1. Only allow related ICMP responses back. | |
2789 | dnl Make sure ICMP responses are reverse-NATted. | |
2790 | AT_DATA([flows.txt], [dnl | |
2791 | in_port=1,udp,action=ct(commit,nat(src=10.1.1.240-10.1.1.255),exec(set_field:1->ct_mark)),2 | |
2792 | in_port=2,icmp,ct_state=-trk,action=ct(table=0,nat) | |
2793 | in_port=2,icmp,nw_dst=10.1.1.1,ct_state=+trk+rel,ct_mark=1,action=1 | |
2794 | dnl | |
2795 | dnl ARP | |
2796 | priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2797 | priority=10 arp action=normal | |
2798 | priority=0,action=drop | |
2799 | dnl | |
2800 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2801 | table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2802 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2803 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2804 | dnl TPA IP in reg2. | |
2805 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2806 | table=10 priority=100 arp xreg0=0 action=normal | |
2807 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
2808 | table=10 priority=0 action=drop | |
2809 | ]) | |
2810 | ||
2811 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2812 | ||
2813 | dnl UDP packets from ns0->ns1 should solicit "destination unreachable" response. | |
b54971f7 | 2814 | NS_CHECK_EXEC([at_ns0], [bash -c "echo a | nc $NC_EOF_OPT -u 10.1.1.2 10000"]) |
9ac0aada JR |
2815 | |
2816 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
2817 | AT_CHECK([ovs-ofctl -O OpenFlow15 dump-flows br0 | ofctl_strip | sort | grep -v drop], [0], [dnl | |
2818 | n_packets=1, n_bytes=42, priority=10,arp actions=NORMAL | |
2819 | n_packets=1, n_bytes=44, udp,in_port=1 actions=ct(commit,nat(src=10.1.1.240-10.1.1.255),exec(set_field:0x1->ct_mark)),output:2 | |
2820 | n_packets=1, n_bytes=72, ct_state=+rel+trk,ct_mark=0x1,icmp,in_port=2,nw_dst=10.1.1.1 actions=output:1 | |
2821 | n_packets=1, n_bytes=72, ct_state=-trk,icmp,in_port=2 actions=ct(table=0,nat) | |
2822 | n_packets=2, n_bytes=84, priority=100,arp,arp_op=1 actions=move:NXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2823 | table=10, n_packets=1, n_bytes=42, priority=10,arp,arp_op=1 actions=set_field:2->arp_op,move:NXM_NX_ARP_SHA[[]]->NXM_NX_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_NX_ARP_SHA[[]],move:NXM_OF_ARP_SPA[[]]->NXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->NXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],set_field:0->in_port,output:NXM_NX_REG3[[0..15]] | |
2824 | table=10, n_packets=1, n_bytes=42, priority=100,arp,reg0=0,reg1=0 actions=NORMAL | |
2825 | table=8, n_packets=1, n_bytes=42, priority=0 actions=set_field:0->xreg0 | |
2826 | table=8, n_packets=1, n_bytes=42, reg2=0xa0101f0/0xfffffff0 actions=set_field:0x808888888888->xreg0 | |
2827 | OFPST_FLOW reply (OF1.5): | |
2828 | ]) | |
2829 | ||
a857bb69 DDP |
2830 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | sed -e 's/dst=10.1.1.2[[45]][[0-9]]/dst=10.1.1.2XX/'], [0], [dnl |
2831 | udp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.2XX,sport=<cleared>,dport=<cleared>),mark=1 | |
9ac0aada JR |
2832 | ]) |
2833 | ||
2834 | OVS_TRAFFIC_VSWITCHD_STOP | |
2835 | AT_CLEANUP | |
2836 | ||
2cd20955 | 2837 | dnl CHECK_FTP_NAT(TITLE, IP_ADDR, FLOWS, CT_DUMP) |
019c73ac | 2838 | dnl |
74f205f6 JS |
2839 | dnl Checks the implementation of conntrack with FTP ALGs in combination with |
2840 | dnl NAT, using the provided flow table. | |
2841 | m4_define([CHECK_FTP_NAT], | |
2842 | [AT_SETUP([conntrack - FTP NAT $1]) | |
40c7b2fc | 2843 | AT_SKIP_IF([test $HAVE_FTP = no]) |
74f205f6 JS |
2844 | CHECK_CONNTRACK() |
2845 | CHECK_CONNTRACK_NAT() | |
fc9a5ee1 | 2846 | CHECK_CONNTRACK_ALG() |
019c73ac | 2847 | |
74f205f6 | 2848 | OVS_TRAFFIC_VSWITCHD_START() |
019c73ac | 2849 | |
74f205f6 | 2850 | ADD_NAMESPACES(at_ns0, at_ns1) |
019c73ac | 2851 | |
74f205f6 JS |
2852 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") |
2853 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2854 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
019c73ac | 2855 | |
74f205f6 | 2856 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. |
2cd20955 | 2857 | AT_DATA([flows.txt], [$3]) |
019c73ac | 2858 | |
74f205f6 | 2859 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
019c73ac | 2860 | |
7ed40afe | 2861 | OVS_START_L7([at_ns1], [ftp]) |
019c73ac | 2862 | |
74f205f6 JS |
2863 | dnl FTP requests from p0->p1 should work fine. |
2864 | NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 -4 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v --server-response --no-remove-listing -o wget0.log -d]) | |
019c73ac | 2865 | |
74f205f6 | 2866 | dnl Discards CLOSE_WAIT and CLOSING |
2cd20955 | 2867 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [$4]) |
019c73ac | 2868 | |
74f205f6 JS |
2869 | OVS_TRAFFIC_VSWITCHD_STOP |
2870 | AT_CLEANUP]) | |
019c73ac | 2871 | |
74f205f6 JS |
2872 | dnl CHECK_FTP_NAT_PRE_RECIRC(TITLE, IP_ADDR, IP_ADDR_AS_HEX) |
2873 | dnl | |
2874 | dnl Checks the implementation of conntrack with FTP ALGs in combination with | |
2875 | dnl NAT, with flow tables that implement the NATing as part of handling of | |
2876 | dnl initial incoming packets - ie, the first flow is ct(nat,table=foo). | |
2877 | dnl | |
2878 | dnl IP_ADDR must specify the NAT address in standard "10.1.1.x" format, | |
2879 | dnl and IP_ADDR_AS_HEX must specify the same address as hex, eg 0x0a0101xx. | |
2880 | m4_define([CHECK_FTP_NAT_PRE_RECIRC], [dnl | |
2881 | CHECK_FTP_NAT([prerecirc $1], [$2], [dnl | |
9ac0aada JR |
2882 | dnl track all IP traffic, de-mangle non-NEW connections |
2883 | table=0 in_port=1, ip, action=ct(table=1,nat) | |
2884 | table=0 in_port=2, ip, action=ct(table=2,nat) | |
2885 | dnl | |
2886 | dnl ARP | |
2887 | dnl | |
2888 | table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2889 | table=0 priority=10 arp action=normal | |
2890 | table=0 priority=0 action=drop | |
2891 | dnl | |
2892 | dnl Table 1: port 1 -> 2 | |
2893 | dnl | |
2894 | dnl Allow new FTP connections. These need to be commited. | |
74f205f6 | 2895 | table=1 ct_state=+new, tcp, tp_dst=21, nw_src=10.1.1.1, action=ct(alg=ftp,commit,nat(src=$2)),2 |
9ac0aada | 2896 | dnl Allow established TCP connections, make sure they are NATted already. |
74f205f6 | 2897 | table=1 ct_state=+est, tcp, nw_src=$2, action=2 |
9ac0aada JR |
2898 | dnl |
2899 | dnl Table 1: droppers | |
2900 | dnl | |
2901 | table=1 priority=10, tcp, action=drop | |
2902 | table=1 priority=0,action=drop | |
2903 | dnl | |
2904 | dnl Table 2: port 2 -> 1 | |
2905 | dnl | |
2906 | dnl Allow established TCP connections, make sure they are reverse NATted | |
2907 | table=2 ct_state=+est, tcp, nw_dst=10.1.1.1, action=1 | |
2908 | dnl Allow (new) related (data) connections. These need to be commited. | |
74f205f6 | 2909 | table=2 ct_state=+new+rel, tcp, nw_dst=$2, action=ct(commit,nat),1 |
9ac0aada JR |
2910 | dnl Allow related ICMP packets, make sure they are reverse NATted |
2911 | table=2 ct_state=+rel, icmp, nw_dst=10.1.1.1, action=1 | |
2912 | dnl | |
2913 | dnl Table 2: droppers | |
2914 | dnl | |
2915 | table=2 priority=10, tcp, action=drop | |
2916 | table=2 priority=0, action=drop | |
2917 | dnl | |
2918 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2919 | dnl | |
74f205f6 | 2920 | table=8,reg2=$3/0xffffffff,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] |
9ac0aada JR |
2921 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] |
2922 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2923 | dnl TPA IP in reg2. | |
2924 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2925 | table=10 priority=100 arp xreg0=0 action=normal | |
2926 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
2927 | table=10 priority=0 action=drop | |
2cd20955 JR |
2928 | ], [dnl |
2929 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=$2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>),helper=ftp | |
2930 | tcp,orig=(src=10.1.1.2,dst=$2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
2931 | ]) | |
9ac0aada JR |
2932 | ]) |
2933 | ||
74f205f6 JS |
2934 | dnl Check that ct(nat,table=foo) works without TCP sequence adjustment. |
2935 | CHECK_FTP_NAT_PRE_RECIRC([], [10.1.1.9], [0x0a010109]) | |
9ac0aada | 2936 | |
74f205f6 JS |
2937 | dnl Check that ct(nat,table=foo) works with TCP sequence adjustment. |
2938 | dnl | |
2939 | dnl The FTP PORT command includes the ASCII representation of the address, | |
2940 | dnl so when these messages need to be NATed between addresses that have | |
2941 | dnl different lengths when represented in ASCII (such as the original address | |
2942 | dnl of 10.1.1.1 used in the test and 10.1.1.240 here), the FTP NAT ALG must | |
2943 | dnl resize the packet and adjust TCP sequence numbers. This test is kept | |
2944 | dnl separate from the above to easier identify issues in this code on different | |
2945 | dnl kernels. | |
2946 | CHECK_FTP_NAT_PRE_RECIRC([seqadj], [10.1.1.240], [0x0a0101f0]) | |
2947 | ||
2948 | dnl CHECK_FTP_NAT_POST_RECIRC(TITLE, IP_ADDR, IP_ADDR_AS_HEX) | |
2949 | dnl | |
2950 | dnl Checks the implementation of conntrack with FTP ALGs in combination with | |
2951 | dnl NAT, with flow tables that implement the NATing after the first round | |
2952 | dnl of recirculation - that is, the first flow ct(table=foo) then a subsequent | |
2953 | dnl flow will implement the NATing with ct(nat..),output:foo. | |
2954 | dnl | |
2955 | dnl IP_ADDR must specify the NAT address in standard "10.1.1.x" format, | |
2956 | dnl and IP_ADDR_AS_HEX must specify the same address as hex, eg 0x0a0101xx. | |
2957 | m4_define([CHECK_FTP_NAT_POST_RECIRC], [dnl | |
2958 | CHECK_FTP_NAT([postrecirc $1], [$2], [dnl | |
9ac0aada JR |
2959 | dnl track all IP traffic (this includes a helper call to non-NEW packets.) |
2960 | table=0 ip, action=ct(table=1) | |
2961 | dnl | |
2962 | dnl ARP | |
2963 | dnl | |
2964 | table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2965 | table=0 priority=10 arp action=normal | |
2966 | table=0 priority=0 action=drop | |
2967 | dnl | |
2968 | dnl Table 1 | |
2969 | dnl | |
2970 | dnl Allow new FTP connections. These need to be commited. | |
2971 | dnl This does helper for new packets. | |
74f205f6 | 2972 | table=1 in_port=1 ct_state=+new, tcp, tp_dst=21, action=ct(alg=ftp,commit,nat(src=$2)),2 |
9ac0aada JR |
2973 | dnl Allow and NAT established TCP connections |
2974 | table=1 in_port=1 ct_state=+est, tcp, action=ct(nat),2 | |
2975 | table=1 in_port=2 ct_state=+est, tcp, action=ct(nat),1 | |
2976 | dnl Allow and NAT (new) related active (data) connections. | |
2977 | dnl These need to be commited. | |
2978 | table=1 in_port=2 ct_state=+new+rel, tcp, action=ct(commit,nat),1 | |
2979 | dnl Allow related ICMP packets. | |
2980 | table=1 in_port=2 ct_state=+rel, icmp, action=ct(nat),1 | |
2981 | dnl Drop everything else. | |
2982 | table=1 priority=0, action=drop | |
2983 | dnl | |
2984 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2985 | dnl | |
74f205f6 | 2986 | table=8,reg2=$3/0xffffffff,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] |
9ac0aada JR |
2987 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] |
2988 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2989 | dnl TPA IP in reg2. | |
2990 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2991 | table=10 priority=100 arp xreg0=0 action=normal | |
2992 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
2993 | table=10 priority=0 action=drop | |
2cd20955 JR |
2994 | ], [dnl |
2995 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=$2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>),helper=ftp | |
2996 | tcp,orig=(src=10.1.1.2,dst=$2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
2997 | ]) | |
9ac0aada JR |
2998 | ]) |
2999 | ||
74f205f6 JS |
3000 | dnl Check that ct(nat,table=foo) works without TCP sequence adjustment. |
3001 | CHECK_FTP_NAT_POST_RECIRC([], [10.1.1.9], [0x0a010109]) | |
9ac0aada | 3002 | |
74f205f6 JS |
3003 | dnl Check that ct(nat,table=foo) works with TCP sequence adjustment. |
3004 | dnl | |
3005 | dnl The FTP PORT command includes the ASCII representation of the address, | |
3006 | dnl so when these messages need to be NATed between addresses that have | |
3007 | dnl different lengths when represented in ASCII (such as the original address | |
3008 | dnl of 10.1.1.1 used in the test and 10.1.1.240 here), the FTP NAT ALG must | |
3009 | dnl resize the packet and adjust TCP sequence numbers. This test is kept | |
3010 | dnl separate from the above to easier identify issues in this code on different | |
3011 | dnl kernels. | |
3012 | CHECK_FTP_NAT_POST_RECIRC([seqadj], [10.1.1.240], [0x0a0101f0]) | |
9ac0aada | 3013 | |
daf4d3c1 JR |
3014 | |
3015 | dnl CHECK_FTP_NAT_ORIG_TUPLE(TITLE, IP_ADDR, IP_ADDR_AS_HEX) | |
3016 | dnl | |
3017 | dnl Checks the implementation of conntrack original direction tuple matching | |
3018 | dnl with FTP ALGs in combination with NAT, with flow tables that implement | |
3019 | dnl the NATing before the first round of recirculation - that is, the first | |
3020 | dnl flow ct(nat, table=foo) then a subsequent flow will implement the | |
3021 | dnl commiting of NATed and other connections with ct(nat..),output:foo. | |
3022 | dnl | |
3023 | dnl IP_ADDR must specify the NAT address in standard "10.1.1.x" format, | |
3024 | dnl and IP_ADDR_AS_HEX must specify the same address as hex, eg 0x0a0101xx. | |
3025 | m4_define([CHECK_FTP_NAT_ORIG_TUPLE], [dnl | |
3026 | CHECK_FTP_NAT([orig tuple $1], [$2], [dnl | |
2cd20955 JR |
3027 | dnl Store zone in reg4 and packet direction in reg3 (IN=1, OUT=2). |
3028 | dnl NAT is only applied to OUT-direction packets, so that ACL | |
3029 | dnl processing can be done with non-NATted headers. | |
3030 | dnl | |
3031 | dnl Track all IP traffic in the IN-direction (IN from Port 1). | |
3032 | table=0 in_port=1, ip, action=set_field:1->reg4,set_field:1->reg3,ct(zone=NXM_NX_REG4[[0..15]],table=1) | |
3033 | dnl Track all IP traffic in the OUT-direction (OUT to the Port 1). | |
3034 | table=0 in_port=2, ip, action=set_field:1->reg4,set_field:2->reg3,ct(zone=NXM_NX_REG4[[0..15]],nat,table=1) | |
daf4d3c1 JR |
3035 | dnl |
3036 | dnl ARP | |
3037 | dnl | |
3038 | table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
3039 | table=0 priority=10 arp action=normal | |
3040 | table=0 priority=0 action=drop | |
3041 | dnl | |
2cd20955 JR |
3042 | dnl Pass tracked traffic through ACL, drop everything else. |
3043 | dnl Non-REPLY/RELATED packets get the ACL lookup with the packet headers | |
3044 | dnl in the actual packet direction in reg0 (IN=1, OUT=2). REPLY packets | |
3045 | dnl get the ACL lookup using the conntrack tuple and the inverted direction. | |
3046 | dnl RELATED packets get ACL lookup using the conntrack tuple in the direction | |
3047 | dnl of the master connection, as storted in ct_mark. | |
3048 | dnl | |
3049 | dnl Incoming non-related packet in the original direction (ACL IN) | |
3050 | table=1 reg3=1, ip, ct_state=-rel-rpl+trk-inv action=set_field:1->reg0,resubmit(,3),goto_table:5 | |
3051 | dnl Incoming non-related reply packet (CT ACL OUT) | |
3052 | table=1 reg3=1, ip, ct_state=-rel+rpl+trk-inv action=set_field:2->reg0,resubmit(,3,ct),goto_table:4 | |
3053 | dnl Outgoing non-related packet (ACL OUT) | |
3054 | table=1 reg3=2, ip, ct_state=-rel-rpl+trk-inv action=set_field:2->reg0,resubmit(,3),goto_table:5 | |
3055 | dnl Outgoing non-related reply packet (CT ACL IN) | |
3056 | table=1 reg3=2, ip, ct_state=-rel+rpl+trk-inv action=set_field:1->reg0,resubmit(,3,ct),goto_table:4 | |
daf4d3c1 | 3057 | dnl |
2cd20955 JR |
3058 | dnl Related packet (CT ACL in the direction of the master connection.) |
3059 | table=1 ip, ct_state=+rel+trk-inv, action=move:NXM_NX_CT_MARK[[]]->NXM_NX_REG0[[]],resubmit(,3,ct),goto_table:4 | |
daf4d3c1 JR |
3060 | dnl Drop everything else. |
3061 | table=1 priority=0, action=drop | |
3062 | dnl | |
2cd20955 JR |
3063 | dnl "ACL table" |
3064 | dnl | |
3065 | dnl Stateful accept (1->reg2) all incoming (reg0=1) IP connections with | |
3066 | dnl IP source address '10.1.1.1'. Store rule ID (1234) in reg1, verdict | |
3067 | dnl in reg2. | |
3068 | table=3 priority=10, reg0=1, ip, nw_src=10.1.1.1 action=set_field:1234->reg1,set_field:1->reg2 | |
3069 | dnl Stateless drop (0->reg2) everything else in both directions. (Rule ID: 1235) | |
3070 | table=3 priority=0, action=set_field:1235->reg1,set_field:0->reg2 | |
3071 | dnl | |
3072 | dnl Re-process stateful traffic that was not accepted by a stateful rule as | |
3073 | dnl normal traffic in the current direction. This should also delete the | |
3074 | dnl now stale conntrack state, so that new state can be created in it's place. | |
3075 | dnl | |
3076 | dnl Stateful accepts go to next table. | |
3077 | table=4 priority=100 reg2=1, action=goto_table:5 | |
3078 | dnl Everything else is reprocessed disregarding the CT state, using the actual | |
3079 | dnl packet direction. | |
3080 | table=4 priority=0 action=move:NXM_NX_REG3[[]]->NXM_NX_REG0[[]],resubmit(,3),goto_table:5 | |
3081 | dnl | |
3082 | dnl "ACL verdict processing table." | |
3083 | dnl | |
3084 | dnl Handle stateful (reg2=1) / stateless (reg2=2) accepts and drops (reg2=0) | |
3085 | dnl | |
3086 | dnl Drop all non-accepted packets. | |
3087 | table=5 reg2=0 priority=1000 action=drop | |
daf4d3c1 | 3088 | dnl |
2cd20955 JR |
3089 | dnl Commit new incoming FTP control connections with SNAT range. Must match on |
3090 | dnl 'tcp' when setting 'alg=ftp'. Store the directionality of non-related | |
3091 | dnl connections to ct_mark. Store the rule ID to labels. | |
3092 | table=5 priority=100 reg2=1 reg3=1 ct_state=+new-rel, tcp, tp_dst=21, action=ct(zone=NXM_NX_REG4[[0..15]],alg=ftp,commit,nat(src=$2),exec(move:NXM_NX_REG3[[0..31]]->NXM_NX_CT_MARK[[0..31]],move:NXM_NX_REG1[[0..31]]->NXM_NX_CT_LABEL[[96..127]])),goto_table:6 | |
3093 | dnl Commit other new incoming non-related IP connections with SNAT range. | |
3094 | table=5 priority=10 reg2=1 reg3=1 ct_state=+new-rel, ip, action=ct(zone=NXM_NX_REG4[[0..15]],commit,nat(src=$2),exec(move:NXM_NX_REG3[[0..31]]->NXM_NX_CT_MARK[[0..31]],move:NXM_NX_REG1[[0..31]]->NXM_NX_CT_LABEL[[96..127]])),goto_table:6 | |
3095 | dnl Commit non-related outgoing new IP connections with DNAT range. | |
3096 | dnl (This should not get any packets in this test.) | |
3097 | table=5 priority=10 reg2=1 reg3=2 ct_state=+new-rel, ip, action=ct(zone=NXM_NX_REG4[[0..15]],commit,nat(dst=$2),exec(move:NXM_NX_REG3[[0..31]]->NXM_NX_CT_MARK[[0..31]],move:NXM_NX_REG1[[0..31]]->NXM_NX_CT_LABEL[[96..127]])),goto_table:6 | |
3098 | dnl Commit new related connections in either direction, which need 'nat' | |
3099 | dnl and which inherit the mark (the direction of the original direction | |
3100 | dnl master tuple) from the master connection. | |
3101 | table=5 priority=10 reg2=1 ct_state=+new+rel, ip, action=ct(zone=NXM_NX_REG4[[0..15]],commit,nat,exec(move:NXM_NX_REG1[[0..31]]->NXM_NX_CT_LABEL[[96..127]])),goto_table:6 | |
3102 | dnl | |
3103 | dnl NAT incoming non-NEW packets. Outgoing packets were NATted in table 0. | |
3104 | dnl | |
3105 | table=5 priority=10 ct_state=-new+trk-inv reg3=1 ip, action=ct(zone=NXM_NX_REG4[[0..15]],nat),goto_table:6 | |
3106 | dnl Forward everything else, including stateless accepts. | |
3107 | table=5 priority=0 action=goto_table:6 | |
3108 | dnl | |
3109 | dnl "Forwarding table" | |
3110 | dnl | |
3111 | table=6 in_port=1 action=2 | |
3112 | table=6 in_port=2 action=1 | |
daf4d3c1 JR |
3113 | dnl |
3114 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
3115 | dnl | |
2cd20955 | 3116 | table=8,reg2=$3,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] |
daf4d3c1 JR |
3117 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] |
3118 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
3119 | dnl TPA IP in reg2. | |
3120 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
3121 | table=10 priority=100 arp xreg0=0 action=normal | |
3122 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
3123 | table=10 priority=0 action=drop | |
2cd20955 JR |
3124 | ], [dnl |
3125 | tcp,orig=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=$2,sport=<cleared>,dport=<cleared>),zone=1,mark=1,labels=0x4d2000000000000000000000000,protoinfo=(state=<cleared>),helper=ftp | |
3126 | tcp,orig=(src=10.1.1.2,dst=$2,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.1,dst=10.1.1.2,sport=<cleared>,dport=<cleared>),zone=1,mark=1,labels=0x4d2000000000000000000000000,protoinfo=(state=<cleared>) | |
3127 | ]) | |
daf4d3c1 JR |
3128 | ]) |
3129 | ||
3130 | dnl Check that ct(nat,table=foo) works without TCP sequence adjustment with | |
3131 | dnl an ACL table based on matching on conntrack original direction tuple only. | |
3132 | CHECK_FTP_NAT_ORIG_TUPLE([], [10.1.1.9], [0x0a010109]) | |
3133 | ||
3134 | dnl Check that ct(nat,table=foo) works with TCP sequence adjustment with | |
3135 | dnl an ACL table based on matching on conntrack original direction tuple only. | |
3136 | CHECK_FTP_NAT_ORIG_TUPLE([seqadj], [10.1.1.240], [0x0a0101f0]) | |
3137 | ||
9ac0aada JR |
3138 | AT_SETUP([conntrack - IPv6 HTTP with NAT]) |
3139 | CHECK_CONNTRACK() | |
4573c42e | 3140 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
3141 | OVS_TRAFFIC_VSWITCHD_START() |
3142 | ||
3143 | ADD_NAMESPACES(at_ns0, at_ns1) | |
3144 | ||
3145 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
3146 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
3147 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
3148 | NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::240 lladdr 80:88:88:88:88:88 dev p1]) | |
3149 | ||
3150 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
3151 | AT_DATA([flows.txt], [dnl | |
3152 | priority=1,action=drop | |
3153 | priority=10,icmp6,action=normal | |
3154 | priority=100,in_port=1,ip6,action=ct(commit,nat(src=fc00::240)),2 | |
3155 | priority=100,in_port=2,ct_state=-trk,ip6,action=ct(nat,table=0) | |
3156 | priority=100,in_port=2,ct_state=+trk+est,ip6,action=1 | |
3157 | priority=200,in_port=2,ct_state=+trk+new,icmp6,icmpv6_code=0,icmpv6_type=135,nd_target=fc00::240,action=ct(commit,nat(dst=fc00::1)),1 | |
3158 | ]) | |
3159 | ||
3160 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
3161 | ||
c10840ff JS |
3162 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
3163 | dnl waiting, we get occasional failures due to the following error: | |
9ac0aada | 3164 | dnl "connect: Cannot assign requested address" |
c10840ff | 3165 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) |
9ac0aada JR |
3166 | |
3167 | dnl HTTP requests from ns0->ns1 should work fine. | |
7ed40afe | 3168 | OVS_START_L7([at_ns1], [http6]) |
9ac0aada JR |
3169 | |
3170 | NS_CHECK_EXEC([at_ns0], [wget http://[[fc00::2]] -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
3171 | ||
3172 | dnl HTTP requests from ns1->ns0 should fail due to network failure. | |
3173 | dnl Try 3 times, in 1 second intervals. | |
7ed40afe | 3174 | OVS_START_L7([at_ns0], [http6]) |
9ac0aada JR |
3175 | NS_CHECK_EXEC([at_ns1], [wget http://[[fc00::1]] -t 3 -T 1 -v -o wget1.log], [4]) |
3176 | ||
3177 | OVS_TRAFFIC_VSWITCHD_STOP | |
3178 | AT_CLEANUP | |
3179 | ||
3180 | ||
3181 | AT_SETUP([conntrack - IPv6 FTP with NAT]) | |
40c7b2fc | 3182 | AT_SKIP_IF([test $HAVE_FTP = no]) |
9ac0aada | 3183 | CHECK_CONNTRACK() |
4573c42e | 3184 | CHECK_CONNTRACK_NAT() |
fc9a5ee1 DB |
3185 | CHECK_CONNTRACK_ALG() |
3186 | ||
9ac0aada JR |
3187 | OVS_TRAFFIC_VSWITCHD_START() |
3188 | ||
3189 | ADD_NAMESPACES(at_ns0, at_ns1) | |
3190 | ||
3191 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
3192 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
3193 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
3194 | dnl Would be nice if NAT could translate neighbor discovery messages, too. | |
3195 | NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::240 lladdr 80:88:88:88:88:88 dev p1]) | |
3196 | ||
3197 | dnl Allow any traffic from ns0->ns1. | |
3198 | dnl Only allow nd, return traffic from ns1->ns0. | |
3199 | AT_DATA([flows.txt], [dnl | |
9ac0aada JR |
3200 | dnl track all IPv6 traffic (this includes NAT & help to non-NEW packets.) |
3201 | table=0 priority=10 ip6, action=ct(nat,table=1) | |
3202 | table=0 priority=0 action=drop | |
3203 | dnl | |
3204 | dnl Table 1 | |
3205 | dnl | |
3206 | dnl Allow new TCPv6 FTP control connections. | |
3207 | table=1 in_port=1 ct_state=+new tcp6 ipv6_src=fc00::1 tp_dst=21 action=ct(alg=ftp,commit,nat(src=fc00::240)),2 | |
3208 | dnl Allow related TCPv6 connections from port 2 to the NATted address. | |
3209 | table=1 in_port=2 ct_state=+new+rel tcp6 ipv6_dst=fc00::240 action=ct(commit,nat),1 | |
3210 | dnl Allow established TCPv6 connections both ways, enforce NATting | |
3211 | table=1 in_port=1 ct_state=+est tcp6 ipv6_src=fc00::240 action=2 | |
3212 | table=1 in_port=2 ct_state=+est tcp6 ipv6_dst=fc00::1 action=1 | |
daf4d3c1 JR |
3213 | dnl Allow other ICMPv6 both ways (without commit). |
3214 | table=1 priority=100 in_port=1 icmp6, action=2 | |
3215 | table=1 priority=100 in_port=2 icmp6, action=1 | |
9ac0aada JR |
3216 | dnl Drop everything else. |
3217 | table=1 priority=0, action=drop | |
3218 | ]) | |
3219 | ||
3220 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
3221 | ||
c10840ff JS |
3222 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
3223 | dnl waiting, we get occasional failures due to the following error: | |
3224 | dnl "connect: Cannot assign requested address" | |
3225 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2 >/dev/null]) | |
3226 | ||
7ed40afe | 3227 | OVS_START_L7([at_ns1], [ftp]) |
9ac0aada JR |
3228 | |
3229 | dnl FTP requests from p0->p1 should work fine. | |
4fee8b13 | 3230 | NS_CHECK_EXEC([at_ns0], [wget ftp://[[fc00::2]] -6 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v --server-response --no-remove-listing -o wget0.log -d]) |
9ac0aada | 3231 | |
a857bb69 | 3232 | dnl Discards CLOSE_WAIT and CLOSING |
420c73b2 JR |
3233 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl |
3234 | tcp,orig=(src=fc00::1,dst=fc00::2,sport=<cleared>,dport=<cleared>),reply=(src=fc00::2,dst=fc00::240,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>),helper=ftp | |
3235 | tcp,orig=(src=fc00::2,dst=fc00::240,sport=<cleared>,dport=<cleared>),reply=(src=fc00::1,dst=fc00::2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
9ac0aada JR |
3236 | ]) |
3237 | ||
3238 | OVS_TRAFFIC_VSWITCHD_STOP | |
3239 | AT_CLEANUP | |
2c66ebe4 | 3240 | |
daf4d3c1 JR |
3241 | |
3242 | AT_SETUP([conntrack - IPv6 FTP with NAT - orig tuple]) | |
3243 | AT_SKIP_IF([test $HAVE_FTP = no]) | |
3244 | CHECK_CONNTRACK() | |
3245 | CHECK_CONNTRACK_NAT() | |
3246 | OVS_TRAFFIC_VSWITCHD_START() | |
3247 | ||
3248 | ADD_NAMESPACES(at_ns0, at_ns1) | |
3249 | ||
3250 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
3251 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
3252 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
3253 | dnl Would be nice if NAT could translate neighbor discovery messages, too. | |
3254 | NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::240 lladdr 80:88:88:88:88:88 dev p1]) | |
3255 | ||
3256 | dnl Allow any traffic from ns0->ns1. | |
3257 | dnl Only allow nd, return traffic from ns1->ns0. | |
3258 | AT_DATA([flows.txt], [dnl | |
3259 | dnl track all IPv6 traffic (this includes NAT & help to non-NEW packets.) | |
3260 | table=0 priority=10 ip6, action=ct(nat,table=1) | |
3261 | table=0 priority=0 action=drop | |
3262 | dnl | |
3263 | dnl Table 1 | |
3264 | dnl | |
3265 | dnl Allow other ICMPv6 both ways (without commit). | |
3266 | table=1 priority=100 in_port=1 icmp6, action=2 | |
3267 | table=1 priority=100 in_port=2 icmp6, action=1 | |
3268 | dnl Allow new TCPv6 FTP control connections. | |
3269 | table=1 priority=10 in_port=1 ct_state=+new+trk-inv tcp6 ct_nw_proto=6 ct_ipv6_src=fc00::1 ct_tp_dst=21 action=ct(alg=ftp,commit,nat(src=fc00::240)),2 | |
3270 | dnl Allow related TCPv6 connections from port 2 to the NATted address. | |
3271 | table=1 priority=10 in_port=2 ct_state=+new+rel+trk-inv ipv6 ct_nw_proto=6 ct_ipv6_src=fc00::1 ct_tp_dst=21 action=ct(commit,nat),1 | |
3272 | dnl Allow established TCPv6 connections both ways, enforce NATting | |
3273 | table=1 priority=10 in_port=1 ct_state=+est+trk-inv ipv6 ct_nw_proto=6 ct_ipv6_src=fc00::1 ct_tp_dst=21 action=2 | |
3274 | table=1 priority=10 in_port=2 ct_state=+est+trk-inv ipv6 ct_nw_proto=6 ct_ipv6_src=fc00::1 ct_tp_dst=21 action=1 | |
3275 | dnl Drop everything else. | |
3276 | table=1 priority=0, action=drop | |
3277 | ]) | |
3278 | ||
3279 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
3280 | ||
3281 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without | |
3282 | dnl waiting, we get occasional failures due to the following error: | |
3283 | dnl "connect: Cannot assign requested address" | |
3284 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2 >/dev/null]) | |
3285 | ||
3286 | NETNS_DAEMONIZE([at_ns1], [[$PYTHON $srcdir/test-l7.py ftp]], [ftp0.pid]) | |
3287 | OVS_WAIT_UNTIL([ip netns exec at_ns1 netstat -l | grep ftp]) | |
3288 | ||
3289 | dnl FTP requests from p0->p1 should work fine. | |
3290 | NS_CHECK_EXEC([at_ns0], [wget ftp://[[fc00::2]] -6 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v --server-response --no-remove-listing -o wget0.log -d]) | |
3291 | ||
3292 | dnl Discards CLOSE_WAIT and CLOSING | |
3293 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl | |
3294 | tcp,orig=(src=fc00::1,dst=fc00::2,sport=<cleared>,dport=<cleared>),reply=(src=fc00::2,dst=fc00::240,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>),helper=ftp | |
3295 | tcp,orig=(src=fc00::2,dst=fc00::240,sport=<cleared>,dport=<cleared>),reply=(src=fc00::1,dst=fc00::2,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
3296 | ]) | |
3297 | ||
3298 | OVS_TRAFFIC_VSWITCHD_STOP | |
3299 | AT_CLEANUP | |
3300 | ||
3301 | ||
2c66ebe4 JR |
3302 | AT_SETUP([conntrack - DNAT load balancing]) |
3303 | CHECK_CONNTRACK() | |
4573c42e | 3304 | CHECK_CONNTRACK_NAT() |
2c66ebe4 JR |
3305 | OVS_TRAFFIC_VSWITCHD_START() |
3306 | ||
3307 | ADD_NAMESPACES(at_ns1, at_ns2, at_ns3, at_ns4) | |
3308 | ||
3309 | ADD_VETH(p1, at_ns1, br0, "10.1.1.1/24") | |
3310 | ADD_VETH(p2, at_ns2, br0, "10.1.1.2/24") | |
3311 | ADD_VETH(p3, at_ns3, br0, "10.1.1.3/24") | |
3312 | ADD_VETH(p4, at_ns4, br0, "10.1.1.4/24") | |
3313 | NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address 80:88:88:88:88:11]) | |
3314 | NS_CHECK_EXEC([at_ns2], [ip link set dev p2 address 80:88:88:88:88:22]) | |
3315 | NS_CHECK_EXEC([at_ns3], [ip link set dev p3 address 80:88:88:88:88:33]) | |
3316 | NS_CHECK_EXEC([at_ns4], [ip link set dev p4 address 80:88:88:88:88:44]) | |
3317 | ||
3318 | dnl Select group for load balancing. One bucket per server. Each bucket | |
3319 | dnl tracks and NATs the connection and recirculates to table 4 for egress | |
3320 | dnl routing. Packets of existing connections are always NATted based on | |
3321 | dnl connection state, only new connections are NATted according to the | |
3322 | dnl specific NAT parameters in each bucket. | |
3323 | AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn add-group br0 "group_id=234,type=select,bucket=weight=100,ct(nat(dst=10.1.1.2),commit,table=4),bucket=weight=100,ct(nat(dst=10.1.1.3),commit,table=4),bucket=weight=100,ct(nat(dst=10.1.1.4),commit,table=4)"]) | |
3324 | ||
3325 | AT_DATA([flows.txt], [dnl | |
3326 | dnl Track connections to the virtual IP address. | |
3327 | table=0 priority=100 ip nw_dst=10.1.1.64 action=group:234 | |
3328 | dnl All other IP traffic is allowed but the connection state is no commited. | |
3329 | table=0 priority=90 ip action=ct(table=4,nat) | |
3330 | dnl | |
3331 | dnl Allow ARP, but generate responses for virtual addresses | |
3332 | table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
3333 | table=0 priority=10 arp action=normal | |
3334 | table=0 priority=0 action=drop | |
3335 | dnl | |
3336 | dnl Routing table | |
3337 | dnl | |
3338 | table=4,ip,nw_dst=10.1.1.1 action=mod_dl_dst:80:88:88:88:88:11,output:1 | |
3339 | table=4,ip,nw_dst=10.1.1.2 action=mod_dl_dst:80:88:88:88:88:22,output:2 | |
3340 | table=4,ip,nw_dst=10.1.1.3 action=mod_dl_dst:80:88:88:88:88:33,output:3 | |
3341 | table=4,ip,nw_dst=10.1.1.4 action=mod_dl_dst:80:88:88:88:88:44,output:4 | |
3342 | table=4 priority=0 action=drop | |
3343 | dnl | |
3344 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
3345 | table=8,reg2=0x0a010140,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
3346 | dnl Zero result means not found. | |
3347 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
3348 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
3349 | dnl TPA IP in reg2. | |
3350 | table=10 priority=100 arp xreg0=0 action=normal | |
3351 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
3352 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
3353 | table=10 priority=0 action=controller | |
3354 | ]) | |
3355 | ||
3356 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
3357 | ||
3358 | dnl Start web servers | |
7ed40afe JS |
3359 | OVS_START_L7([at_ns2], [http]) |
3360 | OVS_START_L7([at_ns3], [http]) | |
3361 | OVS_START_L7([at_ns4], [http]) | |
2c66ebe4 JR |
3362 | |
3363 | on_exit 'ovs-ofctl -O OpenFlow15 dump-flows br0' | |
3364 | on_exit 'ovs-appctl revalidator/purge' | |
3365 | on_exit 'ovs-appctl dpif/dump-flows br0' | |
3366 | ||
3367 | dnl Should work with the virtual IP address through NAT | |
3368 | for i in 1 2 3 4 5 6 7 8 9 10 11 12; do | |
3369 | echo Request $i | |
3370 | NS_CHECK_EXEC([at_ns1], [wget 10.1.1.64 -t 5 -T 1 --retry-connrefused -v -o wget$i.log]) | |
3371 | done | |
3372 | ||
3373 | dnl Each server should have at least one connection. | |
420c73b2 JR |
3374 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.64)], [0], [dnl |
3375 | tcp,orig=(src=10.1.1.1,dst=10.1.1.64,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.2,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
3376 | tcp,orig=(src=10.1.1.1,dst=10.1.1.64,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.3,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
3377 | tcp,orig=(src=10.1.1.1,dst=10.1.1.64,sport=<cleared>,dport=<cleared>),reply=(src=10.1.1.4,dst=10.1.1.1,sport=<cleared>,dport=<cleared>),protoinfo=(state=<cleared>) | |
2c66ebe4 JR |
3378 | ]) |
3379 | ||
3380 | ovs-appctl dpif/dump-flows br0 | |
3381 | ovs-appctl revalidator/purge | |
3382 | ovs-ofctl -O OpenFlow15 dump-flows br0 | |
3383 | ovs-ofctl -O OpenFlow15 dump-group-stats br0 | |
3384 | ||
3385 | OVS_TRAFFIC_VSWITCHD_STOP | |
3386 | AT_CLEANUP | |
3387 | ||
3388 | ||
3389 | AT_SETUP([conntrack - DNAT load balancing with NC]) | |
9c1ab985 | 3390 | AT_SKIP_IF([test $HAVE_NC = no]) |
2c66ebe4 | 3391 | CHECK_CONNTRACK() |
4573c42e | 3392 | CHECK_CONNTRACK_NAT() |
2c66ebe4 JR |
3393 | OVS_TRAFFIC_VSWITCHD_START() |
3394 | ||
3395 | ADD_NAMESPACES(at_ns1, at_ns2, at_ns3, at_ns4, at_ns5) | |
3396 | ||
3397 | ADD_VETH(p1, at_ns1, br0, "10.1.1.1/24") | |
3398 | ADD_VETH(p2, at_ns2, br0, "10.1.1.2/24") | |
3399 | ADD_VETH(p3, at_ns3, br0, "10.1.1.3/24") | |
3400 | ADD_VETH(p4, at_ns4, br0, "10.1.1.4/24") | |
3401 | ADD_VETH(p5, at_ns5, br0, "10.1.1.5/24") | |
3402 | NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address 80:88:88:88:88:11]) | |
3403 | NS_CHECK_EXEC([at_ns2], [ip link set dev p2 address 80:88:88:88:88:22]) | |
3404 | NS_CHECK_EXEC([at_ns3], [ip link set dev p3 address 80:88:88:88:88:33]) | |
3405 | NS_CHECK_EXEC([at_ns4], [ip link set dev p4 address 80:88:88:88:88:44]) | |
3406 | NS_CHECK_EXEC([at_ns5], [ip link set dev p5 address 80:88:88:88:88:55]) | |
3407 | ||
3408 | dnl Select group for load balancing. One bucket per server. Each bucket | |
3409 | dnl tracks and NATs the connection and recirculates to table 4 for egress | |
3410 | dnl routing. Packets of existing connections are always NATted based on | |
3411 | dnl connection state, only new connections are NATted according to the | |
3412 | dnl specific NAT parameters in each bucket. | |
3413 | AT_CHECK([ovs-ofctl -O OpenFlow15 -vwarn add-group br0 "group_id=234,type=select,bucket=weight=100,ct(nat(dst=10.1.1.2),commit,table=4),bucket=weight=100,ct(nat(dst=10.1.1.3),commit,table=4),bucket=weight=100,ct(nat(dst=10.1.1.4),commit,table=4)"]) | |
3414 | ||
3415 | AT_DATA([flows.txt], [dnl | |
3416 | dnl Track connections to the virtual IP address. | |
3417 | table=0 priority=100 ip nw_dst=10.1.1.64 action=group:234 | |
3418 | dnl All other IP traffic is allowed but the connection state is no commited. | |
3419 | table=0 priority=90 ip action=ct(table=4,nat) | |
3420 | dnl | |
3421 | dnl Allow ARP, but generate responses for virtual addresses | |
3422 | table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
3423 | table=0 priority=10 arp action=normal | |
3424 | table=0 priority=0 action=drop | |
3425 | dnl | |
3426 | dnl Routing table | |
3427 | dnl | |
3428 | table=4,ip,nw_dst=10.1.1.1 action=mod_dl_dst:80:88:88:88:88:11,output:1 | |
3429 | table=4,ip,nw_dst=10.1.1.2 action=mod_dl_dst:80:88:88:88:88:22,output:2 | |
3430 | table=4,ip,nw_dst=10.1.1.3 action=mod_dl_dst:80:88:88:88:88:33,output:3 | |
3431 | table=4,ip,nw_dst=10.1.1.4 action=mod_dl_dst:80:88:88:88:88:44,output:4 | |
3432 | table=4,ip,nw_dst=10.1.1.5 action=mod_dl_dst:80:88:88:88:88:55,output:5 | |
3433 | table=4 priority=0 action=drop | |
3434 | dnl | |
3435 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
3436 | table=8,reg2=0x0a010140,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
3437 | dnl Zero result means not found. | |
3438 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
3439 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
3440 | dnl TPA IP in reg2. | |
3441 | table=10 priority=100 arp xreg0=0 action=normal | |
3442 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
3443 | table=10 priority=10,arp,arp_op=1,action=load:2->OXM_OF_ARP_OP[[]],move:OXM_OF_ARP_SHA[[]]->OXM_OF_ARP_THA[[]],move:OXM_OF_PKT_REG0[[0..47]]->OXM_OF_ARP_SHA[[]],move:OXM_OF_ARP_SPA[[]]->OXM_OF_ARP_TPA[[]],move:NXM_NX_REG2[[]]->OXM_OF_ARP_SPA[[]],move:NXM_OF_ETH_SRC[[]]->NXM_OF_ETH_DST[[]],move:OXM_OF_PKT_REG0[[0..47]]->NXM_OF_ETH_SRC[[]],move:NXM_OF_IN_PORT[[]]->NXM_NX_REG3[[0..15]],load:0->NXM_OF_IN_PORT[[]],output:NXM_NX_REG3[[0..15]] | |
3444 | table=10 priority=0 action=controller | |
3445 | ]) | |
3446 | ||
3447 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
3448 | ||
3449 | dnl Start web servers | |
7ed40afe JS |
3450 | OVS_START_L7([at_ns2], [http]) |
3451 | OVS_START_L7([at_ns3], [http]) | |
3452 | OVS_START_L7([at_ns4], [http]) | |
2c66ebe4 JR |
3453 | |
3454 | on_exit 'ovs-ofctl -O OpenFlow15 dump-flows br0' | |
3455 | on_exit 'ovs-appctl revalidator/purge' | |
3456 | on_exit 'ovs-appctl dpif/dump-flows br0' | |
3457 | ||
3458 | sleep 5 | |
3459 | ||
3460 | dnl Should work with the virtual IP address through NAT | |
3461 | for i in 1 2 3 4 5 6 7 8 9; do | |
3462 | echo Request $i | |
3463 | NS_CHECK_EXEC([at_ns1], [echo "TEST1" | nc -p 4100$i 10.1.1.64 80 > nc-1-$i.log]) | |
3464 | NS_CHECK_EXEC([at_ns5], [echo "TEST5" | nc -p 4100$i 10.1.1.64 80 > nc-5-$i.log]) | |
3465 | done | |
3466 | ||
3467 | conntrack -L 2>&1 | |
3468 | ||
3469 | ovs-appctl dpif/dump-flows br0 | |
3470 | ovs-appctl revalidator/purge | |
3471 | ovs-ofctl -O OpenFlow15 dump-flows br0 | |
3472 | ovs-ofctl -O OpenFlow15 dump-group-stats br0 | |
3473 | ||
3474 | OVS_TRAFFIC_VSWITCHD_STOP | |
3475 | AT_CLEANUP | |
b4fa814c EG |
3476 | |
3477 | AT_BANNER([802.1ad]) | |
3478 | ||
3479 | AT_SETUP([802.1ad - vlan_limit]) | |
3480 | OVS_TRAFFIC_VSWITCHD_START([set Open_vSwitch . other_config:vlan-limit=0]) | |
3481 | OVS_CHECK_8021AD() | |
3482 | ||
3483 | ADD_NAMESPACES(at_ns0, at_ns1) | |
3484 | ||
3485 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
3486 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
3487 | ||
3488 | ADD_SVLAN(p0, at_ns0, 4094, "10.255.2.1/24") | |
3489 | ADD_SVLAN(p1, at_ns1, 4094, "10.255.2.2/24") | |
3490 | ||
3491 | ADD_CVLAN(p0.4094, at_ns0, 100, "10.2.2.1/24") | |
3492 | ADD_CVLAN(p1.4094, at_ns1, 100, "10.2.2.2/24") | |
3493 | ||
3494 | AT_CHECK([ovs-ofctl add-flow br0 "priority=1 action=normal"]) | |
3495 | ||
3496 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping -c 1 10.2.2.2]) | |
3497 | ||
3498 | dnl CVLAN traffic should match the flow and drop | |
3499 | AT_CHECK([ovs-appctl revalidator/purge]) | |
3500 | AT_CHECK([ovs-vsctl set Open_vSwitch . other_config:vlan-limit=1]) | |
3501 | AT_CHECK([ovs-ofctl add-flow br0 "priority=100 dl_type=0x8100 action=drop"]) | |
3502 | NS_CHECK_EXEC([at_ns0], [ping -q -c 1 -w 3 10.2.2.2], [1], [ignore]) | |
3503 | ||
3504 | OVS_TRAFFIC_VSWITCHD_STOP | |
3505 | AT_CLEANUP | |
0147a20e EG |
3506 | |
3507 | ||
3508 | AT_SETUP([802.1ad - push/pop outer 802.1ad]) | |
3509 | OVS_TRAFFIC_VSWITCHD_START([set Open_vSwitch . other_config:vlan-limit=0]) | |
3510 | OVS_CHECK_8021AD() | |
3511 | ||
3512 | ADD_BR([br1]) | |
3513 | ADD_BR([br2]) | |
3514 | ADD_NAMESPACES(at_ns0, at_ns1) | |
3515 | ||
3516 | AT_CHECK([ip link add ovs-p0 type veth peer name ovs-p1]) | |
3517 | AT_CHECK([ip link set dev ovs-p0 up]) | |
3518 | AT_CHECK([ip link set dev ovs-p1 up]) | |
3519 | AT_CHECK([ovs-vsctl add-port br0 ovs-p0]) | |
3520 | AT_CHECK([ovs-vsctl add-port br1 ovs-p1]) | |
3521 | on_exit 'ip link del ovs-p0' | |
3522 | ||
3523 | AT_CHECK([ip link add ovs-p2 type veth peer name ovs-p3]) | |
3524 | AT_CHECK([ip link set dev ovs-p2 up]) | |
3525 | AT_CHECK([ip link set dev ovs-p3 up]) | |
3526 | AT_CHECK([ovs-vsctl add-port br0 ovs-p2]) | |
3527 | AT_CHECK([ovs-vsctl add-port br2 ovs-p3]) | |
3528 | on_exit 'ip link del ovs-p2' | |
3529 | ||
3530 | ADD_VETH(p4, at_ns0, br1, "10.1.1.1/24") | |
3531 | ADD_VETH(p5, at_ns1, br2, "10.1.1.2/24") | |
3532 | ADD_CVLAN(p4, at_ns0, 100, "10.2.2.1/24") | |
3533 | ADD_CVLAN(p5, at_ns1, 100, "10.2.2.2/24") | |
3534 | ||
3535 | AT_DATA([flows-br0.txt], [dnl | |
3536 | priority=1 action=drop | |
3537 | priority=100 in_port=1 action=push_vlan:0x88a8,mod_vlan_vid=4094,output:2 | |
3538 | priority=100 in_port=2 action=push_vlan:0x88a8,mod_vlan_vid=4094,output:1 | |
3539 | ]) | |
3540 | ||
3541 | AT_DATA([flows-customer-br.txt], [dnl | |
3542 | priority=1 action=normal | |
3543 | priority=100 in_port=1 vlan_tci=0x1000/0x1000 action=pop_vlan,normal | |
3544 | ]) | |
3545 | ||
3546 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows-br0.txt]) | |
3547 | AT_CHECK([ovs-ofctl --bundle add-flows br1 flows-customer-br.txt]) | |
3548 | AT_CHECK([ovs-ofctl --bundle add-flows br2 flows-customer-br.txt]) | |
3549 | ||
3550 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping -c 1 10.2.2.2]) | |
3551 | ||
3552 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
3553 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
3554 | ]) | |
3555 | ||
3556 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
3557 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
3558 | ]) | |
3559 | ||
3560 | OVS_TRAFFIC_VSWITCHD_STOP | |
3561 | AT_CLEANUP | |
3562 | ||
3563 | ||
3564 | AT_SETUP([802.1ad - push/pop outer 802.1q]) | |
3565 | OVS_TRAFFIC_VSWITCHD_START([set Open_vSwitch . other_config:vlan-limit=0]) | |
3566 | OVS_CHECK_8021AD() | |
3567 | ||
3568 | ADD_BR([br1]) | |
3569 | ADD_BR([br2]) | |
3570 | ADD_NAMESPACES(at_ns0, at_ns1) | |
3571 | ||
3572 | AT_CHECK([ip link add ovs-p0 type veth peer name ovs-p1]) | |
3573 | AT_CHECK([ip link set dev ovs-p0 up]) | |
3574 | AT_CHECK([ip link set dev ovs-p1 up]) | |
3575 | AT_CHECK([ovs-vsctl add-port br0 ovs-p0]) | |
3576 | AT_CHECK([ovs-vsctl add-port br1 ovs-p1]) | |
3577 | on_exit 'ip link del ovs-p0' | |
3578 | ||
3579 | AT_CHECK([ip link add ovs-p2 type veth peer name ovs-p3]) | |
3580 | AT_CHECK([ip link set dev ovs-p2 up]) | |
3581 | AT_CHECK([ip link set dev ovs-p3 up]) | |
3582 | AT_CHECK([ovs-vsctl add-port br0 ovs-p2]) | |
3583 | AT_CHECK([ovs-vsctl add-port br2 ovs-p3]) | |
3584 | on_exit 'ip link del ovs-p2' | |
3585 | ||
3586 | ADD_VETH(p4, at_ns0, br1, "10.1.1.1/24") | |
3587 | ADD_VETH(p5, at_ns1, br2, "10.1.1.2/24") | |
3588 | ADD_CVLAN(p4, at_ns0, 100, "10.2.2.1/24") | |
3589 | ADD_CVLAN(p5, at_ns1, 100, "10.2.2.2/24") | |
3590 | ||
3591 | AT_DATA([flows-br0.txt], [dnl | |
3592 | priority=1 action=drop | |
3593 | priority=100 in_port=1 action=push_vlan:0x8100,mod_vlan_vid=4094,output:2 | |
3594 | priority=100 in_port=2 action=push_vlan:0x8100,mod_vlan_vid=4094,output:1 | |
3595 | ]) | |
3596 | ||
3597 | AT_DATA([flows-customer-br.txt], [dnl | |
3598 | priority=1 action=normal | |
3599 | priority=100 in_port=1 vlan_tci=0x1000/0x1000 action=pop_vlan,normal | |
3600 | ]) | |
3601 | ||
3602 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows-br0.txt]) | |
3603 | AT_CHECK([ovs-ofctl --bundle add-flows br1 flows-customer-br.txt]) | |
3604 | AT_CHECK([ovs-ofctl --bundle add-flows br2 flows-customer-br.txt]) | |
3605 | ||
3606 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping -c 1 10.2.2.2]) | |
3607 | ||
3608 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
3609 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
3610 | ]) | |
3611 | ||
3612 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
3613 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
3614 | ]) | |
3615 | ||
3616 | OVS_TRAFFIC_VSWITCHD_STOP | |
3617 | AT_CLEANUP | |
d4a814a8 EG |
3618 | |
3619 | ||
3620 | AT_SETUP([802.1ad - 802.1q tunnel]) | |
3621 | OVS_TRAFFIC_VSWITCHD_START([set Open_vSwitch . other_config:vlan-limit=0]) | |
3622 | OVS_CHECK_8021AD() | |
3623 | ||
3624 | ADD_BR([br1]) | |
3625 | ADD_BR([br2]) | |
3626 | ADD_NAMESPACES(at_ns0, at_ns1) | |
3627 | ||
3628 | AT_CHECK([ip link add ovs-p0 type veth peer name ovs-p1]) | |
3629 | AT_CHECK([ip link set dev ovs-p0 up]) | |
3630 | AT_CHECK([ip link set dev ovs-p1 up]) | |
3631 | AT_CHECK([ovs-vsctl add-port br0 ovs-p0]) | |
3632 | AT_CHECK([ovs-vsctl add-port br1 ovs-p1]) | |
3633 | on_exit 'ip link del ovs-p0' | |
3634 | ||
3635 | AT_CHECK([ip link add ovs-p2 type veth peer name ovs-p3]) | |
3636 | AT_CHECK([ip link set dev ovs-p2 up]) | |
3637 | AT_CHECK([ip link set dev ovs-p3 up]) | |
3638 | AT_CHECK([ovs-vsctl add-port br0 ovs-p2]) | |
3639 | AT_CHECK([ovs-vsctl add-port br2 ovs-p3]) | |
3640 | on_exit 'ip link del ovs-p2' | |
3641 | ||
3642 | ADD_VETH(p4, at_ns0, br1, "10.1.1.1/24") | |
3643 | ADD_VETH(p5, at_ns1, br2, "10.1.1.2/24") | |
3644 | ADD_CVLAN(p4, at_ns0, 100, "10.2.2.1/24") | |
3645 | ADD_CVLAN(p5, at_ns1, 100, "10.2.2.2/24") | |
3646 | ADD_CVLAN(p4, at_ns0, 200, "10.3.2.1/24") | |
3647 | ADD_CVLAN(p5, at_ns1, 200, "10.3.2.2/24") | |
3648 | ADD_CVLAN(p4, at_ns0, 300, "10.4.2.1/24") | |
3649 | ADD_CVLAN(p5, at_ns1, 300, "10.4.2.2/24") | |
3650 | ||
3651 | AT_CHECK([ovs-ofctl add-flow br0 action=normal]) | |
3652 | AT_CHECK([ovs-ofctl add-flow br1 action=normal]) | |
3653 | AT_CHECK([ovs-ofctl add-flow br2 action=normal]) | |
3654 | AT_CHECK([ovs-vsctl set port ovs-p0 vlan_mode=dot1q-tunnel tag=4094 cvlans=100,200]) | |
3655 | AT_CHECK([ovs-vsctl set port ovs-p2 vlan_mode=dot1q-tunnel tag=4094 cvlans=100,200]) | |
3656 | ||
3657 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping -c 1 10.2.2.2]) | |
3658 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping -c 1 10.3.2.2]) | |
3659 | ||
3660 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
3661 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
3662 | ]) | |
3663 | ||
3664 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.3.2.2 | FORMAT_PING], [0], [dnl | |
3665 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
3666 | ]) | |
3667 | ||
3668 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
3669 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
3670 | ]) | |
3671 | ||
3672 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.3.2.2 | FORMAT_PING], [0], [dnl | |
3673 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
3674 | ]) | |
3675 | ||
3676 | dnl CVLAN 300 is not permitted by dot1q-tunnel | |
3677 | NS_CHECK_EXEC([at_ns0], [ping -q -c 1 -w 3 10.4.2.2], [1], [ignore]) | |
3678 | ||
3679 | OVS_TRAFFIC_VSWITCHD_STOP(["/dropping VLAN \(0\|300\) packet received on dot1q-tunnel port/d"]) | |
3680 | AT_CLEANUP |