]>
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() |
07659514 JS |
615 | |
616 | ADD_NAMESPACES(at_ns0, at_ns1) | |
617 | ||
618 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
619 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
620 | ||
621 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
622 | AT_DATA([flows.txt], [dnl | |
623 | priority=1,action=drop | |
624 | priority=10,arp,action=normal | |
625 | priority=100,in_port=1,udp,action=ct(commit),controller | |
626 | priority=100,in_port=2,ct_state=-trk,udp,action=ct(table=0) | |
627 | priority=100,in_port=2,ct_state=+trk+est,udp,action=controller | |
628 | ]) | |
629 | ||
6cfa8ec3 | 630 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 JS |
631 | |
632 | AT_CAPTURE_FILE([ofctl_monitor.log]) | |
633 | AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log]) | |
634 | ||
635 | dnl Send an unsolicited reply from port 2. This should be dropped. | |
4573c42e | 636 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 ct\(table=0\) '50540000000a50540000000908004500001c000000000011a4cd0a0101020a0101010002000100080000']) |
07659514 JS |
637 | |
638 | dnl OK, now start a new connection from port 1. | |
4573c42e | 639 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 1 ct\(commit\),controller '50540000000a50540000000908004500001c000000000011a4cd0a0101010a0101020001000200080000']) |
07659514 JS |
640 | |
641 | dnl Now try a reply from port 2. | |
4573c42e | 642 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 ct\(table=0\) '50540000000a50540000000908004500001c000000000011a4cd0a0101020a0101010002000100080000']) |
07659514 JS |
643 | |
644 | dnl Check this output. We only see the latter two packets, not the first. | |
645 | AT_CHECK([cat ofctl_monitor.log], [0], [dnl | |
f274a047 | 646 | NXT_PACKET_IN2 (xid=0x0): total_len=42 in_port=1 (via action) data_len=42 (unbuffered) |
07659514 | 647 | 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 |
f274a047 | 648 | NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=42 ct_state=est|rpl|trk,in_port=2 (via action) data_len=42 (unbuffered) |
07659514 JS |
649 | 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 |
650 | ]) | |
651 | ||
652 | OVS_TRAFFIC_VSWITCHD_STOP | |
653 | AT_CLEANUP | |
654 | ||
655 | AT_SETUP([conntrack - IPv4 HTTP]) | |
656 | CHECK_CONNTRACK() | |
cf7659b6 | 657 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
658 | |
659 | ADD_NAMESPACES(at_ns0, at_ns1) | |
660 | ||
661 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
662 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
663 | ||
664 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
665 | AT_DATA([flows.txt], [dnl | |
666 | priority=1,action=drop | |
667 | priority=10,arp,action=normal | |
668 | priority=10,icmp,action=normal | |
669 | priority=100,in_port=1,tcp,action=ct(commit),2 | |
670 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0) | |
671 | priority=100,in_port=2,ct_state=+trk+est,tcp,action=1 | |
672 | ]) | |
673 | ||
6cfa8ec3 | 674 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 | 675 | |
7ed40afe JS |
676 | OVS_START_L7([at_ns0], [http]) |
677 | OVS_START_L7([at_ns1], [http]) | |
678 | ||
07659514 | 679 | dnl HTTP requests from ns0->ns1 should work fine. |
07659514 | 680 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
ec3aa16c | 681 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
420c73b2 | 682 | 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>) |
07659514 JS |
683 | ]) |
684 | ||
685 | dnl HTTP requests from ns1->ns0 should fail due to network failure. | |
686 | dnl Try 3 times, in 1 second intervals. | |
07659514 JS |
687 | NS_CHECK_EXEC([at_ns1], [wget 10.1.1.1 -t 3 -T 1 -v -o wget1.log], [4]) |
688 | ||
689 | OVS_TRAFFIC_VSWITCHD_STOP | |
690 | AT_CLEANUP | |
691 | ||
692 | AT_SETUP([conntrack - IPv6 HTTP]) | |
693 | CHECK_CONNTRACK() | |
cf7659b6 | 694 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
695 | |
696 | ADD_NAMESPACES(at_ns0, at_ns1) | |
697 | ||
698 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
699 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
700 | ||
701 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
702 | AT_DATA([flows.txt], [dnl | |
703 | priority=1,action=drop | |
704 | priority=10,icmp6,action=normal | |
705 | priority=100,in_port=1,tcp6,action=ct(commit),2 | |
706 | priority=100,in_port=2,ct_state=-trk,tcp6,action=ct(table=0) | |
707 | priority=100,in_port=2,ct_state=+trk+est,tcp6,action=1 | |
708 | ]) | |
709 | ||
6cfa8ec3 | 710 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 | 711 | |
c10840ff JS |
712 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
713 | dnl waiting, we get occasional failures due to the following error: | |
07659514 | 714 | dnl "connect: Cannot assign requested address" |
c10840ff | 715 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) |
07659514 | 716 | |
7ed40afe JS |
717 | OVS_START_L7([at_ns0], [http6]) |
718 | OVS_START_L7([at_ns1], [http6]) | |
07659514 | 719 | |
7ed40afe | 720 | dnl HTTP requests from ns0->ns1 should work fine. |
07659514 | 721 | NS_CHECK_EXEC([at_ns0], [wget http://[[fc00::2]] -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
ec3aa16c | 722 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl |
420c73b2 | 723 | 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>) |
ec3aa16c DDP |
724 | ]) |
725 | ||
07659514 JS |
726 | dnl HTTP requests from ns1->ns0 should fail due to network failure. |
727 | dnl Try 3 times, in 1 second intervals. | |
07659514 JS |
728 | NS_CHECK_EXEC([at_ns1], [wget http://[[fc00::1]] -t 3 -T 1 -v -o wget1.log], [4]) |
729 | ||
730 | OVS_TRAFFIC_VSWITCHD_STOP | |
731 | AT_CLEANUP | |
732 | ||
e5cf8cce DDP |
733 | AT_SETUP([conntrack - IPv4 ping]) |
734 | CHECK_CONNTRACK() | |
735 | OVS_TRAFFIC_VSWITCHD_START() | |
736 | ||
737 | ADD_NAMESPACES(at_ns0, at_ns1) | |
738 | ||
739 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
740 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
741 | ||
742 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
743 | AT_DATA([flows.txt], [dnl | |
744 | priority=1,action=drop | |
745 | priority=10,arp,action=normal | |
746 | priority=100,in_port=1,icmp,action=ct(commit),2 | |
747 | priority=100,in_port=2,icmp,ct_state=-trk,action=ct(table=0) | |
748 | priority=100,in_port=2,icmp,ct_state=+trk+est,action=1 | |
749 | ]) | |
750 | ||
751 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
752 | ||
753 | dnl Pings from ns0->ns1 should work fine. | |
754 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
755 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
756 | ]) | |
757 | ||
758 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
759 | 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) | |
760 | ]) | |
761 | ||
762 | AT_CHECK([ovs-appctl dpctl/flush-conntrack]) | |
763 | ||
764 | dnl Pings from ns1->ns0 should fail. | |
765 | NS_CHECK_EXEC([at_ns1], [ping -q -c 3 -i 0.3 -w 2 10.1.1.1 | FORMAT_PING], [0], [dnl | |
766 | 7 packets transmitted, 0 received, 100% packet loss, time 0ms | |
767 | ]) | |
768 | ||
769 | OVS_TRAFFIC_VSWITCHD_STOP | |
770 | AT_CLEANUP | |
771 | ||
772 | AT_SETUP([conntrack - IPv6 ping]) | |
773 | CHECK_CONNTRACK() | |
774 | OVS_TRAFFIC_VSWITCHD_START() | |
775 | ||
776 | ADD_NAMESPACES(at_ns0, at_ns1) | |
777 | ||
778 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
779 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
780 | ||
781 | AT_DATA([flows.txt], [dnl | |
782 | ||
783 | dnl ICMPv6 echo request and reply go to table 1. The rest of the traffic goes | |
784 | dnl through normal action. | |
785 | table=0,priority=10,icmp6,icmp_type=128,action=goto_table:1 | |
786 | table=0,priority=10,icmp6,icmp_type=129,action=goto_table:1 | |
787 | table=0,priority=1,action=normal | |
788 | ||
789 | dnl Allow everything from ns0->ns1. Only allow return traffic from ns1->ns0. | |
790 | table=1,priority=100,in_port=1,icmp6,action=ct(commit),2 | |
791 | table=1,priority=100,in_port=2,icmp6,ct_state=-trk,action=ct(table=0) | |
792 | table=1,priority=100,in_port=2,icmp6,ct_state=+trk+est,action=1 | |
793 | table=1,priority=1,action=drop | |
794 | ]) | |
795 | ||
796 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
797 | ||
798 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) | |
799 | ||
027f7e84 DDP |
800 | dnl The above ping creates state in the connection tracker. We're not |
801 | dnl interested in that state. | |
802 | AT_CHECK([ovs-appctl dpctl/flush-conntrack]) | |
803 | ||
e5cf8cce DDP |
804 | dnl Pings from ns1->ns0 should fail. |
805 | NS_CHECK_EXEC([at_ns1], [ping6 -q -c 3 -i 0.3 -w 2 fc00::1 | FORMAT_PING], [0], [dnl | |
806 | 7 packets transmitted, 0 received, 100% packet loss, time 0ms | |
807 | ]) | |
808 | ||
809 | dnl Pings from ns0->ns1 should work fine. | |
810 | NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
811 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
812 | ]) | |
813 | ||
814 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl | |
815 | 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) | |
816 | ]) | |
817 | ||
818 | OVS_TRAFFIC_VSWITCHD_STOP | |
819 | AT_CLEANUP | |
820 | ||
07659514 JS |
821 | AT_SETUP([conntrack - commit, recirc]) |
822 | CHECK_CONNTRACK() | |
cf7659b6 | 823 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
824 | |
825 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
826 | ||
827 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
828 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
829 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
830 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
831 | ||
832 | dnl Allow any traffic from ns0->ns1, ns2->ns3. | |
833 | AT_DATA([flows.txt], [dnl | |
834 | priority=1,action=drop | |
835 | priority=10,arp,action=normal | |
836 | priority=10,icmp,action=normal | |
837 | priority=100,in_port=1,tcp,ct_state=-trk,action=ct(commit,table=0) | |
838 | priority=100,in_port=1,tcp,ct_state=+trk,action=2 | |
839 | priority=100,in_port=2,tcp,ct_state=-trk,action=ct(table=0) | |
840 | priority=100,in_port=2,tcp,ct_state=+trk,action=1 | |
841 | priority=100,in_port=3,tcp,ct_state=-trk,action=set_field:0->metadata,ct(table=0) | |
842 | priority=100,in_port=3,tcp,ct_state=+trk,metadata=0,action=set_field:1->metadata,ct(commit,table=0) | |
843 | priority=100,in_port=3,tcp,ct_state=+trk,metadata=1,action=4 | |
844 | priority=100,in_port=4,tcp,ct_state=-trk,action=ct(commit,table=0) | |
845 | priority=100,in_port=4,tcp,ct_state=+trk,action=3 | |
846 | ]) | |
847 | ||
6cfa8ec3 | 848 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 | 849 | |
7ed40afe JS |
850 | OVS_START_L7([at_ns1], [http]) |
851 | OVS_START_L7([at_ns3], [http]) | |
852 | ||
07659514 | 853 | dnl HTTP requests from p0->p1 should work fine. |
07659514 JS |
854 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
855 | ||
856 | dnl HTTP requests from p2->p3 should work fine. | |
07659514 JS |
857 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 --retry-connrefused -v -o wget1.log]) |
858 | ||
859 | OVS_TRAFFIC_VSWITCHD_STOP | |
860 | AT_CLEANUP | |
861 | ||
862 | AT_SETUP([conntrack - preserve registers]) | |
863 | CHECK_CONNTRACK() | |
cf7659b6 | 864 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
865 | |
866 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
867 | ||
868 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
869 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
870 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
871 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
872 | ||
873 | dnl Allow any traffic from ns0->ns1, ns2->ns3. | |
874 | AT_DATA([flows.txt], [dnl | |
875 | priority=1,action=drop | |
876 | priority=10,arp,action=normal | |
877 | priority=10,icmp,action=normal | |
878 | priority=100,in_port=1,tcp,ct_state=-trk,action=ct(commit,table=0) | |
879 | priority=100,in_port=1,tcp,ct_state=+trk,action=2 | |
880 | priority=100,in_port=2,tcp,ct_state=-trk,action=ct(table=0) | |
881 | priority=100,in_port=2,tcp,ct_state=+trk,action=1 | |
882 | priority=100,in_port=3,tcp,ct_state=-trk,action=load:0->NXM_NX_REG0[[]],ct(table=0) | |
883 | priority=100,in_port=3,tcp,ct_state=+trk,reg0=0,action=load:1->NXM_NX_REG0[[]],ct(commit,table=0) | |
884 | priority=100,in_port=3,tcp,ct_state=+trk,reg0=1,action=4 | |
885 | priority=100,in_port=4,tcp,ct_state=-trk,action=ct(commit,table=0) | |
886 | priority=100,in_port=4,tcp,ct_state=+trk,action=3 | |
887 | ]) | |
888 | ||
6cfa8ec3 | 889 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 | 890 | |
7ed40afe JS |
891 | OVS_START_L7([at_ns1], [http]) |
892 | OVS_START_L7([at_ns3], [http]) | |
893 | ||
07659514 | 894 | dnl HTTP requests from p0->p1 should work fine. |
07659514 JS |
895 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
896 | ||
897 | dnl HTTP requests from p2->p3 should work fine. | |
07659514 JS |
898 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 --retry-connrefused -v -o wget1.log]) |
899 | ||
900 | OVS_TRAFFIC_VSWITCHD_STOP | |
901 | AT_CLEANUP | |
902 | ||
903 | AT_SETUP([conntrack - invalid]) | |
904 | CHECK_CONNTRACK() | |
cf7659b6 | 905 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
906 | |
907 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
908 | ||
909 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
910 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
911 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
912 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
913 | ||
914 | dnl Pass traffic from ns0->ns1 without committing, but attempt to track in | |
915 | dnl the opposite direction. This should fail. | |
916 | dnl Pass traffic from ns3->ns4 without committing, and this time match | |
917 | dnl invalid traffic and allow it through. | |
918 | AT_DATA([flows.txt], [dnl | |
919 | priority=1,action=drop | |
920 | priority=10,arp,action=normal | |
921 | priority=10,icmp,action=normal | |
922 | priority=100,in_port=1,tcp,action=ct(),2 | |
923 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0) | |
924 | priority=100,in_port=2,ct_state=+trk+new,tcp,action=1 | |
925 | priority=100,in_port=3,tcp,action=ct(),4 | |
926 | priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0) | |
927 | priority=100,in_port=4,ct_state=+trk+inv,tcp,action=3 | |
928 | priority=100,in_port=4,ct_state=+trk+new,tcp,action=3 | |
929 | ]) | |
930 | ||
6cfa8ec3 | 931 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 JS |
932 | |
933 | dnl We set up our rules to allow the request without committing. The return | |
934 | dnl traffic can't be identified, because the initial request wasn't committed. | |
935 | dnl For the first pair of ports, this means that the connection fails. | |
7ed40afe JS |
936 | OVS_START_L7([at_ns1], [http]) |
937 | OVS_START_L7([at_ns3], [http]) | |
07659514 JS |
938 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log], [4]) |
939 | ||
940 | dnl For the second pair, we allow packets from invalid connections, so it works. | |
07659514 JS |
941 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 --retry-connrefused -v -o wget1.log]) |
942 | ||
943 | OVS_TRAFFIC_VSWITCHD_STOP | |
944 | AT_CLEANUP | |
945 | ||
946 | AT_SETUP([conntrack - zones]) | |
947 | CHECK_CONNTRACK() | |
cf7659b6 | 948 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
949 | |
950 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
951 | ||
952 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
953 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
954 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
955 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
956 | ||
957 | dnl Allow any traffic from ns0->ns1. Allow return traffic, matching on zone. | |
958 | dnl For ns2->ns3, use a different zone and see that the match fails. | |
959 | AT_DATA([flows.txt], [dnl | |
960 | priority=1,action=drop | |
961 | priority=10,arp,action=normal | |
962 | priority=10,icmp,action=normal | |
963 | priority=100,in_port=1,tcp,action=ct(commit,zone=1),2 | |
964 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0,zone=1) | |
965 | priority=100,in_port=2,ct_state=+trk,ct_zone=1,tcp,action=1 | |
966 | priority=100,in_port=3,tcp,action=ct(commit,zone=2),4 | |
967 | priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0,zone=2) | |
968 | priority=100,in_port=4,ct_state=+trk,ct_zone=1,tcp,action=3 | |
969 | ]) | |
970 | ||
6cfa8ec3 | 971 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 | 972 | |
7ed40afe JS |
973 | OVS_START_L7([at_ns1], [http]) |
974 | OVS_START_L7([at_ns3], [http]) | |
975 | ||
07659514 | 976 | dnl HTTP requests from p0->p1 should work fine. |
07659514 JS |
977 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
978 | ||
ec3aa16c | 979 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
420c73b2 | 980 | 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 |
981 | ]) |
982 | ||
983 | dnl HTTP requests from p2->p3 should fail due to network failure. | |
984 | dnl Try 3 times, in 1 second intervals. | |
07659514 JS |
985 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4]) |
986 | ||
ec3aa16c | 987 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl |
420c73b2 | 988 | 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 |
989 | ]) |
990 | ||
991 | OVS_TRAFFIC_VSWITCHD_STOP | |
992 | AT_CLEANUP | |
993 | ||
994 | AT_SETUP([conntrack - zones from field]) | |
995 | CHECK_CONNTRACK() | |
cf7659b6 | 996 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
997 | |
998 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
999 | ||
1000 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1001 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1002 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
1003 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
1004 | ||
1005 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
1006 | AT_DATA([flows.txt], [dnl | |
1007 | priority=1,action=drop | |
1008 | priority=10,arp,action=normal | |
1009 | priority=10,icmp,action=normal | |
1010 | priority=100,in_port=1,tcp,action=load:0x1001->NXM_NX_REG0[[0..15]],ct(commit,zone=NXM_NX_REG0[[0..15]]),2 | |
1011 | 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]]) | |
1012 | priority=100,in_port=2,ct_state=+trk,ct_zone=0x1001,tcp,action=1 | |
1013 | priority=100,in_port=3,tcp,action=load:0x1002->NXM_NX_REG0[[0..15]],ct(commit,zone=NXM_NX_REG0[[0..15]]),4 | |
1014 | 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]]) | |
1015 | priority=100,in_port=4,ct_state=+trk,ct_zone=0x1001,tcp,action=3 | |
1016 | ]) | |
1017 | ||
6cfa8ec3 | 1018 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 | 1019 | |
7ed40afe JS |
1020 | OVS_START_L7([at_ns1], [http]) |
1021 | OVS_START_L7([at_ns3], [http]) | |
1022 | ||
07659514 | 1023 | dnl HTTP requests from p0->p1 should work fine. |
07659514 JS |
1024 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1025 | ||
ec3aa16c | 1026 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
420c73b2 | 1027 | 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 |
1028 | ]) |
1029 | ||
1030 | dnl HTTP requests from p2->p3 should fail due to network failure. | |
1031 | dnl Try 3 times, in 1 second intervals. | |
07659514 JS |
1032 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4]) |
1033 | ||
ec3aa16c | 1034 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl |
420c73b2 | 1035 | 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 |
1036 | ]) |
1037 | ||
1038 | OVS_TRAFFIC_VSWITCHD_STOP | |
1039 | AT_CLEANUP | |
1040 | ||
1041 | AT_SETUP([conntrack - multiple bridges]) | |
1042 | CHECK_CONNTRACK() | |
1043 | OVS_TRAFFIC_VSWITCHD_START( | |
cf7659b6 | 1044 | [_ADD_BR([br1]) --\ |
07659514 JS |
1045 | add-port br0 patch+ -- set int patch+ type=patch options:peer=patch- --\ |
1046 | add-port br1 patch- -- set int patch- type=patch options:peer=patch+ --]) | |
1047 | ||
1048 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1049 | ||
1050 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1051 | ADD_VETH(p1, at_ns1, br1, "10.1.1.2/24") | |
1052 | ||
1053 | dnl Allow any traffic from ns0->br1, allow established in reverse. | |
1054 | AT_DATA([flows-br0.txt], [dnl | |
1055 | priority=1,action=drop | |
1056 | priority=10,arp,action=normal | |
1057 | priority=10,icmp,action=normal | |
1058 | priority=100,in_port=2,tcp,ct_state=-trk,action=ct(commit,zone=1),1 | |
1059 | priority=100,in_port=1,tcp,ct_state=-trk,action=ct(table=0,zone=1) | |
1060 | priority=100,in_port=1,tcp,ct_state=+trk+est,ct_zone=1,action=2 | |
1061 | ]) | |
1062 | ||
1063 | dnl Allow any traffic from br0->ns1, allow established in reverse. | |
1064 | AT_DATA([flows-br1.txt], [dnl | |
1065 | priority=1,action=drop | |
1066 | priority=10,arp,action=normal | |
1067 | priority=10,icmp,action=normal | |
1068 | priority=100,in_port=1,tcp,ct_state=-trk,action=ct(table=0,zone=2) | |
1069 | priority=100,in_port=1,tcp,ct_state=+trk+new,ct_zone=2,action=ct(commit,zone=2),2 | |
1070 | priority=100,in_port=1,tcp,ct_state=+trk+est,ct_zone=2,action=2 | |
1071 | priority=100,in_port=2,tcp,ct_state=-trk,action=ct(table=0,zone=2) | |
1072 | priority=100,in_port=2,tcp,ct_state=+trk+est,ct_zone=2,action=ct(commit,zone=2),1 | |
1073 | ]) | |
1074 | ||
6cfa8ec3 JR |
1075 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows-br0.txt]) |
1076 | AT_CHECK([ovs-ofctl --bundle add-flows br1 flows-br1.txt]) | |
07659514 JS |
1077 | |
1078 | dnl HTTP requests from p0->p1 should work fine. | |
7ed40afe | 1079 | OVS_START_L7([at_ns1], [http]) |
07659514 JS |
1080 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1081 | ||
1082 | OVS_TRAFFIC_VSWITCHD_STOP | |
1083 | AT_CLEANUP | |
1084 | ||
1085 | AT_SETUP([conntrack - multiple zones]) | |
1086 | CHECK_CONNTRACK() | |
cf7659b6 | 1087 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
1088 | |
1089 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1090 | ||
1091 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1092 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1093 | ||
1094 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
1095 | AT_DATA([flows.txt], [dnl | |
1096 | priority=1,action=drop | |
1097 | priority=10,arp,action=normal | |
1098 | priority=10,icmp,action=normal | |
1099 | priority=100,in_port=1,tcp,action=ct(commit,zone=1),ct(commit,zone=2),2 | |
1100 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0,zone=2) | |
1101 | priority=100,in_port=2,ct_state=+trk,ct_zone=2,tcp,action=1 | |
1102 | ]) | |
1103 | ||
6cfa8ec3 | 1104 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
07659514 | 1105 | |
7ed40afe JS |
1106 | OVS_START_L7([at_ns1], [http]) |
1107 | ||
07659514 | 1108 | dnl HTTP requests from p0->p1 should work fine. |
07659514 JS |
1109 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1110 | ||
1111 | dnl (again) HTTP requests from p0->p1 should work fine. | |
1112 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
1113 | ||
ec3aa16c | 1114 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
420c73b2 JR |
1115 | 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>) |
1116 | 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 |
1117 | ]) |
1118 | ||
1119 | OVS_TRAFFIC_VSWITCHD_STOP | |
1120 | AT_CLEANUP | |
1121 | ||
c2926d6d JS |
1122 | AT_SETUP([conntrack - multiple zones, local]) |
1123 | CHECK_CONNTRACK() | |
4573c42e | 1124 | CHECK_CONNTRACK_LOCAL_STACK() |
cf7659b6 | 1125 | OVS_TRAFFIC_VSWITCHD_START() |
c2926d6d JS |
1126 | |
1127 | ADD_NAMESPACES(at_ns0) | |
1128 | ||
1129 | AT_CHECK([ip addr add dev br0 "10.1.1.1/24"]) | |
1130 | AT_CHECK([ip link set dev br0 up]) | |
1131 | on_exit 'ip addr del dev br0 "10.1.1.1/24"' | |
1132 | ADD_VETH(p0, at_ns0, br0, "10.1.1.2/24") | |
1133 | ||
1134 | dnl Allow traffic from local stack to ns0. Only allow neighbour discovery, | |
1135 | dnl return traffic from ns0 back to the local stack. | |
1136 | AT_DATA([flows.txt], [dnl | |
1137 | priority=1,action=drop | |
1138 | priority=10,arp,action=normal | |
1139 | priority=100,in_port=LOCAL,ip,ct_state=-trk,action=drop | |
1140 | priority=100,in_port=LOCAL,ip,ct_state=+trk+new,action=ct(commit,zone=1),ct(commit,zone=2),1 | |
1141 | priority=100,in_port=LOCAL,ip,ct_state=+trk+est,action=ct(commit,zone=1),ct(commit,zone=2),1 | |
1142 | priority=100,in_port=1,ip,ct_state=-trk,action=ct(table=1,zone=1) | |
723af132 JS |
1143 | table=1,in_port=1,ip,ct_state=+trk+est,ct_zone=1,action=ct(table=2,zone=2) |
1144 | table=2,in_port=1,ip,ct_state=+trk+est,ct_zone=2,action=LOCAL | |
c2926d6d JS |
1145 | ]) |
1146 | ||
6cfa8ec3 | 1147 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
c2926d6d JS |
1148 | |
1149 | AT_CHECK([ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
1150 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1151 | ]) | |
1152 | ||
7ed40afe JS |
1153 | OVS_START_L7([at_ns0], [http]) |
1154 | ||
c2926d6d | 1155 | dnl HTTP requests from root namespace to p0 should work fine. |
c2926d6d JS |
1156 | AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1157 | ||
1158 | dnl (again) HTTP requests from root namespace to p0 should work fine. | |
1159 | AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
1160 | ||
ec3aa16c | 1161 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep "zone"], [0], [dnl |
b269a122 DDP |
1162 | 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 |
1163 | 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 | |
420c73b2 JR |
1164 | 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>) |
1165 | 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>) | |
c2926d6d JS |
1166 | ]) |
1167 | ||
1168 | OVS_TRAFFIC_VSWITCHD_STOP | |
1169 | AT_CLEANUP | |
1170 | ||
0e27c629 JS |
1171 | AT_SETUP([conntrack - multiple namespaces, internal ports]) |
1172 | CHECK_CONNTRACK() | |
4573c42e | 1173 | CHECK_CONNTRACK_LOCAL_STACK() |
0e27c629 JS |
1174 | OVS_TRAFFIC_VSWITCHD_START( |
1175 | [set-fail-mode br0 secure -- ]) | |
1176 | ||
1177 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1178 | ||
1179 | ADD_INT(p0, at_ns0, br0, "10.1.1.1/24") | |
1180 | ADD_INT(p1, at_ns1, br0, "10.1.1.2/24") | |
1181 | ||
1182 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
1183 | dnl | |
1184 | dnl If skb->nfct is leaking from inside the namespace, this test will fail. | |
1185 | AT_DATA([flows.txt], [dnl | |
1186 | priority=1,action=drop | |
1187 | priority=10,arp,action=normal | |
1188 | priority=10,icmp,action=normal | |
1189 | priority=100,in_port=1,tcp,ct_state=-trk,action=ct(commit,zone=1),2 | |
1190 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0,zone=1) | |
1191 | priority=100,in_port=2,ct_state=+trk,ct_zone=1,tcp,action=1 | |
1192 | ]) | |
1193 | ||
1194 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
1195 | ||
7ed40afe JS |
1196 | OVS_START_L7([at_ns1], [http]) |
1197 | ||
0e27c629 | 1198 | dnl HTTP requests from p0->p1 should work fine. |
0e27c629 JS |
1199 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1200 | ||
1201 | dnl (again) HTTP requests from p0->p1 should work fine. | |
1202 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
1203 | ||
ec3aa16c | 1204 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
420c73b2 | 1205 | 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 |
1206 | ]) |
1207 | ||
1208 | OVS_TRAFFIC_VSWITCHD_STOP(["dnl | |
1209 | /ioctl(SIOCGIFINDEX) on .* device failed: No such device/d | |
1210 | /removing policing failed: No such device/d"]) | |
1211 | AT_CLEANUP | |
1212 | ||
c2926d6d JS |
1213 | AT_SETUP([conntrack - multi-stage pipeline, local]) |
1214 | CHECK_CONNTRACK() | |
4573c42e | 1215 | CHECK_CONNTRACK_LOCAL_STACK() |
cf7659b6 | 1216 | OVS_TRAFFIC_VSWITCHD_START() |
c2926d6d JS |
1217 | |
1218 | ADD_NAMESPACES(at_ns0) | |
1219 | ||
1220 | AT_CHECK([ip addr add dev br0 "10.1.1.1/24"]) | |
1221 | AT_CHECK([ip link set dev br0 up]) | |
1222 | on_exit 'ip addr del dev br0 "10.1.1.1/24"' | |
1223 | ADD_VETH(p0, at_ns0, br0, "10.1.1.2/24") | |
1224 | ||
1225 | dnl Allow traffic from local stack to ns0. Only allow neighbour discovery, | |
1226 | dnl return traffic from ns0 back to the local stack. | |
1227 | AT_DATA([flows.txt], [dnl | |
1228 | dnl default | |
1229 | table=0,priority=1,action=drop | |
1230 | table=0,priority=10,arp,action=normal | |
1231 | ||
1232 | dnl Load the output port to REG0 | |
1233 | table=0,priority=100,ip,in_port=LOCAL,action=load:1->NXM_NX_REG0[[0..15]],goto_table:1 | |
1234 | table=0,priority=100,ip,in_port=1,action=load:65534->NXM_NX_REG0[[0..15]],goto_table:1 | |
1235 | ||
1236 | dnl Ingress pipeline | |
1237 | dnl - Allow all connections from LOCAL port (commit and proceed to egress) | |
1238 | dnl - All other connections go through conntracker using the input port as | |
1239 | dnl a connection tracking zone. | |
1240 | 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 | |
1241 | table=1,priority=100,ip,action=ct(table=2,zone=OXM_OF_IN_PORT[[0..15]]) | |
1242 | table=1,priority=1,action=drop | |
1243 | ||
1244 | dnl Egress pipeline | |
1245 | dnl - Allow all connections from LOCAL port (commit and skip to output) | |
1246 | dnl - Allow other established connections to go through conntracker using | |
1247 | dnl output port as a connection tracking zone. | |
1248 | table=2,priority=150,in_port=LOCAL,ip,ct_state=+trk+new,action=ct(commit,zone=NXM_NX_REG0[[0..15]]),goto_table:4 | |
1249 | table=2,priority=100,ip,ct_state=+trk+est,action=ct(table=3,zone=NXM_NX_REG0[[0..15]]) | |
1250 | table=2,priority=1,action=drop | |
1251 | ||
1252 | dnl Only allow established traffic from egress ct lookup | |
1253 | table=3,priority=100,ip,ct_state=+trk+est,action=goto_table:4 | |
1254 | table=3,priority=1,action=drop | |
1255 | ||
1256 | dnl output table | |
1257 | table=4,priority=100,ip,action=output:NXM_NX_REG0[[]] | |
1258 | ]) | |
1259 | ||
6cfa8ec3 | 1260 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
c2926d6d JS |
1261 | |
1262 | AT_CHECK([ping -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
1263 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1264 | ]) | |
1265 | ||
7ed40afe JS |
1266 | OVS_START_L7([at_ns0], [http]) |
1267 | ||
c2926d6d | 1268 | dnl HTTP requests from root namespace to p0 should work fine. |
c2926d6d JS |
1269 | AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1270 | ||
1271 | dnl (again) HTTP requests from root namespace to p0 should work fine. | |
1272 | AT_CHECK([wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
1273 | ||
ec3aa16c | 1274 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2) | grep "zone"], [0], [dnl |
b269a122 DDP |
1275 | 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 |
1276 | 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 | |
420c73b2 JR |
1277 | 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>) |
1278 | 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>) | |
c2926d6d JS |
1279 | ]) |
1280 | ||
1281 | OVS_TRAFFIC_VSWITCHD_STOP | |
1282 | AT_CLEANUP | |
1283 | ||
8e53fe8c JS |
1284 | AT_SETUP([conntrack - ct_mark]) |
1285 | CHECK_CONNTRACK() | |
cf7659b6 | 1286 | OVS_TRAFFIC_VSWITCHD_START() |
8e53fe8c JS |
1287 | |
1288 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1289 | ||
1290 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1291 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1292 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
1293 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
1294 | ||
1295 | dnl Allow traffic between ns0<->ns1 using the ct_mark. | |
1296 | dnl Check that different marks do not match for traffic between ns2<->ns3. | |
1297 | AT_DATA([flows.txt], [dnl | |
1298 | priority=1,action=drop | |
1299 | priority=10,arp,action=normal | |
1300 | priority=10,icmp,action=normal | |
1301 | priority=100,in_port=1,tcp,action=ct(commit,exec(set_field:1->ct_mark)),2 | |
1302 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0) | |
1303 | priority=100,in_port=2,ct_state=+trk,ct_mark=1,tcp,action=1 | |
1304 | priority=100,in_port=3,tcp,action=ct(commit,exec(set_field:2->ct_mark)),4 | |
1305 | priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0) | |
1306 | priority=100,in_port=4,ct_state=+trk,ct_mark=1,tcp,action=3 | |
1307 | ]) | |
1308 | ||
6cfa8ec3 | 1309 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
8e53fe8c | 1310 | |
7ed40afe JS |
1311 | OVS_START_L7([at_ns1], [http]) |
1312 | OVS_START_L7([at_ns3], [http]) | |
1313 | ||
8e53fe8c | 1314 | dnl HTTP requests from p0->p1 should work fine. |
8e53fe8c | 1315 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
420c73b2 JR |
1316 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1317 | 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 |
1318 | ]) |
1319 | ||
1320 | dnl HTTP requests from p2->p3 should fail due to network failure. | |
1321 | dnl Try 3 times, in 1 second intervals. | |
8e53fe8c | 1322 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4]) |
ec3aa16c | 1323 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl |
420c73b2 | 1324 | 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 |
1325 | ]) |
1326 | ||
1327 | OVS_TRAFFIC_VSWITCHD_STOP | |
1328 | AT_CLEANUP | |
1329 | ||
4d182934 JS |
1330 | AT_SETUP([conntrack - ct_mark bit-fiddling]) |
1331 | CHECK_CONNTRACK() | |
1332 | OVS_TRAFFIC_VSWITCHD_START() | |
1333 | ||
1334 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1335 | ||
1336 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1337 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1338 | ||
1339 | dnl Allow traffic between ns0<->ns1 using the ct_mark. Return traffic should | |
1340 | dnl cause an additional bit to be set in the connection (and be allowed). | |
1341 | AT_DATA([flows.txt], [dnl | |
1342 | table=0,priority=1,action=drop | |
1343 | table=0,priority=10,arp,action=normal | |
1344 | table=0,priority=10,icmp,action=normal | |
1345 | table=0,priority=100,in_port=1,tcp,action=ct(table=1) | |
1346 | 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 |
1347 | table=1,in_port=1,ct_state=+new,tcp,action=ct(commit,exec(set_field:0x5/0x5->ct_mark)),2 |
1348 | table=1,in_port=1,ct_state=-new,tcp,action=2 | |
1349 | table=1,in_port=2,ct_state=+trk,ct_mark=3,tcp,action=1 | |
4d182934 JS |
1350 | ]) |
1351 | ||
1352 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1353 | ||
7ed40afe JS |
1354 | OVS_START_L7([at_ns1], [http]) |
1355 | ||
4d182934 | 1356 | dnl HTTP requests from p0->p1 should work fine. |
4d182934 JS |
1357 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1358 | ||
420c73b2 JR |
1359 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1360 | 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 |
1361 | ]) |
1362 | ||
1363 | OVS_TRAFFIC_VSWITCHD_STOP | |
1364 | AT_CLEANUP | |
1365 | ||
8e53fe8c JS |
1366 | AT_SETUP([conntrack - ct_mark from register]) |
1367 | CHECK_CONNTRACK() | |
cf7659b6 | 1368 | OVS_TRAFFIC_VSWITCHD_START() |
8e53fe8c JS |
1369 | |
1370 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1371 | ||
1372 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1373 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1374 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
1375 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
1376 | ||
1377 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
1378 | AT_DATA([flows.txt], [dnl | |
1379 | priority=1,action=drop | |
1380 | priority=10,arp,action=normal | |
1381 | priority=10,icmp,action=normal | |
1382 | 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 | |
1383 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0) | |
1384 | priority=100,in_port=2,ct_state=+trk,ct_mark=1,tcp,action=1 | |
1385 | 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 | |
1386 | priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0) | |
1387 | priority=100,in_port=4,ct_state=+trk,ct_mark=1,tcp,action=3 | |
1388 | ]) | |
1389 | ||
6cfa8ec3 | 1390 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
8e53fe8c | 1391 | |
7ed40afe JS |
1392 | OVS_START_L7([at_ns1], [http]) |
1393 | OVS_START_L7([at_ns3], [http]) | |
1394 | ||
8e53fe8c | 1395 | dnl HTTP requests from p0->p1 should work fine. |
8e53fe8c | 1396 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
420c73b2 JR |
1397 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1398 | 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 |
1399 | ]) |
1400 | ||
1401 | dnl HTTP requests from p2->p3 should fail due to network failure. | |
1402 | dnl Try 3 times, in 1 second intervals. | |
8e53fe8c | 1403 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4]) |
ec3aa16c | 1404 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.4)], [0], [dnl |
420c73b2 | 1405 | 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 |
1406 | ]) |
1407 | ||
1408 | OVS_TRAFFIC_VSWITCHD_STOP | |
1409 | AT_CLEANUP | |
1410 | ||
9daf2348 JS |
1411 | AT_SETUP([conntrack - ct_label]) |
1412 | CHECK_CONNTRACK() | |
cf7659b6 | 1413 | OVS_TRAFFIC_VSWITCHD_START() |
9daf2348 JS |
1414 | |
1415 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1416 | ||
1417 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1418 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1419 | ADD_VETH(p2, at_ns2, br0, "10.1.1.3/24") | |
1420 | ADD_VETH(p3, at_ns3, br0, "10.1.1.4/24") | |
1421 | ||
1422 | dnl Allow traffic between ns0<->ns1 using the ct_label. | |
1423 | dnl Check that different labels do not match for traffic between ns2<->ns3. | |
1424 | AT_DATA([flows.txt], [dnl | |
1425 | priority=1,action=drop | |
1426 | priority=10,arp,action=normal | |
1427 | priority=10,icmp,action=normal | |
1428 | priority=100,in_port=1,tcp,action=ct(commit,exec(set_field:0x0a000d000005000001->ct_label)),2 | |
1429 | priority=100,in_port=2,ct_state=-trk,tcp,action=ct(table=0) | |
1430 | priority=100,in_port=2,ct_state=+trk,ct_label=0x0a000d000005000001,tcp,action=1 | |
1431 | priority=100,in_port=3,tcp,action=ct(commit,exec(set_field:0x2->ct_label)),4 | |
1432 | priority=100,in_port=4,ct_state=-trk,tcp,action=ct(table=0) | |
1433 | priority=100,in_port=4,ct_state=+trk,ct_label=0x0a000d000005000001,tcp,action=3 | |
1434 | ]) | |
1435 | ||
6cfa8ec3 | 1436 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
9daf2348 | 1437 | |
7ed40afe JS |
1438 | OVS_START_L7([at_ns1], [http]) |
1439 | OVS_START_L7([at_ns3], [http]) | |
1440 | ||
9daf2348 | 1441 | dnl HTTP requests from p0->p1 should work fine. |
9daf2348 JS |
1442 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1443 | ||
1444 | dnl HTTP requests from p2->p3 should fail due to network failure. | |
1445 | dnl Try 3 times, in 1 second intervals. | |
9daf2348 JS |
1446 | NS_CHECK_EXEC([at_ns2], [wget 10.1.1.4 -t 3 -T 1 -v -o wget1.log], [4]) |
1447 | ||
1448 | OVS_TRAFFIC_VSWITCHD_STOP | |
1449 | AT_CLEANUP | |
1450 | ||
4d182934 JS |
1451 | AT_SETUP([conntrack - ct_label bit-fiddling]) |
1452 | CHECK_CONNTRACK() | |
1453 | OVS_TRAFFIC_VSWITCHD_START() | |
1454 | ||
1455 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1456 | ||
1457 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1458 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1459 | ||
1460 | dnl Allow traffic between ns0<->ns1 using the ct_labels. Return traffic should | |
1461 | dnl cause an additional bit to be set in the connection labels (and be allowed) | |
1462 | AT_DATA([flows.txt], [dnl | |
1463 | table=0,priority=1,action=drop | |
1464 | table=0,priority=10,arp,action=normal | |
1465 | table=0,priority=10,icmp,action=normal | |
1466 | table=0,priority=100,in_port=1,tcp,action=ct(table=1) | |
1467 | 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 |
1468 | table=1,in_port=1,tcp,ct_state=+new,action=ct(commit,exec(set_field:0x5/0x5->ct_label)),2 |
1469 | table=1,in_port=1,tcp,ct_state=-new,action=2 | |
1470 | table=1,in_port=2,ct_state=+trk,ct_label=0x200000001,tcp,action=1 | |
4d182934 JS |
1471 | ]) |
1472 | ||
1473 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1474 | ||
7ed40afe JS |
1475 | OVS_START_L7([at_ns1], [http]) |
1476 | ||
4d182934 | 1477 | dnl HTTP requests from p0->p1 should work fine. |
4d182934 JS |
1478 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1479 | ||
420c73b2 JR |
1480 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1481 | 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 |
1482 | ]) |
1483 | ||
1484 | OVS_TRAFFIC_VSWITCHD_STOP | |
1485 | AT_CLEANUP | |
1486 | ||
f2d105b5 JS |
1487 | AT_SETUP([conntrack - ct metadata, multiple zones]) |
1488 | CHECK_CONNTRACK() | |
1489 | OVS_TRAFFIC_VSWITCHD_START() | |
1490 | ||
1491 | ADD_NAMESPACES(at_ns0, at_ns1, at_ns2, at_ns3) | |
1492 | ||
1493 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1494 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1495 | ||
1496 | dnl Allow traffic between ns0<->ns1 using the ct_mark and ct_labels in zone=1, | |
1497 | dnl but do *not* set any of these for the ct() in zone=2. Traffic should pass, | |
1498 | dnl and we should see that the conntrack entries only apply the ct_mark and | |
1499 | dnl ct_labels to the connection in zone=1. | |
1500 | AT_DATA([flows.txt], [dnl | |
1501 | table=0,priority=1,action=drop | |
1502 | table=0,priority=10,arp,action=normal | |
1503 | table=0,priority=10,icmp,action=normal | |
1504 | table=0,priority=100,in_port=1,tcp,action=ct(zone=1,table=1) | |
1505 | 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 |
1506 | 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 |
1507 | table=1,in_port=1,tcp,ct_state=-new,action=ct(zone=2),2 | |
1508 | table=1,in_port=2,tcp,action=ct(zone=2),1 | |
f2d105b5 JS |
1509 | ]) |
1510 | ||
1511 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1512 | ||
7ed40afe JS |
1513 | OVS_START_L7([at_ns1], [http]) |
1514 | ||
f2d105b5 | 1515 | dnl HTTP requests from p0->p1 should work fine. |
f2d105b5 JS |
1516 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) |
1517 | ||
420c73b2 JR |
1518 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1519 | 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>) | |
1520 | 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 |
1521 | ]) |
1522 | ||
1523 | OVS_TRAFFIC_VSWITCHD_STOP | |
1524 | AT_CLEANUP | |
1525 | ||
8e53fe8c | 1526 | AT_SETUP([conntrack - ICMP related]) |
9c1ab985 | 1527 | AT_SKIP_IF([test $HAVE_NC = no]) |
8e53fe8c | 1528 | CHECK_CONNTRACK() |
cf7659b6 | 1529 | OVS_TRAFFIC_VSWITCHD_START() |
8e53fe8c JS |
1530 | |
1531 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1532 | ||
1533 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1534 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1535 | ||
1536 | dnl Allow UDP traffic from ns0->ns1. Only allow related ICMP responses back. | |
1537 | AT_DATA([flows.txt], [dnl | |
1538 | priority=1,action=drop | |
1539 | priority=10,arp,action=normal | |
1540 | priority=100,in_port=1,udp,action=ct(commit,exec(set_field:1->ct_mark)),2 | |
1541 | priority=100,in_port=2,icmp,ct_state=-trk,action=ct(table=0) | |
1542 | priority=100,in_port=2,icmp,ct_state=+trk+rel,ct_mark=1,action=1 | |
1543 | ]) | |
1544 | ||
6cfa8ec3 | 1545 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
8e53fe8c | 1546 | |
bde2e7b5 | 1547 | dnl UDP packets from ns0->ns1 should solicit "destination unreachable" response. |
b54971f7 | 1548 | NS_CHECK_EXEC([at_ns0], [bash -c "echo a | nc $NC_EOF_OPT -u 10.1.1.2 10000"]) |
8e53fe8c JS |
1549 | |
1550 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
1551 | AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort | grep -v drop], [0], [dnl | |
1552 | n_packets=1, n_bytes=44, priority=100,udp,in_port=1 actions=ct(commit,exec(load:0x1->NXM_NX_CT_MARK[[]])),output:2 | |
1553 | n_packets=1, n_bytes=72, priority=100,ct_state=+rel+trk,ct_mark=0x1,icmp,in_port=2 actions=output:1 | |
1554 | n_packets=1, n_bytes=72, priority=100,ct_state=-trk,icmp,in_port=2 actions=ct(table=0) | |
bde2e7b5 | 1555 | n_packets=2, n_bytes=84, priority=10,arp actions=NORMAL |
8e53fe8c JS |
1556 | NXST_FLOW reply: |
1557 | ]) | |
1558 | ||
1559 | OVS_TRAFFIC_VSWITCHD_STOP | |
1560 | AT_CLEANUP | |
1561 | ||
07659514 JS |
1562 | AT_SETUP([conntrack - ICMP related 2]) |
1563 | CHECK_CONNTRACK() | |
cf7659b6 | 1564 | OVS_TRAFFIC_VSWITCHD_START() |
07659514 JS |
1565 | |
1566 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1567 | ||
1568 | ADD_VETH(p0, at_ns0, br0, "172.16.0.1/24") | |
1569 | ADD_VETH(p1, at_ns1, br0, "172.16.0.2/24") | |
1570 | ||
1571 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
1572 | AT_DATA([flows.txt], [dnl | |
1573 | priority=1,action=drop | |
1574 | priority=10,arp,action=normal | |
6cfa8ec3 JR |
1575 | priority=100,in_port=1,udp,ct_state=-trk,action=ct(commit,table=0) |
1576 | priority=100,in_port=1,ip,ct_state=+trk,actions=controller | |
1577 | priority=100,in_port=2,ip,ct_state=-trk,action=ct(table=0) | |
1578 | priority=100,in_port=2,ip,ct_state=+trk+rel+rpl,action=controller | |
07659514 JS |
1579 | ]) |
1580 | ||
6cfa8ec3 | 1581 | AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows.txt]) |
07659514 JS |
1582 | |
1583 | AT_CAPTURE_FILE([ofctl_monitor.log]) | |
1584 | AT_CHECK([ovs-ofctl monitor br0 65534 invalid_ttl --detach --no-chdir --pidfile 2> ofctl_monitor.log]) | |
1585 | ||
1586 | dnl 1. Send an ICMP port unreach reply for port 8738, without any previous request | |
1587 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 ct\(table=0\) 'f64c473528c9c6f54ecb72db080045c0003d2e8700004001f355ac100004ac1000030303553f0000000045000021317040004011b138ac100003ac10000411112222000d20966369616f0a']) | |
1588 | ||
1589 | dnl 2. Send and UDP packet to port 5555 | |
1590 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 1 ct\(commit,table=0\) 'c6f94ecb72dbe64c473528c9080045000021317040004011b138ac100001ac100002a28e15b3000d20966369616f0a']) | |
1591 | ||
1592 | dnl 3. Send an ICMP port unreach reply for port 5555, related to the first packet | |
1593 | AT_CHECK([ovs-ofctl -O OpenFlow13 packet-out br0 2 ct\(table=0\) 'e64c473528c9c6f94ecb72db080045c0003d2e8700004001f355ac100002ac1000010303553f0000000045000021317040004011b138ac100001ac100002a28e15b3000d20966369616f0a']) | |
1594 | ||
1595 | dnl Check this output. We only see the latter two packets, not the first. | |
1596 | AT_CHECK([cat ofctl_monitor.log], [0], [dnl | |
f274a047 | 1597 | NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=47 ct_state=new|trk,in_port=1 (via action) data_len=47 (unbuffered) |
07659514 | 1598 | 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 |
f274a047 | 1599 | NXT_PACKET_IN2 (xid=0x0): cookie=0x0 total_len=75 ct_state=rel|rpl|trk,in_port=2 (via action) data_len=75 (unbuffered) |
07659514 JS |
1600 | 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 |
1601 | ]) | |
1602 | ||
1603 | OVS_TRAFFIC_VSWITCHD_STOP | |
1604 | AT_CLEANUP | |
d787ad39 JS |
1605 | |
1606 | AT_SETUP([conntrack - FTP]) | |
1607 | AT_SKIP_IF([test $HAVE_PYFTPDLIB = no]) | |
1608 | CHECK_CONNTRACK() | |
4573c42e | 1609 | CHECK_CONNTRACK_ALG() |
cf7659b6 | 1610 | OVS_TRAFFIC_VSWITCHD_START() |
d787ad39 JS |
1611 | |
1612 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1613 | ||
1614 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1615 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1616 | ||
1617 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
1618 | AT_DATA([flows1.txt], [dnl | |
b3b85373 JS |
1619 | table=0,priority=1,action=drop |
1620 | table=0,priority=10,arp,action=normal | |
1621 | table=0,priority=10,icmp,action=normal | |
1622 | table=0,priority=100,in_port=1,tcp,action=ct(alg=ftp,commit),2 | |
1623 | table=0,priority=100,in_port=2,tcp,action=ct(table=1) | |
1624 | table=1,in_port=2,tcp,ct_state=+trk+est,action=1 | |
1625 | table=1,in_port=2,tcp,ct_state=+trk+rel,action=1 | |
d787ad39 JS |
1626 | ]) |
1627 | ||
1628 | dnl Similar policy but without allowing all traffic from ns0->ns1. | |
1629 | AT_DATA([flows2.txt], [dnl | |
b3b85373 JS |
1630 | table=0,priority=1,action=drop |
1631 | table=0,priority=10,arp,action=normal | |
1632 | table=0,priority=10,icmp,action=normal | |
1633 | ||
1634 | dnl Allow outgoing TCP connections, and treat them as FTP | |
1635 | table=0,priority=100,in_port=1,tcp,action=ct(table=1) | |
1636 | table=1,in_port=1,tcp,ct_state=+trk+new,action=ct(commit,alg=ftp),2 | |
1637 | table=1,in_port=1,tcp,ct_state=+trk+est,action=2 | |
1638 | ||
1639 | dnl Allow incoming FTP data connections and responses to existing connections | |
1640 | table=0,priority=100,in_port=2,tcp,action=ct(table=1) | |
1641 | table=1,in_port=2,tcp,ct_state=+trk+new+rel,action=ct(commit),1 | |
1642 | table=1,in_port=2,tcp,ct_state=+trk+est,action=1 | |
1643 | table=1,in_port=2,tcp,ct_state=+trk-new+rel,action=1 | |
d787ad39 JS |
1644 | ]) |
1645 | ||
6cfa8ec3 | 1646 | AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows1.txt]) |
d787ad39 | 1647 | |
7ed40afe JS |
1648 | OVS_START_L7([at_ns0], [ftp]) |
1649 | OVS_START_L7([at_ns1], [ftp]) | |
d787ad39 JS |
1650 | |
1651 | dnl FTP requests from p1->p0 should fail due to network failure. | |
1652 | dnl Try 3 times, in 1 second intervals. | |
1653 | NS_CHECK_EXEC([at_ns1], [wget ftp://10.1.1.1 --no-passive-ftp -t 3 -T 1 -v -o wget1.log], [4]) | |
ec3aa16c | 1654 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl |
d787ad39 JS |
1655 | ]) |
1656 | ||
1657 | dnl FTP requests from p0->p1 should work fine. | |
1658 | NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
420c73b2 JR |
1659 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1660 | 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 | |
d787ad39 JS |
1661 | ]) |
1662 | ||
1663 | dnl Try the second set of flows. | |
6cfa8ec3 | 1664 | AT_CHECK([ovs-ofctl --bundle replace-flows br0 flows2.txt]) |
ec3aa16c | 1665 | AT_CHECK([ovs-appctl dpctl/flush-conntrack]) |
d787ad39 JS |
1666 | |
1667 | dnl FTP requests from p1->p0 should fail due to network failure. | |
1668 | dnl Try 3 times, in 1 second intervals. | |
1669 | NS_CHECK_EXEC([at_ns1], [wget ftp://10.1.1.1 --no-passive-ftp -t 3 -T 1 -v -o wget1.log], [4]) | |
ec3aa16c | 1670 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl |
d787ad39 JS |
1671 | ]) |
1672 | ||
1673 | dnl Active FTP requests from p0->p1 should work fine. | |
9ac0aada | 1674 | 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]) |
420c73b2 JR |
1675 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1676 | 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 | |
1677 | 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>) | |
d787ad39 JS |
1678 | ]) |
1679 | ||
ec3aa16c | 1680 | AT_CHECK([ovs-appctl dpctl/flush-conntrack]) |
d787ad39 JS |
1681 | |
1682 | dnl Passive FTP requests from p0->p1 should work fine. | |
9ac0aada | 1683 | NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0-2.log]) |
420c73b2 | 1684 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
420c73b2 | 1685 | 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 |
d787ad39 JS |
1686 | ]) |
1687 | ||
1688 | OVS_TRAFFIC_VSWITCHD_STOP | |
1689 | AT_CLEANUP | |
1690 | ||
2fa3e06d JR |
1691 | |
1692 | AT_SETUP([conntrack - IPv6 FTP]) | |
1693 | AT_SKIP_IF([test $HAVE_PYFTPDLIB = no]) | |
1694 | CHECK_CONNTRACK() | |
4573c42e | 1695 | CHECK_CONNTRACK_ALG() |
2fa3e06d JR |
1696 | OVS_TRAFFIC_VSWITCHD_START() |
1697 | ||
1698 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1699 | ||
1700 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
1701 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
1702 | ||
1703 | dnl Allow any traffic from ns0->ns1. | |
1704 | dnl Only allow nd, return traffic from ns1->ns0. | |
1705 | AT_DATA([flows.txt], [dnl | |
1706 | dnl Track all IPv6 traffic and drop the rest. | |
1707 | dnl Allow ICMPv6 both ways. No commit, so pings will not be tracked. | |
1708 | table=0 priority=100 in_port=1 icmp6, action=2 | |
1709 | table=0 priority=100 in_port=2 icmp6, action=1 | |
1710 | table=0 priority=10 ip6, action=ct(table=1) | |
1711 | table=0 priority=0 action=drop | |
1712 | dnl | |
1713 | dnl Table 1 | |
1714 | dnl | |
1715 | dnl Allow new TCPv6 FTP control connections from port 1. | |
1716 | table=1 in_port=1 ct_state=+new, tcp6, tp_dst=21, action=ct(alg=ftp,commit),2 | |
1717 | dnl Allow related TCPv6 connections from port 2. | |
1718 | table=1 in_port=2 ct_state=+new+rel, tcp6, action=ct(commit),1 | |
1719 | dnl Allow established TCPv6 connections both ways. | |
1720 | table=1 in_port=1 ct_state=+est, tcp6, action=2 | |
1721 | table=1 in_port=2 ct_state=+est, tcp6, action=1 | |
1722 | dnl Drop everything else. | |
1723 | table=1 priority=0, action=drop | |
1724 | ]) | |
1725 | ||
1726 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1727 | ||
c10840ff JS |
1728 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
1729 | dnl waiting, we get occasional failures due to the following error: | |
1730 | dnl "connect: Cannot assign requested address" | |
1731 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2 >/dev/null]) | |
1732 | ||
7ed40afe | 1733 | OVS_START_L7([at_ns1], [ftp]) |
2fa3e06d JR |
1734 | |
1735 | dnl FTP requests from p0->p1 should work fine. | |
4fee8b13 | 1736 | 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]) |
2fa3e06d | 1737 | |
ec3aa16c | 1738 | dnl Discards CLOSE_WAIT and CLOSING |
420c73b2 JR |
1739 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl |
1740 | 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 | |
1741 | 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>) | |
2fa3e06d JR |
1742 | ]) |
1743 | ||
1744 | OVS_TRAFFIC_VSWITCHD_STOP | |
1745 | AT_CLEANUP | |
1746 | ||
1747 | ||
d787ad39 JS |
1748 | AT_SETUP([conntrack - FTP with multiple expectations]) |
1749 | AT_SKIP_IF([test $HAVE_PYFTPDLIB = no]) | |
1750 | CHECK_CONNTRACK() | |
4573c42e | 1751 | CHECK_CONNTRACK_ALG() |
cf7659b6 | 1752 | OVS_TRAFFIC_VSWITCHD_START() |
d787ad39 JS |
1753 | |
1754 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1755 | ||
1756 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1757 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1758 | ||
1759 | dnl Dual-firewall, allow all from ns1->ns2, allow established and ftp ns2->ns1. | |
1760 | AT_DATA([flows.txt], [dnl | |
b3b85373 JS |
1761 | table=0,priority=1,action=drop |
1762 | table=0,priority=10,arp,action=normal | |
1763 | table=0,priority=10,icmp,action=normal | |
1764 | ||
1765 | dnl Traffic from ns1 | |
ff188ad1 JS |
1766 | table=0,priority=100,in_port=1,tcp,action=ct(table=1,zone=1) |
1767 | 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 | |
1768 | table=1,in_port=1,tcp,ct_zone=1,ct_state=+trk+new+rel,action=ct(commit,zone=1),ct(commit,zone=2),2 | |
b3b85373 JS |
1769 | table=1,in_port=1,tcp,ct_zone=1,ct_state=+trk+est,action=ct(table=2,zone=2) |
1770 | table=2,in_port=1,tcp,ct_zone=2,ct_state=+trk+est,action=2 | |
1771 | ||
1772 | dnl Traffic from ns2 | |
ff188ad1 | 1773 | table=0,priority=100,in_port=2,tcp,action=ct(table=1,zone=2) |
b3b85373 JS |
1774 | table=1,in_port=2,tcp,ct_zone=2,ct_state=+trk+rel,action=ct(commit,zone=2),ct(commit,zone=1),1 |
1775 | table=1,in_port=2,tcp,ct_zone=2,ct_state=+trk+est,action=ct(table=2,zone=1) | |
1776 | table=2,in_port=2,tcp,ct_zone=1,ct_state=+trk+rel,action=ct(commit,zone=2),ct(commit,zone=1),1 | |
1777 | table=2,in_port=2,tcp,ct_zone=1,ct_state=+trk+est,action=1 | |
d787ad39 JS |
1778 | ]) |
1779 | ||
6cfa8ec3 | 1780 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
d787ad39 | 1781 | |
7ed40afe JS |
1782 | OVS_START_L7([at_ns0], [ftp]) |
1783 | OVS_START_L7([at_ns1], [ftp]) | |
d787ad39 JS |
1784 | |
1785 | dnl FTP requests from p1->p0 should fail due to network failure. | |
1786 | dnl Try 3 times, in 1 second intervals. | |
1787 | NS_CHECK_EXEC([at_ns1], [wget ftp://10.1.1.1 --no-passive-ftp -t 3 -T 1 -v -o wget1.log], [4]) | |
ec3aa16c | 1788 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.1)], [0], [dnl |
d787ad39 JS |
1789 | ]) |
1790 | ||
1791 | dnl Active FTP requests from p0->p1 should work fine. | |
1792 | NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 --no-passive-ftp -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
420c73b2 JR |
1793 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1794 | 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 | |
1795 | 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 | |
1796 | 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>) | |
1797 | 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>) | |
d787ad39 JS |
1798 | ]) |
1799 | ||
ec3aa16c | 1800 | AT_CHECK([ovs-appctl dpctl/flush-conntrack]) |
d787ad39 JS |
1801 | |
1802 | dnl Passive FTP requests from p0->p1 should work fine. | |
1803 | NS_CHECK_EXEC([at_ns0], [wget ftp://10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
420c73b2 JR |
1804 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
1805 | 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>) | |
1806 | 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 | |
1807 | 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>) | |
1808 | 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 | |
d787ad39 JS |
1809 | ]) |
1810 | ||
1811 | OVS_TRAFFIC_VSWITCHD_STOP | |
1812 | AT_CLEANUP | |
27130224 AZ |
1813 | |
1814 | AT_SETUP([conntrack - IPv4 fragmentation ]) | |
1815 | CHECK_CONNTRACK() | |
4573c42e | 1816 | CHECK_CONNTRACK_FRAG() |
cf7659b6 | 1817 | OVS_TRAFFIC_VSWITCHD_START() |
27130224 AZ |
1818 | |
1819 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1820 | ||
1821 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1822 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1823 | ||
1824 | dnl Sending ping through conntrack | |
1825 | AT_DATA([flows.txt], [dnl | |
1826 | priority=1,action=drop | |
1827 | priority=10,arp,action=normal | |
1828 | priority=100,in_port=1,icmp,action=ct(commit,zone=9),2 | |
1829 | priority=100,in_port=2,ct_state=-trk,icmp,action=ct(table=0,zone=9) | |
1830 | priority=100,in_port=2,ct_state=+trk+est-new,icmp,action=1 | |
1831 | ]) | |
1832 | ||
6cfa8ec3 | 1833 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
27130224 | 1834 | |
27130224 AZ |
1835 | dnl Ipv4 fragmentation connectivity check. |
1836 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
1837 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1838 | ]) | |
1839 | ||
1840 | dnl Ipv4 larger fragmentation connectivity check. | |
1841 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
1842 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1843 | ]) | |
1844 | ||
1845 | OVS_TRAFFIC_VSWITCHD_STOP | |
1846 | AT_CLEANUP | |
1847 | ||
0cf28088 JS |
1848 | AT_SETUP([conntrack - IPv4 fragmentation expiry]) |
1849 | CHECK_CONNTRACK() | |
4573c42e | 1850 | CHECK_CONNTRACK_FRAG() |
0cf28088 JS |
1851 | OVS_TRAFFIC_VSWITCHD_START() |
1852 | ||
1853 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1854 | ||
1855 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1856 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1857 | ||
1858 | AT_DATA([flows.txt], [dnl | |
1859 | priority=1,action=drop | |
1860 | priority=10,arp,action=normal | |
1861 | ||
1862 | dnl Only allow non-fragmented messages and 1st fragments of each message | |
1863 | priority=100,in_port=1,icmp,ip_frag=no,action=ct(commit,zone=9),2 | |
1864 | priority=100,in_port=1,icmp,ip_frag=firstaction=ct(commit,zone=9),2 | |
1865 | priority=100,in_port=2,ct_state=-trk,icmp,action=ct(table=0,zone=9) | |
1866 | priority=100,in_port=2,ct_state=+trk+est-new,icmp,action=1 | |
1867 | ]) | |
1868 | ||
1869 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1870 | ||
0cf28088 JS |
1871 | dnl Ipv4 fragmentation connectivity check. |
1872 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 1 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING], [0], [dnl | |
1873 | 7 packets transmitted, 0 received, 100% packet loss, time 0ms | |
1874 | ]) | |
1875 | ||
1876 | OVS_TRAFFIC_VSWITCHD_STOP | |
1877 | AT_CLEANUP | |
1878 | ||
27130224 AZ |
1879 | AT_SETUP([conntrack - IPv4 fragmentation + vlan]) |
1880 | CHECK_CONNTRACK() | |
4573c42e | 1881 | CHECK_CONNTRACK_FRAG() |
cf7659b6 | 1882 | OVS_TRAFFIC_VSWITCHD_START() |
27130224 AZ |
1883 | |
1884 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1885 | ||
1886 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
1887 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
1888 | ADD_VLAN(p0, at_ns0, 100, "10.2.2.1/24") | |
1889 | ADD_VLAN(p1, at_ns1, 100, "10.2.2.2/24") | |
1890 | ||
1891 | dnl Sending ping through conntrack | |
1892 | AT_DATA([flows.txt], [dnl | |
1893 | priority=1,action=drop | |
1894 | priority=10,arp,action=normal | |
1895 | priority=100,in_port=1,icmp,action=ct(commit,zone=9),2 | |
1896 | priority=100,in_port=2,ct_state=-trk,icmp,action=ct(table=0,zone=9) | |
1897 | priority=100,in_port=2,ct_state=+trk+est-new,icmp,action=1 | |
1898 | ]) | |
1899 | ||
6cfa8ec3 | 1900 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
27130224 | 1901 | |
27130224 AZ |
1902 | dnl Ipv4 fragmentation connectivity check. |
1903 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
1904 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1905 | ]) | |
1906 | ||
1907 | dnl Ipv4 larger fragmentation connectivity check. | |
1908 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.2.2.2 | FORMAT_PING], [0], [dnl | |
1909 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1910 | ]) | |
1911 | ||
1912 | OVS_TRAFFIC_VSWITCHD_STOP | |
1913 | AT_CLEANUP | |
1914 | ||
1915 | AT_SETUP([conntrack - IPv6 fragmentation]) | |
1916 | CHECK_CONNTRACK() | |
4573c42e | 1917 | CHECK_CONNTRACK_FRAG() |
cf7659b6 | 1918 | OVS_TRAFFIC_VSWITCHD_START() |
27130224 AZ |
1919 | |
1920 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1921 | ||
1922 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
1923 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
1924 | ||
1925 | dnl Sending ping through conntrack | |
1926 | AT_DATA([flows.txt], [dnl | |
1927 | priority=1,action=drop | |
1928 | priority=10,in_port=1,ipv6,action=ct(commit,zone=9),2 | |
1929 | priority=10,in_port=2,ct_state=-trk,ipv6,action=ct(table=0,zone=9) | |
1930 | priority=10,in_port=2,ct_state=+trk+est-new,ipv6,action=1 | |
1931 | priority=100,icmp6,icmp_type=135,action=normal | |
1932 | priority=100,icmp6,icmp_type=136,action=normal | |
1933 | ]) | |
1934 | ||
6cfa8ec3 | 1935 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
27130224 | 1936 | |
c10840ff JS |
1937 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
1938 | dnl waiting, we get occasional failures due to the following error: | |
27130224 | 1939 | dnl "connect: Cannot assign requested address" |
c10840ff | 1940 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) |
27130224 | 1941 | |
221a2668 | 1942 | dnl Ipv6 fragmentation connectivity check. |
27130224 AZ |
1943 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl |
1944 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1945 | ]) | |
1946 | ||
221a2668 | 1947 | dnl Ipv6 larger fragmentation connectivity check. |
27130224 AZ |
1948 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl |
1949 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
1950 | ]) | |
1951 | ||
1952 | OVS_TRAFFIC_VSWITCHD_STOP | |
1953 | AT_CLEANUP | |
1954 | ||
0cf28088 JS |
1955 | AT_SETUP([conntrack - IPv6 fragmentation expiry]) |
1956 | CHECK_CONNTRACK() | |
4573c42e | 1957 | CHECK_CONNTRACK_FRAG() |
0cf28088 JS |
1958 | OVS_TRAFFIC_VSWITCHD_START() |
1959 | ||
1960 | ADD_NAMESPACES(at_ns0, at_ns1) | |
1961 | ||
1962 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
1963 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
1964 | ||
1965 | AT_DATA([flows.txt], [dnl | |
1966 | priority=1,action=drop | |
1967 | ||
1968 | dnl Only allow non-fragmented messages and 1st fragments of each message | |
1969 | priority=10,in_port=1,ipv6,ip_frag=first,action=ct(commit,zone=9),2 | |
1970 | priority=10,in_port=1,ipv6,ip_frag=no,action=ct(commit,zone=9),2 | |
1971 | priority=10,in_port=2,ct_state=-trk,ipv6,action=ct(table=0,zone=9) | |
1972 | priority=10,in_port=2,ct_state=+trk+est-new,ipv6,action=1 | |
1973 | ||
1974 | dnl Neighbour Discovery | |
1975 | priority=100,icmp6,icmp_type=135,action=normal | |
1976 | priority=100,icmp6,icmp_type=136,action=normal | |
1977 | ]) | |
1978 | ||
1979 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
1980 | ||
c10840ff JS |
1981 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
1982 | dnl waiting, we get occasional failures due to the following error: | |
0cf28088 | 1983 | dnl "connect: Cannot assign requested address" |
c10840ff | 1984 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) |
0cf28088 | 1985 | |
0cf28088 JS |
1986 | dnl Send an IPv6 fragment. Some time later, it should expire. |
1987 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 1 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
1988 | 7 packets transmitted, 0 received, 100% packet loss, time 0ms | |
1989 | ]) | |
1990 | ||
1991 | dnl At this point, the kernel will either crash or everything is OK. | |
1992 | ||
1993 | OVS_TRAFFIC_VSWITCHD_STOP | |
1994 | AT_CLEANUP | |
1995 | ||
27130224 AZ |
1996 | AT_SETUP([conntrack - IPv6 fragmentation + vlan]) |
1997 | CHECK_CONNTRACK() | |
4573c42e | 1998 | CHECK_CONNTRACK_FRAG() |
cf7659b6 | 1999 | OVS_TRAFFIC_VSWITCHD_START() |
27130224 AZ |
2000 | |
2001 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2002 | ||
2003 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
2004 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
2005 | ||
2006 | ADD_VLAN(p0, at_ns0, 100, "fc00:1::3/96") | |
2007 | ADD_VLAN(p1, at_ns1, 100, "fc00:1::4/96") | |
2008 | ||
2009 | dnl Sending ping through conntrack | |
2010 | AT_DATA([flows.txt], [dnl | |
2011 | priority=1,action=drop | |
2012 | priority=10,in_port=1,ipv6,action=ct(commit,zone=9),2 | |
2013 | priority=10,in_port=2,ct_state=-trk,ipv6,action=ct(table=0,zone=9) | |
2014 | priority=10,in_port=2,ct_state=+trk+est-new,ipv6,action=1 | |
2015 | priority=100,icmp6,icmp_type=135,action=normal | |
2016 | priority=100,icmp6,icmp_type=136,action=normal | |
2017 | ]) | |
2018 | ||
6cfa8ec3 | 2019 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
27130224 | 2020 | |
c10840ff JS |
2021 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
2022 | dnl waiting, we get occasional failures due to the following error: | |
27130224 | 2023 | dnl "connect: Cannot assign requested address" |
c10840ff | 2024 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) |
27130224 | 2025 | |
27130224 AZ |
2026 | dnl Ipv4 fragmentation connectivity check. |
2027 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00:1::4 | FORMAT_PING], [0], [dnl | |
2028 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
2029 | ]) | |
2030 | ||
2031 | dnl Ipv4 larger fragmentation connectivity check. | |
2032 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00:1::4 | FORMAT_PING], [0], [dnl | |
2033 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
2034 | ]) | |
2035 | ||
2036 | OVS_TRAFFIC_VSWITCHD_STOP | |
2037 | AT_CLEANUP | |
2038 | ||
2039 | AT_SETUP([conntrack - Fragmentation over vxlan]) | |
dfb21e96 | 2040 | OVS_CHECK_VXLAN() |
27130224 | 2041 | CHECK_CONNTRACK() |
4573c42e | 2042 | CHECK_CONNTRACK_FRAG() |
27130224 | 2043 | |
cf7659b6 JR |
2044 | OVS_TRAFFIC_VSWITCHD_START() |
2045 | ADD_BR([br-underlay]) | |
2046 | AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"]) | |
2047 | ||
27130224 AZ |
2048 | ADD_NAMESPACES(at_ns0) |
2049 | ||
2050 | dnl Sending ping through conntrack | |
2051 | AT_DATA([flows.txt], [dnl | |
2052 | priority=1,action=drop | |
2053 | priority=10,arp,action=normal | |
2054 | priority=100,in_port=1,icmp,action=ct(commit,zone=9),LOCAL | |
3a9eb803 | 2055 | priority=100,in_port=LOCAL,icmp,action=ct(table=1,zone=9) |
723af132 | 2056 | table=1,in_port=LOCAL,ct_state=+trk+est,icmp,action=1 |
27130224 AZ |
2057 | ]) |
2058 | ||
6cfa8ec3 | 2059 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
27130224 AZ |
2060 | |
2061 | dnl Set up underlay link from host into the namespace using veth pair. | |
2062 | ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24") | |
2063 | AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"]) | |
2064 | AT_CHECK([ip link set dev br-underlay up]) | |
2065 | ||
2066 | dnl Set up tunnel endpoints on OVS outside the namespace and with a native | |
2067 | dnl linux device inside the namespace. | |
6e3a764c | 2068 | ADD_OVS_TUNNEL([vxlan], [br0], [at_vxlan0], [172.31.1.1], [10.1.1.100/24]) |
27130224 AZ |
2069 | ADD_NATIVE_TUNNEL([vxlan], [at_vxlan1], [at_ns0], [172.31.1.100], [10.1.1.1/24], |
2070 | [id 0 dstport 4789]) | |
2071 | ||
2072 | dnl First, check the underlay | |
2073 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl | |
2074 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
2075 | ]) | |
2076 | ||
2077 | dnl Okay, now check the overlay with different packet sizes | |
2078 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
2079 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
2080 | ]) | |
2081 | NS_CHECK_EXEC([at_ns0], [ping -s 1600 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
2082 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
2083 | ]) | |
2084 | NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.100 | FORMAT_PING], [0], [dnl | |
2085 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
2086 | ]) | |
2087 | ||
2088 | OVS_TRAFFIC_VSWITCHD_STOP | |
2089 | AT_CLEANUP | |
c4e34c61 | 2090 | |
84f646df | 2091 | AT_SETUP([conntrack - IPv6 Fragmentation over vxlan]) |
a9f70f3d | 2092 | OVS_CHECK_VXLAN() |
84f646df | 2093 | CHECK_CONNTRACK() |
4573c42e | 2094 | CHECK_CONNTRACK_FRAG() |
84f646df JS |
2095 | |
2096 | OVS_TRAFFIC_VSWITCHD_START() | |
2097 | ADD_BR([br-underlay]) | |
2098 | AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"]) | |
2099 | ||
2100 | ADD_NAMESPACES(at_ns0) | |
2101 | ||
2102 | dnl Sending ping through conntrack | |
2103 | AT_DATA([flows.txt], [dnl | |
2104 | priority=1,action=drop | |
2105 | priority=100,in_port=1,ipv6,action=ct(commit,zone=9),LOCAL | |
2106 | priority=100,in_port=LOCAL,ipv6,action=ct(table=1,zone=9) | |
723af132 | 2107 | table=1,in_port=LOCAL,ct_state=+trk+est,ipv6,action=1 |
84f646df JS |
2108 | |
2109 | dnl Neighbour Discovery | |
2110 | priority=1000,icmp6,icmp_type=135,action=normal | |
2111 | priority=1000,icmp6,icmp_type=136,action=normal | |
2112 | ]) | |
2113 | ||
2114 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2115 | ||
2116 | dnl Set up underlay link from host into the namespace using veth pair. | |
2117 | ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24") | |
2118 | AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"]) | |
2119 | AT_CHECK([ip link set dev br-underlay up]) | |
2120 | ||
2121 | dnl Set up tunnel endpoints on OVS outside the namespace and with a native | |
2122 | dnl linux device inside the namespace. | |
6e3a764c | 2123 | ADD_OVS_TUNNEL([vxlan], [br0], [at_vxlan0], [172.31.1.1], ["fc00::2/96"]) |
84f646df JS |
2124 | ADD_NATIVE_TUNNEL([vxlan], [at_vxlan1], [at_ns0], [172.31.1.100], ["fc00::1/96"], |
2125 | [id 0 dstport 4789]) | |
2126 | ||
c10840ff JS |
2127 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
2128 | dnl waiting, we get occasional failures due to the following error: | |
84f646df | 2129 | dnl "connect: Cannot assign requested address" |
c10840ff | 2130 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) |
84f646df JS |
2131 | |
2132 | dnl First, check the underlay | |
2133 | NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl | |
2134 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
2135 | ]) | |
2136 | ||
2137 | dnl Okay, now check the overlay with different packet sizes | |
2138 | NS_CHECK_EXEC([at_ns0], [ping6 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
2139 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
2140 | ]) | |
2141 | NS_CHECK_EXEC([at_ns0], [ping6 -s 1600 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
2142 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
2143 | ]) | |
2144 | NS_CHECK_EXEC([at_ns0], [ping6 -s 3200 -q -c 3 -i 0.3 -w 2 fc00::2 | FORMAT_PING], [0], [dnl | |
2145 | 3 packets transmitted, 3 received, 0% packet loss, time 0ms | |
2146 | ]) | |
2147 | ||
2148 | OVS_TRAFFIC_VSWITCHD_STOP | |
2149 | AT_CLEANUP | |
9ac0aada | 2150 | |
c4e34c61 RB |
2151 | AT_SETUP([conntrack - resubmit to ct multiple times]) |
2152 | CHECK_CONNTRACK() | |
2153 | ||
2154 | OVS_TRAFFIC_VSWITCHD_START( | |
2155 | [set-fail-mode br0 secure -- ]) | |
2156 | ||
2157 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2158 | ||
2159 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2160 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2161 | ||
2162 | AT_DATA([flows.txt], [dnl | |
2163 | table=0,priority=150,arp,action=normal | |
2164 | table=0,priority=100,ip,in_port=1,action=resubmit(,1),resubmit(,2) | |
2165 | ||
723af132 JS |
2166 | table=1,ip,action=ct(table=3) |
2167 | table=2,ip,action=ct(table=3) | |
c4e34c61 RB |
2168 | |
2169 | table=3,ip,action=drop | |
2170 | ]) | |
2171 | ||
2172 | AT_CHECK([ovs-ofctl add-flows br0 flows.txt]) | |
2173 | ||
2174 | NS_CHECK_EXEC([at_ns0], [ping -q -c 1 10.1.1.2 | FORMAT_PING], [0], [dnl | |
2175 | 1 packets transmitted, 0 received, 100% packet loss, time 0ms | |
2176 | ]) | |
2177 | ||
2178 | AT_CHECK([ovs-ofctl dump-flows br0 | ofctl_strip | sort], [0], [dnl | |
2179 | n_packets=1, n_bytes=98, priority=100,ip,in_port=1 actions=resubmit(,1),resubmit(,2) | |
2180 | n_packets=2, n_bytes=84, priority=150,arp actions=NORMAL | |
723af132 JS |
2181 | table=1, n_packets=1, n_bytes=98, ip actions=ct(table=3) |
2182 | table=2, n_packets=1, n_bytes=98, ip actions=ct(table=3) | |
c4e34c61 RB |
2183 | table=3, n_packets=2, n_bytes=196, ip actions=drop |
2184 | NXST_FLOW reply: | |
2185 | ]) | |
2186 | ||
2187 | OVS_TRAFFIC_VSWITCHD_STOP | |
2188 | AT_CLEANUP | |
9ac0aada | 2189 | |
ee8941ab | 2190 | AT_BANNER([conntrack - NAT]) |
9ac0aada JR |
2191 | |
2192 | AT_SETUP([conntrack - simple SNAT]) | |
2193 | CHECK_CONNTRACK() | |
4573c42e | 2194 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2195 | OVS_TRAFFIC_VSWITCHD_START() |
2196 | ||
2197 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2198 | ||
2199 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2200 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2201 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2202 | ||
2203 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2204 | AT_DATA([flows.txt], [dnl | |
2205 | in_port=1,ip,action=ct(commit,zone=1,nat(src=10.1.1.240-10.1.1.255)),2 | |
2206 | in_port=2,ct_state=-trk,ip,action=ct(table=0,zone=1,nat) | |
2207 | in_port=2,ct_state=+trk,ct_zone=1,ip,action=1 | |
2208 | dnl | |
2209 | dnl ARP | |
2210 | priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2211 | priority=10 arp action=normal | |
2212 | priority=0,action=drop | |
2213 | dnl | |
2214 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2215 | table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2216 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2217 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2218 | dnl TPA IP in reg2. | |
2219 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2220 | table=10 priority=100 arp xreg0=0 action=normal | |
2221 | 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]] | |
2222 | table=10 priority=0 action=drop | |
2223 | ]) | |
2224 | ||
2225 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2226 | ||
2227 | dnl HTTP requests from p0->p1 should work fine. | |
7ed40afe | 2228 | OVS_START_L7([at_ns1], [http]) |
9ac0aada JR |
2229 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 5 -T 1 --retry-connrefused -v -o wget0.log]) |
2230 | ||
a857bb69 | 2231 | 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 | 2232 | 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 |
2233 | ]) |
2234 | ||
2235 | OVS_TRAFFIC_VSWITCHD_STOP | |
2236 | AT_CLEANUP | |
2237 | ||
2238 | ||
2239 | AT_SETUP([conntrack - SNAT with port range]) | |
2240 | CHECK_CONNTRACK() | |
4573c42e | 2241 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2242 | OVS_TRAFFIC_VSWITCHD_START() |
2243 | ||
2244 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2245 | ||
2246 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2247 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2248 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2249 | ||
2250 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2251 | AT_DATA([flows.txt], [dnl | |
2252 | in_port=1,tcp,action=ct(commit,zone=1,nat(src=10.1.1.240-10.1.1.255:34567-34568,random)),2 | |
2253 | in_port=2,ct_state=-trk,tcp,tp_dst=34567,action=ct(table=0,zone=1,nat) | |
2254 | in_port=2,ct_state=-trk,tcp,tp_dst=34568,action=ct(table=0,zone=1,nat) | |
2255 | in_port=2,ct_state=+trk,ct_zone=1,tcp,action=1 | |
2256 | dnl | |
2257 | dnl ARP | |
2258 | priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2259 | priority=10 arp action=normal | |
2260 | priority=0,action=drop | |
2261 | dnl | |
2262 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2263 | table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2264 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2265 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2266 | dnl TPA IP in reg2. | |
2267 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2268 | table=10 priority=100 arp xreg0=0 action=normal | |
2269 | 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]] | |
2270 | table=10 priority=0 action=drop | |
2271 | ]) | |
2272 | ||
2273 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2274 | ||
2275 | dnl HTTP requests from p0->p1 should work fine. | |
7ed40afe | 2276 | OVS_START_L7([at_ns1], [http]) |
9ac0aada JR |
2277 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 5 -T 1 --retry-connrefused -v -o wget0.log]) |
2278 | ||
a857bb69 | 2279 | 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 | 2280 | 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 |
2281 | ]) |
2282 | ||
2283 | OVS_TRAFFIC_VSWITCHD_STOP | |
2284 | AT_CLEANUP | |
2285 | ||
2286 | ||
2287 | AT_SETUP([conntrack - more complex SNAT]) | |
2288 | CHECK_CONNTRACK() | |
4573c42e | 2289 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2290 | OVS_TRAFFIC_VSWITCHD_START() |
2291 | ||
2292 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2293 | ||
2294 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2295 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2296 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2297 | ||
2298 | AT_DATA([flows.txt], [dnl | |
2299 | dnl Track all IP traffic, NAT existing connections. | |
2300 | priority=100 ip action=ct(table=1,zone=1,nat) | |
2301 | dnl | |
2302 | dnl Allow ARP, but generate responses for NATed addresses | |
2303 | priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2304 | priority=10 arp action=normal | |
2305 | priority=0 action=drop | |
2306 | dnl | |
2307 | dnl Allow any traffic from ns0->ns1. SNAT ns0 to 10.1.1.240-10.1.1.255 | |
2308 | 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 | |
2309 | table=1 priority=100 in_port=1 ip ct_state=+trk-new+est action=2 | |
2310 | dnl Only allow established traffic from ns1->ns0. | |
2311 | table=1 priority=100 in_port=2 ip ct_state=+trk-new+est action=1 | |
2312 | table=1 priority=0 action=drop | |
2313 | dnl | |
2314 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2315 | table=8 priority=100 reg2=0x0a0101f0/0xfffffff0 action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2316 | dnl Zero result means not found. | |
2317 | table=8 priority=0 action=load:0->OXM_OF_PKT_REG0[[]] | |
2318 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2319 | dnl ARP TPA IP in reg2. | |
2320 | table=10 priority=100 arp xreg0=0 action=normal | |
2321 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2322 | 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]] | |
2323 | table=10 priority=0 action=drop | |
2324 | ]) | |
2325 | ||
2326 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2327 | ||
2328 | dnl HTTP requests from p0->p1 should work fine. | |
7ed40afe | 2329 | OVS_START_L7([at_ns1], [http]) |
9ac0aada JR |
2330 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 5 -T 1 --retry-connrefused -v -o wget0.log]) |
2331 | ||
a857bb69 | 2332 | 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 | 2333 | 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 |
2334 | ]) |
2335 | ||
2336 | OVS_TRAFFIC_VSWITCHD_STOP | |
2337 | AT_CLEANUP | |
2338 | ||
2339 | AT_SETUP([conntrack - simple DNAT]) | |
2340 | CHECK_CONNTRACK() | |
4573c42e | 2341 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2342 | OVS_TRAFFIC_VSWITCHD_START() |
2343 | ||
2344 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2345 | ||
2346 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2347 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2348 | NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address 80:88:88:88:88:88]) | |
2349 | ||
2350 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2351 | AT_DATA([flows.txt], [dnl | |
2352 | priority=100 in_port=1,ip,nw_dst=10.1.1.64,action=ct(zone=1,nat(dst=10.1.1.2),commit),2 | |
2353 | priority=10 in_port=1,ip,action=ct(commit,zone=1),2 | |
2354 | priority=100 in_port=2,ct_state=-trk,ip,action=ct(table=0,nat,zone=1) | |
2355 | priority=100 in_port=2,ct_state=+trk+est,ct_zone=1,ip,action=1 | |
2356 | dnl | |
2357 | dnl ARP | |
2358 | priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2359 | priority=10 arp action=normal | |
2360 | priority=0,action=drop | |
2361 | dnl | |
2362 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2363 | table=8,reg2=0x0a010140,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2364 | dnl Zero result means not found. | |
2365 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2366 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2367 | dnl TPA IP in reg2. | |
2368 | table=10 priority=100 arp xreg0=0 action=normal | |
2369 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2370 | 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]] | |
2371 | table=10 priority=0 action=drop | |
2372 | ]) | |
2373 | ||
2374 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2375 | ||
2376 | dnl Should work with the virtual IP address through NAT | |
7ed40afe | 2377 | OVS_START_L7([at_ns1], [http]) |
9ac0aada JR |
2378 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.64 -t 5 -T 1 --retry-connrefused -v -o wget0.log]) |
2379 | ||
420c73b2 JR |
2380 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.64)], [0], [dnl |
2381 | 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 |
2382 | ]) |
2383 | ||
2384 | dnl Should work with the assigned IP address as well | |
2385 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2386 | ||
420c73b2 JR |
2387 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
2388 | 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 |
2389 | ]) |
2390 | ||
2391 | OVS_TRAFFIC_VSWITCHD_STOP | |
2392 | AT_CLEANUP | |
2393 | ||
2394 | AT_SETUP([conntrack - more complex DNAT]) | |
2395 | CHECK_CONNTRACK() | |
4573c42e | 2396 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2397 | OVS_TRAFFIC_VSWITCHD_START() |
2398 | ||
2399 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2400 | ||
2401 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2402 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2403 | NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address 80:88:88:88:88:88]) | |
2404 | ||
2405 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2406 | AT_DATA([flows.txt], [dnl | |
2407 | dnl Track all IP traffic | |
2408 | table=0 priority=100 ip action=ct(table=1,zone=1,nat) | |
2409 | dnl | |
2410 | dnl Allow ARP, but generate responses for NATed addresses | |
2411 | table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2412 | table=0 priority=10 arp action=normal | |
2413 | table=0 priority=0 action=drop | |
2414 | dnl | |
2415 | dnl Allow any IP traffic from ns0->ns1. DNAT ns0 from 10.1.1.64 to 10.1.1.2 | |
2416 | 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 | |
2417 | table=1 priority=10 in_port=1 ct_state=+new ip action=ct(commit,zone=1),2 | |
2418 | table=1 priority=100 in_port=1 ct_state=+est ct_zone=1 action=2 | |
2419 | dnl Only allow established traffic from ns1->ns0. | |
2420 | table=1 priority=100 in_port=2 ct_state=+est ct_zone=1 action=1 | |
2421 | table=1 priority=0 action=drop | |
2422 | dnl | |
2423 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2424 | table=8,reg2=0x0a010140,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2425 | dnl Zero result means not found. | |
2426 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2427 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2428 | dnl TPA IP in reg2. | |
2429 | table=10 priority=100 arp xreg0=0 action=normal | |
2430 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2431 | 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]] | |
2432 | table=10 priority=0 action=drop | |
2433 | ]) | |
2434 | ||
2435 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2436 | ||
2437 | dnl Should work with the virtual IP address through NAT | |
7ed40afe | 2438 | OVS_START_L7([at_ns1], [http]) |
9ac0aada JR |
2439 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.64 -t 5 -T 1 --retry-connrefused -v -o wget0.log]) |
2440 | ||
420c73b2 JR |
2441 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.64)], [0], [dnl |
2442 | 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 |
2443 | ]) |
2444 | ||
2445 | dnl Should work with the assigned IP address as well | |
2446 | NS_CHECK_EXEC([at_ns0], [wget 10.1.1.2 -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2447 | ||
420c73b2 JR |
2448 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl |
2449 | 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 |
2450 | ]) |
2451 | ||
2452 | OVS_TRAFFIC_VSWITCHD_STOP | |
2453 | AT_CLEANUP | |
2454 | ||
2455 | AT_SETUP([conntrack - ICMP related with NAT]) | |
9c1ab985 | 2456 | AT_SKIP_IF([test $HAVE_NC = no]) |
9ac0aada | 2457 | CHECK_CONNTRACK() |
4573c42e | 2458 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2459 | OVS_TRAFFIC_VSWITCHD_START() |
2460 | ||
2461 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2462 | ||
2463 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") | |
2464 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2465 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
2466 | ||
2467 | dnl Allow UDP traffic from ns0->ns1. Only allow related ICMP responses back. | |
2468 | dnl Make sure ICMP responses are reverse-NATted. | |
2469 | AT_DATA([flows.txt], [dnl | |
2470 | in_port=1,udp,action=ct(commit,nat(src=10.1.1.240-10.1.1.255),exec(set_field:1->ct_mark)),2 | |
2471 | in_port=2,icmp,ct_state=-trk,action=ct(table=0,nat) | |
2472 | in_port=2,icmp,nw_dst=10.1.1.1,ct_state=+trk+rel,ct_mark=1,action=1 | |
2473 | dnl | |
2474 | dnl ARP | |
2475 | priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2476 | priority=10 arp action=normal | |
2477 | priority=0,action=drop | |
2478 | dnl | |
2479 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2480 | table=8,reg2=0x0a0101f0/0xfffffff0,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2481 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2482 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2483 | dnl TPA IP in reg2. | |
2484 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2485 | table=10 priority=100 arp xreg0=0 action=normal | |
2486 | 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]] | |
2487 | table=10 priority=0 action=drop | |
2488 | ]) | |
2489 | ||
2490 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2491 | ||
2492 | dnl UDP packets from ns0->ns1 should solicit "destination unreachable" response. | |
b54971f7 | 2493 | NS_CHECK_EXEC([at_ns0], [bash -c "echo a | nc $NC_EOF_OPT -u 10.1.1.2 10000"]) |
9ac0aada JR |
2494 | |
2495 | AT_CHECK([ovs-appctl revalidator/purge], [0]) | |
2496 | AT_CHECK([ovs-ofctl -O OpenFlow15 dump-flows br0 | ofctl_strip | sort | grep -v drop], [0], [dnl | |
2497 | n_packets=1, n_bytes=42, priority=10,arp actions=NORMAL | |
2498 | 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 | |
2499 | 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 | |
2500 | n_packets=1, n_bytes=72, ct_state=-trk,icmp,in_port=2 actions=ct(table=0,nat) | |
2501 | 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 | |
2502 | 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]] | |
2503 | table=10, n_packets=1, n_bytes=42, priority=100,arp,reg0=0,reg1=0 actions=NORMAL | |
2504 | table=8, n_packets=1, n_bytes=42, priority=0 actions=set_field:0->xreg0 | |
2505 | table=8, n_packets=1, n_bytes=42, reg2=0xa0101f0/0xfffffff0 actions=set_field:0x808888888888->xreg0 | |
2506 | OFPST_FLOW reply (OF1.5): | |
2507 | ]) | |
2508 | ||
a857bb69 DDP |
2509 | 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 |
2510 | 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 |
2511 | ]) |
2512 | ||
2513 | OVS_TRAFFIC_VSWITCHD_STOP | |
2514 | AT_CLEANUP | |
2515 | ||
74f205f6 | 2516 | dnl CHECK_FTP_NAT(TITLE, IP_ADDR, FLOWS) |
019c73ac | 2517 | dnl |
74f205f6 JS |
2518 | dnl Checks the implementation of conntrack with FTP ALGs in combination with |
2519 | dnl NAT, using the provided flow table. | |
2520 | m4_define([CHECK_FTP_NAT], | |
2521 | [AT_SETUP([conntrack - FTP NAT $1]) | |
2522 | AT_SKIP_IF([test $HAVE_PYFTPDLIB = no]) | |
2523 | CHECK_CONNTRACK() | |
2524 | CHECK_CONNTRACK_NAT() | |
019c73ac | 2525 | |
74f205f6 | 2526 | OVS_TRAFFIC_VSWITCHD_START() |
019c73ac | 2527 | |
74f205f6 | 2528 | ADD_NAMESPACES(at_ns0, at_ns1) |
019c73ac | 2529 | |
74f205f6 JS |
2530 | ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") |
2531 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2532 | ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") | |
019c73ac | 2533 | |
74f205f6 JS |
2534 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. |
2535 | AT_DATA([flows.txt], [$3 | |
019c73ac JS |
2536 | ]) |
2537 | ||
74f205f6 | 2538 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) |
019c73ac | 2539 | |
7ed40afe | 2540 | OVS_START_L7([at_ns1], [ftp]) |
019c73ac | 2541 | |
74f205f6 JS |
2542 | dnl FTP requests from p0->p1 should work fine. |
2543 | 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 | 2544 | |
74f205f6 JS |
2545 | dnl Discards CLOSE_WAIT and CLOSING |
2546 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.2)], [0], [dnl | |
2547 | 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 | |
2548 | 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>) | |
2549 | ]) | |
019c73ac | 2550 | |
74f205f6 JS |
2551 | OVS_TRAFFIC_VSWITCHD_STOP |
2552 | AT_CLEANUP]) | |
019c73ac | 2553 | |
74f205f6 JS |
2554 | dnl CHECK_FTP_NAT_PRE_RECIRC(TITLE, IP_ADDR, IP_ADDR_AS_HEX) |
2555 | dnl | |
2556 | dnl Checks the implementation of conntrack with FTP ALGs in combination with | |
2557 | dnl NAT, with flow tables that implement the NATing as part of handling of | |
2558 | dnl initial incoming packets - ie, the first flow is ct(nat,table=foo). | |
2559 | dnl | |
2560 | dnl IP_ADDR must specify the NAT address in standard "10.1.1.x" format, | |
2561 | dnl and IP_ADDR_AS_HEX must specify the same address as hex, eg 0x0a0101xx. | |
2562 | m4_define([CHECK_FTP_NAT_PRE_RECIRC], [dnl | |
2563 | CHECK_FTP_NAT([prerecirc $1], [$2], [dnl | |
9ac0aada JR |
2564 | dnl track all IP traffic, de-mangle non-NEW connections |
2565 | table=0 in_port=1, ip, action=ct(table=1,nat) | |
2566 | table=0 in_port=2, ip, action=ct(table=2,nat) | |
2567 | dnl | |
2568 | dnl ARP | |
2569 | dnl | |
2570 | table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2571 | table=0 priority=10 arp action=normal | |
2572 | table=0 priority=0 action=drop | |
2573 | dnl | |
2574 | dnl Table 1: port 1 -> 2 | |
2575 | dnl | |
2576 | dnl Allow new FTP connections. These need to be commited. | |
74f205f6 | 2577 | 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 | 2578 | dnl Allow established TCP connections, make sure they are NATted already. |
74f205f6 | 2579 | table=1 ct_state=+est, tcp, nw_src=$2, action=2 |
9ac0aada JR |
2580 | dnl |
2581 | dnl Table 1: droppers | |
2582 | dnl | |
2583 | table=1 priority=10, tcp, action=drop | |
2584 | table=1 priority=0,action=drop | |
2585 | dnl | |
2586 | dnl Table 2: port 2 -> 1 | |
2587 | dnl | |
2588 | dnl Allow established TCP connections, make sure they are reverse NATted | |
2589 | table=2 ct_state=+est, tcp, nw_dst=10.1.1.1, action=1 | |
2590 | dnl Allow (new) related (data) connections. These need to be commited. | |
74f205f6 | 2591 | table=2 ct_state=+new+rel, tcp, nw_dst=$2, action=ct(commit,nat),1 |
9ac0aada JR |
2592 | dnl Allow related ICMP packets, make sure they are reverse NATted |
2593 | table=2 ct_state=+rel, icmp, nw_dst=10.1.1.1, action=1 | |
2594 | dnl | |
2595 | dnl Table 2: droppers | |
2596 | dnl | |
2597 | table=2 priority=10, tcp, action=drop | |
2598 | table=2 priority=0, action=drop | |
2599 | dnl | |
2600 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2601 | dnl | |
74f205f6 | 2602 | table=8,reg2=$3/0xffffffff,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] |
9ac0aada JR |
2603 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] |
2604 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2605 | dnl TPA IP in reg2. | |
2606 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2607 | table=10 priority=100 arp xreg0=0 action=normal | |
2608 | 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]] | |
2609 | table=10 priority=0 action=drop | |
74f205f6 | 2610 | ]) |
9ac0aada JR |
2611 | ]) |
2612 | ||
74f205f6 JS |
2613 | dnl Check that ct(nat,table=foo) works without TCP sequence adjustment. |
2614 | CHECK_FTP_NAT_PRE_RECIRC([], [10.1.1.9], [0x0a010109]) | |
9ac0aada | 2615 | |
74f205f6 JS |
2616 | dnl Check that ct(nat,table=foo) works with TCP sequence adjustment. |
2617 | dnl | |
2618 | dnl The FTP PORT command includes the ASCII representation of the address, | |
2619 | dnl so when these messages need to be NATed between addresses that have | |
2620 | dnl different lengths when represented in ASCII (such as the original address | |
2621 | dnl of 10.1.1.1 used in the test and 10.1.1.240 here), the FTP NAT ALG must | |
2622 | dnl resize the packet and adjust TCP sequence numbers. This test is kept | |
2623 | dnl separate from the above to easier identify issues in this code on different | |
2624 | dnl kernels. | |
2625 | CHECK_FTP_NAT_PRE_RECIRC([seqadj], [10.1.1.240], [0x0a0101f0]) | |
2626 | ||
2627 | dnl CHECK_FTP_NAT_POST_RECIRC(TITLE, IP_ADDR, IP_ADDR_AS_HEX) | |
2628 | dnl | |
2629 | dnl Checks the implementation of conntrack with FTP ALGs in combination with | |
2630 | dnl NAT, with flow tables that implement the NATing after the first round | |
2631 | dnl of recirculation - that is, the first flow ct(table=foo) then a subsequent | |
2632 | dnl flow will implement the NATing with ct(nat..),output:foo. | |
2633 | dnl | |
2634 | dnl IP_ADDR must specify the NAT address in standard "10.1.1.x" format, | |
2635 | dnl and IP_ADDR_AS_HEX must specify the same address as hex, eg 0x0a0101xx. | |
2636 | m4_define([CHECK_FTP_NAT_POST_RECIRC], [dnl | |
2637 | CHECK_FTP_NAT([postrecirc $1], [$2], [dnl | |
9ac0aada JR |
2638 | dnl track all IP traffic (this includes a helper call to non-NEW packets.) |
2639 | table=0 ip, action=ct(table=1) | |
2640 | dnl | |
2641 | dnl ARP | |
2642 | dnl | |
2643 | table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2644 | table=0 priority=10 arp action=normal | |
2645 | table=0 priority=0 action=drop | |
2646 | dnl | |
2647 | dnl Table 1 | |
2648 | dnl | |
2649 | dnl Allow new FTP connections. These need to be commited. | |
2650 | dnl This does helper for new packets. | |
74f205f6 | 2651 | table=1 in_port=1 ct_state=+new, tcp, tp_dst=21, action=ct(alg=ftp,commit,nat(src=$2)),2 |
9ac0aada JR |
2652 | dnl Allow and NAT established TCP connections |
2653 | table=1 in_port=1 ct_state=+est, tcp, action=ct(nat),2 | |
2654 | table=1 in_port=2 ct_state=+est, tcp, action=ct(nat),1 | |
2655 | dnl Allow and NAT (new) related active (data) connections. | |
2656 | dnl These need to be commited. | |
2657 | table=1 in_port=2 ct_state=+new+rel, tcp, action=ct(commit,nat),1 | |
2658 | dnl Allow related ICMP packets. | |
2659 | table=1 in_port=2 ct_state=+rel, icmp, action=ct(nat),1 | |
2660 | dnl Drop everything else. | |
2661 | table=1 priority=0, action=drop | |
2662 | dnl | |
2663 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2664 | dnl | |
74f205f6 | 2665 | table=8,reg2=$3/0xffffffff,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] |
9ac0aada JR |
2666 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] |
2667 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2668 | dnl TPA IP in reg2. | |
2669 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2670 | table=10 priority=100 arp xreg0=0 action=normal | |
2671 | 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]] | |
2672 | table=10 priority=0 action=drop | |
74f205f6 | 2673 | ]) |
9ac0aada JR |
2674 | ]) |
2675 | ||
74f205f6 JS |
2676 | dnl Check that ct(nat,table=foo) works without TCP sequence adjustment. |
2677 | CHECK_FTP_NAT_POST_RECIRC([], [10.1.1.9], [0x0a010109]) | |
9ac0aada | 2678 | |
74f205f6 JS |
2679 | dnl Check that ct(nat,table=foo) works with TCP sequence adjustment. |
2680 | dnl | |
2681 | dnl The FTP PORT command includes the ASCII representation of the address, | |
2682 | dnl so when these messages need to be NATed between addresses that have | |
2683 | dnl different lengths when represented in ASCII (such as the original address | |
2684 | dnl of 10.1.1.1 used in the test and 10.1.1.240 here), the FTP NAT ALG must | |
2685 | dnl resize the packet and adjust TCP sequence numbers. This test is kept | |
2686 | dnl separate from the above to easier identify issues in this code on different | |
2687 | dnl kernels. | |
2688 | CHECK_FTP_NAT_POST_RECIRC([seqadj], [10.1.1.240], [0x0a0101f0]) | |
9ac0aada JR |
2689 | |
2690 | AT_SETUP([conntrack - IPv6 HTTP with NAT]) | |
2691 | CHECK_CONNTRACK() | |
4573c42e | 2692 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2693 | OVS_TRAFFIC_VSWITCHD_START() |
2694 | ||
2695 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2696 | ||
2697 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
2698 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2699 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
2700 | NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::240 lladdr 80:88:88:88:88:88 dev p1]) | |
2701 | ||
2702 | dnl Allow any traffic from ns0->ns1. Only allow nd, return traffic from ns1->ns0. | |
2703 | AT_DATA([flows.txt], [dnl | |
2704 | priority=1,action=drop | |
2705 | priority=10,icmp6,action=normal | |
2706 | priority=100,in_port=1,ip6,action=ct(commit,nat(src=fc00::240)),2 | |
2707 | priority=100,in_port=2,ct_state=-trk,ip6,action=ct(nat,table=0) | |
2708 | priority=100,in_port=2,ct_state=+trk+est,ip6,action=1 | |
2709 | 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 | |
2710 | ]) | |
2711 | ||
2712 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2713 | ||
c10840ff JS |
2714 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
2715 | dnl waiting, we get occasional failures due to the following error: | |
9ac0aada | 2716 | dnl "connect: Cannot assign requested address" |
c10840ff | 2717 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2]) |
9ac0aada JR |
2718 | |
2719 | dnl HTTP requests from ns0->ns1 should work fine. | |
7ed40afe | 2720 | OVS_START_L7([at_ns1], [http6]) |
9ac0aada JR |
2721 | |
2722 | NS_CHECK_EXEC([at_ns0], [wget http://[[fc00::2]] -t 3 -T 1 --retry-connrefused -v -o wget0.log]) | |
2723 | ||
2724 | dnl HTTP requests from ns1->ns0 should fail due to network failure. | |
2725 | dnl Try 3 times, in 1 second intervals. | |
7ed40afe | 2726 | OVS_START_L7([at_ns0], [http6]) |
9ac0aada JR |
2727 | NS_CHECK_EXEC([at_ns1], [wget http://[[fc00::1]] -t 3 -T 1 -v -o wget1.log], [4]) |
2728 | ||
2729 | OVS_TRAFFIC_VSWITCHD_STOP | |
2730 | AT_CLEANUP | |
2731 | ||
2732 | ||
2733 | AT_SETUP([conntrack - IPv6 FTP with NAT]) | |
2734 | AT_SKIP_IF([test $HAVE_PYFTPDLIB = no]) | |
2735 | CHECK_CONNTRACK() | |
4573c42e | 2736 | CHECK_CONNTRACK_NAT() |
9ac0aada JR |
2737 | OVS_TRAFFIC_VSWITCHD_START() |
2738 | ||
2739 | ADD_NAMESPACES(at_ns0, at_ns1) | |
2740 | ||
2741 | ADD_VETH(p0, at_ns0, br0, "fc00::1/96") | |
2742 | NS_CHECK_EXEC([at_ns0], [ip link set dev p0 address 80:88:88:88:88:88]) | |
2743 | ADD_VETH(p1, at_ns1, br0, "fc00::2/96") | |
2744 | dnl Would be nice if NAT could translate neighbor discovery messages, too. | |
2745 | NS_CHECK_EXEC([at_ns1], [ip -6 neigh add fc00::240 lladdr 80:88:88:88:88:88 dev p1]) | |
2746 | ||
2747 | dnl Allow any traffic from ns0->ns1. | |
2748 | dnl Only allow nd, return traffic from ns1->ns0. | |
2749 | AT_DATA([flows.txt], [dnl | |
2750 | dnl Allow other ICMPv6 both ways (without commit). | |
2751 | table=1 priority=100 in_port=1 icmp6, action=2 | |
2752 | table=1 priority=100 in_port=2 icmp6, action=1 | |
2753 | dnl track all IPv6 traffic (this includes NAT & help to non-NEW packets.) | |
2754 | table=0 priority=10 ip6, action=ct(nat,table=1) | |
2755 | table=0 priority=0 action=drop | |
2756 | dnl | |
2757 | dnl Table 1 | |
2758 | dnl | |
2759 | dnl Allow new TCPv6 FTP control connections. | |
2760 | 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 | |
2761 | dnl Allow related TCPv6 connections from port 2 to the NATted address. | |
2762 | table=1 in_port=2 ct_state=+new+rel tcp6 ipv6_dst=fc00::240 action=ct(commit,nat),1 | |
2763 | dnl Allow established TCPv6 connections both ways, enforce NATting | |
2764 | table=1 in_port=1 ct_state=+est tcp6 ipv6_src=fc00::240 action=2 | |
2765 | table=1 in_port=2 ct_state=+est tcp6 ipv6_dst=fc00::1 action=1 | |
2766 | dnl Drop everything else. | |
2767 | table=1 priority=0, action=drop | |
2768 | ]) | |
2769 | ||
2770 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2771 | ||
c10840ff JS |
2772 | dnl Linux seems to take a little time to get its IPv6 stack in order. Without |
2773 | dnl waiting, we get occasional failures due to the following error: | |
2774 | dnl "connect: Cannot assign requested address" | |
2775 | OVS_WAIT_UNTIL([ip netns exec at_ns0 ping6 -c 1 fc00::2 >/dev/null]) | |
2776 | ||
7ed40afe | 2777 | OVS_START_L7([at_ns1], [ftp]) |
9ac0aada JR |
2778 | |
2779 | dnl FTP requests from p0->p1 should work fine. | |
4fee8b13 | 2780 | 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 | 2781 | |
a857bb69 | 2782 | dnl Discards CLOSE_WAIT and CLOSING |
420c73b2 JR |
2783 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(fc00::2)], [0], [dnl |
2784 | 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 | |
2785 | 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 |
2786 | ]) |
2787 | ||
2788 | OVS_TRAFFIC_VSWITCHD_STOP | |
2789 | AT_CLEANUP | |
2c66ebe4 JR |
2790 | |
2791 | AT_SETUP([conntrack - DNAT load balancing]) | |
2792 | CHECK_CONNTRACK() | |
4573c42e | 2793 | CHECK_CONNTRACK_NAT() |
2c66ebe4 JR |
2794 | OVS_TRAFFIC_VSWITCHD_START() |
2795 | ||
2796 | ADD_NAMESPACES(at_ns1, at_ns2, at_ns3, at_ns4) | |
2797 | ||
2798 | ADD_VETH(p1, at_ns1, br0, "10.1.1.1/24") | |
2799 | ADD_VETH(p2, at_ns2, br0, "10.1.1.2/24") | |
2800 | ADD_VETH(p3, at_ns3, br0, "10.1.1.3/24") | |
2801 | ADD_VETH(p4, at_ns4, br0, "10.1.1.4/24") | |
2802 | NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address 80:88:88:88:88:11]) | |
2803 | NS_CHECK_EXEC([at_ns2], [ip link set dev p2 address 80:88:88:88:88:22]) | |
2804 | NS_CHECK_EXEC([at_ns3], [ip link set dev p3 address 80:88:88:88:88:33]) | |
2805 | NS_CHECK_EXEC([at_ns4], [ip link set dev p4 address 80:88:88:88:88:44]) | |
2806 | ||
2807 | dnl Select group for load balancing. One bucket per server. Each bucket | |
2808 | dnl tracks and NATs the connection and recirculates to table 4 for egress | |
2809 | dnl routing. Packets of existing connections are always NATted based on | |
2810 | dnl connection state, only new connections are NATted according to the | |
2811 | dnl specific NAT parameters in each bucket. | |
2812 | 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)"]) | |
2813 | ||
2814 | AT_DATA([flows.txt], [dnl | |
2815 | dnl Track connections to the virtual IP address. | |
2816 | table=0 priority=100 ip nw_dst=10.1.1.64 action=group:234 | |
2817 | dnl All other IP traffic is allowed but the connection state is no commited. | |
2818 | table=0 priority=90 ip action=ct(table=4,nat) | |
2819 | dnl | |
2820 | dnl Allow ARP, but generate responses for virtual addresses | |
2821 | table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2822 | table=0 priority=10 arp action=normal | |
2823 | table=0 priority=0 action=drop | |
2824 | dnl | |
2825 | dnl Routing table | |
2826 | dnl | |
2827 | table=4,ip,nw_dst=10.1.1.1 action=mod_dl_dst:80:88:88:88:88:11,output:1 | |
2828 | table=4,ip,nw_dst=10.1.1.2 action=mod_dl_dst:80:88:88:88:88:22,output:2 | |
2829 | table=4,ip,nw_dst=10.1.1.3 action=mod_dl_dst:80:88:88:88:88:33,output:3 | |
2830 | table=4,ip,nw_dst=10.1.1.4 action=mod_dl_dst:80:88:88:88:88:44,output:4 | |
2831 | table=4 priority=0 action=drop | |
2832 | dnl | |
2833 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2834 | table=8,reg2=0x0a010140,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2835 | dnl Zero result means not found. | |
2836 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2837 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2838 | dnl TPA IP in reg2. | |
2839 | table=10 priority=100 arp xreg0=0 action=normal | |
2840 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2841 | 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]] | |
2842 | table=10 priority=0 action=controller | |
2843 | ]) | |
2844 | ||
2845 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2846 | ||
2847 | dnl Start web servers | |
7ed40afe JS |
2848 | OVS_START_L7([at_ns2], [http]) |
2849 | OVS_START_L7([at_ns3], [http]) | |
2850 | OVS_START_L7([at_ns4], [http]) | |
2c66ebe4 JR |
2851 | |
2852 | on_exit 'ovs-ofctl -O OpenFlow15 dump-flows br0' | |
2853 | on_exit 'ovs-appctl revalidator/purge' | |
2854 | on_exit 'ovs-appctl dpif/dump-flows br0' | |
2855 | ||
2856 | dnl Should work with the virtual IP address through NAT | |
2857 | for i in 1 2 3 4 5 6 7 8 9 10 11 12; do | |
2858 | echo Request $i | |
2859 | NS_CHECK_EXEC([at_ns1], [wget 10.1.1.64 -t 5 -T 1 --retry-connrefused -v -o wget$i.log]) | |
2860 | done | |
2861 | ||
2862 | dnl Each server should have at least one connection. | |
420c73b2 JR |
2863 | AT_CHECK([ovs-appctl dpctl/dump-conntrack | FORMAT_CT(10.1.1.64)], [0], [dnl |
2864 | 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>) | |
2865 | 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>) | |
2866 | 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 |
2867 | ]) |
2868 | ||
2869 | ovs-appctl dpif/dump-flows br0 | |
2870 | ovs-appctl revalidator/purge | |
2871 | ovs-ofctl -O OpenFlow15 dump-flows br0 | |
2872 | ovs-ofctl -O OpenFlow15 dump-group-stats br0 | |
2873 | ||
2874 | OVS_TRAFFIC_VSWITCHD_STOP | |
2875 | AT_CLEANUP | |
2876 | ||
2877 | ||
2878 | AT_SETUP([conntrack - DNAT load balancing with NC]) | |
9c1ab985 | 2879 | AT_SKIP_IF([test $HAVE_NC = no]) |
2c66ebe4 | 2880 | CHECK_CONNTRACK() |
4573c42e | 2881 | CHECK_CONNTRACK_NAT() |
2c66ebe4 JR |
2882 | OVS_TRAFFIC_VSWITCHD_START() |
2883 | ||
2884 | ADD_NAMESPACES(at_ns1, at_ns2, at_ns3, at_ns4, at_ns5) | |
2885 | ||
2886 | ADD_VETH(p1, at_ns1, br0, "10.1.1.1/24") | |
2887 | ADD_VETH(p2, at_ns2, br0, "10.1.1.2/24") | |
2888 | ADD_VETH(p3, at_ns3, br0, "10.1.1.3/24") | |
2889 | ADD_VETH(p4, at_ns4, br0, "10.1.1.4/24") | |
2890 | ADD_VETH(p5, at_ns5, br0, "10.1.1.5/24") | |
2891 | NS_CHECK_EXEC([at_ns1], [ip link set dev p1 address 80:88:88:88:88:11]) | |
2892 | NS_CHECK_EXEC([at_ns2], [ip link set dev p2 address 80:88:88:88:88:22]) | |
2893 | NS_CHECK_EXEC([at_ns3], [ip link set dev p3 address 80:88:88:88:88:33]) | |
2894 | NS_CHECK_EXEC([at_ns4], [ip link set dev p4 address 80:88:88:88:88:44]) | |
2895 | NS_CHECK_EXEC([at_ns5], [ip link set dev p5 address 80:88:88:88:88:55]) | |
2896 | ||
2897 | dnl Select group for load balancing. One bucket per server. Each bucket | |
2898 | dnl tracks and NATs the connection and recirculates to table 4 for egress | |
2899 | dnl routing. Packets of existing connections are always NATted based on | |
2900 | dnl connection state, only new connections are NATted according to the | |
2901 | dnl specific NAT parameters in each bucket. | |
2902 | 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)"]) | |
2903 | ||
2904 | AT_DATA([flows.txt], [dnl | |
2905 | dnl Track connections to the virtual IP address. | |
2906 | table=0 priority=100 ip nw_dst=10.1.1.64 action=group:234 | |
2907 | dnl All other IP traffic is allowed but the connection state is no commited. | |
2908 | table=0 priority=90 ip action=ct(table=4,nat) | |
2909 | dnl | |
2910 | dnl Allow ARP, but generate responses for virtual addresses | |
2911 | table=0 priority=100 arp arp_op=1 action=move:OXM_OF_ARP_TPA[[]]->NXM_NX_REG2[[]],resubmit(,8),goto_table:10 | |
2912 | table=0 priority=10 arp action=normal | |
2913 | table=0 priority=0 action=drop | |
2914 | dnl | |
2915 | dnl Routing table | |
2916 | dnl | |
2917 | table=4,ip,nw_dst=10.1.1.1 action=mod_dl_dst:80:88:88:88:88:11,output:1 | |
2918 | table=4,ip,nw_dst=10.1.1.2 action=mod_dl_dst:80:88:88:88:88:22,output:2 | |
2919 | table=4,ip,nw_dst=10.1.1.3 action=mod_dl_dst:80:88:88:88:88:33,output:3 | |
2920 | table=4,ip,nw_dst=10.1.1.4 action=mod_dl_dst:80:88:88:88:88:44,output:4 | |
2921 | table=4,ip,nw_dst=10.1.1.5 action=mod_dl_dst:80:88:88:88:88:55,output:5 | |
2922 | table=4 priority=0 action=drop | |
2923 | dnl | |
2924 | dnl MAC resolution table for IP in reg2, stores mac in OXM_OF_PKT_REG0 | |
2925 | table=8,reg2=0x0a010140,action=load:0x808888888888->OXM_OF_PKT_REG0[[]] | |
2926 | dnl Zero result means not found. | |
2927 | table=8,priority=0,action=load:0->OXM_OF_PKT_REG0[[]] | |
2928 | dnl ARP responder mac filled in at OXM_OF_PKT_REG0, or 0 for normal action. | |
2929 | dnl TPA IP in reg2. | |
2930 | table=10 priority=100 arp xreg0=0 action=normal | |
2931 | dnl Swaps the fields of the ARP message to turn a query to a response. | |
2932 | 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]] | |
2933 | table=10 priority=0 action=controller | |
2934 | ]) | |
2935 | ||
2936 | AT_CHECK([ovs-ofctl --bundle add-flows br0 flows.txt]) | |
2937 | ||
2938 | dnl Start web servers | |
7ed40afe JS |
2939 | OVS_START_L7([at_ns2], [http]) |
2940 | OVS_START_L7([at_ns3], [http]) | |
2941 | OVS_START_L7([at_ns4], [http]) | |
2c66ebe4 JR |
2942 | |
2943 | on_exit 'ovs-ofctl -O OpenFlow15 dump-flows br0' | |
2944 | on_exit 'ovs-appctl revalidator/purge' | |
2945 | on_exit 'ovs-appctl dpif/dump-flows br0' | |
2946 | ||
2947 | sleep 5 | |
2948 | ||
2949 | dnl Should work with the virtual IP address through NAT | |
2950 | for i in 1 2 3 4 5 6 7 8 9; do | |
2951 | echo Request $i | |
2952 | NS_CHECK_EXEC([at_ns1], [echo "TEST1" | nc -p 4100$i 10.1.1.64 80 > nc-1-$i.log]) | |
2953 | NS_CHECK_EXEC([at_ns5], [echo "TEST5" | nc -p 4100$i 10.1.1.64 80 > nc-5-$i.log]) | |
2954 | done | |
2955 | ||
2956 | conntrack -L 2>&1 | |
2957 | ||
2958 | ovs-appctl dpif/dump-flows br0 | |
2959 | ovs-appctl revalidator/purge | |
2960 | ovs-ofctl -O OpenFlow15 dump-flows br0 | |
2961 | ovs-ofctl -O OpenFlow15 dump-group-stats br0 | |
2962 | ||
2963 | OVS_TRAFFIC_VSWITCHD_STOP | |
2964 | AT_CLEANUP |