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